@bevelo/svelte 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/accordion.svelte +98 -0
- package/dist/accordion.svelte.d.ts +29 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +5 -0
- package/dist/alert-dialog.svelte +17 -0
- package/dist/alert-dialog.svelte.d.ts +7 -0
- package/dist/alert.svelte +78 -0
- package/dist/alert.svelte.d.ts +16 -0
- package/dist/aspect-ratio.svelte +43 -0
- package/dist/aspect-ratio.svelte.d.ts +12 -0
- package/dist/async-options.svelte.d.ts +42 -0
- package/dist/async-options.svelte.js +94 -0
- package/dist/autocomplete.svelte +332 -0
- package/dist/autocomplete.svelte.d.ts +81 -0
- package/dist/avatar.svelte +39 -0
- package/dist/avatar.svelte.d.ts +12 -0
- package/dist/badge.svelte +37 -0
- package/dist/badge.svelte.d.ts +12 -0
- package/dist/bound.svelte.d.ts +15 -0
- package/dist/bound.svelte.js +56 -0
- package/dist/breadcrumb.svelte +90 -0
- package/dist/breadcrumb.svelte.d.ts +22 -0
- package/dist/button.svelte +45 -0
- package/dist/button.svelte.d.ts +12 -0
- package/dist/calendar.svelte +463 -0
- package/dist/calendar.svelte.d.ts +74 -0
- package/dist/card.svelte +69 -0
- package/dist/card.svelte.d.ts +16 -0
- package/dist/carousel.svelte +262 -0
- package/dist/carousel.svelte.d.ts +45 -0
- package/dist/checkbox-group-scope.d.ts +11 -0
- package/dist/checkbox-group-scope.js +5 -0
- package/dist/checkbox-group.svelte +93 -0
- package/dist/checkbox-group.svelte.d.ts +18 -0
- package/dist/checkbox.svelte +89 -0
- package/dist/checkbox.svelte.d.ts +16 -0
- package/dist/collapsible.svelte +73 -0
- package/dist/collapsible.svelte.d.ts +25 -0
- package/dist/color-picker-alpha-thumb.svelte +11 -0
- package/dist/color-picker-alpha-thumb.svelte.d.ts +4 -0
- package/dist/color-picker-area-canvas.svelte +11 -0
- package/dist/color-picker-area-canvas.svelte.d.ts +4 -0
- package/dist/color-picker-area-thumb.svelte +11 -0
- package/dist/color-picker-area-thumb.svelte.d.ts +4 -0
- package/dist/color-picker-area.svelte +11 -0
- package/dist/color-picker-area.svelte.d.ts +4 -0
- package/dist/color-picker-channel-input.svelte +35 -0
- package/dist/color-picker-channel-input.svelte.d.ts +9 -0
- package/dist/color-picker-context.d.ts +23 -0
- package/dist/color-picker-context.js +24 -0
- package/dist/color-picker-eye-dropper.svelte +11 -0
- package/dist/color-picker-eye-dropper.svelte.d.ts +4 -0
- package/dist/color-picker-input.svelte +11 -0
- package/dist/color-picker-input.svelte.d.ts +4 -0
- package/dist/color-picker-part.svelte +38 -0
- package/dist/color-picker-part.svelte.d.ts +11 -0
- package/dist/color-picker-slider-thumb.svelte +11 -0
- package/dist/color-picker-slider-thumb.svelte.d.ts +4 -0
- package/dist/color-picker-slider.svelte +21 -0
- package/dist/color-picker-slider.svelte.d.ts +9 -0
- package/dist/color-picker-swatch-item.svelte +38 -0
- package/dist/color-picker-swatch-item.svelte.d.ts +9 -0
- package/dist/color-picker-swatch.svelte +11 -0
- package/dist/color-picker-swatch.svelte.d.ts +4 -0
- package/dist/color-picker-swatches.svelte +11 -0
- package/dist/color-picker-swatches.svelte.d.ts +4 -0
- package/dist/color-picker.svelte +132 -0
- package/dist/color-picker.svelte.d.ts +18 -0
- package/dist/combobox-chip-remove.svelte +25 -0
- package/dist/combobox-chip-remove.svelte.d.ts +4 -0
- package/dist/combobox-chip.svelte +14 -0
- package/dist/combobox-chip.svelte.d.ts +7 -0
- package/dist/combobox-chips-overflow.svelte +27 -0
- package/dist/combobox-chips-overflow.svelte.d.ts +12 -0
- package/dist/combobox-chips.svelte +12 -0
- package/dist/combobox-chips.svelte.d.ts +4 -0
- package/dist/combobox-clear.svelte +27 -0
- package/dist/combobox-clear.svelte.d.ts +4 -0
- package/dist/combobox-compound-root.svelte +150 -0
- package/dist/combobox-compound-root.svelte.d.ts +37 -0
- package/dist/combobox-compound.svelte.d.ts +59 -0
- package/dist/combobox-compound.svelte.js +21 -0
- package/dist/combobox-content.svelte +21 -0
- package/dist/combobox-content.svelte.d.ts +7 -0
- package/dist/combobox-create.svelte +63 -0
- package/dist/combobox-create.svelte.d.ts +11 -0
- package/dist/combobox-empty.svelte +22 -0
- package/dist/combobox-empty.svelte.d.ts +9 -0
- package/dist/combobox-group-label.svelte +14 -0
- package/dist/combobox-group-label.svelte.d.ts +4 -0
- package/dist/combobox-group.svelte +16 -0
- package/dist/combobox-group.svelte.d.ts +4 -0
- package/dist/combobox-input.svelte +44 -0
- package/dist/combobox-input.svelte.d.ts +4 -0
- package/dist/combobox-item-icon.svelte +12 -0
- package/dist/combobox-item-icon.svelte.d.ts +7 -0
- package/dist/combobox-item-indicator.svelte +24 -0
- package/dist/combobox-item-indicator.svelte.d.ts +7 -0
- package/dist/combobox-item-text.svelte +31 -0
- package/dist/combobox-item-text.svelte.d.ts +11 -0
- package/dist/combobox-item.svelte +87 -0
- package/dist/combobox-item.svelte.d.ts +14 -0
- package/dist/combobox-label.svelte +14 -0
- package/dist/combobox-label.svelte.d.ts +4 -0
- package/dist/combobox-list.svelte +36 -0
- package/dist/combobox-list.svelte.d.ts +12 -0
- package/dist/combobox-options.svelte +194 -0
- package/dist/combobox-options.svelte.d.ts +63 -0
- package/dist/combobox-select-all.svelte +36 -0
- package/dist/combobox-select-all.svelte.d.ts +11 -0
- package/dist/combobox-separator.svelte +12 -0
- package/dist/combobox-separator.svelte.d.ts +4 -0
- package/dist/combobox-status.svelte +20 -0
- package/dist/combobox-status.svelte.d.ts +9 -0
- package/dist/combobox-trigger.svelte +36 -0
- package/dist/combobox-trigger.svelte.d.ts +11 -0
- package/dist/combobox-value-icon.svelte +12 -0
- package/dist/combobox-value-icon.svelte.d.ts +4 -0
- package/dist/combobox-value.svelte +40 -0
- package/dist/combobox-value.svelte.d.ts +12 -0
- package/dist/combobox.svelte +59 -0
- package/dist/combobox.svelte.d.ts +37 -0
- package/dist/command-empty.svelte +29 -0
- package/dist/command-empty.svelte.d.ts +15 -0
- package/dist/command-group-label.svelte +16 -0
- package/dist/command-group-label.svelte.d.ts +9 -0
- package/dist/command-group.svelte +31 -0
- package/dist/command-group.svelte.d.ts +11 -0
- package/dist/command-inline.svelte +45 -0
- package/dist/command-inline.svelte.d.ts +14 -0
- package/dist/command-input.svelte +27 -0
- package/dist/command-input.svelte.d.ts +6 -0
- package/dist/command-item-icon.svelte +18 -0
- package/dist/command-item-icon.svelte.d.ts +11 -0
- package/dist/command-item-text.svelte +24 -0
- package/dist/command-item-text.svelte.d.ts +12 -0
- package/dist/command-item.svelte +110 -0
- package/dist/command-item.svelte.d.ts +22 -0
- package/dist/command-list.svelte +28 -0
- package/dist/command-list.svelte.d.ts +15 -0
- package/dist/command-page.svelte +24 -0
- package/dist/command-page.svelte.d.ts +13 -0
- package/dist/command-scope.svelte.d.ts +93 -0
- package/dist/command-scope.svelte.js +155 -0
- package/dist/command-separator.svelte +13 -0
- package/dist/command-separator.svelte.d.ts +6 -0
- package/dist/command-shortcut.svelte +20 -0
- package/dist/command-shortcut.svelte.d.ts +11 -0
- package/dist/command-status.svelte +21 -0
- package/dist/command-status.svelte.d.ts +10 -0
- package/dist/command.svelte +219 -0
- package/dist/command.svelte.d.ts +54 -0
- package/dist/context-menu.svelte +107 -0
- package/dist/context-menu.svelte.d.ts +15 -0
- package/dist/date-input-segment.svelte +50 -0
- package/dist/date-input-segment.svelte.d.ts +12 -0
- package/dist/date-input.svelte +245 -0
- package/dist/date-input.svelte.d.ts +37 -0
- package/dist/date-picker.svelte +533 -0
- package/dist/date-picker.svelte.d.ts +85 -0
- package/dist/date-segments-context.d.ts +7 -0
- package/dist/date-segments-context.js +7 -0
- package/dist/describe.svelte +41 -0
- package/dist/describe.svelte.d.ts +8 -0
- package/dist/dialog.svelte +91 -0
- package/dist/dialog.svelte.d.ts +17 -0
- package/dist/direction.svelte +43 -0
- package/dist/direction.svelte.d.ts +12 -0
- package/dist/dnd.svelte.d.ts +60 -0
- package/dist/dnd.svelte.js +101 -0
- package/dist/drawer.svelte +87 -0
- package/dist/drawer.svelte.d.ts +17 -0
- package/dist/empty-state.svelte +83 -0
- package/dist/empty-state.svelte.d.ts +16 -0
- package/dist/engine-state.svelte.d.ts +12 -0
- package/dist/engine-state.svelte.js +28 -0
- package/dist/error-state.svelte +93 -0
- package/dist/error-state.svelte.d.ts +16 -0
- package/dist/field-api.d.ts +6 -0
- package/dist/field-api.js +16 -0
- package/dist/field.svelte +143 -0
- package/dist/field.svelte.d.ts +37 -0
- package/dist/file-input.svelte +102 -0
- package/dist/file-input.svelte.d.ts +28 -0
- package/dist/gauge-context.d.ts +26 -0
- package/dist/gauge-context.js +41 -0
- package/dist/gauge-indicator.svelte +25 -0
- package/dist/gauge-indicator.svelte.d.ts +10 -0
- package/dist/gauge-label.svelte +16 -0
- package/dist/gauge-label.svelte.d.ts +8 -0
- package/dist/gauge-track.svelte +14 -0
- package/dist/gauge-track.svelte.d.ts +8 -0
- package/dist/gauge-value.svelte +14 -0
- package/dist/gauge-value.svelte.d.ts +9 -0
- package/dist/headless.svelte.d.ts +63 -0
- package/dist/headless.svelte.js +314 -0
- package/dist/hidden-input.svelte +42 -0
- package/dist/hidden-input.svelte.d.ts +12 -0
- package/dist/hover-card.svelte +69 -0
- package/dist/hover-card.svelte.d.ts +17 -0
- package/dist/icon-button.svelte +83 -0
- package/dist/icon-button.svelte.d.ts +12 -0
- package/dist/icon.svelte +41 -0
- package/dist/icon.svelte.d.ts +16 -0
- package/dist/image-cropper.svelte +78 -0
- package/dist/image-cropper.svelte.d.ts +8 -0
- package/dist/image.svelte +51 -0
- package/dist/image.svelte.d.ts +12 -0
- package/dist/index.d.ts +198 -0
- package/dist/index.js +187 -0
- package/dist/input-group.svelte +100 -0
- package/dist/input-group.svelte.d.ts +14 -0
- package/dist/input.svelte +63 -0
- package/dist/input.svelte.d.ts +17 -0
- package/dist/item.svelte +147 -0
- package/dist/item.svelte.d.ts +29 -0
- package/dist/kbd.svelte +41 -0
- package/dist/kbd.svelte.d.ts +12 -0
- package/dist/label.svelte +40 -0
- package/dist/label.svelte.d.ts +14 -0
- package/dist/listbox.svelte +135 -0
- package/dist/listbox.svelte.d.ts +38 -0
- package/dist/loader.svelte +38 -0
- package/dist/loader.svelte.d.ts +8 -0
- package/dist/mention-menu.svelte +134 -0
- package/dist/mention-menu.svelte.d.ts +23 -0
- package/dist/menu.svelte +185 -0
- package/dist/menu.svelte.d.ts +34 -0
- package/dist/menubar.svelte +75 -0
- package/dist/menubar.svelte.d.ts +21 -0
- package/dist/meter.svelte +83 -0
- package/dist/meter.svelte.d.ts +21 -0
- package/dist/native-select.svelte +87 -0
- package/dist/native-select.svelte.d.ts +16 -0
- package/dist/navigation-menu.svelte +155 -0
- package/dist/navigation-menu.svelte.d.ts +28 -0
- package/dist/number-input-scrub-area.svelte +55 -0
- package/dist/number-input-scrub-area.svelte.d.ts +18 -0
- package/dist/number-input-scrub.d.ts +6 -0
- package/dist/number-input-scrub.js +4 -0
- package/dist/number-input.svelte +86 -0
- package/dist/number-input.svelte.d.ts +26 -0
- package/dist/otp-input.svelte +96 -0
- package/dist/otp-input.svelte.d.ts +14 -0
- package/dist/overlay.svelte.d.ts +29 -0
- package/dist/overlay.svelte.js +46 -0
- package/dist/pagination.svelte +129 -0
- package/dist/pagination.svelte.d.ts +33 -0
- package/dist/parts-part.svelte +62 -0
- package/dist/parts-part.svelte.d.ts +14 -0
- package/dist/parts-root.svelte +74 -0
- package/dist/parts-root.svelte.d.ts +12 -0
- package/dist/password-input.svelte +129 -0
- package/dist/password-input.svelte.d.ts +49 -0
- package/dist/popover.svelte +85 -0
- package/dist/popover.svelte.d.ts +19 -0
- package/dist/preferences/preferences.svelte +96 -0
- package/dist/preferences/preferences.svelte.d.ts +21 -0
- package/dist/preferences.d.ts +2 -0
- package/dist/preferences.js +2 -0
- package/dist/preferences.svelte.d.ts +11 -0
- package/dist/preferences.svelte.js +26 -0
- package/dist/presence.svelte.d.ts +25 -0
- package/dist/presence.svelte.js +57 -0
- package/dist/progress.svelte +88 -0
- package/dist/progress.svelte.d.ts +21 -0
- package/dist/props.d.ts +8 -0
- package/dist/props.js +7 -0
- package/dist/query.svelte.d.ts +65 -0
- package/dist/query.svelte.js +219 -0
- package/dist/radio.svelte +79 -0
- package/dist/radio.svelte.d.ts +21 -0
- package/dist/rating.svelte +86 -0
- package/dist/rating.svelte.d.ts +28 -0
- package/dist/resizable.svelte +69 -0
- package/dist/resizable.svelte.d.ts +21 -0
- package/dist/scroll-area.svelte +66 -0
- package/dist/scroll-area.svelte.d.ts +18 -0
- package/dist/segmented-control.svelte +83 -0
- package/dist/segmented-control.svelte.d.ts +27 -0
- package/dist/select.svelte +285 -0
- package/dist/select.svelte.d.ts +77 -0
- package/dist/separator.svelte +26 -0
- package/dist/separator.svelte.d.ts +8 -0
- package/dist/sheet.svelte +105 -0
- package/dist/sheet.svelte.d.ts +19 -0
- package/dist/sidebar.svelte +66 -0
- package/dist/sidebar.svelte.d.ts +16 -0
- package/dist/skeleton.svelte +29 -0
- package/dist/skeleton.svelte.d.ts +8 -0
- package/dist/slider.svelte +78 -0
- package/dist/slider.svelte.d.ts +17 -0
- package/dist/sortable-board-strict.svelte +76 -0
- package/dist/sortable-board-strict.svelte.d.ts +12 -0
- package/dist/sortable-engine.svelte +129 -0
- package/dist/sortable-engine.svelte.d.ts +30 -0
- package/dist/sortable.svelte +86 -0
- package/dist/sortable.svelte.d.ts +27 -0
- package/dist/spinner.svelte +27 -0
- package/dist/spinner.svelte.d.ts +8 -0
- package/dist/steps.svelte +95 -0
- package/dist/steps.svelte.d.ts +23 -0
- package/dist/switch.svelte +74 -0
- package/dist/switch.svelte.d.ts +19 -0
- package/dist/table.svelte +151 -0
- package/dist/table.svelte.d.ts +23 -0
- package/dist/tabs.svelte +97 -0
- package/dist/tabs.svelte.d.ts +23 -0
- package/dist/textarea.svelte +65 -0
- package/dist/textarea.svelte.d.ts +17 -0
- package/dist/time-input.svelte +128 -0
- package/dist/time-input.svelte.d.ts +28 -0
- package/dist/timeline.svelte +88 -0
- package/dist/timeline.svelte.d.ts +25 -0
- package/dist/toast.svelte +190 -0
- package/dist/toast.svelte.d.ts +37 -0
- package/dist/toaster.d.ts +2 -0
- package/dist/toaster.js +6 -0
- package/dist/toggle-group.svelte +76 -0
- package/dist/toggle-group.svelte.d.ts +19 -0
- package/dist/toggle.svelte +50 -0
- package/dist/toggle.svelte.d.ts +14 -0
- package/dist/token-input-editor.svelte +42 -0
- package/dist/token-input-editor.svelte.d.ts +4 -0
- package/dist/token-input-segments-root.svelte +120 -0
- package/dist/token-input-segments-root.svelte.d.ts +33 -0
- package/dist/token-input-token-remove.svelte +32 -0
- package/dist/token-input-token-remove.svelte.d.ts +4 -0
- package/dist/token-input-token-scope.svelte +15 -0
- package/dist/token-input-token-scope.svelte.d.ts +9 -0
- package/dist/token-input-token.svelte +22 -0
- package/dist/token-input-token.svelte.d.ts +4 -0
- package/dist/token-input.svelte +157 -0
- package/dist/token-input.svelte.d.ts +66 -0
- package/dist/token-segments-scope.svelte.d.ts +17 -0
- package/dist/token-segments-scope.svelte.js +11 -0
- package/dist/toolbar-item.svelte +31 -0
- package/dist/toolbar-item.svelte.d.ts +14 -0
- package/dist/toolbar.svelte +74 -0
- package/dist/toolbar.svelte.d.ts +19 -0
- package/dist/tooltip.svelte +84 -0
- package/dist/tooltip.svelte.d.ts +18 -0
- package/dist/tree-grid.svelte +159 -0
- package/dist/tree-grid.svelte.d.ts +34 -0
- package/dist/tree.svelte +229 -0
- package/dist/tree.svelte.d.ts +65 -0
- package/dist/trigger-menu-content.svelte +24 -0
- package/dist/trigger-menu-content.svelte.d.ts +11 -0
- package/dist/trigger-menu-editor.svelte +32 -0
- package/dist/trigger-menu-editor.svelte.d.ts +13 -0
- package/dist/trigger-menu-empty.svelte +29 -0
- package/dist/trigger-menu-empty.svelte.d.ts +15 -0
- package/dist/trigger-menu-group-label.svelte +16 -0
- package/dist/trigger-menu-group-label.svelte.d.ts +9 -0
- package/dist/trigger-menu-group.svelte +16 -0
- package/dist/trigger-menu-group.svelte.d.ts +9 -0
- package/dist/trigger-menu-hint.svelte +16 -0
- package/dist/trigger-menu-hint.svelte.d.ts +9 -0
- package/dist/trigger-menu-inline.svelte.d.ts +59 -0
- package/dist/trigger-menu-inline.svelte.js +72 -0
- package/dist/trigger-menu-input.svelte +24 -0
- package/dist/trigger-menu-input.svelte.d.ts +6 -0
- package/dist/trigger-menu-item-icon.svelte +18 -0
- package/dist/trigger-menu-item-icon.svelte.d.ts +11 -0
- package/dist/trigger-menu-item.svelte +40 -0
- package/dist/trigger-menu-item.svelte.d.ts +19 -0
- package/dist/trigger-menu-list.svelte +20 -0
- package/dist/trigger-menu-list.svelte.d.ts +12 -0
- package/dist/trigger-menu-separator.svelte +13 -0
- package/dist/trigger-menu-separator.svelte.d.ts +6 -0
- package/dist/trigger-menu-status.svelte +21 -0
- package/dist/trigger-menu-status.svelte.d.ts +10 -0
- package/dist/trigger-menu.svelte +150 -0
- package/dist/trigger-menu.svelte.d.ts +30 -0
- package/dist/virtual-list-strict.svelte +83 -0
- package/dist/virtual-list-strict.svelte.d.ts +23 -0
- package/dist/virtual-list.svelte +86 -0
- package/dist/virtual-list.svelte.d.ts +28 -0
- package/dist/virtual.svelte.d.ts +24 -0
- package/dist/virtual.svelte.js +48 -0
- package/dist/waterfall-axis.svelte +25 -0
- package/dist/waterfall-axis.svelte.d.ts +14 -0
- package/dist/waterfall-bar.svelte +23 -0
- package/dist/waterfall-bar.svelte.d.ts +7 -0
- package/dist/waterfall-cell.svelte +13 -0
- package/dist/waterfall-cell.svelte.d.ts +7 -0
- package/dist/waterfall-chart.svelte +134 -0
- package/dist/waterfall-chart.svelte.d.ts +27 -0
- package/dist/waterfall-column-header.svelte +13 -0
- package/dist/waterfall-column-header.svelte.d.ts +7 -0
- package/dist/waterfall-header-row.svelte +13 -0
- package/dist/waterfall-header-row.svelte.d.ts +7 -0
- package/dist/waterfall-indicator.svelte +32 -0
- package/dist/waterfall-indicator.svelte.d.ts +7 -0
- package/dist/waterfall-mark.svelte +26 -0
- package/dist/waterfall-mark.svelte.d.ts +9 -0
- package/dist/waterfall-row-header.svelte +13 -0
- package/dist/waterfall-row-header.svelte.d.ts +7 -0
- package/dist/waterfall-row.svelte +39 -0
- package/dist/waterfall-row.svelte.d.ts +9 -0
- package/dist/waterfall-tick.svelte +25 -0
- package/dist/waterfall-tick.svelte.d.ts +9 -0
- package/dist/waterfall-trace.d.ts +17 -0
- package/dist/waterfall-trace.js +10 -0
- package/dist/waterfall.svelte +177 -0
- package/dist/waterfall.svelte.d.ts +48 -0
- package/package.json +447 -3
- package/README.md +0 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { PrimitiveTimelineOptions, TimelineItem, TimelineStatus } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
|
|
7
|
+
/** Props for `Timeline`. */
|
|
8
|
+
export interface TimelineProps
|
|
9
|
+
extends PrimitiveProps<
|
|
10
|
+
PrimitiveTimelineOptions,
|
|
11
|
+
{
|
|
12
|
+
/** Renders an event's title content; the item's title when left out. */
|
|
13
|
+
item?: Snippet<[TimelineItem, number]> | undefined;
|
|
14
|
+
/** The word shown for each status; the status name when left out. */
|
|
15
|
+
statusLabels?: Partial<Record<TimelineStatus, string>> | undefined;
|
|
16
|
+
/** Marks the list as a feed (`role="feed"`) for a stream that grows. */
|
|
17
|
+
feed?: boolean | undefined;
|
|
18
|
+
/** Marks feed updates in progress (`aria-busy`); absent leaves it unset. */
|
|
19
|
+
busy?: boolean | undefined;
|
|
20
|
+
},
|
|
21
|
+
HTMLOListElement
|
|
22
|
+
> {}
|
|
23
|
+
|
|
24
|
+
/** The imperative half of a `Timeline`. */
|
|
25
|
+
export interface TimelineController {
|
|
26
|
+
/** Focuses an event by position, or by its item `id` (or a composed row's `data-value`). */
|
|
27
|
+
focus(target: number | string): void;
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script lang="ts">
|
|
32
|
+
// The Svelte adapter for `Timeline` on the headless path: the primitive owns
|
|
33
|
+
// the order and the status hooks; Svelte owns the rows.
|
|
34
|
+
import { timelinePrimitive } from "@bevelo/core";
|
|
35
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
36
|
+
import Describe from "./describe.svelte";
|
|
37
|
+
|
|
38
|
+
const NO_ITEMS: readonly TimelineItem[] = [];
|
|
39
|
+
|
|
40
|
+
let { item, statusLabels, feed = false, busy, ...rest }: TimelineProps = $props();
|
|
41
|
+
let rootElement: Element | undefined = $state();
|
|
42
|
+
|
|
43
|
+
/** Focuses one event row inside `root`, making it focusable from script first. */
|
|
44
|
+
function focusRow(root: Element | null | undefined, target: number | string): void {
|
|
45
|
+
if (root === null || root === undefined) return;
|
|
46
|
+
const rows = [...root.querySelectorAll<HTMLElement>('[data-slot="timeline-item"]')];
|
|
47
|
+
const row =
|
|
48
|
+
typeof target === "number"
|
|
49
|
+
? rows[target]
|
|
50
|
+
: rows.find((el) => el.dataset["id"] === target || el.dataset["value"] === target);
|
|
51
|
+
if (row === undefined) return;
|
|
52
|
+
row.setAttribute("tabindex", "-1");
|
|
53
|
+
row.focus();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Focuses an event by position or by its item `id`. */
|
|
57
|
+
export function api(): TimelineController {
|
|
58
|
+
return { focus: (target: number | string) => focusRow(rootElement, target) };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const split = $derived(splitOptions(timelinePrimitive, rest));
|
|
62
|
+
const _uid = $props.id();
|
|
63
|
+
const handle = usePrimitive(timelinePrimitive, () => split.options, _uid);
|
|
64
|
+
|
|
65
|
+
function statusWord(status: TimelineStatus | undefined): string {
|
|
66
|
+
const resolved = status ?? "pending";
|
|
67
|
+
return statusLabels?.[resolved] ?? resolved;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const root = $derived(handle.part("root"));
|
|
71
|
+
const rows = $derived(split.options.items ?? NO_ITEMS);
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
{#if root}
|
|
75
|
+
<svelte:element this={root.tag} bind:this={rootElement} {...partProps(root, { ...(feed ? { role: "feed" } : {}), ...(busy === undefined ? {} : { "aria-busy": busy ? "true" : "false" }), ...split.attrs })}>
|
|
76
|
+
{#each rows as entry, index (entry.id)}
|
|
77
|
+
{@const address = { index }}
|
|
78
|
+
{@const itemPart = handle.part("item", address)}
|
|
79
|
+
{@const icon = handle.part("icon", address)}
|
|
80
|
+
{@const connector = handle.part("connector", address)}
|
|
81
|
+
{@const title = handle.part("title", address)}
|
|
82
|
+
{@const status = handle.part("status", address)}
|
|
83
|
+
{@const description = handle.part("description", address)}
|
|
84
|
+
{@const time = handle.part("time", address)}
|
|
85
|
+
{#if itemPart}<svelte:element this={itemPart.tag} {...partProps(itemPart)}>{#if icon}<svelte:element this={icon.tag} {...partProps(icon)}>{#if entry.icon}{#each entry.icon as child}<Describe node={child} />{/each}{/if}</svelte:element>{/if}{#if connector}<svelte:element this={connector.tag} {...partProps(connector)}></svelte:element>{/if}{#if title}<svelte:element this={title.tag} {...partProps(title)}>{#if item}{@render item(entry, index)}{:else}{entry.title}{/if}</svelte:element>{/if}{#if status}<svelte:element this={status.tag} {...partProps(status)}>{statusWord(entry.status)}</svelte:element>{/if}{#if description}<svelte:element this={description.tag} {...partProps(description)}>{entry.description ?? ""}</svelte:element>{/if}{#if time}<svelte:element this={time.tag} {...partProps(time)}>{entry.time ?? ""}</svelte:element>{/if}</svelte:element>{/if}
|
|
86
|
+
{/each}
|
|
87
|
+
</svelte:element>
|
|
88
|
+
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { PrimitiveTimelineOptions, TimelineItem, TimelineStatus } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** Props for `Timeline`. */
|
|
5
|
+
export interface TimelineProps extends PrimitiveProps<PrimitiveTimelineOptions, {
|
|
6
|
+
/** Renders an event's title content; the item's title when left out. */
|
|
7
|
+
item?: Snippet<[TimelineItem, number]> | undefined;
|
|
8
|
+
/** The word shown for each status; the status name when left out. */
|
|
9
|
+
statusLabels?: Partial<Record<TimelineStatus, string>> | undefined;
|
|
10
|
+
/** Marks the list as a feed (`role="feed"`) for a stream that grows. */
|
|
11
|
+
feed?: boolean | undefined;
|
|
12
|
+
/** Marks feed updates in progress (`aria-busy`); absent leaves it unset. */
|
|
13
|
+
busy?: boolean | undefined;
|
|
14
|
+
}, HTMLOListElement> {
|
|
15
|
+
}
|
|
16
|
+
/** The imperative half of a `Timeline`. */
|
|
17
|
+
export interface TimelineController {
|
|
18
|
+
/** Focuses an event by position, or by its item `id` (or a composed row's `data-value`). */
|
|
19
|
+
focus(target: number | string): void;
|
|
20
|
+
}
|
|
21
|
+
declare const Timeline: import("svelte").Component<TimelineProps, {
|
|
22
|
+
api: () => TimelineController;
|
|
23
|
+
}, "">;
|
|
24
|
+
type Timeline = ReturnType<typeof Timeline>;
|
|
25
|
+
export default Timeline;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { PrimitiveToastItem, PrimitiveToastOptions } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
import type { Toaster, ToasterItem } from "./toaster.js";
|
|
7
|
+
|
|
8
|
+
/** The callbacks and toaster record the `item` snippet receives next to the item. */
|
|
9
|
+
export interface ToastItemControls {
|
|
10
|
+
/** Closes the toast, exactly like its close button. */
|
|
11
|
+
readonly dismiss: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Reports the toast's action. With a toaster it also runs the message's
|
|
14
|
+
* `onAction`, holds `pending` while a returned promise runs, then dismisses
|
|
15
|
+
* the toast, or keeps it and sets `error` when the action throws.
|
|
16
|
+
*/
|
|
17
|
+
readonly action: () => void;
|
|
18
|
+
/** The toaster's record of the message: its `data`, `status` and callbacks. */
|
|
19
|
+
readonly entry: ToasterItem | undefined;
|
|
20
|
+
/** True while the action's promise runs. */
|
|
21
|
+
readonly pending: boolean;
|
|
22
|
+
/** What the last action threw, or null. */
|
|
23
|
+
readonly error: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Props for `Toast`. Bind the instance with `bind:this` and call `api()` for the primitive's api. */
|
|
27
|
+
export interface ToastProps
|
|
28
|
+
extends PrimitiveProps<
|
|
29
|
+
PrimitiveToastOptions,
|
|
30
|
+
{
|
|
31
|
+
/** A store from `createToaster`; the region renders its messages and routes dismiss and action back to it. */
|
|
32
|
+
toaster?: Toaster | undefined;
|
|
33
|
+
/** Renders a toast's whole content inside its toast part, in place of the built-in title, footer and close button. */
|
|
34
|
+
item?: Snippet<[PrimitiveToastItem, ToastItemControls]> | undefined;
|
|
35
|
+
/** The close button's content. */
|
|
36
|
+
closeIcon?: string | Snippet | undefined;
|
|
37
|
+
},
|
|
38
|
+
HTMLElement
|
|
39
|
+
> {}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
// The Svelte adapter for `Toast` on the headless path: the primitive owns
|
|
44
|
+
// the queue, the timers and the dismissal graph; Svelte owns the region.
|
|
45
|
+
// Enter and exit are the adapter's: a fresh toast begins its enter once its
|
|
46
|
+
// element exists, a closing one settles when its transition ends.
|
|
47
|
+
import { createSubscriber } from "svelte/reactivity";
|
|
48
|
+
import { toastPrimitive, toastStatusGlyph } from "@bevelo/core";
|
|
49
|
+
import type { Child, PrimitiveToastApi, ToastMessage } from "@bevelo/core";
|
|
50
|
+
import { usePrimitive, partProps, portal, splitOptions } from "./headless.svelte.js";
|
|
51
|
+
import Describe from "./describe.svelte";
|
|
52
|
+
|
|
53
|
+
const NO_MESSAGES: readonly ToastMessage[] = [];
|
|
54
|
+
|
|
55
|
+
let { toaster, item: itemSnippet, closeIcon = "×", ...rest }: ToastProps = $props();
|
|
56
|
+
|
|
57
|
+
const split = $derived(splitOptions(toastPrimitive, rest));
|
|
58
|
+
const trackToaster = $derived(
|
|
59
|
+
toaster === undefined ? undefined : createSubscriber((update) => toaster.subscribe(update)),
|
|
60
|
+
);
|
|
61
|
+
const messages = $derived.by(() => {
|
|
62
|
+
if (toaster === undefined) return split.options.messages ?? NO_MESSAGES;
|
|
63
|
+
trackToaster?.();
|
|
64
|
+
return toaster.messages();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function dismissed(id: string): void {
|
|
68
|
+
toaster?.dismiss(id);
|
|
69
|
+
split.options.onDismiss?.(id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function acted(id: string): void {
|
|
73
|
+
toaster?.action(id);
|
|
74
|
+
split.options.onAction?.(id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const entries = $derived.by(() => {
|
|
78
|
+
trackToaster?.();
|
|
79
|
+
return toaster?.items() ?? [];
|
|
80
|
+
});
|
|
81
|
+
let pending = $state<Record<string, boolean>>({});
|
|
82
|
+
let errors = $state<Record<string, unknown>>({});
|
|
83
|
+
|
|
84
|
+
async function runAction(id: string): Promise<void> {
|
|
85
|
+
split.options.onAction?.(id);
|
|
86
|
+
const run = toaster?.items().find((entry) => entry.id === id)?.action?.onAction;
|
|
87
|
+
if (toaster === undefined || run === undefined) return;
|
|
88
|
+
errors[id] = null;
|
|
89
|
+
try {
|
|
90
|
+
const result = run();
|
|
91
|
+
if (result instanceof Promise) {
|
|
92
|
+
pending[id] = true;
|
|
93
|
+
await result;
|
|
94
|
+
pending[id] = false;
|
|
95
|
+
}
|
|
96
|
+
toaster.dismiss(id, "action");
|
|
97
|
+
} catch (caught) {
|
|
98
|
+
pending[id] = false;
|
|
99
|
+
errors[id] = caught;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function controlsFor(id: string): ToastItemControls {
|
|
104
|
+
return {
|
|
105
|
+
dismiss: () => handle.api.dismiss(id),
|
|
106
|
+
action: () => void runAction(id),
|
|
107
|
+
entry: entries.find((entry) => entry.id === id),
|
|
108
|
+
pending: pending[id] === true,
|
|
109
|
+
error: errors[id] ?? null,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const _uid = $props.id();
|
|
114
|
+
const handle = usePrimitive(
|
|
115
|
+
toastPrimitive,
|
|
116
|
+
() => ({ ...split.options, messages, onDismiss: dismissed, onAction: acted }),
|
|
117
|
+
_uid,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/** The primitive's api: dismiss, settle, the hover and focus holds, reconcile and cancel. */
|
|
121
|
+
export function api(): PrimitiveToastApi {
|
|
122
|
+
return handle.api;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const root = $derived(handle.part("root"));
|
|
126
|
+
const items = $derived.by(() => {
|
|
127
|
+
handle.revision;
|
|
128
|
+
return (handle.state as { items?: readonly PrimitiveToastItem[] }).items ?? [];
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
{#if root}
|
|
133
|
+
<svelte:element this={root.tag} use:portal {...partProps(root, split.attrs)}>
|
|
134
|
+
{#each items as item, index (item.id)}
|
|
135
|
+
{@const address = { index }}
|
|
136
|
+
{@const toastPart = handle.part("toast", address)}
|
|
137
|
+
{#if toastPart}
|
|
138
|
+
<svelte:element this={toastPart.tag} {...partProps(toastPart)}>
|
|
139
|
+
{#if itemSnippet}
|
|
140
|
+
{@render itemSnippet(item, controlsFor(item.id))}
|
|
141
|
+
{:else}
|
|
142
|
+
{@const icon = handle.part("icon", address)}
|
|
143
|
+
{@const title = handle.part("title", address)}
|
|
144
|
+
{@const description = handle.part("description", address)}
|
|
145
|
+
{@const footer = handle.part("footer", address)}
|
|
146
|
+
{@const actions = handle.part("actions", address)}
|
|
147
|
+
{@const ring = handle.part("timer-ring", address)}
|
|
148
|
+
{@const ringFill = handle.part("timer-ring-fill", address)}
|
|
149
|
+
{@const action = handle.part("action", address)}
|
|
150
|
+
{@const progress = handle.part("progress", address)}
|
|
151
|
+
{@const progressFill = handle.part("progress-fill", address)}
|
|
152
|
+
{@const close = handle.part("close", address)}
|
|
153
|
+
{#if title}
|
|
154
|
+
<svelte:element this={title.tag} {...partProps(title)}>
|
|
155
|
+
{#if icon}<svelte:element this={icon.tag} {...partProps(icon)}><Describe node={toastStatusGlyph(item.status) as Child} /></svelte:element>{/if}
|
|
156
|
+
{item.message.title}
|
|
157
|
+
</svelte:element>
|
|
158
|
+
{/if}
|
|
159
|
+
{#if description}<svelte:element this={description.tag} {...partProps(description)}>{item.message.description ?? ""}</svelte:element>{/if}
|
|
160
|
+
{#if footer}
|
|
161
|
+
<svelte:element this={footer.tag} {...partProps(footer)}>
|
|
162
|
+
{#if actions}
|
|
163
|
+
<svelte:element this={actions.tag} {...partProps(actions)}>
|
|
164
|
+
{#if ring}
|
|
165
|
+
<svelte:element this={ring.tag} {...partProps(ring)}>
|
|
166
|
+
<svg viewBox="0 0 16 16" width="16" height="16" focusable="false">
|
|
167
|
+
<circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="2" opacity="0.25" />
|
|
168
|
+
{#if ringFill}
|
|
169
|
+
<svelte:element this={ringFill.tag} {...partProps(ringFill, { cx: "8", cy: "8", r: "7", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", pathLength: "100" })}></svelte:element>
|
|
170
|
+
{/if}
|
|
171
|
+
</svg>
|
|
172
|
+
</svelte:element>
|
|
173
|
+
{/if}
|
|
174
|
+
{#if action}<svelte:element this={action.tag} {...partProps(action)}>{item.message.action?.label ?? ""}</svelte:element>{/if}
|
|
175
|
+
</svelte:element>
|
|
176
|
+
{/if}
|
|
177
|
+
{#if progress}
|
|
178
|
+
<svelte:element this={progress.tag} {...partProps(progress)}>
|
|
179
|
+
{#if progressFill}<svelte:element this={progressFill.tag} {...partProps(progressFill)}></svelte:element>{/if}
|
|
180
|
+
</svelte:element>
|
|
181
|
+
{/if}
|
|
182
|
+
</svelte:element>
|
|
183
|
+
{/if}
|
|
184
|
+
{#if close}<svelte:element this={close.tag} {...partProps(close)}>{#if typeof closeIcon === "function"}{@render closeIcon()}{:else}{closeIcon}{/if}</svelte:element>{/if}
|
|
185
|
+
{/if}
|
|
186
|
+
</svelte:element>
|
|
187
|
+
{/if}
|
|
188
|
+
{/each}
|
|
189
|
+
</svelte:element>
|
|
190
|
+
{/if}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { PrimitiveToastItem, PrimitiveToastOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
import type { Toaster, ToasterItem } from "./toaster.js";
|
|
5
|
+
/** The callbacks and toaster record the `item` snippet receives next to the item. */
|
|
6
|
+
export interface ToastItemControls {
|
|
7
|
+
/** Closes the toast, exactly like its close button. */
|
|
8
|
+
readonly dismiss: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Reports the toast's action. With a toaster it also runs the message's
|
|
11
|
+
* `onAction`, holds `pending` while a returned promise runs, then dismisses
|
|
12
|
+
* the toast, or keeps it and sets `error` when the action throws.
|
|
13
|
+
*/
|
|
14
|
+
readonly action: () => void;
|
|
15
|
+
/** The toaster's record of the message: its `data`, `status` and callbacks. */
|
|
16
|
+
readonly entry: ToasterItem | undefined;
|
|
17
|
+
/** True while the action's promise runs. */
|
|
18
|
+
readonly pending: boolean;
|
|
19
|
+
/** What the last action threw, or null. */
|
|
20
|
+
readonly error: unknown;
|
|
21
|
+
}
|
|
22
|
+
/** Props for `Toast`. Bind the instance with `bind:this` and call `api()` for the primitive's api. */
|
|
23
|
+
export interface ToastProps extends PrimitiveProps<PrimitiveToastOptions, {
|
|
24
|
+
/** A store from `createToaster`; the region renders its messages and routes dismiss and action back to it. */
|
|
25
|
+
toaster?: Toaster | undefined;
|
|
26
|
+
/** Renders a toast's whole content inside its toast part, in place of the built-in title, footer and close button. */
|
|
27
|
+
item?: Snippet<[PrimitiveToastItem, ToastItemControls]> | undefined;
|
|
28
|
+
/** The close button's content. */
|
|
29
|
+
closeIcon?: string | Snippet | undefined;
|
|
30
|
+
}, HTMLElement> {
|
|
31
|
+
}
|
|
32
|
+
import type { PrimitiveToastApi } from "@bevelo/core";
|
|
33
|
+
declare const Toast: import("svelte").Component<ToastProps, {
|
|
34
|
+
api: () => PrimitiveToastApi;
|
|
35
|
+
}, "">;
|
|
36
|
+
type Toast = ReturnType<typeof Toast>;
|
|
37
|
+
export default Toast;
|
package/dist/toaster.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The imperative toast store is core's: a host creates one, passes it to
|
|
2
|
+
// `<Toast toaster={...} />`, and pushes, updates and dismisses messages from
|
|
3
|
+
// anywhere; the region subscribes and renders the list.
|
|
4
|
+
//
|
|
5
|
+
// @stable — follows semver.
|
|
6
|
+
export { createToaster } from "@bevelo/core";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { Child, PrimitiveToggleGroupItem, PrimitiveToggleGroupOptions } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
|
|
7
|
+
/** One button, as the `item` snippet receives it. */
|
|
8
|
+
export interface ToggleGroupItemState {
|
|
9
|
+
readonly item: PrimitiveToggleGroupItem;
|
|
10
|
+
readonly index: number;
|
|
11
|
+
readonly pressed: boolean;
|
|
12
|
+
readonly disabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Props for `ToggleGroup`. `value` is bindable. */
|
|
16
|
+
export interface ToggleGroupProps
|
|
17
|
+
extends PrimitiveProps<
|
|
18
|
+
PrimitiveToggleGroupOptions,
|
|
19
|
+
{
|
|
20
|
+
/** Renders a button's content after its icon; the label text when left out. */
|
|
21
|
+
item?: Snippet<[ToggleGroupItemState]> | undefined;
|
|
22
|
+
},
|
|
23
|
+
HTMLDivElement
|
|
24
|
+
> {}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
// The Svelte adapter for `ToggleGroup` on the headless path: the primitive
|
|
29
|
+
// owns the selection machine and the roving tab stop; Svelte owns the row.
|
|
30
|
+
// RTL needs the capture-phase interception: the machine's arrow table is LTR,
|
|
31
|
+
// so in a right-to-left subtree the keys swap direction before it ever sees
|
|
32
|
+
// them, and the adapter does the stepping itself.
|
|
33
|
+
import { toggleGroupPrimitive } from "@bevelo/core";
|
|
34
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
35
|
+
import { forwardCancelable } from "./bound.svelte.js";
|
|
36
|
+
import Describe from "./describe.svelte";
|
|
37
|
+
|
|
38
|
+
const NO_ITEMS: readonly PrimitiveToggleGroupItem[] = [];
|
|
39
|
+
const NO_VALUE: readonly string[] = [];
|
|
40
|
+
|
|
41
|
+
let { value = $bindable(), item: itemSnippet, ...rest }: ToggleGroupProps = $props();
|
|
42
|
+
|
|
43
|
+
const split = $derived(splitOptions(toggleGroupPrimitive, rest));
|
|
44
|
+
const _uid = $props.id();
|
|
45
|
+
const handle = usePrimitive(toggleGroupPrimitive, () => ({
|
|
46
|
+
...split.options,
|
|
47
|
+
value,
|
|
48
|
+
defaultValue: split.options.defaultValue ?? NO_VALUE,
|
|
49
|
+
items: split.options.items ?? NO_ITEMS,
|
|
50
|
+
onChange: forwardCancelable(split.options.onChange, (next) => {
|
|
51
|
+
value = next;
|
|
52
|
+
}),
|
|
53
|
+
}), _uid);
|
|
54
|
+
|
|
55
|
+
const root = $derived(handle.part("root"));
|
|
56
|
+
const rows = $derived(split.options.items ?? NO_ITEMS);
|
|
57
|
+
|
|
58
|
+
// The primitive types an item's icon as opaque; the adapter renders it as a description list.
|
|
59
|
+
function iconOf(item: PrimitiveToggleGroupItem): readonly Child[] {
|
|
60
|
+
return (item.icon ?? []) as readonly Child[];
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
{#if root}
|
|
65
|
+
<svelte:element this={root.tag} {...partProps(root, split.attrs)}>
|
|
66
|
+
{#each rows as item, index (item.value)}
|
|
67
|
+
{@const address = { index }}
|
|
68
|
+
{@const toggle = handle.part("toggle", address)}
|
|
69
|
+
{@const icon = handle.part("icon", address)}
|
|
70
|
+
{#if toggle}
|
|
71
|
+
{@const state = toggle.state as unknown as { pressed: boolean; disabled: boolean }}
|
|
72
|
+
<svelte:element this={toggle.tag} {...partProps(toggle)}>{#if icon && item.icon !== undefined && item.icon.length > 0}<svelte:element this={icon.tag} {...partProps(icon)}>{#each iconOf(item) as child}<Describe node={child} />{/each}</svelte:element>{/if}{#if itemSnippet}{@render itemSnippet({ item, index, pressed: state.pressed, disabled: state.disabled })}{:else}{item.label}{/if}</svelte:element>
|
|
73
|
+
{/if}
|
|
74
|
+
{/each}
|
|
75
|
+
</svelte:element>
|
|
76
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { PrimitiveToggleGroupItem, PrimitiveToggleGroupOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** One button, as the `item` snippet receives it. */
|
|
5
|
+
export interface ToggleGroupItemState {
|
|
6
|
+
readonly item: PrimitiveToggleGroupItem;
|
|
7
|
+
readonly index: number;
|
|
8
|
+
readonly pressed: boolean;
|
|
9
|
+
readonly disabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Props for `ToggleGroup`. `value` is bindable. */
|
|
12
|
+
export interface ToggleGroupProps extends PrimitiveProps<PrimitiveToggleGroupOptions, {
|
|
13
|
+
/** Renders a button's content after its icon; the label text when left out. */
|
|
14
|
+
item?: Snippet<[ToggleGroupItemState]> | undefined;
|
|
15
|
+
}, HTMLDivElement> {
|
|
16
|
+
}
|
|
17
|
+
declare const ToggleGroup: import("svelte").Component<ToggleGroupProps, {}, "value">;
|
|
18
|
+
type ToggleGroup = ReturnType<typeof ToggleGroup>;
|
|
19
|
+
export default ToggleGroup;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { Child, PrimitiveToggleOptions } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
|
|
7
|
+
/** Props for `Toggle`. `pressed` is bindable. */
|
|
8
|
+
export interface ToggleProps
|
|
9
|
+
extends PrimitiveProps<
|
|
10
|
+
PrimitiveToggleOptions,
|
|
11
|
+
{
|
|
12
|
+
/** The mark before the label: a snippet or a description list. */
|
|
13
|
+
icon?: Snippet | readonly Child[] | undefined;
|
|
14
|
+
/** The mark, when `icon` is not given. */
|
|
15
|
+
children?: Snippet | undefined;
|
|
16
|
+
},
|
|
17
|
+
HTMLButtonElement
|
|
18
|
+
> {}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
// The Svelte adapter for `Toggle` on the headless path: the primitive owns
|
|
23
|
+
// the pressed machine; Svelte owns the one element. The icon prop is the
|
|
24
|
+
// description channel when it is a Child list.
|
|
25
|
+
import { togglePrimitive } from "@bevelo/core";
|
|
26
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
27
|
+
import { forwardCancelable } from "./bound.svelte.js";
|
|
28
|
+
import Describe from "./describe.svelte";
|
|
29
|
+
|
|
30
|
+
let { pressed = $bindable(), icon, children, ...rest }: ToggleProps = $props();
|
|
31
|
+
|
|
32
|
+
const split = $derived(splitOptions(togglePrimitive, rest));
|
|
33
|
+
const _uid = $props.id();
|
|
34
|
+
const handle = usePrimitive(togglePrimitive, () => ({
|
|
35
|
+
...split.options,
|
|
36
|
+
pressed,
|
|
37
|
+
label: split.options.label ?? "",
|
|
38
|
+
onChange: forwardCancelable(split.options.onChange, (next) => {
|
|
39
|
+
pressed = next;
|
|
40
|
+
}),
|
|
41
|
+
}), _uid);
|
|
42
|
+
|
|
43
|
+
const root = $derived(handle.part("root"));
|
|
44
|
+
const iconPart = $derived(handle.part("icon"));
|
|
45
|
+
const mark = $derived(icon ?? children);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
{#if root}
|
|
49
|
+
<svelte:element this={root.tag} {...partProps(root, split.attrs)}>{#if mark !== undefined && iconPart}<svelte:element this={iconPart.tag} {...partProps(iconPart)}>{#if Array.isArray(mark)}{#each mark as child}<Describe node={child} />{/each}{:else if typeof mark === "function"}{@render mark()}{/if}</svelte:element>{/if}{split.options.label ?? ""}</svelte:element>
|
|
50
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { Child, PrimitiveToggleOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** Props for `Toggle`. `pressed` is bindable. */
|
|
5
|
+
export interface ToggleProps extends PrimitiveProps<PrimitiveToggleOptions, {
|
|
6
|
+
/** The mark before the label: a snippet or a description list. */
|
|
7
|
+
icon?: Snippet | readonly Child[] | undefined;
|
|
8
|
+
/** The mark, when `icon` is not given. */
|
|
9
|
+
children?: Snippet | undefined;
|
|
10
|
+
}, HTMLButtonElement> {
|
|
11
|
+
}
|
|
12
|
+
declare const Toggle: import("svelte").Component<ToggleProps, {}, "pressed">;
|
|
13
|
+
type Toggle = ReturnType<typeof Toggle>;
|
|
14
|
+
export default Toggle;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
// The text field after the segments: Enter submits, Backspace at its start
|
|
7
|
+
// removes the token before it, Command/Control+Z in an empty field undoes.
|
|
8
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
9
|
+
import { chain, getTokenSegmentsScope } from "./token-segments-scope.svelte.js";
|
|
10
|
+
|
|
11
|
+
let { ...rest }: HTMLInputAttributes = $props();
|
|
12
|
+
const scope = getTokenSegmentsScope();
|
|
13
|
+
const disabled = $derived.by(() => {
|
|
14
|
+
scope?.track();
|
|
15
|
+
return scope?.disabled() === true;
|
|
16
|
+
});
|
|
17
|
+
const readOnly = $derived.by(() => {
|
|
18
|
+
scope?.track();
|
|
19
|
+
return scope?.readOnly() === true;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function register(node: HTMLInputElement) {
|
|
23
|
+
scope?.setEditor(node);
|
|
24
|
+
return { destroy: () => scope?.setEditor(null) };
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<input
|
|
29
|
+
data-part="input-editor"
|
|
30
|
+
{...rest}
|
|
31
|
+
disabled={disabled || undefined}
|
|
32
|
+
readonly={readOnly || undefined}
|
|
33
|
+
use:register
|
|
34
|
+
onkeydown={(event) => {
|
|
35
|
+
chain(rest.onkeydown, event);
|
|
36
|
+
if (event.defaultPrevented || scope === undefined) return;
|
|
37
|
+
const action = scope.store.key(event);
|
|
38
|
+
if (action === undefined) return;
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
if (action.type === "submit") scope.submit();
|
|
41
|
+
}}
|
|
42
|
+
/>
|