@puzzle-ui/ui 0.0.0-stage → 0.1.0
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/README.md +16 -2
- package/dist/LICENSE +21 -0
- package/dist/components/actions/button/button-content.cjs +41 -0
- package/dist/components/actions/button/button-content.cjs.map +1 -0
- package/dist/components/actions/button/button-content.js +41 -0
- package/dist/components/actions/button/button-content.js.map +1 -0
- package/dist/components/actions/button/button.css +191 -0
- package/dist/components/actions/button/button.types.d.cts +30 -0
- package/dist/components/actions/button/button.types.d.ts +30 -0
- package/dist/components/actions/button/index.cjs +80 -0
- package/dist/components/actions/button/index.cjs.map +1 -0
- package/dist/components/actions/button/index.d.cts +3 -0
- package/dist/components/actions/button/index.d.ts +3 -0
- package/dist/components/actions/button/index.js +80 -0
- package/dist/components/actions/button/index.js.map +1 -0
- package/dist/components/actions/button-group/button-group.css +64 -0
- package/dist/components/actions/button-group/index.cjs +25 -0
- package/dist/components/actions/button-group/index.cjs.map +1 -0
- package/dist/components/actions/button-group/index.d.cts +14 -0
- package/dist/components/actions/button-group/index.d.ts +14 -0
- package/dist/components/actions/button-group/index.js +25 -0
- package/dist/components/actions/button-group/index.js.map +1 -0
- package/dist/components/actions/toggle-group/index.cjs +124 -0
- package/dist/components/actions/toggle-group/index.cjs.map +1 -0
- package/dist/components/actions/toggle-group/index.d.cts +10 -0
- package/dist/components/actions/toggle-group/index.d.ts +10 -0
- package/dist/components/actions/toggle-group/index.js +124 -0
- package/dist/components/actions/toggle-group/index.js.map +1 -0
- package/dist/components/actions/toggle-group/toggle-group.css +67 -0
- package/dist/components/actions/toggle-group/toggle-group.types.d.cts +54 -0
- package/dist/components/actions/toggle-group/toggle-group.types.d.ts +54 -0
- package/dist/components/data-display/alert/alert.css +128 -0
- package/dist/components/data-display/alert/alert.types.d.cts +14 -0
- package/dist/components/data-display/alert/alert.types.d.ts +14 -0
- package/dist/components/data-display/alert/alert.utils.cjs +11 -0
- package/dist/components/data-display/alert/alert.utils.cjs.map +1 -0
- package/dist/components/data-display/alert/alert.utils.js +11 -0
- package/dist/components/data-display/alert/alert.utils.js.map +1 -0
- package/dist/components/data-display/alert/index.cjs +103 -0
- package/dist/components/data-display/alert/index.cjs.map +1 -0
- package/dist/components/data-display/alert/index.d.cts +3 -0
- package/dist/components/data-display/alert/index.d.ts +3 -0
- package/dist/components/data-display/alert/index.js +103 -0
- package/dist/components/data-display/alert/index.js.map +1 -0
- package/dist/components/data-display/avatar/avatar.css +30 -0
- package/dist/components/data-display/avatar/index.cjs +42 -0
- package/dist/components/data-display/avatar/index.cjs.map +1 -0
- package/dist/components/data-display/avatar/index.d.cts +10 -0
- package/dist/components/data-display/avatar/index.d.ts +10 -0
- package/dist/components/data-display/avatar/index.js +42 -0
- package/dist/components/data-display/avatar/index.js.map +1 -0
- package/dist/components/data-display/badge/badge.css +91 -0
- package/dist/components/data-display/badge/index.cjs +31 -0
- package/dist/components/data-display/badge/index.cjs.map +1 -0
- package/dist/components/data-display/badge/index.d.cts +18 -0
- package/dist/components/data-display/badge/index.d.ts +18 -0
- package/dist/components/data-display/badge/index.js +31 -0
- package/dist/components/data-display/badge/index.js.map +1 -0
- package/dist/components/data-display/card/card.css +164 -0
- package/dist/components/data-display/card/index.cjs +42 -0
- package/dist/components/data-display/card/index.cjs.map +1 -0
- package/dist/components/data-display/card/index.d.cts +29 -0
- package/dist/components/data-display/card/index.d.ts +29 -0
- package/dist/components/data-display/card/index.js +35 -0
- package/dist/components/data-display/card/index.js.map +1 -0
- package/dist/components/data-display/image/image.css +80 -0
- package/dist/components/data-display/image/image.types.d.cts +154 -0
- package/dist/components/data-display/image/image.types.d.ts +154 -0
- package/dist/components/data-display/image/image.utils.cjs +55 -0
- package/dist/components/data-display/image/image.utils.cjs.map +1 -0
- package/dist/components/data-display/image/image.utils.js +51 -0
- package/dist/components/data-display/image/image.utils.js.map +1 -0
- package/dist/components/data-display/image/index.cjs +176 -0
- package/dist/components/data-display/image/index.cjs.map +1 -0
- package/dist/components/data-display/image/index.d.cts +3 -0
- package/dist/components/data-display/image/index.d.ts +3 -0
- package/dist/components/data-display/image/index.js +176 -0
- package/dist/components/data-display/image/index.js.map +1 -0
- package/dist/components/data-display/image/use-image-state.cjs +54 -0
- package/dist/components/data-display/image/use-image-state.cjs.map +1 -0
- package/dist/components/data-display/image/use-image-state.js +54 -0
- package/dist/components/data-display/image/use-image-state.js.map +1 -0
- package/dist/components/data-display/paper/index.cjs +16 -0
- package/dist/components/data-display/paper/index.cjs.map +1 -0
- package/dist/components/data-display/paper/index.d.cts +8 -0
- package/dist/components/data-display/paper/index.d.ts +8 -0
- package/dist/components/data-display/paper/index.js +16 -0
- package/dist/components/data-display/paper/index.js.map +1 -0
- package/dist/components/data-display/paper/paper.css +40 -0
- package/dist/components/data-display/progress/circular-progress.cjs +75 -0
- package/dist/components/data-display/progress/circular-progress.cjs.map +1 -0
- package/dist/components/data-display/progress/circular-progress.css +21 -0
- package/dist/components/data-display/progress/circular-progress.d.cts +9 -0
- package/dist/components/data-display/progress/circular-progress.d.ts +9 -0
- package/dist/components/data-display/progress/circular-progress.js +75 -0
- package/dist/components/data-display/progress/circular-progress.js.map +1 -0
- package/dist/components/data-display/progress/linear-progress.cjs +32 -0
- package/dist/components/data-display/progress/linear-progress.cjs.map +1 -0
- package/dist/components/data-display/progress/linear-progress.css +39 -0
- package/dist/components/data-display/progress/linear-progress.d.cts +5 -0
- package/dist/components/data-display/progress/linear-progress.d.ts +5 -0
- package/dist/components/data-display/progress/linear-progress.js +32 -0
- package/dist/components/data-display/progress/linear-progress.js.map +1 -0
- package/dist/components/data-display/progress/types.d.cts +5 -0
- package/dist/components/data-display/progress/types.d.ts +5 -0
- package/dist/components/data-display/progress/utils.cjs +16 -0
- package/dist/components/data-display/progress/utils.cjs.map +1 -0
- package/dist/components/data-display/progress/utils.js +15 -0
- package/dist/components/data-display/progress/utils.js.map +1 -0
- package/dist/components/data-display/skeleton/index.cjs +18 -0
- package/dist/components/data-display/skeleton/index.cjs.map +1 -0
- package/dist/components/data-display/skeleton/index.d.cts +10 -0
- package/dist/components/data-display/skeleton/index.d.ts +10 -0
- package/dist/components/data-display/skeleton/index.js +18 -0
- package/dist/components/data-display/skeleton/index.js.map +1 -0
- package/dist/components/data-display/skeleton/skeleton.css +47 -0
- package/dist/components/editors/text-editor/editor.cjs +620 -0
- package/dist/components/editors/text-editor/editor.cjs.map +1 -0
- package/dist/components/editors/text-editor/editor.d.cts +1 -0
- package/dist/components/editors/text-editor/editor.d.ts +1 -0
- package/dist/components/editors/text-editor/editor.js +620 -0
- package/dist/components/editors/text-editor/editor.js.map +1 -0
- package/dist/components/editors/text-editor/index.cjs +39 -0
- package/dist/components/editors/text-editor/index.cjs.map +1 -0
- package/dist/components/editors/text-editor/index.d.cts +13 -0
- package/dist/components/editors/text-editor/index.d.ts +13 -0
- package/dist/components/editors/text-editor/index.js +38 -0
- package/dist/components/editors/text-editor/index.js.map +1 -0
- package/dist/components/editors/text-editor/text-document.cjs +406 -0
- package/dist/components/editors/text-editor/text-document.cjs.map +1 -0
- package/dist/components/editors/text-editor/text-document.js +391 -0
- package/dist/components/editors/text-editor/text-document.js.map +1 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.cjs +251 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.cjs.map +1 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.css +16 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.d.cts +7 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.d.ts +7 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.js +251 -0
- package/dist/components/editors/text-editor/text-editor-toolbar.js.map +1 -0
- package/dist/components/editors/text-editor/text-editor.css +116 -0
- package/dist/components/editors/text-editor/text-editor.types.d.cts +37 -0
- package/dist/components/editors/text-editor/text-editor.types.d.ts +37 -0
- package/dist/components/editors/text-editor/text-parser.cjs +262 -0
- package/dist/components/editors/text-editor/text-parser.cjs.map +1 -0
- package/dist/components/editors/text-editor/text-parser.js +261 -0
- package/dist/components/editors/text-editor/text-parser.js.map +1 -0
- package/dist/components/editors/text-editor/text-renderer.cjs +85 -0
- package/dist/components/editors/text-editor/text-renderer.cjs.map +1 -0
- package/dist/components/editors/text-editor/text-renderer.d.cts +7 -0
- package/dist/components/editors/text-editor/text-renderer.d.ts +7 -0
- package/dist/components/editors/text-editor/text-renderer.js +85 -0
- package/dist/components/editors/text-editor/text-renderer.js.map +1 -0
- package/dist/components/forms/autocomplete/autocomplete.css +384 -0
- package/dist/components/forms/autocomplete/autocomplete.types.d.cts +86 -0
- package/dist/components/forms/autocomplete/autocomplete.types.d.ts +86 -0
- package/dist/components/forms/autocomplete/autocomplete.utils.cjs +47 -0
- package/dist/components/forms/autocomplete/autocomplete.utils.cjs.map +1 -0
- package/dist/components/forms/autocomplete/autocomplete.utils.js +44 -0
- package/dist/components/forms/autocomplete/autocomplete.utils.js.map +1 -0
- package/dist/components/forms/autocomplete/index.cjs +532 -0
- package/dist/components/forms/autocomplete/index.cjs.map +1 -0
- package/dist/components/forms/autocomplete/index.d.cts +3 -0
- package/dist/components/forms/autocomplete/index.d.ts +3 -0
- package/dist/components/forms/autocomplete/index.js +532 -0
- package/dist/components/forms/autocomplete/index.js.map +1 -0
- package/dist/components/forms/checkbox/checkbox.css +146 -0
- package/dist/components/forms/checkbox/index.cjs +80 -0
- package/dist/components/forms/checkbox/index.cjs.map +1 -0
- package/dist/components/forms/checkbox/index.d.cts +20 -0
- package/dist/components/forms/checkbox/index.d.ts +20 -0
- package/dist/components/forms/checkbox/index.js +80 -0
- package/dist/components/forms/checkbox/index.js.map +1 -0
- package/dist/components/forms/date-picker/date-picker.css +478 -0
- package/dist/components/forms/date-picker/date-picker.types.d.cts +75 -0
- package/dist/components/forms/date-picker/date-picker.types.d.ts +75 -0
- package/dist/components/forms/date-picker/date-picker.utils.cjs +76 -0
- package/dist/components/forms/date-picker/date-picker.utils.cjs.map +1 -0
- package/dist/components/forms/date-picker/date-picker.utils.js +64 -0
- package/dist/components/forms/date-picker/date-picker.utils.js.map +1 -0
- package/dist/components/forms/date-picker/index.cjs +572 -0
- package/dist/components/forms/date-picker/index.cjs.map +1 -0
- package/dist/components/forms/date-picker/index.d.cts +3 -0
- package/dist/components/forms/date-picker/index.d.ts +3 -0
- package/dist/components/forms/date-picker/index.js +572 -0
- package/dist/components/forms/date-picker/index.js.map +1 -0
- package/dist/components/forms/file-upload/file-upload.css +290 -0
- package/dist/components/forms/file-upload/file-upload.types.d.cts +51 -0
- package/dist/components/forms/file-upload/file-upload.types.d.ts +51 -0
- package/dist/components/forms/file-upload/file-upload.utils.cjs +76 -0
- package/dist/components/forms/file-upload/file-upload.utils.cjs.map +1 -0
- package/dist/components/forms/file-upload/file-upload.utils.js +72 -0
- package/dist/components/forms/file-upload/file-upload.utils.js.map +1 -0
- package/dist/components/forms/file-upload/index.cjs +346 -0
- package/dist/components/forms/file-upload/index.cjs.map +1 -0
- package/dist/components/forms/file-upload/index.d.cts +3 -0
- package/dist/components/forms/file-upload/index.d.ts +3 -0
- package/dist/components/forms/file-upload/index.js +346 -0
- package/dist/components/forms/file-upload/index.js.map +1 -0
- package/dist/components/forms/form-field/form-field-state.cjs +25 -0
- package/dist/components/forms/form-field/form-field-state.cjs.map +1 -0
- package/dist/components/forms/form-field/form-field-state.js +25 -0
- package/dist/components/forms/form-field/form-field-state.js.map +1 -0
- package/dist/components/forms/form-field/form-field.css +44 -0
- package/dist/components/forms/form-field/index.cjs +61 -0
- package/dist/components/forms/form-field/index.cjs.map +1 -0
- package/dist/components/forms/form-field/index.d.cts +23 -0
- package/dist/components/forms/form-field/index.d.ts +23 -0
- package/dist/components/forms/form-field/index.js +61 -0
- package/dist/components/forms/form-field/index.js.map +1 -0
- package/dist/components/forms/input/index.d.cts +4 -0
- package/dist/components/forms/input/index.d.ts +4 -0
- package/dist/components/forms/input/input.css +153 -0
- package/dist/components/forms/input/number-input.cjs +192 -0
- package/dist/components/forms/input/number-input.cjs.map +1 -0
- package/dist/components/forms/input/number-input.d.cts +20 -0
- package/dist/components/forms/input/number-input.d.ts +20 -0
- package/dist/components/forms/input/number-input.js +192 -0
- package/dist/components/forms/input/number-input.js.map +1 -0
- package/dist/components/forms/input/text-area-input.cjs +47 -0
- package/dist/components/forms/input/text-area-input.cjs.map +1 -0
- package/dist/components/forms/input/text-area-input.d.cts +8 -0
- package/dist/components/forms/input/text-area-input.d.ts +8 -0
- package/dist/components/forms/input/text-area-input.js +47 -0
- package/dist/components/forms/input/text-area-input.js.map +1 -0
- package/dist/components/forms/input/text-input.cjs +47 -0
- package/dist/components/forms/input/text-input.cjs.map +1 -0
- package/dist/components/forms/input/text-input.d.cts +9 -0
- package/dist/components/forms/input/text-input.d.ts +9 -0
- package/dist/components/forms/input/text-input.js +47 -0
- package/dist/components/forms/input/text-input.js.map +1 -0
- package/dist/components/forms/label/index.cjs +26 -0
- package/dist/components/forms/label/index.cjs.map +1 -0
- package/dist/components/forms/label/index.d.cts +8 -0
- package/dist/components/forms/label/index.d.ts +8 -0
- package/dist/components/forms/label/index.js +26 -0
- package/dist/components/forms/label/index.js.map +1 -0
- package/dist/components/forms/label/label.css +22 -0
- package/dist/components/forms/radio-group/index.cjs +226 -0
- package/dist/components/forms/radio-group/index.cjs.map +1 -0
- package/dist/components/forms/radio-group/index.d.cts +5 -0
- package/dist/components/forms/radio-group/index.d.ts +5 -0
- package/dist/components/forms/radio-group/index.js +225 -0
- package/dist/components/forms/radio-group/index.js.map +1 -0
- package/dist/components/forms/radio-group/radio-group.css +222 -0
- package/dist/components/forms/radio-group/radio-group.types.d.cts +51 -0
- package/dist/components/forms/radio-group/radio-group.types.d.ts +51 -0
- package/dist/components/forms/radio-group/radio-group.utils.cjs +22 -0
- package/dist/components/forms/radio-group/radio-group.utils.cjs.map +1 -0
- package/dist/components/forms/radio-group/radio-group.utils.js +21 -0
- package/dist/components/forms/radio-group/radio-group.utils.js.map +1 -0
- package/dist/components/forms/select/index.cjs +468 -0
- package/dist/components/forms/select/index.cjs.map +1 -0
- package/dist/components/forms/select/index.d.cts +112 -0
- package/dist/components/forms/select/index.d.ts +112 -0
- package/dist/components/forms/select/index.js +468 -0
- package/dist/components/forms/select/index.js.map +1 -0
- package/dist/components/forms/select/select.css +363 -0
- package/dist/components/forms/slider/index.cjs +93 -0
- package/dist/components/forms/slider/index.cjs.map +1 -0
- package/dist/components/forms/slider/index.d.cts +37 -0
- package/dist/components/forms/slider/index.d.ts +37 -0
- package/dist/components/forms/slider/index.js +93 -0
- package/dist/components/forms/slider/index.js.map +1 -0
- package/dist/components/forms/slider/slider.css +202 -0
- package/dist/components/forms/stepper/index.cjs +113 -0
- package/dist/components/forms/stepper/index.cjs.map +1 -0
- package/dist/components/forms/stepper/index.d.cts +48 -0
- package/dist/components/forms/stepper/index.d.ts +48 -0
- package/dist/components/forms/stepper/index.js +113 -0
- package/dist/components/forms/stepper/index.js.map +1 -0
- package/dist/components/forms/stepper/stepper.css +241 -0
- package/dist/components/forms/switch/index.cjs +45 -0
- package/dist/components/forms/switch/index.cjs.map +1 -0
- package/dist/components/forms/switch/index.d.cts +11 -0
- package/dist/components/forms/switch/index.d.ts +11 -0
- package/dist/components/forms/switch/index.js +45 -0
- package/dist/components/forms/switch/index.js.map +1 -0
- package/dist/components/forms/switch/switch.css +142 -0
- package/dist/components/layout/app-bar/app-bar.css +197 -0
- package/dist/components/layout/app-bar/index.cjs +150 -0
- package/dist/components/layout/app-bar/index.cjs.map +1 -0
- package/dist/components/layout/app-bar/index.d.cts +21 -0
- package/dist/components/layout/app-bar/index.d.ts +21 -0
- package/dist/components/layout/app-bar/index.js +150 -0
- package/dist/components/layout/app-bar/index.js.map +1 -0
- package/dist/components/layout/background/background.css +160 -0
- package/dist/components/layout/background/index.cjs +34 -0
- package/dist/components/layout/background/index.cjs.map +1 -0
- package/dist/components/layout/background/index.d.cts +23 -0
- package/dist/components/layout/background/index.d.ts +23 -0
- package/dist/components/layout/background/index.js +34 -0
- package/dist/components/layout/background/index.js.map +1 -0
- package/dist/components/layout/bottom-navigation/bottom-navigation.css +108 -0
- package/dist/components/layout/bottom-navigation/index.cjs +51 -0
- package/dist/components/layout/bottom-navigation/index.cjs.map +1 -0
- package/dist/components/layout/bottom-navigation/index.d.cts +19 -0
- package/dist/components/layout/bottom-navigation/index.d.ts +19 -0
- package/dist/components/layout/bottom-navigation/index.js +50 -0
- package/dist/components/layout/bottom-navigation/index.js.map +1 -0
- package/dist/components/layout/breadcrumbs/breadcrumbs.css +80 -0
- package/dist/components/layout/breadcrumbs/index.cjs +38 -0
- package/dist/components/layout/breadcrumbs/index.cjs.map +1 -0
- package/dist/components/layout/breadcrumbs/index.d.cts +18 -0
- package/dist/components/layout/breadcrumbs/index.d.ts +18 -0
- package/dist/components/layout/breadcrumbs/index.js +38 -0
- package/dist/components/layout/breadcrumbs/index.js.map +1 -0
- package/dist/components/layout/collapsable-sidebar/collapsable-sidebar.css +240 -0
- package/dist/components/layout/collapsable-sidebar/index.cjs +107 -0
- package/dist/components/layout/collapsable-sidebar/index.cjs.map +1 -0
- package/dist/components/layout/collapsable-sidebar/index.d.cts +35 -0
- package/dist/components/layout/collapsable-sidebar/index.d.ts +35 -0
- package/dist/components/layout/collapsable-sidebar/index.js +107 -0
- package/dist/components/layout/collapsable-sidebar/index.js.map +1 -0
- package/dist/components/layout/container/container.css +24 -0
- package/dist/components/layout/container/container.utils.cjs +11 -0
- package/dist/components/layout/container/container.utils.cjs.map +1 -0
- package/dist/components/layout/container/container.utils.d.cts +1 -0
- package/dist/components/layout/container/container.utils.d.ts +1 -0
- package/dist/components/layout/container/container.utils.js +11 -0
- package/dist/components/layout/container/container.utils.js.map +1 -0
- package/dist/components/layout/container/index.cjs +17 -0
- package/dist/components/layout/container/index.cjs.map +1 -0
- package/dist/components/layout/container/index.d.cts +11 -0
- package/dist/components/layout/container/index.d.ts +11 -0
- package/dist/components/layout/container/index.js +17 -0
- package/dist/components/layout/container/index.js.map +1 -0
- package/dist/components/layout/page-layout/index.cjs +80 -0
- package/dist/components/layout/page-layout/index.cjs.map +1 -0
- package/dist/components/layout/page-layout/index.d.cts +61 -0
- package/dist/components/layout/page-layout/index.d.ts +61 -0
- package/dist/components/layout/page-layout/index.js +80 -0
- package/dist/components/layout/page-layout/index.js.map +1 -0
- package/dist/components/layout/page-layout/page-layout.css +88 -0
- package/dist/components/layout/section/index.cjs +15 -0
- package/dist/components/layout/section/index.cjs.map +1 -0
- package/dist/components/layout/section/index.d.cts +2 -0
- package/dist/components/layout/section/index.d.ts +2 -0
- package/dist/components/layout/section/index.js +15 -0
- package/dist/components/layout/section/index.js.map +1 -0
- package/dist/components/layout/section/section.css +71 -0
- package/dist/components/layout/section/types.d.cts +13 -0
- package/dist/components/layout/section/types.d.ts +13 -0
- package/dist/components/layout/section-stack/index.cjs +29 -0
- package/dist/components/layout/section-stack/index.cjs.map +1 -0
- package/dist/components/layout/section-stack/index.d.cts +8 -0
- package/dist/components/layout/section-stack/index.d.ts +8 -0
- package/dist/components/layout/section-stack/index.js +29 -0
- package/dist/components/layout/section-stack/index.js.map +1 -0
- package/dist/components/layout/sidebar/index.cjs +16 -0
- package/dist/components/layout/sidebar/index.cjs.map +1 -0
- package/dist/components/layout/sidebar/index.d.cts +7 -0
- package/dist/components/layout/sidebar/index.d.ts +7 -0
- package/dist/components/layout/sidebar/index.js +16 -0
- package/dist/components/layout/sidebar/index.js.map +1 -0
- package/dist/components/layout/sidebar/sidebar.css +21 -0
- package/dist/components/layout/stack/index.cjs +30 -0
- package/dist/components/layout/stack/index.cjs.map +1 -0
- package/dist/components/layout/stack/index.d.cts +31 -0
- package/dist/components/layout/stack/index.d.ts +31 -0
- package/dist/components/layout/stack/index.js +30 -0
- package/dist/components/layout/stack/index.js.map +1 -0
- package/dist/components/layout/stack/stack.css +303 -0
- package/dist/components/navigation/accordion/accordion.css +97 -0
- package/dist/components/navigation/accordion/index.cjs +107 -0
- package/dist/components/navigation/accordion/index.cjs.map +1 -0
- package/dist/components/navigation/accordion/index.d.cts +48 -0
- package/dist/components/navigation/accordion/index.d.ts +48 -0
- package/dist/components/navigation/accordion/index.js +107 -0
- package/dist/components/navigation/accordion/index.js.map +1 -0
- package/dist/components/navigation/carousel/carousel.css +283 -0
- package/dist/components/navigation/carousel/controller.cjs +46 -0
- package/dist/components/navigation/carousel/controller.cjs.map +1 -0
- package/dist/components/navigation/carousel/controller.d.cts +16 -0
- package/dist/components/navigation/carousel/controller.d.ts +16 -0
- package/dist/components/navigation/carousel/controller.js +45 -0
- package/dist/components/navigation/carousel/controller.js.map +1 -0
- package/dist/components/navigation/carousel/index.cjs +494 -0
- package/dist/components/navigation/carousel/index.cjs.map +1 -0
- package/dist/components/navigation/carousel/index.d.cts +27 -0
- package/dist/components/navigation/carousel/index.d.ts +27 -0
- package/dist/components/navigation/carousel/index.js +494 -0
- package/dist/components/navigation/carousel/index.js.map +1 -0
- package/dist/components/navigation/link/index.cjs +40 -0
- package/dist/components/navigation/link/index.cjs.map +1 -0
- package/dist/components/navigation/link/index.d.cts +3 -0
- package/dist/components/navigation/link/index.d.ts +3 -0
- package/dist/components/navigation/link/index.js +40 -0
- package/dist/components/navigation/link/index.js.map +1 -0
- package/dist/components/navigation/link/link.css +31 -0
- package/dist/components/navigation/link/types.d.cts +12 -0
- package/dist/components/navigation/link/types.d.ts +12 -0
- package/dist/components/navigation/tabs/index.cjs +111 -0
- package/dist/components/navigation/tabs/index.cjs.map +1 -0
- package/dist/components/navigation/tabs/index.d.cts +30 -0
- package/dist/components/navigation/tabs/index.d.ts +30 -0
- package/dist/components/navigation/tabs/index.js +110 -0
- package/dist/components/navigation/tabs/index.js.map +1 -0
- package/dist/components/navigation/tabs/tabs.css +216 -0
- package/dist/components/navigation/tree-view/index.cjs +455 -0
- package/dist/components/navigation/tree-view/index.cjs.map +1 -0
- package/dist/components/navigation/tree-view/index.d.cts +96 -0
- package/dist/components/navigation/tree-view/index.d.ts +96 -0
- package/dist/components/navigation/tree-view/index.js +455 -0
- package/dist/components/navigation/tree-view/index.js.map +1 -0
- package/dist/components/navigation/tree-view/tree-view.css +258 -0
- package/dist/components/overlays/backdrop/backdrop.css +10 -0
- package/dist/components/overlays/backdrop/index.cjs +70 -0
- package/dist/components/overlays/backdrop/index.cjs.map +1 -0
- package/dist/components/overlays/backdrop/index.d.cts +12 -0
- package/dist/components/overlays/backdrop/index.d.ts +12 -0
- package/dist/components/overlays/backdrop/index.js +70 -0
- package/dist/components/overlays/backdrop/index.js.map +1 -0
- package/dist/components/overlays/command/command.css +154 -0
- package/dist/components/overlays/command/command.types.d.cts +36 -0
- package/dist/components/overlays/command/command.types.d.ts +36 -0
- package/dist/components/overlays/command/command.utils.cjs +39 -0
- package/dist/components/overlays/command/command.utils.cjs.map +1 -0
- package/dist/components/overlays/command/command.utils.js +35 -0
- package/dist/components/overlays/command/command.utils.js.map +1 -0
- package/dist/components/overlays/command/index.cjs +274 -0
- package/dist/components/overlays/command/index.cjs.map +1 -0
- package/dist/components/overlays/command/index.d.cts +4 -0
- package/dist/components/overlays/command/index.d.ts +4 -0
- package/dist/components/overlays/command/index.js +273 -0
- package/dist/components/overlays/command/index.js.map +1 -0
- package/dist/components/overlays/dialog/dialog.css +121 -0
- package/dist/components/overlays/dialog/index.cjs +80 -0
- package/dist/components/overlays/dialog/index.cjs.map +1 -0
- package/dist/components/overlays/dialog/index.d.cts +35 -0
- package/dist/components/overlays/dialog/index.d.ts +35 -0
- package/dist/components/overlays/dialog/index.js +80 -0
- package/dist/components/overlays/dialog/index.js.map +1 -0
- package/dist/components/overlays/drawer/drawer.css +133 -0
- package/dist/components/overlays/drawer/index.cjs +90 -0
- package/dist/components/overlays/drawer/index.cjs.map +1 -0
- package/dist/components/overlays/drawer/index.d.cts +11 -0
- package/dist/components/overlays/drawer/index.d.ts +11 -0
- package/dist/components/overlays/drawer/index.js +90 -0
- package/dist/components/overlays/drawer/index.js.map +1 -0
- package/dist/components/overlays/drawer/use-resize-bar.cjs +152 -0
- package/dist/components/overlays/drawer/use-resize-bar.cjs.map +1 -0
- package/dist/components/overlays/drawer/use-resize-bar.js +152 -0
- package/dist/components/overlays/drawer/use-resize-bar.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.cjs +120 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.d.cts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.d.ts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.js +120 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-content.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.cjs +136 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.d.cts +7 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.d.ts +7 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.js +132 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-items.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.cjs +76 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.d.cts +4 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.d.ts +4 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.js +75 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-radio.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.cjs +96 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.d.cts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.d.ts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.js +96 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu-trigger.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.cjs +111 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.context.cjs +21 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.context.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.context.js +18 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.context.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.css +127 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.d.cts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.d.ts +3 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.js +111 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.types.d.cts +66 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.types.d.ts +66 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.utils.cjs +44 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.utils.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.utils.js +39 -0
- package/dist/components/overlays/dropdown-menu/dropdown-menu.utils.js.map +1 -0
- package/dist/components/overlays/dropdown-menu/index.cjs +31 -0
- package/dist/components/overlays/dropdown-menu/index.cjs.map +1 -0
- package/dist/components/overlays/dropdown-menu/index.d.cts +19 -0
- package/dist/components/overlays/dropdown-menu/index.d.ts +19 -0
- package/dist/components/overlays/dropdown-menu/index.js +22 -0
- package/dist/components/overlays/dropdown-menu/index.js.map +1 -0
- package/dist/components/overlays/floating-position/calculate-position.cjs +94 -0
- package/dist/components/overlays/floating-position/calculate-position.cjs.map +1 -0
- package/dist/components/overlays/floating-position/calculate-position.js +89 -0
- package/dist/components/overlays/floating-position/calculate-position.js.map +1 -0
- package/dist/components/overlays/floating-position/use-floating-position.cjs +89 -0
- package/dist/components/overlays/floating-position/use-floating-position.cjs.map +1 -0
- package/dist/components/overlays/floating-position/use-floating-position.js +89 -0
- package/dist/components/overlays/floating-position/use-floating-position.js.map +1 -0
- package/dist/components/overlays/notification/index.cjs +142 -0
- package/dist/components/overlays/notification/index.cjs.map +1 -0
- package/dist/components/overlays/notification/index.d.cts +16 -0
- package/dist/components/overlays/notification/index.d.ts +16 -0
- package/dist/components/overlays/notification/index.js +139 -0
- package/dist/components/overlays/notification/index.js.map +1 -0
- package/dist/components/overlays/notification/notification-provider.cjs +69 -0
- package/dist/components/overlays/notification/notification-provider.cjs.map +1 -0
- package/dist/components/overlays/notification/notification-provider.d.cts +3 -0
- package/dist/components/overlays/notification/notification-provider.d.ts +3 -0
- package/dist/components/overlays/notification/notification-provider.js +68 -0
- package/dist/components/overlays/notification/notification-provider.js.map +1 -0
- package/dist/components/overlays/notification/notification.css +172 -0
- package/dist/components/overlays/notification/notification.types.d.cts +41 -0
- package/dist/components/overlays/notification/notification.types.d.ts +41 -0
- package/dist/components/overlays/notification/notification.utils.cjs +23 -0
- package/dist/components/overlays/notification/notification.utils.cjs.map +1 -0
- package/dist/components/overlays/notification/notification.utils.js +22 -0
- package/dist/components/overlays/notification/notification.utils.js.map +1 -0
- package/dist/components/overlays/notification/use-notification.cjs +12 -0
- package/dist/components/overlays/notification/use-notification.cjs.map +1 -0
- package/dist/components/overlays/notification/use-notification.d.cts +3 -0
- package/dist/components/overlays/notification/use-notification.d.ts +3 -0
- package/dist/components/overlays/notification/use-notification.js +12 -0
- package/dist/components/overlays/notification/use-notification.js.map +1 -0
- package/dist/components/overlays/overlay-stack/index.cjs +195 -0
- package/dist/components/overlays/overlay-stack/index.cjs.map +1 -0
- package/dist/components/overlays/overlay-stack/index.js +193 -0
- package/dist/components/overlays/overlay-stack/index.js.map +1 -0
- package/dist/components/overlays/popout/index.cjs +190 -0
- package/dist/components/overlays/popout/index.cjs.map +1 -0
- package/dist/components/overlays/popout/index.d.cts +26 -0
- package/dist/components/overlays/popout/index.d.ts +26 -0
- package/dist/components/overlays/popout/index.js +190 -0
- package/dist/components/overlays/popout/index.js.map +1 -0
- package/dist/components/overlays/popout/popout.css +15 -0
- package/dist/components/overlays/popover/index.cjs +163 -0
- package/dist/components/overlays/popover/index.cjs.map +1 -0
- package/dist/components/overlays/popover/index.d.cts +28 -0
- package/dist/components/overlays/popover/index.d.ts +28 -0
- package/dist/components/overlays/popover/index.js +163 -0
- package/dist/components/overlays/popover/index.js.map +1 -0
- package/dist/components/overlays/popover/popover.css +56 -0
- package/dist/components/overlays/portal/index.cjs +33 -0
- package/dist/components/overlays/portal/index.cjs.map +1 -0
- package/dist/components/overlays/portal/index.d.cts +15 -0
- package/dist/components/overlays/portal/index.d.ts +15 -0
- package/dist/components/overlays/portal/index.js +33 -0
- package/dist/components/overlays/portal/index.js.map +1 -0
- package/dist/components/overlays/portal/target.cjs +17 -0
- package/dist/components/overlays/portal/target.cjs.map +1 -0
- package/dist/components/overlays/portal/target.css +3 -0
- package/dist/components/overlays/portal/target.d.cts +7 -0
- package/dist/components/overlays/portal/target.d.ts +7 -0
- package/dist/components/overlays/portal/target.js +17 -0
- package/dist/components/overlays/portal/target.js.map +1 -0
- package/dist/components/overlays/tooltip/index.cjs +71 -0
- package/dist/components/overlays/tooltip/index.cjs.map +1 -0
- package/dist/components/overlays/tooltip/index.d.cts +24 -0
- package/dist/components/overlays/tooltip/index.d.ts +24 -0
- package/dist/components/overlays/tooltip/index.js +71 -0
- package/dist/components/overlays/tooltip/index.js.map +1 -0
- package/dist/components/overlays/tooltip/tooltip.css +67 -0
- package/dist/components/typography/heading.cjs +14 -0
- package/dist/components/typography/heading.cjs.map +1 -0
- package/dist/components/typography/heading.d.cts +11 -0
- package/dist/components/typography/heading.d.ts +11 -0
- package/dist/components/typography/heading.js +14 -0
- package/dist/components/typography/heading.js.map +1 -0
- package/dist/components/typography/text.cjs +14 -0
- package/dist/components/typography/text.cjs.map +1 -0
- package/dist/components/typography/text.d.cts +12 -0
- package/dist/components/typography/text.d.ts +12 -0
- package/dist/components/typography/text.js +14 -0
- package/dist/components/typography/text.js.map +1 -0
- package/dist/components/utilities/preview/highlight.cjs +79 -0
- package/dist/components/utilities/preview/highlight.cjs.map +1 -0
- package/dist/components/utilities/preview/highlight.js +79 -0
- package/dist/components/utilities/preview/highlight.js.map +1 -0
- package/dist/components/utilities/preview/index.cjs +391 -0
- package/dist/components/utilities/preview/index.cjs.map +1 -0
- package/dist/components/utilities/preview/index.d.cts +20 -0
- package/dist/components/utilities/preview/index.d.ts +20 -0
- package/dist/components/utilities/preview/index.js +391 -0
- package/dist/components/utilities/preview/index.js.map +1 -0
- package/dist/components/utilities/preview/preview.css +268 -0
- package/dist/components/utilities/scroll-lock/index.cjs +124 -0
- package/dist/components/utilities/scroll-lock/index.cjs.map +1 -0
- package/dist/components/utilities/scroll-lock/index.d.cts +6 -0
- package/dist/components/utilities/scroll-lock/index.d.ts +6 -0
- package/dist/components/utilities/scroll-lock/index.js +124 -0
- package/dist/components/utilities/scroll-lock/index.js.map +1 -0
- package/dist/components/utilities/transition/index.cjs +171 -0
- package/dist/components/utilities/transition/index.cjs.map +1 -0
- package/dist/components/utilities/transition/index.d.cts +27 -0
- package/dist/components/utilities/transition/index.d.ts +27 -0
- package/dist/components/utilities/transition/index.js +171 -0
- package/dist/components/utilities/transition/index.js.map +1 -0
- package/dist/components/utilities/transition/transition.css +130 -0
- package/dist/index.cjs +155 -0
- package/dist/index.d.cts +85 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +69 -0
- package/package.json +65 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Label } from "../label/index.js";
|
|
2
|
+
import { resolveFormFieldState } from "./form-field-state.js";
|
|
3
|
+
import "./form-field.css";
|
|
4
|
+
import { cn } from "@puzzle-ui/core";
|
|
5
|
+
import { cloneElement, useId } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/forms/form-field/index.tsx
|
|
8
|
+
const FormField = ({ label, description, error, invalid, required = false, disabled = false, controlId, optional = false, className, children, ...rootProps }) => {
|
|
9
|
+
const generatedId = useId();
|
|
10
|
+
const child = children;
|
|
11
|
+
const childProps = child.props;
|
|
12
|
+
const { resolvedControlId, isInvalid, errorContent, hasError, descriptionId, errorId, describedBy } = resolveFormFieldState({
|
|
13
|
+
generatedId,
|
|
14
|
+
controlId,
|
|
15
|
+
childProps,
|
|
16
|
+
description,
|
|
17
|
+
error,
|
|
18
|
+
invalid
|
|
19
|
+
});
|
|
20
|
+
const control = cloneElement(child, {
|
|
21
|
+
id: resolvedControlId,
|
|
22
|
+
required: required || childProps.required === true,
|
|
23
|
+
disabled: disabled || childProps.disabled === true,
|
|
24
|
+
"aria-describedby": describedBy,
|
|
25
|
+
"aria-invalid": isInvalid ? true : childProps["aria-invalid"]
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
28
|
+
...rootProps,
|
|
29
|
+
className: cn("puzzle-form-field", className),
|
|
30
|
+
"data-invalid": isInvalid || void 0,
|
|
31
|
+
"data-disabled": disabled || void 0,
|
|
32
|
+
children: [
|
|
33
|
+
label != null && /* @__PURE__ */ jsx(Label, {
|
|
34
|
+
htmlFor: resolvedControlId,
|
|
35
|
+
required,
|
|
36
|
+
optional,
|
|
37
|
+
className: "puzzle-form-field__label",
|
|
38
|
+
children: label
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ jsx("div", {
|
|
41
|
+
className: "puzzle-form-field__control",
|
|
42
|
+
children: control
|
|
43
|
+
}),
|
|
44
|
+
description != null && /* @__PURE__ */ jsx("div", {
|
|
45
|
+
id: descriptionId,
|
|
46
|
+
className: "puzzle-form-field__description",
|
|
47
|
+
children: description
|
|
48
|
+
}),
|
|
49
|
+
hasError && /* @__PURE__ */ jsx("div", {
|
|
50
|
+
id: errorId,
|
|
51
|
+
className: "puzzle-form-field__error",
|
|
52
|
+
"aria-live": "polite",
|
|
53
|
+
"aria-atomic": "true",
|
|
54
|
+
children: errorContent
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export { FormField };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/forms/form-field/index.tsx"],"sourcesContent":["import {\n cloneElement,\n useId,\n type ComponentPropsWithoutRef,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { cn } from \"@puzzle-ui/core\";\n\nimport { Label } from \"../label\";\nimport { resolveFormFieldState } from \"./form-field-state\";\n\nimport \"./form-field.css\";\n\ntype FormFieldProps = Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> & {\n /** Visible label associated with the control. */\n label?: ReactNode;\n\n /** Supporting text displayed below the control. */\n description?: ReactNode;\n\n /** Validation error message. */\n error?: ReactNode | boolean;\n\n /** Explicitly controls the invalid state. Defaults to whether an error exists. */\n invalid?: boolean;\n\n /** Marks the control as required. */\n required?: boolean;\n\n /** Disables the control. */\n disabled?: boolean;\n\n /** ID applied to the actual form control. */\n controlId?: string;\n\n /** Displays an optional indicator beside the label. */\n optional?: boolean;\n\n /** A single Puzzle control or native form element. */\n children: ReactElement;\n};\n\nconst FormField = ({\n label,\n description,\n error,\n invalid,\n required = false,\n disabled = false,\n controlId,\n optional = false,\n className,\n children,\n ...rootProps\n}: FormFieldProps) => {\n const generatedId = useId();\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n\n const {\n resolvedControlId,\n isInvalid,\n errorContent,\n hasError,\n descriptionId,\n errorId,\n describedBy,\n } = resolveFormFieldState({\n generatedId,\n controlId,\n childProps,\n description,\n error,\n invalid,\n });\n\n const control = cloneElement(child, {\n id: resolvedControlId,\n required: required || childProps.required === true,\n disabled: disabled || childProps.disabled === true,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": isInvalid ? true : childProps[\"aria-invalid\"],\n });\n\n return (\n <div\n {...rootProps}\n className={cn(\"puzzle-form-field\", className)}\n data-invalid={isInvalid || undefined}\n data-disabled={disabled || undefined}\n >\n {label != null && (\n <Label\n htmlFor={resolvedControlId}\n required={required}\n optional={optional}\n className=\"puzzle-form-field__label\"\n >\n {label}\n </Label>\n )}\n\n <div className=\"puzzle-form-field__control\">{control}</div>\n\n {description != null && (\n <div id={descriptionId} className=\"puzzle-form-field__description\">\n {description}\n </div>\n )}\n\n {hasError && (\n <div\n id={errorId}\n className=\"puzzle-form-field__error\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {errorContent}\n </div>\n )}\n </div>\n );\n};\n\nexport { FormField, type FormFieldProps };\n"],"mappings":";;;;;;;AA4CA,MAAM,aAAa,EACjB,OACA,aACA,OACA,SACA,WAAW,OACX,WAAW,OACX,WACA,WAAW,OACX,WACA,UACA,GAAG,gBACiB;CACpB,MAAM,cAAc,MAAM;CAE1B,MAAM,QAAQ;CACd,MAAM,aAAa,MAAM;CAEzB,MAAM,EACJ,mBACA,WACA,cACA,UACA,eACA,SACA,gBACE,sBAAsB;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,UAAU,aAAa,OAAO;EAClC,IAAI;EACJ,UAAU,YAAY,WAAW,aAAa;EAC9C,UAAU,YAAY,WAAW,aAAa;EAC9C,oBAAoB;EACpB,gBAAgB,YAAY,OAAO,WAAW;CAChD,CAAC;CAED,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,GAAG,qBAAqB,SAAS;EAC5C,gBAAc,aAAa,KAAA;EAC3B,iBAAe,YAAY,KAAA;EAJ7B,UAAA;GAMG,SAAS,QACR,oBAAC,OAAD;IACE,SAAS;IACC;IACA;IACV,WAAU;IAET,UAAA;GACI,CAAA;GAGT,oBAAC,OAAD;IAAK,WAAU;IAA8B,UAAA;GAAa,CAAA;GAEzD,eAAe,QACd,oBAAC,OAAD;IAAK,IAAI;IAAe,WAAU;IAC/B,UAAA;GACE,CAAA;GAGN,YACC,oBAAC,OAAD;IACE,IAAI;IACJ,WAAU;IACV,aAAU;IACV,eAAY;IAEX,UAAA;GACE,CAAA;EAEJ;;AAET"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TextInput, TextInputProps, TextInputType } from "./text-input.cjs";
|
|
2
|
+
import { TextAreaInput, TextAreaInputProps } from "./text-area-input.cjs";
|
|
3
|
+
import { NumberInput, NumberInputProps } from "./number-input.cjs";
|
|
4
|
+
export { NumberInput, type NumberInputProps, TextAreaInput, type TextAreaInputProps, TextInput, type TextInputProps, type TextInputType };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TextInput, TextInputProps, TextInputType } from "./text-input.js";
|
|
2
|
+
import { TextAreaInput, TextAreaInputProps } from "./text-area-input.js";
|
|
3
|
+
import { NumberInput, NumberInputProps } from "./number-input.js";
|
|
4
|
+
export { NumberInput, type NumberInputProps, TextAreaInput, type TextAreaInputProps, TextInput, type TextInputProps, type TextInputType };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
.puzzle-input {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--puzzle-space-2, .5rem);
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: 2.5rem;
|
|
8
|
+
padding: 0 var(--puzzle-space-3, .75rem);
|
|
9
|
+
border: var(--puzzle-border-width, 1px) solid var(--puzzle-color-border);
|
|
10
|
+
border-radius: var(--puzzle-radius-md, .5rem);
|
|
11
|
+
background: var(--puzzle-color-surface);
|
|
12
|
+
color: var(--puzzle-color-text);
|
|
13
|
+
transition: border-color var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease),
|
|
14
|
+
box-shadow var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease),
|
|
15
|
+
background-color var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease);
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.puzzle-input:focus-within {
|
|
20
|
+
border-color: var(--puzzle-color-ring);
|
|
21
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--puzzle-color-ring), transparent 82%);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.puzzle-input[data-disabled="true"] {
|
|
25
|
+
opacity: .6;
|
|
26
|
+
cursor: not-allowed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.puzzle-input__control {
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
width: 100%;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
min-height: 2.375rem;
|
|
34
|
+
color: inherit;
|
|
35
|
+
font: inherit;
|
|
36
|
+
line-height: var(--puzzle-font-line-height-normal, 1.5);
|
|
37
|
+
background: none;
|
|
38
|
+
border: 0;
|
|
39
|
+
outline: 0;
|
|
40
|
+
flex: auto;
|
|
41
|
+
padding: 0;
|
|
42
|
+
display: block;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.puzzle-input__control::placeholder, .puzzle-input--textarea::placeholder {
|
|
46
|
+
color: var(--puzzle-color-text-subtle, var(--puzzle-color-text-muted));
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.puzzle-input__control:disabled {
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.puzzle-input__affix {
|
|
55
|
+
color: var(--puzzle-color-text-muted);
|
|
56
|
+
flex: none;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
align-items: center;
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.puzzle-input__affix > svg {
|
|
63
|
+
width: 1.125em;
|
|
64
|
+
height: 1.125em;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.puzzle-input__icon-button, .puzzle-input__stepper {
|
|
68
|
+
color: var(--puzzle-color-text-muted);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
touch-action: manipulation;
|
|
71
|
+
background: none;
|
|
72
|
+
border: 0;
|
|
73
|
+
flex: none;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
align-items: center;
|
|
76
|
+
padding: 0;
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.puzzle-input__icon-button {
|
|
81
|
+
border-radius: var(--puzzle-radius-sm, .375rem);
|
|
82
|
+
width: 2rem;
|
|
83
|
+
height: 2rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.puzzle-input__icon-button:hover:not(:disabled), .puzzle-input__stepper:hover:not(:disabled) {
|
|
87
|
+
color: var(--puzzle-color-text);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.puzzle-input__icon-button:focus-visible, .puzzle-input__stepper:focus-visible {
|
|
91
|
+
outline: 2px solid var(--puzzle-color-ring);
|
|
92
|
+
outline-offset: 2px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.puzzle-input__icon-button:disabled, .puzzle-input__stepper:disabled {
|
|
96
|
+
opacity: .35;
|
|
97
|
+
cursor: not-allowed;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.puzzle-input--textarea {
|
|
101
|
+
width: 100%;
|
|
102
|
+
min-height: 0;
|
|
103
|
+
padding: var(--puzzle-space-2, .5rem) var(--puzzle-space-3, .75rem);
|
|
104
|
+
font: inherit;
|
|
105
|
+
line-height: var(--puzzle-font-line-height-normal, 1.5);
|
|
106
|
+
color: var(--puzzle-color-text);
|
|
107
|
+
background: var(--puzzle-color-surface);
|
|
108
|
+
border: var(--puzzle-border-width, 1px) solid var(--puzzle-color-border);
|
|
109
|
+
border-radius: var(--puzzle-radius-md, .5rem);
|
|
110
|
+
transition: border-color var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease),
|
|
111
|
+
box-shadow var(--puzzle-duration-fast, .15s) var(--puzzle-easing-standard, ease);
|
|
112
|
+
outline: 0;
|
|
113
|
+
display: block;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.puzzle-input--textarea:focus {
|
|
117
|
+
border-color: var(--puzzle-color-ring);
|
|
118
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--puzzle-color-ring), transparent 82%);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.puzzle-input--textarea:disabled {
|
|
122
|
+
opacity: .6;
|
|
123
|
+
cursor: not-allowed;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.puzzle-input--number {
|
|
127
|
+
gap: var(--puzzle-space-2, .5rem);
|
|
128
|
+
padding-inline: .1rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.puzzle-input--number .puzzle-input__control {
|
|
132
|
+
text-align: center;
|
|
133
|
+
font-variant-numeric: tabular-nums;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.puzzle-input__stepper {
|
|
137
|
+
border-radius: var(--puzzle-radius-sm, .375rem);
|
|
138
|
+
-webkit-user-select: none;
|
|
139
|
+
user-select: none;
|
|
140
|
+
width: 2rem;
|
|
141
|
+
height: 2rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.puzzle-input__stepper svg {
|
|
145
|
+
width: 1.125rem;
|
|
146
|
+
height: 1.125rem;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (prefers-reduced-motion: reduce) {
|
|
150
|
+
.puzzle-input, .puzzle-input--textarea {
|
|
151
|
+
transition: none;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
;/* empty css */
|
|
3
|
+
let _puzzle_ui_core = require("@puzzle-ui/core");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
let _puzzle_ui_icons = require("@puzzle-ui/icons");
|
|
7
|
+
// src/components/forms/input/number-input.tsx
|
|
8
|
+
const clamp = (value, min, max) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, value));
|
|
9
|
+
const getPrecision = (value) => {
|
|
10
|
+
const valueString = String(value);
|
|
11
|
+
if (valueString.includes("e-")) return Number(valueString.split("e-")[1]) || 0;
|
|
12
|
+
return valueString.split(".")[1]?.length ?? 0;
|
|
13
|
+
};
|
|
14
|
+
const NumberInput = ({ value, initialValue = 0, onChange, min, max, step = 1, largeStep, fractionDigits = getPrecision(step), longPressDelay = 450, repeatInterval = 120, decrementLabel = "Decrease value", incrementLabel = "Increase value", disabled, readOnly, className, onBlur, onFocus, onKeyDown, ...inputProps }) => {
|
|
15
|
+
const isControlled = value !== void 0;
|
|
16
|
+
const digits = Math.min(12, Math.max(0, Math.trunc(fractionDigits)));
|
|
17
|
+
const factor = 10 ** digits;
|
|
18
|
+
const safeStep = Number.isFinite(step) && step > 0 ? step : 1;
|
|
19
|
+
const safeLargeStep = largeStep !== void 0 && Number.isFinite(largeStep) && largeStep > 0 ? largeStep : safeStep * 10;
|
|
20
|
+
const allowsNegative = min === void 0 || min < 0;
|
|
21
|
+
const [internalValue, setInternalValue] = (0, react.useState)(() => clamp(Number.isFinite(initialValue) ? initialValue : 0, min, max));
|
|
22
|
+
const currentValue = clamp(isControlled ? value : internalValue, min, max);
|
|
23
|
+
const [draft, setDraft] = (0, react.useState)(() => String(Number(currentValue.toFixed(digits))));
|
|
24
|
+
const currentValueRef = (0, react.useRef)(currentValue);
|
|
25
|
+
const focusedRef = (0, react.useRef)(false);
|
|
26
|
+
const holdTimerRef = (0, react.useRef)(null);
|
|
27
|
+
const repeatTimerRef = (0, react.useRef)(null);
|
|
28
|
+
const holdStartedAtRef = (0, react.useRef)(0);
|
|
29
|
+
const holdDirectionRef = (0, react.useRef)(1);
|
|
30
|
+
currentValueRef.current = currentValue;
|
|
31
|
+
(0, react.useEffect)(() => {
|
|
32
|
+
if (!focusedRef.current) setDraft(String(Number(currentValue.toFixed(digits))));
|
|
33
|
+
}, [currentValue, digits]);
|
|
34
|
+
const commit = (0, react.useCallback)((nextValue) => {
|
|
35
|
+
const rounded = Math.round(clamp(nextValue, min, max) * factor) / factor;
|
|
36
|
+
if (!Number.isFinite(rounded) || rounded === currentValueRef.current) return;
|
|
37
|
+
currentValueRef.current = rounded;
|
|
38
|
+
if (!isControlled) setInternalValue(rounded);
|
|
39
|
+
setDraft(String(rounded));
|
|
40
|
+
onChange?.(rounded);
|
|
41
|
+
}, [
|
|
42
|
+
factor,
|
|
43
|
+
isControlled,
|
|
44
|
+
max,
|
|
45
|
+
min,
|
|
46
|
+
onChange
|
|
47
|
+
]);
|
|
48
|
+
const changeBy = (0, react.useCallback)((direction, amount = safeStep) => {
|
|
49
|
+
const next = Math.round((currentValueRef.current + direction * amount) * factor) / factor;
|
|
50
|
+
commit(next);
|
|
51
|
+
}, [
|
|
52
|
+
commit,
|
|
53
|
+
factor,
|
|
54
|
+
safeStep
|
|
55
|
+
]);
|
|
56
|
+
const stopHold = (0, react.useCallback)(() => {
|
|
57
|
+
if (holdTimerRef.current) clearTimeout(holdTimerRef.current);
|
|
58
|
+
if (repeatTimerRef.current) clearTimeout(repeatTimerRef.current);
|
|
59
|
+
holdTimerRef.current = null;
|
|
60
|
+
repeatTimerRef.current = null;
|
|
61
|
+
}, []);
|
|
62
|
+
const scheduleRepeat = (0, react.useCallback)(() => {
|
|
63
|
+
const elapsed = Date.now() - holdStartedAtRef.current;
|
|
64
|
+
const interval = Math.max(45, repeatInterval - Math.floor(elapsed / 1800) * 20);
|
|
65
|
+
repeatTimerRef.current = setTimeout(() => {
|
|
66
|
+
changeBy(holdDirectionRef.current);
|
|
67
|
+
scheduleRepeat();
|
|
68
|
+
}, interval);
|
|
69
|
+
}, [changeBy, repeatInterval]);
|
|
70
|
+
const startHold = (direction) => (event) => {
|
|
71
|
+
if (disabled || readOnly || event.button !== 0) return;
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
stopHold();
|
|
74
|
+
holdDirectionRef.current = direction;
|
|
75
|
+
holdStartedAtRef.current = Date.now();
|
|
76
|
+
changeBy(direction);
|
|
77
|
+
holdTimerRef.current = setTimeout(scheduleRepeat, longPressDelay);
|
|
78
|
+
};
|
|
79
|
+
const handleStepperKeyDown = (direction) => (event) => {
|
|
80
|
+
if (event.key !== " " && event.key !== "Enter") return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
changeBy(direction);
|
|
83
|
+
};
|
|
84
|
+
const handleInputKeyDown = (event) => {
|
|
85
|
+
onKeyDown?.(event);
|
|
86
|
+
if (event.defaultPrevented || disabled || readOnly) return;
|
|
87
|
+
switch (event.key) {
|
|
88
|
+
case "ArrowUp":
|
|
89
|
+
changeBy(1);
|
|
90
|
+
break;
|
|
91
|
+
case "ArrowDown":
|
|
92
|
+
changeBy(-1);
|
|
93
|
+
break;
|
|
94
|
+
case "PageUp":
|
|
95
|
+
changeBy(1, safeLargeStep);
|
|
96
|
+
break;
|
|
97
|
+
case "PageDown":
|
|
98
|
+
changeBy(-1, safeLargeStep);
|
|
99
|
+
break;
|
|
100
|
+
case "Home":
|
|
101
|
+
if (min === void 0) return;
|
|
102
|
+
commit(min);
|
|
103
|
+
break;
|
|
104
|
+
case "End":
|
|
105
|
+
if (max === void 0) return;
|
|
106
|
+
commit(max);
|
|
107
|
+
break;
|
|
108
|
+
default: return;
|
|
109
|
+
}
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
};
|
|
112
|
+
const handleInputChange = (event) => {
|
|
113
|
+
const nextDraft = event.target.value;
|
|
114
|
+
setDraft(nextDraft);
|
|
115
|
+
if (nextDraft.trim() === "" || nextDraft === "-" || nextDraft === "." || nextDraft === "-.") return;
|
|
116
|
+
const parsed = Number(nextDraft.replace(",", "."));
|
|
117
|
+
if (Number.isFinite(parsed)) commit(parsed);
|
|
118
|
+
};
|
|
119
|
+
const handleBlur = (event) => {
|
|
120
|
+
focusedRef.current = false;
|
|
121
|
+
const parsed = Number(draft.replace(",", "."));
|
|
122
|
+
const nextValue = draft.trim() !== "" && Number.isFinite(parsed) ? clamp(Math.round(parsed * factor) / factor, min, max) : currentValueRef.current;
|
|
123
|
+
commit(nextValue);
|
|
124
|
+
setDraft(String(Number(nextValue.toFixed(digits))));
|
|
125
|
+
onBlur?.(event);
|
|
126
|
+
};
|
|
127
|
+
(0, react.useEffect)(() => stopHold, [stopHold]);
|
|
128
|
+
const atMinimum = min !== void 0 && currentValue <= min;
|
|
129
|
+
const atMaximum = max !== void 0 && currentValue >= max;
|
|
130
|
+
const trimmedDraft = draft.trim();
|
|
131
|
+
const draftIsIncomplete = trimmedDraft === "" || trimmedDraft === "-" || trimmedDraft === "." || trimmedDraft === "-.";
|
|
132
|
+
const draftValue = Number(trimmedDraft.replace(",", "."));
|
|
133
|
+
const draftIsInvalid = !draftIsIncomplete && (!Number.isFinite(draftValue) || min !== void 0 && draftValue < min || max !== void 0 && draftValue > max);
|
|
134
|
+
const stepperDisabled = disabled || readOnly;
|
|
135
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
136
|
+
className: (0, _puzzle_ui_core.cn)("puzzle-input", "puzzle-input--number", className),
|
|
137
|
+
"data-disabled": disabled || void 0,
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
140
|
+
type: "button",
|
|
141
|
+
className: "puzzle-input__stepper",
|
|
142
|
+
"aria-label": decrementLabel,
|
|
143
|
+
tabIndex: -1,
|
|
144
|
+
disabled: stepperDisabled || atMinimum,
|
|
145
|
+
onPointerDown: startHold(-1),
|
|
146
|
+
onPointerUp: stopHold,
|
|
147
|
+
onPointerLeave: stopHold,
|
|
148
|
+
onPointerCancel: stopHold,
|
|
149
|
+
onKeyDown: handleStepperKeyDown(-1),
|
|
150
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_puzzle_ui_icons.Icon, { name: "lucide:minus" })
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
153
|
+
...inputProps,
|
|
154
|
+
type: "text",
|
|
155
|
+
role: "spinbutton",
|
|
156
|
+
"aria-valuenow": currentValue,
|
|
157
|
+
"aria-valuemin": min,
|
|
158
|
+
"aria-valuemax": max,
|
|
159
|
+
"aria-invalid": draftIsInvalid || inputProps["aria-invalid"],
|
|
160
|
+
inputMode: allowsNegative ? "text" : digits > 0 ? "decimal" : "numeric",
|
|
161
|
+
pattern: `${allowsNegative ? "-?" : ""}[0-9]*${digits > 0 ? "[.,]?[0-9]*" : ""}`,
|
|
162
|
+
disabled,
|
|
163
|
+
readOnly,
|
|
164
|
+
value: draft,
|
|
165
|
+
className: "puzzle-input__control",
|
|
166
|
+
onFocus: (event) => {
|
|
167
|
+
focusedRef.current = true;
|
|
168
|
+
onFocus?.(event);
|
|
169
|
+
},
|
|
170
|
+
onChange: handleInputChange,
|
|
171
|
+
onKeyDown: handleInputKeyDown,
|
|
172
|
+
onBlur: handleBlur
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
175
|
+
type: "button",
|
|
176
|
+
className: "puzzle-input__stepper",
|
|
177
|
+
"aria-label": incrementLabel,
|
|
178
|
+
tabIndex: -1,
|
|
179
|
+
disabled: stepperDisabled || atMaximum,
|
|
180
|
+
onPointerDown: startHold(1),
|
|
181
|
+
onPointerUp: stopHold,
|
|
182
|
+
onPointerLeave: stopHold,
|
|
183
|
+
onPointerCancel: stopHold,
|
|
184
|
+
onKeyDown: handleStepperKeyDown(1),
|
|
185
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_puzzle_ui_icons.Icon, { name: "lucide:plus" })
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.NumberInput = NumberInput;
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=number-input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-input.cjs","names":["useState","useRef","useCallback","cn","Icon"],"sources":["../../../../src/components/forms/input/number-input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type PointerEvent as ReactPointerEvent,\n type KeyboardEvent as ReactKeyboardEvent,\n type ChangeEvent,\n type FocusEvent,\n} from \"react\";\n\nimport { cn } from \"@puzzle-ui/core\";\nimport { Icon } from \"@puzzle-ui/icons\";\n\nimport \"./input.css\";\n\ntype NumberInputProps = Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"step\" | \"min\" | \"max\"\n> & {\n value?: number;\n initialValue?: number;\n\n onChange?: (value: number) => void;\n\n min?: number;\n max?: number;\n step?: number;\n\n /** Amount applied by PageUp and PageDown. Defaults to ten times `step`. */\n largeStep?: number;\n\n fractionDigits?: number;\n\n longPressDelay?: number;\n repeatInterval?: number;\n\n /** Accessible label of the decrement button. */\n decrementLabel?: string;\n\n /** Accessible label of the increment button. */\n incrementLabel?: string;\n};\n\ntype Direction = -1 | 1;\n\nconst clamp = (value: number, min?: number, max?: number) =>\n Math.min(max ?? Infinity, Math.max(min ?? -Infinity, value));\n\nconst getPrecision = (value: number) => {\n const valueString = String(value);\n\n if (valueString.includes(\"e-\")) {\n return Number(valueString.split(\"e-\")[1]) || 0;\n }\n\n return valueString.split(\".\")[1]?.length ?? 0;\n};\n\nconst NumberInput = ({\n value,\n initialValue = 0,\n onChange,\n\n min,\n max,\n step = 1,\n largeStep,\n\n fractionDigits = getPrecision(step),\n\n longPressDelay = 450,\n repeatInterval = 120,\n\n decrementLabel = \"Decrease value\",\n incrementLabel = \"Increase value\",\n\n disabled,\n readOnly,\n className,\n\n onBlur,\n onFocus,\n onKeyDown,\n\n ...inputProps\n}: NumberInputProps) => {\n const isControlled = value !== undefined;\n\n const digits = Math.min(12, Math.max(0, Math.trunc(fractionDigits)));\n\n const factor = 10 ** digits;\n\n const safeStep = Number.isFinite(step) && step > 0 ? step : 1;\n\n const safeLargeStep =\n largeStep !== undefined && Number.isFinite(largeStep) && largeStep > 0\n ? largeStep\n : safeStep * 10;\n\n const allowsNegative = min === undefined || min < 0;\n\n const [internalValue, setInternalValue] = useState(() =>\n clamp(Number.isFinite(initialValue) ? initialValue : 0, min, max),\n );\n\n const currentValue = clamp(isControlled ? value : internalValue, min, max);\n\n const [draft, setDraft] = useState(() =>\n String(Number(currentValue.toFixed(digits))),\n );\n\n const currentValueRef = useRef(currentValue);\n const focusedRef = useRef(false);\n\n const holdTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const repeatTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const holdStartedAtRef = useRef(0);\n const holdDirectionRef = useRef<Direction>(1);\n\n currentValueRef.current = currentValue;\n\n useEffect(() => {\n if (!focusedRef.current) {\n setDraft(String(Number(currentValue.toFixed(digits))));\n }\n }, [currentValue, digits]);\n\n const commit = useCallback(\n (nextValue: number) => {\n const rounded = Math.round(clamp(nextValue, min, max) * factor) / factor;\n\n if (!Number.isFinite(rounded) || rounded === currentValueRef.current) {\n return;\n }\n\n currentValueRef.current = rounded;\n\n if (!isControlled) {\n setInternalValue(rounded);\n }\n\n setDraft(String(rounded));\n\n onChange?.(rounded);\n },\n [factor, isControlled, max, min, onChange],\n );\n\n const changeBy = useCallback(\n (direction: Direction, amount = safeStep) => {\n const next =\n Math.round((currentValueRef.current + direction * amount) * factor) /\n factor;\n\n commit(next);\n },\n [commit, factor, safeStep],\n );\n\n const stopHold = useCallback(() => {\n if (holdTimerRef.current) {\n clearTimeout(holdTimerRef.current);\n }\n\n if (repeatTimerRef.current) {\n clearTimeout(repeatTimerRef.current);\n }\n\n holdTimerRef.current = null;\n repeatTimerRef.current = null;\n }, []);\n\n const scheduleRepeat = useCallback(() => {\n const elapsed = Date.now() - holdStartedAtRef.current;\n\n const interval = Math.max(\n 45,\n repeatInterval - Math.floor(elapsed / 1800) * 20,\n );\n\n repeatTimerRef.current = setTimeout(() => {\n changeBy(holdDirectionRef.current);\n scheduleRepeat();\n }, interval);\n }, [changeBy, repeatInterval]);\n\n const startHold =\n (direction: Direction) => (event: ReactPointerEvent<HTMLButtonElement>) => {\n if (disabled || readOnly || event.button !== 0) {\n return;\n }\n\n event.preventDefault();\n\n stopHold();\n\n holdDirectionRef.current = direction;\n holdStartedAtRef.current = Date.now();\n\n changeBy(direction);\n\n holdTimerRef.current = setTimeout(scheduleRepeat, longPressDelay);\n };\n\n const handleStepperKeyDown =\n (direction: Direction) =>\n (event: ReactKeyboardEvent<HTMLButtonElement>) => {\n if (event.key !== \" \" && event.key !== \"Enter\") {\n return;\n }\n\n event.preventDefault();\n changeBy(direction);\n };\n\n const handleInputKeyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.defaultPrevented || disabled || readOnly) {\n return;\n }\n\n switch (event.key) {\n case \"ArrowUp\":\n changeBy(1);\n break;\n case \"ArrowDown\":\n changeBy(-1);\n break;\n case \"PageUp\":\n changeBy(1, safeLargeStep);\n break;\n case \"PageDown\":\n changeBy(-1, safeLargeStep);\n break;\n case \"Home\":\n if (min === undefined) return;\n commit(min);\n break;\n case \"End\":\n if (max === undefined) return;\n commit(max);\n break;\n default:\n return;\n }\n\n event.preventDefault();\n };\n\n const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const nextDraft = event.target.value;\n\n setDraft(nextDraft);\n\n if (\n nextDraft.trim() === \"\" ||\n nextDraft === \"-\" ||\n nextDraft === \".\" ||\n nextDraft === \"-.\"\n ) {\n return;\n }\n\n const parsed = Number(nextDraft.replace(\",\", \".\"));\n\n if (Number.isFinite(parsed)) {\n commit(parsed);\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n focusedRef.current = false;\n\n const parsed = Number(draft.replace(\",\", \".\"));\n\n const nextValue =\n draft.trim() !== \"\" && Number.isFinite(parsed)\n ? clamp(Math.round(parsed * factor) / factor, min, max)\n : currentValueRef.current;\n\n commit(nextValue);\n\n setDraft(String(Number(nextValue.toFixed(digits))));\n\n onBlur?.(event);\n };\n\n useEffect(() => stopHold, [stopHold]);\n\n const atMinimum = min !== undefined && currentValue <= min;\n\n const atMaximum = max !== undefined && currentValue >= max;\n\n const trimmedDraft = draft.trim();\n const draftIsIncomplete =\n trimmedDraft === \"\" ||\n trimmedDraft === \"-\" ||\n trimmedDraft === \".\" ||\n trimmedDraft === \"-.\";\n const draftValue = Number(trimmedDraft.replace(\",\", \".\"));\n\n const draftIsInvalid =\n !draftIsIncomplete &&\n (!Number.isFinite(draftValue) ||\n (min !== undefined && draftValue < min) ||\n (max !== undefined && draftValue > max));\n\n const stepperDisabled = disabled || readOnly;\n\n return (\n <div\n className={cn(\"puzzle-input\", \"puzzle-input--number\", className)}\n data-disabled={disabled || undefined}\n >\n <button\n type=\"button\"\n className=\"puzzle-input__stepper\"\n aria-label={decrementLabel}\n tabIndex={-1}\n disabled={stepperDisabled || atMinimum}\n onPointerDown={startHold(-1)}\n onPointerUp={stopHold}\n onPointerLeave={stopHold}\n onPointerCancel={stopHold}\n onKeyDown={handleStepperKeyDown(-1)}\n >\n <Icon name=\"lucide:minus\" />\n </button>\n\n <input\n {...inputProps}\n type=\"text\"\n role=\"spinbutton\"\n aria-valuenow={currentValue}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-invalid={draftIsInvalid || inputProps[\"aria-invalid\"]}\n inputMode={allowsNegative ? \"text\" : digits > 0 ? \"decimal\" : \"numeric\"}\n pattern={`${allowsNegative ? \"-?\" : \"\"}[0-9]*${digits > 0 ? \"[.,]?[0-9]*\" : \"\"}`}\n disabled={disabled}\n readOnly={readOnly}\n value={draft}\n className=\"puzzle-input__control\"\n onFocus={(event) => {\n focusedRef.current = true;\n onFocus?.(event);\n }}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown}\n onBlur={handleBlur}\n />\n\n <button\n type=\"button\"\n className=\"puzzle-input__stepper\"\n aria-label={incrementLabel}\n tabIndex={-1}\n disabled={stepperDisabled || atMaximum}\n onPointerDown={startHold(1)}\n onPointerUp={stopHold}\n onPointerLeave={stopHold}\n onPointerCancel={stopHold}\n onKeyDown={handleStepperKeyDown(1)}\n >\n <Icon name=\"lucide:plus\" />\n </button>\n </div>\n );\n};\n\nexport { NumberInput, type NumberInputProps };\n"],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
type NumberInputProps = Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "onChange" | "step" | "min" | "max"> & {
|
|
3
|
+
value?: number;
|
|
4
|
+
initialValue?: number;
|
|
5
|
+
onChange?: (value: number) => void;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
/** Amount applied by PageUp and PageDown. Defaults to ten times `step`. */
|
|
10
|
+
largeStep?: number;
|
|
11
|
+
fractionDigits?: number;
|
|
12
|
+
longPressDelay?: number;
|
|
13
|
+
repeatInterval?: number;
|
|
14
|
+
/** Accessible label of the decrement button. */
|
|
15
|
+
decrementLabel?: string;
|
|
16
|
+
/** Accessible label of the increment button. */
|
|
17
|
+
incrementLabel?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const NumberInput: ({ value, initialValue, onChange, min, max, step, largeStep, fractionDigits, longPressDelay, repeatInterval, decrementLabel, incrementLabel, disabled, readOnly, className, onBlur, onFocus, onKeyDown, ...inputProps }: NumberInputProps) => import("react").JSX.Element;
|
|
20
|
+
export { NumberInput, type NumberInputProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
type NumberInputProps = Omit<ComponentPropsWithoutRef<"input">, "type" | "value" | "defaultValue" | "onChange" | "step" | "min" | "max"> & {
|
|
3
|
+
value?: number;
|
|
4
|
+
initialValue?: number;
|
|
5
|
+
onChange?: (value: number) => void;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
/** Amount applied by PageUp and PageDown. Defaults to ten times `step`. */
|
|
10
|
+
largeStep?: number;
|
|
11
|
+
fractionDigits?: number;
|
|
12
|
+
longPressDelay?: number;
|
|
13
|
+
repeatInterval?: number;
|
|
14
|
+
/** Accessible label of the decrement button. */
|
|
15
|
+
decrementLabel?: string;
|
|
16
|
+
/** Accessible label of the increment button. */
|
|
17
|
+
incrementLabel?: string;
|
|
18
|
+
};
|
|
19
|
+
declare const NumberInput: ({ value, initialValue, onChange, min, max, step, largeStep, fractionDigits, longPressDelay, repeatInterval, decrementLabel, incrementLabel, disabled, readOnly, className, onBlur, onFocus, onKeyDown, ...inputProps }: NumberInputProps) => import("react").JSX.Element;
|
|
20
|
+
export { NumberInput, type NumberInputProps };
|