@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,80 @@
|
|
|
1
|
+
export interface ComboboxRow {
|
|
2
|
+
readonly value: string;
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly disabled?: boolean;
|
|
5
|
+
readonly group?: string;
|
|
6
|
+
readonly index?: number;
|
|
7
|
+
readonly meta?: Readonly<Record<string, string>> | undefined;
|
|
8
|
+
}
|
|
9
|
+
export type ComboboxState = "idle" | "focused" | "interacting" | "suggesting";
|
|
10
|
+
export interface ComboboxContext {
|
|
11
|
+
value: string[];
|
|
12
|
+
inputValue: string;
|
|
13
|
+
highlightedValue: string | null;
|
|
14
|
+
autofill: string | null;
|
|
15
|
+
order: string[];
|
|
16
|
+
labels: Record<string, string>;
|
|
17
|
+
multiple: boolean;
|
|
18
|
+
closeOnSelect: boolean;
|
|
19
|
+
allowCustomValue: boolean;
|
|
20
|
+
inputBehavior: "none" | "autocomplete" | "autohighlight";
|
|
21
|
+
selectionBehavior: "replace" | "preserve" | "clear";
|
|
22
|
+
openOnChange: boolean;
|
|
23
|
+
openOnKeyPress: boolean;
|
|
24
|
+
alwaysSubmitOnEnter: boolean;
|
|
25
|
+
items: readonly ComboboxRow[];
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
readOnly: boolean;
|
|
28
|
+
invalid: boolean;
|
|
29
|
+
required: boolean;
|
|
30
|
+
composite: boolean;
|
|
31
|
+
placement: string;
|
|
32
|
+
name: string;
|
|
33
|
+
form: string;
|
|
34
|
+
placeholder: string;
|
|
35
|
+
triggerLabel: string;
|
|
36
|
+
clearTriggerLabel: string;
|
|
37
|
+
openOnClick: boolean;
|
|
38
|
+
loopFocus: boolean;
|
|
39
|
+
dir: "ltr" | "rtl";
|
|
40
|
+
}
|
|
41
|
+
export interface ComboboxArgs {
|
|
42
|
+
items?: readonly ComboboxRow[];
|
|
43
|
+
value?: string;
|
|
44
|
+
inputValue?: string;
|
|
45
|
+
highlightedValue?: string;
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
closeOnSelect?: boolean;
|
|
48
|
+
allowCustomValue?: boolean;
|
|
49
|
+
inputBehavior?: string;
|
|
50
|
+
selectionBehavior?: string;
|
|
51
|
+
openOnChange?: boolean;
|
|
52
|
+
openOnKeyPress?: boolean;
|
|
53
|
+
alwaysSubmitOnEnter?: boolean;
|
|
54
|
+
defaultOpenOnChange?: boolean;
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
readOnly?: boolean;
|
|
57
|
+
invalid?: boolean;
|
|
58
|
+
required?: boolean;
|
|
59
|
+
composite?: boolean;
|
|
60
|
+
placement?: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
form?: string;
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
triggerLabel?: string;
|
|
65
|
+
clearTriggerLabel?: string;
|
|
66
|
+
openOnClick?: boolean;
|
|
67
|
+
loopFocus?: boolean;
|
|
68
|
+
dir?: "ltr" | "rtl";
|
|
69
|
+
}
|
|
70
|
+
/** Shape raw items the way `initial` does: arrays pass through, anything
|
|
71
|
+
* else becomes empty. Shared by `initial` and the field contract, so a
|
|
72
|
+
* host write parses exactly like the seed. */
|
|
73
|
+
export declare function parseItems(raw: unknown): readonly ComboboxRow[];
|
|
74
|
+
declare const parseKeys: (raw: unknown) => string[];
|
|
75
|
+
export declare function initial(args: ComboboxArgs, authored: (name: string) => boolean): ComboboxContext;
|
|
76
|
+
export declare const stringifyValues: (ctx: ComboboxContext, values: readonly string[]) => string;
|
|
77
|
+
export declare const pickOutcome: (ctx: ComboboxContext, value: string) => string[];
|
|
78
|
+
export declare const isCustomValue: (ctx: ComboboxContext) => boolean;
|
|
79
|
+
export { parseKeys };
|
|
80
|
+
//# sourceMappingURL=combobox.state.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defaultTwin } from "@spinjs/runtime";
|
|
2
|
+
// src/combobox/combobox.state.ts
|
|
3
|
+
/** Shape raw items the way `initial` does: arrays pass through, anything
|
|
4
|
+
* else becomes empty. Shared by `initial` and the field contract, so a
|
|
5
|
+
* host write parses exactly like the seed. */
|
|
6
|
+
function parseItems(raw) {
|
|
7
|
+
return Array.isArray(raw) ? raw : [];
|
|
8
|
+
}
|
|
9
|
+
const parseKeys = (raw) => {
|
|
10
|
+
if (Array.isArray(raw)) return raw.filter((v) => typeof v === "string");
|
|
11
|
+
if (typeof raw !== "string") return [];
|
|
12
|
+
return raw.length > 0 ? raw.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
13
|
+
};
|
|
14
|
+
const textProp = (raw) => typeof raw === "string" ? raw : "";
|
|
15
|
+
const nullableProp = (raw) => typeof raw === "string" && raw.length > 0 ? raw : null;
|
|
16
|
+
function initial(args, authored) {
|
|
17
|
+
const written = (field) => authored(field) || authored(defaultTwin(field)) || args[defaultTwin(field)] !== void 0;
|
|
18
|
+
const multiple = written("multiple") ? args.multiple === true : false;
|
|
19
|
+
const selectionRaw = args.selectionBehavior;
|
|
20
|
+
const selectionBehavior = written("selectionBehavior") ? selectionRaw === "preserve" || selectionRaw === "clear" ? selectionRaw : multiple ? "clear" : "replace" : multiple ? "clear" : "replace";
|
|
21
|
+
const behaviorRaw = args.inputBehavior;
|
|
22
|
+
const inputBehavior = written("inputBehavior") ? behaviorRaw === "autocomplete" || behaviorRaw === "autohighlight" ? behaviorRaw : "none" : "none";
|
|
23
|
+
const rows = parseItems(args.items);
|
|
24
|
+
const order = rows.map((r) => typeof r.value === "string" ? r.value : "").filter(Boolean);
|
|
25
|
+
const labels = Object.fromEntries(rows.map((r) => [String(r.value), typeof r.label === "string" ? r.label : String(r.value)]));
|
|
26
|
+
const value = parseKeys(args.value);
|
|
27
|
+
const seedCtx = {
|
|
28
|
+
value,
|
|
29
|
+
inputValue: "",
|
|
30
|
+
highlightedValue: nullableProp(args.highlightedValue),
|
|
31
|
+
autofill: null,
|
|
32
|
+
order,
|
|
33
|
+
labels,
|
|
34
|
+
multiple,
|
|
35
|
+
closeOnSelect: written("closeOnSelect") ? args.closeOnSelect === true : !multiple,
|
|
36
|
+
allowCustomValue: written("allowCustomValue") ? args.allowCustomValue === true : false,
|
|
37
|
+
inputBehavior,
|
|
38
|
+
selectionBehavior,
|
|
39
|
+
openOnChange: written("openOnChange") ? args.openOnChange !== false : true,
|
|
40
|
+
openOnKeyPress: written("openOnKeyPress") ? args.openOnKeyPress !== false : true,
|
|
41
|
+
alwaysSubmitOnEnter: written("alwaysSubmitOnEnter") ? args.alwaysSubmitOnEnter === true : false,
|
|
42
|
+
items: rows,
|
|
43
|
+
disabled: args.disabled === true,
|
|
44
|
+
readOnly: args.readOnly === true,
|
|
45
|
+
invalid: args.invalid === true,
|
|
46
|
+
required: args.required === true,
|
|
47
|
+
composite: args.composite !== false,
|
|
48
|
+
placement: typeof args.placement === "string" && args.placement.length > 0 ? args.placement : "bottom",
|
|
49
|
+
name: typeof args.name === "string" ? args.name : "",
|
|
50
|
+
form: typeof args.form === "string" ? args.form : "",
|
|
51
|
+
placeholder: typeof args.placeholder === "string" ? args.placeholder : "",
|
|
52
|
+
triggerLabel: typeof args.triggerLabel === "string" ? args.triggerLabel : "",
|
|
53
|
+
clearTriggerLabel: typeof args.clearTriggerLabel === "string" ? args.clearTriggerLabel : "",
|
|
54
|
+
openOnClick: args.openOnClick !== false,
|
|
55
|
+
loopFocus: args.loopFocus === true,
|
|
56
|
+
dir: args.dir === "rtl" ? "rtl" : "ltr"
|
|
57
|
+
};
|
|
58
|
+
const valueAsString = value.map((v) => labels[v] ?? v).join(", ");
|
|
59
|
+
const seeded = textProp(args.inputValue);
|
|
60
|
+
const inputValue = seeded.trim().length > 0 || multiple ? seeded : selectionBehavior === "clear" ? "" : valueAsString;
|
|
61
|
+
return {
|
|
62
|
+
...seedCtx,
|
|
63
|
+
inputValue
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const stringifyValues = (ctx, values) => values.map((value) => ctx.labels[value]).filter((l) => l !== void 0).join(", ");
|
|
67
|
+
const pickOutcome = (ctx, value) => ctx.multiple ? ctx.value.includes(value) ? ctx.value.filter((v) => v !== value) : [...ctx.value, value] : [value];
|
|
68
|
+
const isCustomValue = (ctx) => ctx.inputValue !== stringifyValues(ctx, ctx.value);
|
|
69
|
+
export { initial, isCustomValue, parseItems, parseKeys, pickOutcome, stringifyValues };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=combobox.state.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComboboxEvents } from "./combobox.events.js";
|
|
2
|
+
import { ComboboxContext } from "./combobox.state.js";
|
|
3
|
+
import { AssignFor, GuardFor } from "@spinjs/runtime/fsm";
|
|
4
|
+
type Ctx = ComboboxContext;
|
|
5
|
+
type Ev = ComboboxEvents;
|
|
6
|
+
type ComboboxAssign<K extends keyof Ev = keyof Ev> = AssignFor<Ctx, Ev, K>;
|
|
7
|
+
declare const at: (list: readonly string[], index: number) => string | null;
|
|
8
|
+
declare const completion: (ctx: Ctx, value: string, keypress: boolean) => string | null;
|
|
9
|
+
declare const inlineSingle: (ctx: Ctx) => boolean;
|
|
10
|
+
declare const applySelection: (ctx: Ctx, next: readonly string[]) => Partial<Ctx>;
|
|
11
|
+
export declare const setHighlightedValue: ComboboxAssign<"HIGHLIGHTED_VALUE.SET" | "ITEM.POINTER_MOVE">;
|
|
12
|
+
export declare const clearHighlightedValue: () => Partial<Ctx>;
|
|
13
|
+
export declare const moveHighlight: ComboboxAssign<"INPUT.ARROW_DOWN" | "INPUT.ARROW_UP" | "INPUT.HOME" | "INPUT.END">;
|
|
14
|
+
export declare const highlightFirstItem: (ctx: Ctx) => Partial<Ctx>;
|
|
15
|
+
export declare const highlightFirstOrSelectedItem: (ctx: Ctx) => Partial<Ctx>;
|
|
16
|
+
export declare const selectItem: ComboboxAssign<"ITEM.SELECT" | "ITEM.CLICK">;
|
|
17
|
+
export declare const selectHighlightedItem: ComboboxAssign<"INPUT.ENTER">;
|
|
18
|
+
export declare const clearValue: (ctx: Ctx) => Partial<Ctx>;
|
|
19
|
+
export declare const clearInputValue: () => Partial<Ctx>;
|
|
20
|
+
export declare const setInputValue: ComboboxAssign<"INPUT.CHANGE" | "INPUT_VALUE.SET">;
|
|
21
|
+
export declare const revertInputValue: (ctx: Ctx) => Partial<Ctx>;
|
|
22
|
+
export declare const inlineAutocomplete: (ctx: Ctx) => boolean;
|
|
23
|
+
export declare const closeOnSelect: (ctx: Ctx) => boolean;
|
|
24
|
+
export declare const revertsToValue: (ctx: Ctx) => boolean;
|
|
25
|
+
export declare const isCustomValueGuard: GuardFor<Ctx, Ev>;
|
|
26
|
+
export declare const inlineSingleGuard: GuardFor<Ctx, Ev>;
|
|
27
|
+
export { applySelection, at, completion, inlineSingle };
|
|
28
|
+
//# sourceMappingURL=combobox.transitions.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { isCustomValue, stringifyValues } from "./combobox.state.js";
|
|
2
|
+
// src/combobox/combobox.transitions.ts
|
|
3
|
+
const at = (list, index) => list.at(index) ?? null;
|
|
4
|
+
const completion = (ctx, value, keypress) => {
|
|
5
|
+
if (!keypress || ctx.inputBehavior !== "autocomplete") return null;
|
|
6
|
+
return ctx.labels[value] ?? ctx.inputValue;
|
|
7
|
+
};
|
|
8
|
+
const inlineSingle = (ctx) => ctx.inputBehavior === "autocomplete" && !ctx.multiple;
|
|
9
|
+
const applySelection = (ctx, next) => ({
|
|
10
|
+
value: [...next],
|
|
11
|
+
inputValue: ctx.selectionBehavior === "preserve" ? ctx.inputValue : ctx.selectionBehavior === "clear" ? "" : stringifyValues(ctx, next),
|
|
12
|
+
autofill: null
|
|
13
|
+
});
|
|
14
|
+
const setHighlightedValue = (ctx, e) => {
|
|
15
|
+
if (e.type === "ITEM.POINTER_MOVE") return {
|
|
16
|
+
highlightedValue: e.value,
|
|
17
|
+
autofill: completion(ctx, e.value, false)
|
|
18
|
+
};
|
|
19
|
+
if (e.type !== "HIGHLIGHTED_VALUE.SET" || e.value === null) return {};
|
|
20
|
+
return {
|
|
21
|
+
highlightedValue: e.value,
|
|
22
|
+
autofill: completion(ctx, e.value, e.keypress === true)
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const clearHighlightedValue = () => ({
|
|
26
|
+
highlightedValue: null,
|
|
27
|
+
autofill: null
|
|
28
|
+
});
|
|
29
|
+
const moveHighlight = (ctx, e) => {
|
|
30
|
+
if (e.value === void 0) return {};
|
|
31
|
+
return {
|
|
32
|
+
highlightedValue: e.value,
|
|
33
|
+
autofill: completion(ctx, e.value, e.keypress === true)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const highlightFirstItem = (ctx) => ctx.order.length === 0 ? {} : {
|
|
37
|
+
highlightedValue: at(ctx.order, 0),
|
|
38
|
+
autofill: null
|
|
39
|
+
};
|
|
40
|
+
const highlightFirstOrSelectedItem = (ctx) => {
|
|
41
|
+
const selected = ctx.order.filter((value) => ctx.value.includes(value));
|
|
42
|
+
const value = selected.length > 0 ? at(selected, 0) : at(ctx.order, 0);
|
|
43
|
+
if (value === null) return {};
|
|
44
|
+
return {
|
|
45
|
+
highlightedValue: value,
|
|
46
|
+
autofill: null
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const selectItem = (ctx, e) => {
|
|
50
|
+
if (e.type !== "ITEM.SELECT" && e.type !== "ITEM.CLICK") return {};
|
|
51
|
+
const value = e.value;
|
|
52
|
+
const next = ctx.multiple ? ctx.value.includes(value) ? ctx.value.filter((v) => v !== value) : [...ctx.value, value] : [value];
|
|
53
|
+
return applySelection(ctx, next);
|
|
54
|
+
};
|
|
55
|
+
const selectHighlightedItem = (ctx) => {
|
|
56
|
+
if (ctx.highlightedValue === null || !ctx.order.includes(ctx.highlightedValue)) return {};
|
|
57
|
+
const value = ctx.highlightedValue;
|
|
58
|
+
const next = ctx.multiple ? ctx.value.includes(value) ? ctx.value.filter((v) => v !== value) : [...ctx.value, value] : [value];
|
|
59
|
+
return applySelection(ctx, next);
|
|
60
|
+
};
|
|
61
|
+
const clearValue = (ctx) => applySelection(ctx, []);
|
|
62
|
+
const clearInputValue = () => ({
|
|
63
|
+
inputValue: "",
|
|
64
|
+
autofill: null
|
|
65
|
+
});
|
|
66
|
+
const setInputValue = (_ctx, e) => {
|
|
67
|
+
if (e.type !== "INPUT.CHANGE" && e.type !== "INPUT_VALUE.SET") return {};
|
|
68
|
+
return {
|
|
69
|
+
inputValue: e.value,
|
|
70
|
+
autofill: null
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const revertInputValue = (ctx) => {
|
|
74
|
+
if (ctx.selectionBehavior === "preserve") return {};
|
|
75
|
+
if (ctx.selectionBehavior === "clear") return {
|
|
76
|
+
inputValue: "",
|
|
77
|
+
autofill: null
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
inputValue: ctx.value.length > 0 ? stringifyValues(ctx, ctx.value) : "",
|
|
81
|
+
autofill: null
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const inlineAutocomplete = (ctx) => ctx.inputBehavior === "autocomplete" && !ctx.multiple;
|
|
85
|
+
const closeOnSelect = (ctx) => ctx.closeOnSelect;
|
|
86
|
+
const revertsToValue = (ctx) => isCustomValue(ctx) && !ctx.allowCustomValue && ctx.highlightedValue === null;
|
|
87
|
+
const isCustomValueGuard = (ctx) => isCustomValue(ctx) && !ctx.allowCustomValue;
|
|
88
|
+
const inlineSingleGuard = (ctx) => inlineAutocomplete(ctx) && ctx.highlightedValue === at(ctx.order, -1) ? true : false;
|
|
89
|
+
export { applySelection, at, clearHighlightedValue, clearInputValue, clearValue, closeOnSelect, completion, highlightFirstItem, highlightFirstOrSelectedItem, inlineAutocomplete, inlineSingle, inlineSingleGuard, isCustomValueGuard, moveHighlight, revertInputValue, revertsToValue, selectHighlightedItem, selectItem, setHighlightedValue, setInputValue };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=combobox.transitions.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { combobox } from "../combobox.presentation.js";
|
|
3
|
+
|
|
4
|
+
const machine = combobox({items: [{"value":"apple","label":"Apple"},{"value":"apricot","label":"Apricot"},{"value":"banana","label":"Banana"},{"value":"blueberry","label":"Blueberry"}]});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="relative w-64 max-w-full" {...machine.getRootProps()}>
|
|
8
|
+
<label
|
|
9
|
+
class={["block text-sm font-medium text-text transition-colors duration-fast ease-decelerate", { "opacity-50 cursor-not-allowed": machine.disabled, "text-primary": machine.focused }]}
|
|
10
|
+
{...machine.getLabelProps()}
|
|
11
|
+
>Fruit</label>
|
|
12
|
+
|
|
13
|
+
<div class="relative" {...machine.getControlProps()}>
|
|
14
|
+
<input
|
|
15
|
+
class={["w-full pr-16 transition-colors duration-fast ease-decelerate placeholder:text-text-muted", { "opacity-60 cursor-not-allowed": machine.disabled, "border-border-strong": machine.invalid, "border-primary": machine.open }]}
|
|
16
|
+
{...machine.getInputProps()}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<div class="absolute inset-y-0 right-0 flex items-center gap-1 pr-1">
|
|
20
|
+
<button
|
|
21
|
+
class={["ghost icon s-sm"]}
|
|
22
|
+
{...machine.getClearTriggerProps()}
|
|
23
|
+
><span aria-hidden="true"><span class="inline-block icon-sm i-lucide-x" aria-hidden="true"></span></span></button>
|
|
24
|
+
<button
|
|
25
|
+
class={["ghost icon s-sm", { "cursor-not-allowed": machine.disabled }]}
|
|
26
|
+
{...machine.getTriggerProps()}
|
|
27
|
+
><span aria-hidden="true" class={["text-xs transition-transform duration-fast ease-decelerate", { "rotate-180": machine.open }]} {...machine.getTriggerIndicatorProps()}><span class="inline-block icon-sm i-lucide-chevron-down" aria-hidden="true"></span></span></button>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div
|
|
31
|
+
class={["absolute left-0 top-full z-dropdown mt-1 w-full origin-top transition duration-fast ease-decelerate", { "pointer-events-none invisible scale-95 opacity-0": !machine.open }]}
|
|
32
|
+
{...machine.getPositionerProps()}
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
class={["overflow-hidden rounded-lg border border-solid border-border bg-surface-raised shadow-lg", { "opacity-60": machine.disabled }]}
|
|
36
|
+
{...machine.getContentProps()}
|
|
37
|
+
>
|
|
38
|
+
<div class={["max-h-[15rem] overflow-y-auto p-1 transition-opacity duration-fast ease-decelerate", { "hidden": machine.empty }]} {...machine.getListProps()}>
|
|
39
|
+
<template for={machine.getBlocks()} as={block} key={block.id}>
|
|
40
|
+
<div class="py-1" {...machine.getItemGroupProps(block)}>
|
|
41
|
+
<span class="block px-2 py-1 text-xs font-medium text-text-muted" {...machine.getItemGroupLabelProps(block)}>{block.label}</span>
|
|
42
|
+
<template for={machine.getRows(block)} as={row} key={row.value}>
|
|
43
|
+
<div
|
|
44
|
+
class={["relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1 text-sm text-text transition-colors duration-fast ease-decelerate", { "bg-surface": machine.highlightedValue === row.value, "text-primary": machine.value.includes(row.value), "cursor-not-allowed opacity-50": machine.disabled }]}
|
|
45
|
+
{...machine.getItemProps(row)}
|
|
46
|
+
>
|
|
47
|
+
<span class="min-w-0 flex-1 truncate" {...machine.getItemTextProps(row)}>{row.label}</span>
|
|
48
|
+
<span
|
|
49
|
+
aria-hidden="true"
|
|
50
|
+
class={["shrink-0 text-xs text-primary scale-50 opacity-0 transition-all duration-fast ease-decelerate", { "scale-100 opacity-100": machine.value.includes(row.value) }]}
|
|
51
|
+
{...machine.getItemIndicatorProps(row)}
|
|
52
|
+
><span class="inline-block icon-sm i-lucide-check" aria-hidden="true"></span></span>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { combobox } from "../combobox.presentation.js";
|
|
3
|
+
|
|
4
|
+
const machine = combobox({
|
|
5
|
+
placeholder: "Search directory...",
|
|
6
|
+
items: [
|
|
7
|
+
{ value: "ada", label: "Ada Lovelace — Analytical Engine" },
|
|
8
|
+
{ value: "grace", label: "Grace Hopper — Compiler Systems" },
|
|
9
|
+
{ value: "margaret", label: "Margaret Hamilton — Flight Software" },
|
|
10
|
+
{ value: "barbara", label: "Barbara Liskov — Distributed Systems" },
|
|
11
|
+
{ value: "radia", label: "Radia Perlman — Network Routing" },
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div class="relative w-64 max-w-full" {...machine.getRootProps()}>
|
|
17
|
+
<label
|
|
18
|
+
class={["block text-sm font-medium text-text transition-colors duration-fast ease-decelerate", { "opacity-50 cursor-not-allowed": machine.disabled, "text-primary": machine.focused }]}
|
|
19
|
+
{...machine.getLabelProps()}
|
|
20
|
+
>Assignee</label>
|
|
21
|
+
|
|
22
|
+
<div class="relative" {...machine.getControlProps()}>
|
|
23
|
+
<input
|
|
24
|
+
class={["w-full pr-16 transition-colors duration-fast ease-decelerate placeholder:text-text-muted", { "opacity-60 cursor-not-allowed": machine.disabled, "border-border-strong": machine.invalid, "border-primary": machine.open }]}
|
|
25
|
+
placeholder="Search directory..."
|
|
26
|
+
{...machine.getInputProps()}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<div class="absolute inset-y-0 right-0 flex items-center gap-1 pr-1">
|
|
30
|
+
<button
|
|
31
|
+
class={["ghost icon s-sm"]}
|
|
32
|
+
{...machine.getClearTriggerProps()}
|
|
33
|
+
><span aria-hidden="true"><span class="inline-block icon-sm i-lucide-x" aria-hidden="true"></span></span></button>
|
|
34
|
+
<button
|
|
35
|
+
class={["ghost icon s-sm", { "cursor-not-allowed": machine.disabled }]}
|
|
36
|
+
{...machine.getTriggerProps()}
|
|
37
|
+
><span aria-hidden="true" class={["text-xs transition-transform duration-fast ease-decelerate", { "rotate-180": machine.open }]} {...machine.getTriggerIndicatorProps()}><span class="inline-block icon-sm i-lucide-chevron-down" aria-hidden="true"></span></span></button>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
class={["absolute left-0 top-full z-dropdown mt-1 w-full origin-top transition duration-fast ease-decelerate", { "pointer-events-none invisible scale-95 opacity-0": !machine.open }]}
|
|
42
|
+
{...machine.getPositionerProps()}
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
class={["overflow-hidden rounded-lg border border-solid border-border bg-surface-raised shadow-lg", { "opacity-60": machine.disabled }]}
|
|
46
|
+
{...machine.getContentProps()}
|
|
47
|
+
>
|
|
48
|
+
<div class={["max-h-[15rem] overflow-y-auto p-1 transition-opacity duration-fast ease-decelerate", { "hidden": machine.empty }]} {...machine.getListProps()}>
|
|
49
|
+
<template for={machine.getBlocks()} as={block} key={block.id}>
|
|
50
|
+
<div class="py-1" {...machine.getItemGroupProps(block)}>
|
|
51
|
+
<span class="block px-2 py-1 text-xs font-medium text-text-muted" {...machine.getItemGroupLabelProps(block)}>{block.label}</span>
|
|
52
|
+
<template for={machine.getRows(block)} as={row} key={row.value}>
|
|
53
|
+
<div
|
|
54
|
+
class={["relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1 text-sm text-text transition-colors duration-fast ease-decelerate", { "bg-surface": machine.highlightedValue === row.value, "text-primary": machine.value.includes(row.value), "cursor-not-allowed opacity-50": machine.disabled }]}
|
|
55
|
+
{...machine.getItemProps(row)}
|
|
56
|
+
>
|
|
57
|
+
<span class="min-w-0 flex-1 truncate" {...machine.getItemTextProps(row)}>{row.label}</span>
|
|
58
|
+
<span
|
|
59
|
+
aria-hidden="true"
|
|
60
|
+
class={["shrink-0 text-xs text-primary scale-50 opacity-0 transition-all duration-fast ease-decelerate", { "scale-100 opacity-100": machine.value.includes(row.value) }]}
|
|
61
|
+
{...machine.getItemIndicatorProps(row)}
|
|
62
|
+
><span class="inline-block icon-sm i-lucide-check" aria-hidden="true"></span></span>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { combobox } from "../combobox.presentation.js";
|
|
3
|
+
|
|
4
|
+
const machine = combobox({items: [{"value":"react","label":"React","group":"JS"},{"value":"solid","label":"Solid","group":"JS"},{"value":"vue","label":"Vue","group":"JS"},{"value":"svelte","label":"Svelte","group":"JS"},{"value":"panda","label":"Panda","group":"CSS"},{"value":"tailwind","label":"Tailwind","group":"CSS"}]});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="relative w-64 max-w-full" {...machine.getRootProps()}>
|
|
8
|
+
<label class={["block text-sm font-medium text-text transition-colors duration-fast ease-decelerate", { "opacity-50 cursor-not-allowed": machine.disabled, "text-primary": machine.focused }]} {...machine.getLabelProps()}>Technology</label>
|
|
9
|
+
|
|
10
|
+
<div class="relative" {...machine.getControlProps()}>
|
|
11
|
+
<input class={["w-full pr-16 transition-colors duration-fast ease-decelerate placeholder:text-text-muted", { "opacity-60 cursor-not-allowed": machine.disabled, "border-border-strong": machine.invalid, "border-primary": machine.open }]} {...machine.getInputProps()} placeholder="Select a technology..." />
|
|
12
|
+
|
|
13
|
+
<div class="absolute inset-y-0 right-0 flex items-center gap-1 pr-1">
|
|
14
|
+
<button class={["ghost icon s-sm"]} {...machine.getClearTriggerProps()}><span aria-hidden="true"><span class="inline-block icon-sm i-lucide-x" aria-hidden="true"></span></span></button>
|
|
15
|
+
<button class={["ghost icon s-sm", { "cursor-not-allowed": machine.disabled }]} {...machine.getTriggerProps()}><span aria-hidden="true" class={["text-xs transition-transform duration-fast ease-decelerate", { "rotate-180": machine.open }]} {...machine.getTriggerIndicatorProps()}><span class="inline-block icon-sm i-lucide-chevron-down" aria-hidden="true"></span></span></button>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class={["absolute left-0 top-full z-dropdown mt-1 w-full origin-top transition duration-fast ease-decelerate", { "pointer-events-none invisible scale-95 opacity-0": !machine.open }]} {...machine.getPositionerProps()}>
|
|
19
|
+
<div class={["overflow-hidden rounded-lg border border-solid border-border bg-surface-raised shadow-lg", { "opacity-60": machine.disabled }]} {...machine.getContentProps()}>
|
|
20
|
+
<div class={["max-h-[15rem] overflow-y-auto p-1 transition-opacity duration-fast ease-decelerate", { "hidden": machine.empty }]} {...machine.getListProps()}>
|
|
21
|
+
<template for={machine.getBlocks()} as={block} key={block.id}>
|
|
22
|
+
<div class="py-1" {...machine.getItemGroupProps(block)}>
|
|
23
|
+
<span class="block px-2 py-1 text-xs font-medium text-text-muted" {...machine.getItemGroupLabelProps(block)}>{block.label}</span>
|
|
24
|
+
<template for={machine.getRows(block)} as={row} key={row.value}>
|
|
25
|
+
<div class={["relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1 text-sm text-text transition-colors duration-fast ease-decelerate", { "bg-surface": machine.highlightedValue === row.value, "text-primary": machine.value.includes(row.value), "cursor-not-allowed opacity-50": machine.disabled }]} {...machine.getItemProps(row)}>
|
|
26
|
+
<span class="min-w-0 flex-1 truncate" {...machine.getItemTextProps(row)}>{row.label}</span>
|
|
27
|
+
<span aria-hidden="true" class={["shrink-0 text-xs text-primary scale-50 opacity-0 transition-all duration-fast ease-decelerate", { "scale-100 opacity-100": machine.value.includes(row.value) }]} {...machine.getItemIndicatorProps(row)}><span class="inline-block icon-sm i-lucide-check" aria-hidden="true"></span></span>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { combobox } from "../combobox.presentation.js";
|
|
3
|
+
|
|
4
|
+
const machine = combobox({multiple: true, items: [{"value":"javascript","label":"JavaScript"},{"value":"typescript","label":"TypeScript"},{"value":"react","label":"React"},{"value":"vue","label":"Vue"},{"value":"angular","label":"Angular"},{"value":"svelte","label":"Svelte"}]});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="relative w-64 max-w-full" {...machine.getRootProps()}>
|
|
8
|
+
<label class={["block text-sm font-medium text-text transition-colors duration-fast ease-decelerate", { "opacity-50 cursor-not-allowed": machine.disabled, "text-primary": machine.focused }]} {...machine.getLabelProps()}>Skills</label>
|
|
9
|
+
|
|
10
|
+
<div class="relative" {...machine.getControlProps()}>
|
|
11
|
+
<input class={["w-full pr-16 transition-colors duration-fast ease-decelerate placeholder:text-text-muted", { "opacity-60 cursor-not-allowed": machine.disabled, "border-border-strong": machine.invalid, "border-primary": machine.open }]} {...machine.getInputProps()} placeholder="Add skills..." />
|
|
12
|
+
|
|
13
|
+
<div class="absolute inset-y-0 right-0 flex items-center gap-1 pr-1">
|
|
14
|
+
<button class={["ghost icon s-sm"]} {...machine.getClearTriggerProps()}><span aria-hidden="true"><span class="inline-block icon-sm i-lucide-x" aria-hidden="true"></span></span></button>
|
|
15
|
+
<button class={["ghost icon s-sm", { "cursor-not-allowed": machine.disabled }]} {...machine.getTriggerProps()}><span aria-hidden="true" class={["text-xs transition-transform duration-fast ease-decelerate", { "rotate-180": machine.open }]} {...machine.getTriggerIndicatorProps()}><span class="inline-block icon-sm i-lucide-chevron-down" aria-hidden="true"></span></span></button>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class={["absolute left-0 top-full z-dropdown mt-1 w-full origin-top transition duration-fast ease-decelerate", { "pointer-events-none invisible scale-95 opacity-0": !machine.open }]} {...machine.getPositionerProps()}>
|
|
19
|
+
<div class={["overflow-hidden rounded-lg border border-solid border-border bg-surface-raised shadow-lg", { "opacity-60": machine.disabled }]} {...machine.getContentProps()}>
|
|
20
|
+
<div class={["max-h-[15rem] overflow-y-auto p-1 transition-opacity duration-fast ease-decelerate", { "hidden": machine.empty }]} {...machine.getListProps()}>
|
|
21
|
+
<template for={machine.getBlocks()} as={block} key={block.id}>
|
|
22
|
+
<div class="py-1" {...machine.getItemGroupProps(block)}>
|
|
23
|
+
<span class="block px-2 py-1 text-xs font-medium text-text-muted" {...machine.getItemGroupLabelProps(block)}>{block.label}</span>
|
|
24
|
+
<template for={machine.getRows(block)} as={row} key={row.value}>
|
|
25
|
+
<div class={["relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1 text-sm text-text transition-colors duration-fast ease-decelerate", { "bg-surface": machine.highlightedValue === row.value, "text-primary": machine.value.includes(row.value), "cursor-not-allowed opacity-50": machine.disabled }]} {...machine.getItemProps(row)}>
|
|
26
|
+
<span class="min-w-0 flex-1 truncate" {...machine.getItemTextProps(row)}>{row.label}</span>
|
|
27
|
+
<span aria-hidden="true" class={["shrink-0 text-xs text-primary scale-50 opacity-0 transition-all duration-fast ease-decelerate", { "scale-100 opacity-100": machine.value.includes(row.value) }]} {...machine.getItemIndicatorProps(row)}><span class="inline-block icon-sm i-lucide-check" aria-hidden="true"></span></span>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<p class="mt-2 text-xs text-text-muted" show={machine.hasSelectedItems}>Selected: {machine.valueAsString}</p>
|
|
37
|
+
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DefinedComponent } from "@spinjs/runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The app-controller surface: `{ commands, state, bind, ref }`, for whichever
|
|
4
|
+
* component the host is holding.
|
|
5
|
+
*
|
|
6
|
+
* A component owns its state — a machine does, or the platform does behind a
|
|
7
|
+
* thin adapter. This handle does not care which: it is the instrument the
|
|
8
|
+
* host's app controller uses to reach it, through the same context markup
|
|
9
|
+
* consumes. Nothing here owns state, and nothing here re-implements the
|
|
10
|
+
* element — the host already has the element; this is what you can DO with
|
|
11
|
+
* it.
|
|
12
|
+
*
|
|
13
|
+
* `bind` needs only the element, so it works before the component connects
|
|
14
|
+
* — which matters, because a seed (`defaultValue`, `startMs`) is read during
|
|
15
|
+
* the component's build and a write that arrives after it is too late.
|
|
16
|
+
* `commands` and `state` resolve through the component's registered
|
|
17
|
+
* controller, which exists once it has connected; before then commands are
|
|
18
|
+
* safe no-ops and unknown state keys read `undefined`, and after they are
|
|
19
|
+
* the component's own surface.
|
|
20
|
+
*/
|
|
21
|
+
/** Any element locator: the element now, or a read of it on every access. */
|
|
22
|
+
export type ElementTarget = Element | (() => Element | null | undefined) | {
|
|
23
|
+
readonly current?: Element | null | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
readonly value?: Element | null | undefined;
|
|
26
|
+
} | null | undefined;
|
|
27
|
+
/** Prop-getter names never surface as commands. */
|
|
28
|
+
export type PropGetterName = `get${string}Props` | `get${string}Indexes`;
|
|
29
|
+
/** The callable members of an api, minus prop getters. */
|
|
30
|
+
export type CommandsOf<Api extends object> = { readonly [K in keyof Api as K extends PropGetterName ? never : Api[K] extends ((...args: never[]) => unknown) ? K : never]: Api[K]; };
|
|
31
|
+
/** The readable members of an api, as reactive thunks. */
|
|
32
|
+
export type StateOf<Api extends object> = { readonly [K in keyof Api as Api[K] extends ((...args: never[]) => unknown) ? never : K]: () => Api[K]; };
|
|
33
|
+
/** The inferred ctl for a `DefinedComponent`. */
|
|
34
|
+
export type CtlFor<D> = D extends DefinedComponent<infer Api, infer A> ? SpinComponentCtl<CommandsOf<Api>, StateOf<Api>, Partial<A>> : never;
|
|
35
|
+
/** What a host holds when it holds a spin component. */
|
|
36
|
+
export interface SpinComponentCtl<TCommands extends object = object, TState extends object = Record<string, () => unknown>, TProps extends object = Record<string, unknown>> {
|
|
37
|
+
/** Imperative calls the component declares. */
|
|
38
|
+
readonly commands: TCommands;
|
|
39
|
+
/** Reactive reads of the component's observable state. */
|
|
40
|
+
readonly state: TState;
|
|
41
|
+
/** The element setter for JSX `ref={ctl.ref}`; feeds `bind` and resolution. */
|
|
42
|
+
readonly ref: (el: Element | null | undefined) => void;
|
|
43
|
+
/** The controlled channel: props down, events up. */
|
|
44
|
+
bind(props?: TProps, on?: Readonly<Record<string, (event: CustomEvent) => void>>): () => void;
|
|
45
|
+
/** Re-run `listener` on any state move; returns a disposer. */
|
|
46
|
+
subscribe(listener: () => void): () => void;
|
|
47
|
+
}
|
|
48
|
+
/** The ctl for `target` — never nullish; resolution happens at call time. */
|
|
49
|
+
export declare function spinComponentCtl<D extends DefinedComponent<any, any>>(def: D): CtlFor<D>;
|
|
50
|
+
export declare function spinComponentCtl<D extends DefinedComponent<any, any>>(target: ElementTarget, def: D): CtlFor<D>;
|
|
51
|
+
export declare function spinComponentCtl<TCommands extends object = object, TState extends object = Record<string, () => unknown>, TProps extends object = Record<string, unknown>>(target: ElementTarget, handle?: object): SpinComponentCtl<TCommands, TState, TProps>;
|
|
52
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { bindSpinElement } from "./spin-element.js";
|
|
2
|
+
import { controllerOf, effect, scope, signal } from "@spinjs/runtime";
|
|
3
|
+
// src/controller.ts
|
|
4
|
+
function resolveTarget(target) {
|
|
5
|
+
if (target === null || target === void 0) return void 0;
|
|
6
|
+
if (typeof target === "function") return target() ?? void 0;
|
|
7
|
+
if (typeof target !== "object") return void 0;
|
|
8
|
+
if ("current" in target) return target.current ?? void 0;
|
|
9
|
+
if ("value" in target) return target.value ?? void 0;
|
|
10
|
+
return target;
|
|
11
|
+
}
|
|
12
|
+
function spinComponentCtl(target, handleOrDef) {
|
|
13
|
+
const isDef = (value) => typeof value === "function" && "createBridge" in value;
|
|
14
|
+
const targetArg = isDef(target) ? void 0 : target;
|
|
15
|
+
const node = signal(resolveTarget(targetArg));
|
|
16
|
+
const handle = isDef(handleOrDef) ? handleOrDef : handleOrDef;
|
|
17
|
+
const resolveController = () => {
|
|
18
|
+
const el = node() ?? resolveTarget(targetArg);
|
|
19
|
+
return el === void 0 ? void 0 : controllerOf(el, handle);
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
commands: new Proxy({}, {
|
|
23
|
+
get: (_t, key) => {
|
|
24
|
+
const found = resolveController()?.commands[key];
|
|
25
|
+
if (typeof found === "function") return found;
|
|
26
|
+
return (..._args) => {};
|
|
27
|
+
},
|
|
28
|
+
has: (_t, key) => key in (resolveController()?.commands ?? {}),
|
|
29
|
+
ownKeys: () => Reflect.ownKeys(resolveController()?.commands ?? {}),
|
|
30
|
+
getOwnPropertyDescriptor: (_t, key) => {
|
|
31
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(resolveController()?.commands ?? {}, key);
|
|
32
|
+
if (descriptor === void 0) return {
|
|
33
|
+
configurable: true,
|
|
34
|
+
enumerable: true
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
...descriptor,
|
|
38
|
+
configurable: true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
state: new Proxy({}, {
|
|
43
|
+
get: (_t, key) => {
|
|
44
|
+
const found = resolveController()?.state[key];
|
|
45
|
+
if (typeof found === "function") return found;
|
|
46
|
+
return () => void 0;
|
|
47
|
+
},
|
|
48
|
+
has: (_t, key) => key in (resolveController()?.state ?? {}),
|
|
49
|
+
ownKeys: () => Reflect.ownKeys(resolveController()?.state ?? {}),
|
|
50
|
+
getOwnPropertyDescriptor: (_t, key) => {
|
|
51
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(resolveController()?.state ?? {}, key);
|
|
52
|
+
if (descriptor === void 0) return {
|
|
53
|
+
configurable: true,
|
|
54
|
+
enumerable: true
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
...descriptor,
|
|
58
|
+
configurable: true
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
ref: (el) => {
|
|
63
|
+
node(el ?? void 0);
|
|
64
|
+
},
|
|
65
|
+
bind(props, on) {
|
|
66
|
+
const el = node() ?? resolveTarget(targetArg);
|
|
67
|
+
if (el === void 0) return () => {};
|
|
68
|
+
return bindSpinElement(el, {
|
|
69
|
+
props,
|
|
70
|
+
on
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
subscribe(listener) {
|
|
74
|
+
const owner = scope();
|
|
75
|
+
let first = true;
|
|
76
|
+
owner.run(() => effect(() => {
|
|
77
|
+
for (const read of Object.values(resolveController()?.state ?? {})) read();
|
|
78
|
+
if (first) {
|
|
79
|
+
first = false;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
listener();
|
|
83
|
+
}));
|
|
84
|
+
return () => owner.dispose();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export { spinComponentCtl };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=controller.js.map
|