@hanzo/ui 8.27.91 → 8.28.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/NOTICE +25 -0
- package/README.md +1 -1
- package/dist/backends/gui/alert-dialog.cjs +24 -6
- package/dist/backends/gui/alert-dialog.d.ts +11 -3
- package/dist/backends/gui/alert-dialog.d.ts.map +1 -1
- package/dist/backends/gui/alert-dialog.js +24 -6
- package/dist/backends/gui/alert-dialog.js.map +1 -1
- package/dist/backends/gui/alert.cjs +32 -1
- package/dist/backends/gui/alert.d.ts +36 -3
- package/dist/backends/gui/alert.d.ts.map +1 -1
- package/dist/backends/gui/alert.js +32 -2
- package/dist/backends/gui/alert.js.map +1 -1
- package/dist/backends/gui/avatar-group.cjs +28 -0
- package/dist/backends/gui/avatar-group.d.ts +33 -0
- package/dist/backends/gui/avatar-group.d.ts.map +1 -0
- package/dist/backends/gui/avatar-group.js +26 -0
- package/dist/backends/gui/avatar-group.js.map +1 -0
- package/dist/backends/gui/avatar.cjs +53 -3
- package/dist/backends/gui/avatar.d.ts +46 -4
- package/dist/backends/gui/avatar.d.ts.map +1 -1
- package/dist/backends/gui/avatar.js +52 -3
- package/dist/backends/gui/avatar.js.map +1 -1
- package/dist/backends/gui/badge.cjs +40 -2
- package/dist/backends/gui/badge.d.ts +7 -2
- package/dist/backends/gui/badge.d.ts.map +1 -1
- package/dist/backends/gui/badge.js +40 -2
- package/dist/backends/gui/badge.js.map +1 -1
- package/dist/backends/gui/banner.cjs +40 -1
- package/dist/backends/gui/banner.d.ts +36 -3
- package/dist/backends/gui/banner.d.ts.map +1 -1
- package/dist/backends/gui/banner.js +42 -4
- package/dist/backends/gui/banner.js.map +1 -1
- package/dist/backends/gui/breadcrumb.cjs +28 -10
- package/dist/backends/gui/breadcrumb.d.ts +20 -11
- package/dist/backends/gui/breadcrumb.d.ts.map +1 -1
- package/dist/backends/gui/breadcrumb.js +28 -10
- package/dist/backends/gui/breadcrumb.js.map +1 -1
- package/dist/backends/gui/button-group.cjs +43 -0
- package/dist/backends/gui/button-group.d.ts +48 -0
- package/dist/backends/gui/button-group.d.ts.map +1 -0
- package/dist/backends/gui/button-group.js +40 -0
- package/dist/backends/gui/button-group.js.map +1 -0
- package/dist/backends/gui/button.cjs +177 -4
- package/dist/backends/gui/button.d.ts +69 -4
- package/dist/backends/gui/button.d.ts.map +1 -1
- package/dist/backends/gui/button.js +179 -6
- package/dist/backends/gui/button.js.map +1 -1
- package/dist/backends/gui/card.cjs +50 -21
- package/dist/backends/gui/card.d.ts +16 -7
- package/dist/backends/gui/card.d.ts.map +1 -1
- package/dist/backends/gui/card.js +50 -21
- package/dist/backends/gui/card.js.map +1 -1
- package/dist/backends/gui/checkbox.cjs +86 -14
- package/dist/backends/gui/checkbox.d.ts +30 -2
- package/dist/backends/gui/checkbox.d.ts.map +1 -1
- package/dist/backends/gui/checkbox.js +87 -15
- package/dist/backends/gui/checkbox.js.map +1 -1
- package/dist/backends/gui/chip.cjs +51 -0
- package/dist/backends/gui/chip.d.ts +47 -0
- package/dist/backends/gui/chip.d.ts.map +1 -0
- package/dist/backends/gui/chip.js +49 -0
- package/dist/backends/gui/chip.js.map +1 -0
- package/dist/backends/gui/choice.cjs +18 -3
- package/dist/backends/gui/choice.d.ts +10 -2
- package/dist/backends/gui/choice.d.ts.map +1 -1
- package/dist/backends/gui/choice.js +19 -4
- package/dist/backends/gui/choice.js.map +1 -1
- package/dist/backends/gui/code-editor.cjs +16 -5
- package/dist/backends/gui/code-editor.d.ts +18 -1
- package/dist/backends/gui/code-editor.d.ts.map +1 -1
- package/dist/backends/gui/code-editor.js +16 -5
- package/dist/backends/gui/code-editor.js.map +1 -1
- package/dist/backends/gui/color-sample.cjs +24 -0
- package/dist/backends/gui/color-sample.d.ts +23 -0
- package/dist/backends/gui/color-sample.d.ts.map +1 -0
- package/dist/backends/gui/color-sample.js +22 -0
- package/dist/backends/gui/color-sample.js.map +1 -0
- package/dist/backends/gui/control.cjs +5 -3
- package/dist/backends/gui/control.d.ts +13 -3
- package/dist/backends/gui/control.d.ts.map +1 -1
- package/dist/backends/gui/control.js +5 -3
- package/dist/backends/gui/control.js.map +1 -1
- package/dist/backends/gui/country-select.cjs +69 -0
- package/dist/backends/gui/country-select.d.ts +30 -0
- package/dist/backends/gui/country-select.d.ts.map +1 -0
- package/dist/backends/gui/country-select.js +67 -0
- package/dist/backends/gui/country-select.js.map +1 -0
- package/dist/backends/gui/currency-picker.cjs +48 -0
- package/dist/backends/gui/currency-picker.d.ts +37 -0
- package/dist/backends/gui/currency-picker.d.ts.map +1 -0
- package/dist/backends/gui/currency-picker.js +46 -0
- package/dist/backends/gui/currency-picker.js.map +1 -0
- package/dist/backends/gui/density.cjs +32 -0
- package/dist/backends/gui/density.d.ts +27 -0
- package/dist/backends/gui/density.d.ts.map +1 -0
- package/dist/backends/gui/density.js +27 -0
- package/dist/backends/gui/density.js.map +1 -0
- package/dist/backends/gui/dialog.cjs +65 -7
- package/dist/backends/gui/dialog.d.ts +68 -3
- package/dist/backends/gui/dialog.d.ts.map +1 -1
- package/dist/backends/gui/dialog.js +63 -7
- package/dist/backends/gui/dialog.js.map +1 -1
- package/dist/backends/gui/dropdown-menu.cjs +361 -31
- package/dist/backends/gui/dropdown-menu.d.ts +151 -15
- package/dist/backends/gui/dropdown-menu.d.ts.map +1 -1
- package/dist/backends/gui/dropdown-menu.js +353 -34
- package/dist/backends/gui/dropdown-menu.js.map +1 -1
- package/dist/backends/gui/feedback.cjs +78 -0
- package/dist/backends/gui/feedback.d.ts +46 -0
- package/dist/backends/gui/feedback.d.ts.map +1 -0
- package/dist/backends/gui/feedback.js +74 -0
- package/dist/backends/gui/feedback.js.map +1 -0
- package/dist/backends/gui/field.cjs +71 -14
- package/dist/backends/gui/field.d.ts +43 -3
- package/dist/backends/gui/field.d.ts.map +1 -1
- package/dist/backends/gui/field.js +69 -14
- package/dist/backends/gui/field.js.map +1 -1
- package/dist/backends/gui/flag.cjs +17 -0
- package/dist/backends/gui/flag.d.ts +9 -0
- package/dist/backends/gui/flag.d.ts.map +1 -0
- package/dist/backends/gui/flag.js +14 -0
- package/dist/backends/gui/flag.js.map +1 -0
- package/dist/backends/gui/grip.cjs +35 -3
- package/dist/backends/gui/grip.d.ts +16 -1
- package/dist/backends/gui/grip.d.ts.map +1 -1
- package/dist/backends/gui/grip.js +35 -3
- package/dist/backends/gui/grip.js.map +1 -1
- package/dist/backends/gui/heading.cjs +27 -0
- package/dist/backends/gui/heading.d.ts +8 -0
- package/dist/backends/gui/heading.d.ts.map +1 -0
- package/dist/backends/gui/heading.js +25 -0
- package/dist/backends/gui/heading.js.map +1 -0
- package/dist/backends/gui/hue.cjs +49 -0
- package/dist/backends/gui/hue.d.ts +18 -0
- package/dist/backends/gui/hue.d.ts.map +1 -0
- package/dist/backends/gui/hue.js +43 -0
- package/dist/backends/gui/hue.js.map +1 -0
- package/dist/backends/gui/icon-tile.cjs +36 -0
- package/dist/backends/gui/icon-tile.d.ts +26 -0
- package/dist/backends/gui/icon-tile.d.ts.map +1 -0
- package/dist/backends/gui/icon-tile.js +32 -0
- package/dist/backends/gui/icon-tile.js.map +1 -0
- package/dist/backends/gui/image-input.cjs +78 -0
- package/dist/backends/gui/image-input.d.ts +32 -0
- package/dist/backends/gui/image-input.d.ts.map +1 -0
- package/dist/backends/gui/image-input.js +74 -0
- package/dist/backends/gui/image-input.js.map +1 -0
- package/dist/backends/gui/index.cjs +93 -7
- package/dist/backends/gui/index.d.ts +45 -2
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +35 -1
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/backends/gui/input-group.cjs +49 -0
- package/dist/backends/gui/input-group.d.ts +46 -0
- package/dist/backends/gui/input-group.d.ts.map +1 -0
- package/dist/backends/gui/input-group.js +46 -0
- package/dist/backends/gui/input-group.js.map +1 -0
- package/dist/backends/gui/input.cjs +32 -4
- package/dist/backends/gui/input.d.ts +5 -1
- package/dist/backends/gui/input.d.ts.map +1 -1
- package/dist/backends/gui/input.js +33 -5
- package/dist/backends/gui/input.js.map +1 -1
- package/dist/backends/gui/item.cjs +34 -2
- package/dist/backends/gui/item.d.ts +21 -5
- package/dist/backends/gui/item.d.ts.map +1 -1
- package/dist/backends/gui/item.js +35 -3
- package/dist/backends/gui/item.js.map +1 -1
- package/dist/backends/gui/json-tree.cjs +103 -15
- package/dist/backends/gui/json-tree.d.ts +39 -3
- package/dist/backends/gui/json-tree.d.ts.map +1 -1
- package/dist/backends/gui/json-tree.js +104 -16
- package/dist/backends/gui/json-tree.js.map +1 -1
- package/dist/backends/gui/kbd.cjs +18 -2
- package/dist/backends/gui/kbd.d.ts +5 -2
- package/dist/backends/gui/kbd.d.ts.map +1 -1
- package/dist/backends/gui/kbd.js +18 -2
- package/dist/backends/gui/kbd.js.map +1 -1
- package/dist/backends/gui/label.cjs +14 -3
- package/dist/backends/gui/label.d.ts +12 -3
- package/dist/backends/gui/label.d.ts.map +1 -1
- package/dist/backends/gui/label.js +14 -3
- package/dist/backends/gui/label.js.map +1 -1
- package/dist/backends/gui/layout.cjs +5 -1
- package/dist/backends/gui/layout.d.ts +1 -1
- package/dist/backends/gui/layout.d.ts.map +1 -1
- package/dist/backends/gui/layout.js +5 -1
- package/dist/backends/gui/layout.js.map +1 -1
- package/dist/backends/gui/number-field.cjs +163 -0
- package/dist/backends/gui/number-field.d.ts +34 -0
- package/dist/backends/gui/number-field.d.ts.map +1 -0
- package/dist/backends/gui/number-field.js +160 -0
- package/dist/backends/gui/number-field.js.map +1 -0
- package/dist/backends/gui/overflowing-list.cjs +79 -0
- package/dist/backends/gui/overflowing-list.d.ts +42 -0
- package/dist/backends/gui/overflowing-list.d.ts.map +1 -0
- package/dist/backends/gui/overflowing-list.js +76 -0
- package/dist/backends/gui/overflowing-list.js.map +1 -0
- package/dist/backends/gui/phone-country-picker.cjs +60 -0
- package/dist/backends/gui/phone-country-picker.d.ts +34 -0
- package/dist/backends/gui/phone-country-picker.d.ts.map +1 -0
- package/dist/backends/gui/phone-country-picker.js +57 -0
- package/dist/backends/gui/phone-country-picker.js.map +1 -0
- package/dist/backends/gui/popover.cjs +20 -4
- package/dist/backends/gui/popover.d.ts +12 -1
- package/dist/backends/gui/popover.d.ts.map +1 -1
- package/dist/backends/gui/popover.js +21 -5
- package/dist/backends/gui/popover.js.map +1 -1
- package/dist/backends/gui/progress-ring.cjs +38 -0
- package/dist/backends/gui/progress-ring.d.ts +37 -0
- package/dist/backends/gui/progress-ring.d.ts.map +1 -0
- package/dist/backends/gui/progress-ring.js +36 -0
- package/dist/backends/gui/progress-ring.js.map +1 -0
- package/dist/backends/gui/progress.cjs +31 -7
- package/dist/backends/gui/progress.d.ts +25 -3
- package/dist/backends/gui/progress.d.ts.map +1 -1
- package/dist/backends/gui/progress.js +32 -8
- package/dist/backends/gui/progress.js.map +1 -1
- package/dist/backends/gui/radio-group.cjs +28 -2
- package/dist/backends/gui/radio-group.d.ts +20 -2
- package/dist/backends/gui/radio-group.d.ts.map +1 -1
- package/dist/backends/gui/radio-group.js +28 -2
- package/dist/backends/gui/radio-group.js.map +1 -1
- package/dist/backends/gui/search-list.cjs +62 -0
- package/dist/backends/gui/search-list.d.ts +65 -0
- package/dist/backends/gui/search-list.d.ts.map +1 -0
- package/dist/backends/gui/search-list.js +58 -0
- package/dist/backends/gui/search-list.js.map +1 -0
- package/dist/backends/gui/select.cjs +50 -16
- package/dist/backends/gui/select.d.ts +12 -3
- package/dist/backends/gui/select.d.ts.map +1 -1
- package/dist/backends/gui/select.js +51 -17
- package/dist/backends/gui/select.js.map +1 -1
- package/dist/backends/gui/shortcut.cjs +122 -0
- package/dist/backends/gui/shortcut.d.ts +58 -0
- package/dist/backends/gui/shortcut.d.ts.map +1 -0
- package/dist/backends/gui/shortcut.js +115 -0
- package/dist/backends/gui/shortcut.js.map +1 -0
- package/dist/backends/gui/skeleton.cjs +41 -10
- package/dist/backends/gui/skeleton.d.ts +46 -8
- package/dist/backends/gui/skeleton.d.ts.map +1 -1
- package/dist/backends/gui/skeleton.js +39 -8
- package/dist/backends/gui/skeleton.js.map +1 -1
- package/dist/backends/gui/snippet.cjs +12 -1
- package/dist/backends/gui/snippet.d.ts +4 -2
- package/dist/backends/gui/snippet.d.ts.map +1 -1
- package/dist/backends/gui/snippet.js +12 -1
- package/dist/backends/gui/snippet.js.map +1 -1
- package/dist/backends/gui/spinner.cjs +8 -1
- package/dist/backends/gui/spinner.d.ts +11 -2
- package/dist/backends/gui/spinner.d.ts.map +1 -1
- package/dist/backends/gui/spinner.js +9 -2
- package/dist/backends/gui/spinner.js.map +1 -1
- package/dist/backends/gui/stack-icon.cjs +17 -0
- package/dist/backends/gui/stack-icon.d.ts +15 -0
- package/dist/backends/gui/stack-icon.d.ts.map +1 -0
- package/dist/backends/gui/stack-icon.js +15 -0
- package/dist/backends/gui/stack-icon.js.map +1 -0
- package/dist/backends/gui/status.cjs +38 -1
- package/dist/backends/gui/status.d.ts +16 -2
- package/dist/backends/gui/status.d.ts.map +1 -1
- package/dist/backends/gui/status.js +38 -2
- package/dist/backends/gui/status.js.map +1 -1
- package/dist/backends/gui/stepper.cjs +73 -3
- package/dist/backends/gui/stepper.d.ts +25 -1
- package/dist/backends/gui/stepper.d.ts.map +1 -1
- package/dist/backends/gui/stepper.js +71 -5
- package/dist/backends/gui/stepper.js.map +1 -1
- package/dist/backends/gui/switch.cjs +35 -20
- package/dist/backends/gui/switch.d.ts +12 -2
- package/dist/backends/gui/switch.d.ts.map +1 -1
- package/dist/backends/gui/switch.js +35 -20
- package/dist/backends/gui/switch.js.map +1 -1
- package/dist/backends/gui/tabs.cjs +63 -17
- package/dist/backends/gui/tabs.d.ts +35 -6
- package/dist/backends/gui/tabs.d.ts.map +1 -1
- package/dist/backends/gui/tabs.js +65 -19
- package/dist/backends/gui/tabs.js.map +1 -1
- package/dist/backends/gui/tag.cjs +48 -0
- package/dist/backends/gui/tag.d.ts +53 -0
- package/dist/backends/gui/tag.d.ts.map +1 -0
- package/dist/backends/gui/tag.js +46 -0
- package/dist/backends/gui/tag.js.map +1 -0
- package/dist/backends/gui/tags.cjs +9 -2
- package/dist/backends/gui/tags.d.ts +6 -5
- package/dist/backends/gui/tags.d.ts.map +1 -1
- package/dist/backends/gui/tags.js +9 -2
- package/dist/backends/gui/tags.js.map +1 -1
- package/dist/backends/gui/textarea.cjs +22 -6
- package/dist/backends/gui/textarea.d.ts +10 -1
- package/dist/backends/gui/textarea.d.ts.map +1 -1
- package/dist/backends/gui/textarea.js +22 -6
- package/dist/backends/gui/textarea.js.map +1 -1
- package/dist/backends/gui/toaster.cjs +167 -3
- package/dist/backends/gui/toaster.d.ts +28 -2
- package/dist/backends/gui/toaster.d.ts.map +1 -1
- package/dist/backends/gui/toaster.js +167 -5
- package/dist/backends/gui/toaster.js.map +1 -1
- package/dist/backends/gui/toggle-group.cjs +13 -0
- package/dist/backends/gui/toggle-group.d.ts +7 -1
- package/dist/backends/gui/toggle-group.d.ts.map +1 -1
- package/dist/backends/gui/toggle-group.js +13 -0
- package/dist/backends/gui/toggle-group.js.map +1 -1
- package/dist/backends/gui/tooltip.cjs +29 -6
- package/dist/backends/gui/tooltip.d.ts +23 -4
- package/dist/backends/gui/tooltip.d.ts.map +1 -1
- package/dist/backends/gui/tooltip.js +31 -8
- package/dist/backends/gui/tooltip.js.map +1 -1
- package/dist/backends/gui/truncated-text.cjs +102 -0
- package/dist/backends/gui/truncated-text.d.ts +55 -0
- package/dist/backends/gui/truncated-text.d.ts.map +1 -0
- package/dist/backends/gui/truncated-text.js +97 -0
- package/dist/backends/gui/truncated-text.js.map +1 -0
- package/dist/gallery/compound.cjs +60 -0
- package/dist/gallery/compound.d.ts +2 -0
- package/dist/gallery/compound.d.ts.map +1 -0
- package/dist/gallery/compound.js +58 -0
- package/dist/gallery/compound.js.map +1 -0
- package/dist/gallery/display.cjs +47 -0
- package/dist/gallery/display.d.ts +3 -0
- package/dist/gallery/display.d.ts.map +1 -0
- package/dist/gallery/display.js +45 -0
- package/dist/gallery/display.js.map +1 -0
- package/dist/gallery/feedback.cjs +38 -0
- package/dist/gallery/feedback.d.ts +2 -0
- package/dist/gallery/feedback.d.ts.map +1 -0
- package/dist/gallery/feedback.js +36 -0
- package/dist/gallery/feedback.js.map +1 -0
- package/dist/gallery/fields.cjs +53 -0
- package/dist/gallery/fields.d.ts +2 -0
- package/dist/gallery/fields.d.ts.map +1 -0
- package/dist/gallery/fields.js +51 -0
- package/dist/gallery/fields.js.map +1 -0
- package/dist/gallery/frames.cjs +47 -0
- package/dist/gallery/frames.d.ts +2 -0
- package/dist/gallery/frames.d.ts.map +1 -0
- package/dist/gallery/frames.js +45 -0
- package/dist/gallery/frames.js.map +1 -0
- package/dist/gallery/menus.cjs +64 -0
- package/dist/gallery/menus.d.ts +15 -0
- package/dist/gallery/menus.d.ts.map +1 -0
- package/dist/gallery/menus.js +58 -0
- package/dist/gallery/menus.js.map +1 -0
- package/dist/gallery/records.cjs +33 -0
- package/dist/gallery/records.d.ts +2 -0
- package/dist/gallery/records.d.ts.map +1 -0
- package/dist/gallery/records.js +31 -0
- package/dist/gallery/records.js.map +1 -0
- package/dist/gallery/section.cjs +17 -0
- package/dist/gallery/section.d.ts +10 -0
- package/dist/gallery/section.d.ts.map +1 -0
- package/dist/gallery/section.js +14 -0
- package/dist/gallery/section.js.map +1 -0
- package/dist/gallery.cjs +8 -14
- package/dist/gallery.d.ts.map +1 -1
- package/dist/gallery.html +1594 -256
- package/dist/gallery.js +3 -9
- package/dist/gallery.js.map +1 -1
- package/dist/gui-config.cjs +33 -4
- package/dist/gui-config.d.ts +11 -3
- package/dist/gui-config.d.ts.map +1 -1
- package/dist/gui-config.js +33 -4
- package/dist/gui-config.js.map +1 -1
- package/dist/index.cjs +61 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +61 -2
- package/dist/index.node.js +7 -1
- package/dist/motion.cjs +25 -1
- package/dist/motion.d.ts +16 -1
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +24 -1
- package/dist/motion.js.map +1 -1
- package/dist/primitives/AvatarGroup.cjs +8 -0
- package/dist/primitives/AvatarGroup.d.ts +2 -0
- package/dist/primitives/AvatarGroup.d.ts.map +1 -0
- package/dist/primitives/AvatarGroup.js +5 -0
- package/dist/primitives/AvatarGroup.js.map +1 -0
- package/dist/primitives/BannerAction.cjs +8 -0
- package/dist/primitives/BannerAction.d.ts +2 -0
- package/dist/primitives/BannerAction.d.ts.map +1 -0
- package/dist/primitives/BannerAction.js +5 -0
- package/dist/primitives/BannerAction.js.map +1 -0
- package/dist/primitives/ButtonGroup.cjs +8 -0
- package/dist/primitives/ButtonGroup.d.ts +2 -0
- package/dist/primitives/ButtonGroup.d.ts.map +1 -0
- package/dist/primitives/ButtonGroup.js +5 -0
- package/dist/primitives/ButtonGroup.js.map +1 -0
- package/dist/primitives/ButtonGroupContext.cjs +8 -0
- package/dist/primitives/ButtonGroupContext.d.ts +2 -0
- package/dist/primitives/ButtonGroupContext.d.ts.map +1 -0
- package/dist/primitives/ButtonGroupContext.js +5 -0
- package/dist/primitives/ButtonGroupContext.js.map +1 -0
- package/dist/primitives/CalloutAction.cjs +8 -0
- package/dist/primitives/CalloutAction.d.ts +2 -0
- package/dist/primitives/CalloutAction.d.ts.map +1 -0
- package/dist/primitives/CalloutAction.js +5 -0
- package/dist/primitives/CalloutAction.js.map +1 -0
- package/dist/primitives/Chip.cjs +8 -0
- package/dist/primitives/Chip.d.ts +2 -0
- package/dist/primitives/Chip.d.ts.map +1 -0
- package/dist/primitives/Chip.js +5 -0
- package/dist/primitives/Chip.js.map +1 -0
- package/dist/primitives/ColorSample.cjs +8 -0
- package/dist/primitives/ColorSample.d.ts +2 -0
- package/dist/primitives/ColorSample.d.ts.map +1 -0
- package/dist/primitives/ColorSample.js +5 -0
- package/dist/primitives/ColorSample.js.map +1 -0
- package/dist/primitives/CountrySelect.cjs +8 -0
- package/dist/primitives/CountrySelect.d.ts +2 -0
- package/dist/primitives/CountrySelect.d.ts.map +1 -0
- package/dist/primitives/CountrySelect.js +5 -0
- package/dist/primitives/CountrySelect.js.map +1 -0
- package/dist/primitives/CurrencyPicker.cjs +8 -0
- package/dist/primitives/CurrencyPicker.d.ts +2 -0
- package/dist/primitives/CurrencyPicker.d.ts.map +1 -0
- package/dist/primitives/CurrencyPicker.js +5 -0
- package/dist/primitives/CurrencyPicker.js.map +1 -0
- package/dist/primitives/Density.cjs +8 -0
- package/dist/primitives/Density.d.ts +2 -0
- package/dist/primitives/Density.d.ts.map +1 -0
- package/dist/primitives/Density.js +5 -0
- package/dist/primitives/Density.js.map +1 -0
- package/dist/primitives/DialogBody.cjs +8 -0
- package/dist/primitives/DialogBody.d.ts +2 -0
- package/dist/primitives/DialogBody.d.ts.map +1 -0
- package/dist/primitives/DialogBody.js +5 -0
- package/dist/primitives/DialogBody.js.map +1 -0
- package/dist/primitives/DropdownMenuBack.cjs +8 -0
- package/dist/primitives/DropdownMenuBack.d.ts +2 -0
- package/dist/primitives/DropdownMenuBack.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuBack.js +5 -0
- package/dist/primitives/DropdownMenuBack.js.map +1 -0
- package/dist/primitives/DropdownMenuClose.cjs +8 -0
- package/dist/primitives/DropdownMenuClose.d.ts +2 -0
- package/dist/primitives/DropdownMenuClose.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuClose.js +5 -0
- package/dist/primitives/DropdownMenuClose.js.map +1 -0
- package/dist/primitives/DropdownMenuEmpty.cjs +8 -0
- package/dist/primitives/DropdownMenuEmpty.d.ts +2 -0
- package/dist/primitives/DropdownMenuEmpty.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuEmpty.js +5 -0
- package/dist/primitives/DropdownMenuEmpty.js.map +1 -0
- package/dist/primitives/DropdownMenuHeader.cjs +8 -0
- package/dist/primitives/DropdownMenuHeader.d.ts +2 -0
- package/dist/primitives/DropdownMenuHeader.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuHeader.js +5 -0
- package/dist/primitives/DropdownMenuHeader.js.map +1 -0
- package/dist/primitives/DropdownMenuLoading.cjs +8 -0
- package/dist/primitives/DropdownMenuLoading.d.ts +2 -0
- package/dist/primitives/DropdownMenuLoading.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuLoading.js +5 -0
- package/dist/primitives/DropdownMenuLoading.js.map +1 -0
- package/dist/primitives/DropdownMenuOptionItem.cjs +8 -0
- package/dist/primitives/DropdownMenuOptionItem.d.ts +2 -0
- package/dist/primitives/DropdownMenuOptionItem.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuOptionItem.js +5 -0
- package/dist/primitives/DropdownMenuOptionItem.js.map +1 -0
- package/dist/primitives/DropdownMenuPage.cjs +8 -0
- package/dist/primitives/DropdownMenuPage.d.ts +2 -0
- package/dist/primitives/DropdownMenuPage.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuPage.js +5 -0
- package/dist/primitives/DropdownMenuPage.js.map +1 -0
- package/dist/primitives/DropdownMenuSearch.cjs +8 -0
- package/dist/primitives/DropdownMenuSearch.d.ts +2 -0
- package/dist/primitives/DropdownMenuSearch.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuSearch.js +5 -0
- package/dist/primitives/DropdownMenuSearch.js.map +1 -0
- package/dist/primitives/DropdownMenuSection.cjs +8 -0
- package/dist/primitives/DropdownMenuSection.d.ts +2 -0
- package/dist/primitives/DropdownMenuSection.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuSection.js +5 -0
- package/dist/primitives/DropdownMenuSection.js.map +1 -0
- package/dist/primitives/DropdownMenuSelectionGroup.cjs +8 -0
- package/dist/primitives/DropdownMenuSelectionGroup.d.ts +2 -0
- package/dist/primitives/DropdownMenuSelectionGroup.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuSelectionGroup.js +5 -0
- package/dist/primitives/DropdownMenuSelectionGroup.js.map +1 -0
- package/dist/primitives/DropdownMenuTitle.cjs +8 -0
- package/dist/primitives/DropdownMenuTitle.d.ts +2 -0
- package/dist/primitives/DropdownMenuTitle.d.ts.map +1 -0
- package/dist/primitives/DropdownMenuTitle.js +5 -0
- package/dist/primitives/DropdownMenuTitle.js.map +1 -0
- package/dist/primitives/Heading.cjs +2 -2
- package/dist/primitives/Heading.d.ts +1 -1
- package/dist/primitives/Heading.d.ts.map +1 -1
- package/dist/primitives/Heading.js +1 -1
- package/dist/primitives/Heading.js.map +1 -1
- package/dist/primitives/IconTile.cjs +8 -0
- package/dist/primitives/IconTile.d.ts +2 -0
- package/dist/primitives/IconTile.d.ts.map +1 -0
- package/dist/primitives/IconTile.js +5 -0
- package/dist/primitives/IconTile.js.map +1 -0
- package/dist/primitives/ImageInput.cjs +8 -0
- package/dist/primitives/ImageInput.d.ts +2 -0
- package/dist/primitives/ImageInput.d.ts.map +1 -0
- package/dist/primitives/ImageInput.js +5 -0
- package/dist/primitives/ImageInput.js.map +1 -0
- package/dist/primitives/InputGroup.cjs +8 -0
- package/dist/primitives/InputGroup.d.ts +2 -0
- package/dist/primitives/InputGroup.d.ts.map +1 -0
- package/dist/primitives/InputGroup.js +5 -0
- package/dist/primitives/InputGroup.js.map +1 -0
- package/dist/primitives/NumberField.cjs +8 -0
- package/dist/primitives/NumberField.d.ts +2 -0
- package/dist/primitives/NumberField.d.ts.map +1 -0
- package/dist/primitives/NumberField.js +5 -0
- package/dist/primitives/NumberField.js.map +1 -0
- package/dist/primitives/OverflowingList.cjs +8 -0
- package/dist/primitives/OverflowingList.d.ts +2 -0
- package/dist/primitives/OverflowingList.d.ts.map +1 -0
- package/dist/primitives/OverflowingList.js +5 -0
- package/dist/primitives/OverflowingList.js.map +1 -0
- package/dist/primitives/PhoneCountryPicker.cjs +8 -0
- package/dist/primitives/PhoneCountryPicker.d.ts +2 -0
- package/dist/primitives/PhoneCountryPicker.d.ts.map +1 -0
- package/dist/primitives/PhoneCountryPicker.js +5 -0
- package/dist/primitives/PhoneCountryPicker.js.map +1 -0
- package/dist/primitives/ProgressRing.cjs +8 -0
- package/dist/primitives/ProgressRing.d.ts +2 -0
- package/dist/primitives/ProgressRing.d.ts.map +1 -0
- package/dist/primitives/ProgressRing.js +5 -0
- package/dist/primitives/ProgressRing.js.map +1 -0
- package/dist/primitives/RadioCircle.cjs +8 -0
- package/dist/primitives/RadioCircle.d.ts +2 -0
- package/dist/primitives/RadioCircle.d.ts.map +1 -0
- package/dist/primitives/RadioCircle.js +5 -0
- package/dist/primitives/RadioCircle.js.map +1 -0
- package/dist/primitives/SKELETON_HEIGHT.cjs +8 -0
- package/dist/primitives/SKELETON_HEIGHT.d.ts +2 -0
- package/dist/primitives/SKELETON_HEIGHT.d.ts.map +1 -0
- package/dist/primitives/SKELETON_HEIGHT.js +5 -0
- package/dist/primitives/SKELETON_HEIGHT.js.map +1 -0
- package/dist/primitives/STATUS_COLOR.cjs +8 -0
- package/dist/primitives/STATUS_COLOR.d.ts +2 -0
- package/dist/primitives/STATUS_COLOR.d.ts.map +1 -0
- package/dist/primitives/STATUS_COLOR.js +5 -0
- package/dist/primitives/STATUS_COLOR.js.map +1 -0
- package/dist/primitives/STATUS_HUE.cjs +8 -0
- package/dist/primitives/STATUS_HUE.d.ts +2 -0
- package/dist/primitives/STATUS_HUE.d.ts.map +1 -0
- package/dist/primitives/STATUS_HUE.js +5 -0
- package/dist/primitives/STATUS_HUE.js.map +1 -0
- package/dist/primitives/STATUS_PAINT.cjs +8 -0
- package/dist/primitives/STATUS_PAINT.d.ts +2 -0
- package/dist/primitives/STATUS_PAINT.d.ts.map +1 -0
- package/dist/primitives/STATUS_PAINT.js +5 -0
- package/dist/primitives/STATUS_PAINT.js.map +1 -0
- package/dist/primitives/Shortcut.cjs +8 -0
- package/dist/primitives/Shortcut.d.ts +2 -0
- package/dist/primitives/Shortcut.d.ts.map +1 -0
- package/dist/primitives/Shortcut.js +5 -0
- package/dist/primitives/Shortcut.js.map +1 -0
- package/dist/primitives/StackIcon.cjs +8 -0
- package/dist/primitives/StackIcon.d.ts +2 -0
- package/dist/primitives/StackIcon.d.ts.map +1 -0
- package/dist/primitives/StackIcon.js +5 -0
- package/dist/primitives/StackIcon.js.map +1 -0
- package/dist/primitives/TOAST_DURATION.cjs +8 -0
- package/dist/primitives/TOAST_DURATION.d.ts +2 -0
- package/dist/primitives/TOAST_DURATION.d.ts.map +1 -0
- package/dist/primitives/TOAST_DURATION.js +5 -0
- package/dist/primitives/TOAST_DURATION.js.map +1 -0
- package/dist/primitives/Tag.cjs +8 -0
- package/dist/primitives/Tag.d.ts +2 -0
- package/dist/primitives/Tag.d.ts.map +1 -0
- package/dist/primitives/Tag.js +5 -0
- package/dist/primitives/Tag.js.map +1 -0
- package/dist/primitives/ToastCard.cjs +8 -0
- package/dist/primitives/ToastCard.d.ts +2 -0
- package/dist/primitives/ToastCard.d.ts.map +1 -0
- package/dist/primitives/ToastCard.js +5 -0
- package/dist/primitives/ToastCard.js.map +1 -0
- package/dist/primitives/ToastFace.cjs +8 -0
- package/dist/primitives/ToastFace.d.ts +2 -0
- package/dist/primitives/ToastFace.d.ts.map +1 -0
- package/dist/primitives/ToastFace.js +5 -0
- package/dist/primitives/ToastFace.js.map +1 -0
- package/dist/primitives/TruncatedText.cjs +8 -0
- package/dist/primitives/TruncatedText.d.ts +2 -0
- package/dist/primitives/TruncatedText.d.ts.map +1 -0
- package/dist/primitives/TruncatedText.js +5 -0
- package/dist/primitives/TruncatedText.js.map +1 -0
- package/dist/primitives/TruncatedTextProvider.cjs +8 -0
- package/dist/primitives/TruncatedTextProvider.d.ts +2 -0
- package/dist/primitives/TruncatedTextProvider.d.ts.map +1 -0
- package/dist/primitives/TruncatedTextProvider.js +5 -0
- package/dist/primitives/TruncatedTextProvider.js.map +1 -0
- package/dist/primitives/VisuallyHidden.cjs +8 -0
- package/dist/primitives/VisuallyHidden.d.ts +2 -0
- package/dist/primitives/VisuallyHidden.d.ts.map +1 -0
- package/dist/primitives/VisuallyHidden.js +5 -0
- package/dist/primitives/VisuallyHidden.js.map +1 -0
- package/dist/primitives/fieldSize.cjs +8 -0
- package/dist/primitives/fieldSize.d.ts +2 -0
- package/dist/primitives/fieldSize.d.ts.map +1 -0
- package/dist/primitives/fieldSize.js +5 -0
- package/dist/primitives/fieldSize.js.map +1 -0
- package/dist/primitives/flag.cjs +8 -0
- package/dist/primitives/flag.d.ts +2 -0
- package/dist/primitives/flag.d.ts.map +1 -0
- package/dist/primitives/flag.js +5 -0
- package/dist/primitives/flag.js.map +1 -0
- package/dist/primitives/formatShortcut.cjs +8 -0
- package/dist/primitives/formatShortcut.d.ts +2 -0
- package/dist/primitives/formatShortcut.d.ts.map +1 -0
- package/dist/primitives/formatShortcut.js +5 -0
- package/dist/primitives/formatShortcut.js.map +1 -0
- package/dist/primitives/initialOf.cjs +8 -0
- package/dist/primitives/initialOf.d.ts +2 -0
- package/dist/primitives/initialOf.d.ts.map +1 -0
- package/dist/primitives/initialOf.js +5 -0
- package/dist/primitives/initialOf.js.map +1 -0
- package/dist/primitives/parseNumber.cjs +8 -0
- package/dist/primitives/parseNumber.d.ts +2 -0
- package/dist/primitives/parseNumber.d.ts.map +1 -0
- package/dist/primitives/parseNumber.js +5 -0
- package/dist/primitives/parseNumber.js.map +1 -0
- package/dist/primitives/speakShortcut.cjs +8 -0
- package/dist/primitives/speakShortcut.d.ts +2 -0
- package/dist/primitives/speakShortcut.d.ts.map +1 -0
- package/dist/primitives/speakShortcut.js +5 -0
- package/dist/primitives/speakShortcut.js.map +1 -0
- package/dist/primitives/tileTones.cjs +8 -0
- package/dist/primitives/tileTones.d.ts +2 -0
- package/dist/primitives/tileTones.d.ts.map +1 -0
- package/dist/primitives/tileTones.js +5 -0
- package/dist/primitives/tileTones.js.map +1 -0
- package/dist/primitives/useDensity.cjs +8 -0
- package/dist/primitives/useDensity.d.ts +2 -0
- package/dist/primitives/useDensity.d.ts.map +1 -0
- package/dist/primitives/useDensity.js +5 -0
- package/dist/primitives/useDensity.js.map +1 -0
- package/dist/primitives/useField.cjs +8 -0
- package/dist/primitives/useField.d.ts +2 -0
- package/dist/primitives/useField.d.ts.map +1 -0
- package/dist/primitives/useField.js +5 -0
- package/dist/primitives/useField.js.map +1 -0
- package/dist/product/ComboBox.cjs +25 -7
- package/dist/product/ComboBox.d.ts +3 -1
- package/dist/product/ComboBox.d.ts.map +1 -1
- package/dist/product/ComboBox.js +25 -7
- package/dist/product/ComboBox.js.map +1 -1
- package/dist/product/CommandMenu.cjs +137 -0
- package/dist/product/CommandMenu.d.ts +77 -0
- package/dist/product/CommandMenu.d.ts.map +1 -0
- package/dist/product/CommandMenu.js +134 -0
- package/dist/product/CommandMenu.js.map +1 -0
- package/dist/product/DetailPane.cjs +154 -12
- package/dist/product/DetailPane.d.ts +80 -2
- package/dist/product/DetailPane.d.ts.map +1 -1
- package/dist/product/DetailPane.js +153 -16
- package/dist/product/DetailPane.js.map +1 -1
- package/dist/product/Fact.cjs +6 -1
- package/dist/product/Fact.d.ts +16 -1
- package/dist/product/Fact.d.ts.map +1 -1
- package/dist/product/Fact.js +6 -1
- package/dist/product/Fact.js.map +1 -1
- package/dist/product/Field.cjs +14 -2
- package/dist/product/Field.d.ts +16 -1
- package/dist/product/Field.d.ts.map +1 -1
- package/dist/product/Field.js +14 -2
- package/dist/product/Field.js.map +1 -1
- package/dist/product/Filters.cjs +61 -9
- package/dist/product/Filters.d.ts +37 -6
- package/dist/product/Filters.d.ts.map +1 -1
- package/dist/product/Filters.js +62 -10
- package/dist/product/Filters.js.map +1 -1
- package/dist/product/MenuRow.cjs +81 -2
- package/dist/product/MenuRow.d.ts +76 -6
- package/dist/product/MenuRow.d.ts.map +1 -1
- package/dist/product/MenuRow.js +81 -4
- package/dist/product/MenuRow.js.map +1 -1
- package/dist/product/PrimaryButton.cjs +5 -1
- package/dist/product/PrimaryButton.d.ts +8 -0
- package/dist/product/PrimaryButton.d.ts.map +1 -1
- package/dist/product/PrimaryButton.js +5 -1
- package/dist/product/PrimaryButton.js.map +1 -1
- package/dist/product/Skeleton.cjs +7 -6
- package/dist/product/Skeleton.d.ts +3 -20
- package/dist/product/Skeleton.d.ts.map +1 -1
- package/dist/product/Skeleton.js +8 -7
- package/dist/product/Skeleton.js.map +1 -1
- package/dist/product/index.cjs +2 -0
- package/dist/product/index.d.ts +1 -0
- package/dist/product/index.d.ts.map +1 -1
- package/dist/product/index.js +2 -0
- package/dist/product/index.js.map +1 -1
- package/dist/settings/Section.cjs +11 -2
- package/dist/settings/Section.d.ts +8 -1
- package/dist/settings/Section.d.ts.map +1 -1
- package/dist/settings/Section.js +11 -2
- package/dist/settings/Section.js.map +1 -1
- package/dist/styles/motion.css +70 -0
- package/dist/styles.css +1460 -127
- package/dist/theme.css +944 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-icon.js","sourceRoot":"","sources":["../../../src/backends/gui/stack-icon.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAO7B,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,EAAkB;IACvE,OAAO,CACL,MAAC,MAAM,OAAK,IAAI,CAAC,YAAY,CAAC,uBAAc,QAAQ,EAAC,UAAU,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAC,QAAQ,EAAC,OAAO,EAAC,QAAQ,KAAK,KAAK,aACxI,IAAI,EACL,KAAC,MAAM,IAAC,QAAQ,EAAC,UAAU,EAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YACnC,WAAW,GACL,IACF,CACV,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.STATUS_HUE = void 0;
|
|
4
5
|
exports.Status = Status;
|
|
5
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
7
|
/**
|
|
@@ -11,10 +12,34 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
11
12
|
* context, so a variant reaches both without either reading it twice by hand.
|
|
12
13
|
* The dot is on by default (it is the whole point of a status pill) and can be
|
|
13
14
|
* turned off for a plain label.
|
|
15
|
+
*
|
|
16
|
+
* `color` draws the record status instead (re-expressed from twenty-ui's
|
|
17
|
+
* Status, MIT, see NOTICE): any of the thirty data hues, its step 3 under step
|
|
18
|
+
* 11 ink, a 4px dot in the ink, 20px tall, 13px regular, and a `loading` state
|
|
19
|
+
* that busies the pill. The semantic names stay as aliases onto hues — success
|
|
20
|
+
* green, warning orange, error red, info blue, default and gray gray — so one
|
|
21
|
+
* status map serves both looks.
|
|
14
22
|
*/
|
|
15
23
|
const gui_1 = require("@hanzo/gui");
|
|
24
|
+
const hue_1 = require("./hue.cjs");
|
|
25
|
+
const feedback_1 = require("./feedback.cjs");
|
|
16
26
|
const ink_1 = require("./ink.cjs");
|
|
17
27
|
const slot_1 = require("./slot.cjs");
|
|
28
|
+
/**
|
|
29
|
+
* Status's names onto data hues, read from the one status map (feedback.ts
|
|
30
|
+
* `STATUS_COLOR`), so a success pill, a success banner and a success toast
|
|
31
|
+
* cannot name different colours. The pill draws the hue's tag pair (data
|
|
32
|
+
* steps 3/11); the strip and the toast draw the state token — the same colour
|
|
33
|
+
* by name, each in its own material.
|
|
34
|
+
*/
|
|
35
|
+
exports.STATUS_HUE = {
|
|
36
|
+
default: feedback_1.STATUS_COLOR.neutral,
|
|
37
|
+
gray: feedback_1.STATUS_COLOR.neutral,
|
|
38
|
+
success: feedback_1.STATUS_COLOR.success,
|
|
39
|
+
warning: feedback_1.STATUS_COLOR.warning,
|
|
40
|
+
error: feedback_1.STATUS_COLOR.error,
|
|
41
|
+
info: feedback_1.STATUS_COLOR.info,
|
|
42
|
+
};
|
|
18
43
|
const StatusContext = /* @__PURE__ */ (0, gui_1.createStyledContext)({
|
|
19
44
|
variant: 'default',
|
|
20
45
|
});
|
|
@@ -73,7 +98,19 @@ const StatusDot = (0, gui_1.styled)(gui_1.XStack, {
|
|
|
73
98
|
},
|
|
74
99
|
},
|
|
75
100
|
});
|
|
76
|
-
function Status({ variant = 'default', dot = true, children, ...props }) {
|
|
101
|
+
function Status({ variant = 'default', color, loading = false, weight = 'regular', dot = true, children, ...props }) {
|
|
102
|
+
if (color != null)
|
|
103
|
+
return (0, jsx_runtime_1.jsx)(Hued, { color: color, loading: loading, weight: weight, dot: dot, ...props, children: children });
|
|
77
104
|
const resolved = variant ?? 'default';
|
|
78
105
|
return ((0, jsx_runtime_1.jsxs)(StatusFrame, { ...(0, slot_1.slot)('status'), variant: resolved, "data-variant": resolved, ...props, children: [dot ? (0, jsx_runtime_1.jsx)(StatusDot, { ...(0, slot_1.slot)('status-dot') }) : null, (0, ink_1.ink)(children, StatusText)] }));
|
|
79
106
|
}
|
|
107
|
+
function Hued({ color, loading, weight, dot, children, style, ...props }) {
|
|
108
|
+
const hue = color in exports.STATUS_HUE ? exports.STATUS_HUE[color] : (0, hue_1.hueOr)(color);
|
|
109
|
+
const { style: hueStyle, tone } = (0, hue_1.useTone)(hue, [3, 11]);
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { ...(0, slot_1.slot)('status'), "data-color": hue, ...(loading ? { 'aria-busy': true } : null), display: "inline-flex", self: "flex-start", items: "center", gap: "$1", height: 20, pl: "$2", pr: loading ? '$1' : '$2', rounded: "$10", bg: tone(3), maxW: "100%", overflow: "hidden", style: { ...hueStyle, ...style }, ...props, children: [dot ? (0, jsx_runtime_1.jsx)(gui_1.XStack, { ...(0, slot_1.slot)('status-dot'), width: 4, height: 4, rounded: "$10", bg: tone(11), shrink: 0 }) : null, (0, ink_1.ink)(children, gui_1.SizableText, {
|
|
111
|
+
size: '$2',
|
|
112
|
+
color: tone(11),
|
|
113
|
+
numberOfLines: 1,
|
|
114
|
+
...(weight === 'medium' ? { fontWeight: '500' } : null),
|
|
115
|
+
}), loading ? (0, jsx_runtime_1.jsx)(gui_1.Spinner, { size: "small", maxW: 12, maxH: 12, color: tone(11) }) : null] }));
|
|
116
|
+
}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
+
import { type DataHue } from './hue.js';
|
|
3
|
+
/**
|
|
4
|
+
* Status's names onto data hues, read from the one status map (feedback.ts
|
|
5
|
+
* `STATUS_COLOR`), so a success pill, a success banner and a success toast
|
|
6
|
+
* cannot name different colours. The pill draws the hue's tag pair (data
|
|
7
|
+
* steps 3/11); the strip and the toast draw the state token — the same colour
|
|
8
|
+
* by name, each in its own material.
|
|
9
|
+
*/
|
|
10
|
+
export declare const STATUS_HUE: Record<StatusVariant, DataHue>;
|
|
2
11
|
export type StatusVariant = 'default' | 'success' | 'warning' | 'error' | 'info' | 'gray';
|
|
3
12
|
declare const StatusFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, any, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
4
13
|
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
5
14
|
fullscreen?: boolean | undefined;
|
|
6
15
|
variant?: "default" | "error" | "gray" | "info" | "success" | "warning" | undefined;
|
|
7
16
|
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
8
|
-
export type StatusProps = Omit<ComponentProps<typeof StatusFrame>, 'variant'> & {
|
|
17
|
+
export type StatusProps = Omit<ComponentProps<typeof StatusFrame>, 'variant' | 'color'> & {
|
|
9
18
|
variant?: StatusVariant | null;
|
|
19
|
+
/** A data hue or a semantic name: the record status look. */
|
|
20
|
+
color?: DataHue | StatusVariant | (string & {});
|
|
21
|
+
/** Busy: a spinner after the label, `aria-busy` on the pill. */
|
|
22
|
+
loading?: boolean;
|
|
23
|
+
weight?: 'regular' | 'medium';
|
|
10
24
|
/** Show the leading dot. Defaults to true — the dot is the point of a status pill. */
|
|
11
25
|
dot?: boolean;
|
|
12
26
|
};
|
|
13
|
-
export declare function Status({ variant, dot, children, ...props }: StatusProps): import("react").JSX.Element;
|
|
27
|
+
export declare function Status({ variant, color, loading, weight, dot, children, ...props }: StatusProps): import("react").JSX.Element;
|
|
14
28
|
export {};
|
|
15
29
|
//# sourceMappingURL=status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/status.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/status.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,OAAO,CAAA;AAKpD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,CAOrD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAMzF,QAAA,MAAM,WAAW;;;;8CAuBf,CAAA;AAuCF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG;IACxF,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC9B,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;IAC/C,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC7B,sFAAsF;IACtF,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,wBAAgB,MAAM,CAAC,EAAE,OAAmB,EAAE,KAAK,EAAE,OAAe,EAAE,MAAkB,EAAE,GAAU,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BAUtI"}
|
|
@@ -8,10 +8,34 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* context, so a variant reaches both without either reading it twice by hand.
|
|
9
9
|
* The dot is on by default (it is the whole point of a status pill) and can be
|
|
10
10
|
* turned off for a plain label.
|
|
11
|
+
*
|
|
12
|
+
* `color` draws the record status instead (re-expressed from twenty-ui's
|
|
13
|
+
* Status, MIT, see NOTICE): any of the thirty data hues, its step 3 under step
|
|
14
|
+
* 11 ink, a 4px dot in the ink, 20px tall, 13px regular, and a `loading` state
|
|
15
|
+
* that busies the pill. The semantic names stay as aliases onto hues — success
|
|
16
|
+
* green, warning orange, error red, info blue, default and gray gray — so one
|
|
17
|
+
* status map serves both looks.
|
|
11
18
|
*/
|
|
12
|
-
import { SizableText, XStack, createStyledContext, styled } from '@hanzo/gui';
|
|
19
|
+
import { SizableText, Spinner, XStack, createStyledContext, styled } from '@hanzo/gui';
|
|
20
|
+
import { hueOr, useTone } from './hue.js';
|
|
21
|
+
import { STATUS_COLOR } from './feedback.js';
|
|
13
22
|
import { ink } from './ink.js';
|
|
14
23
|
import { slot } from './slot.js';
|
|
24
|
+
/**
|
|
25
|
+
* Status's names onto data hues, read from the one status map (feedback.ts
|
|
26
|
+
* `STATUS_COLOR`), so a success pill, a success banner and a success toast
|
|
27
|
+
* cannot name different colours. The pill draws the hue's tag pair (data
|
|
28
|
+
* steps 3/11); the strip and the toast draw the state token — the same colour
|
|
29
|
+
* by name, each in its own material.
|
|
30
|
+
*/
|
|
31
|
+
export const STATUS_HUE = {
|
|
32
|
+
default: STATUS_COLOR.neutral,
|
|
33
|
+
gray: STATUS_COLOR.neutral,
|
|
34
|
+
success: STATUS_COLOR.success,
|
|
35
|
+
warning: STATUS_COLOR.warning,
|
|
36
|
+
error: STATUS_COLOR.error,
|
|
37
|
+
info: STATUS_COLOR.info,
|
|
38
|
+
};
|
|
15
39
|
const StatusContext = /* @__PURE__ */ createStyledContext({
|
|
16
40
|
variant: 'default',
|
|
17
41
|
});
|
|
@@ -70,8 +94,20 @@ const StatusDot = styled(XStack, {
|
|
|
70
94
|
},
|
|
71
95
|
},
|
|
72
96
|
});
|
|
73
|
-
export function Status({ variant = 'default', dot = true, children, ...props }) {
|
|
97
|
+
export function Status({ variant = 'default', color, loading = false, weight = 'regular', dot = true, children, ...props }) {
|
|
98
|
+
if (color != null)
|
|
99
|
+
return _jsx(Hued, { color: color, loading: loading, weight: weight, dot: dot, ...props, children: children });
|
|
74
100
|
const resolved = variant ?? 'default';
|
|
75
101
|
return (_jsxs(StatusFrame, { ...slot('status'), variant: resolved, "data-variant": resolved, ...props, children: [dot ? _jsx(StatusDot, { ...slot('status-dot') }) : null, ink(children, StatusText)] }));
|
|
76
102
|
}
|
|
103
|
+
function Hued({ color, loading, weight, dot, children, style, ...props }) {
|
|
104
|
+
const hue = color in STATUS_HUE ? STATUS_HUE[color] : hueOr(color);
|
|
105
|
+
const { style: hueStyle, tone } = useTone(hue, [3, 11]);
|
|
106
|
+
return (_jsxs(XStack, { ...slot('status'), "data-color": hue, ...(loading ? { 'aria-busy': true } : null), display: "inline-flex", self: "flex-start", items: "center", gap: "$1", height: 20, pl: "$2", pr: loading ? '$1' : '$2', rounded: "$10", bg: tone(3), maxW: "100%", overflow: "hidden", style: { ...hueStyle, ...style }, ...props, children: [dot ? _jsx(XStack, { ...slot('status-dot'), width: 4, height: 4, rounded: "$10", bg: tone(11), shrink: 0 }) : null, ink(children, SizableText, {
|
|
107
|
+
size: '$2',
|
|
108
|
+
color: tone(11),
|
|
109
|
+
numberOfLines: 1,
|
|
110
|
+
...(weight === 'medium' ? { fontWeight: '500' } : null),
|
|
111
|
+
}), loading ? _jsx(Spinner, { size: "small", maxW: 12, maxH: 12, color: tone(11) }) : null] }));
|
|
112
|
+
}
|
|
77
113
|
//# sourceMappingURL=status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/backends/gui/status.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/backends/gui/status.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEtF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgB,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAmC;IACxD,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,IAAI,EAAE,YAAY,CAAC,OAAO;IAC1B,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;CACxB,CAAA;AAID,MAAM,aAAa,GAAG,eAAe,CAAC,mBAAmB,CAA6B;IACpF,OAAO,EAAE,SAAS;CACnB,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;IACjC,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,QAAQ;IACf,GAAG,E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AO,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAU,GAAI,CAAC,CAAC,CAAC,IAAI,IACjF,CACV,CAAA;AACH,CAAC"}
|
|
@@ -1,20 +1,90 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.settle = exports.parseCount = exports.formatCount = void 0;
|
|
4
5
|
exports.Stepper = Stepper;
|
|
5
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
7
|
/**
|
|
7
|
-
* Stepper — a
|
|
8
|
+
* Stepper — a number with a button either side.
|
|
8
9
|
*
|
|
9
10
|
* Both buttons are named for the thing counted (`label`), the count is a live
|
|
10
11
|
* region, and each button disables at its bound instead of silently clamping.
|
|
12
|
+
*
|
|
13
|
+
* `editable` makes the count a field a person can type into, twenty-ui's
|
|
14
|
+
* NumberStepper (MIT, NOTICE): a 64px centred value at the medium weight that
|
|
15
|
+
* commits on Enter or blur — read leniently (grouping stripped, either decimal
|
|
16
|
+
* mark), held to the bounds, rounded to `step` and to `decimals` — and shows
|
|
17
|
+
* Latin digits, grouped only from five digits up. It is on by default under
|
|
18
|
+
* `<Density value="compact">`, where the buttons are 24px; a regular surface
|
|
19
|
+
* keeps the plain count it always had. `readOnly` keeps the value and the
|
|
20
|
+
* layout but lets neither the buttons nor the field change it.
|
|
11
21
|
*/
|
|
12
22
|
const gui_1 = require("@hanzo/gui");
|
|
13
23
|
const lucide_icons_2_1 = require("@hanzogui/lucide-icons-2");
|
|
24
|
+
const react_1 = require("react");
|
|
14
25
|
const button_1 = require("./button.cjs");
|
|
26
|
+
const input_1 = require("./input.cjs");
|
|
15
27
|
const layout_1 = require("./layout.cjs");
|
|
16
28
|
const slot_1 = require("./slot.cjs");
|
|
17
|
-
|
|
29
|
+
const density_1 = require("./density.cjs");
|
|
30
|
+
/** Up to `decimals` fraction digits, Latin digits, grouping from five digits up. */
|
|
31
|
+
const formatCount = (n, decimals = 0) => new Intl.NumberFormat('en-US', {
|
|
32
|
+
maximumFractionDigits: Math.min(Math.max(decimals, 0), 15),
|
|
33
|
+
useGrouping: Math.abs(n) >= 10000,
|
|
34
|
+
}).format(n);
|
|
35
|
+
exports.formatCount = formatCount;
|
|
36
|
+
/**
|
|
37
|
+
* What a person typed, as a number, or `null` when it is not one. Spaces are
|
|
38
|
+
* dropped. With both marks present the LAST is the decimal one (`1,234.5` and
|
|
39
|
+
* `1.234,5` both read 1234.5); a comma alone is a decimal mark unless it groups
|
|
40
|
+
* three digits (`12,345`).
|
|
41
|
+
*/
|
|
42
|
+
const parseCount = (text) => {
|
|
43
|
+
const t = text.trim().replace(/[\s_]/g, '');
|
|
44
|
+
if (!t)
|
|
45
|
+
return null;
|
|
46
|
+
const dot = t.lastIndexOf('.');
|
|
47
|
+
const comma = t.lastIndexOf(',');
|
|
48
|
+
const normal = dot >= 0 && comma >= 0
|
|
49
|
+
? dot > comma
|
|
50
|
+
? t.replace(/,/g, '')
|
|
51
|
+
: t.replace(/\./g, '').replace(',', '.')
|
|
52
|
+
: comma >= 0
|
|
53
|
+
? t.replace(/,(?=\d{3}(\D|$))/g, '').replace(',', '.')
|
|
54
|
+
: t;
|
|
55
|
+
if (!/^[-+]?(\d+\.?\d*|\.\d+)$/.test(normal))
|
|
56
|
+
return null;
|
|
57
|
+
const n = Number(normal);
|
|
58
|
+
return Number.isFinite(n) ? n : null;
|
|
59
|
+
};
|
|
60
|
+
exports.parseCount = parseCount;
|
|
61
|
+
/** A value held to the bounds and rounded to the step (from `min`) and the decimals. */
|
|
62
|
+
const settle = (n, { min, max, step, decimals }) => {
|
|
63
|
+
const stepped = step > 0 ? min + Math.round((n - min) / step) * step : n;
|
|
64
|
+
const bounded = Math.min(max, Math.max(min, stepped));
|
|
65
|
+
const f = 10 ** Math.min(Math.max(decimals, 0), 15);
|
|
66
|
+
return Math.round(bounded * f) / f;
|
|
67
|
+
};
|
|
68
|
+
exports.settle = settle;
|
|
69
|
+
function Stepper({ label, value, onChange, min = 0, max = Number.MAX_SAFE_INTEGER, step = 1, decimals = 0, editable, readOnly = false, }) {
|
|
18
70
|
const what = label.toLowerCase();
|
|
19
|
-
|
|
71
|
+
const compact = (0, density_1.useDensity)() === 'compact';
|
|
72
|
+
const typing = editable ?? compact;
|
|
73
|
+
const size = compact ? 'icon-xs' : 'icon';
|
|
74
|
+
const [draft, setDraft] = (0, react_1.useState)(() => (0, exports.formatCount)(value, decimals));
|
|
75
|
+
(0, react_1.useEffect)(() => setDraft((0, exports.formatCount)(value, decimals)), [value, decimals]);
|
|
76
|
+
const commit = () => {
|
|
77
|
+
const n = (0, exports.parseCount)(draft);
|
|
78
|
+
if (n == null)
|
|
79
|
+
return setDraft((0, exports.formatCount)(value, decimals));
|
|
80
|
+
const next = (0, exports.settle)(n, { min, max, step, decimals });
|
|
81
|
+
setDraft((0, exports.formatCount)(next, decimals));
|
|
82
|
+
if (next !== value)
|
|
83
|
+
onChange(next);
|
|
84
|
+
};
|
|
85
|
+
const move = (dir) => onChange((0, exports.settle)(value + dir * step, { min, max, step, decimals }));
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)(gui_1.XStack, { ...(0, slot_1.slot)('stepper'), role: "group", "aria-label": label, items: "center", gap: "$1", children: [(0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outline", size: size, type: "button", "aria-label": `Fewer ${what}`, disabled: value <= min, ...(readOnly ? { 'aria-disabled': true, opacity: 0.5, pointerEvents: 'none' } : null), onClick: () => move(-1), children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.Minus, { size: 16 }) }), typing ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(input_1.Input, { ...(0, slot_1.slot)('stepper-value'), "aria-label": label, size: compact ? 'sm' : 'default',
|
|
87
|
+
// 64 holds a short count; a longer one widens the field rather
|
|
88
|
+
// than clipping its own digits (about 8px a character at 13px).
|
|
89
|
+
width: Math.max(64, draft.length * 8 + 20), text: "center", fontWeight: "500", inputMode: decimals > 0 ? 'decimal' : 'numeric', value: draft, readOnly: readOnly, onChangeText: (t) => setDraft(t), onBlur: commit, onSubmitEditing: commit }), (0, jsx_runtime_1.jsx)(gui_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)(layout_1.SizableText, { role: "status", "aria-live": "polite", children: (0, exports.formatCount)(value, decimals) }) })] })) : ((0, jsx_runtime_1.jsx)(layout_1.SizableText, { role: "status", "aria-live": "polite", minW: 32, text: "center", children: decimals > 0 ? (0, exports.formatCount)(value, decimals) : value })), (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outline", size: size, type: "button", "aria-label": `More ${what}`, disabled: value >= max, ...(readOnly ? { 'aria-disabled': true, opacity: 0.5, pointerEvents: 'none' } : null), onClick: () => move(1), children: (0, jsx_runtime_1.jsx)(lucide_icons_2_1.Plus, { size: 16 }) })] }));
|
|
20
90
|
}
|
|
@@ -5,6 +5,30 @@ export interface StepperProps {
|
|
|
5
5
|
onChange: (n: number) => void;
|
|
6
6
|
min?: number;
|
|
7
7
|
max?: number;
|
|
8
|
+
/** How far one press moves the value. */
|
|
9
|
+
step?: number;
|
|
10
|
+
/** Fraction digits a typed value keeps (0: whole numbers). */
|
|
11
|
+
decimals?: number;
|
|
12
|
+
/** The count is a field. Default: on under a compact density, off elsewhere. */
|
|
13
|
+
editable?: boolean;
|
|
14
|
+
/** Shown and announced, never changed. */
|
|
15
|
+
readOnly?: boolean;
|
|
8
16
|
}
|
|
9
|
-
|
|
17
|
+
/** Up to `decimals` fraction digits, Latin digits, grouping from five digits up. */
|
|
18
|
+
export declare const formatCount: (n: number, decimals?: number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* What a person typed, as a number, or `null` when it is not one. Spaces are
|
|
21
|
+
* dropped. With both marks present the LAST is the decimal one (`1,234.5` and
|
|
22
|
+
* `1.234,5` both read 1234.5); a comma alone is a decimal mark unless it groups
|
|
23
|
+
* three digits (`12,345`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const parseCount: (text: string) => number | null;
|
|
26
|
+
/** A value held to the bounds and rounded to the step (from `min`) and the decimals. */
|
|
27
|
+
export declare const settle: (n: number, { min, max, step, decimals }: {
|
|
28
|
+
min: number;
|
|
29
|
+
max: number;
|
|
30
|
+
step: number;
|
|
31
|
+
decimals: number;
|
|
32
|
+
}) => number;
|
|
33
|
+
export declare function Stepper({ label, value, onChange, min, max, step, decimals, editable, readOnly, }: StepperProps): import("react").JSX.Element;
|
|
10
34
|
//# sourceMappingURL=stepper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/stepper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/stepper.tsx"],"names":[],"mappings":"AA0BA,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,oFAAoF;AACpF,eAAO,MAAM,WAAW,MAAO,MAAM,8BAIvB,CAAA;AAEd;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAAM,GAAG,IAgBlD,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,MAAM,MAAO,MAAM,gCAAgC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,WAK3H,CAAA;AAED,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,GAAO,EACP,GAA6B,EAC7B,IAAQ,EACR,QAAY,EACZ,QAAQ,EACR,QAAgB,GACjB,EAAE,YAAY,+BAyEd"}
|
|
@@ -1,18 +1,84 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
|
-
* Stepper — a
|
|
4
|
+
* Stepper — a number with a button either side.
|
|
5
5
|
*
|
|
6
6
|
* Both buttons are named for the thing counted (`label`), the count is a live
|
|
7
7
|
* region, and each button disables at its bound instead of silently clamping.
|
|
8
|
+
*
|
|
9
|
+
* `editable` makes the count a field a person can type into, twenty-ui's
|
|
10
|
+
* NumberStepper (MIT, NOTICE): a 64px centred value at the medium weight that
|
|
11
|
+
* commits on Enter or blur — read leniently (grouping stripped, either decimal
|
|
12
|
+
* mark), held to the bounds, rounded to `step` and to `decimals` — and shows
|
|
13
|
+
* Latin digits, grouped only from five digits up. It is on by default under
|
|
14
|
+
* `<Density value="compact">`, where the buttons are 24px; a regular surface
|
|
15
|
+
* keeps the plain count it always had. `readOnly` keeps the value and the
|
|
16
|
+
* layout but lets neither the buttons nor the field change it.
|
|
8
17
|
*/
|
|
9
|
-
import { XStack } from '@hanzo/gui';
|
|
18
|
+
import { VisuallyHidden, XStack } from '@hanzo/gui';
|
|
10
19
|
import { Minus, Plus } from '@hanzogui/lucide-icons-2';
|
|
20
|
+
import { useEffect, useState } from 'react';
|
|
11
21
|
import { Button } from './button.js';
|
|
22
|
+
import { Input } from './input.js';
|
|
12
23
|
import { SizableText } from './layout.js';
|
|
13
24
|
import { slot } from './slot.js';
|
|
14
|
-
|
|
25
|
+
import { useDensity } from './density.js';
|
|
26
|
+
/** Up to `decimals` fraction digits, Latin digits, grouping from five digits up. */
|
|
27
|
+
export const formatCount = (n, decimals = 0) => new Intl.NumberFormat('en-US', {
|
|
28
|
+
maximumFractionDigits: Math.min(Math.max(decimals, 0), 15),
|
|
29
|
+
useGrouping: Math.abs(n) >= 10000,
|
|
30
|
+
}).format(n);
|
|
31
|
+
/**
|
|
32
|
+
* What a person typed, as a number, or `null` when it is not one. Spaces are
|
|
33
|
+
* dropped. With both marks present the LAST is the decimal one (`1,234.5` and
|
|
34
|
+
* `1.234,5` both read 1234.5); a comma alone is a decimal mark unless it groups
|
|
35
|
+
* three digits (`12,345`).
|
|
36
|
+
*/
|
|
37
|
+
export const parseCount = (text) => {
|
|
38
|
+
const t = text.trim().replace(/[\s_]/g, '');
|
|
39
|
+
if (!t)
|
|
40
|
+
return null;
|
|
41
|
+
const dot = t.lastIndexOf('.');
|
|
42
|
+
const comma = t.lastIndexOf(',');
|
|
43
|
+
const normal = dot >= 0 && comma >= 0
|
|
44
|
+
? dot > comma
|
|
45
|
+
? t.replace(/,/g, '')
|
|
46
|
+
: t.replace(/\./g, '').replace(',', '.')
|
|
47
|
+
: comma >= 0
|
|
48
|
+
? t.replace(/,(?=\d{3}(\D|$))/g, '').replace(',', '.')
|
|
49
|
+
: t;
|
|
50
|
+
if (!/^[-+]?(\d+\.?\d*|\.\d+)$/.test(normal))
|
|
51
|
+
return null;
|
|
52
|
+
const n = Number(normal);
|
|
53
|
+
return Number.isFinite(n) ? n : null;
|
|
54
|
+
};
|
|
55
|
+
/** A value held to the bounds and rounded to the step (from `min`) and the decimals. */
|
|
56
|
+
export const settle = (n, { min, max, step, decimals }) => {
|
|
57
|
+
const stepped = step > 0 ? min + Math.round((n - min) / step) * step : n;
|
|
58
|
+
const bounded = Math.min(max, Math.max(min, stepped));
|
|
59
|
+
const f = 10 ** Math.min(Math.max(decimals, 0), 15);
|
|
60
|
+
return Math.round(bounded * f) / f;
|
|
61
|
+
};
|
|
62
|
+
export function Stepper({ label, value, onChange, min = 0, max = Number.MAX_SAFE_INTEGER, step = 1, decimals = 0, editable, readOnly = false, }) {
|
|
15
63
|
const what = label.toLowerCase();
|
|
16
|
-
|
|
64
|
+
const compact = useDensity() === 'compact';
|
|
65
|
+
const typing = editable ?? compact;
|
|
66
|
+
const size = compact ? 'icon-xs' : 'icon';
|
|
67
|
+
const [draft, setDraft] = useState(() => formatCount(value, decimals));
|
|
68
|
+
useEffect(() => setDraft(formatCount(value, decimals)), [value, decimals]);
|
|
69
|
+
const commit = () => {
|
|
70
|
+
const n = parseCount(draft);
|
|
71
|
+
if (n == null)
|
|
72
|
+
return setDraft(formatCount(value, decimals));
|
|
73
|
+
const next = settle(n, { min, max, step, decimals });
|
|
74
|
+
setDraft(formatCount(next, decimals));
|
|
75
|
+
if (next !== value)
|
|
76
|
+
onChange(next);
|
|
77
|
+
};
|
|
78
|
+
const move = (dir) => onChange(settle(value + dir * step, { min, max, step, decimals }));
|
|
79
|
+
return (_jsxs(XStack, { ...slot('stepper'), role: "group", "aria-label": label, items: "center", gap: "$1", children: [_jsx(Button, { variant: "outline", size: size, type: "button", "aria-label": `Fewer ${what}`, disabled: value <= min, ...(readOnly ? { 'aria-disabled': true, opacity: 0.5, pointerEvents: 'none' } : null), onClick: () => move(-1), children: _jsx(Minus, { size: 16 }) }), typing ? (_jsxs(_Fragment, { children: [_jsx(Input, { ...slot('stepper-value'), "aria-label": label, size: compact ? 'sm' : 'default',
|
|
80
|
+
// 64 holds a short count; a longer one widens the field rather
|
|
81
|
+
// than clipping its own digits (about 8px a character at 13px).
|
|
82
|
+
width: Math.max(64, draft.length * 8 + 20), text: "center", fontWeight: "500", inputMode: decimals > 0 ? 'decimal' : 'numeric', value: draft, readOnly: readOnly, onChangeText: (t) => setDraft(t), onBlur: commit, onSubmitEditing: commit }), _jsx(VisuallyHidden, { children: _jsx(SizableText, { role: "status", "aria-live": "polite", children: formatCount(value, decimals) }) })] })) : (_jsx(SizableText, { role: "status", "aria-live": "polite", minW: 32, text: "center", children: decimals > 0 ? formatCount(value, decimals) : value })), _jsx(Button, { variant: "outline", size: size, type: "button", "aria-label": `More ${what}`, disabled: value >= max, ...(readOnly ? { 'aria-disabled': true, opacity: 0.5, pointerEvents: 'none' } : null), onClick: () => move(1), children: _jsx(Plus, { size: 16 }) })] }));
|
|
17
83
|
}
|
|
18
84
|
//# sourceMappingURL=stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../../src/backends/gui/stepper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../../src/backends/gui/stepper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAmBtC,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,QAAQ,GAAG,CAAC,EAAE,EAAE,CACrD,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;IA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OAAO,EAAC,SAAS,EACjB,IAAI,EAAE,IAAI,EACV,IAAI,EAAC,QAAQ,gBACD,QAAQ,IAAI,EAAE,EAC1B,QAAQ,EAAE,KAAK,IAAI,GAAG,KAClB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EACtF,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,YAEtB,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,GAAI,GACX,IACF,CACV,CAAA;AACH,CAAC"}
|
|
@@ -50,28 +50,43 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
50
50
|
* this file was measured — both thumbs came out the same colour as the track
|
|
51
51
|
* behind them, off and on, exactly as 8.0.57 did. A flat name cannot say "and
|
|
52
52
|
* the opposite of that, one level down", so this file names rungs on purpose.
|
|
53
|
+
*
|
|
54
|
+
* THREE SIZES, and the record two are twenty-ui's (MIT, NOTICE): `md` a 32×20
|
|
55
|
+
* pill with a 16px thumb, `sm` 24×16 with a 12px thumb, each with no edge and
|
|
56
|
+
* the thumb 2px in. `default` stays the 36×20 pill with its hairline; under
|
|
57
|
+
* `<Density value="compact">` a switch that names no size is `md`. The tokens do
|
|
58
|
+
* not change with the size — the inverting thumb works on every one.
|
|
53
59
|
*/
|
|
54
60
|
const gui_1 = require("@hanzo/gui");
|
|
55
61
|
const slot_1 = require("./slot.cjs");
|
|
56
62
|
const gesture_1 = require("./gesture.cjs");
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
const density_1 = require("./density.cjs");
|
|
64
|
+
/** Each size's track, thumb and edge. The edge is what keeps the UA's button border off. */
|
|
65
|
+
const SIZE = {
|
|
66
|
+
default: { w: 36, h: 20, thumb: 16, edge: 1 },
|
|
67
|
+
md: { w: 32, h: 20, thumb: 16, edge: 0 },
|
|
68
|
+
sm: { w: 24, h: 16, thumb: 12, edge: 0 },
|
|
69
|
+
};
|
|
70
|
+
const Switch = ({ disabled, size, ...props }) => {
|
|
71
|
+
const compact = (0, density_1.useDensity)() === 'compact';
|
|
72
|
+
const box = SIZE[size ?? (compact ? 'md' : 'default')];
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(gui_1.Switch, { ...(0, slot_1.slot)('switch'), "data-size": size ?? (compact ? 'md' : 'default'), width: box.w, height: box.h, minHeight: box.h, padding: 2, flexShrink: 0, backgroundColor: "$color3",
|
|
74
|
+
// Without an explicit border the UA's 2px outset button border shows; the
|
|
75
|
+
// record sizes draw none and say so with a zero.
|
|
76
|
+
borderWidth: box.edge, borderColor: "$borderColor", activeStyle: { backgroundColor: '$color12', borderColor: '$color12' },
|
|
77
|
+
// Stated rather than left to a `disabledStyle` this backend uses nowhere
|
|
78
|
+
// else: a control that ignores its own disabled prop looks identical to a
|
|
79
|
+
// live one, and the page this was found on had a disabled switch sitting
|
|
80
|
+
// beside eight enabled ones with nothing to tell them apart.
|
|
81
|
+
disabled: disabled, opacity: disabled ? 0.5 : 1, cursor: disabled ? 'not-allowed' : 'pointer', ...(0, gesture_1.touch)(box.h, 44, 'y'), ...props, children: (0, jsx_runtime_1.jsx)(gui_1.Switch.Thumb, { ...(0, slot_1.slot)('switch-thumb'), width: box.thumb, height: box.thumb, backgroundColor: "$color3",
|
|
82
|
+
// `bg`, and it is the only one of the three spellings that is both typed
|
|
83
|
+
// and correct. The Thumb's activeStyle is typed as the SHORTHAND style set:
|
|
84
|
+
// `backgroundColor` paints but is not in that type; `background` is in it
|
|
85
|
+
// and compiles to a SEPARATE `_background-` class that races the base
|
|
86
|
+
// `_bg-` one on load order rather than replacing it; `bg` replaces it.
|
|
87
|
+
// Consumers build with ignoreBuildErrors, so the first would have shipped
|
|
88
|
+
// an error nobody sees and the second a colour that lands or does not
|
|
89
|
+
// depending on stylesheet order.
|
|
90
|
+
activeStyle: { bg: '$color12' } }) }));
|
|
91
|
+
};
|
|
77
92
|
exports.Switch = Switch;
|
|
@@ -45,10 +45,20 @@
|
|
|
45
45
|
* this file was measured — both thumbs came out the same colour as the track
|
|
46
46
|
* behind them, off and on, exactly as 8.0.57 did. A flat name cannot say "and
|
|
47
47
|
* the opposite of that, one level down", so this file names rungs on purpose.
|
|
48
|
+
*
|
|
49
|
+
* THREE SIZES, and the record two are twenty-ui's (MIT, NOTICE): `md` a 32×20
|
|
50
|
+
* pill with a 16px thumb, `sm` 24×16 with a 12px thumb, each with no edge and
|
|
51
|
+
* the thumb 2px in. `default` stays the 36×20 pill with its hairline; under
|
|
52
|
+
* `<Density value="compact">` a switch that names no size is `md`. The tokens do
|
|
53
|
+
* not change with the size — the inverting thumb works on every one.
|
|
48
54
|
*/
|
|
49
55
|
import { Switch as GuiSwitch } from '@hanzo/gui';
|
|
50
56
|
import type { ComponentProps } from 'react';
|
|
51
|
-
export type
|
|
52
|
-
|
|
57
|
+
export type SwitchSize = 'default' | 'md' | 'sm';
|
|
58
|
+
export type SwitchProps = Omit<ComponentProps<typeof GuiSwitch>, 'size'> & {
|
|
59
|
+
/** `default` 36×20; `md` 32×20 and `sm` 24×16, the record pair. Unset, the nearest `<Density>` decides. */
|
|
60
|
+
size?: SwitchSize;
|
|
61
|
+
};
|
|
62
|
+
declare const Switch: ({ disabled, size, ...props }: SwitchProps) => import("react").JSX.Element;
|
|
53
63
|
export { Switch };
|
|
54
64
|
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/switch.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/switch.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAK3C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAA;AAShD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,EAAE,MAAM,CAAC,GAAG;IACzE,2GAA2G;IAC3G,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,QAAA,MAAM,MAAM,iCAAkC,WAAW,gCA6CxD,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -47,29 +47,44 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
47
47
|
* this file was measured — both thumbs came out the same colour as the track
|
|
48
48
|
* behind them, off and on, exactly as 8.0.57 did. A flat name cannot say "and
|
|
49
49
|
* the opposite of that, one level down", so this file names rungs on purpose.
|
|
50
|
+
*
|
|
51
|
+
* THREE SIZES, and the record two are twenty-ui's (MIT, NOTICE): `md` a 32×20
|
|
52
|
+
* pill with a 16px thumb, `sm` 24×16 with a 12px thumb, each with no edge and
|
|
53
|
+
* the thumb 2px in. `default` stays the 36×20 pill with its hairline; under
|
|
54
|
+
* `<Density value="compact">` a switch that names no size is `md`. The tokens do
|
|
55
|
+
* not change with the size — the inverting thumb works on every one.
|
|
50
56
|
*/
|
|
51
57
|
import { Switch as GuiSwitch } from '@hanzo/gui';
|
|
52
58
|
import { slot } from './slot.js';
|
|
53
59
|
import { touch } from './gesture.js';
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
import { useDensity } from './density.js';
|
|
61
|
+
/** Each size's track, thumb and edge. The edge is what keeps the UA's button border off. */
|
|
62
|
+
const SIZE = {
|
|
63
|
+
default: { w: 36, h: 20, thumb: 16, edge: 1 },
|
|
64
|
+
md: { w: 32, h: 20, thumb: 16, edge: 0 },
|
|
65
|
+
sm: { w: 24, h: 16, thumb: 12, edge: 0 },
|
|
66
|
+
};
|
|
67
|
+
const Switch = ({ disabled, size, ...props }) => {
|
|
68
|
+
const compact = useDensity() === 'compact';
|
|
69
|
+
const box = SIZE[size ?? (compact ? 'md' : 'default')];
|
|
70
|
+
return (_jsx(GuiSwitch, { ...slot('switch'), "data-size": size ?? (compact ? 'md' : 'default'), width: box.w, height: box.h, minHeight: box.h, padding: 2, flexShrink: 0, backgroundColor: "$color3",
|
|
71
|
+
// Without an explicit border the UA's 2px outset button border shows; the
|
|
72
|
+
// record sizes draw none and say so with a zero.
|
|
73
|
+
borderWidth: box.edge, borderColor: "$borderColor", activeStyle: { backgroundColor: '$color12', borderColor: '$color12' },
|
|
74
|
+
// Stated rather than left to a `disabledStyle` this backend uses nowhere
|
|
75
|
+
// else: a control that ignores its own disabled prop looks identical to a
|
|
76
|
+
// live one, and the page this was found on had a disabled switch sitting
|
|
77
|
+
// beside eight enabled ones with nothing to tell them apart.
|
|
78
|
+
disabled: disabled, opacity: disabled ? 0.5 : 1, cursor: disabled ? 'not-allowed' : 'pointer', ...touch(box.h, 44, 'y'), ...props, children: _jsx(GuiSwitch.Thumb, { ...slot('switch-thumb'), width: box.thumb, height: box.thumb, backgroundColor: "$color3",
|
|
79
|
+
// `bg`, and it is the only one of the three spellings that is both typed
|
|
80
|
+
// and correct. The Thumb's activeStyle is typed as the SHORTHAND style set:
|
|
81
|
+
// `backgroundColor` paints but is not in that type; `background` is in it
|
|
82
|
+
// and compiles to a SEPARATE `_background-` class that races the base
|
|
83
|
+
// `_bg-` one on load order rather than replacing it; `bg` replaces it.
|
|
84
|
+
// Consumers build with ignoreBuildErrors, so the first would have shipped
|
|
85
|
+
// an error nobody sees and the second a colour that lands or does not
|
|
86
|
+
// depending on stylesheet order.
|
|
87
|
+
activeStyle: { bg: '$color12' } }) }));
|
|
88
|
+
};
|
|
74
89
|
export { Switch };
|
|
75
90
|
//# sourceMappingURL=switch.js.map
|