2021-08-04 23:31:54 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
import { SvelteComponent } from 'svelte'
|
2021-09-09 07:34:51 +00:00
|
|
|
import type { AnySvelteComponent, AnyComponent, PopupAlignment, LabelAndProps, TooltipAligment } from './types'
|
|
|
|
import type { IntlString } from '@anticrm/platform'
|
2021-08-04 23:31:54 +00:00
|
|
|
|
|
|
|
import Root from './components/internal/Root.svelte'
|
|
|
|
|
2021-09-09 07:34:51 +00:00
|
|
|
export type { AnyComponent, AnySvelteComponent, Action, LabelAndProps, TooltipAligment } from './types'
|
2021-08-04 23:31:54 +00:00
|
|
|
// export { applicationShortcutKey } from './utils'
|
|
|
|
export { getCurrentLocation, navigate, location } from './location'
|
|
|
|
|
|
|
|
export { default as EditBox } from './components/EditBox.svelte'
|
|
|
|
export { default as Label } from './components/Label.svelte'
|
|
|
|
export { default as Button } from './components/Button.svelte'
|
|
|
|
export { default as StatusControl } from './components/StatusControl.svelte'
|
|
|
|
export { default as Component } from './components/Component.svelte'
|
|
|
|
export { default as Icon } from './components/Icon.svelte'
|
|
|
|
export { default as ActionIcon } from './components/ActionIcon.svelte'
|
|
|
|
export { default as Toggle } from './components/Toggle.svelte'
|
|
|
|
export { default as Dialog } from './components/Dialog.svelte'
|
|
|
|
export { default as ToggleWithLabel } from './components/ToggleWithLabel.svelte'
|
|
|
|
export { default as Tooltip } from './components/Tooltip.svelte'
|
2021-09-09 07:34:51 +00:00
|
|
|
export { default as TooltipInstance } from './components/TooltipInstance.svelte'
|
2021-08-04 23:31:54 +00:00
|
|
|
export { default as CheckBox } from './components/CheckBox.svelte'
|
|
|
|
export { default as Progress } from './components/Progress.svelte'
|
|
|
|
export { default as Tabs } from './components/Tabs.svelte'
|
|
|
|
export { default as ScrollBox } from './components/ScrollBox.svelte'
|
|
|
|
export { default as PopupMenu } from './components/PopupMenu.svelte'
|
|
|
|
export { default as PopupItem } from './components/PopupItem.svelte'
|
|
|
|
export { default as SelectItem } from './components/SelectItem.svelte'
|
|
|
|
export { default as TextArea } from './components/TextArea.svelte'
|
|
|
|
export { default as Section } from './components/Section.svelte'
|
|
|
|
export { default as DatePicker } from './components/DatePicker.svelte'
|
2021-08-05 16:27:51 +00:00
|
|
|
export { default as StylishEdit } from './components/StylishEdit.svelte'
|
2021-08-04 23:31:54 +00:00
|
|
|
export { default as Grid } from './components/Grid.svelte'
|
|
|
|
export { default as Row } from './components/Row.svelte'
|
|
|
|
export { default as CheckBoxWithLabel } from './components/CheckBoxWithLabel.svelte'
|
|
|
|
export { default as CheckBoxList } from './components/CheckBoxList.svelte'
|
2021-08-06 06:49:54 +00:00
|
|
|
export { default as EditWithIcon } from './components/EditWithIcon.svelte'
|
2021-08-10 10:53:24 +00:00
|
|
|
export { default as Loading } from './components/Loading.svelte'
|
2021-08-19 12:54:06 +00:00
|
|
|
export { default as Popup } from './components/Popup.svelte'
|
2021-08-28 10:06:28 +00:00
|
|
|
export { default as CircleButton } from './components/CircleButton.svelte'
|
2021-08-30 17:19:58 +00:00
|
|
|
export { default as Link } from './components/Link.svelte'
|
2021-08-04 23:31:54 +00:00
|
|
|
|
|
|
|
export { default as IconAdd } from './components/icons/Add.svelte'
|
2021-08-30 07:17:26 +00:00
|
|
|
export { default as IconClose } from './components/icons/Close.svelte'
|
2021-08-04 23:31:54 +00:00
|
|
|
export { default as IconSearch } from './components/icons/Search.svelte'
|
|
|
|
export { default as IconToDo } from './components/icons/ToDo.svelte'
|
|
|
|
export { default as IconComments } from './components/icons/Comments.svelte'
|
2021-09-03 15:39:10 +00:00
|
|
|
export { default as IconFolder } from './components/icons/Folder.svelte'
|
2021-09-06 16:00:43 +00:00
|
|
|
export { default as IconMoreH } from './components/icons/MoreH.svelte'
|
|
|
|
export { default as IconFile } from './components/icons/File.svelte'
|
2021-09-07 07:48:41 +00:00
|
|
|
export { default as IconAttachment } from './components/icons/Attachment.svelte'
|
|
|
|
export { default as IconThread } from './components/icons/Thread.svelte'
|
2021-08-04 23:31:54 +00:00
|
|
|
|
2021-08-24 17:06:19 +00:00
|
|
|
export * from './utils'
|
|
|
|
|
2021-08-18 09:37:15 +00:00
|
|
|
import { writable } from 'svelte/store'
|
|
|
|
|
2021-08-04 23:31:54 +00:00
|
|
|
export function createApp (target: HTMLElement): SvelteComponent {
|
|
|
|
return new Root({ target })
|
|
|
|
}
|
|
|
|
|
|
|
|
interface CompAndProps {
|
|
|
|
is: AnySvelteComponent | AnyComponent | undefined
|
|
|
|
props: any
|
2021-09-01 16:31:05 +00:00
|
|
|
element?: PopupAlignment
|
2021-09-01 12:38:22 +00:00
|
|
|
onClose?: (result: any) => void
|
2021-08-04 23:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const store = writable<CompAndProps>({
|
|
|
|
is: undefined,
|
|
|
|
props: {},
|
|
|
|
})
|
|
|
|
|
2021-08-31 17:07:28 +00:00
|
|
|
export const popupstore = writable<CompAndProps[]>([])
|
2021-08-19 12:54:06 +00:00
|
|
|
|
2021-09-01 16:31:05 +00:00
|
|
|
export function showPopup (component: AnySvelteComponent | AnyComponent, props: any, element?: PopupAlignment, onClose?: (result: any) => void): void {
|
2021-08-31 17:07:28 +00:00
|
|
|
popupstore.update(popups => {
|
2021-09-01 12:38:22 +00:00
|
|
|
popups.push({ is: component, props, element, onClose })
|
2021-08-31 17:07:28 +00:00
|
|
|
return popups
|
|
|
|
})
|
2021-08-19 12:54:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function closePopup (): void {
|
2021-08-31 17:07:28 +00:00
|
|
|
popupstore.update(popups => {
|
|
|
|
popups.pop()
|
|
|
|
return popups
|
|
|
|
})
|
2021-08-19 12:54:06 +00:00
|
|
|
}
|
2021-09-09 07:34:51 +00:00
|
|
|
|
|
|
|
export const tooltipstore = writable<LabelAndProps>({
|
|
|
|
label: undefined,
|
|
|
|
element: undefined,
|
|
|
|
direction: undefined
|
|
|
|
})
|
|
|
|
|
|
|
|
export function showTooltip (label: IntlString, element: HTMLElement, direction?: TooltipAligment): void {
|
|
|
|
tooltipstore.set({ label: label, element: element, direction: direction })
|
|
|
|
}
|
|
|
|
|
|
|
|
export function closeTooltip (): void {
|
|
|
|
tooltipstore.set({ label: undefined, element: undefined, direction: undefined })
|
|
|
|
}
|