@zyncat/ui 0.20.0 → 0.22.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/dist/alert.js +11 -10
- package/dist/alert.js.map +1 -1
- package/dist/avatar.css +1 -1
- package/dist/badge.css +20 -11
- package/dist/badge.js +4 -1
- package/dist/{bloom-HV23M4AW.js → bloom-5MZXLNKG.js} +23 -5
- package/dist/bloom-5MZXLNKG.js.map +1 -0
- package/dist/button.css +24 -27
- package/dist/button.js +3 -3
- package/dist/checkbox.css +0 -1
- package/dist/chunk-2EPNCOLN.js +177 -0
- package/dist/chunk-2EPNCOLN.js.map +1 -0
- package/dist/{chunk-LNAV5E7S.js → chunk-2GYZ3HP3.js} +8 -4
- package/dist/chunk-2GYZ3HP3.js.map +1 -0
- package/dist/chunk-4M5FMCFJ.js +16 -0
- package/dist/chunk-4M5FMCFJ.js.map +1 -0
- package/dist/{chunk-ODRO3KS6.js → chunk-7GTACTZD.js} +8 -6
- package/dist/chunk-7GTACTZD.js.map +1 -0
- package/dist/{chunk-V6QAAOA5.js → chunk-AK2AXGEC.js} +38 -8
- package/dist/chunk-AK2AXGEC.js.map +1 -0
- package/dist/{chunk-5VC3TUZ2.js → chunk-BA4ALXQW.js} +2 -2
- package/dist/{chunk-5VC3TUZ2.js.map → chunk-BA4ALXQW.js.map} +1 -1
- package/dist/{chunk-N43NDSME.js → chunk-CF6ZFXRV.js} +19 -11
- package/dist/chunk-CF6ZFXRV.js.map +1 -0
- package/dist/{chunk-BRKGYLEQ.js → chunk-DOAR4PJ3.js} +9 -4
- package/dist/chunk-DOAR4PJ3.js.map +1 -0
- package/dist/{tide-DJZMDAFT.js → chunk-DVLKB3CZ.js} +15 -12
- package/dist/chunk-DVLKB3CZ.js.map +1 -0
- package/dist/chunk-EUAXI6OF.js +16 -0
- package/dist/chunk-EUAXI6OF.js.map +1 -0
- package/dist/{chunk-RLNCRDAL.js → chunk-G2TOUG2A.js} +7 -6
- package/dist/chunk-G2TOUG2A.js.map +1 -0
- package/dist/{chunk-VQFILXQN.js → chunk-HRP4UFWN.js} +70 -8
- package/dist/chunk-HRP4UFWN.js.map +1 -0
- package/dist/chunk-INK2GJTA.js +102 -0
- package/dist/chunk-INK2GJTA.js.map +1 -0
- package/dist/chunk-ITW5UCVU.js +24 -0
- package/dist/chunk-ITW5UCVU.js.map +1 -0
- package/dist/{chunk-F64Z42PJ.js → chunk-JJHEVW4M.js} +5 -6
- package/dist/chunk-JJHEVW4M.js.map +1 -0
- package/dist/{chunk-7NHY2CRA.js → chunk-JUC35N3C.js} +2 -2
- package/dist/chunk-JUC35N3C.js.map +1 -0
- package/dist/{chunk-PXQBJMPJ.js → chunk-LFJ4C7ZP.js} +7 -7
- package/dist/chunk-LFJ4C7ZP.js.map +1 -0
- package/dist/{chunk-TDHLZY6I.js → chunk-MCOIR3CK.js} +77 -18
- package/dist/chunk-MCOIR3CK.js.map +1 -0
- package/dist/chunk-NATK4DDW.js +108 -0
- package/dist/chunk-NATK4DDW.js.map +1 -0
- package/dist/{chunk-BIDVNLJO.js → chunk-O3RMSMBP.js} +8 -3
- package/dist/{chunk-BIDVNLJO.js.map → chunk-O3RMSMBP.js.map} +1 -1
- package/dist/{chunk-UKPX3RIP.js → chunk-ODO2TCTS.js} +27 -13
- package/dist/chunk-ODO2TCTS.js.map +1 -0
- package/dist/{chunk-M2KGLH2G.js → chunk-P3QSWNED.js} +11 -11
- package/dist/{chunk-M2KGLH2G.js.map → chunk-P3QSWNED.js.map} +1 -1
- package/dist/{chunk-QDAN43B6.js → chunk-Q4K337QY.js} +6 -6
- package/dist/chunk-Q4K337QY.js.map +1 -0
- package/dist/{chunk-2YGHPQ66.js → chunk-Q5N24VII.js} +2 -2
- package/dist/{chunk-2YGHPQ66.js.map → chunk-Q5N24VII.js.map} +1 -1
- package/dist/{chunk-VJXP256V.js → chunk-RLRZJAF7.js} +20 -8
- package/dist/chunk-RLRZJAF7.js.map +1 -0
- package/dist/{chunk-VZXML7EH.js → chunk-SY5UA6WS.js} +39 -10
- package/dist/chunk-SY5UA6WS.js.map +1 -0
- package/dist/{chunk-XKDR22VE.js → chunk-TFC5SCAB.js} +37 -14
- package/dist/chunk-TFC5SCAB.js.map +1 -0
- package/dist/{chunk-HBWRKEW4.js → chunk-VBALIMST.js} +3 -3
- package/dist/{chunk-HBWRKEW4.js.map → chunk-VBALIMST.js.map} +1 -1
- package/dist/{chunk-JINATP4N.js → chunk-VXQ7A6ZI.js} +8 -9
- package/dist/chunk-VXQ7A6ZI.js.map +1 -0
- package/dist/{chunk-TBLPZQSI.js → chunk-W7CHDHRV.js} +114 -42
- package/dist/chunk-W7CHDHRV.js.map +1 -0
- package/dist/{chunk-AIAPXRCI.js → chunk-WBWVOOKM.js} +201 -123
- package/dist/chunk-WBWVOOKM.js.map +1 -0
- package/dist/{chunk-6H3IJ752.js → chunk-WJEZWKEY.js} +20 -10
- package/dist/chunk-WJEZWKEY.js.map +1 -0
- package/dist/{chunk-TRPAKUIB.js → chunk-WMTOAYGP.js} +9 -9
- package/dist/{chunk-TRPAKUIB.js.map → chunk-WMTOAYGP.js.map} +1 -1
- package/dist/{chunk-C3D32LE3.js → chunk-WTHIUPVJ.js} +3 -3
- package/dist/{chunk-C3D32LE3.js.map → chunk-WTHIUPVJ.js.map} +1 -1
- package/dist/{chunk-F2TB3TT6.js → chunk-XCTMTOGT.js} +5 -5
- package/dist/{chunk-F2TB3TT6.js.map → chunk-XCTMTOGT.js.map} +1 -1
- package/dist/chunk-XMJ343KF.js +18 -0
- package/dist/chunk-XMJ343KF.js.map +1 -0
- package/dist/collapse.js +1 -1
- package/dist/combobox.css +7 -0
- package/dist/combobox.js +183 -0
- package/dist/combobox.js.map +1 -0
- package/dist/confetti.js +2 -2
- package/dist/crossfade-UHUQBUVG.js +133 -0
- package/dist/crossfade-UHUQBUVG.js.map +1 -0
- package/dist/date-field.js +27 -22
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +25 -41
- package/dist/date-range-field.js +463 -279
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +28 -23
- package/dist/datetime-field.js.map +1 -1
- package/dist/dialog-sheet.css +31 -0
- package/dist/dialog.css +3 -0
- package/dist/dialog.js +44 -42
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown.css +14 -11
- package/dist/dropdown.js +79 -37
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +22 -21
- package/dist/emoji-picker.js.map +1 -1
- package/dist/flow-field.js +2 -2
- package/dist/glide.js +3 -3
- package/dist/input.css +54 -34
- package/dist/instagram-feed.js +3 -3
- package/dist/lens.js +184 -160
- package/dist/lens.js.map +1 -1
- package/dist/mcp.js +29 -22
- package/dist/menu-surface.css +81 -7
- package/dist/modal.js +11 -10
- package/dist/modal.js.map +1 -1
- package/dist/morphing-text.js +2 -2
- package/dist/motion-devtools.css +6 -5
- package/dist/motion-devtools.js +6 -6
- package/dist/motion-tokens.js +1 -1
- package/dist/motion.js +10 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.js +63 -24
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +122 -75
- package/dist/number-field.js.map +1 -1
- package/dist/odometer.css +27 -16
- package/dist/odometer.js +225 -73
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +49 -12
- package/dist/otp-field.js.map +1 -1
- package/dist/overlay.css +1 -0
- package/dist/pagination.css +1 -1
- package/dist/pagination.js +6 -6
- package/dist/{paint-CJQCM6ZO.js → paint-NLTI6TEF.js} +5 -3
- package/dist/paint-NLTI6TEF.js.map +1 -0
- package/dist/popover.js +12 -11
- package/dist/radio-group.css +9 -6
- package/dist/radio-group.js +9 -8
- package/dist/radio-group.js.map +1 -1
- package/dist/range-sheet-days.css +35 -0
- package/dist/range-sheet.css +80 -0
- package/dist/range-summary.css +67 -0
- package/dist/scroll-area.css +150 -0
- package/dist/scroll-area.js +85 -0
- package/dist/scroll-area.js.map +1 -0
- package/dist/select.css +55 -7
- package/dist/select.js +29 -15
- package/dist/select.js.map +1 -1
- package/dist/sheet.js +12 -11
- package/dist/support-rail.css +2 -2
- package/dist/support-rail.js +17 -15
- package/dist/support-rail.js.map +1 -1
- package/dist/table-detail.css +27 -0
- package/dist/table.css +41 -14
- package/dist/table.js +341 -172
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +32 -13
- package/dist/tabs.js +69 -55
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +2 -4
- package/dist/tag.js +8 -7
- package/dist/tag.js.map +1 -1
- package/dist/text-field.js +4 -4
- package/dist/textarea.css +26 -41
- package/dist/textarea.js +43 -32
- package/dist/textarea.js.map +1 -1
- package/dist/theme-grid.js +8 -7
- package/dist/theme-switcher.js +19 -18
- package/dist/theme-switcher.js.map +1 -1
- package/dist/{theme-transition-VGLPZDJI.js → theme-transition-F3CBENM5.js} +29 -9
- package/dist/theme-transition-F3CBENM5.js.map +1 -0
- package/dist/theme-transition.css +49 -0
- package/dist/theme.js +5 -4
- package/dist/theme.js.map +1 -1
- package/dist/tide-AGGMQEJV.js +4 -0
- package/dist/tide-AGGMQEJV.js.map +1 -0
- package/dist/tiktok.js +3 -3
- package/dist/time-field.js +15 -8
- package/dist/time-field.js.map +1 -1
- package/dist/toast.css +1 -1
- package/dist/toast.js +11 -10
- package/dist/toast.js.map +1 -1
- package/dist/toggle-tag.js +2 -2
- package/dist/toggle-tag.js.map +1 -1
- package/dist/toggle.css +0 -1
- package/dist/toggle.js +4 -15
- package/dist/toggle.js.map +1 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +22 -17
- package/dist/tooltip.js.map +1 -1
- package/dist/trigger.css +0 -1
- package/dist/types/components/composites/combobox/Combobox.d.ts +51 -0
- package/dist/types/components/composites/combobox/caret.d.ts +8 -0
- package/dist/types/components/composites/combobox/use-combobox.d.ts +52 -0
- package/dist/types/components/composites/date-picker/DateField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/DateRangeField.d.ts +6 -3
- package/dist/types/components/composites/date-picker/DateTimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/date-utils.d.ts +2 -0
- package/dist/types/components/composites/date-picker/field-shell.d.ts +8 -1
- package/dist/types/components/composites/date-picker/month-swipe.d.ts +3 -0
- package/dist/types/components/composites/date-picker/range-day.d.ts +11 -0
- package/dist/types/components/composites/date-picker/range-month.d.ts +14 -0
- package/dist/types/components/composites/date-picker/range-panel.d.ts +4 -18
- package/dist/types/components/composites/date-picker/range-presets.d.ts +24 -0
- package/dist/types/components/composites/date-picker/range-sheet.d.ts +12 -0
- package/dist/types/components/composites/date-picker/range-summary.d.ts +9 -0
- package/dist/types/components/composites/date-picker/typed-key.d.ts +3 -0
- package/dist/types/components/composites/date-picker/use-month-view.d.ts +14 -0
- package/dist/types/components/composites/date-picker/use-range-panel.d.ts +44 -0
- package/dist/types/components/composites/dialog/Dialog.d.ts +3 -2
- package/dist/types/components/composites/dialog/surface.d.ts +17 -0
- package/dist/types/components/composites/dropdown/Dropdown.d.ts +21 -4
- package/dist/types/components/composites/dropdown/types.d.ts +9 -3
- package/dist/types/components/composites/scroll-area/ScrollArea.d.ts +29 -0
- package/dist/types/components/composites/select/MultiSelect.d.ts +31 -5
- package/dist/types/components/composites/select/Select.d.ts +20 -4
- package/dist/types/components/composites/select/core/index.d.ts +2 -1
- package/dist/types/components/composites/select/core/menu.d.ts +10 -5
- package/dist/types/components/composites/select/core/panel.d.ts +7 -4
- package/dist/types/components/composites/select/core/trigger.d.ts +7 -2
- package/dist/types/components/composites/select/core/types.d.ts +9 -0
- package/dist/types/components/composites/select/core/use-listbox.d.ts +8 -6
- package/dist/types/components/composites/select/presets.d.ts +17 -0
- package/dist/types/components/composites/table/Table.d.ts +3 -74
- package/dist/types/components/composites/table/body.d.ts +15 -0
- package/dist/types/components/composites/table/detail.d.ts +24 -0
- package/dist/types/components/composites/table/head.d.ts +16 -0
- package/dist/types/components/composites/table/types.d.ts +86 -0
- package/dist/types/components/composites/table/use-scroller.d.ts +12 -0
- package/dist/types/components/composites/table/use-table-state.d.ts +16 -0
- package/dist/types/components/composites/tabs/Tabs.d.ts +4 -69
- package/dist/types/components/composites/tabs/tab-panel.d.ts +26 -0
- package/dist/types/components/composites/tabs/types.d.ts +48 -0
- package/dist/types/components/composites/tabs/use-ink.d.ts +5 -0
- package/dist/types/components/composites/tooltip/Tooltip.d.ts +1 -1
- package/dist/types/components/compound/support-rail/SupportRail.d.ts +1 -1
- package/dist/types/components/expressive/lens/Lens.d.ts +1 -1
- package/dist/types/components/expressive/lens/input.d.ts +2 -0
- package/dist/types/components/expressive/lens/optics.d.ts +37 -0
- package/dist/types/components/expressive/lens/paint.d.ts +2 -0
- package/dist/types/components/expressive/lens/use-lens.d.ts +10 -0
- package/dist/types/components/expressive/odometer/Odometer.d.ts +1 -1
- package/dist/types/components/expressive/odometer/roll.d.ts +18 -0
- package/dist/types/components/expressive/odometer/spring.d.ts +11 -0
- package/dist/types/components/expressive/theme-transition/scene.d.ts +3 -0
- package/dist/types/components/internal/hooks/use-hold-repeat.d.ts +8 -0
- package/dist/types/components/internal/icon/Icon.d.ts +2 -0
- package/dist/types/components/internal/menu/highlight.d.ts +9 -1
- package/dist/types/components/internal/menu/menu-row.d.ts +4 -0
- package/dist/types/components/internal/menu/use-anchor-width.d.ts +2 -0
- package/dist/types/components/internal/overlay/layer.d.ts +5 -8
- package/dist/types/components/internal/overlay/track-anchor.d.ts +5 -0
- package/dist/types/components/internal/support/types.d.ts +1 -1
- package/dist/types/components/internal/utils/activation.d.ts +1 -0
- package/dist/types/components/primitives/badge/Badge.d.ts +17 -8
- package/dist/types/components/primitives/badge/morph-label.d.ts +3 -0
- package/dist/types/components/primitives/badge/use-glint-on-change.d.ts +2 -0
- package/dist/types/components/primitives/button/Button.d.ts +4 -8
- package/dist/types/components/primitives/button/button-style.d.ts +8 -4
- package/dist/types/components/primitives/collapse/Collapse.d.ts +3 -2
- package/dist/types/components/primitives/input/NumberField.d.ts +1 -1
- package/dist/types/components/primitives/input/OtpField.d.ts +7 -3
- package/dist/types/components/primitives/input/TextField.d.ts +1 -1
- package/dist/types/components/primitives/input/field-chrome.d.ts +2 -1
- package/dist/types/components/primitives/input/use-number-value.d.ts +16 -0
- package/dist/types/components/primitives/tag/Tag.d.ts +1 -1
- package/dist/types/components/primitives/tag/ToggleTag.d.ts +2 -2
- package/dist/types/components/primitives/textarea/Textarea.d.ts +5 -3
- package/dist/types/components/primitives/textarea/char-meter.d.ts +6 -0
- package/dist/types/components/primitives/toggle/switch-glyph.d.ts +6 -0
- package/dist/types/engine/flip.d.ts +3 -1
- package/dist/types/engine/index.d.ts +2 -2
- package/dist/types/engine/loop.d.ts +5 -2
- package/dist/types/motion/before-paint.d.ts +4 -0
- package/dist/types/motion/crossfade.d.ts +4 -0
- package/dist/types/motion/element.d.ts +16 -4
- package/dist/types/motion/flip.d.ts +12 -3
- package/dist/types/motion/holders.d.ts +4 -0
- package/dist/types/motion/motion.d.ts +7 -0
- package/dist/types/motion/use-motion.d.ts +3 -1
- package/dist/types/theme-scope.d.ts +5 -0
- package/dist/types/tokens/component-styles.generated.d.ts +0 -2
- package/dist/types/tokens/motion-defaults.generated.d.ts +2 -0
- package/dist/types/tokens/motion-scale.d.ts +18 -15
- package/dist/types/tokens/motion-tokens.d.ts +1 -1
- package/dist/types/tokens/theme-store.d.ts +4 -4
- package/dist/types/tokens/theme-tokens.generated.d.ts +77 -59
- package/dist/types/tokens/theme.d.ts +1 -1
- package/dist/typing-lines.js +2 -2
- package/dist/youtube.js +3 -3
- package/package.json +16 -11
- package/skills/zyncat-ui/SKILL.md +8 -8
- package/skills/zyncat-ui/references/components.md +6 -5
- package/skills/zyncat-ui/references/recipes.md +1 -1
- package/skills/zyncat-ui/references/theming.md +3 -3
- package/src/components/composites/combobox/Combobox.tsx +100 -0
- package/src/components/composites/combobox/Combobox.usage.md +32 -0
- package/src/components/composites/combobox/caret.ts +41 -0
- package/src/components/composites/combobox/combobox.css +7 -0
- package/src/components/composites/combobox/use-combobox.ts +112 -0
- package/src/components/composites/date-picker/DateField.tsx +4 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +15 -18
- package/src/components/composites/date-picker/DateTimeField.tsx +4 -0
- package/src/components/composites/date-picker/TimeField.tsx +12 -4
- package/src/components/composites/date-picker/date-picker.css +25 -41
- package/src/components/composites/date-picker/date-utils.ts +4 -0
- package/src/components/composites/date-picker/field-shell.tsx +45 -8
- package/src/components/composites/date-picker/month-swipe.ts +41 -0
- package/src/components/composites/date-picker/range-day.tsx +112 -0
- package/src/components/composites/date-picker/range-month.tsx +79 -0
- package/src/components/composites/date-picker/range-panel.tsx +30 -356
- package/src/components/composites/date-picker/range-presets.tsx +104 -0
- package/src/components/composites/date-picker/range-sheet-days.css +35 -0
- package/src/components/composites/date-picker/range-sheet.css +80 -0
- package/src/components/composites/date-picker/range-sheet.tsx +72 -0
- package/src/components/composites/date-picker/range-summary.css +67 -0
- package/src/components/composites/date-picker/range-summary.tsx +69 -0
- package/src/components/composites/date-picker/time-core.tsx +23 -17
- package/src/components/composites/date-picker/typed-key.ts +9 -0
- package/src/components/composites/date-picker/use-month-view.ts +32 -0
- package/src/components/composites/date-picker/use-range-panel.ts +145 -0
- package/src/components/composites/dialog/Dialog.tsx +28 -110
- package/src/components/composites/dialog/dialog-sheet.css +31 -0
- package/src/components/composites/dialog/dialog.css +3 -0
- package/src/components/composites/dialog/surface.tsx +93 -0
- package/src/components/composites/dropdown/Dropdown.tsx +49 -7
- package/src/components/composites/dropdown/Dropdown.usage.md +2 -0
- package/src/components/composites/dropdown/dropdown.css +14 -11
- package/src/components/composites/dropdown/menu-panel.tsx +49 -26
- package/src/components/composites/dropdown/types.ts +9 -3
- package/src/components/composites/pagination/pagination.css +1 -1
- package/src/components/composites/scroll-area/ScrollArea.tsx +114 -0
- package/src/components/composites/scroll-area/ScrollArea.usage.md +28 -0
- package/src/components/composites/scroll-area/scroll-area.css +150 -0
- package/src/components/composites/select/MultiSelect.tsx +71 -12
- package/src/components/composites/select/MultiSelect.usage.md +10 -0
- package/src/components/composites/select/Select.tsx +32 -2
- package/src/components/composites/select/Select.usage.md +13 -1
- package/src/components/composites/select/core/index.ts +2 -1
- package/src/components/composites/select/core/menu.tsx +34 -17
- package/src/components/composites/select/core/panel.tsx +62 -55
- package/src/components/composites/select/core/trigger.tsx +44 -13
- package/src/components/composites/select/core/types.ts +10 -0
- package/src/components/composites/select/core/use-listbox.ts +91 -38
- package/src/components/composites/select/presets.tsx +47 -0
- package/src/components/composites/select/select.css +55 -7
- package/src/components/composites/sheet/use-sheet-drag.ts +13 -0
- package/src/components/composites/table/Table.tsx +65 -305
- package/src/components/composites/table/Table.usage.md +19 -2
- package/src/components/composites/table/body.tsx +147 -0
- package/src/components/composites/table/detail.tsx +76 -0
- package/src/components/composites/table/head.tsx +90 -0
- package/src/components/composites/table/table-detail.css +27 -0
- package/src/components/composites/table/table.css +41 -14
- package/src/components/composites/table/types.ts +97 -0
- package/src/components/composites/table/use-scroller.ts +53 -0
- package/src/components/composites/table/use-table-state.ts +98 -0
- package/src/components/composites/tabs/Tabs.tsx +23 -188
- package/src/components/composites/tabs/tab-panel.tsx +63 -0
- package/src/components/composites/tabs/tabs.css +32 -13
- package/src/components/composites/tabs/types.ts +51 -0
- package/src/components/composites/tabs/use-ink.ts +87 -0
- package/src/components/composites/toast/toast.css +1 -1
- package/src/components/composites/tooltip/Tooltip.tsx +6 -5
- package/src/components/composites/tooltip/tooltip-host.tsx +10 -6
- package/src/components/composites/tooltip/tooltip.css +1 -1
- package/src/components/compound/support-rail/SupportRail.tsx +3 -2
- package/src/components/compound/support-rail/support-rail.css +2 -2
- package/src/components/dev/motion-devtools.css +6 -5
- package/src/components/expressive/lens/Lens.tsx +11 -368
- package/src/components/expressive/lens/input.ts +91 -0
- package/src/components/expressive/lens/optics.ts +119 -0
- package/src/components/expressive/lens/paint.ts +60 -0
- package/src/components/expressive/lens/use-lens.ts +121 -0
- package/src/components/expressive/odometer/Odometer.tsx +78 -99
- package/src/components/expressive/odometer/Odometer.usage.md +2 -2
- package/src/components/expressive/odometer/odometer.css +27 -16
- package/src/components/expressive/odometer/roll.ts +139 -0
- package/src/components/expressive/odometer/spring.ts +86 -0
- package/src/components/expressive/theme-transition/bloom.ts +22 -2
- package/src/components/expressive/theme-transition/paint.ts +2 -0
- package/src/components/expressive/theme-transition/scene.ts +3 -0
- package/src/components/expressive/theme-transition/theme-transition.css +49 -0
- package/src/components/expressive/theme-transition/theme-transition.ts +21 -1
- package/src/components/expressive/theme-transition/tide.ts +15 -10
- package/src/components/internal/hooks/use-hold-repeat.ts +43 -0
- package/src/components/internal/hooks/use-scroll-edges.ts +6 -1
- package/src/components/internal/icon/Icon.tsx +4 -0
- package/src/components/internal/menu/highlight.ts +20 -2
- package/src/components/internal/menu/menu-row.tsx +36 -8
- package/src/components/internal/menu/menu-surface.css +81 -7
- package/src/components/internal/menu/use-anchor-width.ts +26 -0
- package/src/components/internal/overlay/layer.tsx +11 -23
- package/src/components/internal/overlay/overlay.css +1 -0
- package/src/components/internal/overlay/position.ts +17 -6
- package/src/components/internal/overlay/track-anchor.ts +69 -0
- package/src/components/internal/overlay/trigger.css +0 -1
- package/src/components/internal/support/types.ts +1 -1
- package/src/components/internal/utils/activation.ts +7 -2
- package/src/components/primitives/avatar/avatar.css +1 -1
- package/src/components/primitives/badge/Badge.tsx +38 -15
- package/src/components/primitives/badge/Badge.usage.md +12 -5
- package/src/components/primitives/badge/badge.css +20 -11
- package/src/components/primitives/badge/morph-label.tsx +71 -0
- package/src/components/primitives/badge/use-glint-on-change.ts +16 -0
- package/src/components/primitives/button/Button.tsx +5 -8
- package/src/components/primitives/button/Button.usage.md +5 -4
- package/src/components/primitives/button/button-style.ts +11 -5
- package/src/components/primitives/button/button.css +24 -27
- package/src/components/primitives/checkbox/checkbox.css +0 -1
- package/src/components/primitives/collapse/Collapse.tsx +3 -2
- package/src/components/primitives/input/NumberField.tsx +38 -46
- package/src/components/primitives/input/OtpField.tsx +52 -11
- package/src/components/primitives/input/OtpField.usage.md +2 -1
- package/src/components/primitives/input/TextField.tsx +5 -3
- package/src/components/primitives/input/field-chrome.tsx +3 -2
- package/src/components/primitives/input/input.css +54 -34
- package/src/components/primitives/input/use-number-value.ts +38 -0
- package/src/components/primitives/radio-group/radio-group.css +9 -6
- package/src/components/primitives/tag/Tag.tsx +1 -1
- package/src/components/primitives/tag/ToggleTag.tsx +2 -2
- package/src/components/primitives/tag/tag.css +2 -4
- package/src/components/primitives/textarea/Textarea.tsx +44 -30
- package/src/components/primitives/textarea/char-meter.tsx +19 -0
- package/src/components/primitives/textarea/textarea.css +26 -41
- package/src/components/primitives/toggle/Toggle.tsx +3 -12
- package/src/components/primitives/toggle/switch-glyph.tsx +25 -0
- package/src/components/primitives/toggle/toggle.css +0 -1
- package/src/engine/animate.ts +5 -3
- package/src/engine/flip.ts +28 -4
- package/src/engine/index.ts +2 -2
- package/src/engine/loop.ts +17 -6
- package/src/mcp/server.ts +30 -20
- package/src/motion/before-paint.ts +15 -0
- package/src/motion/crossfade.ts +143 -0
- package/src/motion/element.tsx +29 -8
- package/src/motion/flip.ts +102 -31
- package/src/motion/glide.tsx +5 -0
- package/src/motion/holders.ts +10 -0
- package/src/motion/motion.ts +7 -0
- package/src/motion/motion.usage.md +34 -0
- package/src/motion/presence.tsx +22 -9
- package/src/motion/use-motion.ts +45 -6
- package/src/theme-scope.ts +19 -0
- package/src/tokens/base.css +7 -5
- package/src/tokens/color.css +17 -15
- package/src/tokens/component-styles.generated.ts +0 -2
- package/src/tokens/dark.css +8 -5
- package/src/tokens/decisions.css +5 -3
- package/src/tokens/motion-defaults.generated.ts +15 -8
- package/src/tokens/motion-scale.ts +18 -15
- package/src/tokens/motion-tokens.ts +4 -4
- package/src/tokens/motion.css +19 -11
- package/src/tokens/reset.css +1 -0
- package/src/tokens/semantic.css +20 -14
- package/src/tokens/spacing.css +5 -3
- package/src/tokens/theme-store.ts +4 -4
- package/src/tokens/theme-sync.tsx +4 -2
- package/src/tokens/theme-tokens.generated.ts +78 -59
- package/src/tokens/theme.tsx +1 -1
- package/tailwind.css +6 -0
- package/dist/bloom-HV23M4AW.js.map +0 -1
- package/dist/chunk-2DNKZ57E.js +0 -72
- package/dist/chunk-2DNKZ57E.js.map +0 -1
- package/dist/chunk-6H3IJ752.js.map +0 -1
- package/dist/chunk-7NHY2CRA.js.map +0 -1
- package/dist/chunk-AIAPXRCI.js.map +0 -1
- package/dist/chunk-BRKGYLEQ.js.map +0 -1
- package/dist/chunk-F64Z42PJ.js.map +0 -1
- package/dist/chunk-JINATP4N.js.map +0 -1
- package/dist/chunk-KSAJ6DED.js +0 -16
- package/dist/chunk-KSAJ6DED.js.map +0 -1
- package/dist/chunk-LNAV5E7S.js.map +0 -1
- package/dist/chunk-N43NDSME.js.map +0 -1
- package/dist/chunk-ODRO3KS6.js.map +0 -1
- package/dist/chunk-PXQBJMPJ.js.map +0 -1
- package/dist/chunk-QDAN43B6.js.map +0 -1
- package/dist/chunk-RJENXXTI.js +0 -93
- package/dist/chunk-RJENXXTI.js.map +0 -1
- package/dist/chunk-RLNCRDAL.js.map +0 -1
- package/dist/chunk-RW2A4M2Q.js +0 -57
- package/dist/chunk-RW2A4M2Q.js.map +0 -1
- package/dist/chunk-TBLPZQSI.js.map +0 -1
- package/dist/chunk-TDHLZY6I.js.map +0 -1
- package/dist/chunk-UKPX3RIP.js.map +0 -1
- package/dist/chunk-V6QAAOA5.js.map +0 -1
- package/dist/chunk-VDOBLABP.js +0 -38
- package/dist/chunk-VDOBLABP.js.map +0 -1
- package/dist/chunk-VJXP256V.js.map +0 -1
- package/dist/chunk-VQFILXQN.js.map +0 -1
- package/dist/chunk-VZXML7EH.js.map +0 -1
- package/dist/chunk-XKDR22VE.js.map +0 -1
- package/dist/count-badge.js +0 -13
- package/dist/count-badge.js.map +0 -1
- package/dist/paint-CJQCM6ZO.js.map +0 -1
- package/dist/status-badge.js +0 -72
- package/dist/status-badge.js.map +0 -1
- package/dist/theme-transition-VGLPZDJI.js.map +0 -1
- package/dist/tide-DJZMDAFT.js.map +0 -1
- package/dist/types/components/primitives/badge/CountBadge.d.ts +0 -8
- package/dist/types/components/primitives/badge/StatusBadge.d.ts +0 -15
- package/src/components/primitives/badge/CountBadge.tsx +0 -20
- package/src/components/primitives/badge/CountBadge.usage.md +0 -13
- package/src/components/primitives/badge/StatusBadge.tsx +0 -113
- package/src/components/primitives/badge/StatusBadge.usage.md +0 -14
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import '../select/select.css';
|
|
4
|
+
import './combobox.css';
|
|
5
|
+
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
|
|
8
|
+
import type { DisableableAnimation } from '../../../motion/timing';
|
|
9
|
+
import type { MenuSize, MenuWeight, MenuWidth } from '../../internal/menu/highlight';
|
|
10
|
+
import type { ActivateOn } from '../../internal/utils/activation';
|
|
11
|
+
import { ListboxPanel, type SelectGroup, type SelectMenuHtmlProps, type SelectOption } from '../select/core';
|
|
12
|
+
import { optionText } from '../select/core/types';
|
|
13
|
+
import { useCombobox } from './use-combobox';
|
|
14
|
+
|
|
15
|
+
export type { SelectOption, SelectGroup } from '../select/core';
|
|
16
|
+
|
|
17
|
+
export interface ComboboxProps {
|
|
18
|
+
/** The field the list completes: one `input` or `textarea`, or a component rendering one, such as `TextField`
|
|
19
|
+
* or `Textarea`. Focus stays in it - the arrow keys walk the list and Enter picks. */
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/** The suggestions - a flat `SelectOption[]`, or `SelectGroup[]` for labeled sections - filtered by the query. */
|
|
22
|
+
options: SelectOption[] | SelectGroup[];
|
|
23
|
+
/** Characters that start a query mid-text, such as `@` for mentions. The list opens when they are typed at the
|
|
24
|
+
* start of a word, filters on the text up to the caret, and a pick replaces that text. Without a trigger the
|
|
25
|
+
* whole value is the query. */
|
|
26
|
+
trigger?: string;
|
|
27
|
+
/** The text a pick writes over the query, trigger included. The edit goes through the browser, so undo
|
|
28
|
+
* restores the query and the field's own `onChange` fires. @default the trigger, the option's text and a
|
|
29
|
+
* space; the option's text alone without a `trigger` */
|
|
30
|
+
insert?: (option: SelectOption) => string;
|
|
31
|
+
/** Fires after a pick has written its text into the field - gets the option's `value` and the full option. */
|
|
32
|
+
onSelect?: (value: string, option: SelectOption) => void;
|
|
33
|
+
/** Where the list hangs: `caret` from the start of the query, `field` under the whole field.
|
|
34
|
+
* @default 'caret' with a `trigger`, else 'field' */
|
|
35
|
+
anchor?: 'caret' | 'field';
|
|
36
|
+
/** List width. `trigger` is never narrower than the field, `auto` fits the options, and `sm` | `md` | `lg` are
|
|
37
|
+
* fixed steps with long labels ellipsizing. @default 'trigger' under the field, 'auto' at the caret */
|
|
38
|
+
width?: MenuWidth;
|
|
39
|
+
/** List density - row type and padding. A row carrying a description sits one step taller. @default 'md' */
|
|
40
|
+
size?: MenuSize;
|
|
41
|
+
/** Weight of every option label. @default 'medium' */
|
|
42
|
+
weight?: MenuWeight;
|
|
43
|
+
/** Hue of the highlight that travels between options: the neutral wash, or the accent wash with accent ink on
|
|
44
|
+
* the active option. @default 'neutral' */
|
|
45
|
+
highlight?: 'neutral' | 'accent';
|
|
46
|
+
/** Short accent bar on the leading edge of the highlight, marking the active option. @default false */
|
|
47
|
+
rail?: boolean;
|
|
48
|
+
/** Base id for the list and option ids; auto-generated if omitted. */
|
|
49
|
+
id?: string;
|
|
50
|
+
/** Accessible name for the list. */
|
|
51
|
+
ariaLabel?: string;
|
|
52
|
+
/** Standard attributes (className, style, data-*, ...) forwarded to the list panel, which portals to <body>. */
|
|
53
|
+
menuProps?: SelectMenuHtmlProps;
|
|
54
|
+
/** Whether an option picks on `pointerdown` (snappier) or waits for `click`. @default 'pointerdown' */
|
|
55
|
+
activateOn?: ActivateOn;
|
|
56
|
+
/** List open/close timing - motion tokens only, or `null` to disable. @default duration 'base' + ease 'entrance'/'exit' */
|
|
57
|
+
animation?: DisableableAnimation;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function Combobox({
|
|
61
|
+
children,
|
|
62
|
+
options = [],
|
|
63
|
+
trigger,
|
|
64
|
+
insert = (option) => (trigger ? trigger + optionText(option) + ' ' : optionText(option)),
|
|
65
|
+
onSelect,
|
|
66
|
+
anchor = trigger ? 'caret' : 'field',
|
|
67
|
+
width = anchor === 'field' ? 'trigger' : 'auto',
|
|
68
|
+
size = 'md',
|
|
69
|
+
weight = 'medium',
|
|
70
|
+
highlight = 'neutral',
|
|
71
|
+
rail = false,
|
|
72
|
+
id,
|
|
73
|
+
ariaLabel,
|
|
74
|
+
menuProps,
|
|
75
|
+
activateOn = 'pointerdown',
|
|
76
|
+
animation,
|
|
77
|
+
}: ComboboxProps) {
|
|
78
|
+
const { lb, caretAnchor, wrapProps } = useCombobox({ options, trigger, insert, onSelect, id });
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div {...wrapProps} className="zc-combobox">
|
|
82
|
+
{children}
|
|
83
|
+
<ListboxPanel
|
|
84
|
+
lb={lb}
|
|
85
|
+
anchor={anchor === 'caret' ? caretAnchor : null}
|
|
86
|
+
loading={false}
|
|
87
|
+
searchable={false}
|
|
88
|
+
ariaLabel={ariaLabel}
|
|
89
|
+
highlight={highlight}
|
|
90
|
+
rail={rail}
|
|
91
|
+
size={size}
|
|
92
|
+
weight={weight}
|
|
93
|
+
width={width}
|
|
94
|
+
activateOn={activateOn}
|
|
95
|
+
animation={animation}
|
|
96
|
+
menuProps={menuProps}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Combobox - @zyncat/ui/combobox
|
|
2
|
+
|
|
3
|
+
Group: forms
|
|
4
|
+
Docs: https://ui.zyncat.app/combobox
|
|
5
|
+
|
|
6
|
+
Autocomplete for a text field you own - @mentions, slash commands, or the whole value. A pick only writes text: unlike Select, the value is whatever the field holds.
|
|
7
|
+
|
|
8
|
+
NOT a Select, which holds an option picked behind its own trigger button - searchable or not, the value is an
|
|
9
|
+
option. NOT a Dropdown, which runs commands. Wrap your own TextField, Textarea or plain input/textarea: it renders
|
|
10
|
+
unchanged in a display: contents wrapper, no ref or prop wiring. options takes Select's SelectOption[] or
|
|
11
|
+
SelectGroup[], both re-exported here. trigger (such as @ or /) completes one word mid-text: the list opens when the
|
|
12
|
+
trigger starts a word and hangs at the start of that word. Without one it completes the whole value from under
|
|
13
|
+
the field, opening as you type or on ArrowDown. The list never takes focus: while it is open, the arrows, Enter,
|
|
14
|
+
Tab and Escape are its keys and never reach the field's own onKeyDown, so an Enter-to-send handler stays quiet;
|
|
15
|
+
Shift+Enter and other modified keys pass. Enter or Tab picks the highlighted option, the first match until the
|
|
16
|
+
arrows move it; with a trigger Tab keeps focus in the field, without one it moves on as in a form. With no match,
|
|
17
|
+
Enter and Tab pass through. Escape closes the list, and with a trigger it stays shut for that word until a new
|
|
18
|
+
trigger is typed; moving the caret out of the word or blurring the field closes it too. A pick writes
|
|
19
|
+
insert(option) over the trigger and query through the browser's edit stack, so Ctrl+Z restores what was typed
|
|
20
|
+
and the field's onChange fires; onSelect(value, option) runs after. The filter matches the option's text and
|
|
21
|
+
description, and the default insert writes that text - searchText, else a string label, else value - so give a
|
|
22
|
+
node label a searchText. anchor caret|field picks where the list hangs (caret with a trigger, field without) and
|
|
23
|
+
width follows it; size, weight, highlight neutral|accent and rail style the list as on Select.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<Combobox trigger="@" options={TEAMMATES} onSelect={addMention} ariaLabel="Teammates">
|
|
27
|
+
<input value={message} placeholder="Message #launch" onChange={(e) => setMessage(e.target.value)} />
|
|
28
|
+
</Combobox>
|
|
29
|
+
<Combobox options={CITIES} ariaLabel="Cities">
|
|
30
|
+
<input value={city} aria-label="City" onChange={(e) => setCity(e.target.value)} />
|
|
31
|
+
</Combobox>
|
|
32
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type TextControl = HTMLInputElement | HTMLTextAreaElement;
|
|
2
|
+
|
|
3
|
+
export interface QueryRange {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function queryAt(field: TextControl, trigger: string | undefined): QueryRange | null {
|
|
10
|
+
const { value, selectionStart: caret, selectionEnd } = field;
|
|
11
|
+
if (!trigger) return { start: 0, end: value.length, text: value };
|
|
12
|
+
if (caret !== selectionEnd || caret < trigger.length) return null;
|
|
13
|
+
const start = value.lastIndexOf(trigger, caret - trigger.length);
|
|
14
|
+
const text = value.slice(start + trigger.length, caret);
|
|
15
|
+
if (start < 0 || /\s/.test(text) || /\S/.test(value[start - 1] ?? ' ')) return null;
|
|
16
|
+
return { start, end: caret, text };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function caretRect(field: TextControl, index: number): DOMRect {
|
|
20
|
+
const box = field.getBoundingClientRect();
|
|
21
|
+
const style = getComputedStyle(field);
|
|
22
|
+
const multiline = field instanceof HTMLTextAreaElement;
|
|
23
|
+
const mirror = document.createElement('div');
|
|
24
|
+
for (const name of style) mirror.style.setProperty(name, style.getPropertyValue(name));
|
|
25
|
+
Object.assign(mirror.style, {
|
|
26
|
+
position: 'fixed',
|
|
27
|
+
top: '0',
|
|
28
|
+
left: '0',
|
|
29
|
+
visibility: 'hidden',
|
|
30
|
+
whiteSpace: multiline ? 'pre-wrap' : 'pre',
|
|
31
|
+
});
|
|
32
|
+
const marker = document.createElement('span');
|
|
33
|
+
marker.textContent = field.value[index] || '';
|
|
34
|
+
mirror.append(field.value.slice(0, index), marker, field.value.slice(index + 1));
|
|
35
|
+
document.body.append(mirror);
|
|
36
|
+
const line = parseFloat(style.lineHeight) || marker.offsetHeight;
|
|
37
|
+
const left = box.left + field.clientLeft + marker.offsetLeft - field.scrollLeft;
|
|
38
|
+
const top = box.top + field.clientTop + marker.offsetTop - field.scrollTop - (line - marker.offsetHeight) / 2;
|
|
39
|
+
mirror.remove();
|
|
40
|
+
return multiline ? new DOMRect(left, top, 0, line) : new DOMRect(left, box.top, 0, box.height);
|
|
41
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
type FocusEvent,
|
|
8
|
+
type FormEvent,
|
|
9
|
+
type KeyboardEvent,
|
|
10
|
+
type MouseEvent,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
import { useListbox, type SelectGroup, type SelectOption } from '../select/core';
|
|
14
|
+
import { caretRect, queryAt, type QueryRange, type TextControl } from './caret';
|
|
15
|
+
|
|
16
|
+
const LIST_KEYS = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape', 'Tab'];
|
|
17
|
+
|
|
18
|
+
interface UseComboboxArgs {
|
|
19
|
+
options: SelectOption[] | SelectGroup[];
|
|
20
|
+
trigger: string | undefined;
|
|
21
|
+
insert: (option: SelectOption) => string;
|
|
22
|
+
onSelect: ((value: string, option: SelectOption) => void) | undefined;
|
|
23
|
+
id: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function useCombobox({ options, trigger, insert, onSelect, id }: UseComboboxArgs) {
|
|
27
|
+
const wrapRef = useRef<HTMLDivElement>(null);
|
|
28
|
+
const fieldRef = useRef<TextControl>(null);
|
|
29
|
+
const range = useRef<QueryRange>(null);
|
|
30
|
+
const dismissed = useRef(-1);
|
|
31
|
+
|
|
32
|
+
const lb = useListbox({
|
|
33
|
+
options,
|
|
34
|
+
disabled: false,
|
|
35
|
+
loading: false,
|
|
36
|
+
searchable: true,
|
|
37
|
+
id,
|
|
38
|
+
idPrefix: 'combobox-',
|
|
39
|
+
isSelected: () => false,
|
|
40
|
+
onCommit: (option) => {
|
|
41
|
+
const field = fieldRef.current;
|
|
42
|
+
if (trigger) field.setSelectionRange(range.current.start, range.current.end);
|
|
43
|
+
else field.select();
|
|
44
|
+
document.execCommand('insertText', false, insert(option));
|
|
45
|
+
onSelect?.(option.value, option);
|
|
46
|
+
},
|
|
47
|
+
closeOnCommit: true,
|
|
48
|
+
autoHighlight: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const caretAnchor = useMemo(
|
|
52
|
+
() => ({ getBoundingClientRect: () => caretRect(fieldRef.current, range.current.start) }),
|
|
53
|
+
[lb.query],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
useLayoutEffect(() => {
|
|
57
|
+
const field = wrapRef.current.querySelector<TextControl>('input, textarea');
|
|
58
|
+
fieldRef.current = field;
|
|
59
|
+
lb.triggerRef.current = field;
|
|
60
|
+
field.setAttribute('aria-autocomplete', 'list');
|
|
61
|
+
if (!trigger) field.setAttribute('role', 'combobox');
|
|
62
|
+
if (!trigger) field.setAttribute('aria-expanded', String(lb.open));
|
|
63
|
+
if (lb.open) field.setAttribute('aria-controls', lb.listId);
|
|
64
|
+
else field.removeAttribute('aria-controls');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const show = (query: QueryRange) => {
|
|
68
|
+
range.current = query;
|
|
69
|
+
lb.setQuery(query.text);
|
|
70
|
+
lb.show();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onInput = (e: FormEvent) => {
|
|
74
|
+
if (e.target !== fieldRef.current) return;
|
|
75
|
+
const query = queryAt(fieldRef.current, trigger);
|
|
76
|
+
if (!query) dismissed.current = -1;
|
|
77
|
+
if (!query || !(trigger || query.text) || query.start === dismissed.current) lb.requestClose();
|
|
78
|
+
else show(query);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const onSelectionChange = (e: FormEvent) => {
|
|
82
|
+
if (!trigger || !lb.open || e.target !== fieldRef.current) return;
|
|
83
|
+
if (queryAt(fieldRef.current, trigger)?.start !== range.current.start) lb.requestClose();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const onKeyDownCapture = (e: KeyboardEvent) => {
|
|
87
|
+
if (e.target !== fieldRef.current || e.nativeEvent.isComposing) return;
|
|
88
|
+
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
89
|
+
if (!lb.open && !trigger && e.key === 'ArrowDown') {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
return show(queryAt(fieldRef.current, trigger));
|
|
92
|
+
}
|
|
93
|
+
if (!lb.open || !LIST_KEYS.includes(e.key)) return;
|
|
94
|
+
if (!lb.navItems.length && (e.key === 'Enter' || e.key === 'Tab')) return lb.requestClose();
|
|
95
|
+
if (e.key === 'Escape' && trigger) dismissed.current = range.current.start;
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
if (e.key !== 'Tab') return lb.onMenuKeyDown(e);
|
|
98
|
+
if (trigger) e.preventDefault();
|
|
99
|
+
lb.commitActive();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const onBlur = (e: FocusEvent) => {
|
|
103
|
+
if (e.target === fieldRef.current) lb.requestClose();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
107
|
+
if (e.target instanceof Node && !wrapRef.current.contains(e.target)) e.preventDefault();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const wrapProps = { ref: wrapRef, onInput, onSelect: onSelectionChange, onKeyDownCapture, onBlur, onMouseDown };
|
|
111
|
+
return { lb, caretAnchor, wrapProps };
|
|
112
|
+
}
|
|
@@ -32,6 +32,7 @@ export function DateField({
|
|
|
32
32
|
defaultValue = null,
|
|
33
33
|
onChange,
|
|
34
34
|
label,
|
|
35
|
+
ariaLabel,
|
|
35
36
|
placeholder = 'Pick a date',
|
|
36
37
|
timezone,
|
|
37
38
|
min,
|
|
@@ -40,6 +41,7 @@ export function DateField({
|
|
|
40
41
|
invalid = false,
|
|
41
42
|
message,
|
|
42
43
|
disabled = false,
|
|
44
|
+
size = 'md',
|
|
43
45
|
className = '',
|
|
44
46
|
htmlProps,
|
|
45
47
|
activateOn = 'pointerdown',
|
|
@@ -53,10 +55,12 @@ export function DateField({
|
|
|
53
55
|
<FieldShell
|
|
54
56
|
variant="zc-dtf"
|
|
55
57
|
label={label}
|
|
58
|
+
ariaLabel={ariaLabel}
|
|
56
59
|
required={required}
|
|
57
60
|
invalid={invalid}
|
|
58
61
|
message={message}
|
|
59
62
|
icon="calendar"
|
|
63
|
+
size={size}
|
|
60
64
|
className={className}
|
|
61
65
|
htmlProps={htmlProps}
|
|
62
66
|
>
|
|
@@ -9,7 +9,9 @@ import { useMediaQuery } from '../../internal/hooks/use-media-query';
|
|
|
9
9
|
import { Popover } from '../popover/Popover';
|
|
10
10
|
import { Sheet } from '../sheet/Sheet';
|
|
11
11
|
import { FieldShell, FieldTrigger, type DateFieldBaseProps } from './field-shell';
|
|
12
|
-
import { DrpPanel
|
|
12
|
+
import { DrpPanel } from './range-panel';
|
|
13
|
+
import { drpRangeText, type DateRange } from './range-presets';
|
|
14
|
+
import { DrpSheet } from './range-sheet';
|
|
13
15
|
|
|
14
16
|
export type { DateRange };
|
|
15
17
|
|
|
@@ -20,7 +22,8 @@ export interface DateRangeFieldProps extends DateFieldBaseProps {
|
|
|
20
22
|
value?: DateRange | null;
|
|
21
23
|
/** Uncontrolled initial range. Use instead of `value`. @default null */
|
|
22
24
|
defaultValue?: DateRange | null;
|
|
23
|
-
/** Fires
|
|
25
|
+
/** Fires on Done with the range the panel shows, when it differs from the current one.
|
|
26
|
+
* Closing the panel any other way discards the pick. */
|
|
24
27
|
onChange?: (value: DateRange) => void;
|
|
25
28
|
/** Trigger text shown when no range is picked. @default 'Pick a date range' */
|
|
26
29
|
placeholder?: string;
|
|
@@ -30,6 +33,8 @@ export interface DateRangeFieldProps extends DateFieldBaseProps {
|
|
|
30
33
|
min?: string;
|
|
31
34
|
/** Latest pickable date, 'YYYY-MM-DD', inclusive. */
|
|
32
35
|
max?: string;
|
|
36
|
+
/** Longest pickable range in days, inclusive. After the first day pick, days further away disable, and so do quick picks that run longer. */
|
|
37
|
+
maxDays?: number;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
export function DateRangeField({
|
|
@@ -37,14 +42,17 @@ export function DateRangeField({
|
|
|
37
42
|
defaultValue = null,
|
|
38
43
|
onChange,
|
|
39
44
|
label,
|
|
45
|
+
ariaLabel,
|
|
40
46
|
placeholder = 'Pick a date range',
|
|
41
47
|
timezone,
|
|
42
48
|
min,
|
|
43
49
|
max,
|
|
50
|
+
maxDays,
|
|
44
51
|
required = false,
|
|
45
52
|
invalid = false,
|
|
46
53
|
message,
|
|
47
54
|
disabled = false,
|
|
55
|
+
size = 'md',
|
|
48
56
|
className = '',
|
|
49
57
|
htmlProps,
|
|
50
58
|
activateOn = 'pointerdown',
|
|
@@ -57,29 +65,18 @@ export function DateRangeField({
|
|
|
57
65
|
|
|
58
66
|
const display = val && val.start && val.end ? drpRangeText(val.start, val.end) : null;
|
|
59
67
|
const trigger = <FieldTrigger display={display} placeholder={placeholder} disabled={disabled} />;
|
|
60
|
-
const
|
|
61
|
-
<DrpPanel
|
|
62
|
-
value={val}
|
|
63
|
-
commit={commit}
|
|
64
|
-
close={() => setPickerOpen(false)}
|
|
65
|
-
min={min}
|
|
66
|
-
max={max}
|
|
67
|
-
timezone={timezone}
|
|
68
|
-
label={label}
|
|
69
|
-
months={narrow ? 1 : 2}
|
|
70
|
-
layout={narrow ? 'sheet' : 'popover'}
|
|
71
|
-
activateOn={activateOn}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
68
|
+
const range = { value: val, commit, close: () => setPickerOpen(false), min, max, maxDays, timezone, activateOn };
|
|
74
69
|
|
|
75
70
|
return (
|
|
76
71
|
<FieldShell
|
|
77
72
|
variant="zc-dtf"
|
|
78
73
|
label={label}
|
|
74
|
+
ariaLabel={ariaLabel}
|
|
79
75
|
required={required}
|
|
80
76
|
invalid={invalid}
|
|
81
77
|
message={message}
|
|
82
78
|
icon="calendar"
|
|
79
|
+
size={size}
|
|
83
80
|
className={className}
|
|
84
81
|
htmlProps={htmlProps}
|
|
85
82
|
>
|
|
@@ -92,7 +89,7 @@ export function DateRangeField({
|
|
|
92
89
|
activateOn={activateOn}
|
|
93
90
|
animation={animation}
|
|
94
91
|
>
|
|
95
|
-
{
|
|
92
|
+
<DrpSheet {...range} title={label || ariaLabel || 'Date range'} />
|
|
96
93
|
</Sheet>
|
|
97
94
|
) : (
|
|
98
95
|
<Popover
|
|
@@ -104,7 +101,7 @@ export function DateRangeField({
|
|
|
104
101
|
activateOn={activateOn}
|
|
105
102
|
animation={animation}
|
|
106
103
|
>
|
|
107
|
-
{
|
|
104
|
+
<DrpPanel {...range} label={label} />
|
|
108
105
|
</Popover>
|
|
109
106
|
)}
|
|
110
107
|
</FieldShell>
|
|
@@ -54,6 +54,7 @@ export function DateTimeField({
|
|
|
54
54
|
defaultValue = null,
|
|
55
55
|
onChange,
|
|
56
56
|
label,
|
|
57
|
+
ariaLabel,
|
|
57
58
|
placeholder = 'Pick date & time',
|
|
58
59
|
timezone,
|
|
59
60
|
min,
|
|
@@ -64,6 +65,7 @@ export function DateTimeField({
|
|
|
64
65
|
invalid = false,
|
|
65
66
|
message,
|
|
66
67
|
disabled = false,
|
|
68
|
+
size = 'md',
|
|
67
69
|
className = '',
|
|
68
70
|
htmlProps,
|
|
69
71
|
activateOn = 'pointerdown',
|
|
@@ -117,10 +119,12 @@ export function DateTimeField({
|
|
|
117
119
|
<FieldShell
|
|
118
120
|
variant="zc-dtf"
|
|
119
121
|
label={label}
|
|
122
|
+
ariaLabel={ariaLabel}
|
|
120
123
|
required={required}
|
|
121
124
|
invalid={invalid}
|
|
122
125
|
message={message}
|
|
123
126
|
icon="calendar"
|
|
127
|
+
size={size}
|
|
124
128
|
className={className}
|
|
125
129
|
htmlProps={htmlProps}
|
|
126
130
|
>
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import './date-picker.css';
|
|
4
4
|
|
|
5
|
-
import type { PointerEvent } from 'react';
|
|
5
|
+
import type { MouseEvent, PointerEvent } from 'react';
|
|
6
6
|
|
|
7
7
|
import { useControllable } from '../../internal/hooks/use-controllable';
|
|
8
8
|
import { FieldShell, type DateFieldBaseProps } from './field-shell';
|
|
9
9
|
import { TimeSegments } from './time-core';
|
|
10
10
|
|
|
11
|
+
const focusHours = (box: HTMLDivElement) => box.querySelector<HTMLElement>('.zc-tsg__seg')?.focus();
|
|
12
|
+
|
|
11
13
|
export interface TimeFieldProps extends DateFieldBaseProps {
|
|
12
14
|
/** Controlled value, canonical 'HH:mm' (24h). */
|
|
13
15
|
value?: string | null;
|
|
@@ -32,6 +34,7 @@ export function TimeField({
|
|
|
32
34
|
defaultValue = null,
|
|
33
35
|
onChange,
|
|
34
36
|
label,
|
|
37
|
+
ariaLabel,
|
|
35
38
|
format = '24h',
|
|
36
39
|
minuteStep = 5,
|
|
37
40
|
min,
|
|
@@ -40,6 +43,7 @@ export function TimeField({
|
|
|
40
43
|
invalid = false,
|
|
41
44
|
message,
|
|
42
45
|
disabled = false,
|
|
46
|
+
size = 'md',
|
|
43
47
|
className = '',
|
|
44
48
|
htmlProps,
|
|
45
49
|
}: TimeFieldProps) {
|
|
@@ -48,8 +52,10 @@ export function TimeField({
|
|
|
48
52
|
function onBoxPointerDown(e: PointerEvent<HTMLDivElement>) {
|
|
49
53
|
if (disabled || (e.target as HTMLElement).closest('.zc-tsg__seg')) return;
|
|
50
54
|
e.preventDefault();
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
if (e.pointerType === 'mouse') focusHours(e.currentTarget);
|
|
56
|
+
}
|
|
57
|
+
function onBoxClick(e: MouseEvent<HTMLDivElement>) {
|
|
58
|
+
if (!disabled && !(e.target as HTMLElement).closest('.zc-tsg__seg')) focusHours(e.currentTarget);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
return (
|
|
@@ -60,12 +66,14 @@ export function TimeField({
|
|
|
60
66
|
invalid={invalid}
|
|
61
67
|
message={message}
|
|
62
68
|
icon="clock"
|
|
69
|
+
size={size}
|
|
63
70
|
className={className}
|
|
64
71
|
htmlProps={htmlProps}
|
|
65
72
|
>
|
|
66
73
|
<div
|
|
67
74
|
className={'zc-fld__input zc-tfd__box' + (disabled ? ' zc-is-disabled' : '')}
|
|
68
75
|
onPointerDown={onBoxPointerDown}
|
|
76
|
+
onClick={onBoxClick}
|
|
69
77
|
>
|
|
70
78
|
<TimeSegments
|
|
71
79
|
value={val}
|
|
@@ -75,7 +83,7 @@ export function TimeField({
|
|
|
75
83
|
min={min}
|
|
76
84
|
max={max}
|
|
77
85
|
disabled={disabled}
|
|
78
|
-
ariaLabel={label || 'Time'}
|
|
86
|
+
ariaLabel={label || ariaLabel || 'Time'}
|
|
79
87
|
/>
|
|
80
88
|
</div>
|
|
81
89
|
</FieldShell>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
gap: var(--space-2);
|
|
10
10
|
}
|
|
11
11
|
.zc-dtf__value {
|
|
12
|
-
font: var(--type-
|
|
12
|
+
font: var(--type-caption);
|
|
13
13
|
font-variant-numeric: tabular-nums;
|
|
14
14
|
color: var(--text-strong);
|
|
15
15
|
}
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
.zc-dtf__trigger[aria-expanded='true']:not(:disabled) {
|
|
28
28
|
border-color: var(--accent);
|
|
29
29
|
background: var(--bg-surface);
|
|
30
|
-
outline: var(--ring-accent);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
.zc-dtp,
|
|
@@ -144,7 +143,7 @@
|
|
|
144
143
|
transition: var(--transition-control);
|
|
145
144
|
}
|
|
146
145
|
.zc-dtp__jumpYear {
|
|
147
|
-
font-family: var(--font-
|
|
146
|
+
font-family: var(--font-body);
|
|
148
147
|
font-variant-numeric: tabular-nums;
|
|
149
148
|
}
|
|
150
149
|
.zc-dtp__jumpOpt:hover:not(:disabled):not(.zc-is-active) {
|
|
@@ -247,7 +246,7 @@
|
|
|
247
246
|
padding: 0;
|
|
248
247
|
background: transparent;
|
|
249
248
|
border-radius: var(--radius-md);
|
|
250
|
-
font-family: var(--font-
|
|
249
|
+
font-family: var(--font-body);
|
|
251
250
|
font-size: var(--size-caption);
|
|
252
251
|
font-variant-numeric: tabular-nums;
|
|
253
252
|
color: var(--text-body);
|
|
@@ -274,6 +273,7 @@
|
|
|
274
273
|
top: 0;
|
|
275
274
|
left: 0;
|
|
276
275
|
z-index: 0;
|
|
276
|
+
pointer-events: none;
|
|
277
277
|
border-radius: var(--radius-md);
|
|
278
278
|
background: var(--neutral-wash);
|
|
279
279
|
will-change: transform, opacity;
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
border-top: var(--border-hairline) solid var(--border-subtle);
|
|
368
368
|
}
|
|
369
369
|
.zc-dtp__tz {
|
|
370
|
-
font-family: var(--font-
|
|
370
|
+
font-family: var(--font-body);
|
|
371
371
|
font-size: var(--size-caption);
|
|
372
372
|
font-variant-numeric: tabular-nums;
|
|
373
373
|
color: var(--text-subtle);
|
|
@@ -424,6 +424,10 @@
|
|
|
424
424
|
.zc-drp__preset:hover {
|
|
425
425
|
color: var(--text-strong);
|
|
426
426
|
}
|
|
427
|
+
.zc-drp__preset:disabled {
|
|
428
|
+
color: var(--text-disabled);
|
|
429
|
+
cursor: default;
|
|
430
|
+
}
|
|
427
431
|
.zc-drp__preset:focus-visible {
|
|
428
432
|
outline: var(--ring-accent);
|
|
429
433
|
}
|
|
@@ -576,7 +580,7 @@
|
|
|
576
580
|
border-top: var(--border-hairline) solid var(--border-subtle);
|
|
577
581
|
}
|
|
578
582
|
.zc-drp__readout {
|
|
579
|
-
font-family: var(--font-
|
|
583
|
+
font-family: var(--font-body);
|
|
580
584
|
font-size: var(--size-caption);
|
|
581
585
|
font-variant-numeric: tabular-nums;
|
|
582
586
|
color: var(--text-body);
|
|
@@ -589,7 +593,7 @@
|
|
|
589
593
|
color: var(--text-disabled);
|
|
590
594
|
}
|
|
591
595
|
.zc-drp__tz {
|
|
592
|
-
font-family: var(--font-
|
|
596
|
+
font-family: var(--font-body);
|
|
593
597
|
font-size: var(--size-caption);
|
|
594
598
|
font-variant-numeric: tabular-nums;
|
|
595
599
|
color: var(--text-subtle);
|
|
@@ -599,43 +603,10 @@
|
|
|
599
603
|
flex: 1 1 auto;
|
|
600
604
|
}
|
|
601
605
|
|
|
602
|
-
.zc-drp--sheet {
|
|
603
|
-
--dtp-cell: var(--control-height-lg);
|
|
604
|
-
width: 100vw;
|
|
605
|
-
max-width: 100%;
|
|
606
|
-
border: 0;
|
|
607
|
-
border-radius: var(--radius-xl) var(--radius-xl) 0 0;
|
|
608
|
-
box-shadow: none;
|
|
609
|
-
}
|
|
610
|
-
.zc-drp--sheet .zc-drp__body {
|
|
611
|
-
flex-direction: column;
|
|
612
|
-
}
|
|
613
|
-
.zc-drp--sheet .zc-drp__presets {
|
|
614
|
-
width: auto;
|
|
615
|
-
flex-direction: row;
|
|
616
|
-
overflow-x: auto;
|
|
617
|
-
scroll-padding-inline: var(--ring-gutter);
|
|
618
|
-
gap: var(--space-1);
|
|
619
|
-
border-right: 0;
|
|
620
|
-
border-bottom: var(--border-hairline) solid var(--border-subtle);
|
|
621
|
-
scrollbar-width: none;
|
|
622
|
-
}
|
|
623
|
-
.zc-drp--sheet .zc-drp__presets::-webkit-scrollbar {
|
|
624
|
-
display: none;
|
|
625
|
-
}
|
|
626
|
-
.zc-drp--sheet .zc-drp__preset {
|
|
627
|
-
flex: none;
|
|
628
|
-
padding-block: var(--space-2);
|
|
629
|
-
}
|
|
630
|
-
.zc-drp--sheet .zc-drp__months {
|
|
631
|
-
justify-content: center;
|
|
632
|
-
padding-block: var(--space-2);
|
|
633
|
-
}
|
|
634
|
-
|
|
635
606
|
.zc-tsg {
|
|
636
607
|
display: inline-flex;
|
|
637
608
|
align-items: center;
|
|
638
|
-
font-family: var(--font-
|
|
609
|
+
font-family: var(--font-body);
|
|
639
610
|
font-size: var(--size-caption);
|
|
640
611
|
font-variant-numeric: tabular-nums;
|
|
641
612
|
color: var(--text-strong);
|
|
@@ -648,6 +619,14 @@
|
|
|
648
619
|
user-select: none;
|
|
649
620
|
transition: var(--transition-colors);
|
|
650
621
|
}
|
|
622
|
+
input.zc-tsg__seg {
|
|
623
|
+
inline-size: calc(2ch + 2 * var(--space-1));
|
|
624
|
+
caret-color: transparent;
|
|
625
|
+
user-select: auto;
|
|
626
|
+
}
|
|
627
|
+
input.zc-tsg__seg::selection {
|
|
628
|
+
background: transparent;
|
|
629
|
+
}
|
|
651
630
|
/* :focus, not :focus-visible: a clicked segment has to read selected, the same as keyboard entry. */
|
|
652
631
|
.zc-tsg__seg:focus {
|
|
653
632
|
background: var(--accent-subtle);
|
|
@@ -671,6 +650,11 @@
|
|
|
671
650
|
color: var(--text-disabled);
|
|
672
651
|
cursor: not-allowed;
|
|
673
652
|
}
|
|
653
|
+
@media (pointer: coarse) {
|
|
654
|
+
.zc-tsg {
|
|
655
|
+
font-size: var(--size-body-lg);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
674
658
|
|
|
675
659
|
/* The box is a div in .zc-fld__input chrome, so the input focus rules never reach it; these
|
|
676
660
|
restate them, scoped under .zc-tfd to outrank .zc-fld__input. */
|
|
@@ -29,6 +29,10 @@ export const add = (k: string, days: number): string => {
|
|
|
29
29
|
export const col = (d: Date): number => (d.getDay() + 6) % 7;
|
|
30
30
|
|
|
31
31
|
export const within = (k: string, min?: string, max?: string): boolean => (!min || k >= min) && (!max || k <= max);
|
|
32
|
+
export const canTurn = (y: number, m: number, dir: number, min?: string, max?: string): boolean =>
|
|
33
|
+
dir < 0 ? !min || toKey(new Date(y, m, 0)) >= min : !max || toKey(new Date(y, m + 1, 1)) <= max;
|
|
34
|
+
export const clampKey = (k: string, min?: string, max?: string): string =>
|
|
35
|
+
min && k < min ? min : max && k > max ? max : k;
|
|
32
36
|
|
|
33
37
|
export function displayDay(k: string | null): string | null {
|
|
34
38
|
if (!k) return null;
|