@leap-online/jolt 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +51 -2
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/components/accordion/accordion.svelte +150 -0
- package/dist/components/accordion/accordion.svelte.d.ts +32 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/alert.svelte +75 -0
- package/dist/components/alert/alert.svelte.d.ts +24 -0
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/app-shell/app-shell.svelte +53 -0
- package/dist/components/app-shell/app-shell.svelte.d.ts +13 -0
- package/dist/components/app-shell/index.d.ts +2 -0
- package/dist/components/app-shell/index.js +1 -0
- package/dist/components/attachment/attachment-list.svelte +77 -0
- package/dist/components/attachment/attachment-list.svelte.d.ts +15 -0
- package/dist/components/attachment/attachment.svelte +119 -0
- package/dist/components/attachment/attachment.svelte.d.ts +14 -0
- package/dist/components/attachment/format.d.ts +1 -0
- package/dist/components/attachment/format.js +9 -0
- package/dist/components/attachment/index.d.ts +3 -0
- package/dist/components/attachment/index.js +2 -0
- package/dist/components/attachment/preview.d.ts +9 -0
- package/dist/components/attachment/preview.js +191 -0
- package/dist/components/attachment/types.d.ts +12 -0
- package/dist/components/attachment/types.js +1 -0
- package/dist/components/avatar/avatar.svelte +115 -0
- package/dist/components/avatar/avatar.svelte.d.ts +18 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar-group/avatar-group.svelte +79 -0
- package/dist/components/avatar-group/avatar-group.svelte.d.ts +19 -0
- package/dist/components/avatar-group/index.d.ts +1 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/badge/badge.svelte +45 -0
- package/dist/components/badge/badge.svelte.d.ts +25 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.svelte +165 -0
- package/dist/components/breadcrumb/breadcrumb.svelte.d.ts +24 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/button.svelte +77 -0
- package/dist/components/button/button.svelte.d.ts +29 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/calendar/calendar.svelte +512 -0
- package/dist/components/calendar/calendar.svelte.d.ts +4 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/calendar/types.d.ts +31 -0
- package/dist/components/calendar/types.js +1 -0
- package/dist/components/card/card.svelte +65 -0
- package/dist/components/card/card.svelte.d.ts +15 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/chat/chat-actions.svelte +183 -0
- package/dist/components/chat/chat-actions.svelte.d.ts +21 -0
- package/dist/components/chat/chat-attachments.svelte +41 -0
- package/dist/components/chat/chat-attachments.svelte.d.ts +12 -0
- package/dist/components/chat/chat-composer.svelte +165 -0
- package/dist/components/chat/chat-composer.svelte.d.ts +21 -0
- package/dist/components/chat/chat-loader.svelte +23 -0
- package/dist/components/chat/chat-loader.svelte.d.ts +7 -0
- package/dist/components/chat/chat-markdown.svelte +16 -0
- package/dist/components/chat/chat-markdown.svelte.d.ts +7 -0
- package/dist/components/chat/chat-message.svelte +114 -0
- package/dist/components/chat/chat-message.svelte.d.ts +18 -0
- package/dist/components/chat/chat-reasoning.svelte +52 -0
- package/dist/components/chat/chat-reasoning.svelte.d.ts +11 -0
- package/dist/components/chat/chat-sources.svelte +54 -0
- package/dist/components/chat/chat-sources.svelte.d.ts +10 -0
- package/dist/components/chat/chat-suggestions.svelte +44 -0
- package/dist/components/chat/chat-suggestions.svelte.d.ts +10 -0
- package/dist/components/chat/chat-tool-call.svelte +182 -0
- package/dist/components/chat/chat-tool-call.svelte.d.ts +26 -0
- package/dist/components/chat/chat-viewport.svelte +105 -0
- package/dist/components/chat/chat-viewport.svelte.d.ts +14 -0
- package/dist/components/chat/chat.svelte +113 -0
- package/dist/components/chat/chat.svelte.d.ts +27 -0
- package/dist/components/chat/index.d.ts +16 -0
- package/dist/components/chat/index.js +12 -0
- package/dist/components/chat/types.d.ts +19 -0
- package/dist/components/chat/types.js +1 -0
- package/dist/components/checkbox/checkbox.svelte +99 -0
- package/dist/components/checkbox/checkbox.svelte.d.ts +20 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/code-block/code-block.svelte +53 -0
- package/dist/components/code-block/code-block.svelte.d.ts +12 -0
- package/dist/components/code-block/index.d.ts +1 -0
- package/dist/components/code-block/index.js +1 -0
- package/dist/components/collapsible/collapsible.svelte +79 -0
- package/dist/components/collapsible/collapsible.svelte.d.ts +17 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox/combobox.svelte +272 -0
- package/dist/components/combobox/combobox.svelte.d.ts +25 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/combobox/types.d.ts +42 -0
- package/dist/components/combobox/types.js +1 -0
- package/dist/components/command-palette/command-palette.svelte +143 -0
- package/dist/components/command-palette/command-palette.svelte.d.ts +31 -0
- package/dist/components/command-palette/index.d.ts +2 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/confirm-dialog/confirm-dialog.svelte +107 -0
- package/dist/components/confirm-dialog/confirm-dialog.svelte.d.ts +20 -0
- package/dist/components/confirm-dialog/index.d.ts +1 -0
- package/dist/components/confirm-dialog/index.js +1 -0
- package/dist/components/context-menu/context-menu.svelte +175 -0
- package/dist/components/context-menu/context-menu.svelte.d.ts +22 -0
- package/dist/components/context-menu/index.d.ts +1 -0
- package/dist/components/context-menu/index.js +1 -0
- package/dist/components/copy-button/copy-button.svelte +130 -0
- package/dist/components/copy-button/copy-button.svelte.d.ts +19 -0
- package/dist/components/copy-button/index.d.ts +1 -0
- package/dist/components/copy-button/index.js +1 -0
- package/dist/components/data-table/data-table.svelte +146 -0
- package/dist/components/data-table/data-table.svelte.d.ts +43 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +1 -0
- package/dist/components/date-picker/date-picker.svelte +95 -0
- package/dist/components/date-picker/date-picker.svelte.d.ts +24 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/date-range-picker.svelte +117 -0
- package/dist/components/date-range-picker/date-range-picker.svelte.d.ts +28 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/dialog/dialog.svelte +98 -0
- package/dist/components/dialog/dialog.svelte.d.ts +16 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.svelte +197 -0
- package/dist/components/dropdown-menu/dropdown-menu.svelte.d.ts +29 -0
- package/dist/components/dropdown-menu/index.d.ts +1 -0
- package/dist/components/dropdown-menu/index.js +1 -0
- package/dist/components/email-input/email-input.svelte +21 -0
- package/dist/components/email-input/email-input.svelte.d.ts +5 -0
- package/dist/components/email-input/email.d.ts +10 -0
- package/dist/components/email-input/email.js +15 -0
- package/dist/components/email-input/index.d.ts +1 -0
- package/dist/components/email-input/index.js +1 -0
- package/dist/components/empty-state/empty-state.svelte +46 -0
- package/dist/components/empty-state/empty-state.svelte.d.ts +14 -0
- package/dist/components/empty-state/index.d.ts +1 -0
- package/dist/components/empty-state/index.js +1 -0
- package/dist/components/field/checkbox-field.svelte +50 -0
- package/dist/components/field/checkbox-field.svelte.d.ts +4 -0
- package/dist/components/field/field.svelte +71 -0
- package/dist/components/field/field.svelte.d.ts +21 -0
- package/dist/components/field/index.d.ts +5 -0
- package/dist/components/field/index.js +4 -0
- package/dist/components/field/select-field.svelte +55 -0
- package/dist/components/field/select-field.svelte.d.ts +25 -0
- package/dist/components/field/text-field.svelte +48 -0
- package/dist/components/field/text-field.svelte.d.ts +4 -0
- package/dist/components/field/textarea-field.svelte +45 -0
- package/dist/components/field/textarea-field.svelte.d.ts +4 -0
- package/dist/components/field/types.d.ts +74 -0
- package/dist/components/field/types.js +1 -0
- package/dist/components/file-upload/file-upload.svelte +202 -0
- package/dist/components/file-upload/file-upload.svelte.d.ts +15 -0
- package/dist/components/file-upload/index.d.ts +1 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/hover-card/hover-card.svelte +64 -0
- package/dist/components/hover-card/hover-card.svelte.d.ts +20 -0
- package/dist/components/hover-card/index.d.ts +1 -0
- package/dist/components/hover-card/index.js +1 -0
- package/dist/components/inline-edit/index.d.ts +1 -0
- package/dist/components/inline-edit/index.js +1 -0
- package/dist/components/inline-edit/inline-edit.svelte +207 -0
- package/dist/components/inline-edit/inline-edit.svelte.d.ts +17 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/input.svelte +36 -0
- package/dist/components/input/input.svelte.d.ts +8 -0
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/index.js +1 -0
- package/dist/components/kbd/kbd.svelte +33 -0
- package/dist/components/kbd/kbd.svelte.d.ts +10 -0
- package/dist/components/label/index.d.ts +1 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/label/label.svelte +25 -0
- package/dist/components/label/label.svelte.d.ts +8 -0
- package/dist/components/lightbox/index.d.ts +2 -0
- package/dist/components/lightbox/index.js +1 -0
- package/dist/components/lightbox/lightbox.svelte +264 -0
- package/dist/components/lightbox/lightbox.svelte.d.ts +4 -0
- package/dist/components/lightbox/types.d.ts +41 -0
- package/dist/components/lightbox/types.js +1 -0
- package/dist/components/loader/index.d.ts +1 -0
- package/dist/components/loader/index.js +1 -0
- package/dist/components/loader/loader.svelte +78 -0
- package/dist/components/loader/loader.svelte.d.ts +10 -0
- package/dist/components/markdown/markdown.svelte +52 -0
- package/dist/components/markdown/markdown.svelte.d.ts +7 -0
- package/dist/components/menubar/index.d.ts +3 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/menubar/menubar.svelte +180 -0
- package/dist/components/menubar/menubar.svelte.d.ts +4 -0
- package/dist/components/menubar/types.d.ts +26 -0
- package/dist/components/menubar/types.js +1 -0
- package/dist/components/multi-select/index.d.ts +2 -0
- package/dist/components/multi-select/index.js +1 -0
- package/dist/components/multi-select/multi-select.svelte +273 -0
- package/dist/components/multi-select/multi-select.svelte.d.ts +25 -0
- package/dist/components/multi-select/types.d.ts +32 -0
- package/dist/components/multi-select/types.js +1 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +1 -0
- package/dist/components/navigation-menu/navigation-menu.svelte +125 -0
- package/dist/components/navigation-menu/navigation-menu.svelte.d.ts +4 -0
- package/dist/components/navigation-menu/types.d.ts +40 -0
- package/dist/components/navigation-menu/types.js +1 -0
- package/dist/components/page-header/index.d.ts +1 -0
- package/dist/components/page-header/index.js +1 -0
- package/dist/components/page-header/page-header.svelte +44 -0
- package/dist/components/page-header/page-header.svelte.d.ts +11 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pagination/pagination.svelte +105 -0
- package/dist/components/pagination/pagination.svelte.d.ts +20 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/popover.svelte +67 -0
- package/dist/components/popover/popover.svelte.d.ts +20 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.svelte +81 -0
- package/dist/components/progress/progress.svelte.d.ts +16 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/radio-group/radio-group.svelte +140 -0
- package/dist/components/radio-group/radio-group.svelte.d.ts +32 -0
- package/dist/components/reaction-bar/index.d.ts +1 -0
- package/dist/components/reaction-bar/index.js +1 -0
- package/dist/components/reaction-bar/reaction-bar.svelte +99 -0
- package/dist/components/reaction-bar/reaction-bar.svelte.d.ts +18 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/scroll-area/scroll-area.svelte +81 -0
- package/dist/components/scroll-area/scroll-area.svelte.d.ts +15 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/select/select.svelte +183 -0
- package/dist/components/select/select.svelte.d.ts +25 -0
- package/dist/components/select/types.d.ts +38 -0
- package/dist/components/select/types.js +1 -0
- package/dist/components/separator/index.d.ts +1 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/separator/separator.svelte +25 -0
- package/dist/components/separator/separator.svelte.d.ts +8 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +1 -0
- package/dist/components/sheet/sheet.svelte +111 -0
- package/dist/components/sheet/sheet.svelte.d.ts +17 -0
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/sidebar/sidebar.svelte +124 -0
- package/dist/components/sidebar/sidebar.svelte.d.ts +4 -0
- package/dist/components/sidebar/types.d.ts +28 -0
- package/dist/components/sidebar/types.js +1 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.svelte +17 -0
- package/dist/components/skeleton/skeleton.svelte.d.ts +6 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.svelte +194 -0
- package/dist/components/slider/slider.svelte.d.ts +25 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.svelte +32 -0
- package/dist/components/spinner/spinner.svelte.d.ts +9 -0
- package/dist/components/split-button/index.d.ts +1 -0
- package/dist/components/split-button/index.js +1 -0
- package/dist/components/split-button/split-button.svelte +87 -0
- package/dist/components/split-button/split-button.svelte.d.ts +21 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/switch/switch.svelte +78 -0
- package/dist/components/switch/switch.svelte.d.ts +17 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/table.svelte +71 -0
- package/dist/components/table/table.svelte.d.ts +25 -0
- package/dist/components/table/types.d.ts +19 -0
- package/dist/components/table/types.js +1 -0
- package/dist/components/tabs/index.d.ts +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tabs/tabs.svelte +117 -0
- package/dist/components/tabs/tabs.svelte.d.ts +30 -0
- package/dist/components/tags-input/index.d.ts +2 -0
- package/dist/components/tags-input/index.js +1 -0
- package/dist/components/tags-input/parse.d.ts +6 -0
- package/dist/components/tags-input/parse.js +24 -0
- package/dist/components/tags-input/tags-input.svelte +181 -0
- package/dist/components/tags-input/tags-input.svelte.d.ts +4 -0
- package/dist/components/tags-input/types.d.ts +21 -0
- package/dist/components/tags-input/types.js +1 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/textarea/textarea.svelte +35 -0
- package/dist/components/textarea/textarea.svelte.d.ts +8 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/time-picker/index.js +1 -0
- package/dist/components/time-picker/time-picker.svelte +255 -0
- package/dist/components/time-picker/time-picker.svelte.d.ts +4 -0
- package/dist/components/time-picker/types.d.ts +23 -0
- package/dist/components/time-picker/types.js +1 -0
- package/dist/components/toast/index.d.ts +4 -0
- package/dist/components/toast/index.js +2 -0
- package/dist/components/toast/toast.svelte +68 -0
- package/dist/components/toast/toast.svelte.d.ts +16 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle/toggle-variants.d.ts +14 -0
- package/dist/components/toggle/toggle-variants.js +19 -0
- package/dist/components/toggle/toggle.svelte +57 -0
- package/dist/components/toggle/toggle.svelte.d.ts +19 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/toggle-group/toggle-group.svelte +163 -0
- package/dist/components/toggle-group/toggle-group.svelte.d.ts +32 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/tooltip.svelte +65 -0
- package/dist/components/tooltip/tooltip.svelte.d.ts +18 -0
- package/dist/components/tree-view/index.d.ts +3 -0
- package/dist/components/tree-view/index.js +2 -0
- package/dist/components/tree-view/move-tree-node.d.ts +7 -0
- package/dist/components/tree-view/move-tree-node.js +57 -0
- package/dist/components/tree-view/tree-view.svelte +553 -0
- package/dist/components/tree-view/tree-view.svelte.d.ts +4 -0
- package/dist/components/tree-view/types.d.ts +45 -0
- package/dist/components/tree-view/types.js +1 -0
- package/dist/form/create-form.svelte.d.ts +23 -0
- package/dist/form/create-form.svelte.js +68 -0
- package/dist/form/index.d.ts +4 -0
- package/dist/form/index.js +2 -0
- package/dist/form/superform-errors.d.ts +6 -0
- package/dist/form/superform-errors.js +13 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +67 -0
- package/dist/styles/theme.css +373 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +1 -0
- package/dist/types/menu.d.ts +51 -0
- package/dist/types/menu.js +1 -0
- package/dist/utils/clipboard.d.ts +13 -0
- package/dist/utils/clipboard.js +22 -0
- package/dist/utils/cls.d.ts +5 -0
- package/dist/utils/cls.js +8 -0
- package/dist/utils/highlight.d.ts +4 -0
- package/dist/utils/highlight.js +82 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +126 -5
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends object">
|
|
2
|
+
import { ArrowDownIcon, ArrowUpDownIcon, ArrowUpIcon } from '@lucide/svelte';
|
|
3
|
+
import {
|
|
4
|
+
type ColumnDef,
|
|
5
|
+
createSortedRowModel,
|
|
6
|
+
createTable,
|
|
7
|
+
rowSortingFeature,
|
|
8
|
+
sortFn_alphanumeric,
|
|
9
|
+
sortFn_text,
|
|
10
|
+
tableFeatures,
|
|
11
|
+
} from '@tanstack/svelte-table';
|
|
12
|
+
import type { Snippet } from 'svelte';
|
|
13
|
+
import { cls } from '../../utils/index.js';
|
|
14
|
+
|
|
15
|
+
export type DataTableColumn<T extends object> = {
|
|
16
|
+
id: string;
|
|
17
|
+
header: string;
|
|
18
|
+
accessor: (row: T) => unknown;
|
|
19
|
+
sortable?: boolean;
|
|
20
|
+
format?: (value: unknown, row: T) => string;
|
|
21
|
+
class?: string;
|
|
22
|
+
headerClass?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type Props<T extends object> = {
|
|
26
|
+
data: T[];
|
|
27
|
+
columns: DataTableColumn<T>[];
|
|
28
|
+
caption?: string;
|
|
29
|
+
empty?: Snippet;
|
|
30
|
+
cell?: Snippet<[T, DataTableColumn<T>]>;
|
|
31
|
+
class?: string;
|
|
32
|
+
tableClass?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let { data, columns, caption, empty, cell, class: className, tableClass }: Props<T> = $props();
|
|
36
|
+
|
|
37
|
+
const features = tableFeatures({
|
|
38
|
+
rowSortingFeature,
|
|
39
|
+
sortedRowModel: createSortedRowModel(),
|
|
40
|
+
sortFns: {
|
|
41
|
+
alphanumeric: sortFn_alphanumeric,
|
|
42
|
+
text: sortFn_text,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const tableColumns = $derived.by<ColumnDef<typeof features, T>[]>(() =>
|
|
47
|
+
columns.map((column) => ({
|
|
48
|
+
id: column.id,
|
|
49
|
+
accessorFn: column.accessor,
|
|
50
|
+
header: column.header,
|
|
51
|
+
enableSorting: column.sortable ?? false,
|
|
52
|
+
})),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const table = createTable({
|
|
56
|
+
features,
|
|
57
|
+
get columns() {
|
|
58
|
+
return tableColumns;
|
|
59
|
+
},
|
|
60
|
+
get data() {
|
|
61
|
+
return data;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
function getAriaSort(direction: false | 'asc' | 'desc'): 'ascending' | 'descending' | 'none' {
|
|
66
|
+
if (direction === 'asc') return 'ascending';
|
|
67
|
+
if (direction === 'desc') return 'descending';
|
|
68
|
+
return 'none';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function formatCell(column: DataTableColumn<T>, row: T): string {
|
|
72
|
+
const value = column.accessor(row);
|
|
73
|
+
if (column.format) return column.format(value, row);
|
|
74
|
+
if (value === null || value === undefined) return '—';
|
|
75
|
+
return String(value);
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div data-slot="data-table" class={cls('relative w-full overflow-x-auto', className)}>
|
|
80
|
+
<table data-slot="data-table-table" class={cls('w-full caption-bottom text-sm', tableClass)}>
|
|
81
|
+
{#if caption}
|
|
82
|
+
<caption class="sr-only">{caption}</caption>
|
|
83
|
+
{/if}
|
|
84
|
+
<thead data-slot="data-table-header" class="[&_tr]:border-b">
|
|
85
|
+
<tr class="border-b transition-colors hover:bg-muted/50">
|
|
86
|
+
{#each columns as column (column.id)}
|
|
87
|
+
{@const tableColumn = table.getColumn(column.id)}
|
|
88
|
+
{@const sorted = tableColumn?.getIsSorted() ?? false}
|
|
89
|
+
<th
|
|
90
|
+
scope="col"
|
|
91
|
+
aria-sort={column.sortable ? getAriaSort(sorted) : undefined}
|
|
92
|
+
data-slot="data-table-head"
|
|
93
|
+
class={cls(
|
|
94
|
+
'h-10 px-3 text-left align-middle text-xs font-medium text-muted-foreground',
|
|
95
|
+
column.headerClass,
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{#if column.sortable && tableColumn}
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
class="inline-flex items-center gap-1.5 rounded-sm transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
102
|
+
onclick={tableColumn.getToggleSortingHandler()}
|
|
103
|
+
>
|
|
104
|
+
{column.header}
|
|
105
|
+
{#if sorted === 'asc'}
|
|
106
|
+
<ArrowUpIcon class="size-3.5" />
|
|
107
|
+
{:else if sorted === 'desc'}
|
|
108
|
+
<ArrowDownIcon class="size-3.5" />
|
|
109
|
+
{:else}
|
|
110
|
+
<ArrowUpDownIcon class="size-3.5 opacity-50" />
|
|
111
|
+
{/if}
|
|
112
|
+
</button>
|
|
113
|
+
{:else}
|
|
114
|
+
{column.header}
|
|
115
|
+
{/if}
|
|
116
|
+
</th>
|
|
117
|
+
{/each}
|
|
118
|
+
</tr>
|
|
119
|
+
</thead>
|
|
120
|
+
<tbody data-slot="data-table-body" class="[&_tr:last-child]:border-0">
|
|
121
|
+
{#each table.getRowModel().rows as row (row.id)}
|
|
122
|
+
<tr class="border-b transition-colors hover:bg-muted/50" data-slot="data-table-row">
|
|
123
|
+
{#each columns as column (column.id)}
|
|
124
|
+
<td data-slot="data-table-cell" class={cls('p-3 align-middle', column.class)}>
|
|
125
|
+
{#if cell}
|
|
126
|
+
{@render cell(row.original, column)}
|
|
127
|
+
{:else}
|
|
128
|
+
{formatCell(column, row.original)}
|
|
129
|
+
{/if}
|
|
130
|
+
</td>
|
|
131
|
+
{/each}
|
|
132
|
+
</tr>
|
|
133
|
+
{:else}
|
|
134
|
+
<tr class="border-b">
|
|
135
|
+
<td colspan={columns.length} class="p-6 text-center text-sm text-muted-foreground">
|
|
136
|
+
{#if empty}
|
|
137
|
+
{@render empty()}
|
|
138
|
+
{:else}
|
|
139
|
+
No results.
|
|
140
|
+
{/if}
|
|
141
|
+
</td>
|
|
142
|
+
</tr>
|
|
143
|
+
{/each}
|
|
144
|
+
</tbody>
|
|
145
|
+
</table>
|
|
146
|
+
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type DataTableColumn<T extends object> = {
|
|
3
|
+
id: string;
|
|
4
|
+
header: string;
|
|
5
|
+
accessor: (row: T) => unknown;
|
|
6
|
+
sortable?: boolean;
|
|
7
|
+
format?: (value: unknown, row: T) => string;
|
|
8
|
+
class?: string;
|
|
9
|
+
headerClass?: string;
|
|
10
|
+
};
|
|
11
|
+
export type Props<T extends object> = {
|
|
12
|
+
data: T[];
|
|
13
|
+
columns: DataTableColumn<T>[];
|
|
14
|
+
caption?: string;
|
|
15
|
+
empty?: Snippet;
|
|
16
|
+
cell?: Snippet<[T, DataTableColumn<T>]>;
|
|
17
|
+
class?: string;
|
|
18
|
+
tableClass?: string;
|
|
19
|
+
};
|
|
20
|
+
declare function $$render<T extends object>(): {
|
|
21
|
+
props: Props<T>;
|
|
22
|
+
exports: {};
|
|
23
|
+
bindings: "";
|
|
24
|
+
slots: {};
|
|
25
|
+
events: {};
|
|
26
|
+
};
|
|
27
|
+
declare class __sveltets_Render<T extends object> {
|
|
28
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
29
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
30
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
31
|
+
bindings(): "";
|
|
32
|
+
exports(): {};
|
|
33
|
+
}
|
|
34
|
+
interface $$IsomorphicComponent {
|
|
35
|
+
new <T extends object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
36
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
37
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
38
|
+
<T extends object>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
39
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
40
|
+
}
|
|
41
|
+
declare const DataTable: $$IsomorphicComponent;
|
|
42
|
+
type DataTable<T extends object> = InstanceType<typeof DataTable<T>>;
|
|
43
|
+
export default DataTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DataTable } from './data-table.svelte';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
|
|
4
|
+
export type DatePickerValue = DateValue;
|
|
5
|
+
export type DatePickerWeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
|
+
|
|
7
|
+
export type Props = {
|
|
8
|
+
value?: DateValue;
|
|
9
|
+
onValueChange?: (value: DateValue | undefined) => void;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
calendarLabel?: string;
|
|
15
|
+
minValue?: DateValue;
|
|
16
|
+
maxValue?: DateValue;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
readonly?: boolean;
|
|
19
|
+
locale?: string;
|
|
20
|
+
weekStartsOn?: DatePickerWeekStartsOn;
|
|
21
|
+
class?: string;
|
|
22
|
+
triggerClass?: string;
|
|
23
|
+
contentClass?: string;
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
import { DateFormatter, getLocalTimeZone } from '@internationalized/date';
|
|
29
|
+
import { CalendarIcon } from '@lucide/svelte';
|
|
30
|
+
import { cls } from '../../utils/index.js';
|
|
31
|
+
import { Button } from '../button/index.js';
|
|
32
|
+
import { Calendar } from '../calendar/index.js';
|
|
33
|
+
import type { CalendarValue } from '../calendar/types.js';
|
|
34
|
+
import { Popover } from '../popover/index.js';
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
value = $bindable(),
|
|
38
|
+
onValueChange,
|
|
39
|
+
open = $bindable(false),
|
|
40
|
+
onOpenChange,
|
|
41
|
+
placeholder = 'Pick a date',
|
|
42
|
+
ariaLabel = 'Choose a date',
|
|
43
|
+
calendarLabel = 'Choose a date',
|
|
44
|
+
minValue,
|
|
45
|
+
maxValue,
|
|
46
|
+
disabled,
|
|
47
|
+
readonly,
|
|
48
|
+
locale = 'en',
|
|
49
|
+
weekStartsOn,
|
|
50
|
+
class: className,
|
|
51
|
+
triggerClass,
|
|
52
|
+
contentClass,
|
|
53
|
+
}: Props = $props();
|
|
54
|
+
|
|
55
|
+
const formatter = $derived(new DateFormatter(locale, { dateStyle: 'medium' }));
|
|
56
|
+
const displayValue = $derived(
|
|
57
|
+
value ? formatter.format(value.toDate(getLocalTimeZone())) : placeholder,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
function handleValueChange(next: CalendarValue | undefined): void {
|
|
61
|
+
if (!next || Array.isArray(next) || 'start' in next) return;
|
|
62
|
+
value = next;
|
|
63
|
+
onValueChange?.(next);
|
|
64
|
+
open = false;
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<Popover bind:open {onOpenChange} contentClass={cls('w-auto p-3', contentClass)}>
|
|
69
|
+
{#snippet trigger(props)}
|
|
70
|
+
<Button
|
|
71
|
+
{...props}
|
|
72
|
+
variant="outline"
|
|
73
|
+
{disabled}
|
|
74
|
+
aria-label={`${ariaLabel}: ${displayValue}`}
|
|
75
|
+
class={cls('w-56 justify-start gap-2 text-left font-normal', triggerClass)}
|
|
76
|
+
>
|
|
77
|
+
<CalendarIcon class="size-4 text-muted-foreground" />
|
|
78
|
+
<span class={cls(!value && 'text-muted-foreground')}>{displayValue}</span>
|
|
79
|
+
</Button>
|
|
80
|
+
{/snippet}
|
|
81
|
+
|
|
82
|
+
<Calendar
|
|
83
|
+
{value}
|
|
84
|
+
onValueChange={handleValueChange}
|
|
85
|
+
{minValue}
|
|
86
|
+
{maxValue}
|
|
87
|
+
{disabled}
|
|
88
|
+
{readonly}
|
|
89
|
+
{locale}
|
|
90
|
+
{weekStartsOn}
|
|
91
|
+
{calendarLabel}
|
|
92
|
+
initialFocus
|
|
93
|
+
class={className}
|
|
94
|
+
/>
|
|
95
|
+
</Popover>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
export type DatePickerValue = DateValue;
|
|
3
|
+
export type DatePickerWeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
export type Props = {
|
|
5
|
+
value?: DateValue;
|
|
6
|
+
onValueChange?: (value: DateValue | undefined) => void;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
calendarLabel?: string;
|
|
12
|
+
minValue?: DateValue;
|
|
13
|
+
maxValue?: DateValue;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
locale?: string;
|
|
17
|
+
weekStartsOn?: DatePickerWeekStartsOn;
|
|
18
|
+
class?: string;
|
|
19
|
+
triggerClass?: string;
|
|
20
|
+
contentClass?: string;
|
|
21
|
+
};
|
|
22
|
+
declare const DatePicker: import("svelte").Component<Props, {}, "value" | "open">;
|
|
23
|
+
type DatePicker = ReturnType<typeof DatePicker>;
|
|
24
|
+
export default DatePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from './date-picker.svelte';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
import type { CalendarRange, CalendarValue } from '../calendar/types.js';
|
|
4
|
+
|
|
5
|
+
export type DateRangeValue = CalendarRange;
|
|
6
|
+
|
|
7
|
+
export type DateRangePickerWeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
|
|
9
|
+
export type Props = {
|
|
10
|
+
value?: DateRangeValue;
|
|
11
|
+
onValueChange?: (value: DateRangeValue) => void;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
calendarLabel?: string;
|
|
17
|
+
minValue?: DateValue;
|
|
18
|
+
maxValue?: DateValue;
|
|
19
|
+
minDays?: number;
|
|
20
|
+
maxDays?: number;
|
|
21
|
+
numberOfMonths?: number;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
locale?: string;
|
|
25
|
+
weekStartsOn?: DateRangePickerWeekStartsOn;
|
|
26
|
+
class?: string;
|
|
27
|
+
triggerClass?: string;
|
|
28
|
+
contentClass?: string;
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import { DateFormatter, getLocalTimeZone } from '@internationalized/date';
|
|
34
|
+
import { CalendarIcon } from '@lucide/svelte';
|
|
35
|
+
import { cls } from '../../utils/index.js';
|
|
36
|
+
import { Button } from '../button/index.js';
|
|
37
|
+
import { Calendar } from '../calendar/index.js';
|
|
38
|
+
import { Popover } from '../popover/index.js';
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
value = $bindable({ start: undefined, end: undefined }),
|
|
42
|
+
onValueChange,
|
|
43
|
+
open = $bindable(false),
|
|
44
|
+
onOpenChange,
|
|
45
|
+
placeholder = 'Pick a date range',
|
|
46
|
+
ariaLabel = 'Choose a date range',
|
|
47
|
+
calendarLabel = 'Choose a date range',
|
|
48
|
+
minValue,
|
|
49
|
+
maxValue,
|
|
50
|
+
minDays,
|
|
51
|
+
maxDays,
|
|
52
|
+
numberOfMonths = 2,
|
|
53
|
+
disabled,
|
|
54
|
+
readonly,
|
|
55
|
+
locale = 'en',
|
|
56
|
+
weekStartsOn,
|
|
57
|
+
class: className,
|
|
58
|
+
triggerClass,
|
|
59
|
+
contentClass,
|
|
60
|
+
}: Props = $props();
|
|
61
|
+
|
|
62
|
+
const formatter = $derived(new DateFormatter(locale, { dateStyle: 'medium' }));
|
|
63
|
+
const displayValue = $derived.by(() => {
|
|
64
|
+
const zone = getLocalTimeZone();
|
|
65
|
+
if (value.start && value.end) {
|
|
66
|
+
return `${formatter.format(value.start.toDate(zone))} – ${formatter.format(value.end.toDate(zone))}`;
|
|
67
|
+
}
|
|
68
|
+
if (value.start) {
|
|
69
|
+
return formatter.format(value.start.toDate(zone));
|
|
70
|
+
}
|
|
71
|
+
return placeholder;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function handleValueChange(next: CalendarValue | undefined): void {
|
|
75
|
+
if (!next || Array.isArray(next) || !('start' in next)) return;
|
|
76
|
+
|
|
77
|
+
value = next;
|
|
78
|
+
onValueChange?.(next);
|
|
79
|
+
if (next.start && next.end) open = false;
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<Popover
|
|
84
|
+
bind:open
|
|
85
|
+
{onOpenChange}
|
|
86
|
+
contentClass={cls('w-auto max-w-[calc(100vw-2rem)] overflow-x-auto p-3', contentClass)}
|
|
87
|
+
>
|
|
88
|
+
{#snippet trigger(props)}
|
|
89
|
+
<Button
|
|
90
|
+
{...props}
|
|
91
|
+
variant="outline"
|
|
92
|
+
{disabled}
|
|
93
|
+
aria-label={`${ariaLabel}: ${displayValue}`}
|
|
94
|
+
class={cls('w-64 justify-start gap-2 text-left font-normal', triggerClass)}
|
|
95
|
+
>
|
|
96
|
+
<CalendarIcon class="size-4 shrink-0 text-muted-foreground" />
|
|
97
|
+
<span class={cls('truncate', !value.start && 'text-muted-foreground')}>{displayValue}</span>
|
|
98
|
+
</Button>
|
|
99
|
+
{/snippet}
|
|
100
|
+
|
|
101
|
+
<Calendar
|
|
102
|
+
type="range"
|
|
103
|
+
{value}
|
|
104
|
+
onValueChange={handleValueChange}
|
|
105
|
+
{minValue}
|
|
106
|
+
{maxValue}
|
|
107
|
+
{minDays}
|
|
108
|
+
{maxDays}
|
|
109
|
+
{numberOfMonths}
|
|
110
|
+
{disabled}
|
|
111
|
+
{readonly}
|
|
112
|
+
{locale}
|
|
113
|
+
{weekStartsOn}
|
|
114
|
+
{calendarLabel}
|
|
115
|
+
class={className}
|
|
116
|
+
/>
|
|
117
|
+
</Popover>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import type { CalendarRange } from '../calendar/types.js';
|
|
3
|
+
export type DateRangeValue = CalendarRange;
|
|
4
|
+
export type DateRangePickerWeekStartsOn = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
5
|
+
export type Props = {
|
|
6
|
+
value?: DateRangeValue;
|
|
7
|
+
onValueChange?: (value: DateRangeValue) => void;
|
|
8
|
+
open?: boolean;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
calendarLabel?: string;
|
|
13
|
+
minValue?: DateValue;
|
|
14
|
+
maxValue?: DateValue;
|
|
15
|
+
minDays?: number;
|
|
16
|
+
maxDays?: number;
|
|
17
|
+
numberOfMonths?: number;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
readonly?: boolean;
|
|
20
|
+
locale?: string;
|
|
21
|
+
weekStartsOn?: DateRangePickerWeekStartsOn;
|
|
22
|
+
class?: string;
|
|
23
|
+
triggerClass?: string;
|
|
24
|
+
contentClass?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const DateRangePicker: import("svelte").Component<Props, {}, "value" | "open">;
|
|
27
|
+
type DateRangePicker = ReturnType<typeof DateRangePicker>;
|
|
28
|
+
export default DateRangePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DateRangePicker } from './date-range-picker.svelte';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DialogRootProps } from 'bits-ui';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export type DialogTriggerProps = Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
export type Props = {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
onOpenChange?: DialogRootProps['onOpenChange'];
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
trigger?: Snippet<[DialogTriggerProps]>;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
footer?: Snippet;
|
|
15
|
+
class?: string;
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { XIcon } from '@lucide/svelte';
|
|
21
|
+
import { Dialog as BitsDialog } from 'bits-ui';
|
|
22
|
+
import { cls } from '../../utils/index.js';
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
open = $bindable(false),
|
|
26
|
+
onOpenChange,
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
trigger,
|
|
30
|
+
children,
|
|
31
|
+
footer,
|
|
32
|
+
class: className,
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<BitsDialog.Root bind:open {onOpenChange}>
|
|
37
|
+
{#if trigger}
|
|
38
|
+
<BitsDialog.Trigger>
|
|
39
|
+
{#snippet child({ props })}
|
|
40
|
+
{@render trigger(props)}
|
|
41
|
+
{/snippet}
|
|
42
|
+
</BitsDialog.Trigger>
|
|
43
|
+
{/if}
|
|
44
|
+
<BitsDialog.Portal>
|
|
45
|
+
<BitsDialog.Overlay
|
|
46
|
+
data-slot="dialog-overlay"
|
|
47
|
+
class="fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0"
|
|
48
|
+
/>
|
|
49
|
+
<BitsDialog.Content
|
|
50
|
+
data-slot="dialog-content"
|
|
51
|
+
class={cls(
|
|
52
|
+
'fixed top-1/2 left-1/2 z-50 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-background p-0 shadow-lg duration-200',
|
|
53
|
+
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
data-slot="dialog-header"
|
|
59
|
+
class="flex shrink-0 items-start justify-between gap-4 px-6 pt-6 pb-4"
|
|
60
|
+
>
|
|
61
|
+
<div class="flex min-w-0 flex-col gap-2">
|
|
62
|
+
<BitsDialog.Title class="text-lg font-semibold tracking-tight">
|
|
63
|
+
{title}
|
|
64
|
+
</BitsDialog.Title>
|
|
65
|
+
{#if description}
|
|
66
|
+
<BitsDialog.Description class="text-sm text-muted-foreground">
|
|
67
|
+
{description}
|
|
68
|
+
</BitsDialog.Description>
|
|
69
|
+
{/if}
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<BitsDialog.Close
|
|
73
|
+
type="button"
|
|
74
|
+
aria-label="Close"
|
|
75
|
+
class="-me-1 -mt-1 shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden"
|
|
76
|
+
>
|
|
77
|
+
<XIcon class="size-4" />
|
|
78
|
+
</BitsDialog.Close>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div
|
|
82
|
+
data-slot="dialog-body"
|
|
83
|
+
class="min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-6"
|
|
84
|
+
>
|
|
85
|
+
{@render children?.()}
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
{#if footer}
|
|
89
|
+
<div
|
|
90
|
+
data-slot="dialog-footer"
|
|
91
|
+
class="flex shrink-0 flex-col-reverse gap-2 border-t bg-background px-6 py-4 sm:flex-row sm:justify-end"
|
|
92
|
+
>
|
|
93
|
+
{@render footer()}
|
|
94
|
+
</div>
|
|
95
|
+
{/if}
|
|
96
|
+
</BitsDialog.Content>
|
|
97
|
+
</BitsDialog.Portal>
|
|
98
|
+
</BitsDialog.Root>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DialogRootProps } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export type DialogTriggerProps = Record<string, unknown>;
|
|
4
|
+
export type Props = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?: DialogRootProps['onOpenChange'];
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
trigger?: Snippet<[DialogTriggerProps]>;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
footer?: Snippet;
|
|
12
|
+
class?: string;
|
|
13
|
+
};
|
|
14
|
+
declare const Dialog: import("svelte").Component<Props, {}, "open">;
|
|
15
|
+
type Dialog = ReturnType<typeof Dialog>;
|
|
16
|
+
export default Dialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Dialog, type Props as DialogProps, type DialogTriggerProps, } from './dialog.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Dialog, } from './dialog.svelte';
|