@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,96 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Writes each `createAttributePreference` value to a `data-*` attribute so stylesheets can match it on first paint.
|
|
4
|
+
A global preference lands on `<html>`; any other lands on this component's own wrapper, which uses `display: contents`.
|
|
5
|
+
During server rendering the first child is an inline script built by `preferencesScript`; it applies stored values while
|
|
6
|
+
the page is still loading, ahead of hydration. Components reading a value with `usePreference` update once hydrated.
|
|
7
|
+
@experimental
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { preferencesScript, type AttributePreference } from "@bevelo/core";
|
|
11
|
+
import type { Snippet } from "svelte";
|
|
12
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
13
|
+
|
|
14
|
+
type WrapperAttributes = Omit<HTMLAttributes<HTMLDivElement>, "children">;
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
preferences,
|
|
18
|
+
nonce,
|
|
19
|
+
children,
|
|
20
|
+
...rest
|
|
21
|
+
}: WrapperAttributes & {
|
|
22
|
+
/** Preferences created with `createAttributePreference`. */
|
|
23
|
+
preferences: readonly AttributePreference<string>[]
|
|
24
|
+
/** CSP nonce to put on the inline startup script. */
|
|
25
|
+
nonce?: string
|
|
26
|
+
children?: Snippet
|
|
27
|
+
} = $props()
|
|
28
|
+
|
|
29
|
+
let element = $state<HTMLDivElement>()
|
|
30
|
+
// Only the server's HTML carries the startup script, and it is dropped once
|
|
31
|
+
// the component mounts. Browsers do not execute a script element that Svelte
|
|
32
|
+
// creates on the client, so a client-only render never needs it.
|
|
33
|
+
let mounted = $state(false)
|
|
34
|
+
|
|
35
|
+
const attributeText = (preference: AttributePreference<string>, value: string) =>
|
|
36
|
+
preference.attributeText(value)
|
|
37
|
+
|
|
38
|
+
const write = (list: readonly AttributePreference<string>[]) => {
|
|
39
|
+
for (const preference of list) {
|
|
40
|
+
const target = preference.global ? document.documentElement : element
|
|
41
|
+
const text = attributeText(preference, preference.get())
|
|
42
|
+
if (text === null) {
|
|
43
|
+
target?.removeAttribute(preference.attribute)
|
|
44
|
+
} else {
|
|
45
|
+
target?.setAttribute(preference.attribute, text)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// On the server the wrapper's attributes hold each initial value. In the
|
|
51
|
+
// browser they stay empty and the effect sets them instead: if the template
|
|
52
|
+
// carried them, hydration would overwrite what the startup script applied.
|
|
53
|
+
const server = $derived.by(() => {
|
|
54
|
+
const attrs: Record<string, string> = {}
|
|
55
|
+
if (typeof window === "undefined") {
|
|
56
|
+
for (const preference of preferences) {
|
|
57
|
+
if (!preference.global) {
|
|
58
|
+
const text = attributeText(preference, preference.initialValue)
|
|
59
|
+
if (text !== null) {
|
|
60
|
+
attrs[preference.attribute] = text
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return attrs
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// `{@html}` inserts the markup verbatim, so the nonce is entity-encoded first.
|
|
69
|
+
const encode = (value: string) => value.replace(/[&"<>]/g, (char) => `&#${char.charCodeAt(0)};`)
|
|
70
|
+
const nonceAttribute = $derived(nonce ? ` nonce="${encode(nonce)}"` : "")
|
|
71
|
+
const script = $derived(
|
|
72
|
+
"<script" + nonceAttribute + ">" + preferencesScript(preferences) + "<\/script>"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
$effect(() => {
|
|
76
|
+
const list = preferences
|
|
77
|
+
// Subscribe before the first write so each preference has loaded its stored value.
|
|
78
|
+
const stops = list.map((preference) => preference.subscribe(() => write(list)))
|
|
79
|
+
write(list)
|
|
80
|
+
mounted = true
|
|
81
|
+
return () => {
|
|
82
|
+
for (const stop of stops) stop()
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<div
|
|
88
|
+
{...rest}
|
|
89
|
+
{...server}
|
|
90
|
+
data-slot="preferences"
|
|
91
|
+
style="display: contents"
|
|
92
|
+
bind:this={element}
|
|
93
|
+
>
|
|
94
|
+
{#if !mounted}{@html script}{/if}
|
|
95
|
+
{@render children?.()}
|
|
96
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AttributePreference } from "@bevelo/core";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
type WrapperAttributes = Omit<HTMLAttributes<HTMLDivElement>, "children">;
|
|
5
|
+
type $$ComponentProps = WrapperAttributes & {
|
|
6
|
+
/** Preferences created with `createAttributePreference`. */
|
|
7
|
+
preferences: readonly AttributePreference<string>[];
|
|
8
|
+
/** CSP nonce to put on the inline startup script. */
|
|
9
|
+
nonce?: string;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Writes each `createAttributePreference` value to a `data-*` attribute so stylesheets can match it on first paint.
|
|
14
|
+
* A global preference lands on `<html>`; any other lands on this component's own wrapper, which uses `display: contents`.
|
|
15
|
+
* During server rendering the first child is an inline script built by `preferencesScript`; it applies stored values while
|
|
16
|
+
* the page is still loading, ahead of hydration. Components reading a value with `usePreference` update once hydrated.
|
|
17
|
+
* @experimental
|
|
18
|
+
*/
|
|
19
|
+
declare const Preferences: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
20
|
+
type Preferences = ReturnType<typeof Preferences>;
|
|
21
|
+
export default Preferences;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AttributePreference } from "@bevelo/core";
|
|
2
|
+
/**
|
|
3
|
+
* Tracks a preference as `.current`: the initial value before mount, the stored
|
|
4
|
+
* value from then on.
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
declare function usePreference<T extends string>(preference: AttributePreference<T>): {
|
|
8
|
+
/** The current value. */
|
|
9
|
+
readonly current: T;
|
|
10
|
+
};
|
|
11
|
+
export { usePreference };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// `usePreference` for Svelte: exposes a preference as `.current`. It holds the
|
|
2
|
+
// initial (server) value until the component mounts, then the stored value, so a
|
|
3
|
+
// control can both show and change it.
|
|
4
|
+
//
|
|
5
|
+
// @experimental — may change in any minor release.
|
|
6
|
+
/**
|
|
7
|
+
* Tracks a preference as `.current`: the initial value before mount, the stored
|
|
8
|
+
* value from then on.
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
function usePreference(preference) {
|
|
12
|
+
let state = $state.raw(preference.initialValue);
|
|
13
|
+
$effect(() => {
|
|
14
|
+
// Subscribe first: subscribing loads the stored value, which `get()` then returns.
|
|
15
|
+
const stop = preference.subscribe((value) => (state = value));
|
|
16
|
+
state = preference.get();
|
|
17
|
+
return stop;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
/** The current value. */
|
|
21
|
+
get current() {
|
|
22
|
+
return state;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { usePreference };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Attachment } from "svelte/attachments";
|
|
2
|
+
import type { PresenceEntry, PresenceGroupOptions, PresenceOptions, PresenceState } from "@bevelo/motion/presence";
|
|
3
|
+
export type { PresenceGroupOptions, PresenceMode, PresenceOptions, PresenceRunner, PresenceState, } from "@bevelo/motion/presence";
|
|
4
|
+
/** What `usePresence` returns. `mounted` and `state` are reactive. */
|
|
5
|
+
export interface PresenceView {
|
|
6
|
+
/** Keep the element rendered while true: through `entering`, `open` and `exiting`. */
|
|
7
|
+
readonly mounted: boolean;
|
|
8
|
+
readonly state: PresenceState;
|
|
9
|
+
/** `{@attach p.attach}` on the element whose phases play. */
|
|
10
|
+
readonly attach: Attachment<Element>;
|
|
11
|
+
}
|
|
12
|
+
/** One rendered member of a presence group. */
|
|
13
|
+
export interface PresenceGroupItem<T> extends PresenceEntry<T> {
|
|
14
|
+
/** `{@attach entry.attach}` on the member's element. Stable per key. */
|
|
15
|
+
readonly attach: Attachment<HTMLElement>;
|
|
16
|
+
}
|
|
17
|
+
/** What `usePresenceGroup` returns. */
|
|
18
|
+
export interface PresenceGroupView<T> {
|
|
19
|
+
/** The mounted members in render order; an exiting member keeps its place and its last value. */
|
|
20
|
+
readonly entries: readonly PresenceGroupItem<T>[];
|
|
21
|
+
}
|
|
22
|
+
/** One element's presence, following `open`. It disposes on unmount. */
|
|
23
|
+
export declare function usePresence(open: () => boolean, options?: () => PresenceOptions): PresenceView;
|
|
24
|
+
/** A keyed list's presence, following `values`. It disposes on unmount. */
|
|
25
|
+
export declare function usePresenceGroup<T>(values: () => readonly T[], keyOf: (value: T) => string, options?: () => PresenceGroupOptions): PresenceGroupView<T>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Presence for Svelte 5: `@bevelo/motion/presence` behind rune helpers.
|
|
2
|
+
//
|
|
3
|
+
// `usePresence` keeps an element mounted through its exit: render it while `mounted`, attach
|
|
4
|
+
// it with `{@attach p.attach}`, and the engine writes `data-state` and plays each phase. CSS
|
|
5
|
+
// owns the motion by default (`cssRunner`); `springRunner` from `@bevelo/motion/spring-value`
|
|
6
|
+
// drives a progress value instead. `usePresenceGroup` does the same for a keyed list, keeping an
|
|
7
|
+
// exiting entry in its place. The open flag and the values are getters, applied in an
|
|
8
|
+
// `$effect.pre` so a change mounts in the same update. A server render shows the initial state.
|
|
9
|
+
//
|
|
10
|
+
// @experimental — may change in any minor release.
|
|
11
|
+
import { untrack } from "svelte";
|
|
12
|
+
import { createPresence, createPresenceGroup } from "@bevelo/motion/presence";
|
|
13
|
+
import { fromStore } from "./engine-state.svelte.js";
|
|
14
|
+
/** One element's presence, following `open`. It disposes on unmount. */
|
|
15
|
+
export function usePresence(open, options) {
|
|
16
|
+
const presence = createPresence(untrack(open), untrack(() => options?.() ?? {}));
|
|
17
|
+
$effect.pre(() => presence.setOpen(open()));
|
|
18
|
+
if (options !== undefined)
|
|
19
|
+
$effect(() => presence.update(options()));
|
|
20
|
+
$effect(() => () => presence.dispose());
|
|
21
|
+
const snapshot = fromStore(presence, (state) => state);
|
|
22
|
+
return {
|
|
23
|
+
get mounted() {
|
|
24
|
+
return snapshot.current.mounted;
|
|
25
|
+
},
|
|
26
|
+
get state() {
|
|
27
|
+
return snapshot.current.state;
|
|
28
|
+
},
|
|
29
|
+
attach: (el) => presence.attach(el),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** A keyed list's presence, following `values`. It disposes on unmount. */
|
|
33
|
+
export function usePresenceGroup(values, keyOf, options) {
|
|
34
|
+
const group = createPresenceGroup(untrack(() => options?.() ?? {}));
|
|
35
|
+
group.sync(untrack(values), keyOf);
|
|
36
|
+
$effect.pre(() => group.sync(values(), keyOf));
|
|
37
|
+
if (options !== undefined)
|
|
38
|
+
$effect(() => group.update(options()));
|
|
39
|
+
$effect(() => () => group.dispose());
|
|
40
|
+
const snapshot = fromStore(group, (entries) => entries);
|
|
41
|
+
let attachments = new Map();
|
|
42
|
+
const entries = $derived.by(() => {
|
|
43
|
+
const next = new Map();
|
|
44
|
+
const items = snapshot.current.map((entry) => {
|
|
45
|
+
const attach = attachments.get(entry.key) ?? ((el) => group.attach(entry.key, el));
|
|
46
|
+
next.set(entry.key, attach);
|
|
47
|
+
return { ...entry, attach };
|
|
48
|
+
});
|
|
49
|
+
attachments = next;
|
|
50
|
+
return items;
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
get entries() {
|
|
54
|
+
return entries;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
// @stable — follows semver.
|
|
3
|
+
import type { GaugeValueFormat, GaugeValueLabelDetails, PrimitiveProgressOptions } 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 `ProgressValue`'s and `ProgressIndicator`'s snippets receive. */
|
|
9
|
+
export type ProgressPartState = GaugePartState;
|
|
10
|
+
|
|
11
|
+
/** Props for `Progress`. */
|
|
12
|
+
export interface ProgressProps
|
|
13
|
+
extends PrimitiveProps<
|
|
14
|
+
PrimitiveProgressOptions,
|
|
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 `Progress` on the headless path: the primitive owns
|
|
31
|
+
// the range, the clamp and the ARIA; Svelte owns the elements: label, then
|
|
32
|
+
// track with the bar inside it, then the readout. With children the root
|
|
33
|
+
// renders only them, and `ProgressLabel`, `ProgressTrack`,
|
|
34
|
+
// `ProgressIndicator` and `ProgressValue` place the pieces.
|
|
35
|
+
import { progressPrimitive } from "@bevelo/core";
|
|
36
|
+
import { usePrimitive, partProps, splitOptions } from "./headless.svelte.js";
|
|
37
|
+
import { resolveGaugeText, setGauge } from "./gauge-context.js";
|
|
38
|
+
|
|
39
|
+
let { format, locale, getValueLabel, children, ...rest }: ProgressProps = $props();
|
|
40
|
+
|
|
41
|
+
const split = $derived(splitOptions(progressPrimitive, rest));
|
|
42
|
+
const valueText = $derived(
|
|
43
|
+
resolveGaugeText(split.options.value, {
|
|
44
|
+
min: split.options.min,
|
|
45
|
+
max: split.options.max,
|
|
46
|
+
valueText: split.options.valueText,
|
|
47
|
+
format,
|
|
48
|
+
locale,
|
|
49
|
+
getValueLabel,
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
const _uid = $props.id();
|
|
53
|
+
const handle = usePrimitive(
|
|
54
|
+
progressPrimitive,
|
|
55
|
+
() => (valueText === undefined ? split.options : { ...split.options, valueText }),
|
|
56
|
+
_uid,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const root = $derived(handle.part("root"));
|
|
60
|
+
const labelPart = $derived(handle.part("label"));
|
|
61
|
+
const track = $derived(handle.part("track"));
|
|
62
|
+
const bar = $derived(handle.part("bar"));
|
|
63
|
+
const valuePart = $derived(handle.part("value"));
|
|
64
|
+
const state = $derived(
|
|
65
|
+
handle.state as { label?: string; shown: string; min: number; max: number; percent: number | undefined },
|
|
66
|
+
);
|
|
67
|
+
const partState = $derived.by((): GaugePartState => {
|
|
68
|
+
const value = split.options.value;
|
|
69
|
+
return {
|
|
70
|
+
value,
|
|
71
|
+
min: state.min,
|
|
72
|
+
max: state.max,
|
|
73
|
+
percent: state.percent,
|
|
74
|
+
text: state.shown,
|
|
75
|
+
status: value === undefined ? "indeterminate" : value >= state.max ? "complete" : "progress",
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
setGauge({
|
|
79
|
+
handle,
|
|
80
|
+
get state() {
|
|
81
|
+
return partState;
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
{#if root}
|
|
87
|
+
{#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}{#if valuePart}<svelte:element this={valuePart.tag} {...partProps(valuePart)}>{state.shown ?? ""}</svelte:element>{/if}</svelte:element>{/if}
|
|
88
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GaugeValueFormat, GaugeValueLabelDetails, PrimitiveProgressOptions } 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 `ProgressValue`'s and `ProgressIndicator`'s snippets receive. */
|
|
6
|
+
export type ProgressPartState = GaugePartState;
|
|
7
|
+
/** Props for `Progress`. */
|
|
8
|
+
export interface ProgressProps extends PrimitiveProps<PrimitiveProgressOptions, {
|
|
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 Progress: import("svelte").Component<ProgressProps, {}, "">;
|
|
20
|
+
type Progress = ReturnType<typeof Progress>;
|
|
21
|
+
export default Progress;
|
package/dist/props.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PrimitiveInput, PrimitiveOptions } from "@bevelo/core";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
/**
|
|
4
|
+
* The props of a primitive-backed component: every option of the primitive, the
|
|
5
|
+
* component's own `Own` props (which replace an option of the same name), and
|
|
6
|
+
* the HTML attributes of the element the remaining props spread onto.
|
|
7
|
+
*/
|
|
8
|
+
export type PrimitiveProps<Options extends PrimitiveOptions, Own extends object = object, Root extends EventTarget = HTMLElement> = Own & Omit<PrimitiveInput<Options>, keyof Own> & Omit<HTMLAttributes<Root>, keyof Options | keyof Own>;
|
package/dist/props.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Props types shared by the Svelte components. Each component declares and
|
|
2
|
+
// exports its own props interface in its module script, built from the
|
|
3
|
+
// primitive's options with `PrimitiveProps`, and the package root re-exports
|
|
4
|
+
// every one of them.
|
|
5
|
+
//
|
|
6
|
+
// @stable — follows semver.
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { QueryClient } from "@bevelo/query";
|
|
2
|
+
import type { FetchPhase, InfiniteQuerySpec, InfiniteSnapshot, MutateCallOptions, MutationFilter, MutationSpec, MutationStatus, PageData, QueryFilter, QueryKey, QueryRefetchOptions, QuerySnapshot, QuerySpec, QueryStatus } from "@bevelo/query";
|
|
3
|
+
/** Provides a `QueryClient` through Svelte context. */
|
|
4
|
+
export declare function setQueryClient(client: QueryClient): void;
|
|
5
|
+
/** Reads the `QueryClient` from Svelte context. */
|
|
6
|
+
export declare function getQueryClient(explicitClient?: QueryClient): QueryClient;
|
|
7
|
+
export interface SvelteQueryResult<TData, TError> {
|
|
8
|
+
readonly data: TData | undefined;
|
|
9
|
+
readonly error: TError | null;
|
|
10
|
+
readonly status: QueryStatus;
|
|
11
|
+
readonly fetchPhase: FetchPhase;
|
|
12
|
+
readonly isPending: boolean;
|
|
13
|
+
readonly isLoading: boolean;
|
|
14
|
+
readonly isError: boolean;
|
|
15
|
+
readonly isSuccess: boolean;
|
|
16
|
+
readonly isFetching: boolean;
|
|
17
|
+
readonly isPaused: boolean;
|
|
18
|
+
readonly isStale: boolean;
|
|
19
|
+
readonly isPlaceholderData: boolean;
|
|
20
|
+
readonly failureCount: number;
|
|
21
|
+
refetch(options?: QueryRefetchOptions): Promise<QuerySnapshot<TData, TError>>;
|
|
22
|
+
}
|
|
23
|
+
/** Rune-based reactive query helper in Svelte 5. */
|
|
24
|
+
export declare function createQuery<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: () => QuerySpec<TQueryFnData, TError, TData, TQueryKey>, explicitClient?: QueryClient): SvelteQueryResult<TData, TError>;
|
|
25
|
+
export interface SvelteInfiniteQueryResult<TPage, TParam, TError> extends Omit<SvelteQueryResult<PageData<TPage, TParam>, TError>, "refetch"> {
|
|
26
|
+
readonly hasNextPage: boolean;
|
|
27
|
+
readonly hasPreviousPage: boolean;
|
|
28
|
+
readonly isFetchingNextPage: boolean;
|
|
29
|
+
readonly isFetchingPreviousPage: boolean;
|
|
30
|
+
fetchNextPage(options?: QueryRefetchOptions): Promise<InfiniteSnapshot<TPage, TParam, TError>>;
|
|
31
|
+
fetchPreviousPage(options?: QueryRefetchOptions): Promise<InfiniteSnapshot<TPage, TParam, TError>>;
|
|
32
|
+
refetch(options?: QueryRefetchOptions): Promise<InfiniteSnapshot<TPage, TParam, TError>>;
|
|
33
|
+
}
|
|
34
|
+
/** Rune-based infinite query helper in Svelte 5. */
|
|
35
|
+
export declare function createInfiniteQuery<TQueryFnData = unknown, TError = Error, TData = PageData<TQueryFnData, unknown>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: () => InfiniteQuerySpec<TQueryFnData, TError, TData, TQueryKey, TPageParam>, explicitClient?: QueryClient): SvelteInfiniteQueryResult<TQueryFnData, TPageParam, TError>;
|
|
36
|
+
/** Watches multiple parallel queries using Svelte 5 runes. */
|
|
37
|
+
export declare function createQueries<TCombined = readonly QuerySnapshot<unknown, unknown>[]>(options: () => {
|
|
38
|
+
readonly queries: readonly QuerySpec<unknown, unknown, unknown, QueryKey>[];
|
|
39
|
+
readonly combine?: ((results: readonly QuerySnapshot<unknown, unknown>[]) => TCombined) | undefined;
|
|
40
|
+
}, explicitClient?: QueryClient): {
|
|
41
|
+
readonly current: TCombined;
|
|
42
|
+
};
|
|
43
|
+
export interface SvelteMutationResult<TData, TError, TVariables, TContext> {
|
|
44
|
+
readonly data: TData | undefined;
|
|
45
|
+
readonly error: TError | null;
|
|
46
|
+
readonly status: MutationStatus;
|
|
47
|
+
readonly isIdle: boolean;
|
|
48
|
+
readonly isPending: boolean;
|
|
49
|
+
readonly isError: boolean;
|
|
50
|
+
readonly isSuccess: boolean;
|
|
51
|
+
readonly variables: TVariables | undefined;
|
|
52
|
+
mutate(variables: TVariables, options?: MutateCallOptions<TData, TError, TVariables, TContext>): void;
|
|
53
|
+
mutateAsync(variables: TVariables, options?: MutateCallOptions<TData, TError, TVariables, TContext>): Promise<TData>;
|
|
54
|
+
reset(): void;
|
|
55
|
+
}
|
|
56
|
+
/** Rune-based mutation helper in Svelte 5. */
|
|
57
|
+
export declare function createMutation<TData = unknown, TError = Error, TVariables = void, TContext = unknown>(options: () => MutationSpec<TData, TError, TVariables, TContext>, explicitClient?: QueryClient): SvelteMutationResult<TData, TError, TVariables, TContext>;
|
|
58
|
+
/** Reactive counter of active queries matching `filters`. */
|
|
59
|
+
export declare function useIsFetching(filters?: () => QueryFilter | undefined, explicitClient?: QueryClient): {
|
|
60
|
+
readonly current: number;
|
|
61
|
+
};
|
|
62
|
+
/** Reactive counter of active mutations matching `filters`. */
|
|
63
|
+
export declare function useIsMutating(filters?: () => MutationFilter | undefined, explicitClient?: QueryClient): {
|
|
64
|
+
readonly current: number;
|
|
65
|
+
};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Svelte 5 rune helpers over `@bevelo/query`, bridged with `$state.raw` and `$effect`.
|
|
2
|
+
// @experimental
|
|
3
|
+
import { getContext, setContext, untrack } from "svelte";
|
|
4
|
+
import { QueryClient, createInfiniteWatcher, createMutationWatcher, createQueriesWatcher, createQueryWatcher, } from "@bevelo/query";
|
|
5
|
+
import { fromStore } from "./engine-state.svelte.js";
|
|
6
|
+
const SVELTE_QUERY_CLIENT = Symbol("bevelo.svelte.queryClient");
|
|
7
|
+
/** Provides a `QueryClient` through Svelte context. */
|
|
8
|
+
export function setQueryClient(client) {
|
|
9
|
+
setContext(SVELTE_QUERY_CLIENT, client);
|
|
10
|
+
$effect(() => {
|
|
11
|
+
client.mount();
|
|
12
|
+
return () => client.unmount();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Reads the `QueryClient` from Svelte context. */
|
|
16
|
+
export function getQueryClient(explicitClient) {
|
|
17
|
+
const client = explicitClient ?? getContext(SVELTE_QUERY_CLIENT);
|
|
18
|
+
if (!client) {
|
|
19
|
+
throw new Error("No QueryClient set in Svelte context; call setQueryClient(client)");
|
|
20
|
+
}
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
23
|
+
/** Rune-based reactive query helper in Svelte 5. */
|
|
24
|
+
export function createQuery(options, explicitClient) {
|
|
25
|
+
const client = getQueryClient(explicitClient);
|
|
26
|
+
const watcher = createQueryWatcher(client, untrack(options));
|
|
27
|
+
$effect(() => watcher.update(options()));
|
|
28
|
+
$effect(() => () => watcher.dispose());
|
|
29
|
+
const snapshot = fromStore(watcher, (s) => s);
|
|
30
|
+
return {
|
|
31
|
+
get data() {
|
|
32
|
+
return snapshot.current.data;
|
|
33
|
+
},
|
|
34
|
+
get error() {
|
|
35
|
+
return snapshot.current.error;
|
|
36
|
+
},
|
|
37
|
+
get status() {
|
|
38
|
+
return snapshot.current.status;
|
|
39
|
+
},
|
|
40
|
+
get fetchPhase() {
|
|
41
|
+
return snapshot.current.fetchPhase;
|
|
42
|
+
},
|
|
43
|
+
get isPending() {
|
|
44
|
+
return snapshot.current.isPending;
|
|
45
|
+
},
|
|
46
|
+
get isLoading() {
|
|
47
|
+
return snapshot.current.isLoading;
|
|
48
|
+
},
|
|
49
|
+
get isError() {
|
|
50
|
+
return snapshot.current.isError;
|
|
51
|
+
},
|
|
52
|
+
get isSuccess() {
|
|
53
|
+
return snapshot.current.isSuccess;
|
|
54
|
+
},
|
|
55
|
+
get isFetching() {
|
|
56
|
+
return snapshot.current.isFetching;
|
|
57
|
+
},
|
|
58
|
+
get isPaused() {
|
|
59
|
+
return snapshot.current.isPaused;
|
|
60
|
+
},
|
|
61
|
+
get isStale() {
|
|
62
|
+
return snapshot.current.isStale;
|
|
63
|
+
},
|
|
64
|
+
get isPlaceholderData() {
|
|
65
|
+
return snapshot.current.isPlaceholderData;
|
|
66
|
+
},
|
|
67
|
+
get failureCount() {
|
|
68
|
+
return snapshot.current.failureCount;
|
|
69
|
+
},
|
|
70
|
+
refetch: watcher.refetch,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Rune-based infinite query helper in Svelte 5. */
|
|
74
|
+
export function createInfiniteQuery(options, explicitClient) {
|
|
75
|
+
const client = getQueryClient(explicitClient);
|
|
76
|
+
const watcher = createInfiniteWatcher(client, untrack(options));
|
|
77
|
+
$effect(() => watcher.update(options()));
|
|
78
|
+
$effect(() => () => watcher.dispose());
|
|
79
|
+
const snapshot = fromStore(watcher, (s) => s);
|
|
80
|
+
return {
|
|
81
|
+
get data() {
|
|
82
|
+
return snapshot.current.data;
|
|
83
|
+
},
|
|
84
|
+
get error() {
|
|
85
|
+
return snapshot.current.error;
|
|
86
|
+
},
|
|
87
|
+
get status() {
|
|
88
|
+
return snapshot.current.status;
|
|
89
|
+
},
|
|
90
|
+
get fetchPhase() {
|
|
91
|
+
return snapshot.current.fetchPhase;
|
|
92
|
+
},
|
|
93
|
+
get isPending() {
|
|
94
|
+
return snapshot.current.isPending;
|
|
95
|
+
},
|
|
96
|
+
get isLoading() {
|
|
97
|
+
return snapshot.current.isLoading;
|
|
98
|
+
},
|
|
99
|
+
get isError() {
|
|
100
|
+
return snapshot.current.isError;
|
|
101
|
+
},
|
|
102
|
+
get isSuccess() {
|
|
103
|
+
return snapshot.current.isSuccess;
|
|
104
|
+
},
|
|
105
|
+
get isFetching() {
|
|
106
|
+
return snapshot.current.isFetching;
|
|
107
|
+
},
|
|
108
|
+
get isPaused() {
|
|
109
|
+
return snapshot.current.isPaused;
|
|
110
|
+
},
|
|
111
|
+
get isStale() {
|
|
112
|
+
return snapshot.current.isStale;
|
|
113
|
+
},
|
|
114
|
+
get isPlaceholderData() {
|
|
115
|
+
return snapshot.current.isPlaceholderData;
|
|
116
|
+
},
|
|
117
|
+
get failureCount() {
|
|
118
|
+
return snapshot.current.failureCount;
|
|
119
|
+
},
|
|
120
|
+
get hasNextPage() {
|
|
121
|
+
return snapshot.current.hasNextPage;
|
|
122
|
+
},
|
|
123
|
+
get hasPreviousPage() {
|
|
124
|
+
return snapshot.current.hasPreviousPage;
|
|
125
|
+
},
|
|
126
|
+
get isFetchingNextPage() {
|
|
127
|
+
return snapshot.current.isFetchingNextPage;
|
|
128
|
+
},
|
|
129
|
+
get isFetchingPreviousPage() {
|
|
130
|
+
return snapshot.current.isFetchingPreviousPage;
|
|
131
|
+
},
|
|
132
|
+
fetchNextPage: watcher.fetchNextPage,
|
|
133
|
+
fetchPreviousPage: watcher.fetchPreviousPage,
|
|
134
|
+
refetch: watcher.refetch,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** Watches multiple parallel queries using Svelte 5 runes. */
|
|
138
|
+
export function createQueries(options, explicitClient) {
|
|
139
|
+
const client = getQueryClient(explicitClient);
|
|
140
|
+
const initial = untrack(options);
|
|
141
|
+
const watcher = createQueriesWatcher(client, initial.queries, initial.combine);
|
|
142
|
+
$effect(() => {
|
|
143
|
+
const next = options();
|
|
144
|
+
watcher.update(next.queries, next.combine);
|
|
145
|
+
});
|
|
146
|
+
$effect(() => () => watcher.dispose());
|
|
147
|
+
return fromStore(watcher, (s) => s);
|
|
148
|
+
}
|
|
149
|
+
/** Rune-based mutation helper in Svelte 5. */
|
|
150
|
+
export function createMutation(options, explicitClient) {
|
|
151
|
+
const client = getQueryClient(explicitClient);
|
|
152
|
+
const watcher = createMutationWatcher(client, untrack(options));
|
|
153
|
+
$effect(() => watcher.update(options()));
|
|
154
|
+
$effect(() => () => watcher.dispose());
|
|
155
|
+
const snapshot = fromStore(watcher, (s) => s);
|
|
156
|
+
return {
|
|
157
|
+
get data() {
|
|
158
|
+
return snapshot.current.data;
|
|
159
|
+
},
|
|
160
|
+
get error() {
|
|
161
|
+
return snapshot.current.error;
|
|
162
|
+
},
|
|
163
|
+
get status() {
|
|
164
|
+
return snapshot.current.status;
|
|
165
|
+
},
|
|
166
|
+
get isIdle() {
|
|
167
|
+
return snapshot.current.isIdle;
|
|
168
|
+
},
|
|
169
|
+
get isPending() {
|
|
170
|
+
return snapshot.current.isPending;
|
|
171
|
+
},
|
|
172
|
+
get isError() {
|
|
173
|
+
return snapshot.current.isError;
|
|
174
|
+
},
|
|
175
|
+
get isSuccess() {
|
|
176
|
+
return snapshot.current.isSuccess;
|
|
177
|
+
},
|
|
178
|
+
get variables() {
|
|
179
|
+
return snapshot.current.variables;
|
|
180
|
+
},
|
|
181
|
+
mutate: watcher.mutate,
|
|
182
|
+
mutateAsync: watcher.mutateAsync,
|
|
183
|
+
reset: watcher.reset,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** Reactive counter of active queries matching `filters`. */
|
|
187
|
+
export function useIsFetching(filters, explicitClient) {
|
|
188
|
+
const client = getQueryClient(explicitClient);
|
|
189
|
+
let count = $state(client.isFetching(filters ? untrack(filters) : undefined));
|
|
190
|
+
$effect(() => {
|
|
191
|
+
const sync = () => {
|
|
192
|
+
count = client.isFetching(filters?.());
|
|
193
|
+
};
|
|
194
|
+
sync();
|
|
195
|
+
return client.getQueryCache().subscribe(sync);
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
get current() {
|
|
199
|
+
return count;
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** Reactive counter of active mutations matching `filters`. */
|
|
204
|
+
export function useIsMutating(filters, explicitClient) {
|
|
205
|
+
const client = getQueryClient(explicitClient);
|
|
206
|
+
let count = $state(client.isMutating(filters ? untrack(filters) : undefined));
|
|
207
|
+
$effect(() => {
|
|
208
|
+
const sync = () => {
|
|
209
|
+
count = client.isMutating(filters?.());
|
|
210
|
+
};
|
|
211
|
+
sync();
|
|
212
|
+
return client.getMutationCache().subscribe(sync);
|
|
213
|
+
});
|
|
214
|
+
return {
|
|
215
|
+
get current() {
|
|
216
|
+
return count;
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|