@spinjs/components 0.0.0-stage → 0.1.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/angle-slider/angle-slider.events.d.ts +30 -0
- package/dist/angle-slider/angle-slider.events.js +1 -0
- package/dist/angle-slider/angle-slider.machine.d.ts +9 -0
- package/dist/angle-slider/angle-slider.machine.js +56 -0
- package/dist/angle-slider/angle-slider.presentation.d.ts +194 -0
- package/dist/angle-slider/angle-slider.presentation.js +277 -0
- package/dist/angle-slider/angle-slider.state.d.ts +38 -0
- package/dist/angle-slider/angle-slider.state.js +71 -0
- package/dist/angle-slider/angle-slider.transitions.d.ts +11 -0
- package/dist/angle-slider/angle-slider.transitions.js +18 -0
- package/dist/angle-slider/examples/basic.html +42 -0
- package/dist/angle-slider/examples/knob.html +34 -0
- package/dist/angle-slider/examples/labeled.html +63 -0
- package/dist/angle-slider/examples/marks.html +42 -0
- package/dist/async-list/async-list.events.d.ts +23 -0
- package/dist/async-list/async-list.events.js +1 -0
- package/dist/async-list/async-list.machine.d.ts +5 -0
- package/dist/async-list/async-list.machine.js +96 -0
- package/dist/async-list/async-list.presentation.d.ts +294 -0
- package/dist/async-list/async-list.presentation.js +380 -0
- package/dist/async-list/async-list.state.d.ts +27 -0
- package/dist/async-list/async-list.state.js +31 -0
- package/dist/async-list/async-list.transitions.d.ts +16 -0
- package/dist/async-list/async-list.transitions.js +17 -0
- package/dist/async-list/examples/basic.html +88 -0
- package/dist/avatar/avatar.events.d.ts +18 -0
- package/dist/avatar/avatar.events.js +1 -0
- package/dist/avatar/avatar.machine.d.ts +5 -0
- package/dist/avatar/avatar.machine.js +47 -0
- package/dist/avatar/avatar.presentation.d.ts +75 -0
- package/dist/avatar/avatar.presentation.js +68 -0
- package/dist/avatar/avatar.state.d.ts +28 -0
- package/dist/avatar/avatar.state.js +20 -0
- package/dist/avatar/avatar.transitions.d.ts +7 -0
- package/dist/avatar/avatar.transitions.js +5 -0
- package/dist/avatar/examples/badge.html +24 -0
- package/dist/avatar/examples/badgeminimal.html +16 -0
- package/dist/avatar/examples/basic.html +24 -0
- package/dist/avatar/examples/count.html +29 -0
- package/dist/avatar/examples/fallback.html +24 -0
- package/dist/avatar/examples/group.html +28 -0
- package/dist/avatar/examples/icon.html +15 -0
- package/dist/avatar/examples/multiples.html +48 -0
- package/dist/avatar/examples/pills.html +58 -0
- package/dist/avatar/examples/pillsolid.html +21 -0
- package/dist/avatar/examples/rounded.html +13 -0
- package/dist/avatar/examples/status.html +24 -0
- package/dist/avatar/examples/statusminimal.html +16 -0
- package/dist/avatar/examples/trusted.html +33 -0
- package/dist/avatar/examples/verification.html +18 -0
- package/dist/carousel/carousel.events.d.ts +50 -0
- package/dist/carousel/carousel.events.js +1 -0
- package/dist/carousel/carousel.machine.d.ts +6 -0
- package/dist/carousel/carousel.machine.js +70 -0
- package/dist/carousel/carousel.presentation.d.ts +379 -0
- package/dist/carousel/carousel.presentation.js +554 -0
- package/dist/carousel/carousel.state.d.ts +61 -0
- package/dist/carousel/carousel.state.js +93 -0
- package/dist/carousel/carousel.transitions.d.ts +20 -0
- package/dist/carousel/carousel.transitions.js +49 -0
- package/dist/carousel/examples/autoplay.html +69 -0
- package/dist/carousel/examples/basic.html +56 -0
- package/dist/carousel/examples/cards.html +71 -0
- package/dist/carousel/examples/hero.html +54 -0
- package/dist/carousel/examples/infinite.html +68 -0
- package/dist/carousel/examples/minimal.html +47 -0
- package/dist/carousel/examples/testimonials.html +78 -0
- package/dist/carousel/examples/thumbnails.html +67 -0
- package/dist/carousel/examples/vertical.html +67 -0
- package/dist/cascade-select/cascade.events.d.ts +42 -0
- package/dist/cascade-select/cascade.events.js +1 -0
- package/dist/cascade-select/cascade.machine.d.ts +7 -0
- package/dist/cascade-select/cascade.machine.js +118 -0
- package/dist/cascade-select/cascade.presentation.d.ts +415 -0
- package/dist/cascade-select/cascade.presentation.js +771 -0
- package/dist/cascade-select/cascade.state.d.ts +58 -0
- package/dist/cascade-select/cascade.state.js +97 -0
- package/dist/cascade-select/cascade.transitions.d.ts +21 -0
- package/dist/cascade-select/cascade.transitions.js +54 -0
- package/dist/cascade-select/examples/basic.html +77 -0
- package/dist/color-picker/color-picker.events.d.ts +83 -0
- package/dist/color-picker/color-picker.events.js +1 -0
- package/dist/color-picker/color-picker.machine.d.ts +5 -0
- package/dist/color-picker/color-picker.machine.js +130 -0
- package/dist/color-picker/color-picker.presentation.d.ts +402 -0
- package/dist/color-picker/color-picker.presentation.js +761 -0
- package/dist/color-picker/color-picker.state.d.ts +41 -0
- package/dist/color-picker/color-picker.state.js +71 -0
- package/dist/color-picker/color-picker.transitions.d.ts +21 -0
- package/dist/color-picker/color-picker.transitions.js +99 -0
- package/dist/color-picker/examples/basic.html +106 -0
- package/dist/color-picker/examples/hue-wheel.html +57 -0
- package/dist/color-picker/examples/inline.html +61 -0
- package/dist/color-picker/examples/with-presets.html +49 -0
- package/dist/combobox/combobox.events.d.ts +61 -0
- package/dist/combobox/combobox.events.js +1 -0
- package/dist/combobox/combobox.machine.d.ts +7 -0
- package/dist/combobox/combobox.machine.js +234 -0
- package/dist/combobox/combobox.presentation.d.ts +433 -0
- package/dist/combobox/combobox.presentation.js +746 -0
- package/dist/combobox/combobox.state.d.ts +80 -0
- package/dist/combobox/combobox.state.js +71 -0
- package/dist/combobox/combobox.transitions.d.ts +28 -0
- package/dist/combobox/combobox.transitions.js +91 -0
- package/dist/combobox/examples/basic.html +61 -0
- package/dist/combobox/examples/directory.html +71 -0
- package/dist/combobox/examples/grouping.html +36 -0
- package/dist/combobox/examples/multiple.html +37 -0
- package/dist/controller.d.ts +52 -0
- package/dist/controller.js +90 -0
- package/dist/date-input/date-input.events.d.ts +37 -0
- package/dist/date-input/date-input.events.js +1 -0
- package/dist/date-input/date-input.machine.d.ts +6 -0
- package/dist/date-input/date-input.machine.js +61 -0
- package/dist/date-input/date-input.presentation.d.ts +133 -0
- package/dist/date-input/date-input.presentation.js +328 -0
- package/dist/date-input/date-input.state.d.ts +77 -0
- package/dist/date-input/date-input.state.js +260 -0
- package/dist/date-input/date-input.transitions.d.ts +22 -0
- package/dist/date-input/date-input.transitions.js +166 -0
- package/dist/date-input/examples/basic.html +18 -0
- package/dist/date-picker/date-picker.events.d.ts +42 -0
- package/dist/date-picker/date-picker.events.js +1 -0
- package/dist/date-picker/date-picker.machine.d.ts +6 -0
- package/dist/date-picker/date-picker.machine.js +102 -0
- package/dist/date-picker/date-picker.presentation.d.ts +256 -0
- package/dist/date-picker/date-picker.presentation.js +549 -0
- package/dist/date-picker/date-picker.state.d.ts +66 -0
- package/dist/date-picker/date-picker.state.js +177 -0
- package/dist/date-picker/date-picker.transitions.d.ts +23 -0
- package/dist/date-picker/date-picker.transitions.js +94 -0
- package/dist/date-picker/examples/appointment.html +49 -0
- package/dist/date-picker/examples/basic.html +6 -0
- package/dist/date-picker/examples/multiple.html +6 -0
- package/dist/date-picker/examples/pricing.html +6 -0
- package/dist/date-picker/examples/range.html +6 -0
- package/dist/date-picker/examples/unavailable.html +6 -0
- package/dist/editable/editable.events.d.ts +29 -0
- package/dist/editable/editable.events.js +1 -0
- package/dist/editable/editable.machine.d.ts +5 -0
- package/dist/editable/editable.machine.js +82 -0
- package/dist/editable/editable.presentation.d.ts +278 -0
- package/dist/editable/editable.presentation.js +388 -0
- package/dist/editable/editable.state.d.ts +54 -0
- package/dist/editable/editable.state.js +32 -0
- package/dist/editable/editable.transitions.d.ts +11 -0
- package/dist/editable/editable.transitions.js +9 -0
- package/dist/editable/examples/basic.html +43 -0
- package/dist/editable/examples/doubleclick.html +19 -0
- package/dist/editable/examples/inline-edit.html +13 -0
- package/dist/editable/examples/profile-field.html +20 -0
- package/dist/editable/examples/resize.html +19 -0
- package/dist/editable/examples/task-item.html +19 -0
- package/dist/editable/examples/title-editor.html +13 -0
- package/dist/editable/examples/with-controls.html +20 -0
- package/dist/file-upload/examples/avatar.html +34 -0
- package/dist/file-upload/examples/basic.html +34 -0
- package/dist/file-upload/examples/directory.html +34 -0
- package/dist/file-upload/examples/dragdrop.html +31 -0
- package/dist/file-upload/examples/files.html +39 -0
- package/dist/file-upload/examples/images.html +40 -0
- package/dist/file-upload/examples/paste.html +30 -0
- package/dist/file-upload/examples/table.html +39 -0
- package/dist/file-upload/file-upload.events.d.ts +27 -0
- package/dist/file-upload/file-upload.events.js +1 -0
- package/dist/file-upload/file-upload.machine.d.ts +6 -0
- package/dist/file-upload/file-upload.machine.js +59 -0
- package/dist/file-upload/file-upload.presentation.d.ts +182 -0
- package/dist/file-upload/file-upload.presentation.js +256 -0
- package/dist/file-upload/file-upload.state.d.ts +52 -0
- package/dist/file-upload/file-upload.state.js +72 -0
- package/dist/file-upload/file-upload.transitions.d.ts +11 -0
- package/dist/file-upload/file-upload.transitions.js +32 -0
- package/dist/floating-panel/examples/basic.html +42 -0
- package/dist/floating-panel/examples/calculator.html +56 -0
- package/dist/floating-panel/examples/chat.html +45 -0
- package/dist/floating-panel/examples/media-player.html +54 -0
- package/dist/floating-panel/examples/notes.html +60 -0
- package/dist/floating-panel/examples/settings.html +73 -0
- package/dist/floating-panel/examples/task.html +79 -0
- package/dist/floating-panel/examples/video-call.html +47 -0
- package/dist/floating-panel/floating-panel.events.d.ts +45 -0
- package/dist/floating-panel/floating-panel.events.js +1 -0
- package/dist/floating-panel/floating-panel.machine.d.ts +6 -0
- package/dist/floating-panel/floating-panel.machine.js +70 -0
- package/dist/floating-panel/floating-panel.presentation.d.ts +239 -0
- package/dist/floating-panel/floating-panel.presentation.js +271 -0
- package/dist/floating-panel/floating-panel.state.d.ts +67 -0
- package/dist/floating-panel/floating-panel.state.js +76 -0
- package/dist/floating-panel/floating-panel.transitions.d.ts +22 -0
- package/dist/floating-panel/floating-panel.transitions.js +114 -0
- package/dist/hover-card/examples/basic.html +19 -0
- package/dist/hover-card/examples/controlled.html +32 -0
- package/dist/hover-card/examples/custom-positioning.html +29 -0
- package/dist/hover-card/examples/link.html +10 -0
- package/dist/hover-card/examples/product.html +33 -0
- package/dist/hover-card/examples/user.html +38 -0
- package/dist/hover-card/examples/with-arrow.html +29 -0
- package/dist/hover-card/hover-card.controller-def.d.ts +50 -0
- package/dist/hover-card/hover-card.controller-def.js +134 -0
- package/dist/image-cropper/crop-geometry.d.ts +133 -0
- package/dist/image-cropper/crop-geometry.js +453 -0
- package/dist/image-cropper/examples/basic.html +44 -0
- package/dist/image-cropper/examples/circle.html +44 -0
- package/dist/image-cropper/image-cropper.events.d.ts +108 -0
- package/dist/image-cropper/image-cropper.events.js +1 -0
- package/dist/image-cropper/image-cropper.machine.d.ts +5 -0
- package/dist/image-cropper/image-cropper.machine.js +231 -0
- package/dist/image-cropper/image-cropper.presentation.d.ts +295 -0
- package/dist/image-cropper/image-cropper.presentation.js +536 -0
- package/dist/image-cropper/image-cropper.state.d.ts +94 -0
- package/dist/image-cropper/image-cropper.state.js +134 -0
- package/dist/image-cropper/image-cropper.transitions.d.ts +13 -0
- package/dist/image-cropper/image-cropper.transitions.js +11 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +279 -0
- package/dist/listbox/examples/basic.html +50 -0
- package/dist/listbox/examples/controlled.html +54 -0
- package/dist/listbox/examples/countries.html +61 -0
- package/dist/listbox/examples/grouped.html +58 -0
- package/dist/listbox/examples/icons.html +56 -0
- package/dist/listbox/examples/multiple.html +56 -0
- package/dist/listbox/examples/priority.html +50 -0
- package/dist/listbox/examples/settings.html +64 -0
- package/dist/listbox/listbox.events.d.ts +42 -0
- package/dist/listbox/listbox.events.js +1 -0
- package/dist/listbox/listbox.machine.d.ts +6 -0
- package/dist/listbox/listbox.machine.js +51 -0
- package/dist/listbox/listbox.presentation.d.ts +294 -0
- package/dist/listbox/listbox.presentation.js +493 -0
- package/dist/listbox/listbox.state.d.ts +55 -0
- package/dist/listbox/listbox.state.js +59 -0
- package/dist/listbox/listbox.transitions.d.ts +20 -0
- package/dist/listbox/listbox.transitions.js +73 -0
- package/dist/menu/examples/basic.html +75 -0
- package/dist/menu/examples/context.html +74 -0
- package/dist/menu/examples/groups.html +88 -0
- package/dist/menu/examples/icons.html +80 -0
- package/dist/menu/examples/nested.html +83 -0
- package/dist/menu/examples/user.html +87 -0
- package/dist/menu/menu.events.d.ts +42 -0
- package/dist/menu/menu.events.js +1 -0
- package/dist/menu/menu.machine.d.ts +6 -0
- package/dist/menu/menu.machine.js +148 -0
- package/dist/menu/menu.presentation.d.ts +252 -0
- package/dist/menu/menu.presentation.js +709 -0
- package/dist/menu/menu.state.d.ts +54 -0
- package/dist/menu/menu.state.js +55 -0
- package/dist/mode-picker/examples/basic.html +17 -0
- package/dist/mode-picker/examples/minimal.html +17 -0
- package/dist/mode-picker/examples/pill.html +17 -0
- package/dist/mode-picker/mode-picker.events.d.ts +20 -0
- package/dist/mode-picker/mode-picker.events.js +1 -0
- package/dist/mode-picker/mode-picker.machine.d.ts +5 -0
- package/dist/mode-picker/mode-picker.machine.js +29 -0
- package/dist/mode-picker/mode-picker.presentation.d.ts +129 -0
- package/dist/mode-picker/mode-picker.presentation.js +175 -0
- package/dist/mode-picker/mode-picker.state.d.ts +27 -0
- package/dist/mode-picker/mode-picker.state.js +56 -0
- package/dist/mode-picker/mode-picker.transitions.d.ts +11 -0
- package/dist/mode-picker/mode-picker.transitions.js +32 -0
- package/dist/navigation-menu/examples/basic.html +72 -0
- package/dist/navigation-menu/examples/grouped.html +91 -0
- package/dist/navigation-menu/examples/minimal.html +49 -0
- package/dist/navigation-menu/navigation-menu.events.d.ts +20 -0
- package/dist/navigation-menu/navigation-menu.events.js +1 -0
- package/dist/navigation-menu/navigation-menu.machine.d.ts +6 -0
- package/dist/navigation-menu/navigation-menu.machine.js +51 -0
- package/dist/navigation-menu/navigation-menu.presentation.d.ts +132 -0
- package/dist/navigation-menu/navigation-menu.presentation.js +151 -0
- package/dist/navigation-menu/navigation-menu.state.d.ts +33 -0
- package/dist/navigation-menu/navigation-menu.state.js +49 -0
- package/dist/navigation-menu/navigation-menu.transitions.d.ts +11 -0
- package/dist/navigation-menu/navigation-menu.transitions.js +32 -0
- package/dist/number-input/examples/basic.html +49 -0
- package/dist/number-input/examples/currency.html +33 -0
- package/dist/number-input/examples/decimal.html +33 -0
- package/dist/number-input/examples/limits.html +42 -0
- package/dist/number-input/examples/percentage.html +38 -0
- package/dist/number-input/examples/quantity.html +35 -0
- package/dist/number-input/examples/scrubber.html +46 -0
- package/dist/number-input/examples/wheel.html +42 -0
- package/dist/number-input/number-input.events.d.ts +66 -0
- package/dist/number-input/number-input.events.js +1 -0
- package/dist/number-input/number-input.machine.d.ts +5 -0
- package/dist/number-input/number-input.machine.js +132 -0
- package/dist/number-input/number-input.presentation.d.ts +292 -0
- package/dist/number-input/number-input.presentation.js +449 -0
- package/dist/number-input/number-input.state.d.ts +71 -0
- package/dist/number-input/number-input.state.js +86 -0
- package/dist/number-input/number-input.transitions.d.ts +17 -0
- package/dist/number-input/number-input.transitions.js +40 -0
- package/dist/pagination/examples/basic.html +39 -0
- package/dist/pagination/examples/dropdown.html +37 -0
- package/dist/pagination/examples/info.html +41 -0
- package/dist/pagination/examples/jump.html +38 -0
- package/dist/pagination/examples/numbered.html +31 -0
- package/dist/pagination/examples/pagesize.html +46 -0
- package/dist/pagination/pagination.events.d.ts +36 -0
- package/dist/pagination/pagination.events.js +1 -0
- package/dist/pagination/pagination.machine.d.ts +6 -0
- package/dist/pagination/pagination.machine.js +45 -0
- package/dist/pagination/pagination.presentation.d.ts +161 -0
- package/dist/pagination/pagination.presentation.js +162 -0
- package/dist/pagination/pagination.state.d.ts +44 -0
- package/dist/pagination/pagination.state.js +115 -0
- package/dist/pagination/pagination.transitions.d.ts +17 -0
- package/dist/pagination/pagination.transitions.js +30 -0
- package/dist/pin-input/examples/basic.html +23 -0
- package/dist/pin-input/examples/field.html +25 -0
- package/dist/pin-input/examples/masked.html +23 -0
- package/dist/pin-input/examples/placeholder.html +24 -0
- package/dist/pin-input/examples/twofactor.html +25 -0
- package/dist/pin-input/examples/verification.html +32 -0
- package/dist/pin-input/pin-input.events.d.ts +48 -0
- package/dist/pin-input/pin-input.events.js +1 -0
- package/dist/pin-input/pin-input.machine.d.ts +5 -0
- package/dist/pin-input/pin-input.machine.js +99 -0
- package/dist/pin-input/pin-input.presentation.d.ts +204 -0
- package/dist/pin-input/pin-input.presentation.js +392 -0
- package/dist/pin-input/pin-input.state.d.ts +67 -0
- package/dist/pin-input/pin-input.state.js +63 -0
- package/dist/pin-input/pin-input.transitions.d.ts +10 -0
- package/dist/pin-input/pin-input.transitions.js +22 -0
- package/dist/popover/examples/basic.html +15 -0
- package/dist/popover/examples/feedback.html +17 -0
- package/dist/popover/examples/notifications.html +21 -0
- package/dist/popover/examples/settings.html +39 -0
- package/dist/popover/examples/share.html +18 -0
- package/dist/popover/examples/user.html +43 -0
- package/dist/popover/popover.controller-def.d.ts +39 -0
- package/dist/popover/popover.controller-def.js +74 -0
- package/dist/rating-group/examples/basic.html +39 -0
- package/dist/rating-group/examples/movie.html +45 -0
- package/dist/rating-group/examples/product-review.html +52 -0
- package/dist/rating-group/examples/service-evaluation.html +31 -0
- package/dist/rating-group/rating-group.events.d.ts +38 -0
- package/dist/rating-group/rating-group.events.js +1 -0
- package/dist/rating-group/rating-group.machine.d.ts +6 -0
- package/dist/rating-group/rating-group.machine.js +70 -0
- package/dist/rating-group/rating-group.presentation.d.ts +144 -0
- package/dist/rating-group/rating-group.presentation.js +208 -0
- package/dist/rating-group/rating-group.state.d.ts +36 -0
- package/dist/rating-group/rating-group.state.js +41 -0
- package/dist/rating-group/rating-group.transitions.d.ts +16 -0
- package/dist/rating-group/rating-group.transitions.js +15 -0
- package/dist/react/react.d.ts +29 -0
- package/dist/react/react.js +8 -0
- package/dist/select/examples/basic.html +72 -0
- package/dist/select/examples/category.html +67 -0
- package/dist/select/examples/country.html +65 -0
- package/dist/select/examples/language.html +19 -0
- package/dist/select/examples/multiple.html +20 -0
- package/dist/select/examples/profile.html +73 -0
- package/dist/select/examples/theme.html +11 -0
- package/dist/select/examples/with-overlapping-label.html +57 -0
- package/dist/select/select.events.d.ts +59 -0
- package/dist/select/select.events.js +1 -0
- package/dist/select/select.machine.d.ts +6 -0
- package/dist/select/select.machine.js +203 -0
- package/dist/select/select.presentation.d.ts +358 -0
- package/dist/select/select.presentation.js +509 -0
- package/dist/select/select.shared.d.ts +8 -0
- package/dist/select/select.shared.js +13 -0
- package/dist/select/select.state.d.ts +51 -0
- package/dist/select/select.state.js +69 -0
- package/dist/select/select.transitions.d.ts +15 -0
- package/dist/select/select.transitions.js +27 -0
- package/dist/shared/keyboard.d.ts +29 -0
- package/dist/shared/keyboard.js +13 -0
- package/dist/signature-pad/examples/basic.html +29 -0
- package/dist/signature-pad/examples/contract.html +36 -0
- package/dist/signature-pad/examples/receipt.html +40 -0
- package/dist/signature-pad/examples/with-preview.html +40 -0
- package/dist/signature-pad/signature-pad.events.d.ts +26 -0
- package/dist/signature-pad/signature-pad.events.js +1 -0
- package/dist/signature-pad/signature-pad.machine.d.ts +7 -0
- package/dist/signature-pad/signature-pad.machine.js +44 -0
- package/dist/signature-pad/signature-pad.presentation.d.ts +184 -0
- package/dist/signature-pad/signature-pad.presentation.js +236 -0
- package/dist/signature-pad/signature-pad.state.d.ts +40 -0
- package/dist/signature-pad/signature-pad.state.js +94 -0
- package/dist/signature-pad/signature-pad.transitions.d.ts +12 -0
- package/dist/signature-pad/signature-pad.transitions.js +40 -0
- package/dist/slider/examples/basic.html +32 -0
- package/dist/slider/examples/equalizer.html +119 -0
- package/dist/slider/examples/fractional.html +7 -0
- package/dist/slider/examples/marks.html +42 -0
- package/dist/slider/examples/range.html +31 -0
- package/dist/slider/examples/stepped.html +7 -0
- package/dist/slider/examples/ticks.html +72 -0
- package/dist/slider/examples/vertical.html +30 -0
- package/dist/slider/slider.events.d.ts +50 -0
- package/dist/slider/slider.events.js +1 -0
- package/dist/slider/slider.machine.d.ts +5 -0
- package/dist/slider/slider.machine.js +86 -0
- package/dist/slider/slider.presentation.d.ts +252 -0
- package/dist/slider/slider.presentation.js +322 -0
- package/dist/slider/slider.state.d.ts +72 -0
- package/dist/slider/slider.state.js +91 -0
- package/dist/slider/slider.transitions.d.ts +17 -0
- package/dist/slider/slider.transitions.js +62 -0
- package/dist/solid/solid.d.ts +36 -0
- package/dist/solid/solid.js +10 -0
- package/dist/spin-element.d.ts +13 -0
- package/dist/spin-element.js +38 -0
- package/dist/splitter/examples/basic.html +22 -0
- package/dist/splitter/examples/nested.html +41 -0
- package/dist/splitter/examples/threepanels.html +23 -0
- package/dist/splitter/examples/vertical.html +23 -0
- package/dist/splitter/splitter.events.d.ts +52 -0
- package/dist/splitter/splitter.events.js +1 -0
- package/dist/splitter/splitter.machine.d.ts +6 -0
- package/dist/splitter/splitter.machine.js +78 -0
- package/dist/splitter/splitter.presentation.d.ts +204 -0
- package/dist/splitter/splitter.presentation.js +443 -0
- package/dist/splitter/splitter.state.d.ts +48 -0
- package/dist/splitter/splitter.state.js +225 -0
- package/dist/splitter/splitter.transitions.d.ts +20 -0
- package/dist/splitter/splitter.transitions.js +132 -0
- package/dist/steps/examples/basic.html +57 -0
- package/dist/steps/examples/checkmarks.html +32 -0
- package/dist/steps/examples/content.html +45 -0
- package/dist/steps/examples/descriptions.html +26 -0
- package/dist/steps/examples/icons.html +26 -0
- package/dist/steps/examples/lines.html +26 -0
- package/dist/steps/examples/navigation.html +41 -0
- package/dist/steps/examples/onboarding.html +32 -0
- package/dist/steps/examples/progress.html +47 -0
- package/dist/steps/examples/segmented.html +40 -0
- package/dist/steps/examples/vertical.html +58 -0
- package/dist/steps/examples/verticallabels.html +27 -0
- package/dist/steps/examples/verticalnavigation.html +36 -0
- package/dist/steps/steps.events.d.ts +27 -0
- package/dist/steps/steps.events.js +1 -0
- package/dist/steps/steps.machine.d.ts +6 -0
- package/dist/steps/steps.machine.js +36 -0
- package/dist/steps/steps.presentation.d.ts +177 -0
- package/dist/steps/steps.presentation.js +248 -0
- package/dist/steps/steps.state.d.ts +39 -0
- package/dist/steps/steps.state.js +47 -0
- package/dist/steps/steps.transitions.d.ts +15 -0
- package/dist/steps/steps.transitions.js +39 -0
- package/dist/tabs/examples/basic.html +41 -0
- package/dist/tabs/examples/dashboard.html +116 -0
- package/dist/tabs/examples/ghost.html +28 -0
- package/dist/tabs/examples/icon-above.html +50 -0
- package/dist/tabs/examples/icon-only.html +37 -0
- package/dist/tabs/examples/outline-with-icons.html +50 -0
- package/dist/tabs/examples/outline.html +29 -0
- package/dist/tabs/examples/pills.html +40 -0
- package/dist/tabs/examples/project.html +87 -0
- package/dist/tabs/examples/settings.html +100 -0
- package/dist/tabs/examples/stack-with-icons.html +51 -0
- package/dist/tabs/examples/stack.html +28 -0
- package/dist/tabs/examples/underline.html +41 -0
- package/dist/tabs/examples/vertical-ghost.html +44 -0
- package/dist/tabs/examples/vertical-icons.html +44 -0
- package/dist/tabs/examples/vertical-underline.html +45 -0
- package/dist/tabs/examples/vertical-with-icons.html +53 -0
- package/dist/tabs/examples/vertical.html +42 -0
- package/dist/tabs/examples/with-badges.html +43 -0
- package/dist/tabs/examples/with-icons.html +42 -0
- package/dist/tabs/tabs.events.d.ts +19 -0
- package/dist/tabs/tabs.events.js +1 -0
- package/dist/tabs/tabs.machine.d.ts +5 -0
- package/dist/tabs/tabs.machine.js +54 -0
- package/dist/tabs/tabs.presentation.d.ts +83 -0
- package/dist/tabs/tabs.presentation.js +94 -0
- package/dist/tabs/tabs.state.d.ts +61 -0
- package/dist/tabs/tabs.state.js +53 -0
- package/dist/tabs/tabs.transitions.d.ts +8 -0
- package/dist/tabs/tabs.transitions.js +6 -0
- package/dist/tags-input/examples/basic.html +43 -0
- package/dist/tags-input/examples/with-combobox.html +64 -0
- package/dist/tags-input/tags.events.d.ts +77 -0
- package/dist/tags-input/tags.events.js +1 -0
- package/dist/tags-input/tags.machine.d.ts +6 -0
- package/dist/tags-input/tags.machine.js +311 -0
- package/dist/tags-input/tags.presentation.d.ts +376 -0
- package/dist/tags-input/tags.presentation.js +782 -0
- package/dist/tags-input/tags.state.d.ts +109 -0
- package/dist/tags-input/tags.state.js +111 -0
- package/dist/tags-input/tags.transitions.d.ts +23 -0
- package/dist/tags-input/tags.transitions.js +101 -0
- package/dist/theme-picker/examples/basic.html +52 -0
- package/dist/theme-picker/examples/cards.html +32 -0
- package/dist/theme-picker/examples/compact.html +42 -0
- package/dist/theme-picker/examples/swatches.html +31 -0
- package/dist/theme-picker/theme-picker.events.d.ts +32 -0
- package/dist/theme-picker/theme-picker.events.js +1 -0
- package/dist/theme-picker/theme-picker.machine.d.ts +5 -0
- package/dist/theme-picker/theme-picker.machine.js +65 -0
- package/dist/theme-picker/theme-picker.presentation.d.ts +198 -0
- package/dist/theme-picker/theme-picker.presentation.js +306 -0
- package/dist/theme-picker/theme-picker.state.d.ts +40 -0
- package/dist/theme-picker/theme-picker.state.js +108 -0
- package/dist/theme-picker/theme-picker.transitions.d.ts +17 -0
- package/dist/theme-picker/theme-picker.transitions.js +62 -0
- package/dist/timer/examples/basic.html +36 -0
- package/dist/timer/examples/card.html +45 -0
- package/dist/timer/examples/compact.html +32 -0
- package/dist/timer/examples/countdown.html +45 -0
- package/dist/timer/examples/labels.html +43 -0
- package/dist/timer/examples/large.html +38 -0
- package/dist/timer/examples/minimal.html +21 -0
- package/dist/timer/examples/pomodoro.html +45 -0
- package/dist/timer/examples/workout.html +47 -0
- package/dist/timer/timer.events.d.ts +18 -0
- package/dist/timer/timer.events.js +1 -0
- package/dist/timer/timer.machine.d.ts +5 -0
- package/dist/timer/timer.machine.js +50 -0
- package/dist/timer/timer.presentation.d.ts +248 -0
- package/dist/timer/timer.presentation.js +265 -0
- package/dist/timer/timer.state.d.ts +29 -0
- package/dist/timer/timer.state.js +64 -0
- package/dist/timer/timer.transitions.d.ts +11 -0
- package/dist/timer/timer.transitions.js +35 -0
- package/dist/toast/examples/action.html +40 -0
- package/dist/toast/examples/basic.html +37 -0
- package/dist/toast/examples/bottomcenter.html +37 -0
- package/dist/toast/examples/bottomleft.html +37 -0
- package/dist/toast/examples/bottomright.html +37 -0
- package/dist/toast/examples/duration.html +36 -0
- package/dist/toast/examples/promise.html +44 -0
- package/dist/toast/examples/topcenter.html +37 -0
- package/dist/toast/examples/topleft.html +37 -0
- package/dist/toast/examples/topright.html +37 -0
- package/dist/toast/examples/types.html +47 -0
- package/dist/toast/examples/updatable.html +8 -0
- package/dist/toast/toast.events.d.ts +60 -0
- package/dist/toast/toast.events.js +1 -0
- package/dist/toast/toast.machine.d.ts +6 -0
- package/dist/toast/toast.machine.js +97 -0
- package/dist/toast/toast.presentation.d.ts +284 -0
- package/dist/toast/toast.presentation.js +532 -0
- package/dist/toast/toast.state.d.ts +65 -0
- package/dist/toast/toast.state.js +88 -0
- package/dist/toast/toast.transitions.d.ts +24 -0
- package/dist/toast/toast.transitions.js +85 -0
- package/dist/toggle-group/examples/basic.html +25 -0
- package/dist/toggle-group/examples/ghost.html +22 -0
- package/dist/toggle-group/examples/icons.html +25 -0
- package/dist/toggle-group/examples/multiple.html +14 -0
- package/dist/toggle-group/examples/outline.html +25 -0
- package/dist/toggle-group/examples/toolbar.html +25 -0
- package/dist/toggle-group/toggle-group.events.d.ts +45 -0
- package/dist/toggle-group/toggle-group.events.js +1 -0
- package/dist/toggle-group/toggle-group.machine.d.ts +5 -0
- package/dist/toggle-group/toggle-group.machine.js +65 -0
- package/dist/toggle-group/toggle-group.presentation.d.ts +112 -0
- package/dist/toggle-group/toggle-group.presentation.js +217 -0
- package/dist/toggle-group/toggle-group.state.d.ts +45 -0
- package/dist/toggle-group/toggle-group.state.js +67 -0
- package/dist/toggle-group/toggle-group.transitions.d.ts +10 -0
- package/dist/toggle-group/toggle-group.transitions.js +9 -0
- package/dist/tooltip/examples/basic.html +13 -0
- package/dist/tooltip/examples/metrics.html +30 -0
- package/dist/tooltip/examples/positioning.html +26 -0
- package/dist/tooltip/examples/status.html +33 -0
- package/dist/tooltip/examples/video.html +22 -0
- package/dist/tooltip/examples/with-arrow.html +14 -0
- package/dist/tooltip/tooltip.controller-def.d.ts +42 -0
- package/dist/tooltip/tooltip.controller-def.js +110 -0
- package/dist/tour/examples/basic.html +67 -0
- package/dist/tour/tour.events.d.ts +32 -0
- package/dist/tour/tour.events.js +1 -0
- package/dist/tour/tour.machine.d.ts +5 -0
- package/dist/tour/tour.machine.js +77 -0
- package/dist/tour/tour.presentation.d.ts +260 -0
- package/dist/tour/tour.presentation.js +272 -0
- package/dist/tour/tour.state.d.ts +43 -0
- package/dist/tour/tour.state.js +60 -0
- package/dist/tour/tour.transitions.d.ts +16 -0
- package/dist/tour/tour.transitions.js +32 -0
- package/dist/tree-view/examples/basic.html +47 -0
- package/dist/tree-view/examples/loading.html +57 -0
- package/dist/tree-view/tree-view.events.d.ts +67 -0
- package/dist/tree-view/tree-view.events.js +1 -0
- package/dist/tree-view/tree-view.machine.d.ts +6 -0
- package/dist/tree-view/tree-view.machine.js +86 -0
- package/dist/tree-view/tree-view.presentation.d.ts +254 -0
- package/dist/tree-view/tree-view.presentation.js +515 -0
- package/dist/tree-view/tree-view.state.d.ts +54 -0
- package/dist/tree-view/tree-view.state.js +61 -0
- package/dist/tree-view/tree-view.transitions.d.ts +30 -0
- package/dist/tree-view/tree-view.transitions.js +107 -0
- package/package.json +245 -4
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { percentOf, thumbRange, valueOfPercent } from "./slider.state.js";
|
|
2
|
+
import { slider as slider$1 } from "./slider.machine.js";
|
|
3
|
+
import { ariaDisabled, ariaOrientation, defineComponent, isComposing, isInteractive, sliderThumb } from "@spinjs/runtime";
|
|
4
|
+
// src/slider/slider.presentation.ts
|
|
5
|
+
/** A client point as a stepped track value, measured off the track node. */
|
|
6
|
+
const trackValue = (measure, orientation, dir, context, clientX, clientY) => {
|
|
7
|
+
const rect = measure("track");
|
|
8
|
+
if (rect === null) return null;
|
|
9
|
+
if (orientation === "vertical") {
|
|
10
|
+
const percent = rect.height <= 0 ? 0 : (rect.bottom - clientY) / rect.height;
|
|
11
|
+
return valueOfPercent(context, Math.min(1, Math.max(0, percent)));
|
|
12
|
+
}
|
|
13
|
+
const raw = rect.width <= 0 ? 0 : (clientX - rect.left) / rect.width;
|
|
14
|
+
const percent = dir === "rtl" ? 1 - raw : raw;
|
|
15
|
+
return valueOfPercent(context, Math.min(1, Math.max(0, percent)));
|
|
16
|
+
};
|
|
17
|
+
const thumbIndexCache = /* @__PURE__ */ new Map();
|
|
18
|
+
/** The thumb slots, as plain indices: primitives memoize by value, so a
|
|
19
|
+
* fresh inline literal hits the same cache entry.
|
|
20
|
+
*/
|
|
21
|
+
const thumbIndexes = (length) => {
|
|
22
|
+
const hit = thumbIndexCache.get(length);
|
|
23
|
+
if (hit !== void 0) return hit;
|
|
24
|
+
const made = Array.from({ length }, (_, index) => index);
|
|
25
|
+
thumbIndexCache.set(length, made);
|
|
26
|
+
return made;
|
|
27
|
+
};
|
|
28
|
+
const def = {
|
|
29
|
+
name: "slider",
|
|
30
|
+
machine: (args, authored) => slider$1(args, authored),
|
|
31
|
+
start: "idle",
|
|
32
|
+
commitEvents: [
|
|
33
|
+
"POINTER_UP",
|
|
34
|
+
"ARROW_INC",
|
|
35
|
+
"ARROW_DEC",
|
|
36
|
+
"HOME",
|
|
37
|
+
"END",
|
|
38
|
+
"INCREMENT",
|
|
39
|
+
"DECREMENT",
|
|
40
|
+
"SET_VALUE"
|
|
41
|
+
],
|
|
42
|
+
parts: {
|
|
43
|
+
root: {},
|
|
44
|
+
label: { attrs: (scope) => ({
|
|
45
|
+
for: scope.id("input", 0),
|
|
46
|
+
style: { userSelect: "none" },
|
|
47
|
+
onClick: (event) => {
|
|
48
|
+
if (!isInteractive(scope.context)) return;
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
scope.send({
|
|
51
|
+
type: "FOCUS",
|
|
52
|
+
index: Math.max(0, scope.context.focusedIndex)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}) },
|
|
56
|
+
valueText: { id: "value-text" },
|
|
57
|
+
control: { attrs: (scope) => ({
|
|
58
|
+
style: {
|
|
59
|
+
position: "relative",
|
|
60
|
+
touchAction: "none"
|
|
61
|
+
},
|
|
62
|
+
"use:drag": {
|
|
63
|
+
enabled: isInteractive(scope.context),
|
|
64
|
+
preventDefault: true,
|
|
65
|
+
stopPropagation: true,
|
|
66
|
+
cancelOnEscape: false,
|
|
67
|
+
onStart: (press) => {
|
|
68
|
+
const context = scope.context;
|
|
69
|
+
if (press.metaKey || press.ctrlKey || press.altKey) return;
|
|
70
|
+
const value = trackValue(scope.measure, context.orientation, press.direction, context, press.x, press.y);
|
|
71
|
+
if (value === null) return;
|
|
72
|
+
scope.send({
|
|
73
|
+
type: "POINTER_DOWN",
|
|
74
|
+
pointValue: value
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
onMove: (delta) => {
|
|
78
|
+
if (scope.state !== "dragging") return;
|
|
79
|
+
const value = trackValue(scope.measure, scope.context.orientation, delta.direction, scope.context, delta.x, delta.y);
|
|
80
|
+
if (value === null) return;
|
|
81
|
+
scope.send({
|
|
82
|
+
type: "POINTER_MOVE",
|
|
83
|
+
pointValue: value
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
onEnd: () => {
|
|
87
|
+
if (scope.state !== "dragging") return;
|
|
88
|
+
scope.send({ type: "POINTER_UP" });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}) },
|
|
92
|
+
track: { attrs: () => ({ style: { position: "relative" } }) },
|
|
93
|
+
range: { attrs: (scope) => {
|
|
94
|
+
const context = scope.context;
|
|
95
|
+
const percents = context.value.map((value) => percentOf(context, value));
|
|
96
|
+
const origin = context.origin;
|
|
97
|
+
const single = percents.length < 2;
|
|
98
|
+
const low = single && origin === "start" ? 0 : Math.min(...percents);
|
|
99
|
+
const high = single && origin === "end" ? 100 : Math.max(...percents);
|
|
100
|
+
return { style: context.orientation === "vertical" ? {
|
|
101
|
+
bottom: `${low}%`,
|
|
102
|
+
height: `calc(${high}% - ${low}%)`
|
|
103
|
+
} : {
|
|
104
|
+
insetInlineStart: `${low}%`,
|
|
105
|
+
width: `calc(${high}% - ${low}%)`
|
|
106
|
+
} };
|
|
107
|
+
} },
|
|
108
|
+
markerGroup: { id: "marker-group" }
|
|
109
|
+
},
|
|
110
|
+
slots: {
|
|
111
|
+
thumb: {
|
|
112
|
+
indexes: (context) => thumbIndexes(context.value.length),
|
|
113
|
+
attrs: (scope) => {
|
|
114
|
+
const context = scope.context;
|
|
115
|
+
const value = context.value[scope.slot] ?? context.min;
|
|
116
|
+
const range = thumbRange(context, scope.slot);
|
|
117
|
+
const percent = percentOf(context, value);
|
|
118
|
+
const vertical = context.orientation === "vertical";
|
|
119
|
+
const orientation = context.orientation;
|
|
120
|
+
return {
|
|
121
|
+
id: scope.id("thumb", scope.slot),
|
|
122
|
+
"data-index": String(scope.slot),
|
|
123
|
+
draggable: "false",
|
|
124
|
+
...ariaDisabled(context.disabled ? "true" : void 0),
|
|
125
|
+
...ariaOrientation(orientation === "horizontal" || orientation === "vertical" ? orientation : void 0),
|
|
126
|
+
...sliderThumb({
|
|
127
|
+
max: String(range.max),
|
|
128
|
+
min: String(range.min),
|
|
129
|
+
now: String(value)
|
|
130
|
+
}),
|
|
131
|
+
role: "slider",
|
|
132
|
+
tabindex: context.disabled ? void 0 : "0",
|
|
133
|
+
style: vertical ? { bottom: `${percent}%` } : { insetInlineStart: `${percent}%` },
|
|
134
|
+
"use:drag": {
|
|
135
|
+
enabled: isInteractive(scope.context),
|
|
136
|
+
preventDefault: false,
|
|
137
|
+
stopPropagation: true,
|
|
138
|
+
cancelOnEscape: false,
|
|
139
|
+
onStart: () => {
|
|
140
|
+
scope.send({
|
|
141
|
+
type: "THUMB_POINTER_DOWN",
|
|
142
|
+
index: scope.slot
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
onMove: (delta) => {
|
|
146
|
+
if (scope.state !== "dragging") return;
|
|
147
|
+
const value = trackValue(scope.measure, scope.context.orientation, delta.direction, scope.context, delta.x, delta.y);
|
|
148
|
+
if (value === null) return;
|
|
149
|
+
scope.send({
|
|
150
|
+
type: "POINTER_MOVE",
|
|
151
|
+
pointValue: value
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
onEnd: () => {
|
|
155
|
+
if (scope.state !== "dragging") return;
|
|
156
|
+
scope.send({ type: "POINTER_UP" });
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
onBlur: () => {
|
|
160
|
+
if (!isInteractive(scope.context)) return;
|
|
161
|
+
scope.send({ type: "BLUR" });
|
|
162
|
+
},
|
|
163
|
+
onFocus: () => {
|
|
164
|
+
if (!isInteractive(scope.context)) return;
|
|
165
|
+
scope.send({
|
|
166
|
+
type: "FOCUS",
|
|
167
|
+
index: scope.slot
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
onKeydown: (event) => {
|
|
171
|
+
if (event.defaultPrevented) return;
|
|
172
|
+
if (!isInteractive(scope.context)) return;
|
|
173
|
+
if (isComposing(event)) return;
|
|
174
|
+
const large = event.shiftKey ? scope.context.largeStep : void 0;
|
|
175
|
+
const keyed = (type) => {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
event.stopPropagation();
|
|
178
|
+
scope.send(large !== void 0 && (type === "ARROW_INC" || type === "ARROW_DEC") ? {
|
|
179
|
+
type,
|
|
180
|
+
step: large
|
|
181
|
+
} : { type });
|
|
182
|
+
return true;
|
|
183
|
+
};
|
|
184
|
+
const horizontal = scope.context.orientation === "horizontal";
|
|
185
|
+
const rtl = event.target instanceof Element && event.target.ownerDocument?.defaultView?.getComputedStyle(event.target).direction === "rtl";
|
|
186
|
+
switch (event.key) {
|
|
187
|
+
case "ArrowUp":
|
|
188
|
+
if (!horizontal) keyed("ARROW_INC");
|
|
189
|
+
break;
|
|
190
|
+
case "ArrowDown":
|
|
191
|
+
if (!horizontal) keyed("ARROW_DEC");
|
|
192
|
+
break;
|
|
193
|
+
case "ArrowLeft":
|
|
194
|
+
if (horizontal) keyed(rtl ? "ARROW_INC" : "ARROW_DEC");
|
|
195
|
+
break;
|
|
196
|
+
case "ArrowRight":
|
|
197
|
+
if (horizontal) keyed(rtl ? "ARROW_DEC" : "ARROW_INC");
|
|
198
|
+
break;
|
|
199
|
+
case "PageUp":
|
|
200
|
+
keyed("ARROW_INC");
|
|
201
|
+
break;
|
|
202
|
+
case "PageDown":
|
|
203
|
+
keyed("ARROW_DEC");
|
|
204
|
+
break;
|
|
205
|
+
case "Home":
|
|
206
|
+
keyed("HOME");
|
|
207
|
+
break;
|
|
208
|
+
case "End": keyed("END");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
marker: {
|
|
215
|
+
indexes: (context) => context.markers,
|
|
216
|
+
attrs: (scope) => {
|
|
217
|
+
const slot = scope.slot;
|
|
218
|
+
const context = scope.context;
|
|
219
|
+
const percent = percentOf(context, slot);
|
|
220
|
+
const vertical = context.orientation === "vertical";
|
|
221
|
+
return {
|
|
222
|
+
id: scope.id("marker", slot),
|
|
223
|
+
"data-value": String(slot),
|
|
224
|
+
style: vertical ? { bottom: `${percent}%` } : { insetInlineStart: `${percent}%` }
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
hiddenInput: {
|
|
229
|
+
id: "input",
|
|
230
|
+
stamp: false,
|
|
231
|
+
indexes: (context) => thumbIndexes(context.value.length),
|
|
232
|
+
attrs: (scope, arg) => {
|
|
233
|
+
const context = scope.context;
|
|
234
|
+
const index = scope.slot;
|
|
235
|
+
const value = context.value[index] ?? context.min;
|
|
236
|
+
const name = typeof arg === "string" ? arg : "";
|
|
237
|
+
return {
|
|
238
|
+
id: scope.id("input", index),
|
|
239
|
+
name: name.length > 0 ? context.value.length > 1 ? `${name}[]` : name : void 0,
|
|
240
|
+
form: void 0,
|
|
241
|
+
type: "text",
|
|
242
|
+
hidden: true,
|
|
243
|
+
value: String(value)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
commands: {
|
|
249
|
+
setValue: { event: ([value]) => ({
|
|
250
|
+
type: "SET_VALUE",
|
|
251
|
+
value
|
|
252
|
+
}) },
|
|
253
|
+
setThumbValue: { event: ([index, value], context) => {
|
|
254
|
+
const next = [...context.value];
|
|
255
|
+
const i = Math.trunc(index);
|
|
256
|
+
next[i] = value;
|
|
257
|
+
return {
|
|
258
|
+
type: "SET_VALUE",
|
|
259
|
+
value: next,
|
|
260
|
+
index: i
|
|
261
|
+
};
|
|
262
|
+
} },
|
|
263
|
+
increment: { event: ([index]) => index !== void 0 ? {
|
|
264
|
+
type: "INCREMENT",
|
|
265
|
+
index: Math.trunc(index)
|
|
266
|
+
} : { type: "INCREMENT" } },
|
|
267
|
+
decrement: { event: ([index]) => index !== void 0 ? {
|
|
268
|
+
type: "DECREMENT",
|
|
269
|
+
index: Math.trunc(index)
|
|
270
|
+
} : { type: "DECREMENT" } },
|
|
271
|
+
focus: { event: () => ({
|
|
272
|
+
type: "FOCUS",
|
|
273
|
+
index: 0
|
|
274
|
+
}) }
|
|
275
|
+
},
|
|
276
|
+
readers: {
|
|
277
|
+
value: { read: (context) => context.value },
|
|
278
|
+
markers: { read: (context) => context.markers },
|
|
279
|
+
valueText: { read: (context) => context.value.join(", ") },
|
|
280
|
+
dragging: { read: (_context, state) => state === "dragging" },
|
|
281
|
+
focused: { read: (_context, state) => state === "focus" },
|
|
282
|
+
focusedIndex: { read: (context) => context.focusedIndex },
|
|
283
|
+
disabled: { read: (context) => context.disabled }
|
|
284
|
+
},
|
|
285
|
+
methods: {
|
|
286
|
+
getThumbValue: { call: (context, _state, [index]) => context.value[Math.trunc(index)] ?? context.min },
|
|
287
|
+
getThumbPercent: { call: (context, _state, [index]) => percentOf(context, context.value[Math.trunc(index)] ?? context.min) },
|
|
288
|
+
getThumbMin: { call: (context, _state, [index]) => thumbRange(context, Math.trunc(index)).min },
|
|
289
|
+
getThumbMax: { call: (context, _state, [index]) => thumbRange(context, Math.trunc(index)).max },
|
|
290
|
+
getMarkers: { call: (context) => context.markers }
|
|
291
|
+
},
|
|
292
|
+
events: {
|
|
293
|
+
"value-change": {
|
|
294
|
+
prop: "onValueChange",
|
|
295
|
+
watch: (context) => [...context.value],
|
|
296
|
+
detail: (watched) => ({ value: [...watched] })
|
|
297
|
+
},
|
|
298
|
+
"value-change-end": {
|
|
299
|
+
prop: "onValueChangeEnd",
|
|
300
|
+
on: "commit",
|
|
301
|
+
watch: (context) => [...context.value],
|
|
302
|
+
detail: (watched) => ({ value: [...watched] })
|
|
303
|
+
},
|
|
304
|
+
"focus-change": {
|
|
305
|
+
prop: "onFocusChange",
|
|
306
|
+
watch: (context) => [context.focusedIndex, ...context.value],
|
|
307
|
+
detail: (watched) => ({
|
|
308
|
+
focusedIndex: watched[0],
|
|
309
|
+
value: watched.slice(1)
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
settled: ({ event, after, focus }) => {
|
|
314
|
+
if (event.type !== "ARROW_INC" && event.type !== "ARROW_DEC" && event.type !== "HOME" && event.type !== "END" && event.type !== "INCREMENT" && event.type !== "DECREMENT") return;
|
|
315
|
+
const idx = after.context.focusedIndex;
|
|
316
|
+
if (idx >= 0) focus("thumb", idx);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
const slider = defineComponent(def);
|
|
320
|
+
export { def, slider };
|
|
321
|
+
|
|
322
|
+
//# sourceMappingURL=slider.presentation.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type SliderState = "idle" | "focus" | "dragging";
|
|
2
|
+
export type ThumbCollisionBehavior = "none" | "push" | "swap";
|
|
3
|
+
export interface SliderContext {
|
|
4
|
+
value: number[];
|
|
5
|
+
focusedIndex: number;
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
step: number;
|
|
9
|
+
largeStep: number;
|
|
10
|
+
minStepsBetweenThumbs: number;
|
|
11
|
+
origin: "start" | "center" | "end";
|
|
12
|
+
orientation: "horizontal" | "vertical";
|
|
13
|
+
thumbCollisionBehavior: ThumbCollisionBehavior;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
readOnly: boolean;
|
|
16
|
+
invalid: boolean;
|
|
17
|
+
/** Marker stops for the ticks/marks usages. */
|
|
18
|
+
markers: number[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The slider's arguments: the machine's own domain types. The host sets
|
|
22
|
+
* typed values; nothing parses text here.
|
|
23
|
+
*
|
|
24
|
+
* The twin (`defaultValue`) is resolved by the framework before the factory
|
|
25
|
+
* is called, so the machine only ever sees the live value.
|
|
26
|
+
*/
|
|
27
|
+
export interface SliderArgs {
|
|
28
|
+
value?: readonly number[];
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
step?: number;
|
|
32
|
+
/** The coarse step (shift+arrow); absent means ten times the step. */
|
|
33
|
+
largeStep?: number;
|
|
34
|
+
/** The gap the thumbs keep, in steps. */
|
|
35
|
+
minStepsBetweenThumbs?: number;
|
|
36
|
+
origin?: "start" | "center" | "end";
|
|
37
|
+
orientation?: "horizontal" | "vertical";
|
|
38
|
+
thumbCollisionBehavior?: ThumbCollisionBehavior;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
invalid?: boolean;
|
|
42
|
+
markers?: readonly number[];
|
|
43
|
+
defaultInvalid?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The machine's context, built from its arguments: what the args did not
|
|
47
|
+
* carry takes the machine's own default.
|
|
48
|
+
*
|
|
49
|
+
* The seed twin (`defaultValue`) is the host's write of the value — the
|
|
50
|
+
* framework resolved it into the args — so it counts as a write too.
|
|
51
|
+
*/
|
|
52
|
+
export declare function initial(args: SliderArgs | undefined, authored: (name: string) => boolean): SliderContext;
|
|
53
|
+
export declare function valuePercent(ctx: SliderContext): number[];
|
|
54
|
+
declare function rangeAt(ctx: SliderContext, index: number): {
|
|
55
|
+
readonly min: number;
|
|
56
|
+
readonly max: number;
|
|
57
|
+
readonly value: number;
|
|
58
|
+
};
|
|
59
|
+
declare function constrain(ctx: SliderContext, value: number, index: number): number;
|
|
60
|
+
declare function normalizeAll(ctx: SliderContext, next: readonly number[]): number[];
|
|
61
|
+
declare function resolveNone(index: number, value: number, values: number[], min: number, max: number): number[];
|
|
62
|
+
declare function handlePush(index: number, value: number, values: number[], min: number, max: number, gap: number): number[];
|
|
63
|
+
/** Stacked thumbs at max move the first one. */
|
|
64
|
+
export declare function movableIndex(values: readonly number[], index: number, max: number): number;
|
|
65
|
+
export declare function thumbRange(ctx: SliderContext, index: number): {
|
|
66
|
+
min: number;
|
|
67
|
+
max: number;
|
|
68
|
+
};
|
|
69
|
+
export declare function percentOf(ctx: SliderContext, value: number): number;
|
|
70
|
+
export declare function valueOfPercent(ctx: SliderContext, percent: number): number;
|
|
71
|
+
export { constrain, handlePush, normalizeAll, rangeAt, resolveNone };
|
|
72
|
+
//# sourceMappingURL=slider.state.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { clampValue, getPercentValue, getValuePercent, getValueRanges, round10, snapValueToStep } from "@spinjs/runtime";
|
|
2
|
+
// src/slider/slider.state.ts
|
|
3
|
+
/**
|
|
4
|
+
* The machine's context, built from its arguments: what the args did not
|
|
5
|
+
* carry takes the machine's own default.
|
|
6
|
+
*
|
|
7
|
+
* The seed twin (`defaultValue`) is the host's write of the value — the
|
|
8
|
+
* framework resolved it into the args — so it counts as a write too.
|
|
9
|
+
*/
|
|
10
|
+
function initial(args = {}, authored) {
|
|
11
|
+
const written = (field) => args[field] !== void 0 || authored(field);
|
|
12
|
+
const min = args.min ?? 0;
|
|
13
|
+
const max = args.max ?? 100;
|
|
14
|
+
const step = args.step ?? 1;
|
|
15
|
+
const valueOf = (raw, fallback) => raw === void 0 ? fallback : [...raw];
|
|
16
|
+
return {
|
|
17
|
+
min,
|
|
18
|
+
max,
|
|
19
|
+
step,
|
|
20
|
+
largeStep: args.largeStep ?? 10 * step,
|
|
21
|
+
minStepsBetweenThumbs: Math.max(0, Math.floor(args.minStepsBetweenThumbs ?? 0)),
|
|
22
|
+
origin: args.origin ?? "start",
|
|
23
|
+
orientation: args.orientation ?? "horizontal",
|
|
24
|
+
thumbCollisionBehavior: args.thumbCollisionBehavior ?? "none",
|
|
25
|
+
disabled: args.disabled === true,
|
|
26
|
+
readOnly: args.readOnly === true,
|
|
27
|
+
invalid: args.invalid === true,
|
|
28
|
+
value: written("value") ? valueOf(args.value, [min]) : [min],
|
|
29
|
+
markers: valueOf(args.markers, []),
|
|
30
|
+
focusedIndex: -1
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function valuePercent(ctx) {
|
|
34
|
+
return ctx.value.map((value) => getValuePercent(value, ctx.min, ctx.max));
|
|
35
|
+
}
|
|
36
|
+
function rangeAt(ctx, index) {
|
|
37
|
+
return getValueRanges(ctx.value, ctx.min, ctx.max, ctx.step * ctx.minStepsBetweenThumbs)[index] ?? {
|
|
38
|
+
min: ctx.min,
|
|
39
|
+
max: ctx.max,
|
|
40
|
+
value: ctx.value[index] ?? ctx.min
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function constrain(ctx, value, index) {
|
|
44
|
+
const range = rangeAt(ctx, index);
|
|
45
|
+
const snapped = snapValueToStep(value, ctx.min, ctx.max, ctx.step);
|
|
46
|
+
return clampValue(snapped, range.min, range.max);
|
|
47
|
+
}
|
|
48
|
+
function normalizeAll(ctx, next) {
|
|
49
|
+
return next.map((value, index) => constrain({
|
|
50
|
+
...ctx,
|
|
51
|
+
value: [...ctx.value]
|
|
52
|
+
}, value, index));
|
|
53
|
+
}
|
|
54
|
+
function resolveNone(index, value, values, min, max) {
|
|
55
|
+
if (values.length === 1) return [clampValue(value, min, max)];
|
|
56
|
+
const next = [...values];
|
|
57
|
+
next[index] = clampValue(value, min, max);
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
function handlePush(index, value, values, min, max, gap) {
|
|
61
|
+
const next = [...values];
|
|
62
|
+
next[index] = clampValue(value, min, max);
|
|
63
|
+
for (let i = index; i > 0; i -= 1) {
|
|
64
|
+
const upper = next[i] ?? max;
|
|
65
|
+
if ((next[i - 1] ?? min) > upper - gap) next[i - 1] = round10(upper - gap);
|
|
66
|
+
}
|
|
67
|
+
for (let i = index; i < next.length - 1; i += 1) {
|
|
68
|
+
const lower = next[i] ?? min;
|
|
69
|
+
if ((next[i + 1] ?? max) < lower + gap) next[i + 1] = round10(lower + gap);
|
|
70
|
+
}
|
|
71
|
+
return next.map((v) => clampValue(v, min, max));
|
|
72
|
+
}
|
|
73
|
+
/** Stacked thumbs at max move the first one. */
|
|
74
|
+
function movableIndex(values, index, max) {
|
|
75
|
+
if ((values[index] ?? 0) !== max) return index;
|
|
76
|
+
let movable = index;
|
|
77
|
+
while (movable > 0 && values[movable - 1] === max) movable -= 1;
|
|
78
|
+
return movable;
|
|
79
|
+
}
|
|
80
|
+
function thumbRange(ctx, index) {
|
|
81
|
+
return rangeAt(ctx, index);
|
|
82
|
+
}
|
|
83
|
+
function percentOf(ctx, value) {
|
|
84
|
+
return getValuePercent(value, ctx.min, ctx.max) * 100;
|
|
85
|
+
}
|
|
86
|
+
function valueOfPercent(ctx, percent) {
|
|
87
|
+
return getPercentValue(percent, ctx.min, ctx.max, ctx.step);
|
|
88
|
+
}
|
|
89
|
+
export { constrain, handlePush, initial, movableIndex, normalizeAll, percentOf, rangeAt, resolveNone, thumbRange, valueOfPercent, valuePercent };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=slider.state.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SliderContext } from "./slider.state.js";
|
|
2
|
+
import { SliderEvents } from "./slider.events.js";
|
|
3
|
+
import { AssignFor, GuardFor } from "@spinjs/runtime/fsm";
|
|
4
|
+
type SliderAssign<K extends keyof SliderEvents = keyof SliderEvents> = AssignFor<SliderContext, SliderEvents, K>;
|
|
5
|
+
export declare const incrementThumb: SliderAssign<"INCREMENT" | "ARROW_INC">;
|
|
6
|
+
export declare const decrementThumb: SliderAssign<"DECREMENT" | "ARROW_DEC">;
|
|
7
|
+
export declare const setClosestThumb: SliderAssign<"POINTER_DOWN">;
|
|
8
|
+
export declare const setFocusedIndex: SliderAssign<"FOCUS" | "THUMB_POINTER_DOWN">;
|
|
9
|
+
export declare const clearFocusedIndex: () => Partial<SliderContext>;
|
|
10
|
+
export declare const setPointerValue: SliderAssign<"POINTER_DOWN" | "POINTER_MOVE">;
|
|
11
|
+
export declare const hasIndex: GuardFor<SliderContext, SliderEvents>;
|
|
12
|
+
export declare const setIndexedValue: SliderAssign<"SET_VALUE">;
|
|
13
|
+
export declare const setAllValues: SliderAssign<"SET_VALUE">;
|
|
14
|
+
export declare const setHomeValue: (ctx: SliderContext) => Partial<SliderContext>;
|
|
15
|
+
export declare const setEndValue: (ctx: SliderContext) => Partial<SliderContext>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=slider.transitions.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { constrain, handlePush, movableIndex, normalizeAll, rangeAt, resolveNone } from "./slider.state.js";
|
|
2
|
+
import { clampValue, closestIndex, getNextStepValue, getPreviousStepValue } from "@spinjs/runtime";
|
|
3
|
+
// src/slider/slider.transitions.ts
|
|
4
|
+
const incrementThumb = (ctx, event) => {
|
|
5
|
+
const index = event.type === "INCREMENT" && event.index !== void 0 ? event.index : ctx.focusedIndex;
|
|
6
|
+
if (index < 0 || index >= ctx.value.length) return {};
|
|
7
|
+
const range = rangeAt(ctx, index);
|
|
8
|
+
const next = [...getNextStepValue(index, {
|
|
9
|
+
...range,
|
|
10
|
+
step: event.step ?? ctx.step,
|
|
11
|
+
values: [...ctx.value]
|
|
12
|
+
})];
|
|
13
|
+
next[index] = clampValue(next[index] ?? ctx.min, range.min, range.max);
|
|
14
|
+
return { value: next };
|
|
15
|
+
};
|
|
16
|
+
const decrementThumb = (ctx, event) => {
|
|
17
|
+
const index = event.type === "DECREMENT" && event.index !== void 0 ? event.index : ctx.focusedIndex;
|
|
18
|
+
if (index < 0 || index >= ctx.value.length) return {};
|
|
19
|
+
const range = rangeAt(ctx, index);
|
|
20
|
+
const next = [...getPreviousStepValue(index, {
|
|
21
|
+
...range,
|
|
22
|
+
step: event.step ?? ctx.step,
|
|
23
|
+
values: [...ctx.value]
|
|
24
|
+
})];
|
|
25
|
+
next[index] = clampValue(next[index] ?? ctx.min, range.min, range.max);
|
|
26
|
+
return { value: next };
|
|
27
|
+
};
|
|
28
|
+
const setClosestThumb = (ctx, event) => ({ focusedIndex: movableIndex(ctx.value, closestIndex(ctx.value, event.pointValue), ctx.max) });
|
|
29
|
+
const setFocusedIndex = (_ctx, event) => ({ focusedIndex: event.type === "THUMB_POINTER_DOWN" ? event.index : event.index ?? 0 });
|
|
30
|
+
const clearFocusedIndex = () => ({ focusedIndex: -1 });
|
|
31
|
+
const setPointerValue = (ctx, event) => {
|
|
32
|
+
if (ctx.thumbCollisionBehavior === "push") {
|
|
33
|
+
const gap = ctx.step * ctx.minStepsBetweenThumbs;
|
|
34
|
+
return { value: handlePush(ctx.focusedIndex, event.pointValue, ctx.value, ctx.min, ctx.max, gap) };
|
|
35
|
+
}
|
|
36
|
+
return { value: resolveNone(ctx.focusedIndex, event.pointValue, ctx.value, ctx.min, ctx.max) };
|
|
37
|
+
};
|
|
38
|
+
const hasIndex = (_ctx, event) => event.type === "SET_VALUE" && event.index !== void 0 && event.index !== null;
|
|
39
|
+
const setIndexedValue = (ctx, event) => {
|
|
40
|
+
const values = [...event.value];
|
|
41
|
+
if (event.index === void 0 || event.index === null) return {};
|
|
42
|
+
if (values[event.index] === void 0) return {};
|
|
43
|
+
const next = [...ctx.value];
|
|
44
|
+
next[event.index] = constrain(ctx, values[event.index] ?? ctx.min, event.index);
|
|
45
|
+
return { value: next };
|
|
46
|
+
};
|
|
47
|
+
const setAllValues = (ctx, event) => ({ value: normalizeAll(ctx, [...event.value]) });
|
|
48
|
+
const setHomeValue = (ctx) => {
|
|
49
|
+
if (ctx.focusedIndex < 0) return {};
|
|
50
|
+
const next = [...ctx.value];
|
|
51
|
+
next[ctx.focusedIndex] = rangeAt(ctx, ctx.focusedIndex).min;
|
|
52
|
+
return { value: next };
|
|
53
|
+
};
|
|
54
|
+
const setEndValue = (ctx) => {
|
|
55
|
+
if (ctx.focusedIndex < 0) return {};
|
|
56
|
+
const next = [...ctx.value];
|
|
57
|
+
next[ctx.focusedIndex] = rangeAt(ctx, ctx.focusedIndex).max;
|
|
58
|
+
return { value: next };
|
|
59
|
+
};
|
|
60
|
+
export { clearFocusedIndex, decrementThumb, hasIndex, incrementThumb, setAllValues, setClosestThumb, setEndValue, setFocusedIndex, setHomeValue, setIndexedValue, setPointerValue };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=slider.transitions.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CtlFor, ElementTarget, SpinComponentCtl, spinComponentCtl } from "../controller.js";
|
|
2
|
+
import { DefinedComponent } from "@spinjs/runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Solid adapter: `createSpinComponent(el)` is the app controller's
|
|
5
|
+
* instrument.
|
|
6
|
+
*
|
|
7
|
+
* The element is a locator, not a product — the host already owns it. What
|
|
8
|
+
* this adds is the component's controller surface (`{ commands, state,
|
|
9
|
+
* bind }`), reached through the same context markup consumes. Whether a
|
|
10
|
+
* machine or the platform owns the component's state is invisible here: the
|
|
11
|
+
* surface is the same.
|
|
12
|
+
*
|
|
13
|
+
* The ctl is never nullish: it resolves the element on every access, so the
|
|
14
|
+
* host holds one handle and `bind` inside a `createEffect` subscribes to the
|
|
15
|
+
* element signal and runs when the element mounts. It stays callable for
|
|
16
|
+
* hosts that prefer `ctl()` reads.
|
|
17
|
+
*
|
|
18
|
+
* State reads are the component's own signals, so reading
|
|
19
|
+
* `ctl.state.<field>()` inside a tracking scope subscribes to that
|
|
20
|
+
* component's moves — no polling, no synthetic events.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const [drawerEl, setDrawerEl] = createSignal<HTMLElement>();
|
|
24
|
+
* const drawer = createSpinComponent(drawerEl);
|
|
25
|
+
* // Props bind at ref time, so seeds land before the build reads them.
|
|
26
|
+
* createEffect(() => drawer.bind({ open: open() }, { "open-change": (e) => setOpen(e.detail.open) }));
|
|
27
|
+
* <spin-drawer ref={drawer.ref} />
|
|
28
|
+
* drawer.commands.show();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export type SpinComponentCtlAccessor<TCommands extends object = object, TState extends object = Record<string, () => unknown>, TProps extends object = Record<string, unknown>> = (() => SpinComponentCtl<TCommands, TState, TProps>) & SpinComponentCtl<TCommands, TState, TProps>;
|
|
32
|
+
export declare function createSpinComponent<D extends DefinedComponent<any, any>>(def: D): (() => CtlFor<D>) & CtlFor<D>;
|
|
33
|
+
export declare function createSpinComponent<D extends DefinedComponent<any, any>>(target: ElementTarget, def: D): (() => CtlFor<D>) & CtlFor<D>;
|
|
34
|
+
export declare function createSpinComponent<TCommands extends object = object, TState extends object = Record<string, () => unknown>, TProps extends object = Record<string, unknown>>(el: ElementTarget, handle?: object): SpinComponentCtlAccessor<TCommands, TState, TProps>;
|
|
35
|
+
export { spinComponentCtl };
|
|
36
|
+
//# sourceMappingURL=solid.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { spinComponentCtl } from "../controller.js";
|
|
2
|
+
// src/solid/solid.ts
|
|
3
|
+
function createSpinComponent(target, handleOrDef) {
|
|
4
|
+
const ctl = spinComponentCtl(target, handleOrDef);
|
|
5
|
+
const accessor = (() => ctl);
|
|
6
|
+
return Object.assign(accessor, ctl);
|
|
7
|
+
}
|
|
8
|
+
export { createSpinComponent, spinComponentCtl };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=solid.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A spin element as hosts see it: props down, events up, commands in. */
|
|
2
|
+
export interface SpinElement {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface SpinHookOptions<TProps extends object> {
|
|
6
|
+
/** Written as element properties. */
|
|
7
|
+
readonly props?: TProps | undefined;
|
|
8
|
+
/** CustomEvent name -> handler, subscribed for the element's lifetime. */
|
|
9
|
+
readonly on?: Readonly<Record<string, (event: CustomEvent) => void>> | undefined;
|
|
10
|
+
}
|
|
11
|
+
/** Attach-time work shared by every adapter: write props, bind events. */
|
|
12
|
+
export declare function bindSpinElement<TProps extends object>(el: Element, { props, on }: SpinHookOptions<TProps>): () => void;
|
|
13
|
+
//# sourceMappingURL=spin-element.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { writeProp } from "@spinjs/runtime";
|
|
2
|
+
// src/spin-element.ts
|
|
3
|
+
/**
|
|
4
|
+
* Host hooks for spin elements: the drop-in surface for framework apps.
|
|
5
|
+
*
|
|
6
|
+
* The elements are framework-agnostic by construction (custom elements,
|
|
7
|
+
* property writes down, CustomEvents up). This package is the typed,
|
|
8
|
+
* ergonomic version of that contract for the frameworks people actually
|
|
9
|
+
* use — one small adapter each, no framework runtime dependency beyond the
|
|
10
|
+
* host itself.
|
|
11
|
+
*
|
|
12
|
+
* What a hook gives you over raw refs:
|
|
13
|
+
* - declared props written as properties on attach, re-written when they
|
|
14
|
+
* change (so controlled usage is a normal reactive binding);
|
|
15
|
+
* - declared events subscribed with cleanup on unmount — no manual
|
|
16
|
+
* listener bookkeeping;
|
|
17
|
+
* - the element's imperative commands (`el.show()`, `el.hide()`) typed and
|
|
18
|
+
* reachable, for the cases events don't cover;
|
|
19
|
+
* - the machine's read-only state (where the machine-def exposes it).
|
|
20
|
+
*
|
|
21
|
+
* The three surface shapes stay identical across adapters on purpose: the
|
|
22
|
+
* day a framework needs something new, the change is one file.
|
|
23
|
+
*/
|
|
24
|
+
/** Attach-time work shared by every adapter: write props, bind events. */
|
|
25
|
+
function bindSpinElement(el, { props, on }) {
|
|
26
|
+
for (const [name, value] of Object.entries(props ?? {})) {
|
|
27
|
+
if (writeProp(el, name, value)) continue;
|
|
28
|
+
el[name] = value;
|
|
29
|
+
}
|
|
30
|
+
const entries = Object.entries(on ?? {});
|
|
31
|
+
for (const [name, handler] of entries) el.addEventListener(name, handler);
|
|
32
|
+
return () => {
|
|
33
|
+
for (const [name, handler] of entries) el.removeEventListener(name, handler);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { bindSpinElement };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=spin-element.js.map
|