fuma 2.0.50 → 2.1.1
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/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 +17 -0
- package/dist/state/param.svelte.js +64 -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 +17 -24
- package/dist/ui/table/Table.svelte.d.ts +3 -3
- 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 +71 -70
- package/dist/ui/table/TableViewSelect.svelte.d.ts +10 -23
- package/dist/ui/table/cell/TableCellArray.svelte +2 -2
- 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/field.d.ts +7 -7
- 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 +40 -56
- 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 +93 -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 +115 -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/table/type.d.ts +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
- /package/dist/{ui/table → input}/type.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type UseCopyOptions = {
|
|
2
|
+
value: string | (() => string) | (() => Promise<string>);
|
|
3
|
+
successMessage?: string;
|
|
4
|
+
onSuccess?: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function useCopy({ value, onSuccess, successMessage }: UseCopyOptions): {
|
|
7
|
+
[x: symbol]: (node: HTMLElement) => () => void;
|
|
8
|
+
readonly isLoading: boolean;
|
|
9
|
+
readonly disabled: boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createAttachmentKey } from 'svelte/attachments';
|
|
2
|
+
import { on } from 'svelte/events';
|
|
3
|
+
import { toast } from 'svelte-sonner';
|
|
4
|
+
export function useCopy({ value, onSuccess, successMessage = 'Copied' }) {
|
|
5
|
+
let isLoading = $state(false);
|
|
6
|
+
async function loadValue() {
|
|
7
|
+
if (typeof value === 'string')
|
|
8
|
+
return value;
|
|
9
|
+
return value();
|
|
10
|
+
}
|
|
11
|
+
async function onclick(event) {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
if (isLoading)
|
|
14
|
+
return;
|
|
15
|
+
isLoading = true;
|
|
16
|
+
const value = await loadValue().finally(() => (isLoading = false));
|
|
17
|
+
navigator.clipboard
|
|
18
|
+
.writeText(value)
|
|
19
|
+
.then(() => {
|
|
20
|
+
toast.success(successMessage);
|
|
21
|
+
onSuccess?.();
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
toast.error(error);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
get isLoading() {
|
|
29
|
+
return isLoading;
|
|
30
|
+
},
|
|
31
|
+
get disabled() {
|
|
32
|
+
return isLoading;
|
|
33
|
+
},
|
|
34
|
+
[createAttachmentKey()]: (node) => on(node, 'click', onclick)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,67 +1,97 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Icon } from '../icon/index.js'
|
|
5
|
-
import { contextContainer } from '../context.js'
|
|
2
|
+
import { XIcon } from '@lucide/svelte'
|
|
3
|
+
import { onMount, type Snippet } from 'svelte'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
let {
|
|
6
|
+
dialog = $bindable(),
|
|
7
|
+
hideCloseButton = false,
|
|
8
|
+
class: klass = '',
|
|
9
|
+
onOpen,
|
|
10
|
+
onClose,
|
|
11
|
+
activator,
|
|
12
|
+
header,
|
|
13
|
+
footer,
|
|
14
|
+
children
|
|
15
|
+
}: {
|
|
16
|
+
dialog?: HTMLDialogElement
|
|
17
|
+
hideCloseButton?: boolean
|
|
18
|
+
class?: string
|
|
19
|
+
onOpen?: () => void
|
|
20
|
+
onClose?: () => void
|
|
21
|
+
activator?: Snippet<[{ showModal: () => void }]>
|
|
22
|
+
header?: Snippet
|
|
23
|
+
footer?: Snippet
|
|
24
|
+
children: Snippet
|
|
25
|
+
} = $props()
|
|
14
26
|
|
|
15
27
|
onMount(() => {
|
|
28
|
+
if (!dialog) return
|
|
16
29
|
const inputsSelector = 'input:not([type=hidden], [tabindex="-1"])'
|
|
17
30
|
const inputs = dialog.querySelectorAll<HTMLInputElement>(inputsSelector)
|
|
18
31
|
const buttons = dialog.querySelectorAll<HTMLButtonElement>('button')
|
|
19
32
|
|
|
20
|
-
inputs.forEach((input) =>
|
|
21
|
-
|
|
33
|
+
inputs.forEach((input) => {
|
|
34
|
+
input.tabIndex = -1
|
|
35
|
+
})
|
|
36
|
+
buttons.forEach((button) => {
|
|
37
|
+
button.tabIndex = -1
|
|
38
|
+
})
|
|
22
39
|
|
|
23
40
|
function onDialogOpen() {
|
|
24
|
-
|
|
25
|
-
inputs.forEach((input) =>
|
|
26
|
-
|
|
41
|
+
onOpen?.()
|
|
42
|
+
inputs.forEach((input) => {
|
|
43
|
+
input.tabIndex = 0
|
|
44
|
+
})
|
|
45
|
+
buttons.forEach((button) => {
|
|
46
|
+
button.tabIndex = 0
|
|
47
|
+
})
|
|
27
48
|
if (!inputs[0]) return
|
|
28
49
|
inputs[0].focus()
|
|
29
50
|
inputs[0].select()
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
function onDialogClose() {
|
|
33
|
-
|
|
34
|
-
inputs.forEach((input) =>
|
|
35
|
-
|
|
54
|
+
onClose?.()
|
|
55
|
+
inputs.forEach((input) => {
|
|
56
|
+
input.tabIndex = -1
|
|
57
|
+
})
|
|
58
|
+
buttons.forEach((button) => {
|
|
59
|
+
button.tabIndex = -1
|
|
60
|
+
})
|
|
36
61
|
}
|
|
37
62
|
|
|
38
|
-
const observer = new MutationObserver(() => (dialog
|
|
63
|
+
const observer = new MutationObserver(() => (dialog?.open ? onDialogOpen() : onDialogClose()))
|
|
39
64
|
observer.observe(dialog, { attributeFilter: ['open'] })
|
|
40
65
|
return () => observer.disconnect()
|
|
41
66
|
})
|
|
42
67
|
</script>
|
|
43
68
|
|
|
69
|
+
{@render activator?.({ showModal: () => dialog?.showModal() })}
|
|
70
|
+
|
|
44
71
|
<dialog bind:this={dialog} class="modal" tabindex="-1">
|
|
45
|
-
<div class="modal-box
|
|
72
|
+
<div class="bordered modal-box flex flex-col rounded-lg border p-0">
|
|
46
73
|
<div class="relative flex items-center border-b p-4">
|
|
47
74
|
<div class="grow">
|
|
48
|
-
|
|
75
|
+
{@render header?.()}
|
|
49
76
|
</div>
|
|
50
77
|
|
|
51
78
|
{#if !hideCloseButton}
|
|
52
79
|
<button
|
|
53
80
|
type="button"
|
|
54
81
|
class="ml btn btn-square btn-ghost btn-sm"
|
|
55
|
-
|
|
82
|
+
onclick={() => dialog?.close()}
|
|
56
83
|
>
|
|
57
|
-
<
|
|
84
|
+
<XIcon />
|
|
58
85
|
</button>
|
|
59
86
|
{/if}
|
|
60
87
|
</div>
|
|
61
88
|
<div class="grow overflow-auto p-4 {klass}">
|
|
62
|
-
|
|
89
|
+
{@render children()}
|
|
63
90
|
</div>
|
|
64
91
|
|
|
65
|
-
|
|
92
|
+
{@render footer?.()}
|
|
66
93
|
</div>
|
|
94
|
+
<form method="dialog" class="modal-backdrop">
|
|
95
|
+
<button>close</button>
|
|
96
|
+
</form>
|
|
67
97
|
</dialog>
|
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} & Exports;
|
|
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 Dialog: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
-
dialog: HTMLDialogElement;
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
dialog?: HTMLDialogElement;
|
|
21
4
|
hideCloseButton?: boolean;
|
|
22
5
|
class?: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
default: {};
|
|
35
|
-
footer: {};
|
|
36
|
-
}, {}, string>;
|
|
37
|
-
type Dialog = InstanceType<typeof Dialog>;
|
|
6
|
+
onOpen?: () => void;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
activator?: Snippet<[{
|
|
9
|
+
showModal: () => void;
|
|
10
|
+
}]>;
|
|
11
|
+
header?: Snippet;
|
|
12
|
+
footer?: Snippet;
|
|
13
|
+
children: Snippet;
|
|
14
|
+
};
|
|
15
|
+
declare const Dialog: import("svelte").Component<$$ComponentProps, {}, "dialog">;
|
|
16
|
+
type Dialog = ReturnType<typeof Dialog>;
|
|
38
17
|
export default Dialog;
|
package/dist/ui/dialog/index.js
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export const transitionX = writable(0)
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script lang="ts">
|
|
2
|
-
import {
|
|
6
|
+
import { type Snippet } from 'svelte'
|
|
3
7
|
import { fade } from 'svelte/transition'
|
|
4
|
-
import {
|
|
8
|
+
import { XIcon } from '@lucide/svelte'
|
|
5
9
|
|
|
6
10
|
import { goto } from '$app/navigation'
|
|
7
|
-
import { urlParam } from '../../
|
|
8
|
-
import { Icon } from '../icon/index.js'
|
|
9
|
-
import { subscibeDrawerLayers } from './layers.js'
|
|
10
|
-
import { contextContainer } from '../context.js'
|
|
11
|
+
import { urlParam } from '../../state/param.svelte.ts'
|
|
11
12
|
import { drawerFly } from './drawerFly.js'
|
|
13
|
+
import { writable } from 'svelte/store'
|
|
14
|
+
import { useLayer } from './useLayer.svelte.js'
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
let {
|
|
17
|
+
key,
|
|
18
|
+
title,
|
|
19
|
+
class: klass = '',
|
|
20
|
+
maxWidth = '32rem',
|
|
21
|
+
classHeader = '',
|
|
22
|
+
classBody = '',
|
|
23
|
+
duration = 180,
|
|
24
|
+
noOverlay = false,
|
|
25
|
+
zIndex = 50,
|
|
26
|
+
children
|
|
27
|
+
}: {
|
|
28
|
+
key: string
|
|
29
|
+
title?: string
|
|
30
|
+
class?: string
|
|
31
|
+
maxWidth?: string
|
|
32
|
+
classHeader?: string
|
|
33
|
+
classBody?: string
|
|
34
|
+
duration?: number
|
|
35
|
+
noOverlay?: boolean
|
|
36
|
+
zIndex?: number
|
|
37
|
+
children: Snippet<[{ open: typeof open; close: typeof close }]>
|
|
38
|
+
} = $props()
|
|
26
39
|
|
|
27
40
|
type GotoOptions = Parameters<typeof goto>[1]
|
|
28
41
|
export function open(value = 1, options: GotoOptions = {}) {
|
|
29
|
-
return goto(
|
|
42
|
+
return goto(urlParam.with({ [key]: value }), {
|
|
30
43
|
...options,
|
|
31
44
|
replaceState: true,
|
|
32
45
|
noScroll: true
|
|
33
46
|
})
|
|
34
47
|
}
|
|
48
|
+
|
|
35
49
|
export function close(options: GotoOptions = {}) {
|
|
36
|
-
return goto(
|
|
50
|
+
return goto(urlParam.without(key), { ...options, replaceState: true, noScroll: true })
|
|
37
51
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onDestroy(destroy)
|
|
41
|
-
contextContainer.set('drawer')
|
|
42
|
-
let clientWidth = 0
|
|
43
|
-
|
|
44
|
-
onMount(() => {
|
|
45
|
-
transitionX = $isActive ? clientWidth : 0
|
|
46
|
-
})
|
|
52
|
+
let { offset, index, isActive } = $derived(useLayer(key))
|
|
53
|
+
let clientWidth = $state(0)
|
|
47
54
|
</script>
|
|
48
55
|
|
|
49
|
-
{#if !noOverlay &&
|
|
50
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
56
|
+
{#if !noOverlay && isActive}
|
|
51
57
|
<div
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
role="button"
|
|
59
|
+
onclick={() => close()}
|
|
60
|
+
onkeyup={() => close()}
|
|
61
|
+
tabindex={-1}
|
|
54
62
|
transition:fade={{ duration }}
|
|
55
|
-
style="z-index: {zIndex +
|
|
63
|
+
style="z-index: {zIndex + index};"
|
|
56
64
|
class="fixed inset-0 bg-black/15 backdrop-blur-[1.5px] dark:bg-white/15"
|
|
57
65
|
></div>
|
|
58
66
|
{/if}
|
|
59
67
|
|
|
60
|
-
{#if
|
|
68
|
+
{#if isActive}
|
|
61
69
|
<aside
|
|
62
70
|
bind:clientWidth
|
|
63
71
|
transition:drawerFly|local={{
|
|
@@ -65,21 +73,21 @@
|
|
|
65
73
|
duration,
|
|
66
74
|
opacity: 1,
|
|
67
75
|
onTransition(pos) {
|
|
68
|
-
transitionX = pos.x
|
|
76
|
+
$transitionX = pos.x
|
|
69
77
|
}
|
|
70
78
|
}}
|
|
71
79
|
style="
|
|
72
|
-
z-index: {zIndex +
|
|
80
|
+
z-index: {zIndex + index};
|
|
73
81
|
max-width: min(100%, {maxWidth});
|
|
74
|
-
transform: translateX({
|
|
82
|
+
transform: translateX({-offset * 4}rem);
|
|
75
83
|
transition-duration: {duration}ms;
|
|
76
84
|
"
|
|
77
85
|
class:border-l={noOverlay}
|
|
78
86
|
class="{klass} fixed
|
|
79
|
-
|
|
87
|
+
top-0 right-0 bottom-0 z-10 flex
|
|
80
88
|
w-full flex-col overflow-y-scroll bg-base-100
|
|
81
89
|
transition-transform
|
|
82
|
-
|
|
90
|
+
"
|
|
83
91
|
>
|
|
84
92
|
<div
|
|
85
93
|
class="{classHeader}
|
|
@@ -88,13 +96,13 @@
|
|
|
88
96
|
"
|
|
89
97
|
>
|
|
90
98
|
<h2 class="title min-w-0 overflow-hidden">{title}</h2>
|
|
91
|
-
<button
|
|
92
|
-
<
|
|
99
|
+
<button onclick={() => close()} class="btn btn-square btn-sm">
|
|
100
|
+
<XIcon title="Fermer" />
|
|
93
101
|
</button>
|
|
94
102
|
</div>
|
|
95
103
|
|
|
96
|
-
<div class="{classBody} grow pl-8
|
|
97
|
-
|
|
104
|
+
<div class="{classBody} grow pr-4 pl-8">
|
|
105
|
+
{@render children({ open, close })}
|
|
98
106
|
</div>
|
|
99
107
|
</aside>
|
|
100
108
|
{/if}
|
|
@@ -1,71 +1,16 @@
|
|
|
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 Drawer: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
1
|
+
export declare const transitionX: import("svelte/store").Writable<number>;
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
declare const Drawer: import("svelte").Component<{
|
|
4
|
+
key: string;
|
|
20
5
|
title?: string;
|
|
21
|
-
/** Key used in url query params */ key: string;
|
|
22
6
|
class?: string;
|
|
23
7
|
maxWidth?: string;
|
|
24
8
|
classHeader?: string;
|
|
25
9
|
classBody?: string;
|
|
26
10
|
duration?: number;
|
|
27
11
|
noOverlay?: boolean;
|
|
28
|
-
transitionX?: number;
|
|
29
12
|
zIndex?: number;
|
|
30
|
-
|
|
31
|
-
replaceState?: boolean | undefined;
|
|
32
|
-
noScroll?: boolean | undefined;
|
|
33
|
-
keepFocus?: boolean | undefined;
|
|
34
|
-
invalidateAll?: boolean | undefined;
|
|
35
|
-
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
36
|
-
state?: App.PageState | undefined;
|
|
37
|
-
} | undefined) => Promise<void>;
|
|
38
|
-
close?: (options?: {
|
|
39
|
-
replaceState?: boolean | undefined;
|
|
40
|
-
noScroll?: boolean | undefined;
|
|
41
|
-
keepFocus?: boolean | undefined;
|
|
42
|
-
invalidateAll?: boolean | undefined;
|
|
43
|
-
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
44
|
-
state?: App.PageState | undefined;
|
|
45
|
-
} | undefined) => Promise<void>;
|
|
46
|
-
}, {
|
|
47
|
-
default: {
|
|
48
|
-
open: (value?: number, options?: {
|
|
49
|
-
replaceState?: boolean | undefined;
|
|
50
|
-
noScroll?: boolean | undefined;
|
|
51
|
-
keepFocus?: boolean | undefined;
|
|
52
|
-
invalidateAll?: boolean | undefined;
|
|
53
|
-
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
54
|
-
state?: App.PageState | undefined;
|
|
55
|
-
} | undefined) => Promise<void>;
|
|
56
|
-
close: (options?: {
|
|
57
|
-
replaceState?: boolean | undefined;
|
|
58
|
-
noScroll?: boolean | undefined;
|
|
59
|
-
keepFocus?: boolean | undefined;
|
|
60
|
-
invalidateAll?: boolean | undefined;
|
|
61
|
-
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
62
|
-
state?: App.PageState | undefined;
|
|
63
|
-
} | undefined) => Promise<void>;
|
|
64
|
-
};
|
|
65
|
-
}>, {
|
|
66
|
-
[evt: string]: CustomEvent<any>;
|
|
67
|
-
}, {
|
|
68
|
-
default: {
|
|
13
|
+
children: Snippet<[{
|
|
69
14
|
open: (value?: number, options?: {
|
|
70
15
|
replaceState?: boolean | undefined;
|
|
71
16
|
noScroll?: boolean | undefined;
|
|
@@ -82,7 +27,7 @@ declare const Drawer: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWit
|
|
|
82
27
|
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
83
28
|
state?: App.PageState | undefined;
|
|
84
29
|
} | undefined) => Promise<void>;
|
|
85
|
-
}
|
|
30
|
+
}]>;
|
|
86
31
|
}, {
|
|
87
32
|
open: (value?: number, options?: {
|
|
88
33
|
replaceState?: boolean | undefined;
|
|
@@ -100,6 +45,6 @@ declare const Drawer: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWit
|
|
|
100
45
|
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
101
46
|
state?: App.PageState | undefined;
|
|
102
47
|
} | undefined) => Promise<void>;
|
|
103
|
-
},
|
|
104
|
-
type Drawer =
|
|
48
|
+
}, "">;
|
|
49
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
105
50
|
export default Drawer;
|
|
@@ -13,7 +13,7 @@ export function drawerFly(node, { delay = 0, duration = 400, easing = cubicOut,
|
|
|
13
13
|
css: (t, u) => `
|
|
14
14
|
transform: ${transform} translate(${(1 - t) * xValue}${xUnit}, ${(1 - t) * yValue}${yUnit});
|
|
15
15
|
opacity: ${target_opacity - od * u}`,
|
|
16
|
-
tick: (t,
|
|
16
|
+
tick: (t, _u) => {
|
|
17
17
|
onTransition({ x: t * xValue, y: t * yValue });
|
|
18
18
|
}
|
|
19
19
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { untrack } from 'svelte';
|
|
2
|
+
import { page } from '$app/state';
|
|
3
|
+
let nbActives = $state(0);
|
|
4
|
+
export function useLayer(key) {
|
|
5
|
+
const index = $derived.by(() => {
|
|
6
|
+
let i = 0;
|
|
7
|
+
for (const k of page.url.searchParams.keys()) {
|
|
8
|
+
if (k === key)
|
|
9
|
+
return i;
|
|
10
|
+
i++;
|
|
11
|
+
}
|
|
12
|
+
return -1;
|
|
13
|
+
});
|
|
14
|
+
const isActive = $derived(index !== -1);
|
|
15
|
+
const offset = $derived(isActive && nbActives - index - 1);
|
|
16
|
+
$effect(() => {
|
|
17
|
+
if (isActive)
|
|
18
|
+
untrack(() => nbActives++);
|
|
19
|
+
else
|
|
20
|
+
untrack(() => (nbActives = Math.max(nbActives - 1, 0)));
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
get index() {
|
|
24
|
+
return index;
|
|
25
|
+
},
|
|
26
|
+
get offset() {
|
|
27
|
+
return offset;
|
|
28
|
+
},
|
|
29
|
+
get isActive() {
|
|
30
|
+
return isActive;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './button/index.js';
|
|
2
|
+
export * from './dialog/index.js';
|
|
2
3
|
export * from './drawer/index.js';
|
|
3
|
-
export * from './input/index.js';
|
|
4
|
-
export * from './form/index.js';
|
|
5
4
|
export * from './menu/index.js';
|
|
5
|
+
export * from './mode/index.js';
|
|
6
|
+
export * from './pagination/index.js';
|
|
6
7
|
export * from './range/index.js';
|
|
7
8
|
export * from './table/index.js';
|
|
8
|
-
export * from './tabs/index.js';
|
|
9
|
-
export * from './button/index.js';
|
|
10
|
-
export * from './dialog/index.js';
|
|
11
|
-
export * from './placeholder/index.js';
|
|
12
|
-
export * from './icon/index.js';
|
|
13
|
-
export * from './login/index.js';
|
|
14
|
-
export * from './pagination/index.js';
|
|
15
|
-
export * from './mode/index.js';
|
|
16
|
-
export * from './badge/index.js';
|
package/dist/ui/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './button/index.js';
|
|
2
|
+
export * from './dialog/index.js';
|
|
2
3
|
export * from './drawer/index.js';
|
|
3
|
-
export * from './input/index.js';
|
|
4
|
-
export * from './form/index.js';
|
|
5
4
|
export * from './menu/index.js';
|
|
5
|
+
export * from './mode/index.js';
|
|
6
|
+
export * from './pagination/index.js';
|
|
6
7
|
export * from './range/index.js';
|
|
7
8
|
export * from './table/index.js';
|
|
8
|
-
export * from './tabs/index.js';
|
|
9
|
-
export * from './button/index.js';
|
|
10
|
-
export * from './dialog/index.js';
|
|
11
|
-
export * from './placeholder/index.js';
|
|
12
|
-
export * from './icon/index.js';
|
|
13
|
-
export * from './login/index.js';
|
|
14
|
-
export * from './pagination/index.js';
|
|
15
|
-
export * from './mode/index.js';
|
|
16
|
-
export * from './badge/index.js';
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import { MediaQuery } from 'svelte/reactivity'
|
|
5
4
|
import { Dialog } from '../dialog/index.js'
|
|
6
5
|
import { DropDown } from './index.js'
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
export let tippyProps: Partial<TippyProps> = {}
|
|
10
|
-
let klass = ''
|
|
11
|
-
export { klass as class }
|
|
12
|
-
|
|
13
|
-
const dispatch = createEventDispatcher<{ show: void; hide: void }>()
|
|
6
|
+
import type { TippyProps } from '../../utils/tippy.js'
|
|
14
7
|
|
|
15
|
-
let
|
|
16
|
-
|
|
8
|
+
let {
|
|
9
|
+
tippyProps = {},
|
|
10
|
+
class: klass = '',
|
|
11
|
+
onShow,
|
|
12
|
+
onHide,
|
|
13
|
+
children
|
|
14
|
+
}: {
|
|
15
|
+
tippyProps?: Partial<TippyProps>
|
|
16
|
+
class?: string
|
|
17
|
+
onShow?: () => void
|
|
18
|
+
onHide?: () => void
|
|
19
|
+
children: Snippet
|
|
20
|
+
} = $props()
|
|
21
|
+
|
|
22
|
+
const isSmallScreen = new MediaQuery('max-width: 600px;')
|
|
23
|
+
let dropdown: DropDown | undefined = $state()
|
|
24
|
+
let dialog: HTMLDialogElement | undefined = $state()
|
|
17
25
|
|
|
18
26
|
export function show(event: MouseEvent) {
|
|
19
|
-
if (
|
|
27
|
+
if (isSmallScreen.current) {
|
|
20
28
|
dialog?.showModal()
|
|
21
29
|
} else {
|
|
22
30
|
const target = event.target as HTMLElement
|
|
@@ -26,29 +34,22 @@
|
|
|
26
34
|
})
|
|
27
35
|
dropdown?.show()
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
dispatch('show')
|
|
37
|
+
onShow?.()
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export function hide() {
|
|
34
|
-
if (
|
|
41
|
+
if (isSmallScreen.current) dialog?.close()
|
|
35
42
|
else dropdown?.hide()
|
|
36
|
-
|
|
43
|
+
onHide?.()
|
|
37
44
|
}
|
|
38
45
|
</script>
|
|
39
46
|
|
|
40
|
-
{#if
|
|
47
|
+
{#if isSmallScreen.current}
|
|
41
48
|
<Dialog bind:dialog class={klass}>
|
|
42
|
-
|
|
43
|
-
<slot name="header" />
|
|
44
|
-
</div>
|
|
45
|
-
<slot />
|
|
49
|
+
{@render children()}
|
|
46
50
|
</Dialog>
|
|
47
51
|
{:else}
|
|
48
52
|
<DropDown class={klass} bind:this={dropdown} tippyProps={{ offset: [0, -5], ...tippyProps }}>
|
|
49
|
-
|
|
50
|
-
<slot name="header" />
|
|
51
|
-
<slot />
|
|
52
|
-
</div>
|
|
53
|
+
{@render children()}
|
|
53
54
|
</DropDown>
|
|
54
55
|
{/if}
|