@ui-sdk/svelte 0.0.0-stage → 0.1.0-beta.10
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 +202 -0
- package/README.md +10 -2
- package/dist/accordion/accordion-header.svelte +24 -0
- package/dist/accordion/accordion-header.svelte.d.ts +10 -0
- package/dist/accordion/accordion-item.svelte +43 -0
- package/dist/accordion/accordion-item.svelte.d.ts +10 -0
- package/dist/accordion/accordion-panel.svelte +33 -0
- package/dist/accordion/accordion-panel.svelte.d.ts +10 -0
- package/dist/accordion/accordion-trigger.svelte +30 -0
- package/dist/accordion/accordion-trigger.svelte.d.ts +10 -0
- package/dist/accordion/accordion.svelte +85 -0
- package/dist/accordion/accordion.svelte.d.ts +33 -0
- package/dist/accordion/context.d.ts +4 -0
- package/dist/accordion/context.js +11 -0
- package/dist/accordion.d.ts +7 -0
- package/dist/accordion.js +6 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +1 -0
- package/dist/alert-dialog/alert-dialog.svelte +111 -0
- package/dist/alert-dialog/alert-dialog.svelte.d.ts +41 -0
- package/dist/alert-dialog.d.ts +10 -0
- package/dist/alert-dialog.js +10 -0
- package/dist/async-options.d.ts +3 -0
- package/dist/async-options.js +2 -0
- package/dist/async-options.svelte.d.ts +18 -0
- package/dist/async-options.svelte.js +39 -0
- package/dist/autocomplete/autocomplete-arrow.svelte +20 -0
- package/dist/autocomplete/autocomplete-arrow.svelte.d.ts +9 -0
- package/dist/autocomplete/autocomplete-clear.svelte +28 -0
- package/dist/autocomplete/autocomplete-clear.svelte.d.ts +11 -0
- package/dist/autocomplete/autocomplete-content.svelte +105 -0
- package/dist/autocomplete/autocomplete-content.svelte.d.ts +16 -0
- package/dist/autocomplete/autocomplete-empty.svelte +24 -0
- package/dist/autocomplete/autocomplete-empty.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-group-label.svelte +29 -0
- package/dist/autocomplete/autocomplete-group-label.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-group.svelte +22 -0
- package/dist/autocomplete/autocomplete-group.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-input.svelte +44 -0
- package/dist/autocomplete/autocomplete-input.svelte.d.ts +11 -0
- package/dist/autocomplete/autocomplete-item-icon.svelte +25 -0
- package/dist/autocomplete/autocomplete-item-icon.svelte.d.ts +11 -0
- package/dist/autocomplete/autocomplete-item-text.svelte +88 -0
- package/dist/autocomplete/autocomplete-item-text.svelte.d.ts +9 -0
- package/dist/autocomplete/autocomplete-item.svelte +44 -0
- package/dist/autocomplete/autocomplete-item.svelte.d.ts +10 -0
- package/dist/autocomplete/autocomplete-items.svelte +39 -0
- package/dist/autocomplete/autocomplete-items.svelte.d.ts +11 -0
- package/dist/autocomplete/autocomplete-label.svelte +17 -0
- package/dist/autocomplete/autocomplete-label.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-list.svelte +27 -0
- package/dist/autocomplete/autocomplete-list.svelte.d.ts +9 -0
- package/dist/autocomplete/autocomplete-separator.svelte +17 -0
- package/dist/autocomplete/autocomplete-separator.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-status.svelte +20 -0
- package/dist/autocomplete/autocomplete-status.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete-trigger.svelte +20 -0
- package/dist/autocomplete/autocomplete-trigger.svelte.d.ts +8 -0
- package/dist/autocomplete/autocomplete.svelte +200 -0
- package/dist/autocomplete/autocomplete.svelte.d.ts +81 -0
- package/dist/autocomplete/context.d.ts +11 -0
- package/dist/autocomplete/context.js +7 -0
- package/dist/autocomplete.d.ts +19 -0
- package/dist/autocomplete.js +18 -0
- package/dist/avatar/avatar-fallback.svelte +24 -0
- package/dist/avatar/avatar-fallback.svelte.d.ts +10 -0
- package/dist/avatar/avatar-image.svelte +19 -0
- package/dist/avatar/avatar-image.svelte.d.ts +10 -0
- package/dist/avatar/avatar.svelte +46 -0
- package/dist/avatar/avatar.svelte.d.ts +16 -0
- package/dist/avatar.d.ts +4 -0
- package/dist/avatar.js +3 -0
- package/dist/bindable.svelte.d.ts +24 -0
- package/dist/bindable.svelte.js +126 -0
- package/dist/button/button.svelte +55 -0
- package/dist/button/button.svelte.d.ts +20 -0
- package/dist/button.d.ts +2 -0
- package/dist/button.js +1 -0
- package/dist/calendar/calendar-day.svelte +31 -0
- package/dist/calendar/calendar-day.svelte.d.ts +13 -0
- package/dist/calendar/calendar-grid.svelte +53 -0
- package/dist/calendar/calendar-grid.svelte.d.ts +14 -0
- package/dist/calendar/calendar-heading.svelte +23 -0
- package/dist/calendar/calendar-heading.svelte.d.ts +9 -0
- package/dist/calendar/calendar-month-select.svelte +34 -0
- package/dist/calendar/calendar-month-select.svelte.d.ts +9 -0
- package/dist/calendar/calendar-next.svelte +23 -0
- package/dist/calendar/calendar-next.svelte.d.ts +9 -0
- package/dist/calendar/calendar-previous.svelte +23 -0
- package/dist/calendar/calendar-previous.svelte.d.ts +9 -0
- package/dist/calendar/calendar-week.svelte +38 -0
- package/dist/calendar/calendar-week.svelte.d.ts +10 -0
- package/dist/calendar/calendar-weekday.svelte +35 -0
- package/dist/calendar/calendar-weekday.svelte.d.ts +13 -0
- package/dist/calendar/calendar-weekdays.svelte +43 -0
- package/dist/calendar/calendar-weekdays.svelte.d.ts +14 -0
- package/dist/calendar/calendar-weeks.svelte +30 -0
- package/dist/calendar/calendar-weeks.svelte.d.ts +16 -0
- package/dist/calendar/calendar-year-select.svelte +31 -0
- package/dist/calendar/calendar-year-select.svelte.d.ts +9 -0
- package/dist/calendar/calendar.svelte +145 -0
- package/dist/calendar/calendar.svelte.d.ts +16 -0
- package/dist/calendar/context.d.ts +14 -0
- package/dist/calendar/context.js +26 -0
- package/dist/calendar.d.ts +13 -0
- package/dist/calendar.js +12 -0
- package/dist/carousel/carousel-connected.svelte +40 -0
- package/dist/carousel/carousel-connected.svelte.d.ts +20 -0
- package/dist/carousel/carousel-content.svelte +17 -0
- package/dist/carousel/carousel-content.svelte.d.ts +9 -0
- package/dist/carousel/carousel-indicator-binding.svelte +27 -0
- package/dist/carousel/carousel-indicator-binding.svelte.d.ts +9 -0
- package/dist/carousel/carousel-indicator-group.svelte +45 -0
- package/dist/carousel/carousel-indicator-group.svelte.d.ts +10 -0
- package/dist/carousel/carousel-indicator.svelte +36 -0
- package/dist/carousel/carousel-indicator.svelte.d.ts +10 -0
- package/dist/carousel/carousel-item.svelte +18 -0
- package/dist/carousel/carousel-item.svelte.d.ts +9 -0
- package/dist/carousel/carousel-next.svelte +43 -0
- package/dist/carousel/carousel-next.svelte.d.ts +10 -0
- package/dist/carousel/carousel-play-toggle.svelte +44 -0
- package/dist/carousel/carousel-play-toggle.svelte.d.ts +10 -0
- package/dist/carousel/carousel-previous.svelte +44 -0
- package/dist/carousel/carousel-previous.svelte.d.ts +10 -0
- package/dist/carousel/carousel-viewport.svelte +17 -0
- package/dist/carousel/carousel-viewport.svelte.d.ts +9 -0
- package/dist/carousel/carousel.svelte +127 -0
- package/dist/carousel/carousel.svelte.d.ts +48 -0
- package/dist/carousel/context.d.ts +4 -0
- package/dist/carousel/context.js +1 -0
- package/dist/carousel.d.ts +11 -0
- package/dist/carousel.js +10 -0
- package/dist/checkbox/checkbox-group.svelte +100 -0
- package/dist/checkbox/checkbox-group.svelte.d.ts +36 -0
- package/dist/checkbox/checkbox-indicator.svelte +33 -0
- package/dist/checkbox/checkbox-indicator.svelte.d.ts +10 -0
- package/dist/checkbox/checkbox.svelte +96 -0
- package/dist/checkbox/checkbox.svelte.d.ts +24 -0
- package/dist/checkbox/context.d.ts +9 -0
- package/dist/checkbox/context.js +8 -0
- package/dist/checkbox.d.ts +5 -0
- package/dist/checkbox.js +4 -0
- package/dist/collapsible/collapsible-panel.svelte +31 -0
- package/dist/collapsible/collapsible-panel.svelte.d.ts +11 -0
- package/dist/collapsible/collapsible-trigger.svelte +20 -0
- package/dist/collapsible/collapsible-trigger.svelte.d.ts +8 -0
- package/dist/collapsible/collapsible.svelte +73 -0
- package/dist/collapsible/collapsible.svelte.d.ts +27 -0
- package/dist/collapsible.d.ts +5 -0
- package/dist/collapsible.js +4 -0
- package/dist/color-picker/color-picker-area-canvas.svelte +27 -0
- package/dist/color-picker/color-picker-area-canvas.svelte.d.ts +11 -0
- package/dist/color-picker/color-picker-area-thumb.svelte +30 -0
- package/dist/color-picker/color-picker-area-thumb.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-area.svelte +29 -0
- package/dist/color-picker/color-picker-area.svelte.d.ts +11 -0
- package/dist/color-picker/color-picker-channel-input.svelte +26 -0
- package/dist/color-picker/color-picker-channel-input.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-eye-dropper.svelte +18 -0
- package/dist/color-picker/color-picker-eye-dropper.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-input.svelte +18 -0
- package/dist/color-picker/color-picker-input.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-slider-thumb.svelte +32 -0
- package/dist/color-picker/color-picker-slider-thumb.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-slider.svelte +30 -0
- package/dist/color-picker/color-picker-slider.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-swatch-item.svelte +25 -0
- package/dist/color-picker/color-picker-swatch-item.svelte.d.ts +10 -0
- package/dist/color-picker/color-picker-swatch.svelte +17 -0
- package/dist/color-picker/color-picker-swatch.svelte.d.ts +9 -0
- package/dist/color-picker/color-picker-swatches.svelte +17 -0
- package/dist/color-picker/color-picker-swatches.svelte.d.ts +9 -0
- package/dist/color-picker/color-picker.svelte +118 -0
- package/dist/color-picker/color-picker.svelte.d.ts +39 -0
- package/dist/color-picker/context.d.ts +13 -0
- package/dist/color-picker/context.js +9 -0
- package/dist/color-picker.d.ts +14 -0
- package/dist/color-picker.js +13 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +1 -0
- package/dist/combobox/combobox-arrow.svelte +17 -0
- package/dist/combobox/combobox-arrow.svelte.d.ts +9 -0
- package/dist/combobox/combobox-chip-remove.svelte +32 -0
- package/dist/combobox/combobox-chip-remove.svelte.d.ts +9 -0
- package/dist/combobox/combobox-chip.svelte +36 -0
- package/dist/combobox/combobox-chip.svelte.d.ts +10 -0
- package/dist/combobox/combobox-chips-overflow.svelte +31 -0
- package/dist/combobox/combobox-chips-overflow.svelte.d.ts +10 -0
- package/dist/combobox/combobox-chips.svelte +20 -0
- package/dist/combobox/combobox-chips.svelte.d.ts +8 -0
- package/dist/combobox/combobox-clear.svelte +27 -0
- package/dist/combobox/combobox-clear.svelte.d.ts +11 -0
- package/dist/combobox/combobox-content.svelte +105 -0
- package/dist/combobox/combobox-content.svelte.d.ts +16 -0
- package/dist/combobox/combobox-create.svelte +41 -0
- package/dist/combobox/combobox-create.svelte.d.ts +11 -0
- package/dist/combobox/combobox-empty.svelte +21 -0
- package/dist/combobox/combobox-empty.svelte.d.ts +8 -0
- package/dist/combobox/combobox-group-label.svelte +27 -0
- package/dist/combobox/combobox-group-label.svelte.d.ts +8 -0
- package/dist/combobox/combobox-group.svelte +22 -0
- package/dist/combobox/combobox-group.svelte.d.ts +8 -0
- package/dist/combobox/combobox-input.svelte +43 -0
- package/dist/combobox/combobox-input.svelte.d.ts +10 -0
- package/dist/combobox/combobox-item-icon.svelte +30 -0
- package/dist/combobox/combobox-item-icon.svelte.d.ts +12 -0
- package/dist/combobox/combobox-item-indicator.svelte +40 -0
- package/dist/combobox/combobox-item-indicator.svelte.d.ts +10 -0
- package/dist/combobox/combobox-item-text.svelte +85 -0
- package/dist/combobox/combobox-item-text.svelte.d.ts +9 -0
- package/dist/combobox/combobox-item.svelte +45 -0
- package/dist/combobox/combobox-item.svelte.d.ts +10 -0
- package/dist/combobox/combobox-items.svelte +44 -0
- package/dist/combobox/combobox-items.svelte.d.ts +11 -0
- package/dist/combobox/combobox-label.svelte +17 -0
- package/dist/combobox/combobox-label.svelte.d.ts +8 -0
- package/dist/combobox/combobox-list.svelte +26 -0
- package/dist/combobox/combobox-list.svelte.d.ts +9 -0
- package/dist/combobox/combobox-select-all.svelte +29 -0
- package/dist/combobox/combobox-select-all.svelte.d.ts +9 -0
- package/dist/combobox/combobox-separator.svelte +17 -0
- package/dist/combobox/combobox-separator.svelte.d.ts +8 -0
- package/dist/combobox/combobox-status.svelte +17 -0
- package/dist/combobox/combobox-status.svelte.d.ts +8 -0
- package/dist/combobox/combobox-trigger.svelte +17 -0
- package/dist/combobox/combobox-trigger.svelte.d.ts +8 -0
- package/dist/combobox/combobox-value-icon.svelte +23 -0
- package/dist/combobox/combobox-value-icon.svelte.d.ts +9 -0
- package/dist/combobox/combobox-value.svelte +28 -0
- package/dist/combobox/combobox-value.svelte.d.ts +14 -0
- package/dist/combobox/combobox.svelte +287 -0
- package/dist/combobox/combobox.svelte.d.ts +134 -0
- package/dist/combobox/context.d.ts +16 -0
- package/dist/combobox/context.js +8 -0
- package/dist/combobox.d.ts +28 -0
- package/dist/combobox.js +27 -0
- package/dist/command/command-empty.svelte +21 -0
- package/dist/command/command-empty.svelte.d.ts +8 -0
- package/dist/command/command-group-label.svelte +27 -0
- package/dist/command/command-group-label.svelte.d.ts +8 -0
- package/dist/command/command-group.svelte +22 -0
- package/dist/command/command-group.svelte.d.ts +8 -0
- package/dist/command/command-input.svelte +17 -0
- package/dist/command/command-input.svelte.d.ts +9 -0
- package/dist/command/command-item-icon.svelte +24 -0
- package/dist/command/command-item-icon.svelte.d.ts +11 -0
- package/dist/command/command-item-text.svelte +85 -0
- package/dist/command/command-item-text.svelte.d.ts +9 -0
- package/dist/command/command-item.svelte +72 -0
- package/dist/command/command-item.svelte.d.ts +11 -0
- package/dist/command/command-items.svelte +43 -0
- package/dist/command/command-items.svelte.d.ts +11 -0
- package/dist/command/command-list.svelte +42 -0
- package/dist/command/command-list.svelte.d.ts +13 -0
- package/dist/command/command-page.svelte +23 -0
- package/dist/command/command-page.svelte.d.ts +12 -0
- package/dist/command/command-separator.svelte +17 -0
- package/dist/command/command-separator.svelte.d.ts +8 -0
- package/dist/command/command-shortcut.svelte +33 -0
- package/dist/command/command-shortcut.svelte.d.ts +10 -0
- package/dist/command/command-status.svelte +17 -0
- package/dist/command/command-status.svelte.d.ts +8 -0
- package/dist/command/command.svelte +170 -0
- package/dist/command/command.svelte.d.ts +57 -0
- package/dist/command/context.d.ts +13 -0
- package/dist/command/context.js +13 -0
- package/dist/command.d.ts +16 -0
- package/dist/command.js +15 -0
- package/dist/controller-target.svelte.d.ts +15 -0
- package/dist/controller-target.svelte.js +51 -0
- package/dist/create-parts/schema-part.svelte +50 -0
- package/dist/create-parts/schema-part.svelte.d.ts +15 -0
- package/dist/create-parts/schema.svelte.d.ts +43 -0
- package/dist/create-parts/schema.svelte.js +123 -0
- package/dist/create-parts.d.ts +76 -0
- package/dist/create-parts.js +41 -0
- package/dist/date-input/date-input-segment.svelte +20 -0
- package/dist/date-input/date-input-segment.svelte.d.ts +11 -0
- package/dist/date-input/date-input.svelte +34 -0
- package/dist/date-input/date-input.svelte.d.ts +16 -0
- package/dist/date-input/segment.svelte +41 -0
- package/dist/date-input/segment.svelte.d.ts +10 -0
- package/dist/date-input/segmented-input.svelte +113 -0
- package/dist/date-input/segmented-input.svelte.d.ts +17 -0
- package/dist/date-input.d.ts +4 -0
- package/dist/date-input.js +3 -0
- package/dist/date-picker/context.d.ts +14 -0
- package/dist/date-picker/context.js +12 -0
- package/dist/date-picker/date-picker-clear.svelte +17 -0
- package/dist/date-picker/date-picker-clear.svelte.d.ts +9 -0
- package/dist/date-picker/date-picker-content.svelte +103 -0
- package/dist/date-picker/date-picker-content.svelte.d.ts +15 -0
- package/dist/date-picker/date-picker-hint.svelte +23 -0
- package/dist/date-picker/date-picker-hint.svelte.d.ts +9 -0
- package/dist/date-picker/date-picker-input.svelte +41 -0
- package/dist/date-picker/date-picker-input.svelte.d.ts +11 -0
- package/dist/date-picker/date-picker-preset.svelte +33 -0
- package/dist/date-picker/date-picker-preset.svelte.d.ts +13 -0
- package/dist/date-picker/date-picker-trigger.svelte +36 -0
- package/dist/date-picker/date-picker-trigger.svelte.d.ts +9 -0
- package/dist/date-picker/date-picker.svelte +205 -0
- package/dist/date-picker/date-picker.svelte.d.ts +22 -0
- package/dist/date-picker.d.ts +10 -0
- package/dist/date-picker.js +9 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +1 -0
- package/dist/dialog/context.d.ts +22 -0
- package/dist/dialog/context.js +14 -0
- package/dist/dialog/dialog-backdrop.svelte +27 -0
- package/dist/dialog/dialog-backdrop.svelte.d.ts +9 -0
- package/dist/dialog/dialog-close.svelte +28 -0
- package/dist/dialog/dialog-close.svelte.d.ts +11 -0
- package/dist/dialog/dialog-content.svelte +66 -0
- package/dist/dialog/dialog-content.svelte.d.ts +47 -0
- package/dist/dialog/dialog-description.svelte +16 -0
- package/dist/dialog/dialog-description.svelte.d.ts +8 -0
- package/dist/dialog/dialog-shortcut-binding.svelte +28 -0
- package/dist/dialog/dialog-shortcut-binding.svelte.d.ts +9 -0
- package/dist/dialog/dialog-shortcut.svelte +51 -0
- package/dist/dialog/dialog-shortcut.svelte.d.ts +11 -0
- package/dist/dialog/dialog-title.svelte +16 -0
- package/dist/dialog/dialog-title.svelte.d.ts +8 -0
- package/dist/dialog/dialog-trigger-binding.svelte +30 -0
- package/dist/dialog/dialog-trigger-binding.svelte.d.ts +9 -0
- package/dist/dialog/dialog-trigger.svelte +73 -0
- package/dist/dialog/dialog-trigger.svelte.d.ts +14 -0
- package/dist/dialog/dialog.svelte +110 -0
- package/dist/dialog/dialog.svelte.d.ts +44 -0
- package/dist/dialog.d.ts +10 -0
- package/dist/dialog.js +9 -0
- package/dist/drawer/context.d.ts +18 -0
- package/dist/drawer/context.js +14 -0
- package/dist/drawer/drawer-backdrop.svelte +26 -0
- package/dist/drawer/drawer-backdrop.svelte.d.ts +9 -0
- package/dist/drawer/drawer-close.svelte +28 -0
- package/dist/drawer/drawer-close.svelte.d.ts +11 -0
- package/dist/drawer/drawer-content.svelte +61 -0
- package/dist/drawer/drawer-content.svelte.d.ts +42 -0
- package/dist/drawer/drawer-description.svelte +16 -0
- package/dist/drawer/drawer-description.svelte.d.ts +8 -0
- package/dist/drawer/drawer-handle.svelte +17 -0
- package/dist/drawer/drawer-handle.svelte.d.ts +9 -0
- package/dist/drawer/drawer-outlet-binding.svelte +27 -0
- package/dist/drawer/drawer-outlet-binding.svelte.d.ts +9 -0
- package/dist/drawer/drawer-outlet.svelte +40 -0
- package/dist/drawer/drawer-outlet.svelte.d.ts +10 -0
- package/dist/drawer/drawer-shortcut-binding.svelte +28 -0
- package/dist/drawer/drawer-shortcut-binding.svelte.d.ts +9 -0
- package/dist/drawer/drawer-shortcut.svelte +49 -0
- package/dist/drawer/drawer-shortcut.svelte.d.ts +11 -0
- package/dist/drawer/drawer-title.svelte +16 -0
- package/dist/drawer/drawer-title.svelte.d.ts +8 -0
- package/dist/drawer/drawer-trigger-binding.svelte +30 -0
- package/dist/drawer/drawer-trigger-binding.svelte.d.ts +9 -0
- package/dist/drawer/drawer-trigger.svelte +65 -0
- package/dist/drawer/drawer-trigger.svelte.d.ts +12 -0
- package/dist/drawer/drawer.svelte +161 -0
- package/dist/drawer/drawer.svelte.d.ts +67 -0
- package/dist/drawer.d.ts +12 -0
- package/dist/drawer.js +11 -0
- package/dist/editor-context.d.ts +4 -0
- package/dist/editor-context.js +4 -0
- package/dist/field/context.d.ts +30 -0
- package/dist/field/context.js +79 -0
- package/dist/field/field-control.svelte +23 -0
- package/dist/field/field-control.svelte.d.ts +9 -0
- package/dist/field/field-description.svelte +35 -0
- package/dist/field/field-description.svelte.d.ts +10 -0
- package/dist/field/field-error.svelte +37 -0
- package/dist/field/field-error.svelte.d.ts +11 -0
- package/dist/field/field-group.svelte +22 -0
- package/dist/field/field-group.svelte.d.ts +8 -0
- package/dist/field/field-label.svelte +21 -0
- package/dist/field/field-label.svelte.d.ts +10 -0
- package/dist/field/field-legend.svelte +22 -0
- package/dist/field/field-legend.svelte.d.ts +9 -0
- package/dist/field/field-set.svelte +38 -0
- package/dist/field/field-set.svelte.d.ts +15 -0
- package/dist/field/field.svelte +52 -0
- package/dist/field/field.svelte.d.ts +19 -0
- package/dist/field.d.ts +10 -0
- package/dist/field.js +9 -0
- package/dist/file-input/context.d.ts +7 -0
- package/dist/file-input/context.js +16 -0
- package/dist/file-input/file-input-dropzone.svelte +32 -0
- package/dist/file-input/file-input-dropzone.svelte.d.ts +11 -0
- package/dist/file-input/file-input-file-scope.svelte +11 -0
- package/dist/file-input/file-input-file-scope.svelte.d.ts +8 -0
- package/dist/file-input/file-input-item-remove.svelte +33 -0
- package/dist/file-input/file-input-item-remove.svelte.d.ts +14 -0
- package/dist/file-input/file-input-item.svelte +32 -0
- package/dist/file-input/file-input-item.svelte.d.ts +14 -0
- package/dist/file-input/file-input-list.svelte +26 -0
- package/dist/file-input/file-input-list.svelte.d.ts +10 -0
- package/dist/file-input/file-input-trigger-binding.svelte +28 -0
- package/dist/file-input/file-input-trigger-binding.svelte.d.ts +9 -0
- package/dist/file-input/file-input-trigger.svelte +44 -0
- package/dist/file-input/file-input-trigger.svelte.d.ts +11 -0
- package/dist/file-input/file-input.svelte +149 -0
- package/dist/file-input/file-input.svelte.d.ts +52 -0
- package/dist/file-input.d.ts +8 -0
- package/dist/file-input.js +7 -0
- package/dist/gesture.d.ts +1 -0
- package/dist/gesture.js +1 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +1 -0
- package/dist/hover-card/context.d.ts +7 -0
- package/dist/hover-card/context.js +3 -0
- package/dist/hover-card/hover-card-arrow.svelte +17 -0
- package/dist/hover-card/hover-card-arrow.svelte.d.ts +9 -0
- package/dist/hover-card/hover-card-content.svelte +69 -0
- package/dist/hover-card/hover-card-content.svelte.d.ts +48 -0
- package/dist/hover-card/hover-card-trigger-binding.svelte +27 -0
- package/dist/hover-card/hover-card-trigger-binding.svelte.d.ts +9 -0
- package/dist/hover-card/hover-card-trigger.svelte +38 -0
- package/dist/hover-card/hover-card-trigger.svelte.d.ts +10 -0
- package/dist/hover-card/hover-card.svelte +89 -0
- package/dist/hover-card/hover-card.svelte.d.ts +38 -0
- package/dist/hover-card.d.ts +6 -0
- package/dist/hover-card.js +5 -0
- package/dist/image-cropper/image-cropper-flip.svelte +25 -0
- package/dist/image-cropper/image-cropper-flip.svelte.d.ts +10 -0
- package/dist/image-cropper/image-cropper-grid.svelte +20 -0
- package/dist/image-cropper/image-cropper-grid.svelte.d.ts +9 -0
- package/dist/image-cropper/image-cropper-handle.svelte +26 -0
- package/dist/image-cropper/image-cropper-handle.svelte.d.ts +10 -0
- package/dist/image-cropper/image-cropper-image.svelte +20 -0
- package/dist/image-cropper/image-cropper-image.svelte.d.ts +9 -0
- package/dist/image-cropper/image-cropper-rotate.svelte +20 -0
- package/dist/image-cropper/image-cropper-rotate.svelte.d.ts +9 -0
- package/dist/image-cropper/image-cropper-selection.svelte +21 -0
- package/dist/image-cropper/image-cropper-selection.svelte.d.ts +10 -0
- package/dist/image-cropper/image-cropper-viewport.svelte +21 -0
- package/dist/image-cropper/image-cropper-viewport.svelte.d.ts +10 -0
- package/dist/image-cropper/image-cropper-zoom.svelte +20 -0
- package/dist/image-cropper/image-cropper-zoom.svelte.d.ts +9 -0
- package/dist/image-cropper/image-cropper.svelte +111 -0
- package/dist/image-cropper/image-cropper.svelte.d.ts +39 -0
- package/dist/image-cropper.d.ts +11 -0
- package/dist/image-cropper.js +10 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +67 -0
- package/dist/input/context.d.ts +6 -0
- package/dist/input/context.js +10 -0
- package/dist/input/input-clear.svelte +19 -0
- package/dist/input/input-clear.svelte.d.ts +9 -0
- package/dist/input/input-group.svelte +33 -0
- package/dist/input/input-group.svelte.d.ts +11 -0
- package/dist/input/input.svelte +82 -0
- package/dist/input/input.svelte.d.ts +10 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +4 -0
- package/dist/instance.d.ts +18 -0
- package/dist/instance.js +28 -0
- package/dist/item-icon.svelte +37 -0
- package/dist/item-icon.svelte.d.ts +51 -0
- package/dist/label/label.svelte +27 -0
- package/dist/label/label.svelte.d.ts +12 -0
- package/dist/label.d.ts +2 -0
- package/dist/label.js +1 -0
- package/dist/listbox/context.d.ts +6 -0
- package/dist/listbox/context.js +3 -0
- package/dist/listbox/listbox-group-label.svelte +27 -0
- package/dist/listbox/listbox-group-label.svelte.d.ts +8 -0
- package/dist/listbox/listbox-group.svelte +22 -0
- package/dist/listbox/listbox-group.svelte.d.ts +8 -0
- package/dist/listbox/listbox-item-icon.svelte +26 -0
- package/dist/listbox/listbox-item-icon.svelte.d.ts +10 -0
- package/dist/listbox/listbox-item-indicator.svelte +38 -0
- package/dist/listbox/listbox-item-indicator.svelte.d.ts +10 -0
- package/dist/listbox/listbox-item.svelte +40 -0
- package/dist/listbox/listbox-item.svelte.d.ts +10 -0
- package/dist/listbox/listbox-items.svelte +42 -0
- package/dist/listbox/listbox-items.svelte.d.ts +11 -0
- package/dist/listbox/listbox-separator.svelte +17 -0
- package/dist/listbox/listbox-separator.svelte.d.ts +8 -0
- package/dist/listbox/listbox.svelte +165 -0
- package/dist/listbox/listbox.svelte.d.ts +55 -0
- package/dist/listbox.d.ts +10 -0
- package/dist/listbox.js +9 -0
- package/dist/menu/context.d.ts +20 -0
- package/dist/menu/context.js +10 -0
- package/dist/menu/menu-checkbox-item.svelte +59 -0
- package/dist/menu/menu-checkbox-item.svelte.d.ts +10 -0
- package/dist/menu/menu-content.svelte +95 -0
- package/dist/menu/menu-content.svelte.d.ts +51 -0
- package/dist/menu/menu-context-trigger.svelte +54 -0
- package/dist/menu/menu-context-trigger.svelte.d.ts +11 -0
- package/dist/menu/menu-group-label.svelte +28 -0
- package/dist/menu/menu-group-label.svelte.d.ts +8 -0
- package/dist/menu/menu-group.svelte +22 -0
- package/dist/menu/menu-group.svelte.d.ts +8 -0
- package/dist/menu/menu-item-icon.svelte +25 -0
- package/dist/menu/menu-item-icon.svelte.d.ts +11 -0
- package/dist/menu/menu-item-indicator.svelte +44 -0
- package/dist/menu/menu-item-indicator.svelte.d.ts +11 -0
- package/dist/menu/menu-item.svelte +53 -0
- package/dist/menu/menu-item.svelte.d.ts +10 -0
- package/dist/menu/menu-items.svelte +91 -0
- package/dist/menu/menu-items.svelte.d.ts +11 -0
- package/dist/menu/menu-radio-group.svelte +55 -0
- package/dist/menu/menu-radio-group.svelte.d.ts +10 -0
- package/dist/menu/menu-radio-item.svelte +53 -0
- package/dist/menu/menu-radio-item.svelte.d.ts +10 -0
- package/dist/menu/menu-separator.svelte +17 -0
- package/dist/menu/menu-separator.svelte.d.ts +8 -0
- package/dist/menu/menu-shortcut.svelte +17 -0
- package/dist/menu/menu-shortcut.svelte.d.ts +8 -0
- package/dist/menu/menu-sub-trigger.svelte +24 -0
- package/dist/menu/menu-sub-trigger.svelte.d.ts +10 -0
- package/dist/menu/menu-sub.svelte +74 -0
- package/dist/menu/menu-sub.svelte.d.ts +30 -0
- package/dist/menu/menu-trigger-binding.svelte +58 -0
- package/dist/menu/menu-trigger-binding.svelte.d.ts +23 -0
- package/dist/menu/menu-trigger.svelte +60 -0
- package/dist/menu/menu-trigger.svelte.d.ts +10 -0
- package/dist/menu/menu.svelte +148 -0
- package/dist/menu/menu.svelte.d.ts +56 -0
- package/dist/menu.d.ts +20 -0
- package/dist/menu.js +20 -0
- package/dist/menubar/menubar.svelte +60 -0
- package/dist/menubar/menubar.svelte.d.ts +24 -0
- package/dist/menubar-context.d.ts +5 -0
- package/dist/menubar-context.js +4 -0
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.js +2 -0
- package/dist/meter/meter-indicator.svelte +17 -0
- package/dist/meter/meter-indicator.svelte.d.ts +9 -0
- package/dist/meter/meter-label.svelte +17 -0
- package/dist/meter/meter-label.svelte.d.ts +9 -0
- package/dist/meter/meter-track.svelte +17 -0
- package/dist/meter/meter-track.svelte.d.ts +9 -0
- package/dist/meter/meter-value.svelte +19 -0
- package/dist/meter/meter-value.svelte.d.ts +9 -0
- package/dist/meter/meter.svelte +62 -0
- package/dist/meter/meter.svelte.d.ts +25 -0
- package/dist/meter.d.ts +6 -0
- package/dist/meter.js +5 -0
- package/dist/native-input.svelte +33 -0
- package/dist/native-input.svelte.d.ts +35 -0
- package/dist/navigation-menu/context.d.ts +10 -0
- package/dist/navigation-menu/context.js +14 -0
- package/dist/navigation-menu/navigation-menu-content.svelte +78 -0
- package/dist/navigation-menu/navigation-menu-content.svelte.d.ts +11 -0
- package/dist/navigation-menu/navigation-menu-indicator.svelte +21 -0
- package/dist/navigation-menu/navigation-menu-indicator.svelte.d.ts +10 -0
- package/dist/navigation-menu/navigation-menu-item.svelte +31 -0
- package/dist/navigation-menu/navigation-menu-item.svelte.d.ts +10 -0
- package/dist/navigation-menu/navigation-menu-link-icon.svelte +25 -0
- package/dist/navigation-menu/navigation-menu-link-icon.svelte.d.ts +11 -0
- package/dist/navigation-menu/navigation-menu-link.svelte +31 -0
- package/dist/navigation-menu/navigation-menu-link.svelte.d.ts +10 -0
- package/dist/navigation-menu/navigation-menu-list.svelte +20 -0
- package/dist/navigation-menu/navigation-menu-list.svelte.d.ts +9 -0
- package/dist/navigation-menu/navigation-menu-trigger.svelte +30 -0
- package/dist/navigation-menu/navigation-menu-trigger.svelte.d.ts +10 -0
- package/dist/navigation-menu/navigation-menu-viewport.svelte +52 -0
- package/dist/navigation-menu/navigation-menu-viewport.svelte.d.ts +11 -0
- package/dist/navigation-menu/navigation-menu.svelte +113 -0
- package/dist/navigation-menu/navigation-menu.svelte.d.ts +39 -0
- package/dist/navigation-menu.d.ts +11 -0
- package/dist/navigation-menu.js +10 -0
- package/dist/number-input/context.d.ts +9 -0
- package/dist/number-input/context.js +10 -0
- package/dist/number-input/number-input-control.svelte +26 -0
- package/dist/number-input/number-input-control.svelte.d.ts +9 -0
- package/dist/number-input/number-input-decrement.svelte +28 -0
- package/dist/number-input/number-input-decrement.svelte.d.ts +10 -0
- package/dist/number-input/number-input-group.svelte +17 -0
- package/dist/number-input/number-input-group.svelte.d.ts +9 -0
- package/dist/number-input/number-input-increment.svelte +28 -0
- package/dist/number-input/number-input-increment.svelte.d.ts +10 -0
- package/dist/number-input/number-input-scrub-area-binding.svelte +31 -0
- package/dist/number-input/number-input-scrub-area-binding.svelte.d.ts +9 -0
- package/dist/number-input/number-input-scrub-area-cursor.svelte +31 -0
- package/dist/number-input/number-input-scrub-area-cursor.svelte.d.ts +10 -0
- package/dist/number-input/number-input-scrub-area.svelte +54 -0
- package/dist/number-input/number-input-scrub-area.svelte.d.ts +11 -0
- package/dist/number-input/number-input.svelte +100 -0
- package/dist/number-input/number-input.svelte.d.ts +14 -0
- package/dist/number-input.d.ts +9 -0
- package/dist/number-input.js +8 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +1 -0
- package/dist/observe.d.ts +2 -0
- package/dist/observe.js +1 -0
- package/dist/otp-input/context.d.ts +2 -0
- package/dist/otp-input/context.js +10 -0
- package/dist/otp-input/otp-input-group.svelte +17 -0
- package/dist/otp-input/otp-input-group.svelte.d.ts +9 -0
- package/dist/otp-input/otp-input-separator.svelte +17 -0
- package/dist/otp-input/otp-input-separator.svelte.d.ts +9 -0
- package/dist/otp-input/otp-input-slot.svelte +29 -0
- package/dist/otp-input/otp-input-slot.svelte.d.ts +10 -0
- package/dist/otp-input/otp-input.svelte +116 -0
- package/dist/otp-input/otp-input.svelte.d.ts +14 -0
- package/dist/otp-input.d.ts +6 -0
- package/dist/otp-input.js +5 -0
- package/dist/overlays/hosted-confirm.svelte +36 -0
- package/dist/overlays/hosted-confirm.svelte.d.ts +7 -0
- package/dist/overlays/hosted-toaster.svelte +22 -0
- package/dist/overlays/hosted-toaster.svelte.d.ts +9 -0
- package/dist/overlays/overlay-host.svelte +59 -0
- package/dist/overlays/overlay-host.svelte.d.ts +16 -0
- package/dist/overlays/types.d.ts +13 -0
- package/dist/overlays/types.js +1 -0
- package/dist/overlays.d.ts +4 -0
- package/dist/overlays.js +2 -0
- package/dist/own-part.svelte.d.ts +5 -0
- package/dist/own-part.svelte.js +22 -0
- package/dist/pagination/context.d.ts +8 -0
- package/dist/pagination/context.js +10 -0
- package/dist/pagination/pagination-ellipsis.svelte +26 -0
- package/dist/pagination/pagination-ellipsis.svelte.d.ts +9 -0
- package/dist/pagination/pagination-first.svelte +18 -0
- package/dist/pagination/pagination-first.svelte.d.ts +9 -0
- package/dist/pagination/pagination-item.svelte +16 -0
- package/dist/pagination/pagination-item.svelte.d.ts +8 -0
- package/dist/pagination/pagination-last.svelte +18 -0
- package/dist/pagination/pagination-last.svelte.d.ts +9 -0
- package/dist/pagination/pagination-link.svelte +34 -0
- package/dist/pagination/pagination-link.svelte.d.ts +10 -0
- package/dist/pagination/pagination-list.svelte +17 -0
- package/dist/pagination/pagination-list.svelte.d.ts +9 -0
- package/dist/pagination/pagination-next.svelte +18 -0
- package/dist/pagination/pagination-next.svelte.d.ts +9 -0
- package/dist/pagination/pagination-previous.svelte +18 -0
- package/dist/pagination/pagination-previous.svelte.d.ts +9 -0
- package/dist/pagination/pagination.svelte +103 -0
- package/dist/pagination/pagination.svelte.d.ts +37 -0
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.js +10 -0
- package/dist/part.svelte +45 -0
- package/dist/part.svelte.d.ts +46 -0
- package/dist/password-input/context.d.ts +11 -0
- package/dist/password-input/context.js +10 -0
- package/dist/password-input/password-input-control.svelte +48 -0
- package/dist/password-input/password-input-control.svelte.d.ts +10 -0
- package/dist/password-input/password-input-toggle.svelte +21 -0
- package/dist/password-input/password-input-toggle.svelte.d.ts +10 -0
- package/dist/password-input/password-input.svelte +102 -0
- package/dist/password-input/password-input.svelte.d.ts +15 -0
- package/dist/password-input.d.ts +5 -0
- package/dist/password-input.js +4 -0
- package/dist/popover/context.d.ts +12 -0
- package/dist/popover/context.js +8 -0
- package/dist/popover/popover-arrow.svelte +17 -0
- package/dist/popover/popover-arrow.svelte.d.ts +9 -0
- package/dist/popover/popover-close.svelte +17 -0
- package/dist/popover/popover-close.svelte.d.ts +8 -0
- package/dist/popover/popover-content.svelte +91 -0
- package/dist/popover/popover-content.svelte.d.ts +51 -0
- package/dist/popover/popover-description.svelte +17 -0
- package/dist/popover/popover-description.svelte.d.ts +8 -0
- package/dist/popover/popover-shortcut-binding.svelte +28 -0
- package/dist/popover/popover-shortcut-binding.svelte.d.ts +9 -0
- package/dist/popover/popover-shortcut.svelte +51 -0
- package/dist/popover/popover-shortcut.svelte.d.ts +11 -0
- package/dist/popover/popover-title.svelte +17 -0
- package/dist/popover/popover-title.svelte.d.ts +8 -0
- package/dist/popover/popover-trigger-binding.svelte +30 -0
- package/dist/popover/popover-trigger-binding.svelte.d.ts +9 -0
- package/dist/popover/popover-trigger.svelte +66 -0
- package/dist/popover/popover-trigger.svelte.d.ts +10 -0
- package/dist/popover/popover.svelte +108 -0
- package/dist/popover/popover.svelte.d.ts +46 -0
- package/dist/popover.d.ts +10 -0
- package/dist/popover.js +9 -0
- package/dist/popup.svelte.d.ts +17 -0
- package/dist/popup.svelte.js +62 -0
- package/dist/preferences/preferences.svelte +84 -0
- package/dist/preferences/preferences.svelte.d.ts +20 -0
- package/dist/preferences.d.ts +2 -0
- package/dist/preferences.js +2 -0
- package/dist/preferences.svelte.d.ts +15 -0
- package/dist/preferences.svelte.js +22 -0
- package/dist/primitive.d.ts +4 -0
- package/dist/primitive.js +5 -0
- package/dist/progress/progress-indicator.svelte +17 -0
- package/dist/progress/progress-indicator.svelte.d.ts +9 -0
- package/dist/progress/progress-label.svelte +17 -0
- package/dist/progress/progress-label.svelte.d.ts +9 -0
- package/dist/progress/progress-track.svelte +17 -0
- package/dist/progress/progress-track.svelte.d.ts +9 -0
- package/dist/progress/progress-value.svelte +19 -0
- package/dist/progress/progress-value.svelte.d.ts +9 -0
- package/dist/progress/progress.svelte +62 -0
- package/dist/progress/progress.svelte.d.ts +25 -0
- package/dist/progress.d.ts +6 -0
- package/dist/progress.js +5 -0
- package/dist/radio/context.d.ts +8 -0
- package/dist/radio/context.js +14 -0
- package/dist/radio/radio-group.svelte +99 -0
- package/dist/radio/radio-group.svelte.d.ts +35 -0
- package/dist/radio/radio-indicator.svelte +34 -0
- package/dist/radio/radio-indicator.svelte.d.ts +10 -0
- package/dist/radio/radio.svelte +40 -0
- package/dist/radio/radio.svelte.d.ts +10 -0
- package/dist/radio.d.ts +5 -0
- package/dist/radio.js +4 -0
- package/dist/rating/context.d.ts +7 -0
- package/dist/rating/context.js +10 -0
- package/dist/rating/rating-item-scope.svelte +18 -0
- package/dist/rating/rating-item-scope.svelte.d.ts +9 -0
- package/dist/rating/rating-item.svelte +32 -0
- package/dist/rating/rating-item.svelte.d.ts +10 -0
- package/dist/rating/rating-radio.svelte +13 -0
- package/dist/rating/rating-radio.svelte.d.ts +6 -0
- package/dist/rating/rating.svelte +130 -0
- package/dist/rating/rating.svelte.d.ts +44 -0
- package/dist/rating.d.ts +4 -0
- package/dist/rating.js +3 -0
- package/dist/resizable/resizable-handle.svelte +25 -0
- package/dist/resizable/resizable-handle.svelte.d.ts +10 -0
- package/dist/resizable/resizable-panel.svelte +38 -0
- package/dist/resizable/resizable-panel.svelte.d.ts +11 -0
- package/dist/resizable/resizable.svelte +98 -0
- package/dist/resizable/resizable.svelte.d.ts +35 -0
- package/dist/resizable.d.ts +5 -0
- package/dist/resizable.js +4 -0
- package/dist/scroll-area/context.d.ts +4 -0
- package/dist/scroll-area/context.js +3 -0
- package/dist/scroll-area/scroll-area-content.svelte +17 -0
- package/dist/scroll-area/scroll-area-content.svelte.d.ts +9 -0
- package/dist/scroll-area/scroll-area-corner.svelte +17 -0
- package/dist/scroll-area/scroll-area-corner.svelte.d.ts +8 -0
- package/dist/scroll-area/scroll-area-scroll-to-end.svelte +20 -0
- package/dist/scroll-area/scroll-area-scroll-to-end.svelte.d.ts +9 -0
- package/dist/scroll-area/scroll-area-scrollbar.svelte +31 -0
- package/dist/scroll-area/scroll-area-scrollbar.svelte.d.ts +10 -0
- package/dist/scroll-area/scroll-area-thumb.svelte +28 -0
- package/dist/scroll-area/scroll-area-thumb.svelte.d.ts +9 -0
- package/dist/scroll-area/scroll-area-viewport.svelte +17 -0
- package/dist/scroll-area/scroll-area-viewport.svelte.d.ts +9 -0
- package/dist/scroll-area/scroll-area.svelte +54 -0
- package/dist/scroll-area/scroll-area.svelte.d.ts +21 -0
- package/dist/scroll-area.d.ts +9 -0
- package/dist/scroll-area.js +8 -0
- package/dist/segmented-control/segmented-control-indicator.svelte +21 -0
- package/dist/segmented-control/segmented-control-indicator.svelte.d.ts +10 -0
- package/dist/segmented-control/segmented-control-item.svelte +29 -0
- package/dist/segmented-control/segmented-control-item.svelte.d.ts +10 -0
- package/dist/segmented-control/segmented-control.svelte +103 -0
- package/dist/segmented-control/segmented-control.svelte.d.ts +38 -0
- package/dist/segmented-control.d.ts +5 -0
- package/dist/segmented-control.js +4 -0
- package/dist/select/context.d.ts +14 -0
- package/dist/select/context.js +7 -0
- package/dist/select/select-arrow.svelte +17 -0
- package/dist/select/select-arrow.svelte.d.ts +9 -0
- package/dist/select/select-clear.svelte +26 -0
- package/dist/select/select-clear.svelte.d.ts +10 -0
- package/dist/select/select-content.svelte +102 -0
- package/dist/select/select-content.svelte.d.ts +16 -0
- package/dist/select/select-empty.svelte +21 -0
- package/dist/select/select-empty.svelte.d.ts +8 -0
- package/dist/select/select-group-label.svelte +27 -0
- package/dist/select/select-group-label.svelte.d.ts +8 -0
- package/dist/select/select-group.svelte +22 -0
- package/dist/select/select-group.svelte.d.ts +8 -0
- package/dist/select/select-input.svelte +18 -0
- package/dist/select/select-input.svelte.d.ts +10 -0
- package/dist/select/select-item-icon.svelte +30 -0
- package/dist/select/select-item-icon.svelte.d.ts +12 -0
- package/dist/select/select-item-indicator.svelte +38 -0
- package/dist/select/select-item-indicator.svelte.d.ts +10 -0
- package/dist/select/select-item-text.svelte +85 -0
- package/dist/select/select-item-text.svelte.d.ts +9 -0
- package/dist/select/select-item.svelte +43 -0
- package/dist/select/select-item.svelte.d.ts +10 -0
- package/dist/select/select-items.svelte +39 -0
- package/dist/select/select-items.svelte.d.ts +11 -0
- package/dist/select/select-label.svelte +17 -0
- package/dist/select/select-label.svelte.d.ts +8 -0
- package/dist/select/select-list.svelte +27 -0
- package/dist/select/select-list.svelte.d.ts +10 -0
- package/dist/select/select-select-all.svelte +29 -0
- package/dist/select/select-select-all.svelte.d.ts +9 -0
- package/dist/select/select-separator.svelte +17 -0
- package/dist/select/select-separator.svelte.d.ts +8 -0
- package/dist/select/select-status.svelte +17 -0
- package/dist/select/select-status.svelte.d.ts +8 -0
- package/dist/select/select-trigger-binding.svelte +60 -0
- package/dist/select/select-trigger-binding.svelte.d.ts +10 -0
- package/dist/select/select-trigger.svelte +58 -0
- package/dist/select/select-trigger.svelte.d.ts +10 -0
- package/dist/select/select-value-icon.svelte +23 -0
- package/dist/select/select-value-icon.svelte.d.ts +9 -0
- package/dist/select/select-value.svelte +51 -0
- package/dist/select/select-value.svelte.d.ts +10 -0
- package/dist/select/select.svelte +275 -0
- package/dist/select/select.svelte.d.ts +128 -0
- package/dist/select.d.ts +23 -0
- package/dist/select.js +22 -0
- package/dist/separator/separator.svelte +36 -0
- package/dist/separator/separator.svelte.d.ts +10 -0
- package/dist/separator.d.ts +2 -0
- package/dist/separator.js +1 -0
- package/dist/sheet-header.svelte.d.ts +13 -0
- package/dist/sheet-header.svelte.js +41 -0
- package/dist/shortcuts.d.ts +3 -0
- package/dist/shortcuts.js +2 -0
- package/dist/shortcuts.svelte.d.ts +35 -0
- package/dist/shortcuts.svelte.js +46 -0
- package/dist/slider/context.d.ts +9 -0
- package/dist/slider/context.js +10 -0
- package/dist/slider/slider-control.svelte +17 -0
- package/dist/slider/slider-control.svelte.d.ts +9 -0
- package/dist/slider/slider-indicator.svelte +17 -0
- package/dist/slider/slider-indicator.svelte.d.ts +9 -0
- package/dist/slider/slider-thumb.svelte +50 -0
- package/dist/slider/slider-thumb.svelte.d.ts +11 -0
- package/dist/slider/slider-track.svelte +17 -0
- package/dist/slider/slider-track.svelte.d.ts +9 -0
- package/dist/slider/slider-value.svelte +23 -0
- package/dist/slider/slider-value.svelte.d.ts +9 -0
- package/dist/slider/slider.svelte +149 -0
- package/dist/slider/slider.svelte.d.ts +54 -0
- package/dist/slider.d.ts +8 -0
- package/dist/slider.js +7 -0
- package/dist/switch/context.d.ts +5 -0
- package/dist/switch/context.js +2 -0
- package/dist/switch/switch-thumb.svelte +22 -0
- package/dist/switch/switch-thumb.svelte.d.ts +8 -0
- package/dist/switch/switch.svelte +88 -0
- package/dist/switch/switch.svelte.d.ts +22 -0
- package/dist/switch.d.ts +4 -0
- package/dist/switch.js +3 -0
- package/dist/tabs/tabs-indicator.svelte +17 -0
- package/dist/tabs/tabs-indicator.svelte.d.ts +9 -0
- package/dist/tabs/tabs-list.svelte +17 -0
- package/dist/tabs/tabs-list.svelte.d.ts +9 -0
- package/dist/tabs/tabs-panel.svelte +32 -0
- package/dist/tabs/tabs-panel.svelte.d.ts +10 -0
- package/dist/tabs/tabs-tab-icon.svelte +22 -0
- package/dist/tabs/tabs-tab-icon.svelte.d.ts +11 -0
- package/dist/tabs/tabs-tab.svelte +21 -0
- package/dist/tabs/tabs-tab.svelte.d.ts +10 -0
- package/dist/tabs/tabs.svelte +81 -0
- package/dist/tabs/tabs.svelte.d.ts +31 -0
- package/dist/tabs.d.ts +8 -0
- package/dist/tabs.js +7 -0
- package/dist/text-control.d.ts +72 -0
- package/dist/text-control.js +31 -0
- package/dist/text-match.d.ts +2 -0
- package/dist/text-match.js +1 -0
- package/dist/textarea/textarea.svelte +120 -0
- package/dist/textarea/textarea.svelte.d.ts +21 -0
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.js +2 -0
- package/dist/time-input/time-input-segment.svelte +21 -0
- package/dist/time-input/time-input-segment.svelte.d.ts +11 -0
- package/dist/time-input/time-input.svelte +32 -0
- package/dist/time-input/time-input.svelte.d.ts +16 -0
- package/dist/time-input.d.ts +4 -0
- package/dist/time-input.js +3 -0
- package/dist/timeline/context.d.ts +8 -0
- package/dist/timeline/context.js +12 -0
- package/dist/timeline/timeline-connector.svelte +23 -0
- package/dist/timeline/timeline-connector.svelte.d.ts +9 -0
- package/dist/timeline/timeline-description.svelte +25 -0
- package/dist/timeline/timeline-description.svelte.d.ts +8 -0
- package/dist/timeline/timeline-item.svelte +38 -0
- package/dist/timeline/timeline-item.svelte.d.ts +11 -0
- package/dist/timeline/timeline-marker.svelte +23 -0
- package/dist/timeline/timeline-marker.svelte.d.ts +9 -0
- package/dist/timeline/timeline-time.svelte +23 -0
- package/dist/timeline/timeline-time.svelte.d.ts +9 -0
- package/dist/timeline/timeline-title.svelte +22 -0
- package/dist/timeline/timeline-title.svelte.d.ts +8 -0
- package/dist/timeline/timeline.svelte +60 -0
- package/dist/timeline/timeline.svelte.d.ts +25 -0
- package/dist/timeline.d.ts +9 -0
- package/dist/timeline.js +8 -0
- package/dist/toast/content.svelte +8 -0
- package/dist/toast/content.svelte.d.ts +7 -0
- package/dist/toast/context.d.ts +37 -0
- package/dist/toast/context.js +10 -0
- package/dist/toast/data-toast.svelte +26 -0
- package/dist/toast/data-toast.svelte.d.ts +8 -0
- package/dist/toast/region.svelte +79 -0
- package/dist/toast/region.svelte.d.ts +8 -0
- package/dist/toast/toast-action.svelte +52 -0
- package/dist/toast/toast-action.svelte.d.ts +11 -0
- package/dist/toast/toast-close.svelte +28 -0
- package/dist/toast/toast-close.svelte.d.ts +11 -0
- package/dist/toast/toast-description.svelte +31 -0
- package/dist/toast/toast-description.svelte.d.ts +9 -0
- package/dist/toast/toast-region.svelte +14 -0
- package/dist/toast/toast-region.svelte.d.ts +8 -0
- package/dist/toast/toast-scope.svelte +29 -0
- package/dist/toast/toast-scope.svelte.d.ts +11 -0
- package/dist/toast/toast-title.svelte +28 -0
- package/dist/toast/toast-title.svelte.d.ts +8 -0
- package/dist/toast/toast.svelte +21 -0
- package/dist/toast/toast.svelte.d.ts +9 -0
- package/dist/toast.d.ts +23 -0
- package/dist/toast.js +20 -0
- package/dist/toggle/context.d.ts +9 -0
- package/dist/toggle/context.js +15 -0
- package/dist/toggle/toggle-group.svelte +90 -0
- package/dist/toggle/toggle-group.svelte.d.ts +33 -0
- package/dist/toggle/toggle-icon.svelte +19 -0
- package/dist/toggle/toggle-icon.svelte.d.ts +11 -0
- package/dist/toggle/toggle.svelte +83 -0
- package/dist/toggle/toggle.svelte.d.ts +29 -0
- package/dist/toggle-props.d.ts +18 -0
- package/dist/toggle-props.js +1 -0
- package/dist/toggle.d.ts +5 -0
- package/dist/toggle.js +4 -0
- package/dist/token-input/context.d.ts +3 -0
- package/dist/token-input/context.js +11 -0
- package/dist/token-input/token-input-editor.svelte +51 -0
- package/dist/token-input/token-input-editor.svelte.d.ts +11 -0
- package/dist/token-input/token-input-host.svelte +10 -0
- package/dist/token-input/token-input-host.svelte.d.ts +9 -0
- package/dist/token-input/token-input-token-remove.svelte +20 -0
- package/dist/token-input/token-input-token-remove.svelte.d.ts +8 -0
- package/dist/token-input/token-input-token.svelte +23 -0
- package/dist/token-input/token-input-token.svelte.d.ts +9 -0
- package/dist/token-input/token-input.svelte +221 -0
- package/dist/token-input/token-input.svelte.d.ts +54 -0
- package/dist/token-input.d.ts +6 -0
- package/dist/token-input.js +5 -0
- package/dist/toolbar/context.d.ts +3 -0
- package/dist/toolbar/context.js +10 -0
- package/dist/toolbar/toolbar-button.svelte +34 -0
- package/dist/toolbar/toolbar-button.svelte.d.ts +10 -0
- package/dist/toolbar/toolbar-group.svelte +28 -0
- package/dist/toolbar/toolbar-group.svelte.d.ts +10 -0
- package/dist/toolbar/toolbar-input.svelte +34 -0
- package/dist/toolbar/toolbar-input.svelte.d.ts +10 -0
- package/dist/toolbar/toolbar-link.svelte +25 -0
- package/dist/toolbar/toolbar-link.svelte.d.ts +9 -0
- package/dist/toolbar/toolbar-separator.svelte +17 -0
- package/dist/toolbar/toolbar-separator.svelte.d.ts +9 -0
- package/dist/toolbar/toolbar.svelte +57 -0
- package/dist/toolbar/toolbar.svelte.d.ts +23 -0
- package/dist/toolbar-context.d.ts +11 -0
- package/dist/toolbar-context.js +22 -0
- package/dist/toolbar.d.ts +8 -0
- package/dist/toolbar.js +7 -0
- package/dist/tooltip/context.d.ts +9 -0
- package/dist/tooltip/context.js +6 -0
- package/dist/tooltip/tooltip-arrow.svelte +17 -0
- package/dist/tooltip/tooltip-arrow.svelte.d.ts +9 -0
- package/dist/tooltip/tooltip-content.svelte +66 -0
- package/dist/tooltip/tooltip-content.svelte.d.ts +48 -0
- package/dist/tooltip/tooltip-shortcut-binding.svelte +28 -0
- package/dist/tooltip/tooltip-shortcut-binding.svelte.d.ts +9 -0
- package/dist/tooltip/tooltip-shortcut.svelte +44 -0
- package/dist/tooltip/tooltip-shortcut.svelte.d.ts +10 -0
- package/dist/tooltip/tooltip-trigger-binding.svelte +27 -0
- package/dist/tooltip/tooltip-trigger-binding.svelte.d.ts +9 -0
- package/dist/tooltip/tooltip-trigger.svelte +46 -0
- package/dist/tooltip/tooltip-trigger.svelte.d.ts +10 -0
- package/dist/tooltip/tooltip.svelte +105 -0
- package/dist/tooltip/tooltip.svelte.d.ts +46 -0
- package/dist/tooltip.d.ts +7 -0
- package/dist/tooltip.js +6 -0
- package/dist/tree/context.d.ts +14 -0
- package/dist/tree/context.js +13 -0
- package/dist/tree/tree-group.svelte +36 -0
- package/dist/tree/tree-group.svelte.d.ts +10 -0
- package/dist/tree/tree-item-checkbox.svelte +22 -0
- package/dist/tree/tree-item-checkbox.svelte.d.ts +10 -0
- package/dist/tree/tree-item-indicator.svelte +22 -0
- package/dist/tree/tree-item-indicator.svelte.d.ts +10 -0
- package/dist/tree/tree-item-label.svelte +22 -0
- package/dist/tree/tree-item-label.svelte.d.ts +10 -0
- package/dist/tree/tree-item.svelte +57 -0
- package/dist/tree/tree-item.svelte.d.ts +12 -0
- package/dist/tree/tree-items.svelte +41 -0
- package/dist/tree/tree-items.svelte.d.ts +11 -0
- package/dist/tree/tree.svelte +226 -0
- package/dist/tree/tree.svelte.d.ts +98 -0
- package/dist/tree.d.ts +9 -0
- package/dist/tree.js +8 -0
- package/dist/trigger-menu/context.d.ts +6 -0
- package/dist/trigger-menu/context.js +6 -0
- package/dist/trigger-menu/trigger-menu-content.svelte +84 -0
- package/dist/trigger-menu/trigger-menu-content.svelte.d.ts +16 -0
- package/dist/trigger-menu/trigger-menu-empty.svelte +24 -0
- package/dist/trigger-menu/trigger-menu-empty.svelte.d.ts +9 -0
- package/dist/trigger-menu/trigger-menu-group-label.svelte +26 -0
- package/dist/trigger-menu/trigger-menu-group-label.svelte.d.ts +8 -0
- package/dist/trigger-menu/trigger-menu-group.svelte +22 -0
- package/dist/trigger-menu/trigger-menu-group.svelte.d.ts +8 -0
- package/dist/trigger-menu/trigger-menu-hint.svelte +22 -0
- package/dist/trigger-menu/trigger-menu-hint.svelte.d.ts +9 -0
- package/dist/trigger-menu/trigger-menu-input.svelte +20 -0
- package/dist/trigger-menu/trigger-menu-input.svelte.d.ts +9 -0
- package/dist/trigger-menu/trigger-menu-item-icon.svelte +25 -0
- package/dist/trigger-menu/trigger-menu-item-icon.svelte.d.ts +11 -0
- package/dist/trigger-menu/trigger-menu-item.svelte +41 -0
- package/dist/trigger-menu/trigger-menu-item.svelte.d.ts +10 -0
- package/dist/trigger-menu/trigger-menu-items.svelte +42 -0
- package/dist/trigger-menu/trigger-menu-items.svelte.d.ts +11 -0
- package/dist/trigger-menu/trigger-menu-list.svelte +26 -0
- package/dist/trigger-menu/trigger-menu-list.svelte.d.ts +9 -0
- package/dist/trigger-menu/trigger-menu-separator.svelte +17 -0
- package/dist/trigger-menu/trigger-menu-separator.svelte.d.ts +8 -0
- package/dist/trigger-menu/trigger-menu-status.svelte +20 -0
- package/dist/trigger-menu/trigger-menu-status.svelte.d.ts +9 -0
- package/dist/trigger-menu/trigger-menu.svelte +138 -0
- package/dist/trigger-menu/trigger-menu.svelte.d.ts +58 -0
- package/dist/trigger-menu.d.ts +15 -0
- package/dist/trigger-menu.js +14 -0
- package/dist/use-primitive.svelte.d.ts +124 -0
- package/dist/use-primitive.svelte.js +441 -0
- package/dist/value-icon.svelte +29 -0
- package/dist/value-icon.svelte.d.ts +7 -0
- package/dist/value-input.svelte +17 -0
- package/dist/value-input.svelte.d.ts +8 -0
- package/dist/waterfall/context.d.ts +8 -0
- package/dist/waterfall/context.js +10 -0
- package/dist/waterfall/waterfall-axis.svelte +32 -0
- package/dist/waterfall/waterfall-axis.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-bar.svelte +23 -0
- package/dist/waterfall/waterfall-bar.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-cell.svelte +23 -0
- package/dist/waterfall/waterfall-cell.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-column-header.svelte +17 -0
- package/dist/waterfall/waterfall-column-header.svelte.d.ts +8 -0
- package/dist/waterfall/waterfall-header-row.svelte +17 -0
- package/dist/waterfall/waterfall-header-row.svelte.d.ts +8 -0
- package/dist/waterfall/waterfall-indicator.svelte +23 -0
- package/dist/waterfall/waterfall-indicator.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-mark.svelte +24 -0
- package/dist/waterfall/waterfall-mark.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-row-header.svelte +23 -0
- package/dist/waterfall/waterfall-row-header.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-row.svelte +27 -0
- package/dist/waterfall/waterfall-row.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall-tick.svelte +27 -0
- package/dist/waterfall/waterfall-tick.svelte.d.ts +10 -0
- package/dist/waterfall/waterfall.svelte +150 -0
- package/dist/waterfall/waterfall.svelte.d.ts +41 -0
- package/dist/waterfall.d.ts +13 -0
- package/dist/waterfall.js +12 -0
- package/docs/README.md +89 -0
- package/docs/agents.md +1586 -0
- package/docs/components/accordion.md +1347 -0
- package/docs/components/alert-dialog.md +774 -0
- package/docs/components/autocomplete.md +1853 -0
- package/docs/components/avatar.md +257 -0
- package/docs/components/button.md +407 -0
- package/docs/components/calendar.md +1640 -0
- package/docs/components/carousel.md +1173 -0
- package/docs/components/checkbox.md +984 -0
- package/docs/components/collapsible.md +524 -0
- package/docs/components/color-picker.md +701 -0
- package/docs/components/combobox.md +3422 -0
- package/docs/components/command.md +1465 -0
- package/docs/components/date-input.md +522 -0
- package/docs/components/date-picker.md +1288 -0
- package/docs/components/dialog.md +1411 -0
- package/docs/components/drawer.md +1161 -0
- package/docs/components/field.md +537 -0
- package/docs/components/file-input.md +607 -0
- package/docs/components/hover-card.md +500 -0
- package/docs/components/image-cropper.md +552 -0
- package/docs/components/input.md +295 -0
- package/docs/components/label.md +193 -0
- package/docs/components/listbox.md +1076 -0
- package/docs/components/menu.md +1209 -0
- package/docs/components/menubar.md +427 -0
- package/docs/components/meter.md +305 -0
- package/docs/components/navigation-menu.md +1513 -0
- package/docs/components/number-input.md +996 -0
- package/docs/components/otp-input.md +534 -0
- package/docs/components/pagination.md +612 -0
- package/docs/components/password-input.md +687 -0
- package/docs/components/popover.md +1481 -0
- package/docs/components/preferences.md +208 -0
- package/docs/components/progress.md +408 -0
- package/docs/components/radio.md +774 -0
- package/docs/components/rating.md +407 -0
- package/docs/components/resizable.md +890 -0
- package/docs/components/scroll-area.md +921 -0
- package/docs/components/segmented-control.md +432 -0
- package/docs/components/select.md +2011 -0
- package/docs/components/separator.md +215 -0
- package/docs/components/slider.md +1052 -0
- package/docs/components/switch.md +540 -0
- package/docs/components/tabs.md +914 -0
- package/docs/components/textarea.md +282 -0
- package/docs/components/time-input.md +220 -0
- package/docs/components/timeline.md +652 -0
- package/docs/components/toast.md +1229 -0
- package/docs/components/toggle.md +486 -0
- package/docs/components/token-input.md +948 -0
- package/docs/components/toolbar.md +726 -0
- package/docs/components/tooltip.md +849 -0
- package/docs/components/tree.md +1275 -0
- package/docs/components/trigger-menu.md +1195 -0
- package/docs/components/waterfall.md +704 -0
- package/docs/controllers.md +65 -0
- package/docs/core.md +8105 -0
- package/docs/custom-parts.md +82 -0
- package/docs/first-component.md +75 -0
- package/docs/forms.md +114 -0
- package/docs/installation.md +66 -0
- package/docs/introduction.md +32 -0
- package/docs/lists-and-menus.md +111 -0
- package/docs/llms.txt +1496 -0
- package/docs/parts-and-composition.md +79 -0
- package/docs/popups.md +102 -0
- package/docs/rendering.md +53 -0
- package/docs/server-rendering.md +153 -0
- package/docs/state-and-events.md +163 -0
- package/docs/styling-and-animation.md +170 -0
- package/docs/utilities/async-options.md +336 -0
- package/docs/utilities/shortcuts.md +151 -0
- package/package.json +401 -3
package/docs/llms.txt
ADDED
|
@@ -0,0 +1,1496 @@
|
|
|
1
|
+
# ui-sdk for Svelte
|
|
2
|
+
|
|
3
|
+
> @ui-sdk/svelte renders ui-sdk's framework-free TypeScript core in Svelte. How an interface behaves lives in the core; @ui-sdk/svelte turns each primitive into parts. No styles, no dependencies, no providers, no portals.
|
|
4
|
+
|
|
5
|
+
This file is the context an agent needs to build with @ui-sdk/svelte: how Svelte renders a primitive and the conventions every part shares, then every component with a link to its page. Read the pages of the components you use. It's generated from the docs, for this release.
|
|
6
|
+
|
|
7
|
+
- [Core](./core.md): build a component, compose behaviors, and explore the foundations, from defining a primitive to working with state, the browser and text.
|
|
8
|
+
- [Agents](./agents.md): letting an agent operate a page, and WebMCP.
|
|
9
|
+
|
|
10
|
+
## Introduction
|
|
11
|
+
|
|
12
|
+
These docs cover ui-sdk in Svelte. Using another framework? See React, Vue, Solid or Web Components. To build your own components from behaviors, see [Core](./core.md).
|
|
13
|
+
|
|
14
|
+
`@ui-sdk/svelte` gives you components such as Select, Dialog, and Tabs, built on ui-sdk's behaviors. They handle interactions, focus, and ARIA attributes. You choose their markup and styles.
|
|
15
|
+
|
|
16
|
+
Import the parts you need, put them together in your app, and style them with your own CSS.
|
|
17
|
+
|
|
18
|
+
### Quick Start
|
|
19
|
+
|
|
20
|
+
Copy this prompt into your agent:
|
|
21
|
+
|
|
22
|
+
```text prompt
|
|
23
|
+
Set up ui-sdk in this Svelte project. It needs Svelte 5.33 or newer.
|
|
24
|
+
|
|
25
|
+
1. Install @ui-sdk/svelte and @ui-sdk/core with the project's package manager. If a release-age policy blocks the install, stop and ask me instead of changing it.
|
|
26
|
+
2. Add a note to AGENTS.md, creating it if needed: before using ui-sdk, follow the ui-sdk skill if it's installed, and read node_modules/@ui-sdk/svelte/docs/llms.txt. To build a new component, also search node_modules/@ui-sdk/svelte/docs/core.md by heading, and read rendering.md next to it.
|
|
27
|
+
3. If you support skills, run: npx skills@latest add vercel-labs/ui --skill ui-sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
It installs ui-sdk and points your `AGENTS.md` at the docs that ship with the packages.
|
|
31
|
+
|
|
32
|
+
### Set It Up Yourself
|
|
33
|
+
|
|
34
|
+
- [Installation](./installation.md): Install the packages in your Svelte app.
|
|
35
|
+
- [First Component](./first-component.md): Add and style your first component.
|
|
36
|
+
|
|
37
|
+
### Explore the Components
|
|
38
|
+
|
|
39
|
+
The [Using Components guides](./parts-and-composition.md) cover patterns the components share, such as composing parts, handling state, and styling.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
Start with an app using Svelte 5.33 or newer.
|
|
44
|
+
|
|
45
|
+
### Install the Packages
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @ui-sdk/svelte @ui-sdk/core
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`@ui-sdk/svelte` provides the Svelte components. `@ui-sdk/core` provides their behavior and is a peer dependency. Install both so the components and any helpers you use share one copy of the core.
|
|
52
|
+
|
|
53
|
+
### Import a Component
|
|
54
|
+
|
|
55
|
+
Import each component from its own entry:
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
import { Button } from "@ui-sdk/svelte/button"
|
|
60
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
61
|
+
</script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A Dialog has separate parts for its trigger, content, and title. Import those parts from the same entry:
|
|
65
|
+
|
|
66
|
+
```svelte
|
|
67
|
+
<script lang="ts">
|
|
68
|
+
import {
|
|
69
|
+
Dialog,
|
|
70
|
+
DialogContent,
|
|
71
|
+
DialogTitle,
|
|
72
|
+
DialogTrigger,
|
|
73
|
+
} from "@ui-sdk/svelte/dialog"
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Each [component page](./README.md) lists the parts you can use.
|
|
78
|
+
|
|
79
|
+
### Add Your Styles
|
|
80
|
+
|
|
81
|
+
Components are unstyled, so you style them with your app's CSS or with Tailwind CSS. [Styling and Animation](./styling-and-animation.md) covers both.
|
|
82
|
+
|
|
83
|
+
For a default look to start from, import `@ui-sdk/core/web.css` once. In SvelteKit, import it in the `<script>` of `src/routes/+layout.svelte`. In a Vite app, import it at the top of `main.ts`:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import "@ui-sdk/core/web.css"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
With Tailwind CSS, import it in your global stylesheet instead, after Tailwind. `layer(components)` puts it above Tailwind's base styles, so they don't reset it, and below its utilities, so a class still wins. Declare [the ui-sdk layer](./styling-and-animation.md#the-ui-sdk-layer) above both:
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
@layer ui-sdk;
|
|
93
|
+
|
|
94
|
+
@import "tailwindcss";
|
|
95
|
+
@import "@ui-sdk/core/web.css" layer(components);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can render your first component without setting up a provider or adding a portal root. SvelteKit can render the initial HTML on the server; [Server Rendering](./server-rendering.md) explains how to keep it consistent when the page hydrates.
|
|
99
|
+
|
|
100
|
+
### Right to Left
|
|
101
|
+
|
|
102
|
+
Set `dir="rtl"` on the page or a container. Arrow keys and popup placement follow that direction without a provider. Use logical CSS properties, such as `padding-inline-start`, for your styles.
|
|
103
|
+
|
|
104
|
+
Continue with [First Component](./first-component.md) to add a working toggle to your app.
|
|
105
|
+
|
|
106
|
+
## First Component
|
|
107
|
+
|
|
108
|
+
Let's add a Bookmark toggle. Press it once to turn it on, then again to turn it off.
|
|
109
|
+
|
|
110
|
+
If you haven't installed the packages yet, start with [Installation](./installation.md).
|
|
111
|
+
|
|
112
|
+
### Create the Component
|
|
113
|
+
|
|
114
|
+
Create `bookmark-button.svelte` next to your app component and render a `Toggle`:
|
|
115
|
+
|
|
116
|
+
```svelte title="bookmark-button.svelte"
|
|
117
|
+
<script lang="ts">
|
|
118
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<Toggle>Bookmark</Toggle>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`Toggle` renders a button. It keeps track of its pressed state, handles Enter and Space, and sets `aria-pressed` for screen readers.
|
|
125
|
+
|
|
126
|
+
### Use It in Your App
|
|
127
|
+
|
|
128
|
+
In your app component (`App.svelte` here), import and render `BookmarkButton`:
|
|
129
|
+
|
|
130
|
+
```svelte title="App.svelte"
|
|
131
|
+
<script lang="ts">
|
|
132
|
+
import BookmarkButton from "./bookmark-button.svelte"
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<BookmarkButton />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Open your app. You should see a button labeled Bookmark. Next, add styles so you can tell when it is pressed.
|
|
139
|
+
|
|
140
|
+
### Add Styles
|
|
141
|
+
|
|
142
|
+
When the toggle is pressed, it has a `data-pressed` attribute. Use that attribute to change its appearance.
|
|
143
|
+
|
|
144
|
+
With Tailwind CSS configured in your app, add utility classes to `class`. The `data-pressed:` variant applies while the toggle is pressed:
|
|
145
|
+
|
|
146
|
+
```svelte title="bookmark-button.svelte"
|
|
147
|
+
<script lang="ts">
|
|
148
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<Toggle
|
|
152
|
+
class="inline-flex h-8 items-center rounded-md border border-neutral-300 px-3 text-sm font-medium hover:bg-neutral-100 focus-visible:outline-2 focus-visible:outline-offset-2 data-pressed:bg-neutral-900 data-pressed:text-white"
|
|
153
|
+
>
|
|
154
|
+
Bookmark
|
|
155
|
+
</Toggle>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Try the styled toggle:
|
|
159
|
+
|
|
160
|
+
```svelte title="first-component.svelte"
|
|
161
|
+
<script lang="ts">
|
|
162
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<Toggle data-variant="outline">Bookmark</Toggle>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Click Bookmark to turn it on or off. A filled background means it is on. You can also focus the button with Tab and press Enter or Space.
|
|
169
|
+
|
|
170
|
+
Keep the label the same in both states. `aria-pressed` tells a screen reader whether the toggle is on.
|
|
171
|
+
|
|
172
|
+
### Keep Going
|
|
173
|
+
|
|
174
|
+
- [Toggle](./components/toggle.md) covers disabled states, controlled state, and groups of toggles.
|
|
175
|
+
- [Components](./README.md) lists the other components you can add with the same install.
|
|
176
|
+
- [Parts and Composition](./parts-and-composition.md) shows how to put a component with several parts together.
|
|
177
|
+
- [State and Events](./state-and-events.md) shows how to read changes and control state from your app.
|
|
178
|
+
- [Styling and Animation](./styling-and-animation.md) covers state attributes, CSS variables, and transitions.
|
|
179
|
+
|
|
180
|
+
## Parts and Composition
|
|
181
|
+
|
|
182
|
+
A component can have several parts. A Popover has a root to hold its state, a trigger to open it, and content to show.
|
|
183
|
+
|
|
184
|
+
### Put Parts Together
|
|
185
|
+
|
|
186
|
+
Import the parts you need and nest them as shown in the component's Composition:
|
|
187
|
+
|
|
188
|
+
```svelte
|
|
189
|
+
<script lang="ts">
|
|
190
|
+
import {
|
|
191
|
+
Popover,
|
|
192
|
+
PopoverClose,
|
|
193
|
+
PopoverContent,
|
|
194
|
+
PopoverTitle,
|
|
195
|
+
PopoverTrigger,
|
|
196
|
+
} from "@ui-sdk/svelte/popover"
|
|
197
|
+
</script>
|
|
198
|
+
|
|
199
|
+
<Popover>
|
|
200
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
201
|
+
<PopoverContent>
|
|
202
|
+
<PopoverTitle>Project Details</PopoverTitle>
|
|
203
|
+
<p>Last updated today.</p>
|
|
204
|
+
<PopoverClose>Done</PopoverClose>
|
|
205
|
+
</PopoverContent>
|
|
206
|
+
</Popover>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`Popover` shares state without adding an element. Other roots, such as `Tabs`, do render an element. Parts find their root through the framework's context, so you can put your own components between them.
|
|
210
|
+
|
|
211
|
+
### Choose the Element
|
|
212
|
+
|
|
213
|
+
Render a menu item as a link:
|
|
214
|
+
|
|
215
|
+
```svelte
|
|
216
|
+
<script lang="ts">
|
|
217
|
+
import { Menu, MenuContent, MenuItem, MenuTrigger } from "@ui-sdk/svelte/menu"
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<Menu>
|
|
221
|
+
<MenuTrigger>Account</MenuTrigger>
|
|
222
|
+
<MenuContent>
|
|
223
|
+
<MenuItem>
|
|
224
|
+
{#snippet render({ props })}
|
|
225
|
+
<a {...props} href="/settings">Settings</a>
|
|
226
|
+
{/snippet}
|
|
227
|
+
</MenuItem>
|
|
228
|
+
</MenuContent>
|
|
229
|
+
</Menu>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The `render` snippet receives the part's props and state. Spread the props onto your element, or a component, to keep its behavior connected. It also receives `children`, the part's own content, like a slider thumb's range input: render it inside your element with `{@render children?.(state)}`.
|
|
233
|
+
|
|
234
|
+
Pass event handlers to the component, like `<MenuItem onclick={track}>`, even when you render your own element. Your handler runs first, and calling `event.preventDefault()` skips the built-in one. A handler written on the element inside `render` runs after the built-in one, because Svelte calls handlers written in markup from the root of the page. Keep the supplied roles, IDs, and ARIA state when rendering your own element. A name or typing hint you pass replaces the part's own: `aria-label`, `aria-labelledby`, `aria-description`, `title`, `autocomplete`, `autocapitalize`, `autocorrect`, `inputmode` and `spellcheck`. Roles, `tabindex`, references like `aria-controls` and `aria-describedby`, state attributes and `data-slot` stay the part's, since its behavior reads them.
|
|
235
|
+
|
|
236
|
+
### Read the State
|
|
237
|
+
|
|
238
|
+
The part can pass its state to its content:
|
|
239
|
+
|
|
240
|
+
```svelte
|
|
241
|
+
<script lang="ts">
|
|
242
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
243
|
+
</script>
|
|
244
|
+
|
|
245
|
+
<Toggle aria-label="Mute">
|
|
246
|
+
{#snippet children(state)}{state.pressed ? "Mute on" : "Mute off"}{/snippet}
|
|
247
|
+
</Toggle>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Keep the accessible name stable when the content changes. Here, `aria-label="Mute"` names the toggle and `aria-pressed` reports its state.
|
|
251
|
+
|
|
252
|
+
### Name the Control
|
|
253
|
+
|
|
254
|
+
Use the component's label or title part, such as `FieldLabel` or `DialogTitle`. Give controls without visible text an `aria-label`.
|
|
255
|
+
|
|
256
|
+
[Custom Parts](./custom-parts.md) covers writing a part with logic of its own.
|
|
257
|
+
|
|
258
|
+
## State and Events
|
|
259
|
+
|
|
260
|
+
Components manage their own state until you bind a value. A change callback lets you respond in either case.
|
|
261
|
+
|
|
262
|
+
### Set the Starting Value
|
|
263
|
+
|
|
264
|
+
Use a default prop to choose the starting state. Here, Bold starts pressed and changes when you click it:
|
|
265
|
+
|
|
266
|
+
```svelte
|
|
267
|
+
<script lang="ts">
|
|
268
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
269
|
+
</script>
|
|
270
|
+
|
|
271
|
+
<Toggle defaultPressed>Bold</Toggle>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The prop depends on the component: `defaultPressed`, `defaultChecked`, `defaultOpen`, or `defaultValue`.
|
|
275
|
+
|
|
276
|
+
### Control the Value
|
|
277
|
+
|
|
278
|
+
```svelte
|
|
279
|
+
<script lang="ts">
|
|
280
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
281
|
+
|
|
282
|
+
let pressed = $state(false)
|
|
283
|
+
</script>
|
|
284
|
+
|
|
285
|
+
<Toggle bind:pressed>Bold</Toggle>
|
|
286
|
+
<output>{pressed ? "On" : "Off"}</output>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Clicking Bold updates `pressed`, so the output changes too. Other components bind `open`, `checked`, or `value`.
|
|
290
|
+
|
|
291
|
+
A prop without `bind:` does not write changes back to the parent. The component can still update its local value. Use a binding when the parent should stay in sync.
|
|
292
|
+
|
|
293
|
+
To keep a value in the URL, bind it to `$state` and call `goto` when it changes. A value that changes only when the navigation finishes leaves the component showing the old one until then, and logs a warning in development.
|
|
294
|
+
|
|
295
|
+
#### Decide Which Changes to Accept
|
|
296
|
+
|
|
297
|
+
A function binding lets the parent decide whether to save the next value:
|
|
298
|
+
|
|
299
|
+
```svelte
|
|
300
|
+
<script lang="ts">
|
|
301
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
302
|
+
|
|
303
|
+
let pressed = $state(false)
|
|
304
|
+
let allowChanges = $state(true)
|
|
305
|
+
|
|
306
|
+
function setPressed(next: boolean) {
|
|
307
|
+
if (allowChanges) {
|
|
308
|
+
pressed = next
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
</script>
|
|
312
|
+
|
|
313
|
+
<label
|
|
314
|
+
><input type="checkbox" bind:checked={allowChanges} /> Allow changes</label
|
|
315
|
+
>
|
|
316
|
+
<Toggle bind:pressed={() => pressed, setPressed}>Bold</Toggle>
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Uncheck Allow changes, then press Bold. The setter leaves `pressed` unchanged, so the toggle stays as it was. This also cancels the change request.
|
|
320
|
+
|
|
321
|
+
A bound value may start as `undefined`. Until it has a defined value, the component manages its own state. For example, `let pressed = $state<boolean>()` lets the toggle start from `defaultPressed`; the binding receives its first change, or you can set `pressed` yourself.
|
|
322
|
+
|
|
323
|
+
### Respond to a Change
|
|
324
|
+
|
|
325
|
+
Callbacks such as `onPressedChange` receive the requested value and `details`. They run before a bound value updates.
|
|
326
|
+
|
|
327
|
+
| Detail | What It Tells You |
|
|
328
|
+
| ---------- | ------------------------------------------------------------------------------------------------ |
|
|
329
|
+
| `reason` | What requested the change, such as `press` or `outside-press`. Each component lists its reasons. |
|
|
330
|
+
| `event` | The DOM event, when there is one. |
|
|
331
|
+
| `source` | `keyboard`, `mouse`, `touch`, `pen`, `virtual`, `programmatic`, or `agent`. |
|
|
332
|
+
| `cancel()` | Stops the requested change. |
|
|
333
|
+
|
|
334
|
+
For example, keep a popover open when someone clicks outside it:
|
|
335
|
+
|
|
336
|
+
```svelte
|
|
337
|
+
<script lang="ts">
|
|
338
|
+
import {
|
|
339
|
+
Popover,
|
|
340
|
+
PopoverClose,
|
|
341
|
+
PopoverContent,
|
|
342
|
+
PopoverTitle,
|
|
343
|
+
PopoverTrigger,
|
|
344
|
+
} from "@ui-sdk/svelte/popover"
|
|
345
|
+
|
|
346
|
+
function keepOpen(
|
|
347
|
+
open: boolean,
|
|
348
|
+
details: { reason: string; cancel: () => void }
|
|
349
|
+
) {
|
|
350
|
+
if (!open && details.reason === "outside-press") {
|
|
351
|
+
details.cancel()
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
</script>
|
|
355
|
+
|
|
356
|
+
<Popover onOpenChange={keepOpen}>
|
|
357
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
358
|
+
<PopoverContent>
|
|
359
|
+
<PopoverTitle>Project Details</PopoverTitle>
|
|
360
|
+
<p>Last updated today.</p>
|
|
361
|
+
<PopoverClose>Done</PopoverClose>
|
|
362
|
+
</PopoverContent>
|
|
363
|
+
</Popover>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The Done button still closes it. Cancellation also works when you control the value. Add `debug` to a root to log changes while you work.
|
|
367
|
+
|
|
368
|
+
### Share State Across Components
|
|
369
|
+
|
|
370
|
+
When several components need the same state, create it once in a parent and hand it down through context. A pair of small functions keeps the context key in one place:
|
|
371
|
+
|
|
372
|
+
```ts title="editor.svelte.ts"
|
|
373
|
+
import { getContext, setContext } from "svelte"
|
|
374
|
+
|
|
375
|
+
export class Editor {
|
|
376
|
+
bold = $state(false)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const key = Symbol("editor")
|
|
380
|
+
|
|
381
|
+
export const setEditor = (editor: Editor) => setContext(key, editor)
|
|
382
|
+
export const getEditor = () => getContext<Editor>(key)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Create the state in a component near the top of your app. In SvelteKit, the root layout works well:
|
|
386
|
+
|
|
387
|
+
```svelte title="+layout.svelte"
|
|
388
|
+
<script lang="ts">
|
|
389
|
+
import { Editor, setEditor } from "$lib/editor.svelte"
|
|
390
|
+
|
|
391
|
+
let { children } = $props()
|
|
392
|
+
|
|
393
|
+
setEditor(new Editor())
|
|
394
|
+
</script>
|
|
395
|
+
|
|
396
|
+
{@render children()}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Any component inside it can read and bind the same state:
|
|
400
|
+
|
|
401
|
+
```svelte
|
|
402
|
+
<script lang="ts">
|
|
403
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
404
|
+
import { getEditor } from "$lib/editor.svelte"
|
|
405
|
+
|
|
406
|
+
const editor = getEditor()
|
|
407
|
+
</script>
|
|
408
|
+
|
|
409
|
+
<Toggle bind:pressed={editor.bold}>Bold</Toggle>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Each render of the layout creates its own `Editor`, so on the server every request starts with a fresh copy. A `$state` exported from a module lives as long as the server does, so every visitor would read and change the same copy. Keep shared state in context, and use module state only for values that are the same for everyone.
|
|
413
|
+
|
|
414
|
+
### Empty and Multiple Values
|
|
415
|
+
|
|
416
|
+
Select, Tabs, and Radio Group report `null` when nothing is selected. A multiple Select or Combobox uses an array. Accordion and Toggle Group always use arrays.
|
|
417
|
+
|
|
418
|
+
To change a component from outside its parts, use a [Controller](./controllers.md).
|
|
419
|
+
|
|
420
|
+
## Styling and Animation
|
|
421
|
+
|
|
422
|
+
Parts render without styles. The component demos use plain CSS, and the same state attributes and CSS variables work with Tailwind CSS or any other stylesheet.
|
|
423
|
+
|
|
424
|
+
### Style a Part
|
|
425
|
+
|
|
426
|
+
Every part has a `data-slot` attribute. State adds attributes such as `data-pressed` and `data-disabled`:
|
|
427
|
+
|
|
428
|
+
```svelte
|
|
429
|
+
<script lang="ts">
|
|
430
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
431
|
+
</script>
|
|
432
|
+
|
|
433
|
+
<Toggle
|
|
434
|
+
class="rounded-md border border-neutral-300 px-2.5 py-1.5 text-sm data-pressed:bg-neutral-100 data-disabled:opacity-50"
|
|
435
|
+
>Bold</Toggle
|
|
436
|
+
>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Most state attributes are present or absent. Others have values, such as `data-side="top"`. Each component's Styling section lists its attributes and CSS variables. Use those rather than generated IDs.
|
|
440
|
+
|
|
441
|
+
### CSS Modules
|
|
442
|
+
|
|
443
|
+
Import a CSS Module and pass its class to the part. State selectors work the same way:
|
|
444
|
+
|
|
445
|
+
```svelte
|
|
446
|
+
<script lang="ts">
|
|
447
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
448
|
+
import styles from "./toggle.module.css"
|
|
449
|
+
</script>
|
|
450
|
+
|
|
451
|
+
<Toggle class={styles.toggle}>Bold</Toggle>
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
```css title="toggle.module.css"
|
|
455
|
+
.toggle {
|
|
456
|
+
cursor: default;
|
|
457
|
+
border: 1px solid var(--input, #e5e5e5);
|
|
458
|
+
border-radius: 1.125rem;
|
|
459
|
+
background: transparent;
|
|
460
|
+
padding: 0.375rem 0.625rem;
|
|
461
|
+
color: inherit;
|
|
462
|
+
font: inherit;
|
|
463
|
+
font-size: 0.875rem;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.toggle[data-pressed] {
|
|
467
|
+
background: var(--muted, #f5f5f5);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.toggle[data-disabled] {
|
|
471
|
+
opacity: 0.5;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.toggle:focus-visible {
|
|
475
|
+
outline: 2px solid var(--ring, #a3a3a3);
|
|
476
|
+
outline-offset: 2px;
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
You can also use Svelte's scoped styles. When a selector targets markup inside a component, use `:global`, such as `:global([data-slot="toggle"])`. CSS Modules avoid that scoping boundary.
|
|
481
|
+
|
|
482
|
+
### Animate Opening and Closing
|
|
483
|
+
|
|
484
|
+
Popup content gets `data-starting-style` before it enters and `data-ending-style` while it exits. It stays mounted until the exit transition or animation finishes:
|
|
485
|
+
|
|
486
|
+
```svelte
|
|
487
|
+
<script lang="ts">
|
|
488
|
+
import {
|
|
489
|
+
Popover,
|
|
490
|
+
PopoverClose,
|
|
491
|
+
PopoverContent,
|
|
492
|
+
PopoverTitle,
|
|
493
|
+
PopoverTrigger,
|
|
494
|
+
} from "@ui-sdk/svelte/popover"
|
|
495
|
+
</script>
|
|
496
|
+
|
|
497
|
+
<Popover>
|
|
498
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
499
|
+
<PopoverContent
|
|
500
|
+
class="origin-(--transform-origin) transition-[opacity,scale] duration-150 data-starting-style:scale-96 data-starting-style:opacity-0 data-ending-style:scale-96 data-ending-style:opacity-0 motion-reduce:transition-none"
|
|
501
|
+
>
|
|
502
|
+
<PopoverTitle>Project Details</PopoverTitle>
|
|
503
|
+
<p>Last updated today.</p>
|
|
504
|
+
<PopoverClose>Done</PopoverClose>
|
|
505
|
+
</PopoverContent>
|
|
506
|
+
</Popover>
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
Put exit styles on `data-ending-style`. `data-closed` describes the state but doesn't keep the element around for an exit.
|
|
510
|
+
|
|
511
|
+
An exit animation you start from script is waited for too, when it starts in the same task that closes the popup, like in its open change callback. One started later, from an effect or an observer, isn't.
|
|
512
|
+
|
|
513
|
+
#### Svelte Transitions
|
|
514
|
+
|
|
515
|
+
Svelte's own transitions work too. Put one on the element you render, with `|global`, since the block that adds and removes the element is inside the component. A popup stays visible above the page until its outro ends:
|
|
516
|
+
|
|
517
|
+
```svelte
|
|
518
|
+
<script lang="ts">
|
|
519
|
+
import {
|
|
520
|
+
Popover,
|
|
521
|
+
PopoverContent,
|
|
522
|
+
PopoverTrigger,
|
|
523
|
+
} from "@ui-sdk/svelte/popover"
|
|
524
|
+
import { fade } from "svelte/transition"
|
|
525
|
+
</script>
|
|
526
|
+
|
|
527
|
+
<Popover>
|
|
528
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
529
|
+
<PopoverContent aria-label="Project details">
|
|
530
|
+
{#snippet render({ props })}
|
|
531
|
+
<div {...props} transition:fade|global={{ duration: 150 }}>
|
|
532
|
+
Last updated today.
|
|
533
|
+
</div>
|
|
534
|
+
{/snippet}
|
|
535
|
+
</PopoverContent>
|
|
536
|
+
</Popover>
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Popups provide `--anchor-width` and `--available-height` for sizing. [Popups](./popups.md) covers mounting and placement.
|
|
540
|
+
|
|
541
|
+
### The ui-sdk Layer
|
|
542
|
+
|
|
543
|
+
A few behaviors need a little CSS, like keeping a closed popup hidden or dimming the page behind a sheet, so ui-sdk adds it to the page in a cascade layer named `ui-sdk`. Declare that layer at the top of your global stylesheet, like the `app.css` your root `+layout.svelte` imports, so your own styles win over it wherever the page puts them. With Tailwind, put it above `@import "tailwindcss"`:
|
|
544
|
+
|
|
545
|
+
```css
|
|
546
|
+
@layer ui-sdk;
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
A component's `<style>` block loads with the component, too late to come first, so keep the line in the global stylesheet.
|
|
550
|
+
|
|
551
|
+
ui-sdk adds this CSS once a component mounts, so HTML rendered on the server doesn't have it until the page hydrates. Closed content kept in the page, like a tooltip's, carries `hidden`, and a class that sets `display` shows it until then. Tailwind's base styles already hide `hidden` elements. With other CSS, add the same rule to your global stylesheet:
|
|
552
|
+
|
|
553
|
+
```css
|
|
554
|
+
@layer ui-sdk {
|
|
555
|
+
:where([data-slot][hidden]:not([hidden="until-found"])) {
|
|
556
|
+
display: none !important;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
It leaves `hidden="until-found"` alone, so find in page can still open a closed panel.
|
|
562
|
+
|
|
563
|
+
The same layer takes the browser's own popover border, padding and background off Popover, Dialog, Drawer, Tooltip and Hover Card content. Menu, Select, Combobox and Date Picker content keep them, so give those parts a `border`, `padding` and `background` of your own. `web.css` already does.
|
|
564
|
+
|
|
565
|
+
### Content Security Policy
|
|
566
|
+
|
|
567
|
+
A Content Security Policy without `'unsafe-inline'` in `style-src` blocks the CSS ui-sdk adds. Give ui-sdk your policy's nonce with a meta tag in the page's `<head>`:
|
|
568
|
+
|
|
569
|
+
```html
|
|
570
|
+
<meta property="csp-nonce" nonce="your-nonce" />
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
If your policy has no nonce for styles, add the tag without the `nonce` attribute. ui-sdk then adds its CSS as constructed style sheets, which no policy blocks. If your code replaces `document.adoptedStyleSheets`, ui-sdk adds its sheets back the next time a component mounts.
|
|
574
|
+
|
|
575
|
+
In SvelteKit, put the tag without a nonce in `src/app.html`. It works with any `kit.csp` mode, on prerendered pages too, as long as `@layer ui-sdk;` comes first in your global stylesheet:
|
|
576
|
+
|
|
577
|
+
```html
|
|
578
|
+
<meta property="csp-nonce" />
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
SvelteKit's `nonce="%sveltekit.nonce%"` works only when `style-src` carries that nonce, and SvelteKit adds it there only for CSS it inlines itself, which `kit.inlineStyleThreshold` turns on. The placeholder also stops a page from being prerendered.
|
|
582
|
+
|
|
583
|
+
With Vite alone, set `html.cspNonce` in your Vite config to a placeholder, and Vite writes the tag for you. Your server replaces the placeholder with a new nonce on each request.
|
|
584
|
+
|
|
585
|
+
Keep Svelte's default `css: "external"` under a strict policy, since `css: "injected"` adds each component's styles as a `<style>` without a nonce.
|
|
586
|
+
|
|
587
|
+
Pages rendered on the server also carry a few `style` attributes, like the one that hides a select's native input, so the policy needs `style-src-attr 'unsafe-inline'` too.
|
|
588
|
+
|
|
589
|
+
## Controllers
|
|
590
|
+
|
|
591
|
+
A controller connects code to a mounted component. Use one when the button or action that changes it lives somewhere else.
|
|
592
|
+
|
|
593
|
+
### Connect a Controller
|
|
594
|
+
|
|
595
|
+
Create it once in your component and pass it to the root:
|
|
596
|
+
|
|
597
|
+
```svelte
|
|
598
|
+
<script lang="ts">
|
|
599
|
+
import { createToggleController, Toggle } from "@ui-sdk/svelte/toggle"
|
|
600
|
+
|
|
601
|
+
const toggle = createToggleController()
|
|
602
|
+
</script>
|
|
603
|
+
|
|
604
|
+
<button onclick={() => toggle.toggle()}>Toggle Bold</button>
|
|
605
|
+
<Toggle controller={toggle}>Bold</Toggle>
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
Controller methods run the same change callbacks as user input. Controlled values and cancellation follow [State and Events](./state-and-events.md).
|
|
609
|
+
|
|
610
|
+
Each component lists its methods, such as `open()`, `close()`, `setValue()`, or `focus()`.
|
|
611
|
+
|
|
612
|
+
A read like `toggle.isPressed()` answers when you call it, so call it from an event handler or async code. It returns `undefined` on the server and until the component is created, so markup that reads it renders differently on the server and the client. The markup doesn't update when the state changes either. To render the state, keep it in a variable with `bind:pressed`.
|
|
613
|
+
|
|
614
|
+
### Share a Popup
|
|
615
|
+
|
|
616
|
+
External triggers can use the same controller. A `payload` tells the content which item was opened:
|
|
617
|
+
|
|
618
|
+
```svelte
|
|
619
|
+
<script lang="ts">
|
|
620
|
+
import {
|
|
621
|
+
createPopoverController,
|
|
622
|
+
Popover,
|
|
623
|
+
PopoverContent,
|
|
624
|
+
PopoverTitle,
|
|
625
|
+
PopoverTrigger,
|
|
626
|
+
} from "@ui-sdk/svelte/popover"
|
|
627
|
+
|
|
628
|
+
const editor = createPopoverController<string>()
|
|
629
|
+
</script>
|
|
630
|
+
|
|
631
|
+
<PopoverTrigger controller={editor} payload="Notes">Edit Notes</PopoverTrigger>
|
|
632
|
+
<PopoverTrigger controller={editor} payload="Tasks">Edit Tasks</PopoverTrigger>
|
|
633
|
+
<Popover controller={editor}>
|
|
634
|
+
<PopoverContent>
|
|
635
|
+
{#snippet children(state)}
|
|
636
|
+
<PopoverTitle>Edit {String(state.payload ?? "")}</PopoverTitle>
|
|
637
|
+
{/snippet}
|
|
638
|
+
</PopoverContent>
|
|
639
|
+
</Popover>
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Wait for a Popup to Close
|
|
643
|
+
|
|
644
|
+
A popup controller's `open()` returns a promise. It settles when the popup closes, with its reason and return value:
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
const result = await editor.open({ payload: "Notes" })
|
|
648
|
+
console.log(result.reason, result.returnValue)
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
For confirmations, [Alert Dialog](./components/alert-dialog.md) provides `createConfirm()`, which gives you a function you can await.
|
|
652
|
+
|
|
653
|
+
## Popups
|
|
654
|
+
|
|
655
|
+
Popovers, menus, selects, and dialogs use the browser's top layer. They render in place, above the page, so you don't need a portal or Positioner part. Their events bubble through the elements around them like any other child's, so a click handler or a link wrapped around a popup also gets the clicks inside it. Keep popups outside clickable cards and links.
|
|
656
|
+
|
|
657
|
+
### Place the Content
|
|
658
|
+
|
|
659
|
+
Set placement on the content part:
|
|
660
|
+
|
|
661
|
+
```svelte
|
|
662
|
+
<script lang="ts">
|
|
663
|
+
import {
|
|
664
|
+
Popover,
|
|
665
|
+
PopoverClose,
|
|
666
|
+
PopoverContent,
|
|
667
|
+
PopoverTitle,
|
|
668
|
+
PopoverTrigger,
|
|
669
|
+
} from "@ui-sdk/svelte/popover"
|
|
670
|
+
</script>
|
|
671
|
+
|
|
672
|
+
<Popover>
|
|
673
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
674
|
+
<PopoverContent side="bottom" align="start" sideOffset={8}>
|
|
675
|
+
<PopoverTitle>Project Details</PopoverTitle>
|
|
676
|
+
<p>Last updated today.</p>
|
|
677
|
+
<PopoverClose>Done</PopoverClose>
|
|
678
|
+
</PopoverContent>
|
|
679
|
+
</Popover>
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
The popup flips or shifts when there isn't enough room.
|
|
683
|
+
|
|
684
|
+
| Prop | What It Does |
|
|
685
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
686
|
+
| `side` | Chooses `top`, `bottom`, `left`, `right`, `start`, or `end`. Start and end follow reading direction. |
|
|
687
|
+
| `align` | Aligns the popup to the start, center, or end of that side. |
|
|
688
|
+
| `sideOffset` | Sets the gap from the anchor, in pixels. |
|
|
689
|
+
| `alignOffset` | Shifts it along its side. |
|
|
690
|
+
| `collisionPadding` | Leaves space from the window's edges. |
|
|
691
|
+
|
|
692
|
+
An `anchor` positions the popup against another element. The component's page lists the anchors it accepts.
|
|
693
|
+
|
|
694
|
+
### Control Dismissal
|
|
695
|
+
|
|
696
|
+
Set `dismissible` to false to stop Escape, outside presses, focus leaving, Back, and sheet swipes from closing it. The trigger, Close part, and controller can still close it:
|
|
697
|
+
|
|
698
|
+
```svelte
|
|
699
|
+
<script lang="ts">
|
|
700
|
+
import {
|
|
701
|
+
Popover,
|
|
702
|
+
PopoverClose,
|
|
703
|
+
PopoverContent,
|
|
704
|
+
PopoverTitle,
|
|
705
|
+
PopoverTrigger,
|
|
706
|
+
} from "@ui-sdk/svelte/popover"
|
|
707
|
+
</script>
|
|
708
|
+
|
|
709
|
+
<Popover dismissible={false}>
|
|
710
|
+
<PopoverTrigger>Details</PopoverTrigger>
|
|
711
|
+
<PopoverContent>
|
|
712
|
+
<PopoverTitle>Project Details</PopoverTitle>
|
|
713
|
+
<p>Last updated today.</p>
|
|
714
|
+
<PopoverClose>Done</PopoverClose>
|
|
715
|
+
</PopoverContent>
|
|
716
|
+
</Popover>
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
Use `onDismissAttempt` to hear each refused dismissal. [State and Events](./state-and-events.md) shows how to cancel just one reason.
|
|
720
|
+
|
|
721
|
+
### Modals and Sheets
|
|
722
|
+
|
|
723
|
+
`modal` set to true makes the rest of the page inert and locks scrolling. Each component documents its default.
|
|
724
|
+
|
|
725
|
+
Menu, Select, Combobox, Autocomplete, Popover, and Dialog support `presentation="auto"` to become a sheet on small touch screens. Use `presentation="sheet"` to always show a sheet.
|
|
726
|
+
|
|
727
|
+
### Focus
|
|
728
|
+
|
|
729
|
+
Dialogs, alert dialogs, drawers, and popovers move focus into their content when they open. Where it lands depends on how they opened:
|
|
730
|
+
|
|
731
|
+
| Opened With | Focus Goes To |
|
|
732
|
+
| -------------------------------------------- | ------------------------------------------------------------ |
|
|
733
|
+
| Keyboard, screen reader, mouse, pen, or code | The element `initialFocus` picks. |
|
|
734
|
+
| Touch | The content itself, so no on-screen keyboard appears. |
|
|
735
|
+
| Hover | Nowhere. Focus stays where it is. |
|
|
736
|
+
| Rendered open | Nowhere, except in a dialog, which takes focus as it mounts. |
|
|
737
|
+
|
|
738
|
+
`initialFocus` defaults to `"auto"`: the first focusable element, or the content when it has none. A dialog tries an element with `autofocus` first, and an alert dialog tries its first Close part. Pass `"content"` to focus the content itself, `"none"` to leave focus alone, or a CSS selector, an element, or a function that returns one. When focus lands on a text field that already holds a value, its text is selected, so typing replaces it.
|
|
739
|
+
|
|
740
|
+
`modal` decides whether Tab can leave. With `true` or `"trap-focus"`, Tab and Shift+Tab wrap inside the content. With `false`, Tab moves from the trigger into a popover and on to the page after it, and focus leaving closes the popover. A non-modal dialog stays open.
|
|
741
|
+
|
|
742
|
+
When a popup closes while focus is inside it, focus returns to the trigger. If the trigger is gone or can't take focus, focus goes to the element focused before the popup opened, then where the popup it was opened from would return focus, then to the nearest focusable element after where the trigger was. A popup a controller opened returns to the element focused before it first. Set `finalFocus` to `"none"` to leave focus alone, or to a selector, an element, or a function to send it somewhere else. Closing because focus moved away never moves it back, and neither does pressing something focusable outside a non-modal popup.
|
|
743
|
+
|
|
744
|
+
Menus, selects, and comboboxes handle focus within their own lists, and tooltips never move it. Each component's page covers its own.
|
|
745
|
+
|
|
746
|
+
### Mounting and Containers
|
|
747
|
+
|
|
748
|
+
Closed content unmounts after its exit animation. `keepMounted` leaves it in the page, hidden. `onOpenChangeComplete` runs when opening or closing finishes, including animations.
|
|
749
|
+
|
|
750
|
+
Use `container` to render into another element, a shadow root, or an element in an iframe. Focus, Escape, and scroll locking then work in the document and shadow root the content renders in. Keep a dialog containing a form outside any surrounding form, or move its content with `container`, to avoid nested forms.
|
|
751
|
+
|
|
752
|
+
[Styling and Animation](./styling-and-animation.md) covers transitions. For toasts and confirms, mount `OverlayHost` once near your app's root; [Toast](./components/toast.md) and [Alert Dialog](./components/alert-dialog.md) show the setup.
|
|
753
|
+
|
|
754
|
+
## Lists and Menus
|
|
755
|
+
|
|
756
|
+
Select, Combobox, Autocomplete, Listbox, and Trigger Menu accept items as data. Use this when your choices already come from an array. You can also compose their item parts yourself.
|
|
757
|
+
|
|
758
|
+
### Start with Strings
|
|
759
|
+
|
|
760
|
+
```svelte
|
|
761
|
+
<script lang="ts">
|
|
762
|
+
import {
|
|
763
|
+
Select,
|
|
764
|
+
SelectContent,
|
|
765
|
+
SelectTrigger,
|
|
766
|
+
SelectValue,
|
|
767
|
+
} from "@ui-sdk/svelte/select"
|
|
768
|
+
</script>
|
|
769
|
+
|
|
770
|
+
<Select items={["Apple", "Banana", "Pear"]}>
|
|
771
|
+
<SelectTrigger aria-label="Fruit"
|
|
772
|
+
><SelectValue placeholder="Choose a fruit" /></SelectTrigger
|
|
773
|
+
>
|
|
774
|
+
<SelectContent />
|
|
775
|
+
</Select>
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
Each string is both the value and its label. Use objects when those need to differ:
|
|
779
|
+
|
|
780
|
+
```ts
|
|
781
|
+
const items = [
|
|
782
|
+
{ value: "apple", label: "Apple" },
|
|
783
|
+
{ value: "banana", label: "Banana", disabled: true },
|
|
784
|
+
]
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
Items can have `keywords` for searching. Group them with `{ type: "group", label, items }`, or separate them with `{ type: "separator" }`.
|
|
788
|
+
|
|
789
|
+
For object values, provide `itemToValue` for the submitted string and `itemToLabel` for the displayed text. [Select](./components/select.md) and [Combobox](./components/combobox.md) show complete examples.
|
|
790
|
+
|
|
791
|
+
### Style the Items
|
|
792
|
+
|
|
793
|
+
Items as data render bare parts, each with just its label. To style them, render the parts yourself from your array, with your classes right on them. Type the array with `ListData`, so a mistake in it shows up where you write it:
|
|
794
|
+
|
|
795
|
+
```svelte
|
|
796
|
+
<script lang="ts">
|
|
797
|
+
import {
|
|
798
|
+
Select,
|
|
799
|
+
SelectContent,
|
|
800
|
+
SelectItem,
|
|
801
|
+
SelectTrigger,
|
|
802
|
+
SelectValue,
|
|
803
|
+
type ListData,
|
|
804
|
+
} from "@ui-sdk/svelte/select"
|
|
805
|
+
|
|
806
|
+
const fruits = [
|
|
807
|
+
{ value: "apple", label: "Apple" },
|
|
808
|
+
{ value: "banana", label: "Banana" },
|
|
809
|
+
] satisfies ListData
|
|
810
|
+
</script>
|
|
811
|
+
|
|
812
|
+
<Select items={fruits}>
|
|
813
|
+
<SelectTrigger aria-label="Fruit" class="…"
|
|
814
|
+
><SelectValue placeholder="Choose a fruit" /></SelectTrigger
|
|
815
|
+
>
|
|
816
|
+
<SelectContent class="…">
|
|
817
|
+
{#each fruits as fruit (fruit.value)}
|
|
818
|
+
<SelectItem value={fruit.value} class="…">{fruit.label}</SelectItem>
|
|
819
|
+
{/each}
|
|
820
|
+
</SelectContent>
|
|
821
|
+
</Select>
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
A list that searches still filters the items you render, and hides the ones that don't match. When the items come from state, like results from a server, the list part's `children` snippet gives you the ones to show: `{#snippet children(state)}` inside a `SelectList`, then render `state.items`.
|
|
825
|
+
|
|
826
|
+
### Search and Load Items
|
|
827
|
+
|
|
828
|
+
Searchable components accept a `filter` to change how typing narrows their items. [Async Options](./utilities/async-options.md) handles server results, debouncing, and stale requests.
|
|
829
|
+
|
|
830
|
+
For a large list, pass every option through `items` and render only the visible rows. [Select](./components/select.md#virtualized) and [Combobox](./components/combobox.md#virtualized) show how.
|
|
831
|
+
|
|
832
|
+
### Describe a Menu
|
|
833
|
+
|
|
834
|
+
A `MenuData` array describes actions, separators, groups, and submenus. A plain string is an action whose value and label are the string:
|
|
835
|
+
|
|
836
|
+
```svelte
|
|
837
|
+
<script lang="ts">
|
|
838
|
+
import { Menu, MenuTrigger, type MenuData } from "@ui-sdk/svelte/menu"
|
|
839
|
+
|
|
840
|
+
const actions: MenuData = [
|
|
841
|
+
{ value: "open", label: "Open", shortcut: "mod+o" },
|
|
842
|
+
{ type: "separator" },
|
|
843
|
+
{
|
|
844
|
+
type: "submenu",
|
|
845
|
+
label: "Share",
|
|
846
|
+
items: [{ value: "email", label: "Email" }],
|
|
847
|
+
},
|
|
848
|
+
]
|
|
849
|
+
</script>
|
|
850
|
+
|
|
851
|
+
<Menu items={actions} onAction={(value) => console.log(value)}>
|
|
852
|
+
<MenuTrigger>File</MenuTrigger>
|
|
853
|
+
</Menu>
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
A data menu renders bare parts too. To style it, place a `MenuContent` of your own and render the items in it, as [Menu](./components/menu.md#menus-as-data) shows. That page also covers checkbox items, radio groups, and nested menus.
|
|
857
|
+
|
|
858
|
+
### Keys and Shortcuts
|
|
859
|
+
|
|
860
|
+
`loop` controls whether arrow keys wrap around a list. Components that support `orientation` use it to choose the navigation axis.
|
|
861
|
+
|
|
862
|
+
A trigger's `shortcut="mod+k"` opens it from elsewhere on the page. A data menu runs item shortcuts while closed; a manually rendered MenuItem's shortcut only displays the keys. [Shortcuts](./utilities/shortcuts.md) covers registering your own.
|
|
863
|
+
|
|
864
|
+
## Forms
|
|
865
|
+
|
|
866
|
+
Give a control a `name` to include its value in a form. This works for Select and Combobox as well as inputs and checkboxes.
|
|
867
|
+
|
|
868
|
+
### Submit a Value
|
|
869
|
+
|
|
870
|
+
```svelte
|
|
871
|
+
<script lang="ts">
|
|
872
|
+
import { Checkbox } from "@ui-sdk/svelte/checkbox"
|
|
873
|
+
</script>
|
|
874
|
+
|
|
875
|
+
<form action="/preferences" method="post">
|
|
876
|
+
<label
|
|
877
|
+
><Checkbox name="updates" value="yes" defaultChecked /> Email me updates</label
|
|
878
|
+
>
|
|
879
|
+
<button type="submit">Save</button>
|
|
880
|
+
<button type="reset">Reset</button>
|
|
881
|
+
</form>
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
The checkbox submits `updates=yes` when checked. Reset restores its default value.
|
|
885
|
+
|
|
886
|
+
### Reset a Controlled Value
|
|
887
|
+
|
|
888
|
+
A reset also goes through `onCheckedChange` and `bind:checked`. Keep the binding in place so your state follows the reset:
|
|
889
|
+
|
|
890
|
+
```svelte
|
|
891
|
+
<script lang="ts">
|
|
892
|
+
import { Checkbox, type CheckedState } from "@ui-sdk/svelte/checkbox"
|
|
893
|
+
|
|
894
|
+
let checked = $state<CheckedState>(true)
|
|
895
|
+
let reason = $state("No change yet")
|
|
896
|
+
</script>
|
|
897
|
+
|
|
898
|
+
<form>
|
|
899
|
+
<label>
|
|
900
|
+
<Checkbox
|
|
901
|
+
bind:checked
|
|
902
|
+
name="updates"
|
|
903
|
+
defaultChecked
|
|
904
|
+
onCheckedChange={(_next, details) => (reason = details.reason)}
|
|
905
|
+
/>
|
|
906
|
+
Email me updates
|
|
907
|
+
</label>
|
|
908
|
+
<button type="reset">Reset</button>
|
|
909
|
+
<output>{reason}</output>
|
|
910
|
+
</form>
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
Uncheck the box, then press Reset. `defaultChecked` supplies the reset value. The callback receives `true` with reason `"reset"`, and the binding updates `checked`. The callback runs when reset requests a different value; it does not run if the checkbox is already at its default. Without `defaultChecked`, a reset leaves a controlled checkbox as it is, so your state stays the only source of its value.
|
|
914
|
+
|
|
915
|
+
### Label and Validate a Field
|
|
916
|
+
|
|
917
|
+
`Field` connects a control to its label, description, and error message:
|
|
918
|
+
|
|
919
|
+
```svelte
|
|
920
|
+
<script lang="ts">
|
|
921
|
+
import {
|
|
922
|
+
Field,
|
|
923
|
+
FieldDescription,
|
|
924
|
+
FieldError,
|
|
925
|
+
FieldLabel,
|
|
926
|
+
} from "@ui-sdk/svelte/field"
|
|
927
|
+
import { Input } from "@ui-sdk/svelte/input"
|
|
928
|
+
</script>
|
|
929
|
+
|
|
930
|
+
<Field name="email">
|
|
931
|
+
<FieldLabel>Email</FieldLabel>
|
|
932
|
+
<Input type="email" required />
|
|
933
|
+
<FieldDescription>We'll only use it for receipts.</FieldDescription>
|
|
934
|
+
<FieldError />
|
|
935
|
+
</Field>
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
You can use a Textarea, Checkbox, Switch, Radio Group, or Select in place of the Input. [Field](./components/field.md) shows how they connect.
|
|
939
|
+
|
|
940
|
+
On controls that support them, `required`, `disabled`, `readOnly`, and `form` follow native conventions. Disabled fields are left out of submission; read-only fields remain focusable and submitted.
|
|
941
|
+
|
|
942
|
+
### Handle a Submission
|
|
943
|
+
|
|
944
|
+
On a normal submit, the browser checks constraints such as `required` and `type="email"` before running your handler.
|
|
945
|
+
|
|
946
|
+
Your server may still reject a valid-looking value. Pass `invalid` to the field and show the server’s message. When the user edits the field, clear the message and return `invalid` to `undefined` so the field uses native validation again. This example expects a `/api/preferences` endpoint:
|
|
947
|
+
|
|
948
|
+
```svelte
|
|
949
|
+
<script lang="ts">
|
|
950
|
+
import { Field, FieldError, FieldLabel } from "@ui-sdk/svelte/field"
|
|
951
|
+
import { Input } from "@ui-sdk/svelte/input"
|
|
952
|
+
|
|
953
|
+
let error = $state("")
|
|
954
|
+
|
|
955
|
+
async function save(event: SubmitEvent) {
|
|
956
|
+
event.preventDefault()
|
|
957
|
+
const body = new FormData(event.currentTarget as HTMLFormElement)
|
|
958
|
+
const response = await fetch("/api/preferences", { method: "POST", body })
|
|
959
|
+
error = response.ok ? "" : "That email is already taken."
|
|
960
|
+
}
|
|
961
|
+
</script>
|
|
962
|
+
|
|
963
|
+
<form onsubmit={save}>
|
|
964
|
+
<Field name="email" invalid={error ? true : undefined}>
|
|
965
|
+
<FieldLabel>Email</FieldLabel>
|
|
966
|
+
<Input type="email" required onValueChange={() => (error = "")} />
|
|
967
|
+
<FieldError>
|
|
968
|
+
{#snippet children(state)}{error || state.message}{/snippet}
|
|
969
|
+
</FieldError>
|
|
970
|
+
</Field>
|
|
971
|
+
<button type="submit">Save</button>
|
|
972
|
+
</form>
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
Without a handler, the form submits through its `action` URL.
|
|
976
|
+
|
|
977
|
+
## Server Rendering
|
|
978
|
+
|
|
979
|
+
ui-sdk parts render HTML with Svelte's server renderer. Their initial attributes include ARIA state and the group's tab stop.
|
|
980
|
+
|
|
981
|
+
### Render the Initial State
|
|
982
|
+
|
|
983
|
+
```svelte
|
|
984
|
+
<script lang="ts">
|
|
985
|
+
import { Toggle } from "@ui-sdk/svelte/toggle"
|
|
986
|
+
</script>
|
|
987
|
+
|
|
988
|
+
<Toggle defaultPressed>Bold</Toggle>
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
The server sends a button with `aria-pressed="true"`. It can toggle after hydration. Native HTML behavior, such as submitting a form, can work before hydration.
|
|
992
|
+
|
|
993
|
+
### Read Browser Values After Mount
|
|
994
|
+
|
|
995
|
+
The server does not know the browser’s language. Start with the same placeholder on the server and client, then read the language after mount:
|
|
996
|
+
|
|
997
|
+
```svelte
|
|
998
|
+
<script lang="ts">
|
|
999
|
+
import { onMount } from "svelte"
|
|
1000
|
+
|
|
1001
|
+
let language = $state("")
|
|
1002
|
+
onMount(() => {
|
|
1003
|
+
language = navigator.language
|
|
1004
|
+
})
|
|
1005
|
+
</script>
|
|
1006
|
+
|
|
1007
|
+
<p>{language || "Loading language…"}</p>
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
Both initial renders show “Loading language…”. Once mounted, the paragraph shows the browser’s language. Read other browser-only values in the same place, or in an event handler.
|
|
1011
|
+
|
|
1012
|
+
### Saved Preferences and Storage
|
|
1013
|
+
|
|
1014
|
+
Preferences like a color scheme or an emoji skin tone are saved in the browser, so the server can't render them. [Preferences](./core.md#preferences) covers the preferences themselves; this is how they fit server rendering.
|
|
1015
|
+
|
|
1016
|
+
#### Show Them Before Hydration
|
|
1017
|
+
|
|
1018
|
+
Render `Preferences` around your app. On the server it renders one inline script as its first child, which puts every saved value on its `data-*` attribute as the page loads, before Svelte hydrates, so CSS that selects those attributes is right from the first paint:
|
|
1019
|
+
|
|
1020
|
+
```svelte title="app.svelte"
|
|
1021
|
+
<script lang="ts">
|
|
1022
|
+
import { Preferences } from "@ui-sdk/svelte/preferences"
|
|
1023
|
+
import Page from "./page.svelte"
|
|
1024
|
+
import { colorScheme, skinTone } from "./preferences"
|
|
1025
|
+
</script>
|
|
1026
|
+
|
|
1027
|
+
<Preferences preferences={[colorScheme, skinTone]}>
|
|
1028
|
+
<Page />
|
|
1029
|
+
</Preferences>
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
A preference made with `global: true` goes on `<html>` instead. Pass `nonce` if your Content Security Policy only allows inline scripts with one.
|
|
1033
|
+
|
|
1034
|
+
Content that reads a preference through `usePreference` renders the default on the server and the saved value once mounted. Style by the attribute instead wherever the first paint has to be right, as [Style by Preferences](./core.md#style-by-preferences) shows.
|
|
1035
|
+
|
|
1036
|
+
#### Read a Cookie on the Server
|
|
1037
|
+
|
|
1038
|
+
A preference kept in a cookie can render on the server too, content included. Read the request's `Cookie` header on the server, however your server or framework gives you the request, and pass it to your app as a prop, like `render(App, { props: { cookie } })`. Create the preference in the component and share it through context, so each request gets its own, as [Give Each Request Its Own State](#give-each-request-its-own-state) explains:
|
|
1039
|
+
|
|
1040
|
+
```svelte title="app.svelte"
|
|
1041
|
+
<script lang="ts">
|
|
1042
|
+
import { createCookieStorage, createPreference } from "@ui-sdk/core"
|
|
1043
|
+
import { Preferences } from "@ui-sdk/svelte/preferences"
|
|
1044
|
+
import { setContext } from "svelte"
|
|
1045
|
+
import Page from "./page.svelte"
|
|
1046
|
+
|
|
1047
|
+
interface Props {
|
|
1048
|
+
cookie: string | null
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
let { cookie }: Props = $props()
|
|
1052
|
+
// svelte-ignore state_referenced_locally
|
|
1053
|
+
const skinTone = createPreference({
|
|
1054
|
+
values: ["default", "light", "medium", "dark"],
|
|
1055
|
+
defaultValue: "default",
|
|
1056
|
+
attribute: "data-skin-tone",
|
|
1057
|
+
storage: createCookieStorage("skin-tone", { cookie }),
|
|
1058
|
+
})
|
|
1059
|
+
setContext("skin-tone", skinTone)
|
|
1060
|
+
</script>
|
|
1061
|
+
|
|
1062
|
+
<Preferences preferences={[skinTone]}>
|
|
1063
|
+
<Page />
|
|
1064
|
+
</Preferences>
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
The server reads the value from `cookie`, and the browser from `document.cookie`, so both render it and hydration matches.
|
|
1068
|
+
|
|
1069
|
+
#### Render the Storage Script Yourself
|
|
1070
|
+
|
|
1071
|
+
`Preferences` is the usual way. For one component that keeps its own value, like a toolbar's density, a storage's `script` returns the same kind of inline script for a single element. Render it right after the element, since it writes to the element right before it:
|
|
1072
|
+
|
|
1073
|
+
```svelte title="toolbar.svelte"
|
|
1074
|
+
<script lang="ts">
|
|
1075
|
+
import { createLocalStorage } from "@ui-sdk/core"
|
|
1076
|
+
|
|
1077
|
+
let { children } = $props()
|
|
1078
|
+
|
|
1079
|
+
const density = createLocalStorage("density")
|
|
1080
|
+
const script = density.script({
|
|
1081
|
+
attribute: "data-density",
|
|
1082
|
+
values: ["comfortable", "compact"],
|
|
1083
|
+
})
|
|
1084
|
+
let element: HTMLDivElement | undefined = $state()
|
|
1085
|
+
// The script is in the server's HTML until then.
|
|
1086
|
+
let mounted = $state(false)
|
|
1087
|
+
// Only the server renders the attribute. Svelte writes attributes while it
|
|
1088
|
+
// hydrates, which would put the server's value back over the saved one.
|
|
1089
|
+
const server =
|
|
1090
|
+
typeof window === "undefined" ? { "data-density": "comfortable" } : {}
|
|
1091
|
+
|
|
1092
|
+
$effect(() => {
|
|
1093
|
+
element?.setAttribute(
|
|
1094
|
+
"data-density",
|
|
1095
|
+
density.get() === "compact" ? "compact" : "comfortable"
|
|
1096
|
+
)
|
|
1097
|
+
mounted = true
|
|
1098
|
+
})
|
|
1099
|
+
</script>
|
|
1100
|
+
|
|
1101
|
+
<div {...server} bind:this={element}>{@render children()}</div>
|
|
1102
|
+
{#if !mounted && script}{@html `<script>${script}<\/script>`}{/if}
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
- **Only from the server.** The browser never runs a script Svelte inserts, so drop it once mounted.
|
|
1106
|
+
- **Set the attribute yourself.** Svelte writes attributes while hydrating, so render this one on the server only and set it from an effect, as above, or hydration puts the server's value back for a moment.
|
|
1107
|
+
- **Shared by ID.** Every script with the same storage kind and ID reads the storage once, however many elements render it, and the scripts are identical, so compression shrinks the repeats.
|
|
1108
|
+
- **Only safe values.** Any script on your site can write the saved value, so `script` only sets attributes that start with `data-`, and only to one of `values`.
|
|
1109
|
+
- **Not for cookies.** A cookie storage's `script` returns undefined, since the server reads the cookie and renders the value itself.
|
|
1110
|
+
|
|
1111
|
+
To run before the page's content at all, render `preferencesScript([...])` from `@ui-sdk/core` in `<head>` yourself, like with `<svelte:head>`. Only global preferences make sense there, since the others go on the script's parent element.
|
|
1112
|
+
|
|
1113
|
+
### Keep IDs and Values Consistent
|
|
1114
|
+
|
|
1115
|
+
Use the same initial component values on the server and client. For example, do not render an open dialog on the server and a closed one for the first client render.
|
|
1116
|
+
|
|
1117
|
+
Parts generate IDs for relationships such as a Dialog trigger’s `aria-controls` and a Field label’s `for`. You usually do not need to supply them.
|
|
1118
|
+
|
|
1119
|
+
Pass an explicit `id` when something outside the component needs to refer to a part. On the server, render order matters: if a Field label renders before a control with your ID, the label initially uses the generated ID. Hydration updates the reference to yours. The same applies to Dialog triggers, titles, and descriptions.
|
|
1120
|
+
|
|
1121
|
+
Use classes or data attributes for styling, rather than generated IDs.
|
|
1122
|
+
|
|
1123
|
+
### Give Each Request Its Own State
|
|
1124
|
+
|
|
1125
|
+
The server runs your modules once and reuses them for every request. Create app state inside a component and share it through context, so each visitor gets their own copy. [State and Events](./state-and-events.md#share-state-across-components) shows how.
|
|
1126
|
+
|
|
1127
|
+
Popups render in place, so your server layout doesn't need a portal root. [Popups](./popups.md) covers containers; [Forms](./forms.md) covers submission and validation.
|
|
1128
|
+
|
|
1129
|
+
## Rendering Primitives
|
|
1130
|
+
|
|
1131
|
+
This page renders the rating from [Compose Behaviors](./core.md#compose-behaviors). Start with that guide's [complete `rating.ts`](./core.md#complete-primitive): it already handles selection, arrow keys, and focus. Here we'll connect its `root` and `star` slots to Svelte.
|
|
1132
|
+
|
|
1133
|
+
### Create the Parts
|
|
1134
|
+
|
|
1135
|
+
`createParts` maps slots to elements. Save this beside `rating.ts`:
|
|
1136
|
+
|
|
1137
|
+
```ts title="rating-parts.ts"
|
|
1138
|
+
import { createParts } from "@ui-sdk/svelte/primitive"
|
|
1139
|
+
import { rating } from "./rating"
|
|
1140
|
+
|
|
1141
|
+
const { Root: RatingRoot, Star: RatingStar } = createParts(rating, {
|
|
1142
|
+
root: "div",
|
|
1143
|
+
star: "button",
|
|
1144
|
+
})
|
|
1145
|
+
|
|
1146
|
+
export { RatingRoot, RatingStar }
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
`Root` creates the instance and shares it with the parts inside. Each mapped slot becomes a component. Slot names become Pascal case: `star` becomes `Star`, and `tab-icon` would become `TabIcon`.
|
|
1150
|
+
|
|
1151
|
+
If you leave out the `root` tag, `Root` still shares the instance but renders only its children.
|
|
1152
|
+
|
|
1153
|
+
### Render the Rating
|
|
1154
|
+
|
|
1155
|
+
The root accepts the primitive's options and the element's props. Each star receives its slot value and a name a screen reader can announce:
|
|
1156
|
+
|
|
1157
|
+
```svelte
|
|
1158
|
+
<script lang="ts">
|
|
1159
|
+
import { RatingRoot, RatingStar } from "./rating-parts"
|
|
1160
|
+
</script>
|
|
1161
|
+
|
|
1162
|
+
<RatingRoot defaultValue={4} aria-label="Rating" class="flex gap-1">
|
|
1163
|
+
{#each Array.from({ length: 5 }, (_, index) => index + 1) as star (star)}
|
|
1164
|
+
<RatingStar
|
|
1165
|
+
value={String(star)}
|
|
1166
|
+
aria-label={`${star} ${star === 1 ? "star" : "stars"}`}
|
|
1167
|
+
class="opacity-40 data-filled:opacity-100">★</RatingStar
|
|
1168
|
+
>
|
|
1169
|
+
{/each}
|
|
1170
|
+
</RatingRoot>
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
The primitive supplies `data-filled`; these classes make the filled stars easier to see. [Styling and Animation](./styling-and-animation.md) covers other ways to style parts.
|
|
1174
|
+
|
|
1175
|
+
Generated parts also support the same `children` and `render` snippets as the components in the catalog. Use [Parts and Composition](./parts-and-composition.md) when you want to change their markup.
|
|
1176
|
+
|
|
1177
|
+
### Add Logic to a Part
|
|
1178
|
+
|
|
1179
|
+
Keep `createParts` when mapping slots to elements is enough. [Custom Parts](./custom-parts.md) uses the same rating to show how `usePrimitive` and `usePart` let you write your own root or child part.
|
|
1180
|
+
|
|
1181
|
+
## Custom Parts
|
|
1182
|
+
|
|
1183
|
+
The parts from [Rendering Primitives](./rendering.md) are enough until one needs its own logic. You can replace just that part and keep the same `rating.ts` definition from [Compose Behaviors](./core.md#complete-primitive).
|
|
1184
|
+
|
|
1185
|
+
### Write a Root Part
|
|
1186
|
+
|
|
1187
|
+
Here's a replacement for the generated `RatingRoot`. `usePrimitive` creates its instance, and `usePart` connects the `root` slot:
|
|
1188
|
+
|
|
1189
|
+
```svelte title="rating-root.svelte"
|
|
1190
|
+
<script lang="ts">
|
|
1191
|
+
import type { StateOf } from "@ui-sdk/core"
|
|
1192
|
+
import {
|
|
1193
|
+
Part,
|
|
1194
|
+
usePart,
|
|
1195
|
+
usePrimitive,
|
|
1196
|
+
type PartProps,
|
|
1197
|
+
} from "@ui-sdk/svelte/primitive"
|
|
1198
|
+
import { setContext } from "svelte"
|
|
1199
|
+
import { rating, type RatingOptions } from "./rating"
|
|
1200
|
+
|
|
1201
|
+
type RootProps = PartProps<"div", StateOf<typeof rating, "root">>
|
|
1202
|
+
|
|
1203
|
+
interface Props extends RatingOptions, Omit<RootProps, "defaultValue"> {}
|
|
1204
|
+
|
|
1205
|
+
let { value, defaultValue, onValueChange, ...props }: Props = $props()
|
|
1206
|
+
const id = $props.id()
|
|
1207
|
+
const handle = usePrimitive(rating, () => ({
|
|
1208
|
+
id,
|
|
1209
|
+
value,
|
|
1210
|
+
defaultValue,
|
|
1211
|
+
onValueChange,
|
|
1212
|
+
}))
|
|
1213
|
+
setContext(rating, handle)
|
|
1214
|
+
const root = usePart(handle, "root")
|
|
1215
|
+
</script>
|
|
1216
|
+
|
|
1217
|
+
{#if root.present}
|
|
1218
|
+
<Part tag="div" part={root} {props} />
|
|
1219
|
+
{/if}
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
Pass options through a getter so they follow prop changes. `$props.id()` gives the instance a stable ID across server rendering and hydration. This manual root accepts `value` and `onValueChange`; it doesn't add a `bind:value` contract.
|
|
1223
|
+
|
|
1224
|
+
`setContext(rating, handle)` makes the instance available to child parts. A generated `createParts` root does this for you. `usePart` connects the slot, and `Part` renders it with the caller's `render` and `children` snippets. The instance is destroyed on unmount.
|
|
1225
|
+
|
|
1226
|
+
Keep the `{#if root.present}` check: `Part` doesn't hide or remove itself when a slot isn't present.
|
|
1227
|
+
|
|
1228
|
+
### Connect a Child Part
|
|
1229
|
+
|
|
1230
|
+
Pass the primitive itself to `usePart` to find the instance shared by the root above it. This `RatingStar` works inside the manual root above or the generated `RatingRoot`:
|
|
1231
|
+
|
|
1232
|
+
```svelte title="rating-star.svelte"
|
|
1233
|
+
<script lang="ts">
|
|
1234
|
+
import { Part, usePart, type PartProps } from "@ui-sdk/svelte/primitive"
|
|
1235
|
+
import { rating } from "./rating"
|
|
1236
|
+
|
|
1237
|
+
interface Props extends Omit<PartProps<"button">, "value"> {
|
|
1238
|
+
value: string
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
let { value, ...props }: Props = $props()
|
|
1242
|
+
const star = usePart(rating, "star", () => ({ value }))
|
|
1243
|
+
</script>
|
|
1244
|
+
|
|
1245
|
+
{#if star.present}
|
|
1246
|
+
<Part tag="button" part={star} {props} />
|
|
1247
|
+
{/if}
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
Use it in place of the generated star in [Render the Rating](./rendering.md#render-the-rating). The `value` getter identifies the star; the remaining props go to its button. Keep it inside `RatingRoot` and give it an `aria-label`.
|
|
1251
|
+
|
|
1252
|
+
### Merge Props
|
|
1253
|
+
|
|
1254
|
+
`Part` merges your props with the slot's. Slot attributes win, your event handlers run first, and attachments combine. An `id`, or a name or typing hint you pass, like `aria-label` or `autocomplete`, replaces the slot's. Put canceling handlers in the props passed to `Part`. Calling `preventDefault()` there skips the built-in behavior; a handler on an element inside a `render` snippet runs too late to cancel it.
|
|
1255
|
+
|
|
1256
|
+
For custom markup, `part.slot(props)` supplies the attributes and attachment. Read `part.state` in markup so Svelte tracks changes, and wrap the element in `{#if part.present}` to follow the slot's presence.
|
|
1257
|
+
|
|
1258
|
+
### Compose a Popup
|
|
1259
|
+
|
|
1260
|
+
A custom component can also use an existing Popover or Dialog. [Compose Ours](./core.md#compose-ours) shows that connection with an emoji picker.
|
|
1261
|
+
|
|
1262
|
+
## Components
|
|
1263
|
+
|
|
1264
|
+
Each page has the component's composition, examples, styling hooks and every prop.
|
|
1265
|
+
|
|
1266
|
+
- [Accordion](./components/accordion.md): Show and hide sections of content from their headings. Import from `@ui-sdk/svelte/accordion`.
|
|
1267
|
+
- [Alert Dialog](./components/alert-dialog.md): Ask someone to confirm an action before you continue. Import from `@ui-sdk/svelte/alert-dialog`.
|
|
1268
|
+
- [Autocomplete](./components/autocomplete.md): Suggest text while someone types, without limiting what they can enter. Import from `@ui-sdk/svelte/autocomplete`.
|
|
1269
|
+
- [Avatar](./components/avatar.md): Show an image with a fallback while it loads or if it fails. Import from `@ui-sdk/svelte/avatar`.
|
|
1270
|
+
- [Button](./components/button.md): Run an action, show that it's working, and keep it reachable when disabled. Import from `@ui-sdk/svelte/button`.
|
|
1271
|
+
- [Calendar](./components/calendar.md): Choose one date, several dates, or a range from a month grid. Import from `@ui-sdk/svelte/calendar`.
|
|
1272
|
+
- [Carousel](./components/carousel.md): Page through slides with native scrolling, keyboard controls, and optional rotation. Import from `@ui-sdk/svelte/carousel`.
|
|
1273
|
+
- [Checkbox](./components/checkbox.md): Choose one or more options, individually or as a group. Import from `@ui-sdk/svelte/checkbox`.
|
|
1274
|
+
- [Collapsible](./components/collapsible.md): Show and hide a panel, preserve its contents, and animate its height. Import from `@ui-sdk/svelte/collapsible`.
|
|
1275
|
+
- [Color Picker](./components/color-picker.md): Choose a color by dragging across an area and along sliders, typing any CSS color, or picking a preset. Import from `@ui-sdk/svelte/color-picker`.
|
|
1276
|
+
- [Combobox](./components/combobox.md): Search a list of options and choose one or several values. Import from `@ui-sdk/svelte/combobox`.
|
|
1277
|
+
- [Command](./components/command.md): Search commands, run actions, and open pages of more choices. Import from `@ui-sdk/svelte/command`.
|
|
1278
|
+
- [Date Input](./components/date-input.md): Type a date one part at a time, in the order your user's language writes it. Import from `@ui-sdk/svelte/date-input`.
|
|
1279
|
+
- [Date Picker](./components/date-picker.md): Type a date or choose one from a calendar, with support for ranges and forms. Import from `@ui-sdk/svelte/date-picker`.
|
|
1280
|
+
- [Dialog](./components/dialog.md): Open a focused task over the page. Import from `@ui-sdk/svelte/dialog`.
|
|
1281
|
+
- [Drawer](./components/drawer.md): A sheet you can open, drag, and resize from an edge of the screen. Import from `@ui-sdk/svelte/drawer`.
|
|
1282
|
+
- [Field](./components/field.md): Connect a form control to its label, description, and validation errors. Import from `@ui-sdk/svelte/field`.
|
|
1283
|
+
- [File Input](./components/file-input.md): Choose, drop, or paste files, validate them, and submit them with a form. Import from `@ui-sdk/svelte/file-input`.
|
|
1284
|
+
- [Hover Card](./components/hover-card.md): Preview a link on hover or keyboard focus while keeping its normal navigation. Import from `@ui-sdk/svelte/hover-card`.
|
|
1285
|
+
- [Image Cropper](./components/image-cropper.md): Choose the part of an image to keep by moving and resizing a selection, or by panning and zooming the image under it. Import from `@ui-sdk/svelte/image-cropper`.
|
|
1286
|
+
- [Input](./components/input.md): Enter text, add a clear button, and connect the value to your form or state. Import from `@ui-sdk/svelte/input`.
|
|
1287
|
+
- [Label](./components/label.md): Name any control with a label, and let a press on the label reach it. Import from `@ui-sdk/svelte/label`.
|
|
1288
|
+
- [Listbox](./components/listbox.md): Choose one or several options from an always-visible list. Import from `@ui-sdk/svelte/listbox`.
|
|
1289
|
+
- [Menu](./components/menu.md): Choose actions and settings from a button or a context menu. Import from `@ui-sdk/svelte/menu`.
|
|
1290
|
+
- [Menubar](./components/menubar.md): Move between an application’s menus with one tab stop. Import from `@ui-sdk/svelte/menubar`.
|
|
1291
|
+
- [Meter](./components/meter.md): Show a measurement within a known range, such as storage used or an account quota. Import from `@ui-sdk/svelte/meter`.
|
|
1292
|
+
- [Navigation Menu](./components/navigation-menu.md): Groups site links into panels that open from a row of triggers. Import from `@ui-sdk/svelte/navigation-menu`.
|
|
1293
|
+
- [Number Input](./components/number-input.md): Enter numbers, step through values, and format them for a locale. Import from `@ui-sdk/svelte/number-input`.
|
|
1294
|
+
- [OTP Input](./components/otp-input.md): Enter a one-time code with support for pasting, autofill, and native form validation. Import from `@ui-sdk/svelte/otp-input`.
|
|
1295
|
+
- [Pagination](./components/pagination.md): Navigate pages with buttons, links, or your router. Import from `@ui-sdk/svelte/pagination`.
|
|
1296
|
+
- [Password Input](./components/password-input.md): Enter a password, show or hide it, and use it in a native form. Import from `@ui-sdk/svelte/password-input`.
|
|
1297
|
+
- [Popover](./components/popover.md): Edit or explore something beside its trigger. Import from `@ui-sdk/svelte/popover`.
|
|
1298
|
+
- [Preferences](./components/preferences.md): Apply user preferences to data attributes so your styles can follow them. Import from `@ui-sdk/svelte/preferences`.
|
|
1299
|
+
- [Progress](./components/progress.md): Show a task’s progress, or an indeterminate state while its progress is unknown. Import from `@ui-sdk/svelte/progress`.
|
|
1300
|
+
- [Radio](./components/radio.md): Choose one option, move the selection with arrow keys, and submit it with a form. Import from `@ui-sdk/svelte/radio`.
|
|
1301
|
+
- [Rating](./components/rating.md): Pick a score from a row of stars, whole or half, with a preview as the pointer moves over them. Import from `@ui-sdk/svelte/rating`.
|
|
1302
|
+
- [Resizable](./components/resizable.md): Resize, collapse, and save panel layouts with pointer and keyboard controls. Import from `@ui-sdk/svelte/resizable`.
|
|
1303
|
+
- [Scroll Area](./components/scroll-area.md): Add styled scrollbars, edge indicators, and follow-to-end behavior to native scrolling. Import from `@ui-sdk/svelte/scroll-area`.
|
|
1304
|
+
- [Segmented Control](./components/segmented-control.md): Pick one of a few options from a row of buttons, with an indicator that slides to the choice. Import from `@ui-sdk/svelte/segmented-control`.
|
|
1305
|
+
- [Select](./components/select.md): Choose one value or several from a popup list. Import from `@ui-sdk/svelte/select`.
|
|
1306
|
+
- [Separator](./components/separator.md): Divide groups of content with a horizontal or vertical line. Import from `@ui-sdk/svelte/separator`.
|
|
1307
|
+
- [Slider](./components/slider.md): Adjust a number or a range with draggable thumbs and keyboard controls. Import from `@ui-sdk/svelte/slider`.
|
|
1308
|
+
- [Switch](./components/switch.md): Turn a setting on or off. Import from `@ui-sdk/svelte/switch`.
|
|
1309
|
+
- [Tabs](./components/tabs.md): Switch between related panels with one tab selected at a time. Import from `@ui-sdk/svelte/tabs`.
|
|
1310
|
+
- [Textarea](./components/textarea.md): Enter multiple lines of text, grow the field as you type, and connect it to a form. Import from `@ui-sdk/svelte/textarea`.
|
|
1311
|
+
- [Time Input](./components/time-input.md): Type a time one part at a time, on the clock your user's language uses.
|
|
1312
|
+
- [Timeline](./components/timeline.md): Show dated events in order, like an activity feed, a changelog or an order's progress, with arrow keys between them. Import from `@ui-sdk/svelte/timeline`.
|
|
1313
|
+
- [Toast](./components/toast.md): Show notifications with actions, timed dismissal, and screen reader announcements. Import from `@ui-sdk/svelte/toast`.
|
|
1314
|
+
- [Toggle](./components/toggle.md): Keep a button pressed, or group toggles with a shared value and arrow-key navigation. Import from `@ui-sdk/svelte/toggle`.
|
|
1315
|
+
- [Token Input](./components/token-input.md): Mix editable text with tokens for files, people, tags, and other references. Import from `@ui-sdk/svelte/token-input`.
|
|
1316
|
+
- [Toolbar](./components/toolbar.md): Give buttons, toggles, menus and fields one tab stop with arrow-key navigation. Import from `@ui-sdk/svelte/toolbar`.
|
|
1317
|
+
- [Tooltip](./components/tooltip.md): Name a control or add a short hint on hover and keyboard focus. Import from `@ui-sdk/svelte/tooltip`.
|
|
1318
|
+
- [Tree](./components/tree.md): Browse a hierarchy of files, pages, or choices with expandable branches. Import from `@ui-sdk/svelte/tree`.
|
|
1319
|
+
- [Trigger Menu](./components/trigger-menu.md): "Opens suggestions at the caret when you type a trigger such as @, /, or #." Import from `@ui-sdk/svelte/trigger-menu`.
|
|
1320
|
+
- [Waterfall](./components/waterfall.md): Show a trace or a page's requests as bars on a shared time axis, with spans that expand to show what they started. Import from `@ui-sdk/svelte/waterfall`.
|
|
1321
|
+
|
|
1322
|
+
## Utilities
|
|
1323
|
+
|
|
1324
|
+
### Async Options
|
|
1325
|
+
|
|
1326
|
+
`useAsyncOptions` loads items as someone types. It waits for typing to pause, cancels requests that are replaced, and keeps the previous results visible while loading.
|
|
1327
|
+
|
|
1328
|
+
Change the movie search and wait for the results. Use the arrow keys to choose a movie, then press Enter.
|
|
1329
|
+
|
|
1330
|
+
#### Load Results
|
|
1331
|
+
|
|
1332
|
+
Pass a loader to the helper. This example expects `/api/movies` to return an array of movie titles:
|
|
1333
|
+
|
|
1334
|
+
```svelte
|
|
1335
|
+
<script lang="ts">
|
|
1336
|
+
import { useAsyncOptions } from "@ui-sdk/svelte/async-options"
|
|
1337
|
+
import {
|
|
1338
|
+
Combobox,
|
|
1339
|
+
ComboboxContent,
|
|
1340
|
+
ComboboxInput,
|
|
1341
|
+
} from "@ui-sdk/svelte/combobox"
|
|
1342
|
+
|
|
1343
|
+
const movies = useAsyncOptions<string>(async (query, { signal }) => {
|
|
1344
|
+
const response = await fetch(`/api/movies?q=${encodeURIComponent(query)}`, {
|
|
1345
|
+
signal,
|
|
1346
|
+
})
|
|
1347
|
+
if (!response.ok) throw new Error("Couldn't load movies")
|
|
1348
|
+
return response.json()
|
|
1349
|
+
})
|
|
1350
|
+
</script>
|
|
1351
|
+
|
|
1352
|
+
<Combobox
|
|
1353
|
+
items={movies.state.items}
|
|
1354
|
+
filter={false}
|
|
1355
|
+
status={movies.state.status}
|
|
1356
|
+
onQueryChange={movies.setQuery}
|
|
1357
|
+
>
|
|
1358
|
+
<ComboboxInput aria-label="Movie" placeholder="Search movies…" />
|
|
1359
|
+
<ComboboxContent />
|
|
1360
|
+
</Combobox>
|
|
1361
|
+
```
|
|
1362
|
+
|
|
1363
|
+
Read `movies.state` in markup so Svelte tracks it. Destructuring the state would keep only the current value.
|
|
1364
|
+
|
|
1365
|
+
Pass `signal` to `fetch` so a newer search can cancel the request. The helper cancels on unmount. `filter` set to false leaves matching and ordering to the server.
|
|
1366
|
+
|
|
1367
|
+
Use `ComboboxStatus` and `ComboboxEmpty` to show loading, error, and empty messages, as in the demo. The same pattern works with [Select](./components/select.md#async-search), [Autocomplete](./components/autocomplete.md#async-suggestions), and [Command](./components/command.md#async-results).
|
|
1368
|
+
|
|
1369
|
+
#### Choose When to Load
|
|
1370
|
+
|
|
1371
|
+
The second argument sets the starting behavior:
|
|
1372
|
+
|
|
1373
|
+
| Option | What It Does | Default |
|
|
1374
|
+
| ----------- | ------------------------------------------------------------------------------- | ------- |
|
|
1375
|
+
| `debounce` | Milliseconds typing must pause before a request starts. | `200` |
|
|
1376
|
+
| `query` | The starting search text. | `""` |
|
|
1377
|
+
| `immediate` | Loads that text as soon as the component mounts. | `false` |
|
|
1378
|
+
| `minLength` | Characters the text needs before anything loads. Shorter text clears the items. | `0` |
|
|
1379
|
+
|
|
1380
|
+
For initial choices, add `{ immediate: true, debounce: 300 }` after the loader. Until that first load starts, `status` is already `"loading"`, so the list never flashes an empty state. If you set `query`, use the same starting text for the component's `defaultQuery`.
|
|
1381
|
+
|
|
1382
|
+
#### Load More
|
|
1383
|
+
|
|
1384
|
+
For paged results, the loader receives `page`, starting at `0`. Return `{ items, hasMore }`:
|
|
1385
|
+
|
|
1386
|
+
```ts
|
|
1387
|
+
import type { AsyncOptionsContext } from "@ui-sdk/svelte/async-options"
|
|
1388
|
+
|
|
1389
|
+
async function loadMoviePages(
|
|
1390
|
+
query: string,
|
|
1391
|
+
{ signal, page }: AsyncOptionsContext
|
|
1392
|
+
) {
|
|
1393
|
+
const response = await fetch(
|
|
1394
|
+
`/api/movies?q=${encodeURIComponent(query)}&page=${page}`,
|
|
1395
|
+
{ signal }
|
|
1396
|
+
)
|
|
1397
|
+
if (!response.ok) throw new Error("Couldn't load movies")
|
|
1398
|
+
const data: { titles: string[]; next: number | null } = await response.json()
|
|
1399
|
+
return { items: data.titles, hasMore: data.next !== null }
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
export { loadMoviePages }
|
|
1403
|
+
```
|
|
1404
|
+
|
|
1405
|
+
Pass `loadMoviePages` to `useAsyncOptions` in place of the inline loader above.
|
|
1406
|
+
|
|
1407
|
+
Connect `onLoadMore={movies.loadMore}` on Combobox. It asks for another page when scrolling or keyboard navigation reaches the last item. The helper appends the new items.
|
|
1408
|
+
|
|
1409
|
+
Open the movie list and scroll down, or use Arrow Down to reach the last result. The next page is added to the list.
|
|
1410
|
+
|
|
1411
|
+
#### Retry a Search
|
|
1412
|
+
|
|
1413
|
+
`status` is `"loading"` during a request, `"error"` after a failure, and `"idle"` otherwise. `error` holds the failure, and the previous items stay available.
|
|
1414
|
+
|
|
1415
|
+
Call `movies.reload()` from a retry button to load the current query again, starting at page `0`. `movies.state.hasMore` tells you whether another page is available.
|
|
1416
|
+
|
|
1417
|
+
### Shortcuts
|
|
1418
|
+
|
|
1419
|
+
`useShortcut` registers a shortcut while your component is mounted. For a component that already accepts `shortcut`, such as a dialog trigger, use that prop directly.
|
|
1420
|
+
|
|
1421
|
+
Press N to create a note. Press Command+S on Mac or Control+S elsewhere to save. The buttons run the same actions.
|
|
1422
|
+
|
|
1423
|
+
#### Register a Shortcut
|
|
1424
|
+
|
|
1425
|
+
Keys are joined with `+`. `mod` means Command on Apple platforms and Control elsewhere. This example also displays the keys using `useShortcutHint`:
|
|
1426
|
+
|
|
1427
|
+
```svelte
|
|
1428
|
+
<script lang="ts">
|
|
1429
|
+
import { useShortcut, useShortcutHint } from "@ui-sdk/svelte/shortcuts"
|
|
1430
|
+
|
|
1431
|
+
let count = $state(0)
|
|
1432
|
+
const addNote = () => count++
|
|
1433
|
+
useShortcut("mod+enter", addNote, { description: "New note" })
|
|
1434
|
+
const hint = useShortcutHint("mod+enter")
|
|
1435
|
+
</script>
|
|
1436
|
+
|
|
1437
|
+
<button onclick={addNote} aria-keyshortcuts={hint.ariaKeyshortcuts}>
|
|
1438
|
+
New note ({count}) <kbd aria-hidden="true">{hint.text}</kbd>
|
|
1439
|
+
</button>
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
Call the helper in the component's script. It unregisters when the component goes away. Keys and options can be getters; return `null` for keys to leave the shortcut unregistered.
|
|
1443
|
+
|
|
1444
|
+
#### Show the Keys
|
|
1445
|
+
|
|
1446
|
+
`useShortcutHint` supplies display text and `aria-keyshortcuts`. It keeps the server and first client render consistent, then updates for the user's platform after mount.
|
|
1447
|
+
|
|
1448
|
+
Its fields are reactive getters. Read `hint.text` and `hint.ariaKeyshortcuts` in markup.
|
|
1449
|
+
|
|
1450
|
+
Outside rendering, use `formatShortcut` for display text or `ariaKeyshortcuts` for the ARIA value, from the same entry. The hint's text and `formatShortcut` both keep their left-to-right order on a right-to-left page, because two invisible characters wrap the text. Compare the original keys, not the formatted hint.
|
|
1451
|
+
|
|
1452
|
+
#### While Someone Is Typing
|
|
1453
|
+
|
|
1454
|
+
Shortcuts with Command, Control, or Option can run in text fields. Plain letters and other keys stay available for typing. Set `allowInInput: true` when a shortcut should work there too, such as Escape to clear a search. A shortcut runs once per press. Set `repeat: true` to keep it running while the keys are held, like `j` moving down a list.
|
|
1455
|
+
|
|
1456
|
+
#### Limit a Shortcut to an Area
|
|
1457
|
+
|
|
1458
|
+
Use a named `scope` for an editor or another area. Turn it on while that area has focus:
|
|
1459
|
+
|
|
1460
|
+
```svelte
|
|
1461
|
+
<script lang="ts">
|
|
1462
|
+
import { shortcuts, useShortcut } from "@ui-sdk/svelte/shortcuts"
|
|
1463
|
+
import { onDestroy } from "svelte"
|
|
1464
|
+
|
|
1465
|
+
let text = $state("")
|
|
1466
|
+
useShortcut(
|
|
1467
|
+
"escape",
|
|
1468
|
+
() => {
|
|
1469
|
+
text = ""
|
|
1470
|
+
},
|
|
1471
|
+
{ scope: "note", allowInInput: true }
|
|
1472
|
+
)
|
|
1473
|
+
onDestroy(() => shortcuts.setScope("note", false))
|
|
1474
|
+
</script>
|
|
1475
|
+
|
|
1476
|
+
<textarea
|
|
1477
|
+
aria-label="Note"
|
|
1478
|
+
bind:value={text}
|
|
1479
|
+
onfocus={() => shortcuts.setScope("note", true)}
|
|
1480
|
+
onblur={() => shortcuts.setScope("note", false)}
|
|
1481
|
+
/>
|
|
1482
|
+
```
|
|
1483
|
+
|
|
1484
|
+
Scope names are shared, so choose one for each area you want to enable together. A `when` function can add another condition, checked each time the keys are pressed.
|
|
1485
|
+
|
|
1486
|
+
Focus the note and type some text. Press Command+Enter on Mac or Control+Enter elsewhere to save, or Escape to clear it. Move focus outside the note to turn off its shortcuts.
|
|
1487
|
+
|
|
1488
|
+
#### Inside a Popup
|
|
1489
|
+
|
|
1490
|
+
Page shortcuts pause while a modal is open. Pass `layer`, an element inside the popup or a getter that returns one, to make a shortcut belong to that popup. It runs only while that popup is open.
|
|
1491
|
+
|
|
1492
|
+
When shortcuts share the same keys, the topmost open layer wins, then the most recently registered shortcut.
|
|
1493
|
+
|
|
1494
|
+
#### List Available Shortcuts
|
|
1495
|
+
|
|
1496
|
+
Call `shortcuts.list()` when a help screen opens. It returns the shortcuts that can run now, including their `keys`, formatted `hint`, and `description`. Add descriptions when registering shortcuts so the help screen can explain each action.
|