@leap-online/jolt 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +83 -0
- package/dist/components/badge/badge.svelte.d.ts +39 -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/description-list/description-list.svelte +108 -0
- package/dist/components/description-list/description-list.svelte.d.ts +29 -0
- package/dist/components/description-list/index.d.ts +1 -0
- package/dist/components/description-list/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/feed-item/feed-item.svelte +104 -0
- package/dist/components/feed-item/feed-item.svelte.d.ts +16 -0
- package/dist/components/feed-item/index.d.ts +1 -0
- package/dist/components/feed-item/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/severity-dot/index.d.ts +1 -0
- package/dist/components/severity-dot/index.js +1 -0
- package/dist/components/severity-dot/severity-dot.svelte +55 -0
- package/dist/components/severity-dot/severity-dot.svelte.d.ts +12 -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-ago/index.d.ts +1 -0
- package/dist/components/time-ago/index.js +1 -0
- package/dist/components/time-ago/time-ago.svelte +48 -0
- package/dist/components/time-ago/time-ago.svelte.d.ts +9 -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 +72 -0
- package/dist/index.js +71 -0
- package/dist/styles/theme.css +385 -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/format.d.ts +24 -0
- package/dist/utils/format.js +82 -0
- package/dist/utils/highlight.d.ts +4 -0
- package/dist/utils/highlight.js +82 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +123 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AttachmentItem, AttachmentSize } from './types.js';
|
|
2
|
+
export type Props = {
|
|
3
|
+
attachment: AttachmentItem;
|
|
4
|
+
size?: AttachmentSize;
|
|
5
|
+
preview?: boolean;
|
|
6
|
+
removable?: boolean;
|
|
7
|
+
onPreview?: (attachment: AttachmentItem) => void;
|
|
8
|
+
onRemove?: (attachment: AttachmentItem) => void;
|
|
9
|
+
removeLabel?: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const Attachment: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type Attachment = ReturnType<typeof Attachment>;
|
|
14
|
+
export default Attachment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFileSize(bytes: number | undefined): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LightboxItem, LightboxTextFormat } from '../lightbox/index.js';
|
|
2
|
+
import type { AttachmentItem } from './types.js';
|
|
3
|
+
export declare function isImageAttachment(attachment: AttachmentItem): boolean;
|
|
4
|
+
export declare function getTextFormat(attachment: AttachmentItem): LightboxTextFormat | null;
|
|
5
|
+
export declare function getCodeLanguage(attachment: AttachmentItem): string | null;
|
|
6
|
+
export declare function hasTextPreview(attachment: AttachmentItem): boolean;
|
|
7
|
+
export declare function getPreviewSrc(attachment: AttachmentItem): string | undefined;
|
|
8
|
+
export declare function getThumbnailSrc(attachment: AttachmentItem): string | undefined;
|
|
9
|
+
export declare function toLightboxItem(attachment: AttachmentItem): LightboxItem;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
const imageExtension = /\.(avif|gif|jpe?g|png|svg|webp)$/i;
|
|
2
|
+
const markdownExtension = /\.(md|markdown)$/i;
|
|
3
|
+
const textExtension = /\.(txt|text)$/i;
|
|
4
|
+
const codeExtensions = {
|
|
5
|
+
bash: 'bash',
|
|
6
|
+
c: 'c',
|
|
7
|
+
cc: 'cpp',
|
|
8
|
+
conf: 'ini',
|
|
9
|
+
cpp: 'cpp',
|
|
10
|
+
cs: 'csharp',
|
|
11
|
+
csx: 'csharp',
|
|
12
|
+
css: 'css',
|
|
13
|
+
cts: 'typescript',
|
|
14
|
+
cxx: 'cpp',
|
|
15
|
+
diff: 'diff',
|
|
16
|
+
go: 'go',
|
|
17
|
+
gql: 'graphql',
|
|
18
|
+
graphql: 'graphql',
|
|
19
|
+
h: 'c',
|
|
20
|
+
hh: 'cpp',
|
|
21
|
+
hpp: 'cpp',
|
|
22
|
+
htm: 'xml',
|
|
23
|
+
html: 'xml',
|
|
24
|
+
hxx: 'cpp',
|
|
25
|
+
ini: 'ini',
|
|
26
|
+
java: 'java',
|
|
27
|
+
js: 'javascript',
|
|
28
|
+
json: 'json',
|
|
29
|
+
jsonc: 'json',
|
|
30
|
+
jsx: 'javascript',
|
|
31
|
+
kt: 'kotlin',
|
|
32
|
+
kts: 'kotlin',
|
|
33
|
+
lua: 'lua',
|
|
34
|
+
markdown: 'markdown',
|
|
35
|
+
md: 'markdown',
|
|
36
|
+
mjs: 'javascript',
|
|
37
|
+
mts: 'typescript',
|
|
38
|
+
patch: 'diff',
|
|
39
|
+
php: 'php',
|
|
40
|
+
proto: 'protobuf',
|
|
41
|
+
py: 'python',
|
|
42
|
+
pyw: 'python',
|
|
43
|
+
rb: 'ruby',
|
|
44
|
+
rs: 'rust',
|
|
45
|
+
sh: 'bash',
|
|
46
|
+
sql: 'sql',
|
|
47
|
+
svelte: 'xml',
|
|
48
|
+
swift: 'swift',
|
|
49
|
+
toml: 'ini',
|
|
50
|
+
ts: 'typescript',
|
|
51
|
+
tsx: 'typescript',
|
|
52
|
+
vue: 'xml',
|
|
53
|
+
xhtml: 'xml',
|
|
54
|
+
xml: 'xml',
|
|
55
|
+
yaml: 'yaml',
|
|
56
|
+
yml: 'yaml',
|
|
57
|
+
zsh: 'bash',
|
|
58
|
+
};
|
|
59
|
+
const codeMimeTypes = {
|
|
60
|
+
'application/graphql': 'graphql',
|
|
61
|
+
'application/javascript': 'javascript',
|
|
62
|
+
'application/json': 'json',
|
|
63
|
+
'application/ld+json': 'json',
|
|
64
|
+
'application/protobuf': 'protobuf',
|
|
65
|
+
'application/sql': 'sql',
|
|
66
|
+
'application/toml': 'ini',
|
|
67
|
+
'application/typescript': 'typescript',
|
|
68
|
+
'application/x-httpd-php': 'php',
|
|
69
|
+
'application/x-javascript': 'javascript',
|
|
70
|
+
'application/x-python': 'python',
|
|
71
|
+
'application/x-ruby': 'ruby',
|
|
72
|
+
'application/x-sh': 'bash',
|
|
73
|
+
'application/x-shellscript': 'bash',
|
|
74
|
+
'application/x-yaml': 'yaml',
|
|
75
|
+
'application/xml': 'xml',
|
|
76
|
+
'text/css': 'css',
|
|
77
|
+
'text/html': 'xml',
|
|
78
|
+
'text/javascript': 'javascript',
|
|
79
|
+
'text/typescript': 'typescript',
|
|
80
|
+
'text/x-c': 'c',
|
|
81
|
+
'text/x-c++': 'cpp',
|
|
82
|
+
'text/x-csharp': 'csharp',
|
|
83
|
+
'text/x-go': 'go',
|
|
84
|
+
'text/x-ini': 'ini',
|
|
85
|
+
'text/x-java-source': 'java',
|
|
86
|
+
'text/x-kotlin': 'kotlin',
|
|
87
|
+
'text/x-lua': 'lua',
|
|
88
|
+
'text/x-python': 'python',
|
|
89
|
+
'text/x-rust': 'rust',
|
|
90
|
+
'text/x-sql': 'sql',
|
|
91
|
+
'text/x-swift': 'swift',
|
|
92
|
+
'text/xml': 'xml',
|
|
93
|
+
'text/yaml': 'yaml',
|
|
94
|
+
};
|
|
95
|
+
const codeFileNames = {
|
|
96
|
+
containerfile: 'dockerfile',
|
|
97
|
+
dockerfile: 'dockerfile',
|
|
98
|
+
gnumakefile: 'makefile',
|
|
99
|
+
makefile: 'makefile',
|
|
100
|
+
};
|
|
101
|
+
function getExtension(name) {
|
|
102
|
+
const dot = name.lastIndexOf('.');
|
|
103
|
+
return dot >= 0 ? name.slice(dot + 1).toLowerCase() : '';
|
|
104
|
+
}
|
|
105
|
+
export function isImageAttachment(attachment) {
|
|
106
|
+
return Boolean(attachment.type?.startsWith('image/') || imageExtension.test(attachment.name));
|
|
107
|
+
}
|
|
108
|
+
export function getTextFormat(attachment) {
|
|
109
|
+
const type = attachment.type?.toLowerCase();
|
|
110
|
+
if (type?.startsWith('text/markdown') || markdownExtension.test(attachment.name)) {
|
|
111
|
+
return 'markdown';
|
|
112
|
+
}
|
|
113
|
+
if (type?.startsWith('text/plain') || textExtension.test(attachment.name)) {
|
|
114
|
+
return 'text';
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
export function getCodeLanguage(attachment) {
|
|
119
|
+
const name = attachment.name.toLowerCase();
|
|
120
|
+
const baseName = name.split('/').pop() ?? name;
|
|
121
|
+
const fileNameLanguage = codeFileNames[baseName];
|
|
122
|
+
if (fileNameLanguage)
|
|
123
|
+
return fileNameLanguage;
|
|
124
|
+
if (baseName.startsWith('dockerfile.') || baseName.startsWith('containerfile.')) {
|
|
125
|
+
return 'dockerfile';
|
|
126
|
+
}
|
|
127
|
+
const extensionLanguage = codeExtensions[getExtension(name)];
|
|
128
|
+
if (extensionLanguage)
|
|
129
|
+
return extensionLanguage;
|
|
130
|
+
const mimeType = attachment.type?.split(';')[0]?.trim().toLowerCase();
|
|
131
|
+
if (mimeType)
|
|
132
|
+
return codeMimeTypes[mimeType] ?? null;
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
export function hasTextPreview(attachment) {
|
|
136
|
+
return getTextFormat(attachment) !== null || getCodeLanguage(attachment) !== null;
|
|
137
|
+
}
|
|
138
|
+
export function getPreviewSrc(attachment) {
|
|
139
|
+
return attachment.previewSrc ?? attachment.href ?? attachment.thumbnailSrc;
|
|
140
|
+
}
|
|
141
|
+
export function getThumbnailSrc(attachment) {
|
|
142
|
+
return attachment.thumbnailSrc ?? attachment.previewSrc ?? attachment.href;
|
|
143
|
+
}
|
|
144
|
+
export function toLightboxItem(attachment) {
|
|
145
|
+
const src = getPreviewSrc(attachment);
|
|
146
|
+
if (isImageAttachment(attachment) && src) {
|
|
147
|
+
const image = {
|
|
148
|
+
kind: 'image',
|
|
149
|
+
src,
|
|
150
|
+
alt: attachment.alt ?? attachment.name,
|
|
151
|
+
caption: attachment.name,
|
|
152
|
+
downloadUrl: attachment.href,
|
|
153
|
+
};
|
|
154
|
+
return image;
|
|
155
|
+
}
|
|
156
|
+
const format = getTextFormat(attachment);
|
|
157
|
+
const language = getCodeLanguage(attachment);
|
|
158
|
+
if (format === 'markdown' && attachment.content !== undefined) {
|
|
159
|
+
return {
|
|
160
|
+
kind: 'text',
|
|
161
|
+
title: attachment.name,
|
|
162
|
+
content: attachment.content,
|
|
163
|
+
format,
|
|
164
|
+
downloadUrl: attachment.href,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (language && attachment.content !== undefined) {
|
|
168
|
+
return {
|
|
169
|
+
kind: 'code',
|
|
170
|
+
title: attachment.name,
|
|
171
|
+
content: attachment.content,
|
|
172
|
+
language,
|
|
173
|
+
downloadUrl: attachment.href,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (format === 'text' && attachment.content !== undefined) {
|
|
177
|
+
return {
|
|
178
|
+
kind: 'text',
|
|
179
|
+
title: attachment.name,
|
|
180
|
+
content: attachment.content,
|
|
181
|
+
format,
|
|
182
|
+
downloadUrl: attachment.href,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
kind: 'file',
|
|
187
|
+
name: attachment.name,
|
|
188
|
+
mimeType: attachment.type,
|
|
189
|
+
downloadUrl: attachment.href,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type AvatarSize = 'sm' | 'default' | 'lg' | 'xl';
|
|
5
|
+
export type AvatarStatus = 'online' | 'away' | 'busy' | 'offline';
|
|
6
|
+
|
|
7
|
+
export type Props = {
|
|
8
|
+
src?: string;
|
|
9
|
+
alt: string;
|
|
10
|
+
initials?: string;
|
|
11
|
+
fallback?: Snippet;
|
|
12
|
+
size?: AvatarSize;
|
|
13
|
+
status?: AvatarStatus;
|
|
14
|
+
statusLabel?: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
imageClass?: string;
|
|
17
|
+
fallbackClass?: string;
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import { Avatar as BitsAvatar } from 'bits-ui';
|
|
23
|
+
import { cls } from '../../utils/index.js';
|
|
24
|
+
|
|
25
|
+
const sizeClasses: Record<AvatarSize, string> = {
|
|
26
|
+
sm: 'size-8 text-xs',
|
|
27
|
+
default: 'size-10 text-sm',
|
|
28
|
+
lg: 'size-12 text-base',
|
|
29
|
+
xl: 'size-16 text-lg',
|
|
30
|
+
};
|
|
31
|
+
const statusSizeClasses: Record<AvatarSize, string> = {
|
|
32
|
+
sm: 'size-2',
|
|
33
|
+
default: 'size-2.5',
|
|
34
|
+
lg: 'size-3',
|
|
35
|
+
xl: 'size-3.5',
|
|
36
|
+
};
|
|
37
|
+
const statusClasses: Record<AvatarStatus, string> = {
|
|
38
|
+
online: 'bg-success',
|
|
39
|
+
away: 'bg-brand',
|
|
40
|
+
busy: 'bg-destructive',
|
|
41
|
+
offline: 'bg-muted-foreground',
|
|
42
|
+
};
|
|
43
|
+
const statusLabels: Record<AvatarStatus, string> = {
|
|
44
|
+
online: 'Online',
|
|
45
|
+
away: 'Away',
|
|
46
|
+
busy: 'Busy',
|
|
47
|
+
offline: 'Offline',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let {
|
|
51
|
+
src,
|
|
52
|
+
alt,
|
|
53
|
+
initials,
|
|
54
|
+
fallback,
|
|
55
|
+
size = 'default',
|
|
56
|
+
status,
|
|
57
|
+
statusLabel,
|
|
58
|
+
class: className,
|
|
59
|
+
imageClass,
|
|
60
|
+
fallbackClass,
|
|
61
|
+
}: Props = $props();
|
|
62
|
+
|
|
63
|
+
function getInitials(name: string): string {
|
|
64
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
65
|
+
if (parts.length === 0) return '?';
|
|
66
|
+
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
|
|
67
|
+
return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const fallbackText = $derived(initials ?? getInitials(alt));
|
|
71
|
+
const statusText = $derived(status ? (statusLabel ?? statusLabels[status]) : '');
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<span class="relative inline-flex shrink-0" data-slot="avatar-presence">
|
|
75
|
+
<BitsAvatar.Root
|
|
76
|
+
data-slot="avatar"
|
|
77
|
+
class={cls('relative flex shrink-0 overflow-hidden rounded-full', sizeClasses[size], className)}
|
|
78
|
+
>
|
|
79
|
+
{#if src}
|
|
80
|
+
<BitsAvatar.Image
|
|
81
|
+
{src}
|
|
82
|
+
{alt}
|
|
83
|
+
data-slot="avatar-image"
|
|
84
|
+
class={cls('aspect-square size-full object-cover', imageClass)}
|
|
85
|
+
/>
|
|
86
|
+
{/if}
|
|
87
|
+
<BitsAvatar.Fallback
|
|
88
|
+
data-slot="avatar-fallback"
|
|
89
|
+
class={cls(
|
|
90
|
+
'flex size-full items-center justify-center rounded-full bg-muted font-medium text-muted-foreground',
|
|
91
|
+
fallbackClass,
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
{#if fallback}
|
|
95
|
+
{@render fallback()}
|
|
96
|
+
{:else}
|
|
97
|
+
{fallbackText}
|
|
98
|
+
{/if}
|
|
99
|
+
</BitsAvatar.Fallback>
|
|
100
|
+
</BitsAvatar.Root>
|
|
101
|
+
|
|
102
|
+
{#if status}
|
|
103
|
+
<span
|
|
104
|
+
data-slot="avatar-status"
|
|
105
|
+
role="img"
|
|
106
|
+
aria-label={statusText}
|
|
107
|
+
title={statusText}
|
|
108
|
+
class={cls(
|
|
109
|
+
'absolute end-0 bottom-0 z-10 rounded-full ring-2 ring-background',
|
|
110
|
+
statusSizeClasses[size],
|
|
111
|
+
statusClasses[status],
|
|
112
|
+
)}
|
|
113
|
+
></span>
|
|
114
|
+
{/if}
|
|
115
|
+
</span>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type AvatarSize = 'sm' | 'default' | 'lg' | 'xl';
|
|
3
|
+
export type AvatarStatus = 'online' | 'away' | 'busy' | 'offline';
|
|
4
|
+
export type Props = {
|
|
5
|
+
src?: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
initials?: string;
|
|
8
|
+
fallback?: Snippet;
|
|
9
|
+
size?: AvatarSize;
|
|
10
|
+
status?: AvatarStatus;
|
|
11
|
+
statusLabel?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
imageClass?: string;
|
|
14
|
+
fallbackClass?: string;
|
|
15
|
+
};
|
|
16
|
+
declare const Avatar: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type Avatar = ReturnType<typeof Avatar>;
|
|
18
|
+
export default Avatar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar, type Props as AvatarProps, type AvatarSize, type AvatarStatus, } from './avatar.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar, } from './avatar.svelte';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { AvatarSize, AvatarStatus } from '../avatar/index.js';
|
|
3
|
+
|
|
4
|
+
export type AvatarGroupItem = {
|
|
5
|
+
src?: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
initials?: string;
|
|
8
|
+
status?: AvatarStatus;
|
|
9
|
+
statusLabel?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Props = {
|
|
13
|
+
items: AvatarGroupItem[];
|
|
14
|
+
max?: number;
|
|
15
|
+
size?: AvatarSize;
|
|
16
|
+
ariaLabel?: string;
|
|
17
|
+
class?: string;
|
|
18
|
+
avatarClass?: string;
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { cls } from '../../utils/index.js';
|
|
24
|
+
import { Avatar } from '../avatar/index.js';
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
items,
|
|
28
|
+
max = 4,
|
|
29
|
+
size = 'default',
|
|
30
|
+
ariaLabel,
|
|
31
|
+
class: className,
|
|
32
|
+
avatarClass,
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
|
|
35
|
+
const visibleItems = $derived(items.slice(0, Math.max(0, max)));
|
|
36
|
+
const overflowCount = $derived(Math.max(0, items.length - visibleItems.length));
|
|
37
|
+
const groupLabel = $derived(ariaLabel ?? `${items.length} people`);
|
|
38
|
+
const overflowSizeClasses: Record<AvatarSize, string> = {
|
|
39
|
+
sm: 'size-8 text-xs',
|
|
40
|
+
default: 'size-10 text-sm',
|
|
41
|
+
lg: 'size-12 text-base',
|
|
42
|
+
xl: 'size-16 text-lg',
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<div
|
|
47
|
+
role="group"
|
|
48
|
+
aria-label={groupLabel}
|
|
49
|
+
data-slot="avatar-group"
|
|
50
|
+
class={cls('flex items-center -space-x-2', className)}
|
|
51
|
+
>
|
|
52
|
+
{#each visibleItems as item, index (index)}
|
|
53
|
+
<div class="relative rounded-full ring-2 ring-background" data-slot="avatar-group-item">
|
|
54
|
+
<Avatar
|
|
55
|
+
src={item.src}
|
|
56
|
+
alt={item.alt}
|
|
57
|
+
initials={item.initials}
|
|
58
|
+
status={item.status}
|
|
59
|
+
statusLabel={item.statusLabel}
|
|
60
|
+
{size}
|
|
61
|
+
class={avatarClass}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
{/each}
|
|
65
|
+
|
|
66
|
+
{#if overflowCount > 0}
|
|
67
|
+
<span
|
|
68
|
+
aria-label={`${overflowCount} more`}
|
|
69
|
+
title={`${overflowCount} more`}
|
|
70
|
+
data-slot="avatar-group-overflow"
|
|
71
|
+
class={cls(
|
|
72
|
+
'relative flex items-center justify-center rounded-full bg-muted font-medium text-muted-foreground ring-2 ring-background',
|
|
73
|
+
overflowSizeClasses[size],
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
+{overflowCount}
|
|
77
|
+
</span>
|
|
78
|
+
{/if}
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AvatarSize, AvatarStatus } from '../avatar/index.js';
|
|
2
|
+
export type AvatarGroupItem = {
|
|
3
|
+
src?: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
initials?: string;
|
|
6
|
+
status?: AvatarStatus;
|
|
7
|
+
statusLabel?: string;
|
|
8
|
+
};
|
|
9
|
+
export type Props = {
|
|
10
|
+
items: AvatarGroupItem[];
|
|
11
|
+
max?: number;
|
|
12
|
+
size?: AvatarSize;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
class?: string;
|
|
15
|
+
avatarClass?: string;
|
|
16
|
+
};
|
|
17
|
+
declare const AvatarGroup: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type AvatarGroup = ReturnType<typeof AvatarGroup>;
|
|
19
|
+
export default AvatarGroup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AvatarGroup, type AvatarGroupItem, type Props as AvatarGroupProps, } from './avatar-group.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AvatarGroup, } from './avatar-group.svelte';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import { tv, type VariantProps } from 'tailwind-variants';
|
|
4
|
+
|
|
5
|
+
export const badgeVariants = tv({
|
|
6
|
+
base: 'inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden',
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: 'border-transparent bg-primary text-primary-foreground',
|
|
10
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground',
|
|
11
|
+
outline: 'border-foreground/20 text-foreground',
|
|
12
|
+
brand: 'border-transparent bg-brand text-brand-foreground',
|
|
13
|
+
destructive: 'border-transparent bg-destructive text-destructive-foreground',
|
|
14
|
+
neutral: 'border-border bg-muted text-muted-foreground',
|
|
15
|
+
info: 'border-info/20 bg-info/10 text-info',
|
|
16
|
+
success: 'border-success/20 bg-success/10 text-success',
|
|
17
|
+
warning: 'border-warning/20 bg-warning/10 text-warning',
|
|
18
|
+
danger: 'border-destructive/20 bg-destructive/10 text-destructive',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: 'default',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
|
|
27
|
+
export type BadgeIcon = Component<{ class?: string }>;
|
|
28
|
+
|
|
29
|
+
export type BadgeBase = {
|
|
30
|
+
icon?: BadgeIcon;
|
|
31
|
+
iconClass?: string;
|
|
32
|
+
variant?: BadgeVariant;
|
|
33
|
+
dot?: boolean;
|
|
34
|
+
class?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type Props = BadgeBase &
|
|
38
|
+
(
|
|
39
|
+
| { label: string; count?: never; maxCount?: never }
|
|
40
|
+
| { count: number; maxCount?: number; label?: never }
|
|
41
|
+
);
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
import { cls } from '../../utils/index.js';
|
|
46
|
+
|
|
47
|
+
function formatCount(value: number, limit: number): string {
|
|
48
|
+
return value > limit ? `${limit}+` : String(value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let {
|
|
52
|
+
class: className,
|
|
53
|
+
label,
|
|
54
|
+
count,
|
|
55
|
+
icon,
|
|
56
|
+
iconClass,
|
|
57
|
+
variant = 'default',
|
|
58
|
+
dot = false,
|
|
59
|
+
maxCount = 99,
|
|
60
|
+
}: Props = $props();
|
|
61
|
+
|
|
62
|
+
const isCount = $derived(typeof count === 'number');
|
|
63
|
+
const countLabel = $derived(typeof count === 'number' ? formatCount(count, maxCount) : label);
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<span
|
|
67
|
+
data-slot="badge"
|
|
68
|
+
data-variant={variant}
|
|
69
|
+
class={cls(
|
|
70
|
+
badgeVariants({ variant }),
|
|
71
|
+
isCount && 'min-w-5 justify-center px-1.5 tabular-nums',
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
{#if dot}
|
|
76
|
+
<span data-slot="badge-dot" aria-hidden="true" class="size-1.5 rounded-full bg-current"></span>
|
|
77
|
+
{/if}
|
|
78
|
+
{#if icon}
|
|
79
|
+
{@const Icon = icon}
|
|
80
|
+
<Icon class={cls('size-3', iconClass)} />
|
|
81
|
+
{/if}
|
|
82
|
+
{isCount ? countLabel : label}
|
|
83
|
+
</span>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
3
|
+
export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
variant: {
|
|
5
|
+
default: string;
|
|
6
|
+
secondary: string;
|
|
7
|
+
outline: string;
|
|
8
|
+
brand: string;
|
|
9
|
+
destructive: string;
|
|
10
|
+
neutral: string;
|
|
11
|
+
info: string;
|
|
12
|
+
success: string;
|
|
13
|
+
warning: string;
|
|
14
|
+
danger: string;
|
|
15
|
+
};
|
|
16
|
+
}, undefined, "inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden", undefined, undefined, undefined>;
|
|
17
|
+
export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
|
|
18
|
+
export type BadgeIcon = Component<{
|
|
19
|
+
class?: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type BadgeBase = {
|
|
22
|
+
icon?: BadgeIcon;
|
|
23
|
+
iconClass?: string;
|
|
24
|
+
variant?: BadgeVariant;
|
|
25
|
+
dot?: boolean;
|
|
26
|
+
class?: string;
|
|
27
|
+
};
|
|
28
|
+
export type Props = BadgeBase & ({
|
|
29
|
+
label: string;
|
|
30
|
+
count?: never;
|
|
31
|
+
maxCount?: never;
|
|
32
|
+
} | {
|
|
33
|
+
count: number;
|
|
34
|
+
maxCount?: number;
|
|
35
|
+
label?: never;
|
|
36
|
+
});
|
|
37
|
+
declare const Badge: Component<Props, {}, "">;
|
|
38
|
+
type Badge = ReturnType<typeof Badge>;
|
|
39
|
+
export default Badge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Badge, type BadgeIcon, type Props as BadgeProps, type BadgeVariant, badgeVariants, } from './badge.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Badge, badgeVariants, } from './badge.svelte';
|