fuma 2.0.49 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/index.d.ts +2 -5
- package/dist/action/index.js +2 -5
- package/dist/action/list/handlers.d.ts +6 -6
- package/dist/action/list/handlers.js +6 -5
- package/dist/action/list/index.d.ts +1 -1
- package/dist/action/list/index.js +11 -5
- package/dist/action/list/trigger.js +6 -2
- package/dist/action/list/utils.js +1 -1
- package/dist/action/tip.js +2 -2
- package/dist/command/command.svelte.d.ts +16 -0
- package/dist/command/command.svelte.js +68 -0
- package/dist/command/index.d.ts +1 -0
- package/dist/command/index.js +1 -0
- package/dist/data.d.ts +87 -0
- package/dist/data.js +51 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/input/InputBoolean.svelte +107 -0
- package/dist/input/InputBoolean.svelte.d.ts +12 -0
- package/dist/input/InputNumber.svelte +33 -0
- package/dist/input/InputNumber.svelte.d.ts +10 -0
- package/dist/input/InputRadio.svelte +56 -0
- package/dist/input/InputRadio.svelte.d.ts +11 -0
- package/dist/input/InputRange.svelte +30 -0
- package/dist/input/InputRange.svelte.d.ts +10 -0
- package/dist/input/InputRelation.svelte +119 -0
- package/dist/input/InputRelation.svelte.d.ts +39 -0
- package/dist/input/InputSelect.svelte +113 -0
- package/dist/input/InputSelect.svelte.d.ts +37 -0
- package/dist/input/InputSelectNative.svelte +56 -0
- package/dist/input/InputSelectNative.svelte.d.ts +12 -0
- package/dist/input/InputString.svelte +48 -0
- package/dist/input/InputString.svelte.d.ts +11 -0
- package/dist/input/InputTextarea.svelte +47 -0
- package/dist/input/InputTextarea.svelte.d.ts +11 -0
- package/dist/input/Issues.svelte +21 -0
- package/dist/input/Issues.svelte.d.ts +7 -0
- package/dist/input/index.d.ts +11 -0
- package/dist/input/index.js +10 -0
- package/dist/input/type.d.ts +5 -0
- package/dist/input/type.js +1 -0
- package/dist/popover/Popover.svelte +50 -0
- package/dist/popover/index.d.ts +2 -0
- package/dist/popover/index.js +2 -0
- package/dist/popover/popover.svelte.d.ts +26 -0
- package/dist/popover/popover.svelte.js +101 -0
- package/dist/remote/useForm.d.ts +6 -0
- package/dist/remote/useForm.js +22 -0
- package/dist/search/Spans.svelte +15 -0
- package/dist/search/Spans.svelte.d.ts +7 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +2 -0
- package/dist/search/search.js +96 -0
- package/dist/server/index.d.ts +0 -4
- package/dist/server/index.js +0 -4
- package/dist/server/parseQuery.js +1 -1
- package/dist/server/sse.js +4 -4
- package/dist/server/table.js +1 -1
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.js +1 -0
- package/dist/state/param.svelte.d.ts +18 -0
- package/dist/state/param.svelte.js +66 -0
- package/dist/ui/button/ButtonDelete.svelte +49 -28
- package/dist/ui/button/ButtonDelete.svelte.d.ts +12 -31
- package/dist/ui/button/index.d.ts +0 -1
- package/dist/ui/button/index.js +0 -1
- package/dist/ui/copy/ButtonCopy.svelte +43 -0
- package/dist/ui/copy/ButtonCopy.svelte.d.ts +17 -0
- package/dist/ui/copy/index.d.ts +2 -0
- package/dist/ui/copy/index.js +2 -0
- package/dist/ui/copy/useCopy.svelte.d.ts +10 -0
- package/dist/ui/copy/useCopy.svelte.js +36 -0
- package/dist/ui/dialog/Dialog.svelte +56 -26
- package/dist/ui/dialog/Dialog.svelte.d.ts +14 -35
- package/dist/ui/dialog/index.d.ts +0 -1
- package/dist/ui/dialog/index.js +0 -1
- package/dist/ui/drawer/Drawer.svelte +53 -45
- package/dist/ui/drawer/Drawer.svelte.d.ts +8 -63
- package/dist/ui/drawer/drawerFly.js +1 -1
- package/dist/ui/drawer/useLayer.svelte.d.ts +5 -0
- package/dist/ui/drawer/useLayer.svelte.js +33 -0
- package/dist/ui/index.d.ts +4 -12
- package/dist/ui/index.js +4 -12
- package/dist/ui/menu/ContextMenu.svelte +27 -26
- package/dist/ui/menu/ContextMenu.svelte.d.ts +9 -35
- package/dist/ui/menu/DropDown.svelte +44 -26
- package/dist/ui/menu/DropDown.svelte.d.ts +18 -43
- package/dist/ui/menu/DropDownMenu.svelte +51 -41
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +7 -29
- package/dist/ui/menu/dropdown.css +4 -4
- package/dist/ui/menu/index.d.ts +1 -1
- package/dist/ui/menu/index.js +2 -1
- package/dist/ui/mode/ToggleMode.svelte +25 -14
- package/dist/ui/mode/ToggleMode.svelte.d.ts +10 -35
- package/dist/ui/mode/index.d.ts +1 -1
- package/dist/ui/mode/index.js +1 -1
- package/dist/ui/mode/useMode.svelte.d.ts +8 -0
- package/dist/ui/mode/useMode.svelte.js +40 -0
- package/dist/ui/pagination/Pagination.svelte +18 -14
- package/dist/ui/pagination/Pagination.svelte.d.ts +4 -18
- package/dist/ui/range/RangePicker.svelte +3 -2
- package/dist/ui/range/RangePickerButton.svelte +49 -37
- package/dist/ui/range/RangePickerButton.svelte.d.ts +7 -21
- package/dist/ui/range/index.d.ts +1 -1
- package/dist/ui/range/index.js +1 -1
- package/dist/ui/table/Table.svelte +15 -21
- package/dist/ui/table/Table.svelte.d.ts +1 -1
- package/dist/ui/table/TableBody.svelte +1 -1
- package/dist/ui/table/TableBody.svelte.d.ts +1 -1
- package/dist/ui/table/TableFieldsEdition.svelte +90 -78
- package/dist/ui/table/TableFieldsEdition.svelte.d.ts +14 -13
- package/dist/ui/table/TableHead.svelte +1 -1
- package/dist/ui/table/TableViewSelect.svelte +69 -69
- package/dist/ui/table/TableViewSelect.svelte.d.ts +10 -23
- package/dist/ui/table/cell/TableCellArray.svelte +1 -1
- package/dist/ui/table/cell/TableCellBoolean.svelte +3 -4
- package/dist/ui/table/cell/index.d.ts +1 -1
- package/dist/ui/table/cell/index.js +1 -1
- package/dist/ui/table/head/OrderButtons.svelte +18 -13
- package/dist/ui/table/head/OrderButtons.svelte.d.ts +11 -23
- package/dist/ui/table/head/TableHeadBoolean.svelte +3 -3
- package/dist/ui/table/head/TableHeadDate.svelte +41 -53
- package/dist/ui/table/head/TableHeadDate.svelte.d.ts +1 -1
- package/dist/ui/table/head/TableHeadDefault.svelte +2 -1
- package/dist/ui/table/head/TableHeadNumber.svelte +94 -108
- package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadSelect.svelte +55 -52
- package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadString.svelte +28 -34
- package/dist/ui/table/head/index.d.ts +3 -3
- package/dist/ui/table/head/index.js +3 -3
- package/dist/ui/table/index.d.ts +5 -5
- package/dist/ui/table/index.js +4 -5
- package/dist/utils/csv.js +1 -1
- package/dist/utils/eventEmitter.d.ts +2 -2
- package/dist/utils/eventEmitter.js +18 -11
- package/dist/utils/index.d.ts +4 -6
- package/dist/utils/index.js +4 -6
- package/dist/utils/normalizePath.js +1 -1
- package/dist/utils/options.d.ts +6 -5
- package/dist/utils/options.js +3 -2
- package/dist/utils/tippy.d.ts +1 -1
- package/dist/utils/tippy.js +1 -1
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +0 -1
- package/dist/validation/zod.d.ts +12 -393
- package/dist/validation/zod.js +22 -82
- package/package.json +111 -134
- package/dist/action/heightScreen.d.ts +0 -10
- package/dist/action/heightScreen.js +0 -24
- package/dist/action/portal.d.ts +0 -3
- package/dist/action/portal.js +0 -9
- package/dist/action/selector.d.ts +0 -15
- package/dist/action/selector.js +0 -71
- package/dist/api/client.d.ts +0 -3
- package/dist/api/client.js +0 -24
- package/dist/api/config.d.ts +0 -46
- package/dist/api/config.js +0 -7
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.js +0 -3
- package/dist/api/server.d.ts +0 -11
- package/dist/api/server.js +0 -17
- package/dist/private/Meta.svelte +0 -16
- package/dist/private/Meta.svelte.d.ts +0 -30
- package/dist/private/api.d.ts +0 -61
- package/dist/private/api.js +0 -10
- package/dist/private/constant.d.ts +0 -14
- package/dist/private/constant.js +0 -6
- package/dist/private/model.d.ts +0 -70
- package/dist/private/model.js +0 -25
- package/dist/private/prisma.d.ts +0 -2
- package/dist/private/prisma.js +0 -2
- package/dist/private/store.d.ts +0 -1
- package/dist/private/store.js +0 -2
- package/dist/server/auth.d.ts +0 -12
- package/dist/server/auth.js +0 -15
- package/dist/server/formAction.d.ts +0 -13
- package/dist/server/formAction.js +0 -8
- package/dist/server/json.d.ts +0 -1
- package/dist/server/json.js +0 -16
- package/dist/server/parseFormData.d.ts +0 -10
- package/dist/server/parseFormData.js +0 -85
- package/dist/server/try.d.ts +0 -9
- package/dist/server/try.js +0 -41
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.js +0 -2
- package/dist/store/isSmallScreen.d.ts +0 -1
- package/dist/store/isSmallScreen.js +0 -14
- package/dist/store/param.d.ts +0 -22
- package/dist/store/param.js +0 -61
- package/dist/store/session.d.ts +0 -1
- package/dist/store/session.js +0 -13
- package/dist/ui/badge/Badge.svelte +0 -9
- package/dist/ui/badge/Badge.svelte.d.ts +0 -21
- package/dist/ui/badge/index.d.ts +0 -1
- package/dist/ui/badge/index.js +0 -1
- package/dist/ui/button/ButtonCopy.svelte +0 -59
- package/dist/ui/button/ButtonCopy.svelte.d.ts +0 -27
- package/dist/ui/card/Card.svelte +0 -43
- package/dist/ui/card/Card.svelte.d.ts +0 -41
- package/dist/ui/card/CardBasic.svelte +0 -15
- package/dist/ui/card/CardBasic.svelte.d.ts +0 -31
- package/dist/ui/card/CardCollapse.svelte +0 -71
- package/dist/ui/card/CardCollapse.svelte.d.ts +0 -39
- package/dist/ui/card/CardFullScreen.svelte +0 -31
- package/dist/ui/card/CardFullScreen.svelte.d.ts +0 -38
- package/dist/ui/card/CardLink.svelte +0 -22
- package/dist/ui/card/CardLink.svelte.d.ts +0 -31
- package/dist/ui/card/index.d.ts +0 -5
- package/dist/ui/card/index.js +0 -5
- package/dist/ui/context.d.ts +0 -6
- package/dist/ui/context.js +0 -12
- package/dist/ui/dialog/DialogConfirm.svelte +0 -24
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +0 -35
- package/dist/ui/drawer/layers.d.ts +0 -7
- package/dist/ui/drawer/layers.js +0 -68
- package/dist/ui/form/Form.svelte +0 -168
- package/dist/ui/form/Form.svelte.d.ts +0 -62
- package/dist/ui/form/FormInput.svelte +0 -15
- package/dist/ui/form/FormSection.svelte +0 -78
- package/dist/ui/form/FormSection.svelte.d.ts +0 -39
- package/dist/ui/form/form.d.ts +0 -37
- package/dist/ui/form/form.js +0 -57
- package/dist/ui/form/formInput.js +0 -33
- package/dist/ui/form/index.d.ts +0 -3
- package/dist/ui/form/index.js +0 -3
- package/dist/ui/icon/Icon.svelte +0 -53
- package/dist/ui/icon/Icon.svelte.d.ts +0 -29
- package/dist/ui/icon/index.d.ts +0 -1
- package/dist/ui/icon/index.js +0 -1
- package/dist/ui/input/FormControl.svelte +0 -77
- package/dist/ui/input/FormControl.svelte.d.ts +0 -34
- package/dist/ui/input/InputBoolean.svelte +0 -33
- package/dist/ui/input/InputBoolean.svelte.d.ts +0 -46
- package/dist/ui/input/InputCheckboxs.svelte +0 -71
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +0 -57
- package/dist/ui/input/InputCheckboxsMenu.svelte +0 -106
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +0 -59
- package/dist/ui/input/InputCheckboxsTree.svelte +0 -18
- package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +0 -25
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +0 -68
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +0 -27
- package/dist/ui/input/InputCombo.svelte +0 -99
- package/dist/ui/input/InputCombo.svelte.d.ts +0 -59
- package/dist/ui/input/InputDate.svelte +0 -47
- package/dist/ui/input/InputDate.svelte.d.ts +0 -46
- package/dist/ui/input/InputDateTime.svelte +0 -41
- package/dist/ui/input/InputDateTime.svelte.d.ts +0 -23
- package/dist/ui/input/InputImage.svelte +0 -116
- package/dist/ui/input/InputImage.svelte.d.ts +0 -48
- package/dist/ui/input/InputImagePreview.svelte +0 -60
- package/dist/ui/input/InputImagePreview.svelte.d.ts +0 -27
- package/dist/ui/input/InputNumber.svelte +0 -31
- package/dist/ui/input/InputNumber.svelte.d.ts +0 -23
- package/dist/ui/input/InputOptionInParam.svelte +0 -36
- package/dist/ui/input/InputOptionInParam.svelte.d.ts +0 -24
- package/dist/ui/input/InputOptions.svelte +0 -85
- package/dist/ui/input/InputOptions.svelte.d.ts +0 -21
- package/dist/ui/input/InputPassword.svelte +0 -25
- package/dist/ui/input/InputPassword.svelte.d.ts +0 -45
- package/dist/ui/input/InputRadio.svelte +0 -84
- package/dist/ui/input/InputRadio.svelte.d.ts +0 -56
- package/dist/ui/input/InputRelation.svelte +0 -171
- package/dist/ui/input/InputRelation.svelte.d.ts +0 -76
- package/dist/ui/input/InputRelations.svelte +0 -166
- package/dist/ui/input/InputRelations.svelte.d.ts +0 -55
- package/dist/ui/input/InputSearch.svelte +0 -59
- package/dist/ui/input/InputSearch.svelte.d.ts +0 -29
- package/dist/ui/input/InputSelect.svelte +0 -84
- package/dist/ui/input/InputSelect.svelte.d.ts +0 -29
- package/dist/ui/input/InputText.svelte +0 -46
- package/dist/ui/input/InputText.svelte.d.ts +0 -30
- package/dist/ui/input/InputTextarea.svelte +0 -23
- package/dist/ui/input/InputTextarea.svelte.d.ts +0 -23
- package/dist/ui/input/InputTime.svelte +0 -47
- package/dist/ui/input/InputTime.svelte.d.ts +0 -46
- package/dist/ui/input/RelationAfter.svelte +0 -34
- package/dist/ui/input/RelationAfter.svelte.d.ts +0 -26
- package/dist/ui/input/SelectorList.svelte +0 -50
- package/dist/ui/input/SelectorList.svelte.d.ts +0 -49
- package/dist/ui/input/action.d.ts +0 -13
- package/dist/ui/input/action.js +0 -56
- package/dist/ui/input/index.d.ts +0 -26
- package/dist/ui/input/index.js +0 -26
- package/dist/ui/input/textRich/InputTextRich.svelte +0 -72
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +0 -48
- package/dist/ui/input/textRich/SuggesionList.svelte +0 -25
- package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMark.svelte +0 -22
- package/dist/ui/input/textRich/ToolMark.svelte.d.ts +0 -25
- package/dist/ui/input/textRich/ToolMarkColor.svelte +0 -36
- package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMarkLink.svelte +0 -72
- package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenu.svelte +0 -66
- package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +0 -33
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +0 -50
- package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +0 -54
- package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMenuNode.svelte +0 -60
- package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolsBar.svelte +0 -61
- package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +0 -24
- package/dist/ui/input/textRich/extensions.d.ts +0 -2
- package/dist/ui/input/textRich/extensions.js +0 -62
- package/dist/ui/input/textRich/indent.d.ts +0 -13
- package/dist/ui/input/textRich/indent.js +0 -112
- package/dist/ui/input/textRich/index.d.ts +0 -3
- package/dist/ui/input/textRich/index.js +0 -3
- package/dist/ui/input/textRich/suggestion.d.ts +0 -7
- package/dist/ui/input/textRich/suggestion.js +0 -55
- package/dist/ui/input/textRich/tiptapParser.d.ts +0 -4
- package/dist/ui/input/textRich/tiptapParser.js +0 -29
- package/dist/ui/input/types.d.ts +0 -15
- package/dist/ui/input/types.js +0 -1
- package/dist/ui/login/Login.svelte +0 -99
- package/dist/ui/login/Login.svelte.d.ts +0 -20
- package/dist/ui/login/index.d.ts +0 -1
- package/dist/ui/login/index.js +0 -1
- package/dist/ui/placeholder/Placeholder.svelte +0 -12
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +0 -30
- package/dist/ui/placeholder/PlaceholderImage.svelte +0 -16
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +0 -30
- package/dist/ui/placeholder/index.d.ts +0 -2
- package/dist/ui/placeholder/index.js +0 -2
- package/dist/ui/tabs/Tabs.svelte +0 -32
- package/dist/ui/tabs/Tabs.svelte.d.ts +0 -22
- package/dist/ui/tabs/TabsIcon.svelte +0 -60
- package/dist/ui/tabs/TabsIcon.svelte.d.ts +0 -24
- package/dist/ui/tabs/index.d.ts +0 -8
- package/dist/ui/tabs/index.js +0 -2
- package/dist/utils/avatar.d.ts +0 -1
- package/dist/utils/avatar.js +0 -5
- package/dist/utils/component.d.ts +0 -6
- package/dist/utils/component.js +0 -3
- package/dist/validation/form.d.ts +0 -34
- package/dist/validation/form.js +0 -103
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type Alignement = 'start' | 'end';
|
|
2
|
+
type Position = 'left' | 'right' | 'top' | 'bottom';
|
|
3
|
+
export type Placement = Position | `${Position}-${Alignement}`;
|
|
4
|
+
export type PopoverType = ReturnType<typeof usePopover>;
|
|
5
|
+
export type PopoverOptions = {
|
|
6
|
+
mode?: 'auto' | 'hint' | 'manual';
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
listenClick?: boolean;
|
|
9
|
+
listenFocus?: boolean;
|
|
10
|
+
listenHover?: boolean;
|
|
11
|
+
/** Only when listenHover={true} */
|
|
12
|
+
hideDelay?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function usePopover({ mode, placement, listenClick, listenFocus, listenHover, hideDelay }?: PopoverOptions): {
|
|
15
|
+
show: () => void;
|
|
16
|
+
hide: () => void;
|
|
17
|
+
readonly isOpen: boolean;
|
|
18
|
+
content: {
|
|
19
|
+
[x: symbol]: (node: HTMLElement) => () => void;
|
|
20
|
+
popover: "auto" | "hint" | "manual";
|
|
21
|
+
};
|
|
22
|
+
trigger: {
|
|
23
|
+
[x: symbol]: (node: HTMLElement) => () => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import debounce from 'debounce';
|
|
2
|
+
import { createAttachmentKey } from 'svelte/attachments';
|
|
3
|
+
import { on } from 'svelte/events';
|
|
4
|
+
const placements = {
|
|
5
|
+
top: 'top',
|
|
6
|
+
'top-end': 'top span-left',
|
|
7
|
+
'top-start': 'top span-right',
|
|
8
|
+
bottom: 'bottom',
|
|
9
|
+
'bottom-end': 'bottom span-left',
|
|
10
|
+
'bottom-start': 'bottom span-right',
|
|
11
|
+
left: 'left',
|
|
12
|
+
'left-end': 'left span-top',
|
|
13
|
+
'left-start': 'left span-bottom',
|
|
14
|
+
right: 'right',
|
|
15
|
+
'right-end': 'right span-top',
|
|
16
|
+
'right-start': 'right span-bottom'
|
|
17
|
+
};
|
|
18
|
+
let popoverInstanceCount = 0;
|
|
19
|
+
export function usePopover({ mode = 'auto', placement = 'bottom-start', listenClick = true, listenFocus = true, listenHover = false, hideDelay = 400 } = {}) {
|
|
20
|
+
const uid = popoverInstanceCount++;
|
|
21
|
+
const anchorName = `--anchor-${uid}`;
|
|
22
|
+
let popover = $state();
|
|
23
|
+
let isOpen = $state(!!popover?.matches(':popover-open'));
|
|
24
|
+
const hideDebounced = debounce(hide, hideDelay);
|
|
25
|
+
function show() {
|
|
26
|
+
popover?.showPopover();
|
|
27
|
+
}
|
|
28
|
+
function hide() {
|
|
29
|
+
popover?.hidePopover();
|
|
30
|
+
}
|
|
31
|
+
function onMouseEnter() {
|
|
32
|
+
hideDebounced.clear();
|
|
33
|
+
show();
|
|
34
|
+
}
|
|
35
|
+
function onToggle(event) {
|
|
36
|
+
isOpen = event.newState === 'open';
|
|
37
|
+
}
|
|
38
|
+
function attachTriggerListeners(activator) {
|
|
39
|
+
const cleanups = [];
|
|
40
|
+
if (listenClick) {
|
|
41
|
+
cleanups.push(on(activator, 'click', show));
|
|
42
|
+
}
|
|
43
|
+
if (listenFocus) {
|
|
44
|
+
cleanups.push(on(activator, 'focusin', show));
|
|
45
|
+
// TODO: handle focusout ???
|
|
46
|
+
}
|
|
47
|
+
if (listenHover) {
|
|
48
|
+
cleanups.push(on(activator, 'mouseenter', onMouseEnter));
|
|
49
|
+
cleanups.push(on(activator, 'mouseleave', hideDebounced));
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
for (const cleanup of cleanups)
|
|
53
|
+
cleanup();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function attachPopoverListeners(node) {
|
|
57
|
+
const cleanups = [];
|
|
58
|
+
cleanups.push(on(node, 'toggle', onToggle));
|
|
59
|
+
if (listenHover) {
|
|
60
|
+
cleanups.push(on(node, 'mouseenter', onMouseEnter));
|
|
61
|
+
cleanups.push(on(node, 'mouseleave', hideDebounced));
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
for (const cleanup of cleanups)
|
|
65
|
+
cleanup();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
show,
|
|
70
|
+
hide,
|
|
71
|
+
get isOpen() {
|
|
72
|
+
return isOpen;
|
|
73
|
+
},
|
|
74
|
+
content: {
|
|
75
|
+
popover: mode,
|
|
76
|
+
[createAttachmentKey()]: (node) => {
|
|
77
|
+
popover = node;
|
|
78
|
+
// biome-ignore lint/suspicious/noTsIgnore: await for a svelte-check update
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
popover.style.positionAnchor = anchorName;
|
|
81
|
+
// biome-ignore lint/suspicious/noTsIgnore: await for a svelte-check update
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
popover.style.positionArea = placements[placement];
|
|
84
|
+
popover.style.inset = 'auto';
|
|
85
|
+
// biome-ignore lint/suspicious/noTsIgnore: await for a svelte-check update
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
popover.style.positionTry = 'flip-x, flip-y';
|
|
88
|
+
popover.style.position = 'relative';
|
|
89
|
+
return attachPopoverListeners(node);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
trigger: {
|
|
93
|
+
[createAttachmentKey()]: (node) => {
|
|
94
|
+
// biome-ignore lint/suspicious/noTsIgnore: await for a svelte-check update
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
node.style.anchorName = anchorName;
|
|
97
|
+
return attachTriggerListeners(node);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RemoteForm, RemoteFormInput } from '@sveltejs/kit';
|
|
2
|
+
import type { StandardSchemaV1 } from 'runed/kit';
|
|
3
|
+
/**
|
|
4
|
+
* Enable preflight and run validation on input
|
|
5
|
+
*/
|
|
6
|
+
export declare function useForm<Input extends RemoteFormInput | undefined, Output>(remoteForm: RemoteForm<Input, Output>, schema: StandardSchemaV1<Input>, debounceMs?: number): RemoteForm<Input, Output>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import debounce from 'debounce';
|
|
2
|
+
import { createAttachmentKey } from 'svelte/attachments';
|
|
3
|
+
import { on } from 'svelte/events';
|
|
4
|
+
/**
|
|
5
|
+
* Enable preflight and run validation on input
|
|
6
|
+
*/
|
|
7
|
+
export function useForm(remoteForm, schema, debounceMs = 1000) {
|
|
8
|
+
const validation = (formElement) => {
|
|
9
|
+
const debouncedValidate = debounce(() => remoteForm.validate(), debounceMs);
|
|
10
|
+
return on(formElement, 'input', ({ target }) => {
|
|
11
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLSelectElement) {
|
|
12
|
+
const instantValidation = target.ariaInvalid === 'true' ||
|
|
13
|
+
target.type === 'checkbox' ||
|
|
14
|
+
target.type === 'radio' ||
|
|
15
|
+
target.tagName === 'SELECT';
|
|
16
|
+
instantValidation ? remoteForm.validate() : debouncedValidate();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.assign(remoteForm, { [createAttachmentKey()]: validation });
|
|
21
|
+
return remoteForm.preflight(schema);
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SearchQueryResultSpan } from './search.ts'
|
|
3
|
+
|
|
4
|
+
let { spans }: { spans: SearchQueryResultSpan[] } = $props()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
{#each spans as { value, isMatch }}
|
|
8
|
+
<span
|
|
9
|
+
class={isMatch ? 'rounded-xs text-secondary' : ''}
|
|
10
|
+
class:ml-px={value.startsWith(' ')}
|
|
11
|
+
class:mr-px={value.endsWith(' ')}
|
|
12
|
+
>
|
|
13
|
+
{value}
|
|
14
|
+
</span>
|
|
15
|
+
{/each}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Fuse from 'fuse.js';
|
|
2
|
+
import { mergeRanges } from 'perod';
|
|
3
|
+
export function useSearch({ items = [], keys, ...fuseOptions }) {
|
|
4
|
+
const fuse = new Fuse(items, {
|
|
5
|
+
includeMatches: true,
|
|
6
|
+
keys: Object.entries(keys).map(([name, param]) => ({
|
|
7
|
+
name,
|
|
8
|
+
...(param || {})
|
|
9
|
+
})),
|
|
10
|
+
...fuseOptions
|
|
11
|
+
});
|
|
12
|
+
function query(value, { tokensSeparator = ' ', tokensMaxCount = 4 } = {}) {
|
|
13
|
+
const tokens = value.split(tokensSeparator).slice(0, tokensMaxCount);
|
|
14
|
+
const fuseResults = multiTokenFuseSearch(fuse, tokens);
|
|
15
|
+
const queryResults = [];
|
|
16
|
+
for (const { item, matches, score } of fuseResults) {
|
|
17
|
+
const spans = {};
|
|
18
|
+
for (const key of Object.keys(keys)) {
|
|
19
|
+
if (typeof value !== 'string')
|
|
20
|
+
throw new Error('Value is not a string');
|
|
21
|
+
spans[key] = getSpans(key, matches);
|
|
22
|
+
}
|
|
23
|
+
queryResults.push({
|
|
24
|
+
item,
|
|
25
|
+
score,
|
|
26
|
+
spans: spans
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return queryResults;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...fuse,
|
|
33
|
+
query
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function getSpans(key, matches) {
|
|
37
|
+
const { indices, value = '' } = matches?.find((m) => m.key === key) || {};
|
|
38
|
+
if (!indices?.length) {
|
|
39
|
+
return [{ value, isMatch: false }];
|
|
40
|
+
}
|
|
41
|
+
const spans = [];
|
|
42
|
+
if (indices[0][0] !== 0) {
|
|
43
|
+
spans.push({ value: value.slice(0, indices[0][0]), isMatch: false });
|
|
44
|
+
}
|
|
45
|
+
const len = indices.length;
|
|
46
|
+
for (let index = 0; index < len; index++) {
|
|
47
|
+
const [start, end] = indices[index];
|
|
48
|
+
const nextStart = index === len - 1 ? undefined : indices[index + 1][0];
|
|
49
|
+
spans.push({ value: value.slice(start, end + 1), isMatch: true });
|
|
50
|
+
if (end < value.length) {
|
|
51
|
+
spans.push({ value: value.slice(end + 1, nextStart), isMatch: false });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return spans;
|
|
55
|
+
}
|
|
56
|
+
function multiTokenFuseSearch(fuse, tokens) {
|
|
57
|
+
const resultsMap = new Map();
|
|
58
|
+
function ensureEntry(item) {
|
|
59
|
+
let entry = resultsMap.get(item);
|
|
60
|
+
if (entry)
|
|
61
|
+
return entry;
|
|
62
|
+
entry = { item, score: 0, matches: [] };
|
|
63
|
+
resultsMap.set(item, entry);
|
|
64
|
+
return entry;
|
|
65
|
+
}
|
|
66
|
+
for (const token of tokens) {
|
|
67
|
+
const results = fuse.search(token);
|
|
68
|
+
for (const { item, score, matches } of results) {
|
|
69
|
+
const entry = ensureEntry(item);
|
|
70
|
+
if (!matches)
|
|
71
|
+
continue;
|
|
72
|
+
entry.score += score || 0;
|
|
73
|
+
entry.matches = mergeMatches(entry.matches, matches);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [...resultsMap.values()].sort((a, b) => a.score - b.score);
|
|
77
|
+
}
|
|
78
|
+
function mergeMatches(a, b) {
|
|
79
|
+
if (!b || b.length === 0)
|
|
80
|
+
return a;
|
|
81
|
+
const merged = [...a];
|
|
82
|
+
for (const match of b) {
|
|
83
|
+
const existing = merged.find((m) => m.key === match.key);
|
|
84
|
+
if (existing) {
|
|
85
|
+
// TODO: update perod package to handle tuple and export types
|
|
86
|
+
existing.indices = mergeRanges([...existing.indices, ...match.indices].map(([start, end]) => ({
|
|
87
|
+
start,
|
|
88
|
+
end
|
|
89
|
+
}))).map(({ start, end }) => [start, end]);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
merged.push({ ...match });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return merged;
|
|
96
|
+
}
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
package/dist/server/sse.js
CHANGED
|
@@ -12,13 +12,13 @@ export function createSSE(last_id = 0, retry = 0) {
|
|
|
12
12
|
if (event)
|
|
13
13
|
msg += `event: ${event}\n`;
|
|
14
14
|
if (typeof data === 'string') {
|
|
15
|
-
msg +=
|
|
15
|
+
msg += `data: ${data.trim().replace(/\n+/gm, '\ndata: ')}\n`;
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
msg += `data: ${JSON.stringify(data)}\n`;
|
|
19
19
|
}
|
|
20
|
-
controller.enqueue(msg
|
|
21
|
-
}
|
|
20
|
+
controller.enqueue(`${msg}\n`);
|
|
21
|
+
}
|
|
22
22
|
});
|
|
23
23
|
const writer = writable.getWriter();
|
|
24
24
|
return {
|
|
@@ -30,6 +30,6 @@ export function createSSE(last_id = 0, retry = 0) {
|
|
|
30
30
|
eventEmitter.on(event, listener);
|
|
31
31
|
await writer.closed.catch(() => { });
|
|
32
32
|
eventEmitter.off(event, listener);
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
};
|
|
35
35
|
}
|
package/dist/server/table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { redirect } from '@sveltejs/kit';
|
|
2
|
-
import { jsonParse } from '../utils/jsonParse.js';
|
|
3
2
|
import { createKeys } from '../ui/table/context.js';
|
|
3
|
+
import { jsonParse } from '../utils/jsonParse.js';
|
|
4
4
|
export function ensureFieldsWithFilterAreVisibles(tableKey, url, isFilterKey) {
|
|
5
5
|
const { KEY_FIELDS_VISIBLE, KEY_FIELDS_HIDDEN } = createKeys(tableKey);
|
|
6
6
|
const fieldsVisible = jsonParse(url.searchParams.get(KEY_FIELDS_VISIBLE), []);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './param.svelte.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './param.svelte.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const param: {
|
|
2
|
+
readonly with: (params: Record<string, string | number>, ...keysToRemove: string[]) => string;
|
|
3
|
+
readonly without: (...keys: string[]) => string;
|
|
4
|
+
readonly toggle: (params: Record<string, string>, ...keysToRemove: string[]) => string;
|
|
5
|
+
readonly has: (key: string) => boolean;
|
|
6
|
+
readonly get: (key: string) => string | null;
|
|
7
|
+
readonly hasValue: (key: string, value: string) => boolean;
|
|
8
|
+
readonly keys: () => URLSearchParamsIterator<string>;
|
|
9
|
+
};
|
|
10
|
+
export declare const urlParam: {
|
|
11
|
+
with: (params: Record<string, string | number>, ...keysToRemove: string[]) => string;
|
|
12
|
+
without: (...args: string[]) => string;
|
|
13
|
+
toggle: (params: Record<string, string>, ...keysToRemove: string[]) => string;
|
|
14
|
+
has: (key: string) => boolean;
|
|
15
|
+
get: (key: string) => string | null;
|
|
16
|
+
hasValue: (key: string, value: string) => boolean;
|
|
17
|
+
keys: () => URLSearchParamsIterator<string>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { page } from '$app/state';
|
|
2
|
+
export const param = {
|
|
3
|
+
get with() {
|
|
4
|
+
return (params, ...keysToRemove) => {
|
|
5
|
+
const url = new URL(page.url);
|
|
6
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
7
|
+
url.searchParams.set(key, String(value));
|
|
8
|
+
});
|
|
9
|
+
keysToRemove.forEach((key) => {
|
|
10
|
+
url.searchParams.delete(key);
|
|
11
|
+
});
|
|
12
|
+
return url.search;
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
get without() {
|
|
16
|
+
return (...keys) => {
|
|
17
|
+
const url = new URL(page.url);
|
|
18
|
+
keys.forEach((key) => {
|
|
19
|
+
url.searchParams.delete(key);
|
|
20
|
+
});
|
|
21
|
+
return url.search;
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
get toggle() {
|
|
25
|
+
return (params, ...keysToRemove) => {
|
|
26
|
+
const url = new URL(page.url);
|
|
27
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
28
|
+
if (url.searchParams.get(key) === value)
|
|
29
|
+
url.searchParams.delete(key);
|
|
30
|
+
else
|
|
31
|
+
url.searchParams.set(key, value);
|
|
32
|
+
});
|
|
33
|
+
keysToRemove.forEach((key) => {
|
|
34
|
+
url.searchParams.delete(key);
|
|
35
|
+
});
|
|
36
|
+
return url.search;
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
get has() {
|
|
40
|
+
return (key) => page.url.searchParams.has(key);
|
|
41
|
+
},
|
|
42
|
+
get get() {
|
|
43
|
+
return (key) => page.url.searchParams.get(key);
|
|
44
|
+
},
|
|
45
|
+
get hasValue() {
|
|
46
|
+
return (key, value) => page.url.searchParams.get(key) === value;
|
|
47
|
+
},
|
|
48
|
+
get keys() {
|
|
49
|
+
return () => page.url.searchParams.keys();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function addPathname(fn) {
|
|
53
|
+
return (...args) => page.url.pathname + fn(...args);
|
|
54
|
+
}
|
|
55
|
+
export const urlParam = {
|
|
56
|
+
...param,
|
|
57
|
+
get with() {
|
|
58
|
+
return addPathname(param.with);
|
|
59
|
+
},
|
|
60
|
+
get without() {
|
|
61
|
+
return addPathname(param.without);
|
|
62
|
+
},
|
|
63
|
+
get toggle() {
|
|
64
|
+
return addPathname(param.toggle);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -1,45 +1,66 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { HTMLButtonAttributes, MouseEventHandler } from 'svelte/elements'
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
btn = true,
|
|
7
|
+
children,
|
|
8
|
+
formaction = '',
|
|
9
|
+
onclick: onclickProp,
|
|
10
|
+
onmouseleave: onmouseleaveProp,
|
|
11
|
+
...props
|
|
12
|
+
}: {
|
|
13
|
+
/** Form action URL triggered on confirmation */
|
|
14
|
+
formaction: string
|
|
15
|
+
/** Apply button styles */
|
|
16
|
+
btn?: boolean
|
|
17
|
+
/** Custom button content */
|
|
18
|
+
children?: Snippet<[{ waitConfirmation: boolean }]>
|
|
19
|
+
} & HTMLButtonAttributes = $props()
|
|
7
20
|
|
|
8
21
|
let button: HTMLButtonElement
|
|
9
|
-
let
|
|
10
|
-
let ready = false
|
|
22
|
+
let waitConfirmation = $state(false)
|
|
11
23
|
let timeout: NodeJS.Timeout
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
|
|
25
|
+
const onclick: MouseEventHandler<HTMLButtonElement> = (event) => {
|
|
26
|
+
onclickProp?.(event)
|
|
27
|
+
if (waitConfirmation) return
|
|
15
28
|
event.preventDefault()
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
button.style.width = `${button.offsetWidth}px`
|
|
30
|
+
waitConfirmation = true
|
|
31
|
+
timeout = setTimeout(() => {
|
|
32
|
+
waitConfirmation = false
|
|
33
|
+
button.style.width = ''
|
|
34
|
+
}, 2000)
|
|
18
35
|
}
|
|
19
36
|
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
const onmouseleave: MouseEventHandler<HTMLButtonElement> = (event) => {
|
|
38
|
+
onmouseleaveProp?.(event)
|
|
39
|
+
waitConfirmation = false
|
|
40
|
+
button.style.width = ''
|
|
22
41
|
clearTimeout(timeout)
|
|
23
42
|
}
|
|
24
43
|
</script>
|
|
25
44
|
|
|
26
45
|
<button
|
|
27
46
|
bind:this={button}
|
|
28
|
-
class={
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
class={[
|
|
48
|
+
btn && [
|
|
49
|
+
'btn',
|
|
50
|
+
waitConfirmation ? 'btn-outline btn-error' : 'text-error btn-ghost',
|
|
51
|
+
props.disabled && 'btn-disabled'
|
|
52
|
+
]
|
|
53
|
+
]}
|
|
54
|
+
formaction={waitConfirmation ? formaction : undefined}
|
|
55
|
+
{onclick}
|
|
56
|
+
{onmouseleave}
|
|
57
|
+
{...props}
|
|
39
58
|
>
|
|
40
|
-
{#if
|
|
41
|
-
|
|
59
|
+
{#if children}
|
|
60
|
+
{@render children({ waitConfirmation })}
|
|
61
|
+
{:else if waitConfirmation}
|
|
62
|
+
<span>T'es sur ?</span>
|
|
42
63
|
{:else}
|
|
43
|
-
<
|
|
64
|
+
<span>Supprimer</span>
|
|
44
65
|
{/if}
|
|
45
66
|
</button>
|
|
@@ -1,34 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
-
default: any;
|
|
16
|
-
} ? Props extends Record<string, never> ? any : {
|
|
17
|
-
children?: any;
|
|
18
|
-
} : {});
|
|
19
|
-
declare const ButtonDelete: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
-
class?: string;
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
/** Form action URL triggered on confirmation */
|
|
21
5
|
formaction: string;
|
|
22
|
-
|
|
6
|
+
/** Apply button styles */
|
|
23
7
|
btn?: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
default: {};
|
|
32
|
-
}, {}, string>;
|
|
33
|
-
type ButtonDelete = InstanceType<typeof ButtonDelete>;
|
|
8
|
+
/** Custom button content */
|
|
9
|
+
children?: Snippet<[{
|
|
10
|
+
waitConfirmation: boolean;
|
|
11
|
+
}]>;
|
|
12
|
+
} & HTMLButtonAttributes;
|
|
13
|
+
declare const ButtonDelete: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type ButtonDelete = ReturnType<typeof ButtonDelete>;
|
|
34
15
|
export default ButtonDelete;
|
package/dist/ui/button/index.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CopyIcon, type IconProps } from '@lucide/svelte'
|
|
3
|
+
import type { Component } from 'svelte'
|
|
4
|
+
import type { ClassValue } from 'svelte/elements'
|
|
5
|
+
import { tip } from '../../action/tip.js'
|
|
6
|
+
import { type UseCopyOptions, useCopy } from './useCopy.svelte.ts'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
title = '',
|
|
10
|
+
label = '',
|
|
11
|
+
Icon = CopyIcon,
|
|
12
|
+
class: klass = '',
|
|
13
|
+
...copyOptions
|
|
14
|
+
}: {
|
|
15
|
+
/** Tooltip text */
|
|
16
|
+
title?: string
|
|
17
|
+
/** Button label */
|
|
18
|
+
label?: string
|
|
19
|
+
/** Icon component */
|
|
20
|
+
Icon?: Component<IconProps>
|
|
21
|
+
/** Additional CSS classes */
|
|
22
|
+
class?: ClassValue
|
|
23
|
+
} & UseCopyOptions = $props()
|
|
24
|
+
|
|
25
|
+
const copy = $derived(useCopy(copyOptions))
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class="relative">
|
|
29
|
+
{#if copy.isLoading}
|
|
30
|
+
<span class="loading absolute top-1 left-1 scale-125 loading-spinner opacity-25"></span>
|
|
31
|
+
{/if}
|
|
32
|
+
<button
|
|
33
|
+
type="button"
|
|
34
|
+
class={klass ? klass : `btn btn-sm ${label ? '' : ' btn-square'}`}
|
|
35
|
+
{...copy}
|
|
36
|
+
use:tip={{ content: title }}
|
|
37
|
+
>
|
|
38
|
+
<Icon size={20} class="transition-transform {copy.isLoading ? 'scale-75' : ''}" />
|
|
39
|
+
{#if label}
|
|
40
|
+
<span>{label}</span>
|
|
41
|
+
{/if}
|
|
42
|
+
</button>
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type IconProps } from '@lucide/svelte';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
4
|
+
import { type UseCopyOptions } from './useCopy.svelte.ts';
|
|
5
|
+
type $$ComponentProps = {
|
|
6
|
+
/** Tooltip text */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** Button label */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Icon component */
|
|
11
|
+
Icon?: Component<IconProps>;
|
|
12
|
+
/** Additional CSS classes */
|
|
13
|
+
class?: ClassValue;
|
|
14
|
+
} & UseCopyOptions;
|
|
15
|
+
declare const ButtonCopy: Component<$$ComponentProps, {}, "">;
|
|
16
|
+
type ButtonCopy = ReturnType<typeof ButtonCopy>;
|
|
17
|
+
export default ButtonCopy;
|