@zyncat/ui 0.21.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 +10 -9
- package/dist/alert.js.map +1 -1
- package/dist/avatar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/badge.js +5 -100
- package/dist/badge.js.map +1 -1
- 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-3HE7N3UK.js → chunk-2GYZ3HP3.js} +3 -3
- package/dist/chunk-2GYZ3HP3.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-BWGK3OD6.js → chunk-AK2AXGEC.js} +33 -6
- 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-AXZBD7LY.js → chunk-CF6ZFXRV.js} +16 -11
- package/dist/chunk-CF6ZFXRV.js.map +1 -0
- package/dist/{chunk-AQMR7ZYO.js → chunk-DOAR4PJ3.js} +4 -4
- package/dist/{chunk-AQMR7ZYO.js.map → chunk-DOAR4PJ3.js.map} +1 -1
- package/dist/chunk-EUAXI6OF.js +16 -0
- package/dist/chunk-EUAXI6OF.js.map +1 -0
- package/dist/{chunk-AOEO2LCZ.js → chunk-G2TOUG2A.js} +6 -5
- package/dist/chunk-G2TOUG2A.js.map +1 -0
- package/dist/{chunk-CYZKPUCG.js → chunk-HRP4UFWN.js} +3 -3
- 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-GM7IPTTT.js → chunk-JJHEVW4M.js} +5 -5
- package/dist/{chunk-GM7IPTTT.js.map → chunk-JJHEVW4M.js.map} +1 -1
- package/dist/{chunk-7NHY2CRA.js → chunk-JUC35N3C.js} +2 -2
- package/dist/chunk-JUC35N3C.js.map +1 -0
- package/dist/{chunk-LC6NQQER.js → chunk-LFJ4C7ZP.js} +7 -7
- package/dist/chunk-LFJ4C7ZP.js.map +1 -0
- package/dist/{chunk-JQZ3FTHP.js → chunk-MCOIR3CK.js} +3 -3
- package/dist/{chunk-JQZ3FTHP.js.map → chunk-MCOIR3CK.js.map} +1 -1
- package/dist/{chunk-TXJQUN7C.js → chunk-NATK4DDW.js} +15 -15
- package/dist/{chunk-TXJQUN7C.js.map → chunk-NATK4DDW.js.map} +1 -1
- 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-47OMFFIB.js → chunk-ODO2TCTS.js} +27 -13
- package/dist/chunk-ODO2TCTS.js.map +1 -0
- package/dist/{chunk-LV442ZOR.js → chunk-P3QSWNED.js} +11 -11
- package/dist/{chunk-LV442ZOR.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-ZSP4ZTII.js → chunk-RLRZJAF7.js} +20 -8
- package/dist/chunk-RLRZJAF7.js.map +1 -0
- package/dist/{chunk-V4ZN5RD4.js → chunk-SY5UA6WS.js} +29 -9
- package/dist/chunk-SY5UA6WS.js.map +1 -0
- package/dist/{chunk-SPFHWHJ6.js → chunk-TFC5SCAB.js} +32 -13
- 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-2W7FOMWE.js → chunk-VXQ7A6ZI.js} +8 -8
- package/dist/{chunk-2W7FOMWE.js.map → chunk-VXQ7A6ZI.js.map} +1 -1
- package/dist/{chunk-TBLPZQSI.js → chunk-W7CHDHRV.js} +114 -42
- package/dist/chunk-W7CHDHRV.js.map +1 -0
- package/dist/{chunk-DEZIQTBW.js → chunk-WBWVOOKM.js} +58 -53
- 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-TBIY5YR5.js → chunk-WMTOAYGP.js} +9 -9
- package/dist/{chunk-TBIY5YR5.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-PNFFK5HY.js → chunk-XCTMTOGT.js} +5 -5
- package/dist/{chunk-PNFFK5HY.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-XFZLFLT7.js → crossfade-UHUQBUVG.js} +53 -11
- package/dist/crossfade-UHUQBUVG.js.map +1 -0
- package/dist/date-field.js +23 -20
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +25 -40
- package/dist/date-range-field.js +458 -276
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +24 -21
- 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 +42 -40
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown.css +2 -2
- package/dist/dropdown.js +56 -31
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +20 -19
- 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/modal.js +10 -9
- 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 +6 -5
- package/dist/multi-select.js +41 -20
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +121 -74
- package/dist/number-field.js.map +1 -1
- package/dist/odometer.css +12 -7
- package/dist/odometer.js +158 -39
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +32 -3
- 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/popover.js +11 -10
- package/dist/radio-group.css +1 -2
- 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 +22 -1
- package/dist/select.js +15 -14
- package/dist/select.js.map +1 -1
- package/dist/sheet.js +11 -10
- package/dist/support-rail.css +2 -2
- package/dist/support-rail.js +15 -13
- package/dist/support-rail.js.map +1 -1
- package/dist/table-detail.css +27 -0
- package/dist/table.css +35 -13
- package/dist/table.js +341 -172
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +16 -11
- package/dist/tabs.js +68 -56
- 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 +15 -42
- package/dist/textarea.js +24 -26
- package/dist/textarea.js.map +1 -1
- package/dist/theme-grid.js +8 -7
- package/dist/theme-switcher.js +17 -16
- package/dist/theme-switcher.js.map +1 -1
- package/dist/{theme-transition-FDF2REFD.js → theme-transition-F3CBENM5.js} +5 -5
- package/dist/{theme-transition-FDF2REFD.js.map → theme-transition-F3CBENM5.js.map} +1 -1
- package/dist/theme.js +5 -4
- package/dist/theme.js.map +1 -1
- package/dist/tiktok.js +3 -3
- package/dist/time-field.js +13 -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.map +1 -1
- package/dist/toggle.css +0 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +21 -15
- package/dist/tooltip.js.map +1 -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 +4 -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 +9 -3
- package/dist/types/components/composites/dropdown/types.d.ts +4 -1
- package/dist/types/components/composites/scroll-area/ScrollArea.d.ts +29 -0
- package/dist/types/components/composites/select/MultiSelect.d.ts +9 -3
- package/dist/types/components/composites/select/core/menu.d.ts +3 -1
- package/dist/types/components/composites/select/core/panel.d.ts +4 -3
- package/dist/types/components/composites/select/core/use-listbox.d.ts +5 -5
- 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 +3 -71
- 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/roll.d.ts +9 -11
- package/dist/types/components/expressive/odometer/spring.d.ts +11 -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/support/types.d.ts +1 -1
- 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 +5 -1
- 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 +3 -1
- 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 +2 -1
- package/dist/types/motion/element.d.ts +14 -5
- package/dist/types/motion/flip.d.ts +6 -3
- package/dist/types/motion/holders.d.ts +4 -0
- package/dist/types/motion/use-motion.d.ts +3 -1
- 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 +43 -31
- 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 +11 -1
- package/skills/zyncat-ui/SKILL.md +6 -6
- package/skills/zyncat-ui/references/components.md +4 -2
- package/skills/zyncat-ui/references/recipes.md +1 -1
- 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 +2 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +13 -18
- package/src/components/composites/date-picker/DateTimeField.tsx +2 -0
- package/src/components/composites/date-picker/TimeField.tsx +10 -4
- package/src/components/composites/date-picker/date-picker.css +25 -40
- package/src/components/composites/date-picker/date-utils.ts +4 -0
- package/src/components/composites/date-picker/field-shell.tsx +31 -7
- 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 +31 -6
- package/src/components/composites/dropdown/dropdown.css +2 -2
- package/src/components/composites/dropdown/menu-panel.tsx +22 -14
- package/src/components/composites/dropdown/types.ts +4 -1
- 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 +15 -7
- package/src/components/composites/select/core/menu.tsx +6 -2
- package/src/components/composites/select/core/panel.tsx +9 -7
- package/src/components/composites/select/core/trigger.tsx +1 -3
- package/src/components/composites/select/core/use-listbox.ts +35 -28
- package/src/components/composites/select/presets.tsx +47 -0
- package/src/components/composites/select/select.css +22 -1
- 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 +35 -13
- 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 +21 -191
- package/src/components/composites/tabs/tab-panel.tsx +63 -0
- package/src/components/composites/tabs/tabs.css +16 -11
- 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 +9 -5
- 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 +38 -12
- package/src/components/expressive/odometer/odometer.css +12 -7
- package/src/components/expressive/odometer/roll.ts +85 -40
- package/src/components/expressive/odometer/spring.ts +86 -0
- 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/overlay/overlay.css +1 -0
- package/src/components/internal/overlay/track-anchor.ts +1 -1
- package/src/components/internal/support/types.ts +1 -1
- package/src/components/internal/utils/activation.ts +2 -2
- package/src/components/primitives/avatar/avatar.css +1 -1
- package/src/components/primitives/badge/badge.css +1 -1
- 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 +35 -2
- 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 +1 -2
- 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 +24 -6
- package/src/components/primitives/textarea/char-meter.tsx +1 -16
- package/src/components/primitives/textarea/textarea.css +15 -42
- package/src/components/primitives/toggle/toggle.css +0 -1
- package/src/engine/animate.ts +5 -3
- package/src/engine/flip.ts +23 -3
- 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 +54 -8
- package/src/motion/element.tsx +22 -4
- package/src/motion/flip.ts +69 -37
- package/src/motion/holders.ts +10 -0
- package/src/motion/presence.tsx +18 -9
- package/src/motion/use-motion.ts +38 -4
- package/src/tokens/base.css +0 -5
- package/src/tokens/dark.css +5 -5
- 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 +8 -8
- 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 +44 -31
- package/src/tokens/theme.tsx +1 -1
- package/tailwind.css +4 -0
- package/dist/chunk-3HE7N3UK.js.map +0 -1
- package/dist/chunk-47OMFFIB.js.map +0 -1
- package/dist/chunk-6BY5G7BI.js +0 -122
- package/dist/chunk-6BY5G7BI.js.map +0 -1
- package/dist/chunk-6H3IJ752.js.map +0 -1
- package/dist/chunk-7NHY2CRA.js.map +0 -1
- package/dist/chunk-AOEO2LCZ.js.map +0 -1
- package/dist/chunk-AXZBD7LY.js.map +0 -1
- package/dist/chunk-BWGK3OD6.js.map +0 -1
- package/dist/chunk-CYZKPUCG.js.map +0 -1
- package/dist/chunk-DEZIQTBW.js.map +0 -1
- package/dist/chunk-KSAJ6DED.js +0 -16
- package/dist/chunk-KSAJ6DED.js.map +0 -1
- package/dist/chunk-LC6NQQER.js.map +0 -1
- package/dist/chunk-ODRO3KS6.js.map +0 -1
- package/dist/chunk-QDAN43B6.js.map +0 -1
- package/dist/chunk-SPFHWHJ6.js.map +0 -1
- package/dist/chunk-TBLPZQSI.js.map +0 -1
- package/dist/chunk-V4ZN5RD4.js.map +0 -1
- package/dist/chunk-ZSP4ZTII.js.map +0 -1
- package/dist/crossfade-XFZLFLT7.js.map +0 -1
|
@@ -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,
|
|
@@ -54,6 +55,7 @@ export function DateField({
|
|
|
54
55
|
<FieldShell
|
|
55
56
|
variant="zc-dtf"
|
|
56
57
|
label={label}
|
|
58
|
+
ariaLabel={ariaLabel}
|
|
57
59
|
required={required}
|
|
58
60
|
invalid={invalid}
|
|
59
61
|
message={message}
|
|
@@ -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,10 +42,12 @@ 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,
|
|
@@ -58,25 +65,13 @@ export function DateRangeField({
|
|
|
58
65
|
|
|
59
66
|
const display = val && val.start && val.end ? drpRangeText(val.start, val.end) : null;
|
|
60
67
|
const trigger = <FieldTrigger display={display} placeholder={placeholder} disabled={disabled} />;
|
|
61
|
-
const
|
|
62
|
-
<DrpPanel
|
|
63
|
-
value={val}
|
|
64
|
-
commit={commit}
|
|
65
|
-
close={() => setPickerOpen(false)}
|
|
66
|
-
min={min}
|
|
67
|
-
max={max}
|
|
68
|
-
timezone={timezone}
|
|
69
|
-
label={label}
|
|
70
|
-
months={narrow ? 1 : 2}
|
|
71
|
-
layout={narrow ? 'sheet' : 'popover'}
|
|
72
|
-
activateOn={activateOn}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
68
|
+
const range = { value: val, commit, close: () => setPickerOpen(false), min, max, maxDays, timezone, activateOn };
|
|
75
69
|
|
|
76
70
|
return (
|
|
77
71
|
<FieldShell
|
|
78
72
|
variant="zc-dtf"
|
|
79
73
|
label={label}
|
|
74
|
+
ariaLabel={ariaLabel}
|
|
80
75
|
required={required}
|
|
81
76
|
invalid={invalid}
|
|
82
77
|
message={message}
|
|
@@ -94,7 +89,7 @@ export function DateRangeField({
|
|
|
94
89
|
activateOn={activateOn}
|
|
95
90
|
animation={animation}
|
|
96
91
|
>
|
|
97
|
-
{
|
|
92
|
+
<DrpSheet {...range} title={label || ariaLabel || 'Date range'} />
|
|
98
93
|
</Sheet>
|
|
99
94
|
) : (
|
|
100
95
|
<Popover
|
|
@@ -106,7 +101,7 @@ export function DateRangeField({
|
|
|
106
101
|
activateOn={activateOn}
|
|
107
102
|
animation={animation}
|
|
108
103
|
>
|
|
109
|
-
{
|
|
104
|
+
<DrpPanel {...range} label={label} />
|
|
110
105
|
</Popover>
|
|
111
106
|
)}
|
|
112
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,
|
|
@@ -118,6 +119,7 @@ export function DateTimeField({
|
|
|
118
119
|
<FieldShell
|
|
119
120
|
variant="zc-dtf"
|
|
120
121
|
label={label}
|
|
122
|
+
ariaLabel={ariaLabel}
|
|
121
123
|
required={required}
|
|
122
124
|
invalid={invalid}
|
|
123
125
|
message={message}
|
|
@@ -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,
|
|
@@ -49,8 +52,10 @@ export function TimeField({
|
|
|
49
52
|
function onBoxPointerDown(e: PointerEvent<HTMLDivElement>) {
|
|
50
53
|
if (disabled || (e.target as HTMLElement).closest('.zc-tsg__seg')) return;
|
|
51
54
|
e.preventDefault();
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
return (
|
|
@@ -68,6 +73,7 @@ export function TimeField({
|
|
|
68
73
|
<div
|
|
69
74
|
className={'zc-fld__input zc-tfd__box' + (disabled ? ' zc-is-disabled' : '')}
|
|
70
75
|
onPointerDown={onBoxPointerDown}
|
|
76
|
+
onClick={onBoxClick}
|
|
71
77
|
>
|
|
72
78
|
<TimeSegments
|
|
73
79
|
value={val}
|
|
@@ -77,7 +83,7 @@ export function TimeField({
|
|
|
77
83
|
min={min}
|
|
78
84
|
max={max}
|
|
79
85
|
disabled={disabled}
|
|
80
|
-
ariaLabel={label || 'Time'}
|
|
86
|
+
ariaLabel={label || ariaLabel || 'Time'}
|
|
81
87
|
/>
|
|
82
88
|
</div>
|
|
83
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
|
}
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
transition: var(--transition-control);
|
|
144
144
|
}
|
|
145
145
|
.zc-dtp__jumpYear {
|
|
146
|
-
font-family: var(--font-
|
|
146
|
+
font-family: var(--font-body);
|
|
147
147
|
font-variant-numeric: tabular-nums;
|
|
148
148
|
}
|
|
149
149
|
.zc-dtp__jumpOpt:hover:not(:disabled):not(.zc-is-active) {
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
padding: 0;
|
|
247
247
|
background: transparent;
|
|
248
248
|
border-radius: var(--radius-md);
|
|
249
|
-
font-family: var(--font-
|
|
249
|
+
font-family: var(--font-body);
|
|
250
250
|
font-size: var(--size-caption);
|
|
251
251
|
font-variant-numeric: tabular-nums;
|
|
252
252
|
color: var(--text-body);
|
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
top: 0;
|
|
274
274
|
left: 0;
|
|
275
275
|
z-index: 0;
|
|
276
|
+
pointer-events: none;
|
|
276
277
|
border-radius: var(--radius-md);
|
|
277
278
|
background: var(--neutral-wash);
|
|
278
279
|
will-change: transform, opacity;
|
|
@@ -366,7 +367,7 @@
|
|
|
366
367
|
border-top: var(--border-hairline) solid var(--border-subtle);
|
|
367
368
|
}
|
|
368
369
|
.zc-dtp__tz {
|
|
369
|
-
font-family: var(--font-
|
|
370
|
+
font-family: var(--font-body);
|
|
370
371
|
font-size: var(--size-caption);
|
|
371
372
|
font-variant-numeric: tabular-nums;
|
|
372
373
|
color: var(--text-subtle);
|
|
@@ -423,6 +424,10 @@
|
|
|
423
424
|
.zc-drp__preset:hover {
|
|
424
425
|
color: var(--text-strong);
|
|
425
426
|
}
|
|
427
|
+
.zc-drp__preset:disabled {
|
|
428
|
+
color: var(--text-disabled);
|
|
429
|
+
cursor: default;
|
|
430
|
+
}
|
|
426
431
|
.zc-drp__preset:focus-visible {
|
|
427
432
|
outline: var(--ring-accent);
|
|
428
433
|
}
|
|
@@ -575,7 +580,7 @@
|
|
|
575
580
|
border-top: var(--border-hairline) solid var(--border-subtle);
|
|
576
581
|
}
|
|
577
582
|
.zc-drp__readout {
|
|
578
|
-
font-family: var(--font-
|
|
583
|
+
font-family: var(--font-body);
|
|
579
584
|
font-size: var(--size-caption);
|
|
580
585
|
font-variant-numeric: tabular-nums;
|
|
581
586
|
color: var(--text-body);
|
|
@@ -588,7 +593,7 @@
|
|
|
588
593
|
color: var(--text-disabled);
|
|
589
594
|
}
|
|
590
595
|
.zc-drp__tz {
|
|
591
|
-
font-family: var(--font-
|
|
596
|
+
font-family: var(--font-body);
|
|
592
597
|
font-size: var(--size-caption);
|
|
593
598
|
font-variant-numeric: tabular-nums;
|
|
594
599
|
color: var(--text-subtle);
|
|
@@ -598,43 +603,10 @@
|
|
|
598
603
|
flex: 1 1 auto;
|
|
599
604
|
}
|
|
600
605
|
|
|
601
|
-
.zc-drp--sheet {
|
|
602
|
-
--dtp-cell: var(--control-height-lg);
|
|
603
|
-
width: 100vw;
|
|
604
|
-
max-width: 100%;
|
|
605
|
-
border: 0;
|
|
606
|
-
border-radius: var(--radius-xl) var(--radius-xl) 0 0;
|
|
607
|
-
box-shadow: none;
|
|
608
|
-
}
|
|
609
|
-
.zc-drp--sheet .zc-drp__body {
|
|
610
|
-
flex-direction: column;
|
|
611
|
-
}
|
|
612
|
-
.zc-drp--sheet .zc-drp__presets {
|
|
613
|
-
width: auto;
|
|
614
|
-
flex-direction: row;
|
|
615
|
-
overflow-x: auto;
|
|
616
|
-
scroll-padding-inline: var(--ring-gutter);
|
|
617
|
-
gap: var(--space-1);
|
|
618
|
-
border-right: 0;
|
|
619
|
-
border-bottom: var(--border-hairline) solid var(--border-subtle);
|
|
620
|
-
scrollbar-width: none;
|
|
621
|
-
}
|
|
622
|
-
.zc-drp--sheet .zc-drp__presets::-webkit-scrollbar {
|
|
623
|
-
display: none;
|
|
624
|
-
}
|
|
625
|
-
.zc-drp--sheet .zc-drp__preset {
|
|
626
|
-
flex: none;
|
|
627
|
-
padding-block: var(--space-2);
|
|
628
|
-
}
|
|
629
|
-
.zc-drp--sheet .zc-drp__months {
|
|
630
|
-
justify-content: center;
|
|
631
|
-
padding-block: var(--space-2);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
606
|
.zc-tsg {
|
|
635
607
|
display: inline-flex;
|
|
636
608
|
align-items: center;
|
|
637
|
-
font-family: var(--font-
|
|
609
|
+
font-family: var(--font-body);
|
|
638
610
|
font-size: var(--size-caption);
|
|
639
611
|
font-variant-numeric: tabular-nums;
|
|
640
612
|
color: var(--text-strong);
|
|
@@ -647,6 +619,14 @@
|
|
|
647
619
|
user-select: none;
|
|
648
620
|
transition: var(--transition-colors);
|
|
649
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
|
+
}
|
|
650
630
|
/* :focus, not :focus-visible: a clicked segment has to read selected, the same as keyboard entry. */
|
|
651
631
|
.zc-tsg__seg:focus {
|
|
652
632
|
background: var(--accent-subtle);
|
|
@@ -670,6 +650,11 @@
|
|
|
670
650
|
color: var(--text-disabled);
|
|
671
651
|
cursor: not-allowed;
|
|
672
652
|
}
|
|
653
|
+
@media (pointer: coarse) {
|
|
654
|
+
.zc-tsg {
|
|
655
|
+
font-size: var(--size-body-lg);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
673
658
|
|
|
674
659
|
/* The box is a div in .zc-fld__input chrome, so the input focus rules never reach it; these
|
|
675
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;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import './date-picker.css';
|
|
4
4
|
|
|
5
|
+
import { createContext, useContext, useId } from 'react';
|
|
5
6
|
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
6
7
|
|
|
7
8
|
import type { DataAttributes } from '../../../dom-props';
|
|
@@ -14,6 +15,8 @@ import { FieldLabel, FieldMessage } from '../../primitives/input/field-chrome';
|
|
|
14
15
|
export interface DateFieldBaseProps {
|
|
15
16
|
/** Field label rendered above the trigger. */
|
|
16
17
|
label?: string;
|
|
18
|
+
/** Accessible name for a field with no visible `label`. */
|
|
19
|
+
ariaLabel?: string;
|
|
17
20
|
/** Asterisk on the label. @default false */
|
|
18
21
|
required?: boolean;
|
|
19
22
|
/** Danger border + message color (.zc-fld.zc-is-error). @default false */
|
|
@@ -40,6 +43,7 @@ export interface FieldShellProps {
|
|
|
40
43
|
variant: string;
|
|
41
44
|
size?: 'sm' | 'md' | 'lg';
|
|
42
45
|
label?: string;
|
|
46
|
+
ariaLabel?: string;
|
|
43
47
|
required?: boolean;
|
|
44
48
|
invalid?: boolean;
|
|
45
49
|
message?: ReactNode;
|
|
@@ -49,10 +53,13 @@ export interface FieldShellProps {
|
|
|
49
53
|
children?: ReactNode;
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
const FieldNameId = createContext<string | undefined>(undefined);
|
|
57
|
+
|
|
52
58
|
export function FieldShell({
|
|
53
59
|
variant,
|
|
54
60
|
size,
|
|
55
61
|
label,
|
|
62
|
+
ariaLabel,
|
|
56
63
|
required,
|
|
57
64
|
invalid,
|
|
58
65
|
message,
|
|
@@ -61,6 +68,7 @@ export function FieldShell({
|
|
|
61
68
|
htmlProps,
|
|
62
69
|
children,
|
|
63
70
|
}: FieldShellProps) {
|
|
71
|
+
const nameId = useId();
|
|
64
72
|
const cls = cx(
|
|
65
73
|
'zc-fld',
|
|
66
74
|
variant,
|
|
@@ -72,13 +80,20 @@ export function FieldShell({
|
|
|
72
80
|
);
|
|
73
81
|
return (
|
|
74
82
|
<div {...htmlProps} className={cls}>
|
|
75
|
-
<FieldLabel label={label} required={required} />
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
<Icon name={icon} size="md" />
|
|
83
|
+
<FieldLabel labelId={nameId} label={label} required={required} />
|
|
84
|
+
{!label && ariaLabel && (
|
|
85
|
+
<span id={nameId} hidden>
|
|
86
|
+
{ariaLabel}
|
|
80
87
|
</span>
|
|
81
|
-
|
|
88
|
+
)}
|
|
89
|
+
<FieldNameId.Provider value={label || ariaLabel ? nameId : undefined}>
|
|
90
|
+
<div className="zc-fld__control">
|
|
91
|
+
{children}
|
|
92
|
+
<span className="zc-fld__icon zc-fld__icon--lead" aria-hidden="true">
|
|
93
|
+
<Icon name={icon} size="md" />
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
</FieldNameId.Provider>
|
|
82
97
|
<FieldMessage message={message ? <span>{message}</span> : null} />
|
|
83
98
|
</div>
|
|
84
99
|
);
|
|
@@ -92,8 +107,17 @@ export function FieldTrigger({
|
|
|
92
107
|
}: { display: string | null; placeholder: string; disabled?: boolean } & ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
93
108
|
ref?: Ref<HTMLButtonElement>;
|
|
94
109
|
}) {
|
|
110
|
+
const nameId = useContext(FieldNameId);
|
|
111
|
+
const id = useId();
|
|
95
112
|
return (
|
|
96
|
-
<button
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
id={id}
|
|
116
|
+
className="zc-fld__input zc-dtf__trigger"
|
|
117
|
+
aria-labelledby={nameId && `${nameId} ${id}`}
|
|
118
|
+
disabled={disabled}
|
|
119
|
+
{...rest}
|
|
120
|
+
>
|
|
97
121
|
{display ? (
|
|
98
122
|
<span className="zc-dtf__value">{display}</span>
|
|
99
123
|
) : (
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { PointerEvent } from 'react';
|
|
4
|
+
|
|
5
|
+
import { animate, set, startDrag } from '../../../engine';
|
|
6
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
7
|
+
import { canTurn } from './date-utils';
|
|
8
|
+
import type { RangePanel } from './use-range-panel';
|
|
9
|
+
|
|
10
|
+
const INTENT_PX = 8;
|
|
11
|
+
const TURN_PX = 56;
|
|
12
|
+
const TURN_VELOCITY = 400;
|
|
13
|
+
const RESIST = 0.4;
|
|
14
|
+
const EDGE_RESIST = 0.15;
|
|
15
|
+
|
|
16
|
+
export function monthSwipe({ view, nav, gridGlide }: RangePanel, min?: string, max?: string) {
|
|
17
|
+
return function onPointerDown(e: PointerEvent<HTMLElement>) {
|
|
18
|
+
const grid = e.currentTarget.querySelector<HTMLElement>('.zc-dtp__days');
|
|
19
|
+
if (e.pointerType !== 'touch' || !e.isPrimary || !grid) return;
|
|
20
|
+
const dirOf = (dx: number) => (dx < 0 ? 1 : -1);
|
|
21
|
+
const turnable = (dx: number) => canTurn(view.y, view.m, dirOf(dx), min, max);
|
|
22
|
+
let along = false;
|
|
23
|
+
const stop = startDrag(e, {
|
|
24
|
+
onMove({ offset }) {
|
|
25
|
+
if (!along) {
|
|
26
|
+
if (Math.max(Math.abs(offset.x), Math.abs(offset.y)) < INTENT_PX) return;
|
|
27
|
+
if (Math.abs(offset.x) <= Math.abs(offset.y)) return stop();
|
|
28
|
+
along = true;
|
|
29
|
+
gridGlide.leave();
|
|
30
|
+
}
|
|
31
|
+
set(grid, { x: [offset.x * (turnable(offset.x) ? RESIST : EDGE_RESIST)] });
|
|
32
|
+
},
|
|
33
|
+
onEnd({ offset, velocity }) {
|
|
34
|
+
if (!along) return;
|
|
35
|
+
const flung = Math.abs(velocity.x) > TURN_VELOCITY && Math.sign(velocity.x) === Math.sign(offset.x);
|
|
36
|
+
if ((flung || Math.abs(offset.x) > TURN_PX) && turnable(offset.x)) nav(dirOf(offset.x));
|
|
37
|
+
else animate(grid, { x: [0], timing: { ...motionFor(grid).t.settle, release: true } });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|