@spinjs/components 0.0.0-stage → 0.1.0-preview.2
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,449 @@
|
|
|
1
|
+
import { isValueWithinRange, parseValue } from "./number-input.state.js";
|
|
2
|
+
import { numberInput as numberInput$1 } from "./number-input.machine.js";
|
|
3
|
+
import { defineComponent } from "@spinjs/runtime";
|
|
4
|
+
// src/number-input/number-input.presentation.ts
|
|
5
|
+
const SPIN_DWELL = 300;
|
|
6
|
+
const SPIN_REPEAT = 50;
|
|
7
|
+
const CURSOR_HALF = 7.5;
|
|
8
|
+
const PARTIAL_NUMBER = /^-?\d*\.?\d*$/;
|
|
9
|
+
const valueAsNumber = (context) => parseValue(context.value);
|
|
10
|
+
/** Focus the input and leave the caret at the end of what it holds. */
|
|
11
|
+
const focusInput = (scope) => {
|
|
12
|
+
if (!scope.context.focusInputOnChange) return;
|
|
13
|
+
const node = scope.root().ownerDocument?.getElementById(scope.id("input"));
|
|
14
|
+
if (node === null || node === void 0) return;
|
|
15
|
+
if (typeof node.focus !== "function") return;
|
|
16
|
+
node.focus({ preventScroll: true });
|
|
17
|
+
const text = node;
|
|
18
|
+
if (typeof text.setSelectionRange === "function" && typeof text.value === "string") {
|
|
19
|
+
const end = text.value.length;
|
|
20
|
+
text.setSelectionRange(end, end);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const disabledOf = (context) => context.disabled || context.fieldsetDisabled;
|
|
24
|
+
const invalidOf = (context) => {
|
|
25
|
+
if (context.invalid !== void 0) return context.invalid;
|
|
26
|
+
const at = valueAsNumber(context);
|
|
27
|
+
return (Number.isNaN(at) ? 0 : at) < context.min || (Number.isNaN(at) ? 0 : at) > context.max;
|
|
28
|
+
};
|
|
29
|
+
const canIncrement = (context) => {
|
|
30
|
+
if (context.allowOverflow) return true;
|
|
31
|
+
const at = valueAsNumber(context);
|
|
32
|
+
return (Number.isNaN(at) ? 0 : at) < context.max;
|
|
33
|
+
};
|
|
34
|
+
const canDecrement = (context) => {
|
|
35
|
+
if (context.allowOverflow) return true;
|
|
36
|
+
const at = valueAsNumber(context);
|
|
37
|
+
return (Number.isNaN(at) ? 0 : at) > context.min;
|
|
38
|
+
};
|
|
39
|
+
const roundToDpr = (value, dpr) => Math.floor(value * dpr + .5) / dpr;
|
|
40
|
+
const wrapPoint = (x, width) => width > 0 ? (x % width + width) % width : x;
|
|
41
|
+
const handlerTables = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
const handlersOf = (scope) => {
|
|
43
|
+
const found = handlerTables.get(scope.id);
|
|
44
|
+
if (found !== void 0) return found;
|
|
45
|
+
let lastScrubX = null;
|
|
46
|
+
const made = {
|
|
47
|
+
onInputFocus: () => {
|
|
48
|
+
scope.send({ type: "INPUT.FOCUS" });
|
|
49
|
+
},
|
|
50
|
+
onInputBlur: () => {
|
|
51
|
+
scope.send({ type: "INPUT.BLUR" });
|
|
52
|
+
},
|
|
53
|
+
onInput: (event) => {
|
|
54
|
+
scope.send({
|
|
55
|
+
type: "INPUT.CHANGE",
|
|
56
|
+
value: event.currentTarget.value
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onBeforeInput: (event) => {
|
|
60
|
+
const current = event.currentTarget;
|
|
61
|
+
const start = current.selectionStart ?? 0;
|
|
62
|
+
const end = current.selectionEnd ?? 0;
|
|
63
|
+
const next = current.value.slice(0, start) + (event.data ?? "") + current.value.slice(end);
|
|
64
|
+
if (!PARTIAL_NUMBER.test(next)) event.preventDefault();
|
|
65
|
+
},
|
|
66
|
+
onInputKeydown: (event) => {
|
|
67
|
+
if (event.defaultPrevented) return;
|
|
68
|
+
if (scope.context.readOnly) return;
|
|
69
|
+
if (event.isComposing) return;
|
|
70
|
+
const context = scope.context;
|
|
71
|
+
const isArrow = event.key === "ArrowUp" || event.key === "ArrowDown";
|
|
72
|
+
const step = event.altKey && isArrow ? context.smallStep : event.shiftKey && isArrow ? context.largeStep : context.step;
|
|
73
|
+
const naked = !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey;
|
|
74
|
+
switch (event.key) {
|
|
75
|
+
case "ArrowUp":
|
|
76
|
+
scope.send({
|
|
77
|
+
type: "INPUT.ARROW_UP",
|
|
78
|
+
step
|
|
79
|
+
});
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
break;
|
|
82
|
+
case "ArrowDown":
|
|
83
|
+
scope.send({
|
|
84
|
+
type: "INPUT.ARROW_DOWN",
|
|
85
|
+
step
|
|
86
|
+
});
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
break;
|
|
89
|
+
case "Home":
|
|
90
|
+
if (!naked) return;
|
|
91
|
+
scope.send({ type: "INPUT.HOME" });
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
break;
|
|
94
|
+
case "End":
|
|
95
|
+
if (!naked) return;
|
|
96
|
+
scope.send({ type: "INPUT.END" });
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
break;
|
|
99
|
+
case "Enter": scope.send({ type: "INPUT.ENTER" });
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
onInputWheel: (event) => {
|
|
103
|
+
if (!scope.context.allowMouseWheel) return;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const direction = Math.sign(event.deltaY) * -1;
|
|
106
|
+
if (direction === 1) scope.send({ type: "VALUE.INCREMENT" });
|
|
107
|
+
else if (direction === -1) scope.send({ type: "VALUE.DECREMENT" });
|
|
108
|
+
},
|
|
109
|
+
onScrubberDown: (event) => {
|
|
110
|
+
if (scope.context.disabled) return;
|
|
111
|
+
if (event.button !== 0) return;
|
|
112
|
+
const dpr = (typeof document === "undefined" ? void 0 : document)?.defaultView?.devicePixelRatio ?? 1;
|
|
113
|
+
const half = roundToDpr(CURSOR_HALF, dpr);
|
|
114
|
+
lastScrubX = event.clientX;
|
|
115
|
+
scope.send({
|
|
116
|
+
type: "SCRUBBER.PRESS_DOWN",
|
|
117
|
+
point: {
|
|
118
|
+
x: event.clientX - half,
|
|
119
|
+
y: event.clientY - half
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
focusInput(scope);
|
|
124
|
+
},
|
|
125
|
+
onScrubberMove: (event) => {
|
|
126
|
+
const point = scope.context.cursorPoint;
|
|
127
|
+
const from = lastScrubX;
|
|
128
|
+
lastScrubX = event.clientX;
|
|
129
|
+
if (point === null || from === null) return;
|
|
130
|
+
const doc = typeof document === "undefined" ? void 0 : document;
|
|
131
|
+
const dpr = doc?.defaultView?.devicePixelRatio ?? 1;
|
|
132
|
+
const step = roundToDpr(event.clientX - from, dpr);
|
|
133
|
+
if (step === 0) return;
|
|
134
|
+
const hint = step > 0 ? "increment" : "decrement";
|
|
135
|
+
const width = doc?.defaultView?.innerWidth ?? 0;
|
|
136
|
+
const rtl = scope.context.dir === "rtl";
|
|
137
|
+
scope.send({
|
|
138
|
+
type: "SCRUBBER.POINTER_MOVE",
|
|
139
|
+
hint: rtl ? hint === "increment" ? "decrement" : "increment" : hint,
|
|
140
|
+
point: {
|
|
141
|
+
x: wrapPoint(point.x + step, width),
|
|
142
|
+
y: point.y
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
},
|
|
147
|
+
onScrubberUp: () => {
|
|
148
|
+
lastScrubX = null;
|
|
149
|
+
scope.send({ type: "SCRUBBER.POINTER_UP" });
|
|
150
|
+
},
|
|
151
|
+
onDecrementDown: (event) => {
|
|
152
|
+
if (event.button !== 0) return;
|
|
153
|
+
scope.send({
|
|
154
|
+
type: "TRIGGER.PRESS_DOWN",
|
|
155
|
+
hint: "decrement"
|
|
156
|
+
});
|
|
157
|
+
if (event.pointerType === "mouse") event.preventDefault();
|
|
158
|
+
focusInput(scope);
|
|
159
|
+
},
|
|
160
|
+
onIncrementDown: (event) => {
|
|
161
|
+
if (event.button !== 0) return;
|
|
162
|
+
scope.send({
|
|
163
|
+
type: "TRIGGER.PRESS_DOWN",
|
|
164
|
+
hint: "increment"
|
|
165
|
+
});
|
|
166
|
+
if (event.pointerType === "mouse") event.preventDefault();
|
|
167
|
+
focusInput(scope);
|
|
168
|
+
},
|
|
169
|
+
onTriggerUp: () => {
|
|
170
|
+
scope.send({ type: "TRIGGER.PRESS_UP" });
|
|
171
|
+
},
|
|
172
|
+
onLabelClick: () => {
|
|
173
|
+
focusInput(scope);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
handlerTables.set(scope.id, made);
|
|
177
|
+
return made;
|
|
178
|
+
};
|
|
179
|
+
const def = {
|
|
180
|
+
name: "number-input",
|
|
181
|
+
machine: (args, authored) => numberInput$1(args, authored),
|
|
182
|
+
start: "idle",
|
|
183
|
+
parts: {
|
|
184
|
+
root: { attrs: (scope) => ({
|
|
185
|
+
dir: scope.context.dir,
|
|
186
|
+
"data-disabled": scope.attr(disabledOf(scope.context)),
|
|
187
|
+
"data-focus": scope.attr(scope.state === "focused"),
|
|
188
|
+
"data-invalid": scope.attr(invalidOf(scope.context)),
|
|
189
|
+
"data-scrubbing": scope.attr(scope.state === "scrubbing"),
|
|
190
|
+
"use:form-control": {
|
|
191
|
+
onDisabledChange: (value) => {
|
|
192
|
+
scope.send({
|
|
193
|
+
type: "FIELDSET.DISABLED",
|
|
194
|
+
value
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
onFormReset: () => {
|
|
198
|
+
scope.send({
|
|
199
|
+
type: "VALUE.SET",
|
|
200
|
+
value: scope.context.initialValue
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}) },
|
|
205
|
+
label: { attrs: (scope) => ({
|
|
206
|
+
dir: scope.context.dir,
|
|
207
|
+
"data-required": scope.attr(scope.context.required),
|
|
208
|
+
for: scope.id("input"),
|
|
209
|
+
onClick: () => {
|
|
210
|
+
focusInput(scope);
|
|
211
|
+
}
|
|
212
|
+
}) },
|
|
213
|
+
control: { attrs: (scope) => {
|
|
214
|
+
const context = scope.context;
|
|
215
|
+
const spinning = context.spin !== null;
|
|
216
|
+
return {
|
|
217
|
+
dir: context.dir,
|
|
218
|
+
role: "group",
|
|
219
|
+
"data-disabled": scope.attr(disabledOf(context)),
|
|
220
|
+
"data-focus": scope.attr(scope.state === "focused"),
|
|
221
|
+
"data-invalid": scope.attr(invalidOf(context)),
|
|
222
|
+
"data-scrubbing": scope.attr(scope.state === "scrubbing"),
|
|
223
|
+
"aria-disabled": disabledOf(context),
|
|
224
|
+
"aria-invalid": invalidOf(context),
|
|
225
|
+
"use:autoplay": {
|
|
226
|
+
interval: context.spin === "repeat" ? SPIN_REPEAT : SPIN_DWELL,
|
|
227
|
+
enabled: spinning,
|
|
228
|
+
onTick: () => {
|
|
229
|
+
scope.send(context.spin === "repeat" ? { type: "SPIN" } : { type: "CHANGE_DELAY" });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
} },
|
|
234
|
+
valueText: { attrs: (scope) => ({
|
|
235
|
+
dir: scope.context.dir,
|
|
236
|
+
"data-disabled": scope.attr(disabledOf(scope.context)),
|
|
237
|
+
"data-focus": scope.attr(scope.state === "focused")
|
|
238
|
+
}) },
|
|
239
|
+
input: {
|
|
240
|
+
id: "input",
|
|
241
|
+
attrs: (scope) => {
|
|
242
|
+
const context = scope.context;
|
|
243
|
+
const number = valueAsNumber(context);
|
|
244
|
+
return {
|
|
245
|
+
dir: context.dir,
|
|
246
|
+
type: "text",
|
|
247
|
+
role: "spinbutton",
|
|
248
|
+
name: context.name,
|
|
249
|
+
form: context.form,
|
|
250
|
+
inputMode: context.inputMode,
|
|
251
|
+
pattern: context.pattern,
|
|
252
|
+
autoComplete: "off",
|
|
253
|
+
autoCorrect: "off",
|
|
254
|
+
spellCheck: false,
|
|
255
|
+
value: context.value,
|
|
256
|
+
disabled: disabledOf(context),
|
|
257
|
+
readOnly: context.readOnly,
|
|
258
|
+
required: context.required,
|
|
259
|
+
"aria-invalid": invalidOf(context),
|
|
260
|
+
"aria-valuemin": context.min,
|
|
261
|
+
"aria-valuemax": context.max,
|
|
262
|
+
"aria-valuenow": Number.isNaN(number) ? void 0 : number,
|
|
263
|
+
"aria-roledescription": "numberfield",
|
|
264
|
+
onFocus: handlersOf(scope).onInputFocus,
|
|
265
|
+
onBlur: handlersOf(scope).onInputBlur,
|
|
266
|
+
onInput: handlersOf(scope).onInput,
|
|
267
|
+
onBeforeInput: handlersOf(scope).onBeforeInput,
|
|
268
|
+
onKeydown: handlersOf(scope).onInputKeydown,
|
|
269
|
+
onWheel: handlersOf(scope).onInputWheel
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
decrementTrigger: {
|
|
274
|
+
id: "decrement",
|
|
275
|
+
attrs: (scope) => {
|
|
276
|
+
const off = disabledOf(scope.context) || !canDecrement(scope.context) || scope.context.readOnly;
|
|
277
|
+
return {
|
|
278
|
+
dir: scope.context.dir,
|
|
279
|
+
type: "button",
|
|
280
|
+
disabled: off,
|
|
281
|
+
tabIndex: -1,
|
|
282
|
+
"aria-label": scope.context.decrementLabel,
|
|
283
|
+
"aria-controls": scope.id("input"),
|
|
284
|
+
onPointerDown: handlersOf(scope).onDecrementDown,
|
|
285
|
+
onPointerUp: handlersOf(scope).onTriggerUp,
|
|
286
|
+
onPointerLeave: handlersOf(scope).onTriggerUp
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
incrementTrigger: {
|
|
291
|
+
id: "increment",
|
|
292
|
+
attrs: (scope) => {
|
|
293
|
+
const off = disabledOf(scope.context) || !canIncrement(scope.context) || scope.context.readOnly;
|
|
294
|
+
return {
|
|
295
|
+
dir: scope.context.dir,
|
|
296
|
+
type: "button",
|
|
297
|
+
disabled: off,
|
|
298
|
+
tabIndex: -1,
|
|
299
|
+
"aria-label": scope.context.incrementLabel,
|
|
300
|
+
"aria-controls": scope.id("input"),
|
|
301
|
+
onPointerDown: handlersOf(scope).onIncrementDown,
|
|
302
|
+
onPointerUp: handlersOf(scope).onTriggerUp,
|
|
303
|
+
onPointerLeave: handlersOf(scope).onTriggerUp
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
scrubber: { attrs: (scope) => ({
|
|
308
|
+
dir: scope.context.dir,
|
|
309
|
+
role: "presentation",
|
|
310
|
+
onPointerDown: handlersOf(scope).onScrubberDown,
|
|
311
|
+
onPointerMove: handlersOf(scope).onScrubberMove,
|
|
312
|
+
onPointerUp: handlersOf(scope).onScrubberUp
|
|
313
|
+
}) },
|
|
314
|
+
cursor: { attrs: (scope) => {
|
|
315
|
+
const point = scope.context.cursorPoint;
|
|
316
|
+
return {
|
|
317
|
+
"aria-hidden": true,
|
|
318
|
+
hidden: !(scope.state === "scrubbing"),
|
|
319
|
+
style: {
|
|
320
|
+
left: `${point === null ? 0 : point.x}px`,
|
|
321
|
+
top: `${point === null ? 0 : point.y}px`
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
} }
|
|
325
|
+
},
|
|
326
|
+
readers: {
|
|
327
|
+
value: { read: (ctx) => ctx.value },
|
|
328
|
+
valueAsNumber: { read: (ctx) => parseValue(ctx.value) },
|
|
329
|
+
focused: { read: (_ctx, state) => state === "focused" },
|
|
330
|
+
scrubbing: { read: (_ctx, state) => state === "scrubbing" },
|
|
331
|
+
invalid: { read: (ctx) => {
|
|
332
|
+
if (ctx.invalid !== void 0) return ctx.invalid;
|
|
333
|
+
const at = Number.isNaN(Number.parseFloat(ctx.value)) ? 0 : Number.parseFloat(ctx.value);
|
|
334
|
+
return at < ctx.min || at > ctx.max;
|
|
335
|
+
} },
|
|
336
|
+
disabled: { read: (ctx) => ctx.disabled || ctx.fieldsetDisabled },
|
|
337
|
+
empty: { read: (ctx) => ctx.value === "" },
|
|
338
|
+
canIncrement: { read: (ctx) => {
|
|
339
|
+
if (ctx.allowOverflow) return true;
|
|
340
|
+
return (Number.isNaN(Number.parseFloat(ctx.value)) ? 0 : Number.parseFloat(ctx.value)) < ctx.max;
|
|
341
|
+
} },
|
|
342
|
+
canDecrement: { read: (ctx) => {
|
|
343
|
+
if (ctx.allowOverflow) return true;
|
|
344
|
+
const at = parseValue(ctx.value);
|
|
345
|
+
return (Number.isNaN(at) ? 0 : at) > ctx.min;
|
|
346
|
+
} },
|
|
347
|
+
required: { read: (ctx) => ctx.required }
|
|
348
|
+
},
|
|
349
|
+
commands: {
|
|
350
|
+
setValue: { event: ([value]) => ({
|
|
351
|
+
type: "VALUE.SET",
|
|
352
|
+
value
|
|
353
|
+
}) },
|
|
354
|
+
clearValue: { event: () => ({ type: "VALUE.CLEAR" }) },
|
|
355
|
+
increment: { event: () => ({ type: "VALUE.INCREMENT" }) },
|
|
356
|
+
decrement: { event: () => ({ type: "VALUE.DECREMENT" }) },
|
|
357
|
+
setToMax: { event: (_args, ctx) => ({
|
|
358
|
+
type: "VALUE.SET",
|
|
359
|
+
value: ctx.max
|
|
360
|
+
}) },
|
|
361
|
+
setToMin: { event: (_args, ctx) => ({
|
|
362
|
+
type: "VALUE.SET",
|
|
363
|
+
value: ctx.min
|
|
364
|
+
}) },
|
|
365
|
+
focus: { view: ({ focus }) => focus("input") }
|
|
366
|
+
},
|
|
367
|
+
events: {
|
|
368
|
+
"value-change": {
|
|
369
|
+
prop: "onValueChange",
|
|
370
|
+
watch: (ctx) => [ctx.value],
|
|
371
|
+
detail: (watched) => ({
|
|
372
|
+
value: watched[0],
|
|
373
|
+
valueAsNumber: parseValue(String(watched[0] ?? ""))
|
|
374
|
+
}),
|
|
375
|
+
select: (_event, before, after) => after.value === before.value ? null : {
|
|
376
|
+
value: after.value,
|
|
377
|
+
valueAsNumber: parseValue(after.value)
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
"value-commit": {
|
|
381
|
+
prop: "onValueCommit",
|
|
382
|
+
watch: (ctx) => [ctx.value],
|
|
383
|
+
detail: (watched) => ({
|
|
384
|
+
value: watched[0],
|
|
385
|
+
valueAsNumber: parseValue(String(watched[0] ?? ""))
|
|
386
|
+
}),
|
|
387
|
+
select: (event, _before, after) => event.type === "INPUT.BLUR" || event.type === "INPUT.ENTER" ? {
|
|
388
|
+
value: after.value,
|
|
389
|
+
valueAsNumber: parseValue(after.value)
|
|
390
|
+
} : null
|
|
391
|
+
},
|
|
392
|
+
"value-invalid": {
|
|
393
|
+
prop: "onValueInvalid",
|
|
394
|
+
watch: (ctx) => [ctx.value],
|
|
395
|
+
detail: (watched, _event, _props, ctx) => {
|
|
396
|
+
const v = parseValue(String(watched[0] ?? ""));
|
|
397
|
+
return {
|
|
398
|
+
reason: v > ctx.max ? "rangeOverflow" : "rangeUnderflow",
|
|
399
|
+
value: watched[0],
|
|
400
|
+
valueAsNumber: v
|
|
401
|
+
};
|
|
402
|
+
},
|
|
403
|
+
select: (event, _before, after) => {
|
|
404
|
+
const out = !isValueWithinRange(parseValue(after.value), after.min, after.max);
|
|
405
|
+
if (!out) return null;
|
|
406
|
+
if (event.type === "INPUT.BLUR") return {
|
|
407
|
+
reason: parseValue(after.value) > after.max ? "rangeOverflow" : "rangeUnderflow",
|
|
408
|
+
value: after.value,
|
|
409
|
+
valueAsNumber: parseValue(after.value)
|
|
410
|
+
};
|
|
411
|
+
if (event.type === "INPUT.CHANGE") return null;
|
|
412
|
+
if (out === !isValueWithinRange(parseValue(_before.value), _before.min, _before.max)) return null;
|
|
413
|
+
return {
|
|
414
|
+
reason: parseValue(after.value) > after.max ? "rangeOverflow" : "rangeUnderflow",
|
|
415
|
+
value: after.value,
|
|
416
|
+
valueAsNumber: parseValue(after.value)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"focus-change": {
|
|
421
|
+
prop: "onFocusChange",
|
|
422
|
+
watch: (ctx, state) => [state === "focused", ctx.value],
|
|
423
|
+
detail: (watched) => ({
|
|
424
|
+
focused: watched[0],
|
|
425
|
+
value: watched[1],
|
|
426
|
+
valueAsNumber: parseValue(String(watched[1] ?? ""))
|
|
427
|
+
}),
|
|
428
|
+
select: (event, _before, after, states) => {
|
|
429
|
+
const was = states?.was ?? "idle";
|
|
430
|
+
const is = states?.is ?? "idle";
|
|
431
|
+
if (was === "idle" && is !== "idle") return {
|
|
432
|
+
focused: true,
|
|
433
|
+
value: after.value,
|
|
434
|
+
valueAsNumber: parseValue(after.value)
|
|
435
|
+
};
|
|
436
|
+
if (was !== "idle" && (is === "idle" || event.type === "INPUT.BLUR" || event.type === "INPUT.ENTER")) return {
|
|
437
|
+
focused: false,
|
|
438
|
+
value: after.value,
|
|
439
|
+
valueAsNumber: parseValue(after.value)
|
|
440
|
+
};
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const numberInput = defineComponent(def);
|
|
447
|
+
export { def, numberInput };
|
|
448
|
+
|
|
449
|
+
//# sourceMappingURL=number-input.presentation.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { NumberInputHint, NumberInputPoint } from "./number-input.events.js";
|
|
2
|
+
export type NumberInputState = "idle" | "focused" | "scrubbing";
|
|
3
|
+
export interface NumberInputContext {
|
|
4
|
+
value: string;
|
|
5
|
+
hint: NumberInputHint | null;
|
|
6
|
+
cursorPoint: NumberInputPoint | null;
|
|
7
|
+
fieldsetDisabled: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
readOnly: boolean;
|
|
10
|
+
required: boolean;
|
|
11
|
+
invalid: boolean | undefined;
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
step: number;
|
|
15
|
+
largeStep: number;
|
|
16
|
+
smallStep: number;
|
|
17
|
+
allowOverflow: boolean;
|
|
18
|
+
allowMouseWheel: boolean;
|
|
19
|
+
focusInputOnChange: boolean;
|
|
20
|
+
clampValueOnBlur: boolean;
|
|
21
|
+
spinOnPress: boolean;
|
|
22
|
+
dir: "ltr" | "rtl";
|
|
23
|
+
inputMode: string;
|
|
24
|
+
pattern: string;
|
|
25
|
+
name: string | undefined;
|
|
26
|
+
form: string | undefined;
|
|
27
|
+
incrementLabel: string;
|
|
28
|
+
decrementLabel: string;
|
|
29
|
+
initialValue: string;
|
|
30
|
+
spin: "hold" | "repeat" | null;
|
|
31
|
+
}
|
|
32
|
+
export interface NumberInputArgs {
|
|
33
|
+
value?: string;
|
|
34
|
+
defaultValue?: string | undefined;
|
|
35
|
+
min?: string | number;
|
|
36
|
+
max?: string | number;
|
|
37
|
+
step?: string | number;
|
|
38
|
+
largeStep?: string | number;
|
|
39
|
+
smallStep?: string | number;
|
|
40
|
+
allowOverflow?: boolean;
|
|
41
|
+
allowMouseWheel?: boolean;
|
|
42
|
+
focusInputOnChange?: boolean;
|
|
43
|
+
clampValueOnBlur?: boolean;
|
|
44
|
+
spinOnPress?: boolean;
|
|
45
|
+
dir?: "ltr" | "rtl";
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
readOnly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
inputMode?: string;
|
|
51
|
+
pattern?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
form?: string;
|
|
54
|
+
incrementLabel?: string;
|
|
55
|
+
decrementLabel?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function asNumber(raw: unknown, fallback: number): number;
|
|
58
|
+
export declare function valueOf(raw: unknown): string | null;
|
|
59
|
+
export type NumberInputScalarKey = "min" | "max" | "step" | "largeStep" | "smallStep" | "allowOverflow" | "clampValueOnBlur" | "spinOnPress";
|
|
60
|
+
export declare function numberInputScalars(args: NumberInputArgs, authored?: (name: string) => boolean): Pick<NumberInputContext, NumberInputScalarKey>;
|
|
61
|
+
export declare function initial(args: NumberInputArgs, authored?: (name: string) => boolean): NumberInputContext;
|
|
62
|
+
export declare const parseValue: (raw: string) => number;
|
|
63
|
+
export declare const formatValue: (value: number) => string;
|
|
64
|
+
export declare const isValueWithinRange: (value: number, min: number, max: number) => boolean;
|
|
65
|
+
declare const countDecimals: (value: number) => number;
|
|
66
|
+
declare const decimalOp: (a: number, op: "+" | "-", b: number) => number;
|
|
67
|
+
export declare const incrementValue: (value: number, step: number) => number;
|
|
68
|
+
export declare const decrementValue: (value: number, step: number) => number;
|
|
69
|
+
export declare const clampValue: (value: number, min: number, max: number) => number;
|
|
70
|
+
export { countDecimals, decimalOp };
|
|
71
|
+
//# sourceMappingURL=number-input.state.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { defaultTwin } from "@spinjs/runtime";
|
|
2
|
+
// src/number-input/number-input.state.ts
|
|
3
|
+
const MIN_SAFE = Number.MIN_SAFE_INTEGER;
|
|
4
|
+
const MAX_SAFE = Number.MAX_SAFE_INTEGER;
|
|
5
|
+
const DEFAULT_STEP = 1;
|
|
6
|
+
function asNumber(raw, fallback) {
|
|
7
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : fallback;
|
|
8
|
+
if (typeof raw !== "string") return fallback;
|
|
9
|
+
const trimmed = raw.trim();
|
|
10
|
+
if (trimmed.length === 0) return fallback;
|
|
11
|
+
const parsed = Number(trimmed);
|
|
12
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
13
|
+
}
|
|
14
|
+
function valueOf(raw) {
|
|
15
|
+
if (typeof raw === "string") return raw;
|
|
16
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return raw.toString();
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function numberInputScalars(args, authored = () => false) {
|
|
20
|
+
const step = asNumber(args.step, DEFAULT_STEP);
|
|
21
|
+
const allowOverflow = args.allowOverflow === true;
|
|
22
|
+
return {
|
|
23
|
+
min: asNumber(args.min, MIN_SAFE),
|
|
24
|
+
max: asNumber(args.max, MAX_SAFE),
|
|
25
|
+
step,
|
|
26
|
+
largeStep: asNumber(args.largeStep, 10 * step),
|
|
27
|
+
smallStep: asNumber(args.smallStep, step / 10),
|
|
28
|
+
allowOverflow,
|
|
29
|
+
clampValueOnBlur: authored("clampValueOnBlur") ? args.clampValueOnBlur === true : !allowOverflow,
|
|
30
|
+
spinOnPress: args.spinOnPress !== false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function initial(args, authored = () => true) {
|
|
34
|
+
const written = (field) => authored(field) || authored(defaultTwin(field)) || args[defaultTwin(field)] !== void 0;
|
|
35
|
+
return {
|
|
36
|
+
value: written("value") ? valueOf(args.value) ?? "" : "",
|
|
37
|
+
hint: null,
|
|
38
|
+
cursorPoint: null,
|
|
39
|
+
fieldsetDisabled: false,
|
|
40
|
+
disabled: args.disabled === true,
|
|
41
|
+
readOnly: args.readOnly === true,
|
|
42
|
+
required: args.required === true,
|
|
43
|
+
invalid: authored("invalid") ? args.invalid === true : void 0,
|
|
44
|
+
...numberInputScalars(args, authored),
|
|
45
|
+
allowMouseWheel: args.allowMouseWheel === true,
|
|
46
|
+
focusInputOnChange: authored("focusInputOnChange") ? args.focusInputOnChange === true : true,
|
|
47
|
+
dir: args.dir === "rtl" ? "rtl" : "ltr",
|
|
48
|
+
inputMode: typeof args.inputMode === "string" && args.inputMode.length > 0 ? args.inputMode : "decimal",
|
|
49
|
+
pattern: typeof args.pattern === "string" && args.pattern.length > 0 ? args.pattern : "-?[0-9]*(.[0-9]+)?",
|
|
50
|
+
name: typeof args.name === "string" && args.name.length > 0 ? args.name : void 0,
|
|
51
|
+
form: typeof args.form === "string" && args.form.length > 0 ? args.form : void 0,
|
|
52
|
+
incrementLabel: typeof args.incrementLabel === "string" && args.incrementLabel.length > 0 ? args.incrementLabel : "increment value",
|
|
53
|
+
decrementLabel: typeof args.decrementLabel === "string" && args.decrementLabel.length > 0 ? args.decrementLabel : "decrease value",
|
|
54
|
+
initialValue: written("value") ? valueOf(args.value) ?? "" : valueOf(args.defaultValue) ?? "",
|
|
55
|
+
spin: null
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const parseValue = (raw) => Number.parseFloat(raw);
|
|
59
|
+
const formatValue = (value) => Number.isNaN(value) ? "" : value.toString();
|
|
60
|
+
const isValueWithinRange = (value, min, max) => {
|
|
61
|
+
const at = Number.isNaN(value) ? 0 : value;
|
|
62
|
+
return at >= min && at <= max;
|
|
63
|
+
};
|
|
64
|
+
const countDecimals = (value) => {
|
|
65
|
+
if (!Number.isFinite(value)) return 0;
|
|
66
|
+
let exponent = 1;
|
|
67
|
+
let places = 0;
|
|
68
|
+
while (Math.round(value * exponent) / exponent !== value) {
|
|
69
|
+
exponent *= 10;
|
|
70
|
+
places += 1;
|
|
71
|
+
}
|
|
72
|
+
return places;
|
|
73
|
+
};
|
|
74
|
+
const decimalOp = (a, op, b) => {
|
|
75
|
+
if (a % 1 === 0 && b % 1 === 0) return op === "+" ? a + b : a - b;
|
|
76
|
+
const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
|
|
77
|
+
const left = Math.round(a * multiplier);
|
|
78
|
+
const right = Math.round(b * multiplier);
|
|
79
|
+
return (op === "+" ? left + right : left - right) / multiplier;
|
|
80
|
+
};
|
|
81
|
+
const incrementValue = (value, step) => decimalOp(Number.isNaN(value) ? 0 : value, "+", step);
|
|
82
|
+
const decrementValue = (value, step) => decimalOp(Number.isNaN(value) ? 0 : value, "-", step);
|
|
83
|
+
const clampValue = (value, min, max) => Math.min(Math.max(Number.isNaN(value) ? 0 : value, min), max);
|
|
84
|
+
export { asNumber, clampValue, countDecimals, decimalOp, decrementValue, formatValue, incrementValue, initial, isValueWithinRange, numberInputScalars, parseValue, valueOf };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=number-input.state.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NumberInputEvent, NumberInputEvents } from "./number-input.events.js";
|
|
2
|
+
import { NumberInputContext } from "./number-input.state.js";
|
|
3
|
+
import { AssignFor, GuardFor } from "@spinjs/runtime/fsm";
|
|
4
|
+
type NumberInputAssign<K extends keyof NumberInputEvents = keyof NumberInputEvents> = AssignFor<NumberInputContext, NumberInputEvents, K>;
|
|
5
|
+
export declare const increment: NumberInputAssign<"VALUE.INCREMENT" | "INPUT.ARROW_UP" | "TRIGGER.PRESS_DOWN" | "SCRUBBER.POINTER_MOVE" | "SPIN">;
|
|
6
|
+
export declare const decrement: NumberInputAssign<"VALUE.DECREMENT" | "INPUT.ARROW_DOWN" | "TRIGGER.PRESS_DOWN" | "SCRUBBER.POINTER_MOVE" | "SPIN">;
|
|
7
|
+
export declare const setFormattedValue: NumberInputAssign<"INPUT.BLUR" | "INPUT.ENTER">;
|
|
8
|
+
export declare const beginSpin: NumberInputAssign<"TRIGGER.PRESS_DOWN">;
|
|
9
|
+
export declare const endSpin: () => Partial<NumberInputContext>;
|
|
10
|
+
export declare const clearHint: () => Partial<NumberInputContext>;
|
|
11
|
+
export declare const setCursorPoint: (_ctx: NumberInputContext, event: NumberInputEvent) => Partial<NumberInputContext>;
|
|
12
|
+
export declare const moved: (ctx: NumberInputContext, event: NumberInputEvent, op: (value: number, step: number) => number) => Partial<NumberInputContext>;
|
|
13
|
+
export declare const isIncrementHint: GuardFor<NumberInputContext, NumberInputEvents>;
|
|
14
|
+
export declare const isDecrementHint: GuardFor<NumberInputContext, NumberInputEvents>;
|
|
15
|
+
export declare const outOfRange: (ctx: NumberInputContext) => boolean;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=number-input.transitions.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { clampValue, decrementValue, formatValue, incrementValue, isValueWithinRange, parseValue } from "./number-input.state.js";
|
|
2
|
+
// src/number-input/number-input.transitions.ts
|
|
3
|
+
const increment = (ctx, event) => {
|
|
4
|
+
const step = "step" in event ? event.step : void 0;
|
|
5
|
+
const next = incrementValue(parseValue(ctx.value), step ?? ctx.step);
|
|
6
|
+
const bounded = ctx.allowOverflow ? next : clampValue(next, ctx.min, ctx.max);
|
|
7
|
+
return { value: formatValue(bounded) };
|
|
8
|
+
};
|
|
9
|
+
const decrement = (ctx, event) => {
|
|
10
|
+
const step = "step" in event ? event.step : void 0;
|
|
11
|
+
const next = decrementValue(parseValue(ctx.value), step ?? ctx.step);
|
|
12
|
+
const bounded = ctx.allowOverflow ? next : clampValue(next, ctx.min, ctx.max);
|
|
13
|
+
return { value: formatValue(bounded) };
|
|
14
|
+
};
|
|
15
|
+
const setFormattedValue = (ctx) => ({ value: formatValue(parseValue(ctx.value)) });
|
|
16
|
+
const beginSpin = (_ctx, event) => ({
|
|
17
|
+
hint: event.type === "TRIGGER.PRESS_DOWN" ? event.hint : null,
|
|
18
|
+
spin: "hold"
|
|
19
|
+
});
|
|
20
|
+
const endSpin = () => ({
|
|
21
|
+
hint: null,
|
|
22
|
+
spin: null
|
|
23
|
+
});
|
|
24
|
+
const clearHint = () => ({ hint: null });
|
|
25
|
+
const setCursorPoint = (_ctx, event) => {
|
|
26
|
+
const point = "point" in event ? event.point : void 0;
|
|
27
|
+
return point === void 0 ? {} : { cursorPoint: point };
|
|
28
|
+
};
|
|
29
|
+
const moved = (ctx, event, op) => {
|
|
30
|
+
const step = "step" in event ? event.step ?? ctx.step : ctx.step;
|
|
31
|
+
const next = op(parseValue(ctx.value), step);
|
|
32
|
+
const bounded = ctx.allowOverflow ? next : clampValue(next, ctx.min, ctx.max);
|
|
33
|
+
return { value: formatValue(bounded) };
|
|
34
|
+
};
|
|
35
|
+
const isIncrementHint = (ctx, event) => ("hint" in event ? event.hint : ctx.hint) === "increment";
|
|
36
|
+
const isDecrementHint = (ctx, event) => ("hint" in event ? event.hint : ctx.hint) === "decrement";
|
|
37
|
+
const outOfRange = (ctx) => !isValueWithinRange(parseValue(ctx.value), ctx.min, ctx.max);
|
|
38
|
+
export { beginSpin, clearHint, decrement, endSpin, increment, isDecrementHint, isIncrementHint, moved, outOfRange, setCursorPoint, setFormattedValue };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=number-input.transitions.js.map
|