@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Leap Software Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Jolt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Leap's Svelte 5 component library. Black-and-white foundations with a restrained gold accent, built on [bits-ui](https://bits-ui.com) and [Tailwind CSS v4](https://tailwindcss.com).
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
Requires Node 24+ and pnpm.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install
|
|
11
|
+
pnpm storybook
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Useful commands:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pnpm check # svelte-check
|
|
18
|
+
pnpm lint # Prettier + ESLint
|
|
19
|
+
pnpm test # unit, component, and story tests
|
|
20
|
+
pnpm build # svelte-package
|
|
21
|
+
pnpm package # build + publint
|
|
22
|
+
pnpm test:consumer # packed-tarball consumer smoke test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
pnpm add @leap-online/jolt
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Import the theme after Tailwind in your application CSS:
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@import 'tailwindcss';
|
|
35
|
+
@import '@leap-online/jolt/styles.css';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then import components from the package root:
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
import { Button } from '@leap-online/jolt';
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<Button>Continue</Button>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Set `bg-background text-foreground` on `<body>` and toggle `dark` on `<html>` for dark mode.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
## shadcn-svelte
|
|
4
|
+
|
|
5
|
+
Portions of the component source are adapted from [shadcn-svelte](https://github.com/huntabyte/shadcn-svelte), which is licensed under the MIT License.
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2023 Huntabyte
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
|
+
|
|
15
|
+
## Runtime dependencies
|
|
16
|
+
|
|
17
|
+
Jolt depends on the following packages. Their full license texts are included in the installed packages.
|
|
18
|
+
|
|
19
|
+
- `@internationalized/date` — Apache License 2.0
|
|
20
|
+
- `@tanstack/svelte-table` — MIT License
|
|
21
|
+
- `svelte-sonner` — MIT License
|
|
22
|
+
- `valibot` — MIT License
|
|
23
|
+
- `marked` — MIT License
|
|
24
|
+
- `sanitize-html` — MIT License
|
|
25
|
+
- `highlight.js` — BSD 3-Clause License
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type AccordionItem = {
|
|
5
|
+
value: string;
|
|
6
|
+
title: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
icon?: Component<{ class?: string }>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type AccordionType = 'single' | 'multiple';
|
|
13
|
+
export type AccordionOrientation = 'horizontal' | 'vertical';
|
|
14
|
+
export type AccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
15
|
+
|
|
16
|
+
export type Props = {
|
|
17
|
+
items: AccordionItem[];
|
|
18
|
+
type?: AccordionType;
|
|
19
|
+
value?: string | string[];
|
|
20
|
+
onValueChange?: (value: string | string[]) => void;
|
|
21
|
+
orientation?: AccordionOrientation;
|
|
22
|
+
headingLevel?: AccordionHeadingLevel;
|
|
23
|
+
loop?: boolean;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
class?: string;
|
|
26
|
+
itemClass?: string;
|
|
27
|
+
triggerClass?: string;
|
|
28
|
+
contentClass?: string;
|
|
29
|
+
trigger?: Snippet<[AccordionItem]>;
|
|
30
|
+
content?: Snippet<[AccordionItem]>;
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script lang="ts">
|
|
35
|
+
import { ChevronDownIcon } from '@lucide/svelte';
|
|
36
|
+
import { Accordion as BitsAccordion } from 'bits-ui';
|
|
37
|
+
import { cls } from '../../utils/index.js';
|
|
38
|
+
|
|
39
|
+
let {
|
|
40
|
+
items,
|
|
41
|
+
type = 'single',
|
|
42
|
+
value = $bindable(),
|
|
43
|
+
onValueChange,
|
|
44
|
+
orientation = 'vertical',
|
|
45
|
+
headingLevel = 3,
|
|
46
|
+
loop,
|
|
47
|
+
disabled,
|
|
48
|
+
class: className,
|
|
49
|
+
itemClass,
|
|
50
|
+
triggerClass,
|
|
51
|
+
contentClass,
|
|
52
|
+
trigger: triggerSnippet,
|
|
53
|
+
content: contentSnippet,
|
|
54
|
+
}: Props = $props();
|
|
55
|
+
|
|
56
|
+
const singleValue = $derived(typeof value === 'string' ? value : '');
|
|
57
|
+
const multipleValue = $derived(Array.isArray(value) ? value : []);
|
|
58
|
+
|
|
59
|
+
function handleSingleValueChange(next: string): void {
|
|
60
|
+
value = next;
|
|
61
|
+
onValueChange?.(next);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function handleMultipleValueChange(next: string[]): void {
|
|
65
|
+
value = next;
|
|
66
|
+
onValueChange?.(next);
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
{#snippet renderItem(item: AccordionItem)}
|
|
71
|
+
<BitsAccordion.Item
|
|
72
|
+
value={item.value}
|
|
73
|
+
disabled={item.disabled}
|
|
74
|
+
data-slot="accordion-item"
|
|
75
|
+
class={cls('border-b last:border-b-0', itemClass)}
|
|
76
|
+
>
|
|
77
|
+
<BitsAccordion.Header level={headingLevel} class="flex">
|
|
78
|
+
<BitsAccordion.Trigger
|
|
79
|
+
data-slot="accordion-trigger"
|
|
80
|
+
class={cls(
|
|
81
|
+
'group flex flex-1 items-center justify-between gap-3 rounded-md px-3 py-3 text-left text-sm font-medium transition-colors outline-none hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50',
|
|
82
|
+
triggerClass,
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{#if triggerSnippet}
|
|
86
|
+
{@render triggerSnippet(item)}
|
|
87
|
+
{:else}
|
|
88
|
+
<span class="flex min-w-0 items-center gap-2">
|
|
89
|
+
{#if item.icon}
|
|
90
|
+
{@const Icon = item.icon}
|
|
91
|
+
<Icon class="size-4 shrink-0 text-muted-foreground" />
|
|
92
|
+
{/if}
|
|
93
|
+
<span>{item.title}</span>
|
|
94
|
+
</span>
|
|
95
|
+
<ChevronDownIcon
|
|
96
|
+
class="size-4 shrink-0 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 motion-reduce:transition-none"
|
|
97
|
+
/>
|
|
98
|
+
{/if}
|
|
99
|
+
</BitsAccordion.Trigger>
|
|
100
|
+
</BitsAccordion.Header>
|
|
101
|
+
|
|
102
|
+
<BitsAccordion.Content
|
|
103
|
+
data-slot="accordion-content"
|
|
104
|
+
class={cls(
|
|
105
|
+
'overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',
|
|
106
|
+
contentClass,
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
<div class="px-3 pb-4 text-muted-foreground">
|
|
110
|
+
{#if contentSnippet}
|
|
111
|
+
{@render contentSnippet(item)}
|
|
112
|
+
{:else}
|
|
113
|
+
{item.content}
|
|
114
|
+
{/if}
|
|
115
|
+
</div>
|
|
116
|
+
</BitsAccordion.Content>
|
|
117
|
+
</BitsAccordion.Item>
|
|
118
|
+
{/snippet}
|
|
119
|
+
|
|
120
|
+
{#if type === 'multiple'}
|
|
121
|
+
<BitsAccordion.Root
|
|
122
|
+
type="multiple"
|
|
123
|
+
value={multipleValue}
|
|
124
|
+
onValueChange={handleMultipleValueChange}
|
|
125
|
+
{orientation}
|
|
126
|
+
{loop}
|
|
127
|
+
{disabled}
|
|
128
|
+
data-slot="accordion"
|
|
129
|
+
class={cls('w-full', className)}
|
|
130
|
+
>
|
|
131
|
+
{#each items as item (item.value)}
|
|
132
|
+
{@render renderItem(item)}
|
|
133
|
+
{/each}
|
|
134
|
+
</BitsAccordion.Root>
|
|
135
|
+
{:else}
|
|
136
|
+
<BitsAccordion.Root
|
|
137
|
+
type="single"
|
|
138
|
+
value={singleValue}
|
|
139
|
+
onValueChange={handleSingleValueChange}
|
|
140
|
+
{orientation}
|
|
141
|
+
{loop}
|
|
142
|
+
{disabled}
|
|
143
|
+
data-slot="accordion"
|
|
144
|
+
class={cls('w-full', className)}
|
|
145
|
+
>
|
|
146
|
+
{#each items as item (item.value)}
|
|
147
|
+
{@render renderItem(item)}
|
|
148
|
+
{/each}
|
|
149
|
+
</BitsAccordion.Root>
|
|
150
|
+
{/if}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
export type AccordionItem = {
|
|
3
|
+
value: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
icon?: Component<{
|
|
7
|
+
class?: string;
|
|
8
|
+
}>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type AccordionType = 'single' | 'multiple';
|
|
12
|
+
export type AccordionOrientation = 'horizontal' | 'vertical';
|
|
13
|
+
export type AccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
|
+
export type Props = {
|
|
15
|
+
items: AccordionItem[];
|
|
16
|
+
type?: AccordionType;
|
|
17
|
+
value?: string | string[];
|
|
18
|
+
onValueChange?: (value: string | string[]) => void;
|
|
19
|
+
orientation?: AccordionOrientation;
|
|
20
|
+
headingLevel?: AccordionHeadingLevel;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
class?: string;
|
|
24
|
+
itemClass?: string;
|
|
25
|
+
triggerClass?: string;
|
|
26
|
+
contentClass?: string;
|
|
27
|
+
trigger?: Snippet<[AccordionItem]>;
|
|
28
|
+
content?: Snippet<[AccordionItem]>;
|
|
29
|
+
};
|
|
30
|
+
declare const Accordion: Component<Props, {}, "value">;
|
|
31
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
32
|
+
export default Accordion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Accordion } from './accordion.svelte';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import { tv, type VariantProps } from 'tailwind-variants';
|
|
4
|
+
|
|
5
|
+
export const alertVariants = tv({
|
|
6
|
+
base: 'relative w-full rounded-lg border p-4',
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: 'border-foreground/20 bg-background text-foreground',
|
|
10
|
+
destructive: 'border-destructive/40 bg-destructive/10 text-destructive',
|
|
11
|
+
brand: 'border-brand/40 bg-brand/10 text-foreground',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: 'default',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export type AlertVariant = VariantProps<typeof alertVariants>['variant'];
|
|
20
|
+
|
|
21
|
+
export type Props = {
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
variant?: AlertVariant;
|
|
25
|
+
icon?: Component<{ class?: string }>;
|
|
26
|
+
iconClass?: string;
|
|
27
|
+
children?: Snippet;
|
|
28
|
+
class?: string;
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import { cls } from '../../utils/index.js';
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
title,
|
|
37
|
+
description,
|
|
38
|
+
variant = 'default',
|
|
39
|
+
icon,
|
|
40
|
+
iconClass,
|
|
41
|
+
children,
|
|
42
|
+
class: className,
|
|
43
|
+
}: Props = $props();
|
|
44
|
+
|
|
45
|
+
const isDestructive = $derived(variant === 'destructive');
|
|
46
|
+
const isBrand = $derived(variant === 'brand');
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div role="alert" data-slot="alert" class={cls(alertVariants({ variant }), className)}>
|
|
50
|
+
<div class="flex gap-3">
|
|
51
|
+
{#if icon}
|
|
52
|
+
{@const Icon = icon}
|
|
53
|
+
<Icon
|
|
54
|
+
class={cls(
|
|
55
|
+
'mt-0.5 size-4 shrink-0',
|
|
56
|
+
isDestructive ? 'text-destructive' : 'text-brand-strong',
|
|
57
|
+
iconClass,
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
60
|
+
{/if}
|
|
61
|
+
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
|
62
|
+
{#if title}
|
|
63
|
+
<h5 class={cls('text-sm leading-none font-medium', isBrand && 'text-brand-strong')}>
|
|
64
|
+
{title}
|
|
65
|
+
</h5>
|
|
66
|
+
{/if}
|
|
67
|
+
{#if description}
|
|
68
|
+
<p class={cls('text-sm', isDestructive ? 'text-destructive/90' : 'text-muted-foreground')}>
|
|
69
|
+
{description}
|
|
70
|
+
</p>
|
|
71
|
+
{/if}
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
3
|
+
export declare const alertVariants: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
variant: {
|
|
5
|
+
default: string;
|
|
6
|
+
destructive: string;
|
|
7
|
+
brand: string;
|
|
8
|
+
};
|
|
9
|
+
}, undefined, "relative w-full rounded-lg border p-4", undefined, undefined, undefined>;
|
|
10
|
+
export type AlertVariant = VariantProps<typeof alertVariants>['variant'];
|
|
11
|
+
export type Props = {
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
variant?: AlertVariant;
|
|
15
|
+
icon?: Component<{
|
|
16
|
+
class?: string;
|
|
17
|
+
}>;
|
|
18
|
+
iconClass?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
class?: string;
|
|
21
|
+
};
|
|
22
|
+
declare const Alert: Component<Props, {}, "">;
|
|
23
|
+
type Alert = ReturnType<typeof Alert>;
|
|
24
|
+
export default Alert;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Alert, type Props as AlertProps, type AlertVariant, alertVariants, } from './alert.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Alert, alertVariants, } from './alert.svelte';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type Props = {
|
|
5
|
+
sidebar?: Snippet;
|
|
6
|
+
header?: Snippet;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
class?: string;
|
|
9
|
+
sidebarClass?: string;
|
|
10
|
+
headerClass?: string;
|
|
11
|
+
contentClass?: string;
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { cls } from '../../utils/index.js';
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
sidebar,
|
|
20
|
+
header,
|
|
21
|
+
children,
|
|
22
|
+
class: className,
|
|
23
|
+
sidebarClass,
|
|
24
|
+
headerClass,
|
|
25
|
+
contentClass,
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div
|
|
30
|
+
data-slot="app-shell"
|
|
31
|
+
class={cls('flex h-svh w-full overflow-hidden bg-background', className)}
|
|
32
|
+
>
|
|
33
|
+
{#if sidebar}
|
|
34
|
+
<div data-slot="app-shell-sidebar" class={cls('shrink-0', sidebarClass)}>
|
|
35
|
+
{@render sidebar()}
|
|
36
|
+
</div>
|
|
37
|
+
{/if}
|
|
38
|
+
|
|
39
|
+
<div class="flex min-w-0 flex-1 flex-col">
|
|
40
|
+
{#if header}
|
|
41
|
+
<header
|
|
42
|
+
data-slot="app-shell-header"
|
|
43
|
+
class={cls('shrink-0 border-b bg-background', headerClass)}
|
|
44
|
+
>
|
|
45
|
+
{@render header()}
|
|
46
|
+
</header>
|
|
47
|
+
{/if}
|
|
48
|
+
|
|
49
|
+
<main data-slot="app-shell-content" class={cls('min-h-0 flex-1 overflow-y-auto', contentClass)}>
|
|
50
|
+
{@render children?.()}
|
|
51
|
+
</main>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type Props = {
|
|
3
|
+
sidebar?: Snippet;
|
|
4
|
+
header?: Snippet;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
class?: string;
|
|
7
|
+
sidebarClass?: string;
|
|
8
|
+
headerClass?: string;
|
|
9
|
+
contentClass?: string;
|
|
10
|
+
};
|
|
11
|
+
declare const AppShell: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type AppShell = ReturnType<typeof AppShell>;
|
|
13
|
+
export default AppShell;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AppShell } from './app-shell.svelte';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { AttachmentItem, AttachmentSize } from './types.js';
|
|
3
|
+
|
|
4
|
+
export type Props = {
|
|
5
|
+
attachments: AttachmentItem[];
|
|
6
|
+
preview?: boolean;
|
|
7
|
+
removable?: boolean;
|
|
8
|
+
onRemove?: (attachment: AttachmentItem) => void;
|
|
9
|
+
removeLabel?: string;
|
|
10
|
+
size?: AttachmentSize;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
previewLabel?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { cls } from '../../utils/index.js';
|
|
19
|
+
import { Lightbox } from '../lightbox/index.js';
|
|
20
|
+
import Attachment from './attachment.svelte';
|
|
21
|
+
import { toLightboxItem } from './preview.js';
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
attachments,
|
|
25
|
+
preview = true,
|
|
26
|
+
removable = false,
|
|
27
|
+
onRemove,
|
|
28
|
+
removeLabel = 'Remove attachment',
|
|
29
|
+
size = 'default',
|
|
30
|
+
ariaLabel,
|
|
31
|
+
previewLabel = 'Attachment preview',
|
|
32
|
+
class: className,
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
|
|
35
|
+
let lightboxOpen = $state(false);
|
|
36
|
+
let lightboxIndex = $state(0);
|
|
37
|
+
|
|
38
|
+
const lightboxItems = $derived(preview ? attachments.map(toLightboxItem) : []);
|
|
39
|
+
|
|
40
|
+
$effect(() => {
|
|
41
|
+
if (lightboxOpen && lightboxItems.length === 0) lightboxOpen = false;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function openPreview(attachment: AttachmentItem): void {
|
|
45
|
+
const index = attachments.findIndex((candidate) => candidate.id === attachment.id);
|
|
46
|
+
if (index < 0) return;
|
|
47
|
+
lightboxIndex = index;
|
|
48
|
+
lightboxOpen = true;
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<ul
|
|
53
|
+
data-slot="attachment-list"
|
|
54
|
+
aria-label={ariaLabel}
|
|
55
|
+
class={cls('flex flex-wrap gap-2', className)}
|
|
56
|
+
>
|
|
57
|
+
{#each attachments as attachment (attachment.id)}
|
|
58
|
+
<li class="max-w-full">
|
|
59
|
+
<Attachment
|
|
60
|
+
{attachment}
|
|
61
|
+
{size}
|
|
62
|
+
{preview}
|
|
63
|
+
{removable}
|
|
64
|
+
{onRemove}
|
|
65
|
+
{removeLabel}
|
|
66
|
+
onPreview={preview ? openPreview : undefined}
|
|
67
|
+
/>
|
|
68
|
+
</li>
|
|
69
|
+
{/each}
|
|
70
|
+
</ul>
|
|
71
|
+
|
|
72
|
+
<Lightbox
|
|
73
|
+
bind:open={lightboxOpen}
|
|
74
|
+
bind:index={lightboxIndex}
|
|
75
|
+
items={lightboxItems}
|
|
76
|
+
ariaLabel={previewLabel}
|
|
77
|
+
/>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AttachmentItem, AttachmentSize } from './types.js';
|
|
2
|
+
export type Props = {
|
|
3
|
+
attachments: AttachmentItem[];
|
|
4
|
+
preview?: boolean;
|
|
5
|
+
removable?: boolean;
|
|
6
|
+
onRemove?: (attachment: AttachmentItem) => void;
|
|
7
|
+
removeLabel?: string;
|
|
8
|
+
size?: AttachmentSize;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
previewLabel?: string;
|
|
11
|
+
class?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const AttachmentList: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type AttachmentList = ReturnType<typeof AttachmentList>;
|
|
15
|
+
export default AttachmentList;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { AttachmentItem, AttachmentSize } from './types.js';
|
|
3
|
+
|
|
4
|
+
export type Props = {
|
|
5
|
+
attachment: AttachmentItem;
|
|
6
|
+
size?: AttachmentSize;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
removable?: boolean;
|
|
9
|
+
onPreview?: (attachment: AttachmentItem) => void;
|
|
10
|
+
onRemove?: (attachment: AttachmentItem) => void;
|
|
11
|
+
removeLabel?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { FileCodeIcon, FileIcon, FileTextIcon, ImageIcon, XIcon } from '@lucide/svelte';
|
|
18
|
+
import { cls } from '../../utils/index.js';
|
|
19
|
+
import { Button } from '../button/index.js';
|
|
20
|
+
import { formatFileSize } from './format.js';
|
|
21
|
+
import { getCodeLanguage, getTextFormat, getThumbnailSrc, isImageAttachment } from './preview.js';
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
attachment,
|
|
25
|
+
size = 'default',
|
|
26
|
+
preview = true,
|
|
27
|
+
removable = false,
|
|
28
|
+
onPreview,
|
|
29
|
+
onRemove,
|
|
30
|
+
removeLabel = 'Remove attachment',
|
|
31
|
+
class: className,
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
|
|
34
|
+
const isSmall = $derived(size === 'sm');
|
|
35
|
+
const imageSrc = $derived(
|
|
36
|
+
preview && isImageAttachment(attachment) ? getThumbnailSrc(attachment) : undefined,
|
|
37
|
+
);
|
|
38
|
+
const hasPreviewAction = $derived(Boolean(preview && onPreview));
|
|
39
|
+
function getFileTypeIcon() {
|
|
40
|
+
if (getCodeLanguage(attachment)) return FileCodeIcon;
|
|
41
|
+
if (getTextFormat(attachment)) return FileTextIcon;
|
|
42
|
+
return FileIcon;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const FileTypeIcon = $derived(getFileTypeIcon());
|
|
46
|
+
const sizeLabel = $derived(formatFileSize(attachment.size));
|
|
47
|
+
const previewLabel = $derived(`Preview ${attachment.name}${sizeLabel ? ` ${sizeLabel}` : ''}`);
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div
|
|
51
|
+
data-slot="attachment"
|
|
52
|
+
data-attachment-id={attachment.id}
|
|
53
|
+
class={cls(
|
|
54
|
+
'flex max-w-full items-center gap-1 rounded-md border bg-background p-1',
|
|
55
|
+
isSmall && 'max-w-64 rounded-lg',
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
{#snippet content()}
|
|
60
|
+
{#if imageSrc}
|
|
61
|
+
<img
|
|
62
|
+
data-slot="attachment-thumbnail"
|
|
63
|
+
src={imageSrc}
|
|
64
|
+
alt=""
|
|
65
|
+
loading="lazy"
|
|
66
|
+
class="size-8 shrink-0 rounded-md border object-cover"
|
|
67
|
+
/>
|
|
68
|
+
{:else if isImageAttachment(attachment)}
|
|
69
|
+
<ImageIcon class="size-4 shrink-0 text-muted-foreground" />
|
|
70
|
+
{:else}
|
|
71
|
+
<FileTypeIcon class="size-4 shrink-0 text-muted-foreground" />
|
|
72
|
+
{/if}
|
|
73
|
+
<div class={cls('min-w-0 flex-1', isSmall ? 'grid' : 'flex items-center gap-2')}>
|
|
74
|
+
<span class={cls('truncate', isSmall && 'font-medium')}>{attachment.name}</span>
|
|
75
|
+
{#if sizeLabel}
|
|
76
|
+
<span class="shrink-0 text-xs text-muted-foreground">
|
|
77
|
+
{sizeLabel}
|
|
78
|
+
</span>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
{/snippet}
|
|
82
|
+
|
|
83
|
+
{#if hasPreviewAction}
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
data-slot="attachment-preview"
|
|
87
|
+
aria-label={previewLabel}
|
|
88
|
+
class={cls(
|
|
89
|
+
'flex min-w-0 flex-1 items-center gap-2 rounded-md text-left transition-colors hover:bg-accent/50',
|
|
90
|
+
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden',
|
|
91
|
+
isSmall ? 'py-0.5 pr-1 pl-1 text-xs' : 'px-1.5 py-1 text-sm',
|
|
92
|
+
)}
|
|
93
|
+
onclick={() => onPreview?.(attachment)}
|
|
94
|
+
>
|
|
95
|
+
{@render content()}
|
|
96
|
+
</button>
|
|
97
|
+
{:else}
|
|
98
|
+
<div
|
|
99
|
+
class={cls(
|
|
100
|
+
'flex min-w-0 flex-1 items-center gap-2',
|
|
101
|
+
isSmall ? 'py-0.5 pr-1 pl-1 text-xs' : 'px-1.5 py-1 text-sm',
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{@render content()}
|
|
105
|
+
</div>
|
|
106
|
+
{/if}
|
|
107
|
+
|
|
108
|
+
{#if removable}
|
|
109
|
+
<Button
|
|
110
|
+
variant="ghost"
|
|
111
|
+
size="icon"
|
|
112
|
+
class={cls('shrink-0', isSmall ? 'size-6' : 'size-7')}
|
|
113
|
+
aria-label={`${removeLabel}: ${attachment.name}`}
|
|
114
|
+
onclick={() => onRemove?.(attachment)}
|
|
115
|
+
>
|
|
116
|
+
<XIcon />
|
|
117
|
+
</Button>
|
|
118
|
+
{/if}
|
|
119
|
+
</div>
|