@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,771 @@
|
|
|
1
|
+
import { parseCollection as parseCollection$1, parsePath, startOpen } from "./cascade.state.js";
|
|
2
|
+
import { cascade as cascade$1 } from "./cascade.machine.js";
|
|
3
|
+
import { ariaDisabled, ariaHidden, ariaLabelledBy, ariaOwns, defineComponent, disclosureTrigger, isRecord, listSurface, optionRow } from "@spinjs/runtime";
|
|
4
|
+
// src/cascade-select/cascade.presentation.ts
|
|
5
|
+
/** Path segments join with a comma in ids. */
|
|
6
|
+
const SEP = ",";
|
|
7
|
+
const pathKey = (path) => path.join(SEP);
|
|
8
|
+
/** The collection crosses the prop channel as JSON text (the grammar has no
|
|
9
|
+
* recursive type), so it is parsed and validated here rather than trusted
|
|
10
|
+
* at every read. */
|
|
11
|
+
const parseCollection = parseCollection$1;
|
|
12
|
+
const nodeAtPath = (collection, path) => {
|
|
13
|
+
let nodes = collection;
|
|
14
|
+
let found;
|
|
15
|
+
for (const segment of path) {
|
|
16
|
+
found = nodes.find((node) => node.value === segment);
|
|
17
|
+
if (found === void 0) return void 0;
|
|
18
|
+
nodes = found.children ?? [];
|
|
19
|
+
}
|
|
20
|
+
return found;
|
|
21
|
+
};
|
|
22
|
+
/** The nodes along a path, one per level. */
|
|
23
|
+
const itemsAlongPath = (collection, path) => {
|
|
24
|
+
const chain = [];
|
|
25
|
+
let nodes = collection;
|
|
26
|
+
for (const segment of path) {
|
|
27
|
+
const node = nodes.find((candidate) => candidate.value === segment);
|
|
28
|
+
if (node === void 0) break;
|
|
29
|
+
chain.push(node);
|
|
30
|
+
nodes = node.children ?? [];
|
|
31
|
+
}
|
|
32
|
+
return chain;
|
|
33
|
+
};
|
|
34
|
+
const hashValue = (value) => value.map((path) => path.join(",")).join(", ");
|
|
35
|
+
const itemAt = (list, index) => index >= 0 && index < list.length ? list[index] : void 0;
|
|
36
|
+
const samePath = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
37
|
+
/** Derive the visible levels: every node along the highlighted path
|
|
38
|
+
* contributes its children as the next level. Memoized on the collection
|
|
39
|
+
* and the highlight key: drilling in and back out restores the same
|
|
40
|
+
* array, so the row cells keep their identity and their handlers. */
|
|
41
|
+
const levelsCache = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
const levelsOf = (collection, highlighted) => {
|
|
43
|
+
const key = pathKey(highlighted);
|
|
44
|
+
let byKey = levelsCache.get(collection);
|
|
45
|
+
if (byKey === void 0) {
|
|
46
|
+
byKey = /* @__PURE__ */ new Map();
|
|
47
|
+
levelsCache.set(collection, byKey);
|
|
48
|
+
}
|
|
49
|
+
const hit = byKey.get(key);
|
|
50
|
+
if (hit !== void 0) return hit;
|
|
51
|
+
const levels = [];
|
|
52
|
+
const indexPath = [];
|
|
53
|
+
let nodes = collection;
|
|
54
|
+
let path = [];
|
|
55
|
+
for (let depth = 0; nodes.length > 0; depth++) {
|
|
56
|
+
const items = nodes.map((node, index) => {
|
|
57
|
+
const itemPath = [...path, node.value];
|
|
58
|
+
return {
|
|
59
|
+
key: pathKey(itemPath),
|
|
60
|
+
path: itemPath,
|
|
61
|
+
value: node.value,
|
|
62
|
+
label: node.label,
|
|
63
|
+
disabled: node.disabled === true,
|
|
64
|
+
hasChildren: (node.children?.length ?? 0) > 0,
|
|
65
|
+
depth,
|
|
66
|
+
indexInLevel: index,
|
|
67
|
+
indexPath: [...indexPath, index]
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
levels.push({
|
|
71
|
+
depth,
|
|
72
|
+
path,
|
|
73
|
+
key: depth === 0 ? "root" : pathKey(path),
|
|
74
|
+
items
|
|
75
|
+
});
|
|
76
|
+
const segment = highlighted[depth];
|
|
77
|
+
if (segment === void 0) break;
|
|
78
|
+
const at = nodes.findIndex((node) => node.value === segment);
|
|
79
|
+
const node = itemAt(nodes, at);
|
|
80
|
+
const children = node?.children;
|
|
81
|
+
if (node === void 0 || children === void 0 || children.length === 0) break;
|
|
82
|
+
indexPath.push(at);
|
|
83
|
+
path = [...path, node.value];
|
|
84
|
+
nodes = children;
|
|
85
|
+
}
|
|
86
|
+
byKey.set(key, levels);
|
|
87
|
+
return levels;
|
|
88
|
+
};
|
|
89
|
+
const itemByPath = (collection, highlighted, path) => {
|
|
90
|
+
for (const level of levelsOf(collection, highlighted)) {
|
|
91
|
+
const found = level.items.find((item) => samePath(item.path, path));
|
|
92
|
+
if (found !== void 0) return found;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const itemStateOf = (scope, item) => {
|
|
96
|
+
const ctx = scope.context;
|
|
97
|
+
const highlight = ctx.highlightedValue;
|
|
98
|
+
const selected = ctx.value.some((path) => samePath(path, item.path));
|
|
99
|
+
const highlighted = item.path.every((segment, index) => segment === highlight[index]);
|
|
100
|
+
const children = nodeAtPath(scope.context.collection, item.path)?.children ?? [];
|
|
101
|
+
const childSegment = highlighted ? highlight[item.depth + 1] : void 0;
|
|
102
|
+
const highlightedIndex = childSegment === void 0 ? void 0 : children.findIndex((child) => child.value === childSegment);
|
|
103
|
+
return {
|
|
104
|
+
value: item.path,
|
|
105
|
+
disabled: item.disabled,
|
|
106
|
+
highlighted,
|
|
107
|
+
selected,
|
|
108
|
+
hasChildren: item.hasChildren,
|
|
109
|
+
depth: item.depth,
|
|
110
|
+
highlightedChild: childSegment,
|
|
111
|
+
highlightedIndex: highlightedIndex === void 0 || highlightedIndex < 0 ? void 0 : highlightedIndex
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const itemHandlersByBridge = /* @__PURE__ */ new WeakMap();
|
|
115
|
+
const itemHandlers = (scope, item) => {
|
|
116
|
+
let byItem = itemHandlersByBridge.get(scope.send);
|
|
117
|
+
if (byItem === void 0) {
|
|
118
|
+
byItem = /* @__PURE__ */ new WeakMap();
|
|
119
|
+
itemHandlersByBridge.set(scope.send, byItem);
|
|
120
|
+
}
|
|
121
|
+
const hit = byItem.get(item);
|
|
122
|
+
if (hit !== void 0) return hit;
|
|
123
|
+
const made = {
|
|
124
|
+
onClick: () => {
|
|
125
|
+
if (item.disabled || !isInteractive$1(scope)) return;
|
|
126
|
+
scope.send({
|
|
127
|
+
type: "ITEM_CLICK",
|
|
128
|
+
value: [...item.path],
|
|
129
|
+
hasChildren: item.hasChildren
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
onPointerMove: (event) => {
|
|
133
|
+
if (!isInteractive$1(scope) || item.disabled || event.pointerType !== "mouse") return;
|
|
134
|
+
scope.send({
|
|
135
|
+
type: "ITEM_POINTER_ENTER",
|
|
136
|
+
value: [...item.path],
|
|
137
|
+
hasChildren: item.hasChildren
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
onDoubleClick: () => {
|
|
141
|
+
if (item.disabled || !isInteractive$1(scope)) return;
|
|
142
|
+
scope.send({ type: "CLOSE" });
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
byItem.set(item, made);
|
|
146
|
+
return made;
|
|
147
|
+
};
|
|
148
|
+
const fieldsetDisabled = (root) => {
|
|
149
|
+
const fieldset = root().closest("fieldset");
|
|
150
|
+
return fieldset !== null && fieldset.hasAttribute("disabled");
|
|
151
|
+
};
|
|
152
|
+
const disabledOf = (scope) => scope.context.disabled || fieldsetDisabled(scope.root);
|
|
153
|
+
const isInteractive$1 = (scope) => !(disabledOf(scope) || scope.context.readOnly);
|
|
154
|
+
const highlightPath = (scope, path) => {
|
|
155
|
+
scope.send({
|
|
156
|
+
type: "HIGHLIGHTED_VALUE_SET",
|
|
157
|
+
value: [...path]
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
/** The rows of the level holding `path`: its parent's children. */
|
|
161
|
+
const siblingsOf = (scope, path) => {
|
|
162
|
+
const level = levelsOf(scope.context.collection, scope.context.highlightedValue).find((candidate) => samePath(candidate.path, path.slice(0, -1)));
|
|
163
|
+
return level === void 0 ? [] : level.items;
|
|
164
|
+
};
|
|
165
|
+
const rootEdge = (scope, edge) => {
|
|
166
|
+
const level = levelsOf(scope.context.collection, scope.context.highlightedValue).find((candidate) => candidate.depth === 0);
|
|
167
|
+
const items = level === void 0 ? [] : level.items;
|
|
168
|
+
return edge === "first" ? items.find((item) => !item.disabled) : [...items].reverse().find((item) => !item.disabled);
|
|
169
|
+
};
|
|
170
|
+
const levelEdge = (scope, edge) => {
|
|
171
|
+
const items = siblingsOf(scope, scope.context.highlightedValue);
|
|
172
|
+
return edge === "first" ? items.find((item) => !item.disabled) : [...items].reverse().find((item) => !item.disabled);
|
|
173
|
+
};
|
|
174
|
+
const moveHighlight = (scope, delta) => {
|
|
175
|
+
const items = siblingsOf(scope, scope.context.highlightedValue);
|
|
176
|
+
const at = items.findIndex((item) => samePath(item.path, scope.context.highlightedValue));
|
|
177
|
+
if (at === -1) {
|
|
178
|
+
const end = delta > 0 ? items.find((item) => !item.disabled) : [...items].reverse().find((item) => !item.disabled);
|
|
179
|
+
if (end !== void 0) highlightPath(scope, end.path);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const loop = scope.context.loopFocus;
|
|
183
|
+
let index = at;
|
|
184
|
+
for (let count = 0; count < items.length; count++) {
|
|
185
|
+
index += delta > 0 ? 1 : -1;
|
|
186
|
+
if (index < 0 || index >= items.length) {
|
|
187
|
+
if (!loop) return;
|
|
188
|
+
index = index < 0 ? items.length - 1 : 0;
|
|
189
|
+
}
|
|
190
|
+
const item = itemAt(items, index);
|
|
191
|
+
if (item !== void 0 && !item.disabled) {
|
|
192
|
+
highlightPath(scope, item.path);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const enterChild = (scope) => {
|
|
198
|
+
const path = scope.context.highlightedValue;
|
|
199
|
+
const children = nodeAtPath(scope.context.collection, path)?.children ?? [];
|
|
200
|
+
if (path.length === 0 || children.length === 0) return;
|
|
201
|
+
const child = children.find((node) => node.disabled !== true);
|
|
202
|
+
if (child !== void 0) highlightPath(scope, [...path, child.value]);
|
|
203
|
+
};
|
|
204
|
+
/** Leaving at the root level closes with focus back on the trigger. */
|
|
205
|
+
const leaveChild = (scope) => {
|
|
206
|
+
const path = scope.context.highlightedValue;
|
|
207
|
+
if (path.length <= 1) {
|
|
208
|
+
scope.send({
|
|
209
|
+
type: "CLOSE",
|
|
210
|
+
restoreFocus: true
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
highlightPath(scope, path.slice(0, -1));
|
|
215
|
+
};
|
|
216
|
+
const selectHighlighted = (scope) => {
|
|
217
|
+
const path = scope.context.highlightedValue;
|
|
218
|
+
const item = itemByPath(scope.context.collection, path, path);
|
|
219
|
+
if (item === void 0) return;
|
|
220
|
+
if (!scope.context.allowParentSelection && item.hasChildren) return;
|
|
221
|
+
scope.send({
|
|
222
|
+
type: "ITEM_CLICK",
|
|
223
|
+
value: [...path],
|
|
224
|
+
hasChildren: item.hasChildren
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
const FOCUSABLE = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
|
|
228
|
+
const isExcludedTarget = (scope, target) => {
|
|
229
|
+
if (!(target instanceof Element)) return false;
|
|
230
|
+
const host = scope.root();
|
|
231
|
+
if (typeof host.querySelector !== "function") return false;
|
|
232
|
+
for (const part of ["trigger", "clearTrigger"]) {
|
|
233
|
+
const node = host.querySelector(`[id="${scope.id(part)}"]`);
|
|
234
|
+
if (node !== null && node instanceof Element && node.contains(target)) return true;
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
};
|
|
238
|
+
const focusableTarget = (target) => target instanceof Element && target.matches(FOCUSABLE);
|
|
239
|
+
const isEventFn = (value) => typeof value === "function";
|
|
240
|
+
const isInteractFn = (value) => typeof value === "function";
|
|
241
|
+
const callInteract = (fn, details) => {
|
|
242
|
+
if (!isInteractFn(fn)) return;
|
|
243
|
+
fn(details);
|
|
244
|
+
};
|
|
245
|
+
const callHost = (fn, event) => {
|
|
246
|
+
if (!isEventFn(fn)) return;
|
|
247
|
+
fn(event);
|
|
248
|
+
};
|
|
249
|
+
const reportOutside = (scope, kind, event, contextmenu) => {
|
|
250
|
+
const focusable = focusableTarget(event.target);
|
|
251
|
+
if (kind === "pointer") callHost(scope.context.onPointerDownOutside, event);
|
|
252
|
+
else callHost(scope.context.onFocusOutside, event);
|
|
253
|
+
callInteract(scope.context.onInteractOutside, {
|
|
254
|
+
focusable,
|
|
255
|
+
contextmenu,
|
|
256
|
+
originalEvent: event
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
const dismissSelf = (scope, restoreFocus) => {
|
|
260
|
+
scope.send({
|
|
261
|
+
type: "CLOSE",
|
|
262
|
+
restoreFocus
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
const onTriggerKeydown = (scope, event) => {
|
|
266
|
+
if (event.defaultPrevented || !isInteractive$1(scope)) return;
|
|
267
|
+
const forward = scope.context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
268
|
+
const back = scope.context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
269
|
+
const openWithEdge = (end) => {
|
|
270
|
+
const target = rootEdge(scope, end);
|
|
271
|
+
scope.send({
|
|
272
|
+
type: "TRIGGER_OPEN",
|
|
273
|
+
highlight: target === void 0 ? [] : [...target.path]
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
const openPlain = () => {
|
|
277
|
+
scope.send({
|
|
278
|
+
type: "TRIGGER_OPEN",
|
|
279
|
+
highlight: []
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
switch (event.key) {
|
|
283
|
+
case "ArrowUp":
|
|
284
|
+
openWithEdge("last");
|
|
285
|
+
break;
|
|
286
|
+
case "ArrowDown":
|
|
287
|
+
if (event.altKey) openPlain();
|
|
288
|
+
else openWithEdge("first");
|
|
289
|
+
break;
|
|
290
|
+
case "Enter":
|
|
291
|
+
case " ":
|
|
292
|
+
openWithEdge("first");
|
|
293
|
+
break;
|
|
294
|
+
case back:
|
|
295
|
+
openPlain();
|
|
296
|
+
break;
|
|
297
|
+
case forward:
|
|
298
|
+
openWithEdge("first");
|
|
299
|
+
break;
|
|
300
|
+
default: return;
|
|
301
|
+
}
|
|
302
|
+
event.preventDefault();
|
|
303
|
+
};
|
|
304
|
+
const onContentKeydown = (scope, event) => {
|
|
305
|
+
if (event.defaultPrevented || !isInteractive$1(scope)) return;
|
|
306
|
+
const forward = scope.context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
307
|
+
const back = scope.context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
308
|
+
switch (event.key) {
|
|
309
|
+
case "Tab":
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
return;
|
|
312
|
+
case "ArrowDown":
|
|
313
|
+
moveHighlight(scope, 1);
|
|
314
|
+
break;
|
|
315
|
+
case "ArrowUp":
|
|
316
|
+
moveHighlight(scope, -1);
|
|
317
|
+
break;
|
|
318
|
+
case forward:
|
|
319
|
+
enterChild(scope);
|
|
320
|
+
break;
|
|
321
|
+
case back:
|
|
322
|
+
leaveChild(scope);
|
|
323
|
+
break;
|
|
324
|
+
case "Home": {
|
|
325
|
+
const end = levelEdge(scope, "first");
|
|
326
|
+
if (end !== void 0) highlightPath(scope, end.path);
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case "End": {
|
|
330
|
+
const end = levelEdge(scope, "last");
|
|
331
|
+
if (end !== void 0) highlightPath(scope, end.path);
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "Enter":
|
|
335
|
+
case " ":
|
|
336
|
+
selectHighlighted(scope);
|
|
337
|
+
break;
|
|
338
|
+
default: return;
|
|
339
|
+
}
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
};
|
|
342
|
+
const onContentFocusOut = (scope, event) => {
|
|
343
|
+
if (scope.state !== "open") return;
|
|
344
|
+
const next = event.relatedTarget;
|
|
345
|
+
if (next instanceof Element && scope.root().contains(next)) return;
|
|
346
|
+
reportOutside(scope, "focus", event, false);
|
|
347
|
+
dismissSelf(scope, false);
|
|
348
|
+
};
|
|
349
|
+
/** The readout text: labels along each path, one selection per entry. */
|
|
350
|
+
const textFor = (context) => {
|
|
351
|
+
const chains = context.value.map((path) => itemsAlongPath(context.collection, path));
|
|
352
|
+
const custom = context.formatValue;
|
|
353
|
+
if (typeof custom === "function") return formatWith(custom, chains);
|
|
354
|
+
if (context.multiple) return chains.map((chain) => chain[chain.length - 1]?.label ?? "").join(", ");
|
|
355
|
+
return chains.map((chain) => chain.map((node) => node.label).join(" / ")).join(", ");
|
|
356
|
+
};
|
|
357
|
+
const isFormatFn = (value) => typeof value === "function";
|
|
358
|
+
const formatWith = (custom, chains) => {
|
|
359
|
+
if (!isFormatFn(custom)) return "";
|
|
360
|
+
const out = custom(chains);
|
|
361
|
+
return typeof out === "string" ? out : "";
|
|
362
|
+
};
|
|
363
|
+
const isScrollFn = (value) => typeof value === "function";
|
|
364
|
+
const callScroll = (custom, details) => {
|
|
365
|
+
if (!isScrollFn(custom)) return;
|
|
366
|
+
custom(details);
|
|
367
|
+
};
|
|
368
|
+
const levelOf = (arg) => {
|
|
369
|
+
if (!isRecord(arg)) return {
|
|
370
|
+
depth: 0,
|
|
371
|
+
path: [],
|
|
372
|
+
key: "root",
|
|
373
|
+
items: []
|
|
374
|
+
};
|
|
375
|
+
const items = arg["items"];
|
|
376
|
+
const depth = arg["depth"];
|
|
377
|
+
const path = arg["path"];
|
|
378
|
+
return {
|
|
379
|
+
depth: typeof depth === "number" ? depth : 0,
|
|
380
|
+
path: Array.isArray(path) && path.every((p) => typeof p === "string") ? path : [],
|
|
381
|
+
key: typeof arg["key"] === "string" ? arg["key"] : "root",
|
|
382
|
+
items: Array.isArray(items) ? items.filter(isCascadeItem) : []
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
const isCascadeItem = (value) => {
|
|
386
|
+
if (!isRecord(value)) return false;
|
|
387
|
+
return typeof value["value"] === "string" && Array.isArray(value["path"]);
|
|
388
|
+
};
|
|
389
|
+
/** Zag's `scrollToIndexFn`: a host that scrolls its own content supplies the
|
|
390
|
+
* how (with the active row's position in its level), the reflex still owns
|
|
391
|
+
* the when. */
|
|
392
|
+
const scrollParam = (scope) => {
|
|
393
|
+
const activeId = () => {
|
|
394
|
+
const highlighted = scope.context.highlightedValue;
|
|
395
|
+
return highlighted.length === 0 ? "" : scope.id("item", pathKey(highlighted));
|
|
396
|
+
};
|
|
397
|
+
const custom = scope.context.scrollToIndexFn;
|
|
398
|
+
if (typeof custom !== "function") return { activeId };
|
|
399
|
+
return {
|
|
400
|
+
activeId,
|
|
401
|
+
reveal: () => {
|
|
402
|
+
const path = scope.context.highlightedValue;
|
|
403
|
+
const level = levelsOf(scope.context.collection, path).find((candidate) => samePath(candidate.path, path.slice(0, -1)));
|
|
404
|
+
const at = level === void 0 ? -1 : level.items.findIndex((item) => samePath(item.path, path));
|
|
405
|
+
callScroll(custom, {
|
|
406
|
+
index: at < 0 ? 0 : at,
|
|
407
|
+
immediate: true,
|
|
408
|
+
depth: level === void 0 ? 0 : level.depth
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
const def = {
|
|
414
|
+
name: "cascade",
|
|
415
|
+
machine: (args, authored) => cascade$1(args, authored),
|
|
416
|
+
settled: ({ event, before, after, focus }) => {
|
|
417
|
+
if (after.state === "open" && before.state !== "open") focus("content");
|
|
418
|
+
if (event.type === "CLOSE" && event.restoreFocus === true) focus("trigger");
|
|
419
|
+
if (event.type === "CLEAR_TRIGGER_CLICK") focus("trigger");
|
|
420
|
+
if (event.type === "ITEM_CLICK" && before.state === "open" && after.state !== "open") focus("trigger");
|
|
421
|
+
},
|
|
422
|
+
start: (raw) => startOpen(raw) ? "open" : "idle",
|
|
423
|
+
reconcile: ({ context, parsed, authored, send, state }) => {
|
|
424
|
+
if (authored("open")) {
|
|
425
|
+
const outer = parsed["open"] === true;
|
|
426
|
+
if (state === "open" !== outer) {
|
|
427
|
+
send(outer ? { type: "CONTROLLED_OPEN" } : { type: "CONTROLLED_CLOSE" });
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
let moved = false;
|
|
432
|
+
const nextCollection = parseCollection$1(parsed["collection"]);
|
|
433
|
+
if (nextCollection !== context.collection) {
|
|
434
|
+
context.collection = nextCollection;
|
|
435
|
+
moved = true;
|
|
436
|
+
}
|
|
437
|
+
const invalid = parsed["invalid"] === true;
|
|
438
|
+
if (context.invalid !== invalid) {
|
|
439
|
+
context.invalid = invalid;
|
|
440
|
+
moved = true;
|
|
441
|
+
}
|
|
442
|
+
for (const name of [
|
|
443
|
+
"onFocusOutside",
|
|
444
|
+
"onInteractOutside",
|
|
445
|
+
"onPointerDownOutside",
|
|
446
|
+
"scrollToIndexFn",
|
|
447
|
+
"formatValue"
|
|
448
|
+
]) {
|
|
449
|
+
const next = parsed[name];
|
|
450
|
+
if (next !== void 0 && context[name] !== next) {
|
|
451
|
+
context[name] = next;
|
|
452
|
+
moved = true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return moved;
|
|
456
|
+
},
|
|
457
|
+
parts: {
|
|
458
|
+
root: { attrs: (scope) => ({
|
|
459
|
+
dir: scope.context.dir,
|
|
460
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
461
|
+
"data-invalid": scope.attr(scope.context.invalid),
|
|
462
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
463
|
+
}) },
|
|
464
|
+
label: { attrs: (scope) => ({
|
|
465
|
+
dir: scope.context.dir,
|
|
466
|
+
htmlFor: scope.id("hiddenInput"),
|
|
467
|
+
onClick: (event) => {
|
|
468
|
+
if (event.defaultPrevented || !isInteractive$1(scope)) return;
|
|
469
|
+
scope.send({ type: "TRIGGER_FOCUS" });
|
|
470
|
+
},
|
|
471
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
472
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
473
|
+
}) },
|
|
474
|
+
control: { attrs: (scope) => ({
|
|
475
|
+
dir: scope.context.dir,
|
|
476
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
477
|
+
"data-focus": scope.attr(scope.state === "focused"),
|
|
478
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
479
|
+
}) },
|
|
480
|
+
trigger: { attrs: (scope) => ({
|
|
481
|
+
type: "button",
|
|
482
|
+
role: "combobox",
|
|
483
|
+
dir: scope.context.dir,
|
|
484
|
+
"data-focus": scope.attr(scope.state === "focused"),
|
|
485
|
+
...disclosureTrigger(scope, {
|
|
486
|
+
expanded: scope.state === "open",
|
|
487
|
+
hasPopup: "listbox",
|
|
488
|
+
controls: { part: "content" }
|
|
489
|
+
}),
|
|
490
|
+
...ariaLabelledBy(scope, { part: "label" }),
|
|
491
|
+
disabled: disabledOf(scope),
|
|
492
|
+
onClick: (event) => {
|
|
493
|
+
if (event.defaultPrevented || !isInteractive$1(scope)) return;
|
|
494
|
+
scope.send({ type: "TRIGGER_CLICK" });
|
|
495
|
+
},
|
|
496
|
+
onFocus: () => scope.send({ type: "TRIGGER_FOCUS" }),
|
|
497
|
+
onBlur: () => scope.send({ type: "TRIGGER_BLUR" }),
|
|
498
|
+
onKeydown: (event) => onTriggerKeydown(scope, event),
|
|
499
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
500
|
+
"data-placement": scope.context.placement,
|
|
501
|
+
"data-placeholder-shown": scope.attr(scope.context.value.length === 0),
|
|
502
|
+
"data-readonly": scope.attr(scope.context.readOnly),
|
|
503
|
+
"data-invalid": scope.attr(scope.context.invalid),
|
|
504
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
505
|
+
}) },
|
|
506
|
+
indicator: { attrs: (scope) => ({
|
|
507
|
+
dir: scope.context.dir,
|
|
508
|
+
...ariaHidden(true),
|
|
509
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
510
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
511
|
+
}) },
|
|
512
|
+
valueText: {
|
|
513
|
+
id: "value-text",
|
|
514
|
+
attrs: (scope) => ({
|
|
515
|
+
dir: scope.context.dir,
|
|
516
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
517
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
518
|
+
})
|
|
519
|
+
},
|
|
520
|
+
clearTrigger: {
|
|
521
|
+
id: "clear-trigger",
|
|
522
|
+
attrs: (scope) => ({
|
|
523
|
+
type: "button",
|
|
524
|
+
dir: scope.context.dir,
|
|
525
|
+
"aria-label": "Clear value",
|
|
526
|
+
hidden: scope.context.value.length === 0,
|
|
527
|
+
disabled: disabledOf(scope),
|
|
528
|
+
onClick: (event) => {
|
|
529
|
+
if (event.defaultPrevented) return;
|
|
530
|
+
scope.send({ type: "CLEAR_TRIGGER_CLICK" });
|
|
531
|
+
},
|
|
532
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
533
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
534
|
+
})
|
|
535
|
+
},
|
|
536
|
+
positioner: { attrs: (scope) => {
|
|
537
|
+
const rect = scope.measure("trigger");
|
|
538
|
+
return {
|
|
539
|
+
dir: scope.context.dir,
|
|
540
|
+
"data-placement": scope.context.placement,
|
|
541
|
+
"data-side": scope.context.placement.split("-")[0] ?? "bottom",
|
|
542
|
+
style: { minWidth: rect === null ? "100%" : `${rect.width}px` },
|
|
543
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
544
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
545
|
+
};
|
|
546
|
+
} },
|
|
547
|
+
content: { attrs: (scope) => {
|
|
548
|
+
const highlighted = scope.context.highlightedValue;
|
|
549
|
+
return {
|
|
550
|
+
role: "listbox",
|
|
551
|
+
dir: scope.context.dir,
|
|
552
|
+
...listSurface(scope, {
|
|
553
|
+
labelledBy: { part: "label" },
|
|
554
|
+
activeDescendant: highlighted.length === 0 ? void 0 : {
|
|
555
|
+
part: "item",
|
|
556
|
+
slot: pathKey(highlighted)
|
|
557
|
+
},
|
|
558
|
+
multiSelectable: scope.context.multiple,
|
|
559
|
+
required: scope.context.required,
|
|
560
|
+
readOnly: scope.context.readOnly
|
|
561
|
+
}),
|
|
562
|
+
"data-activedescendant": highlighted.length === 0 ? void 0 : scope.id("item", pathKey(highlighted)),
|
|
563
|
+
hidden: scope.state !== "open",
|
|
564
|
+
tabIndex: 0,
|
|
565
|
+
onKeydown: (event) => onContentKeydown(scope, event),
|
|
566
|
+
onFocusOut: (event) => onContentFocusOut(scope, event),
|
|
567
|
+
"use:dismissable": {
|
|
568
|
+
onOutside: (event) => {
|
|
569
|
+
if (isExcludedTarget(scope, event.target)) return;
|
|
570
|
+
reportOutside(scope, "pointer", event, event.button === 2);
|
|
571
|
+
dismissSelf(scope, !(focusableTarget(event.target) || event.button === 2));
|
|
572
|
+
},
|
|
573
|
+
onEscape: () => dismissSelf(scope, true)
|
|
574
|
+
},
|
|
575
|
+
"use:scroll-into-view": scrollParam(scope),
|
|
576
|
+
"data-state": scope.state === "open" ? "open" : "closed",
|
|
577
|
+
...disabledOf(scope) ? { "data-disabled": "" } : {}
|
|
578
|
+
};
|
|
579
|
+
} },
|
|
580
|
+
hiddenInput: {
|
|
581
|
+
id: "hidden-input",
|
|
582
|
+
attrs: (scope) => ({
|
|
583
|
+
...typeof scope.context.name === "string" && scope.context.name.length > 0 ? { name: scope.context.name } : {},
|
|
584
|
+
...typeof scope.context.form === "string" && scope.context.form.length > 0 ? { form: scope.context.form } : {},
|
|
585
|
+
disabled: disabledOf(scope),
|
|
586
|
+
required: scope.context.required,
|
|
587
|
+
readOnly: scope.context.readOnly,
|
|
588
|
+
hidden: true,
|
|
589
|
+
...ariaHidden(true),
|
|
590
|
+
...ariaLabelledBy(scope, { part: "label" }),
|
|
591
|
+
value: hashValue(scope.context.value)
|
|
592
|
+
})
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
slots: {
|
|
596
|
+
list: {
|
|
597
|
+
indexes: (context) => levelsOf(context.collection, context.highlightedValue),
|
|
598
|
+
attrs: (scope) => {
|
|
599
|
+
const level = scope.slot;
|
|
600
|
+
return {
|
|
601
|
+
id: scope.id("list", level.path.join(",")),
|
|
602
|
+
dir: scope.context.dir,
|
|
603
|
+
role: "group",
|
|
604
|
+
"data-depth": level.depth,
|
|
605
|
+
...optionRow({ level: level.depth })
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
item: {
|
|
610
|
+
indexes: (context) => levelsOf(context.collection, context.highlightedValue).flatMap((level) => level.items),
|
|
611
|
+
attrs: (scope) => {
|
|
612
|
+
const item = scope.slot;
|
|
613
|
+
const state = itemStateOf(scope, item);
|
|
614
|
+
return {
|
|
615
|
+
id: scope.id("item", pathKey(item.path)),
|
|
616
|
+
role: "treeitem",
|
|
617
|
+
dir: scope.context.dir,
|
|
618
|
+
...disclosureTrigger(scope, {
|
|
619
|
+
expanded: item.hasChildren ? state.highlighted : false,
|
|
620
|
+
hasPopup: item.hasChildren ? "menu" : void 0,
|
|
621
|
+
controls: item.hasChildren ? {
|
|
622
|
+
part: "list",
|
|
623
|
+
slot: pathKey(item.path)
|
|
624
|
+
} : void 0
|
|
625
|
+
}),
|
|
626
|
+
...ariaOwns(scope, item.hasChildren ? {
|
|
627
|
+
part: "list",
|
|
628
|
+
slot: pathKey(item.path)
|
|
629
|
+
} : void 0),
|
|
630
|
+
...ariaDisabled(item.disabled),
|
|
631
|
+
"data-value": item.path.join(","),
|
|
632
|
+
"data-disabled": item.disabled ? "" : void 0,
|
|
633
|
+
"data-highlighted": state.highlighted ? "" : void 0,
|
|
634
|
+
"data-selected": state.selected ? "" : void 0,
|
|
635
|
+
"data-depth": item.depth,
|
|
636
|
+
"data-type": item.hasChildren ? "branch" : "leaf",
|
|
637
|
+
"data-index-path": item.indexPath.join(","),
|
|
638
|
+
...itemHandlers(scope, item)
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
itemText: {
|
|
643
|
+
indexes: (context) => levelsOf(context.collection, context.highlightedValue).flatMap((level) => level.items),
|
|
644
|
+
attrs: (scope) => {
|
|
645
|
+
const item = scope.slot;
|
|
646
|
+
const state = itemStateOf(scope, item);
|
|
647
|
+
return {
|
|
648
|
+
dir: scope.context.dir,
|
|
649
|
+
"data-value": item.value,
|
|
650
|
+
"data-highlighted": state.highlighted ? "" : void 0,
|
|
651
|
+
"data-selected": state.selected ? "" : void 0,
|
|
652
|
+
"data-disabled": item.disabled ? "" : void 0
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
itemIndicator: {
|
|
657
|
+
indexes: (context) => levelsOf(context.collection, context.highlightedValue).flatMap((level) => level.items),
|
|
658
|
+
attrs: (scope) => {
|
|
659
|
+
const item = scope.slot;
|
|
660
|
+
const state = itemStateOf(scope, item);
|
|
661
|
+
return {
|
|
662
|
+
...ariaHidden(true),
|
|
663
|
+
hidden: !state.selected,
|
|
664
|
+
"data-value": item.value,
|
|
665
|
+
"data-highlighted": state.highlighted ? "" : void 0,
|
|
666
|
+
"data-type": state.hasChildren ? "branch" : "leaf",
|
|
667
|
+
"data-selected": state.selected ? "" : void 0
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
commands: {
|
|
673
|
+
focus: { view: ({ focus }) => focus("trigger") },
|
|
674
|
+
setOpen: { event: (args) => ({ type: args[0] === true ? "OPEN" : "CLOSE" }) },
|
|
675
|
+
setHighlightValue: { event: (args) => ({
|
|
676
|
+
type: "HIGHLIGHTED_VALUE_SET",
|
|
677
|
+
value: [...parsePath(args[0])]
|
|
678
|
+
}) },
|
|
679
|
+
clearHighlightValue: { event: () => ({ type: "HIGHLIGHTED_VALUE_CLEAR" }) },
|
|
680
|
+
setValue: { event: ([value]) => ({
|
|
681
|
+
type: "VALUE_SET",
|
|
682
|
+
value: value.map((path) => [...path])
|
|
683
|
+
}) },
|
|
684
|
+
selectValue: { event: (args, context) => {
|
|
685
|
+
const value = [...parsePath(args[0])];
|
|
686
|
+
return {
|
|
687
|
+
type: "ITEM_SELECT",
|
|
688
|
+
value,
|
|
689
|
+
hasChildren: context.value.some((path) => samePath(path, value))
|
|
690
|
+
};
|
|
691
|
+
} },
|
|
692
|
+
clearValue: { event: (args) => args[0] === void 0 ? { type: "VALUE_CLEAR" } : {
|
|
693
|
+
type: "ITEM_CLEAR",
|
|
694
|
+
value: [...parsePath(args[0])]
|
|
695
|
+
} }
|
|
696
|
+
},
|
|
697
|
+
readers: {
|
|
698
|
+
open: { read: (_context, state) => state === "open" },
|
|
699
|
+
focused: { read: (_context, state) => state === "focused" },
|
|
700
|
+
multiple: { read: (context) => context.multiple },
|
|
701
|
+
disabled: { read: (context, _state, _props, root) => context.disabled || root !== void 0 && fieldsetDisabled(root) },
|
|
702
|
+
value: { read: (context) => context.value.map((path) => [...path]) },
|
|
703
|
+
highlightedValue: { read: (context) => [...context.highlightedValue] },
|
|
704
|
+
hasSelectedItems: { read: (context) => context.value.length > 0 },
|
|
705
|
+
empty: { read: (context) => context.value.length === 0 },
|
|
706
|
+
levels: { read: (context, _state, props) => levelsOf(context.collection, context.highlightedValue) }
|
|
707
|
+
},
|
|
708
|
+
methods: {
|
|
709
|
+
getLevels: { call: (context, _state, _args, props) => levelsOf(context.collection, context.highlightedValue) },
|
|
710
|
+
getItems: { call: (_context, _state, [level]) => levelOf(level).items },
|
|
711
|
+
getItemState: { call: (context, _state, [item]) => {
|
|
712
|
+
const highlight = context.highlightedValue;
|
|
713
|
+
const selected = context.value.some((path) => samePath(path, item.path));
|
|
714
|
+
const highlighted = item.path.every((segment, index) => segment === highlight[index]);
|
|
715
|
+
const children = nodeAtPath(context.collection, item.path)?.children ?? [];
|
|
716
|
+
const childSegment = highlighted ? highlight[item.depth + 1] : void 0;
|
|
717
|
+
const highlightedIndex = childSegment === void 0 ? void 0 : children.findIndex((child) => child.value === childSegment);
|
|
718
|
+
return {
|
|
719
|
+
value: item.path,
|
|
720
|
+
disabled: item.disabled,
|
|
721
|
+
highlighted,
|
|
722
|
+
selected,
|
|
723
|
+
hasChildren: item.hasChildren,
|
|
724
|
+
depth: item.depth,
|
|
725
|
+
highlightedChild: childSegment,
|
|
726
|
+
highlightedIndex: highlightedIndex === void 0 || highlightedIndex < 0 ? void 0 : highlightedIndex
|
|
727
|
+
};
|
|
728
|
+
} },
|
|
729
|
+
getValueText: { call: (context, _state, _args, _props) => textFor(context) },
|
|
730
|
+
getValueTextRows: { call: (context, _state, _args, _props) => [{ value: textFor(context) }] }
|
|
731
|
+
},
|
|
732
|
+
events: {
|
|
733
|
+
"open-change": {
|
|
734
|
+
prop: "onOpenChange",
|
|
735
|
+
watch: (_context, state) => [state === "open"],
|
|
736
|
+
detail: (watched, _event, _props, context) => ({
|
|
737
|
+
open: watched[0] === true,
|
|
738
|
+
value: context.value.map((path) => [...path])
|
|
739
|
+
})
|
|
740
|
+
},
|
|
741
|
+
"value-change": {
|
|
742
|
+
prop: "onValueChange",
|
|
743
|
+
watch: (context) => context.value.map((path) => pathKey(path)),
|
|
744
|
+
detail: (watched, _event, _props, context) => {
|
|
745
|
+
const keys = watched.filter((key) => typeof key === "string");
|
|
746
|
+
const collection = context.collection;
|
|
747
|
+
return {
|
|
748
|
+
value: keys.map((key) => key.split(SEP)),
|
|
749
|
+
items: keys.map((key) => itemsAlongPath(collection, key.split(SEP)))
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
"highlight-change": {
|
|
754
|
+
prop: "onHighlightChange",
|
|
755
|
+
watch: (context) => [pathKey(context.highlightedValue)],
|
|
756
|
+
detail: (watched, _event, _props, context) => {
|
|
757
|
+
const key = watched[0];
|
|
758
|
+
const path = typeof key === "string" && key.length > 0 ? key.split(SEP) : [];
|
|
759
|
+
const collection = context.collection;
|
|
760
|
+
return {
|
|
761
|
+
highlightedValue: [...path],
|
|
762
|
+
highlightedItems: itemsAlongPath(collection, path)
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
const cascade = defineComponent(def);
|
|
769
|
+
export { cascade, def, hashValue, itemsAlongPath, nodeAtPath, parseCollection, pathKey };
|
|
770
|
+
|
|
771
|
+
//# sourceMappingURL=cascade.presentation.js.map
|