@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,38 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { PrimitiveLoaderOptions } from "@bevelo/core";
|
|
4
|
+
import type { PrimitiveProps } from "./props.js";
|
|
5
|
+
|
|
6
|
+
/** Props for `Loader`. */
|
|
7
|
+
export interface LoaderProps extends PrimitiveProps<PrimitiveLoaderOptions, object, HTMLDivElement> {}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
// The Svelte adapter for `Loader` on the headless path: `loaderPrimitive`
|
|
12
|
+
// owns delay/min-duration timers and state transitions through the root's binding.
|
|
13
|
+
import { loaderPrimitive } from "@bevelo/core";
|
|
14
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
15
|
+
|
|
16
|
+
let { ...rest }: LoaderProps = $props();
|
|
17
|
+
|
|
18
|
+
const split = $derived(splitOptions(loaderPrimitive, rest));
|
|
19
|
+
const _uid = $props.id();
|
|
20
|
+
const handle = usePrimitive(loaderPrimitive, () => split.options, _uid);
|
|
21
|
+
|
|
22
|
+
const labelText = $derived(split.options.label ?? loaderPrimitive.defaults.label ?? "");
|
|
23
|
+
const root = $derived(handle.part("root"));
|
|
24
|
+
const status = $derived(handle.part("status"));
|
|
25
|
+
const spinner = $derived(handle.part("spinner"));
|
|
26
|
+
const words = $derived(handle.part("label"));
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#if root}
|
|
30
|
+
<svelte:element this={root.tag} {...partProps(root, split.attrs)}>
|
|
31
|
+
{#if status}
|
|
32
|
+
<svelte:element this={status.tag} {...partProps(status)}>
|
|
33
|
+
{#if spinner}<svelte:element this={spinner.tag} {...partProps(spinner)}></svelte:element>{/if}
|
|
34
|
+
{#if words}<svelte:element this={words.tag} {...partProps(words)}>{labelText}</svelte:element>{/if}
|
|
35
|
+
</svelte:element>
|
|
36
|
+
{/if}
|
|
37
|
+
</svelte:element>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PrimitiveLoaderOptions } from "@bevelo/core";
|
|
2
|
+
import type { PrimitiveProps } from "./props.js";
|
|
3
|
+
/** Props for `Loader`. */
|
|
4
|
+
export interface LoaderProps extends PrimitiveProps<PrimitiveLoaderOptions, object, HTMLDivElement> {
|
|
5
|
+
}
|
|
6
|
+
declare const Loader: import("svelte").Component<LoaderProps, {}, "">;
|
|
7
|
+
type Loader = ReturnType<typeof Loader>;
|
|
8
|
+
export default Loader;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { MentionItem, PrimitiveMentionMenuOptions } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
|
|
7
|
+
/** One suggestion row's state, as the `item` snippet receives it. */
|
|
8
|
+
export interface MentionMenuItemState {
|
|
9
|
+
readonly index: number;
|
|
10
|
+
readonly highlighted: boolean;
|
|
11
|
+
readonly disabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Props for `MentionMenu`. `text` is bindable. */
|
|
15
|
+
export interface MentionMenuProps
|
|
16
|
+
extends PrimitiveProps<
|
|
17
|
+
PrimitiveMentionMenuOptions,
|
|
18
|
+
{
|
|
19
|
+
/** Renders a suggestion's content in place of its label text. */
|
|
20
|
+
item?: Snippet<[MentionItem, MentionMenuItemState]> | undefined;
|
|
21
|
+
/** Text shown when no suggestion matches. */
|
|
22
|
+
emptyText?: string | Snippet | undefined;
|
|
23
|
+
},
|
|
24
|
+
HTMLDivElement
|
|
25
|
+
> {}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
// The Svelte adapter for `MentionMenu` on the headless path: the primitive
|
|
30
|
+
// owns the trigger detection, the filter machine and the text commits; the
|
|
31
|
+
// caret panel positions the list at the caret; Svelte owns the field and the
|
|
32
|
+
// rows. Text flows both ways: a commit token writes the machine's text into
|
|
33
|
+
// the field, a controlled host text writes back into the machine.
|
|
34
|
+
import { mentionMenuPrimitive } from "@bevelo/core";
|
|
35
|
+
import type { PrimitiveMentionMenuApi } from "@bevelo/core";
|
|
36
|
+
import { usePrimitive, partProps, portal, splitOptions } from "./headless.svelte.js";
|
|
37
|
+
import { bound } from "./bound.svelte.js";
|
|
38
|
+
import Describe from "./describe.svelte";
|
|
39
|
+
|
|
40
|
+
let { text = $bindable(), item, emptyText = "No matches", ...rest }: MentionMenuProps = $props();
|
|
41
|
+
|
|
42
|
+
const split = $derived(splitOptions(mentionMenuPrimitive, rest));
|
|
43
|
+
const textBound = bound(text);
|
|
44
|
+
|
|
45
|
+
const _uid = $props.id();
|
|
46
|
+
const handle = usePrimitive(mentionMenuPrimitive, () => {
|
|
47
|
+
const report = split.options.onTextChange;
|
|
48
|
+
return {
|
|
49
|
+
...split.options,
|
|
50
|
+
text: textBound.option(text),
|
|
51
|
+
defaultText: text ?? split.options.defaultText,
|
|
52
|
+
onTextChange: (next: string) => {
|
|
53
|
+
textBound.reported(next);
|
|
54
|
+
text = next;
|
|
55
|
+
report?.(next);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}, _uid);
|
|
59
|
+
|
|
60
|
+
const primitive = handle.api;
|
|
61
|
+
|
|
62
|
+
/** The primitive's api: `isOpen`, `text`, `focus`, the rows and the rest, while mounted. */
|
|
63
|
+
export function api(): PrimitiveMentionMenuApi {
|
|
64
|
+
return primitive;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const root = $derived(handle.part("root"));
|
|
68
|
+
const input = $derived(handle.part("input"));
|
|
69
|
+
const panel = $derived(handle.part("panel"));
|
|
70
|
+
const statusPart = $derived(handle.part("status"));
|
|
71
|
+
const emptyPart = $derived(handle.part("empty"));
|
|
72
|
+
const listPart = $derived(handle.part("list"));
|
|
73
|
+
|
|
74
|
+
const entries = $derived.by(() => {
|
|
75
|
+
handle.revision;
|
|
76
|
+
return primitive.entries();
|
|
77
|
+
});
|
|
78
|
+
const sections = $derived.by(() => {
|
|
79
|
+
handle.revision;
|
|
80
|
+
return primitive.sections();
|
|
81
|
+
});
|
|
82
|
+
const fieldTag = $derived(split.options.field === "input" ? "input" : "textarea");
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
{#if root}
|
|
86
|
+
<svelte:element this={root.tag} {...partProps(root, split.attrs)}>
|
|
87
|
+
{#if input}
|
|
88
|
+
<svelte:element this={fieldTag} {...partProps(input, { onchange: () => {} })}></svelte:element>
|
|
89
|
+
{/if}
|
|
90
|
+
{#if panel}
|
|
91
|
+
<svelte:element this={panel.tag} use:portal {...partProps(panel)}>
|
|
92
|
+
{#if statusPart}<svelte:element this={statusPart.tag} {...partProps(statusPart)}>{split.options.status ?? ""}</svelte:element>{/if}
|
|
93
|
+
{#if emptyPart}<svelte:element this={emptyPart.tag} {...partProps(emptyPart)}>{#if typeof emptyText === "function"}{@render emptyText()}{:else}{emptyText}{/if}</svelte:element>{/if}
|
|
94
|
+
{#if listPart}
|
|
95
|
+
<svelte:element this={listPart.tag} {...partProps(listPart)}>
|
|
96
|
+
{#each sections as section, sectionIndex ("section:" + sectionIndex)}
|
|
97
|
+
{@const sepAddress = { index: sectionIndex }}
|
|
98
|
+
{@const separator = handle.part("separator", sepAddress)}
|
|
99
|
+
{#if separator}<svelte:element this={separator.tag} {...partProps(separator)}></svelte:element>{/if}
|
|
100
|
+
{#snippet rows()}
|
|
101
|
+
{#each section.options as option (option.index)}
|
|
102
|
+
{@const entry = entries[option.index]}
|
|
103
|
+
{@const address = { index: option.index }}
|
|
104
|
+
{#if entry !== undefined}
|
|
105
|
+
{@const itemPart = handle.part("item", address)}
|
|
106
|
+
{@const iconPart = handle.part("icon", address)}
|
|
107
|
+
{@const labelNode = handle.part("label", address)}
|
|
108
|
+
{@const hint = handle.part("hint", address)}
|
|
109
|
+
{#if itemPart}
|
|
110
|
+
{@const itemState = itemPart.state as unknown as MentionMenuItemState}
|
|
111
|
+
<svelte:element this={itemPart.tag} {...partProps(itemPart)}>{#if iconPart && entry.item.icon !== undefined}<svelte:element this={iconPart.tag} {...partProps(iconPart)}><Describe node={entry.item.icon} /></svelte:element>{/if}{#if labelNode}<svelte:element this={labelNode.tag} {...partProps(labelNode)}>{#if item}{@render item(entry.item, itemState)}{:else}{entry.item.label}{/if}</svelte:element>{:else if item}{@render item(entry.item, itemState)}{:else}{entry.item.label}{/if}{#if hint}<svelte:element this={hint.tag} {...partProps(hint)}>{entry.item.description ?? ""}</svelte:element>{/if}</svelte:element>
|
|
112
|
+
{/if}
|
|
113
|
+
{/if}
|
|
114
|
+
{/each}
|
|
115
|
+
{/snippet}
|
|
116
|
+
{#if section.group === undefined}
|
|
117
|
+
{@render rows()}
|
|
118
|
+
{:else}
|
|
119
|
+
{@const groupPart = handle.part("group", sepAddress)}
|
|
120
|
+
{@const groupLabel = handle.part("group-label", sepAddress)}
|
|
121
|
+
{#if groupPart}
|
|
122
|
+
<svelte:element this={groupPart.tag} {...partProps(groupPart)}>
|
|
123
|
+
{#if groupLabel}<svelte:element this={groupLabel.tag} {...partProps(groupLabel)}>{section.group}</svelte:element>{/if}
|
|
124
|
+
{@render rows()}
|
|
125
|
+
</svelte:element>
|
|
126
|
+
{/if}
|
|
127
|
+
{/if}
|
|
128
|
+
{/each}
|
|
129
|
+
</svelte:element>
|
|
130
|
+
{/if}
|
|
131
|
+
</svelte:element>
|
|
132
|
+
{/if}
|
|
133
|
+
</svelte:element>
|
|
134
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { MentionItem, PrimitiveMentionMenuOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** One suggestion row's state, as the `item` snippet receives it. */
|
|
5
|
+
export interface MentionMenuItemState {
|
|
6
|
+
readonly index: number;
|
|
7
|
+
readonly highlighted: boolean;
|
|
8
|
+
readonly disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Props for `MentionMenu`. `text` is bindable. */
|
|
11
|
+
export interface MentionMenuProps extends PrimitiveProps<PrimitiveMentionMenuOptions, {
|
|
12
|
+
/** Renders a suggestion's content in place of its label text. */
|
|
13
|
+
item?: Snippet<[MentionItem, MentionMenuItemState]> | undefined;
|
|
14
|
+
/** Text shown when no suggestion matches. */
|
|
15
|
+
emptyText?: string | Snippet | undefined;
|
|
16
|
+
}, HTMLDivElement> {
|
|
17
|
+
}
|
|
18
|
+
import type { PrimitiveMentionMenuApi } from "@bevelo/core";
|
|
19
|
+
declare const MentionMenu: import("svelte").Component<MentionMenuProps, {
|
|
20
|
+
api: () => PrimitiveMentionMenuApi;
|
|
21
|
+
}, "text">;
|
|
22
|
+
type MentionMenu = ReturnType<typeof MentionMenu>;
|
|
23
|
+
export default MentionMenu;
|
package/dist/menu.svelte
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type {
|
|
5
|
+
PanelPosition,
|
|
6
|
+
PopupPlacementProps,
|
|
7
|
+
PrimitiveMenuApi,
|
|
8
|
+
PrimitiveMenuCommandNode,
|
|
9
|
+
PrimitiveMenuOptions,
|
|
10
|
+
} from "@bevelo/core";
|
|
11
|
+
import type { PrimitiveProps } from "./props.js";
|
|
12
|
+
|
|
13
|
+
/** Props for `Menu`. `open` is bindable. */
|
|
14
|
+
export interface MenuProps
|
|
15
|
+
extends PrimitiveProps<
|
|
16
|
+
PrimitiveMenuOptions,
|
|
17
|
+
PopupPlacementProps & {
|
|
18
|
+
/** The arrow element the root panel points at its anchor. */
|
|
19
|
+
arrow?: PanelPosition["arrow"];
|
|
20
|
+
/** Distance the arrow keeps from the panel's corners. */
|
|
21
|
+
arrowPadding?: number | undefined;
|
|
22
|
+
/** Receives the menu's api while it is mounted. */
|
|
23
|
+
controller?: { api?: PrimitiveMenuApi } | undefined;
|
|
24
|
+
/** A checkbox row toggled: its next checked state and its id. */
|
|
25
|
+
onCheckedChange?: ((checked: boolean, details: { readonly value: string }) => void) | undefined;
|
|
26
|
+
/** A radio row was chosen: its id. */
|
|
27
|
+
onChange?: ((value: string) => void) | undefined;
|
|
28
|
+
/** Renders a command row's content in place of its label text. */
|
|
29
|
+
item?: Snippet<[PrimitiveMenuCommandNode]> | undefined;
|
|
30
|
+
/** A checked checkbox row's mark. */
|
|
31
|
+
checkmark?: string | Snippet | undefined;
|
|
32
|
+
/** A checked radio row's mark. */
|
|
33
|
+
radioMark?: string | Snippet | undefined;
|
|
34
|
+
/** A submenu row's arrow. */
|
|
35
|
+
submenuArrow?: string | Snippet | undefined;
|
|
36
|
+
},
|
|
37
|
+
HTMLDivElement
|
|
38
|
+
> {}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
// The Svelte adapter for `Menu` on the headless path: the primitive owns the
|
|
43
|
+
// tree, the typeahead, the hover intent, and the dismissal arbitration;
|
|
44
|
+
// core's slot bindings own every element concern; Svelte owns the recursive
|
|
45
|
+
// rendering.
|
|
46
|
+
import { menuCheckChange, menuPrimitive, resolvePlacement } from "@bevelo/core";
|
|
47
|
+
import type {
|
|
48
|
+
ChangeDetails,
|
|
49
|
+
PrimitiveMenuTreeNode,
|
|
50
|
+
PrimitiveMenuGroupNode,
|
|
51
|
+
PrimitiveMenuSeparatorNode,
|
|
52
|
+
PrimitiveMenuPanelNode,
|
|
53
|
+
Child,
|
|
54
|
+
} from "@bevelo/core";
|
|
55
|
+
import { onDestroy, untrack } from "svelte";
|
|
56
|
+
import { usePrimitive, partProps, portal, splitOptions } from "./headless.svelte.js";
|
|
57
|
+
import { bound } from "./bound.svelte.js";
|
|
58
|
+
import Describe from "./describe.svelte";
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
open = $bindable(), side, align, offset, alignOffset, padding,
|
|
62
|
+
boundary, arrow, arrowPadding, controller, onCheckedChange, onChange, item, checkmark = "✓",
|
|
63
|
+
radioMark = "•", submenuArrow = "›", ...rest
|
|
64
|
+
}: MenuProps = $props();
|
|
65
|
+
|
|
66
|
+
const split = $derived(splitOptions(menuPrimitive, rest));
|
|
67
|
+
|
|
68
|
+
const resolved = $derived(
|
|
69
|
+
resolvePlacement({
|
|
70
|
+
placement: split.options.placement,
|
|
71
|
+
side,
|
|
72
|
+
align,
|
|
73
|
+
offset,
|
|
74
|
+
alignOffset,
|
|
75
|
+
padding,
|
|
76
|
+
boundary,
|
|
77
|
+
defaultPlacement: "bottom-start",
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const rootPosition = $derived<PanelPosition>({
|
|
82
|
+
offset: resolved.offset,
|
|
83
|
+
alignOffset,
|
|
84
|
+
padding: resolved.padding,
|
|
85
|
+
boundary: resolved.boundary,
|
|
86
|
+
arrow,
|
|
87
|
+
arrowPadding,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const openBound = bound(open);
|
|
91
|
+
|
|
92
|
+
const _uid = $props.id();
|
|
93
|
+
const handle = usePrimitive(menuPrimitive, () => {
|
|
94
|
+
const reportOpen = split.options.onOpenChange;
|
|
95
|
+
const reportSelect = split.options.onSelect;
|
|
96
|
+
return {
|
|
97
|
+
...split.options,
|
|
98
|
+
// Always present, so a checkbox or radio row reports its change even when
|
|
99
|
+
// the host does not handle onSelect.
|
|
100
|
+
onSelect: (id: string) => {
|
|
101
|
+
reportSelect?.(id);
|
|
102
|
+
const change = menuCheckChange(split.options.items ?? [], id, (key) => handle.api.isChecked(key));
|
|
103
|
+
if (change?.kind === "checkbox") onCheckedChange?.(change.checked, { value: change.value });
|
|
104
|
+
else if (change?.kind === "radio") onChange?.(change.value);
|
|
105
|
+
},
|
|
106
|
+
placement: resolved.placement,
|
|
107
|
+
// A thunk, not the object: the kernel's payload diff exempts function
|
|
108
|
+
// identities, and a fresh object would resynchronize state every pass.
|
|
109
|
+
position: split.options.position ?? (() => rootPosition),
|
|
110
|
+
open: openBound.option(open),
|
|
111
|
+
defaultOpen: open ?? split.options.defaultOpen,
|
|
112
|
+
onOpenChange: (next: boolean, details?: ChangeDetails<string>) => {
|
|
113
|
+
reportOpen?.(next, details);
|
|
114
|
+
if (details?.canceled === true) return;
|
|
115
|
+
openBound.reported(next);
|
|
116
|
+
open = next;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}, _uid);
|
|
120
|
+
/** The primitive's api: open, close, toggle, isOpen, isChecked and the rest. */
|
|
121
|
+
export function api(): PrimitiveMenuApi {
|
|
122
|
+
return handle.api;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The bridge a host passes at mount receives the api for the menu's lifetime.
|
|
126
|
+
const bridge = untrack(() => controller);
|
|
127
|
+
if (bridge !== undefined) {
|
|
128
|
+
bridge.api = handle.api;
|
|
129
|
+
}
|
|
130
|
+
onDestroy(() => {
|
|
131
|
+
if (bridge !== undefined) {
|
|
132
|
+
delete bridge.api;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const root = $derived(handle.part("root"));
|
|
137
|
+
const rootState = $derived((handle.part("root")?.state ?? {}) as { showing?: boolean });
|
|
138
|
+
// `api.nodes()` is not revision-tracked on its own: the derived reads the
|
|
139
|
+
// revision first, so the snippet re-evaluates when the machine moves.
|
|
140
|
+
const nodes = $derived.by(() => {
|
|
141
|
+
handle.revision;
|
|
142
|
+
if (rootState.showing !== true) {
|
|
143
|
+
return [] as readonly PrimitiveMenuTreeNode[];
|
|
144
|
+
}
|
|
145
|
+
return handle.api.nodes();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const rootAttrs = $derived({
|
|
149
|
+
...split.attrs,
|
|
150
|
+
style: `position:fixed;left:0;top:0;${typeof split.attrs["style"] === "string" ? split.attrs["style"] : ""}`,
|
|
151
|
+
});
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
{#snippet glyph(content: string | Snippet)}{#if typeof content === "function"}{@render content()}{:else}{content}{/if}{/snippet}
|
|
155
|
+
|
|
156
|
+
{#snippet menuNodes(nodes: readonly PrimitiveMenuTreeNode[])}
|
|
157
|
+
{#each nodes as node (node.key)}
|
|
158
|
+
{#if node.kind === "group"}
|
|
159
|
+
{@const groupNode = node as PrimitiveMenuGroupNode}
|
|
160
|
+
{@const group = handle.part("group", { index: groupNode.index })}
|
|
161
|
+
{@const groupLabel = handle.part("label", { index: groupNode.index })}
|
|
162
|
+
{#if group}
|
|
163
|
+
<svelte:element this={group.tag} {...partProps(group)}>{#if groupNode.item.label !== "" && groupLabel}<svelte:element this={groupLabel.tag} {...partProps(groupLabel)}>{groupNode.item.label}</svelte:element>{/if}{@render menuNodes(groupNode.children)}</svelte:element>
|
|
164
|
+
{/if}
|
|
165
|
+
{:else if node.kind === "separator"}
|
|
166
|
+
{@const sepNode = node as PrimitiveMenuSeparatorNode}
|
|
167
|
+
{@const separator = handle.part("separator", { index: sepNode.index })}
|
|
168
|
+
{#if separator}<svelte:element this={separator.tag} {...partProps(separator)}></svelte:element>{/if}
|
|
169
|
+
{:else}
|
|
170
|
+
{@const commandNode = node as PrimitiveMenuCommandNode}
|
|
171
|
+
{@const itemPart = handle.part("item", { index: commandNode.index })}
|
|
172
|
+
{@const indicator = handle.part("indicator", { index: commandNode.index })}
|
|
173
|
+
{@const iconPart = handle.part("icon", { index: commandNode.index })}
|
|
174
|
+
{@const shortcut = handle.part("shortcut", { index: commandNode.index })}
|
|
175
|
+
{@const arrowPart = handle.part("arrow", { index: commandNode.index })}
|
|
176
|
+
{#if itemPart}
|
|
177
|
+
<svelte:element this={itemPart.tag} {...partProps(itemPart)}>{#if (commandNode.kind === "checkbox" || commandNode.kind === "radio") && indicator}<svelte:element this={indicator.tag} {...partProps(indicator)}>{@render glyph(commandNode.kind === "radio" ? radioMark : checkmark)}</svelte:element>{/if}{#if iconPart && commandNode.item.icon !== undefined && (commandNode.item.icon as readonly Child[]).length > 0}<svelte:element this={iconPart.tag} {...partProps(iconPart)}>{#each commandNode.item.icon as readonly Child[] as child}<Describe node={child} />{/each}</svelte:element>{/if}<span data-menu-label="">{#if item}{@render item(commandNode)}{:else}{commandNode.item.label}{/if}</span>{#if (commandNode.item.shortcut ?? "") !== "" && shortcut}<svelte:element this={shortcut.tag} {...partProps(shortcut)}>{commandNode.item.shortcut}</svelte:element>{/if}{#if commandNode.kind === "submenu"}{#if arrowPart}<svelte:element this={arrowPart.tag} {...partProps(arrowPart)}>{@render glyph(submenuArrow)}</svelte:element>{/if}{#if commandNode.panel !== undefined}{@const panel = commandNode.panel as PrimitiveMenuPanelNode}{@const submenu = handle.part("submenu", { index: panel.index })}{#if submenu}<svelte:element this={submenu.tag} use:portal {...partProps(submenu)}>{@render menuNodes(panel.children)}</svelte:element>{/if}{/if}{/if}</svelte:element>
|
|
178
|
+
{/if}
|
|
179
|
+
{/if}
|
|
180
|
+
{/each}
|
|
181
|
+
{/snippet}
|
|
182
|
+
|
|
183
|
+
{#if root}
|
|
184
|
+
<svelte:element this={root.tag} use:portal {...partProps(root, rootAttrs)}>{@render menuNodes(nodes)}</svelte:element>
|
|
185
|
+
{/if}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { PanelPosition, PopupPlacementProps, PrimitiveMenuApi, PrimitiveMenuCommandNode, PrimitiveMenuOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** Props for `Menu`. `open` is bindable. */
|
|
5
|
+
export interface MenuProps extends PrimitiveProps<PrimitiveMenuOptions, PopupPlacementProps & {
|
|
6
|
+
/** The arrow element the root panel points at its anchor. */
|
|
7
|
+
arrow?: PanelPosition["arrow"];
|
|
8
|
+
/** Distance the arrow keeps from the panel's corners. */
|
|
9
|
+
arrowPadding?: number | undefined;
|
|
10
|
+
/** Receives the menu's api while it is mounted. */
|
|
11
|
+
controller?: {
|
|
12
|
+
api?: PrimitiveMenuApi;
|
|
13
|
+
} | undefined;
|
|
14
|
+
/** A checkbox row toggled: its next checked state and its id. */
|
|
15
|
+
onCheckedChange?: ((checked: boolean, details: {
|
|
16
|
+
readonly value: string;
|
|
17
|
+
}) => void) | undefined;
|
|
18
|
+
/** A radio row was chosen: its id. */
|
|
19
|
+
onChange?: ((value: string) => void) | undefined;
|
|
20
|
+
/** Renders a command row's content in place of its label text. */
|
|
21
|
+
item?: Snippet<[PrimitiveMenuCommandNode]> | undefined;
|
|
22
|
+
/** A checked checkbox row's mark. */
|
|
23
|
+
checkmark?: string | Snippet | undefined;
|
|
24
|
+
/** A checked radio row's mark. */
|
|
25
|
+
radioMark?: string | Snippet | undefined;
|
|
26
|
+
/** A submenu row's arrow. */
|
|
27
|
+
submenuArrow?: string | Snippet | undefined;
|
|
28
|
+
}, HTMLDivElement> {
|
|
29
|
+
}
|
|
30
|
+
declare const Menu: import("svelte").Component<MenuProps, {
|
|
31
|
+
api: () => PrimitiveMenuApi;
|
|
32
|
+
}, "open">;
|
|
33
|
+
type Menu = ReturnType<typeof Menu>;
|
|
34
|
+
export default Menu;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { MenubarItem, PrimitiveMenubarApi, PrimitiveMenubarOptions } from "@bevelo/core";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
|
|
7
|
+
/** One menu trigger's state, as the `item` snippet receives it. */
|
|
8
|
+
export interface MenubarItemState {
|
|
9
|
+
readonly value: string;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly disabled: boolean;
|
|
12
|
+
readonly open: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Props for `Menubar`. `expanded` is bindable: an open request writes the menu's value, Escape writes "". */
|
|
16
|
+
export interface MenubarProps
|
|
17
|
+
extends PrimitiveProps<
|
|
18
|
+
PrimitiveMenubarOptions,
|
|
19
|
+
{
|
|
20
|
+
/** Renders a menu trigger's content in place of its label text. */
|
|
21
|
+
item?: Snippet<[MenubarItem, MenubarItemState]> | undefined;
|
|
22
|
+
},
|
|
23
|
+
HTMLDivElement
|
|
24
|
+
> {}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
// The Svelte adapter for `Menubar` on the headless path: the primitive owns
|
|
29
|
+
// the open machine and the roving tab stop; Svelte owns the item buttons and
|
|
30
|
+
// focus orchestration.
|
|
31
|
+
import { menubarPrimitive } from "@bevelo/core";
|
|
32
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
33
|
+
|
|
34
|
+
const NO_ITEMS: readonly MenubarItem[] = [];
|
|
35
|
+
|
|
36
|
+
let { expanded = $bindable(), item, ...rest }: MenubarProps = $props();
|
|
37
|
+
|
|
38
|
+
const split = $derived(splitOptions(menubarPrimitive, rest));
|
|
39
|
+
const _uid = $props.id();
|
|
40
|
+
const handle = usePrimitive(menubarPrimitive, () => {
|
|
41
|
+
const reportOpen = split.options.onMenuOpen;
|
|
42
|
+
const reportClose = split.options.onMenuClose;
|
|
43
|
+
return {
|
|
44
|
+
...split.options,
|
|
45
|
+
expanded,
|
|
46
|
+
onMenuOpen: (value: string) => {
|
|
47
|
+
expanded = value;
|
|
48
|
+
reportOpen?.(value);
|
|
49
|
+
},
|
|
50
|
+
onMenuClose: () => {
|
|
51
|
+
expanded = "";
|
|
52
|
+
reportClose?.();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}, _uid);
|
|
56
|
+
|
|
57
|
+
/** The primitive's api: `focusItem`, `trackFocus` and `activeValue`. */
|
|
58
|
+
export function api(): PrimitiveMenubarApi {
|
|
59
|
+
return handle.api;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const root = $derived(handle.part("root"));
|
|
63
|
+
const itemList = $derived(split.options.items ?? NO_ITEMS);
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
{#if root}
|
|
67
|
+
<svelte:element this={root.tag} {...partProps(root, split.attrs)}>
|
|
68
|
+
{#each itemList as entry, index (entry.value)}
|
|
69
|
+
{@const trigger = handle.part("menu-trigger", { index })}
|
|
70
|
+
{#if trigger}
|
|
71
|
+
<svelte:element this={trigger.tag} {...partProps(trigger)}>{#if item}{@render item(entry, trigger.state as unknown as MenubarItemState)}{:else}{entry.label}{/if}</svelte:element>
|
|
72
|
+
{/if}
|
|
73
|
+
{/each}
|
|
74
|
+
</svelte:element>
|
|
75
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { MenubarItem, PrimitiveMenubarApi, PrimitiveMenubarOptions } from "@bevelo/core";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
/** One menu trigger's state, as the `item` snippet receives it. */
|
|
5
|
+
export interface MenubarItemState {
|
|
6
|
+
readonly value: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly disabled: boolean;
|
|
9
|
+
readonly open: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Props for `Menubar`. `expanded` is bindable: an open request writes the menu's value, Escape writes "". */
|
|
12
|
+
export interface MenubarProps extends PrimitiveProps<PrimitiveMenubarOptions, {
|
|
13
|
+
/** Renders a menu trigger's content in place of its label text. */
|
|
14
|
+
item?: Snippet<[MenubarItem, MenubarItemState]> | undefined;
|
|
15
|
+
}, HTMLDivElement> {
|
|
16
|
+
}
|
|
17
|
+
declare const Menubar: import("svelte").Component<MenubarProps, {
|
|
18
|
+
api: () => PrimitiveMenubarApi;
|
|
19
|
+
}, "expanded">;
|
|
20
|
+
type Menubar = ReturnType<typeof Menubar>;
|
|
21
|
+
export default Menubar;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { GaugeValueFormat, GaugeValueLabelDetails, PrimitiveMeterOptions } from "@bevelo/core";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import type { PrimitiveProps } from "./props.js";
|
|
6
|
+
import type { GaugePartState } from "./gauge-context.js";
|
|
7
|
+
|
|
8
|
+
/** What `MeterValue`'s and `MeterIndicator`'s snippets receive. */
|
|
9
|
+
export type MeterPartState = GaugePartState;
|
|
10
|
+
|
|
11
|
+
/** Props for `Meter`. */
|
|
12
|
+
export interface MeterProps
|
|
13
|
+
extends PrimitiveProps<
|
|
14
|
+
PrimitiveMeterOptions,
|
|
15
|
+
{
|
|
16
|
+
/** Number formatting options or a formatter for the default value text. */
|
|
17
|
+
format?: GaugeValueFormat;
|
|
18
|
+
/** Locale for `format`'s number formatting. */
|
|
19
|
+
locale?: string;
|
|
20
|
+
/** The accessible and displayed value text, from the value and its details. */
|
|
21
|
+
getValueLabel?: (value: number, details: GaugeValueLabelDetails) => string;
|
|
22
|
+
/** The parts, placed by the host; the root then renders only these. */
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
},
|
|
25
|
+
HTMLDivElement
|
|
26
|
+
> {}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
// The Svelte adapter for `Meter` on the headless path: the primitive owns the
|
|
31
|
+
// range, the clamp and the ARIA; Svelte owns the elements. With children the
|
|
32
|
+
// root renders only them, and `MeterLabel`, `MeterTrack`, `MeterIndicator`
|
|
33
|
+
// and `MeterValue` place the pieces.
|
|
34
|
+
import { meterPrimitive } from "@bevelo/core";
|
|
35
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
36
|
+
import { resolveGaugeText, setGauge } from "./gauge-context.js";
|
|
37
|
+
|
|
38
|
+
let { format, locale, getValueLabel, children, ...rest }: MeterProps = $props();
|
|
39
|
+
|
|
40
|
+
const split = $derived(splitOptions(meterPrimitive, rest));
|
|
41
|
+
const valueText = $derived(
|
|
42
|
+
resolveGaugeText(split.options.value ?? split.options.min ?? 0, {
|
|
43
|
+
min: split.options.min,
|
|
44
|
+
max: split.options.max,
|
|
45
|
+
valueText: split.options.valueText,
|
|
46
|
+
format,
|
|
47
|
+
locale,
|
|
48
|
+
getValueLabel,
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
const _uid = $props.id();
|
|
52
|
+
const handle = usePrimitive(
|
|
53
|
+
meterPrimitive,
|
|
54
|
+
() => (valueText === undefined ? split.options : { ...split.options, valueText }),
|
|
55
|
+
_uid,
|
|
56
|
+
);
|
|
57
|
+
const root = $derived(handle.part("root"));
|
|
58
|
+
const labelPart = $derived(handle.part("label"));
|
|
59
|
+
const track = $derived(handle.part("track"));
|
|
60
|
+
const bar = $derived(handle.part("bar"));
|
|
61
|
+
const state = $derived(
|
|
62
|
+
handle.state as { label?: string; valueText: string; min: number; max: number; percent: number },
|
|
63
|
+
);
|
|
64
|
+
const partState = $derived.by(
|
|
65
|
+
(): GaugePartState => ({
|
|
66
|
+
value: split.options.value ?? state.min,
|
|
67
|
+
min: state.min,
|
|
68
|
+
max: state.max,
|
|
69
|
+
percent: state.percent,
|
|
70
|
+
text: state.valueText !== "" ? state.valueText : `${Math.round(state.percent)}%`,
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
setGauge({
|
|
74
|
+
handle,
|
|
75
|
+
get state() {
|
|
76
|
+
return partState;
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
{#if root}
|
|
82
|
+
{#if children}<svelte:element this={root.tag} {...partProps(root, split.attrs)}>{@render children()}</svelte:element>{:else}<svelte:element this={root.tag} {...partProps(root, split.attrs)}>{#if labelPart}<svelte:element this={labelPart.tag} {...partProps(labelPart)}>{state.label ?? ""}</svelte:element>{/if}{#if track}<svelte:element this={track.tag} {...partProps(track)}>{#if bar}<svelte:element this={bar.tag} {...partProps(bar)}></svelte:element>{/if}</svelte:element>{/if}</svelte:element>{/if}
|
|
83
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GaugeValueFormat, GaugeValueLabelDetails, PrimitiveMeterOptions } from "@bevelo/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { PrimitiveProps } from "./props.js";
|
|
4
|
+
import type { GaugePartState } from "./gauge-context.js";
|
|
5
|
+
/** What `MeterValue`'s and `MeterIndicator`'s snippets receive. */
|
|
6
|
+
export type MeterPartState = GaugePartState;
|
|
7
|
+
/** Props for `Meter`. */
|
|
8
|
+
export interface MeterProps extends PrimitiveProps<PrimitiveMeterOptions, {
|
|
9
|
+
/** Number formatting options or a formatter for the default value text. */
|
|
10
|
+
format?: GaugeValueFormat;
|
|
11
|
+
/** Locale for `format`'s number formatting. */
|
|
12
|
+
locale?: string;
|
|
13
|
+
/** The accessible and displayed value text, from the value and its details. */
|
|
14
|
+
getValueLabel?: (value: number, details: GaugeValueLabelDetails) => string;
|
|
15
|
+
/** The parts, placed by the host; the root then renders only these. */
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
}, HTMLDivElement> {
|
|
18
|
+
}
|
|
19
|
+
declare const Meter: import("svelte").Component<MeterProps, {}, "">;
|
|
20
|
+
type Meter = ReturnType<typeof Meter>;
|
|
21
|
+
export default Meter;
|