@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,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
import { GlidePill, useGlide } from '../../../motion/glide';
|
|
6
|
+
import { useScrollEdges } from '../../internal/hooks/use-scroll-edges';
|
|
7
|
+
import { activationProps, type ActivateOn } from '../../internal/utils/activation';
|
|
8
|
+
import { add, MONTHS, pad, parse, today, toKey } from './date-utils';
|
|
9
|
+
|
|
10
|
+
/** A date range as wall-clock 'YYYY-MM-DD' endpoints, inclusive. */
|
|
11
|
+
export interface DateRange {
|
|
12
|
+
/** Range start, inclusive - `'YYYY-MM-DD'`. */
|
|
13
|
+
start: string;
|
|
14
|
+
/** Range end, inclusive - `'YYYY-MM-DD'`. Never before `start`. */
|
|
15
|
+
end: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface DrpPreset {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
start: string;
|
|
22
|
+
end: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function drpDisplay(key: string, withYear: boolean): string {
|
|
26
|
+
const d = parse(key);
|
|
27
|
+
const mon = MONTHS[d.getMonth()].slice(0, 3);
|
|
28
|
+
return mon + ' ' + pad(d.getDate()) + (withYear ? ', ' + d.getFullYear() : '');
|
|
29
|
+
}
|
|
30
|
+
export function drpRangeText(start: string, end: string): string {
|
|
31
|
+
const sameYear = parse(start).getFullYear() === parse(end).getFullYear();
|
|
32
|
+
const curYear = new Date().getFullYear();
|
|
33
|
+
const startYr = !sameYear || parse(start).getFullYear() !== curYear;
|
|
34
|
+
const endYr = parse(end).getFullYear() !== curYear;
|
|
35
|
+
return drpDisplay(start, startYr) + ' - ' + drpDisplay(end, endYr);
|
|
36
|
+
}
|
|
37
|
+
export const drpDays = (start: string, end: string): number => Math.round((+parse(end) - +parse(start)) / 86400000) + 1;
|
|
38
|
+
|
|
39
|
+
function drpPresets(): DrpPreset[] {
|
|
40
|
+
const t = today();
|
|
41
|
+
const now = new Date();
|
|
42
|
+
const firstThis = toKey(new Date(now.getFullYear(), now.getMonth(), 1));
|
|
43
|
+
const firstPrev = toKey(new Date(now.getFullYear(), now.getMonth() - 1, 1));
|
|
44
|
+
const lastPrev = toKey(new Date(now.getFullYear(), now.getMonth(), 0));
|
|
45
|
+
const jan1 = toKey(new Date(now.getFullYear(), 0, 1));
|
|
46
|
+
return [
|
|
47
|
+
{ id: 'today', label: 'Today', start: t, end: t },
|
|
48
|
+
{ id: 'yest', label: 'Yesterday', start: add(t, -1), end: add(t, -1) },
|
|
49
|
+
{ id: '7d', label: 'Last 7 days', start: add(t, -6), end: t },
|
|
50
|
+
{ id: '30d', label: 'Last 30 days', start: add(t, -29), end: t },
|
|
51
|
+
{ id: 'mtd', label: 'This month', start: firstThis, end: t },
|
|
52
|
+
{ id: 'lastm', label: 'Last month', start: firstPrev, end: lastPrev },
|
|
53
|
+
{ id: '90d', label: 'Last 90 days', start: add(t, -89), end: t },
|
|
54
|
+
{ id: 'ytd', label: 'Year to date', start: jan1, end: t },
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface RangePresetsProps {
|
|
59
|
+
draft: DateRange | null;
|
|
60
|
+
fits: (p: DrpPreset) => boolean;
|
|
61
|
+
onPick: (p: DrpPreset) => void;
|
|
62
|
+
activateOn?: ActivateOn;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function RangePresets({ draft, fits, onPick, activateOn }: RangePresetsProps) {
|
|
66
|
+
const presetsRef = useRef<HTMLDivElement>(null);
|
|
67
|
+
const presetGlide = useGlide(presetsRef);
|
|
68
|
+
const presets = drpPresets();
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
const strip = presetsRef.current;
|
|
71
|
+
const chip = strip && strip.querySelector<HTMLElement>('.zc-is-active');
|
|
72
|
+
if (strip && chip) strip.scrollLeft = chip.offsetLeft - (strip.clientWidth - chip.offsetWidth) / 2;
|
|
73
|
+
}, []);
|
|
74
|
+
useScrollEdges(presetsRef, (edges, el) => {
|
|
75
|
+
el.dataset.fade = ((edges.left ? 'start ' : '') + (edges.right ? 'end' : '')).trim();
|
|
76
|
+
});
|
|
77
|
+
function presetActive(p: DrpPreset): boolean {
|
|
78
|
+
return draft && draft.start === p.start && draft.end === p.end;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
className="zc-drp__presets"
|
|
84
|
+
role="group"
|
|
85
|
+
aria-label="Quick ranges"
|
|
86
|
+
ref={presetsRef}
|
|
87
|
+
onPointerLeave={presetGlide.leave}
|
|
88
|
+
>
|
|
89
|
+
{presets.map((p) => (
|
|
90
|
+
<button
|
|
91
|
+
key={p.id}
|
|
92
|
+
type="button"
|
|
93
|
+
className={'zc-drp__preset' + (presetActive(p) ? ' zc-is-active' : '')}
|
|
94
|
+
disabled={!fits(p)}
|
|
95
|
+
onPointerEnter={(e) => (e.currentTarget.disabled ? presetGlide.leave() : presetGlide.enter(e.currentTarget))}
|
|
96
|
+
{...activationProps<HTMLButtonElement>(() => onPick(p), { on: activateOn })}
|
|
97
|
+
>
|
|
98
|
+
{p.label}
|
|
99
|
+
</button>
|
|
100
|
+
))}
|
|
101
|
+
<GlidePill className="zc-drp__presetGlide" glide={presetGlide} />
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@layer zyncat.components {
|
|
4
|
+
.zc-drp.zc-drp--sheet {
|
|
5
|
+
--dtp-cell: clamp(var(--control-height-sm), 6svh, var(--control-height-xl));
|
|
6
|
+
--dtp-gap: 0px;
|
|
7
|
+
}
|
|
8
|
+
.zc-drp--sheet .zc-dtp__hover {
|
|
9
|
+
z-index: -1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.zc-drp--sheet .zc-dtp__dow,
|
|
13
|
+
.zc-drp--sheet .zc-dtp__days {
|
|
14
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
15
|
+
}
|
|
16
|
+
.zc-drp--sheet .zc-dtp__dow {
|
|
17
|
+
padding-bottom: var(--space-2);
|
|
18
|
+
}
|
|
19
|
+
.zc-drp--sheet .zc-dtp__days {
|
|
20
|
+
row-gap: var(--space-1);
|
|
21
|
+
}
|
|
22
|
+
.zc-drp--sheet .zc-dtp__day {
|
|
23
|
+
width: auto;
|
|
24
|
+
font-size: var(--size-body);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.zc-drp--sheet .zc-drp__band--fadeL {
|
|
28
|
+
left: -100%;
|
|
29
|
+
mask-image: linear-gradient(to right, transparent, black 50%);
|
|
30
|
+
}
|
|
31
|
+
.zc-drp--sheet .zc-drp__band--fadeR {
|
|
32
|
+
right: -100%;
|
|
33
|
+
mask-image: linear-gradient(to left, transparent, black 50%);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@layer zyncat.components {
|
|
4
|
+
.zc-overlay-panel--sheet-bottom:has(> .zc-drp--sheet) {
|
|
5
|
+
border-radius: var(--radius-xl) var(--radius-xl) 0 0;
|
|
6
|
+
}
|
|
7
|
+
.zc-overlay-panel--sheet-bottom[data-drag] > .zc-drp--sheet::before {
|
|
8
|
+
content: '';
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: var(--space-2);
|
|
11
|
+
inset-inline: 0;
|
|
12
|
+
width: var(--space-6);
|
|
13
|
+
height: var(--space-1);
|
|
14
|
+
margin-inline: auto;
|
|
15
|
+
border-radius: var(--radius-full);
|
|
16
|
+
background: var(--border-strong);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.zc-drp.zc-drp--sheet {
|
|
20
|
+
position: relative;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
background: none;
|
|
24
|
+
border: 0;
|
|
25
|
+
border-radius: inherit;
|
|
26
|
+
box-shadow: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.zc-drp--sheet .zc-drp__presets {
|
|
30
|
+
width: auto;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
gap: var(--space-2);
|
|
33
|
+
padding: 0 var(--space-4) var(--space-4);
|
|
34
|
+
border-right: 0;
|
|
35
|
+
overflow-x: auto;
|
|
36
|
+
scrollbar-width: none;
|
|
37
|
+
scroll-padding-inline: var(--space-4);
|
|
38
|
+
--_dtp-fade-start: 0px;
|
|
39
|
+
--_dtp-fade-end: 0px;
|
|
40
|
+
mask-image: linear-gradient(
|
|
41
|
+
to right,
|
|
42
|
+
transparent,
|
|
43
|
+
black var(--_dtp-fade-start),
|
|
44
|
+
black calc(100% - var(--_dtp-fade-end)),
|
|
45
|
+
transparent
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
.zc-drp--sheet .zc-drp__presets::-webkit-scrollbar {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
.zc-drp--sheet .zc-drp__presets[data-fade~='start'] {
|
|
52
|
+
--_dtp-fade-start: var(--space-7);
|
|
53
|
+
}
|
|
54
|
+
.zc-drp--sheet .zc-drp__presets[data-fade~='end'] {
|
|
55
|
+
--_dtp-fade-end: var(--space-7);
|
|
56
|
+
}
|
|
57
|
+
.zc-drp--sheet .zc-drp__preset {
|
|
58
|
+
flex: none;
|
|
59
|
+
padding-inline: var(--space-3);
|
|
60
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.zc-drp--sheet .zc-drp__months {
|
|
64
|
+
display: block;
|
|
65
|
+
padding: 0 var(--space-4);
|
|
66
|
+
overflow: visible clip;
|
|
67
|
+
}
|
|
68
|
+
.zc-drp--sheet .zc-drp__months .zc-dtp__cal {
|
|
69
|
+
padding: 0;
|
|
70
|
+
}
|
|
71
|
+
.zc-drp--sheet .zc-dtp__nav {
|
|
72
|
+
width: var(--control-height);
|
|
73
|
+
height: var(--control-height);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.zc-drp--sheet .zc-drp__foot {
|
|
77
|
+
padding: var(--space-4) var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
|
|
78
|
+
border-top: 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import './date-picker.css';
|
|
4
|
+
import './range-sheet.css';
|
|
5
|
+
import './range-sheet-days.css';
|
|
6
|
+
|
|
7
|
+
import { useLayoutEffect, useRef, type RefObject } from 'react';
|
|
8
|
+
|
|
9
|
+
import { animate, type Playback } from '../../../engine';
|
|
10
|
+
import { GlidePill } from '../../../motion/glide';
|
|
11
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
12
|
+
import type { ActivateOn } from '../../internal/utils/activation';
|
|
13
|
+
import { Button } from '../../primitives/button/Button';
|
|
14
|
+
import { monthSwipe } from './month-swipe';
|
|
15
|
+
import { RangeMonth } from './range-month';
|
|
16
|
+
import { RangePresets } from './range-presets';
|
|
17
|
+
import { RangeSummary } from './range-summary';
|
|
18
|
+
import { useRangePanel, type RangeOptions } from './use-range-panel';
|
|
19
|
+
|
|
20
|
+
interface DrpSheetProps extends Omit<RangeOptions, 'months'> {
|
|
21
|
+
title: string;
|
|
22
|
+
timezone?: string;
|
|
23
|
+
activateOn?: ActivateOn;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function useHeightGlide(ref: RefObject<HTMLElement | null>, viewIdx: number) {
|
|
27
|
+
const settled = useRef(0);
|
|
28
|
+
const flight = useRef<Playback | null>(null);
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
const el = ref.current;
|
|
31
|
+
if (!el) return;
|
|
32
|
+
const from = flight.current ? el.offsetHeight : settled.current;
|
|
33
|
+
flight.current?.stop();
|
|
34
|
+
settled.current = el.offsetHeight;
|
|
35
|
+
if (!from || from === settled.current) return;
|
|
36
|
+
const glide = animate(el, { height: [from, 'auto'], timing: motionFor(el).t.settle });
|
|
37
|
+
flight.current = glide;
|
|
38
|
+
glide?.finished.then(() => {
|
|
39
|
+
if (flight.current === glide) flight.current = null;
|
|
40
|
+
});
|
|
41
|
+
}, [ref, viewIdx]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function DrpSheet({ value, commit, close, min, max, maxDays, title, timezone, activateOn }: DrpSheetProps) {
|
|
45
|
+
const panel = useRangePanel({ value, commit, close, min, max, maxDays, months: 1 });
|
|
46
|
+
const { anchor, setHoverKey, daysRef, onGridKeyDown, gridGlide } = panel;
|
|
47
|
+
useHeightGlide(daysRef, panel.viewIdx);
|
|
48
|
+
return (
|
|
49
|
+
<div className="zc-drp zc-drp--sheet" role="dialog" aria-label={title}>
|
|
50
|
+
<RangeSummary panel={panel} title={title} timezone={timezone} />
|
|
51
|
+
<RangePresets draft={panel.draft} fits={panel.fits} onPick={panel.applyPreset} activateOn={activateOn} />
|
|
52
|
+
<div
|
|
53
|
+
className="zc-drp__months"
|
|
54
|
+
ref={daysRef}
|
|
55
|
+
onKeyDown={onGridKeyDown}
|
|
56
|
+
onPointerDown={monthSwipe(panel, min, max)}
|
|
57
|
+
onPointerLeave={() => {
|
|
58
|
+
if (anchor) setHoverKey(anchor);
|
|
59
|
+
gridGlide.leave();
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<RangeMonth panel={panel} offset={0} withPrev withNext min={min} max={max} months={1} activateOn={activateOn} />
|
|
63
|
+
<GlidePill className="zc-dtp__hover" glide={gridGlide} />
|
|
64
|
+
</div>
|
|
65
|
+
<div className="zc-drp__foot">
|
|
66
|
+
<Button variant="secondary" size="xl" fullWidth onClick={panel.done}>
|
|
67
|
+
Done
|
|
68
|
+
</Button>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@layer zyncat.components {
|
|
4
|
+
.zc-drp__summary {
|
|
5
|
+
display: grid;
|
|
6
|
+
gap: var(--space-3);
|
|
7
|
+
padding: var(--space-5) var(--space-4) var(--space-4);
|
|
8
|
+
}
|
|
9
|
+
.zc-drp__head {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
gap: var(--space-3);
|
|
14
|
+
}
|
|
15
|
+
.zc-drp__heading {
|
|
16
|
+
display: grid;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
}
|
|
19
|
+
.zc-drp__title {
|
|
20
|
+
font: var(--type-heading);
|
|
21
|
+
color: var(--text-strong);
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
}
|
|
26
|
+
.zc-drp__tiles {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--space-2);
|
|
31
|
+
}
|
|
32
|
+
.zc-drp__tile {
|
|
33
|
+
display: grid;
|
|
34
|
+
gap: var(--space-px);
|
|
35
|
+
padding: var(--space-2) var(--space-3);
|
|
36
|
+
border: var(--border-hairline) solid var(--border-subtle);
|
|
37
|
+
border-radius: var(--radius-md);
|
|
38
|
+
background: var(--bg-subtle);
|
|
39
|
+
opacity: 0.6;
|
|
40
|
+
transition: var(--transition-colors), var(--transition-opacity);
|
|
41
|
+
}
|
|
42
|
+
.zc-drp__tile.zc-is-active {
|
|
43
|
+
border-color: var(--border-strong);
|
|
44
|
+
opacity: 1;
|
|
45
|
+
}
|
|
46
|
+
.zc-drp__tileRole {
|
|
47
|
+
font: var(--type-micro);
|
|
48
|
+
letter-spacing: var(--tracking-caps);
|
|
49
|
+
text-transform: uppercase;
|
|
50
|
+
color: var(--text-subtle);
|
|
51
|
+
}
|
|
52
|
+
.zc-drp__tileDate {
|
|
53
|
+
font: var(--type-title);
|
|
54
|
+
font-variant-numeric: tabular-nums;
|
|
55
|
+
color: var(--text-strong);
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
text-overflow: ellipsis;
|
|
59
|
+
}
|
|
60
|
+
.zc-drp__tileDate.zc-is-empty {
|
|
61
|
+
font-weight: var(--weight-medium);
|
|
62
|
+
color: var(--text-subtle);
|
|
63
|
+
}
|
|
64
|
+
.zc-drp__arrow {
|
|
65
|
+
color: var(--text-subtle);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import './range-summary.css';
|
|
4
|
+
|
|
5
|
+
import { animate } from '../../../engine';
|
|
6
|
+
import { Motion } from '../../../motion/element';
|
|
7
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
8
|
+
import { Icon } from '../../internal/icon/Icon';
|
|
9
|
+
import { Badge } from '../../primitives/badge/Badge';
|
|
10
|
+
import { displayDay, tzLabel } from './date-utils';
|
|
11
|
+
import { drpDays } from './range-presets';
|
|
12
|
+
import type { RangePanel } from './use-range-panel';
|
|
13
|
+
|
|
14
|
+
function dateIn(el: HTMLElement) {
|
|
15
|
+
const motion = motionFor(el);
|
|
16
|
+
return animate(el, { y: [motion.dist.sm, 0], opacity: [0, 1], timing: motion.t.enter });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface TileProps {
|
|
20
|
+
role: string;
|
|
21
|
+
day: string | null;
|
|
22
|
+
active: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Tile({ role, day, active }: TileProps) {
|
|
26
|
+
return (
|
|
27
|
+
<span className={'zc-drp__tile' + (active ? ' zc-is-active' : '')}>
|
|
28
|
+
<span className="zc-drp__tileRole">{role}</span>
|
|
29
|
+
<Motion
|
|
30
|
+
as="span"
|
|
31
|
+
className={'zc-drp__tileDate' + (day ? '' : ' zc-is-empty')}
|
|
32
|
+
animate={dateIn}
|
|
33
|
+
deps={[day]}
|
|
34
|
+
initial={false}
|
|
35
|
+
>
|
|
36
|
+
{displayDay(day) || (active ? 'Pick a day' : 'Not set')}
|
|
37
|
+
</Motion>
|
|
38
|
+
</span>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface RangeSummaryProps {
|
|
43
|
+
panel: RangePanel;
|
|
44
|
+
title: string;
|
|
45
|
+
timezone?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function RangeSummary({ panel, title, timezone }: RangeSummaryProps) {
|
|
49
|
+
const { lo, hi, anchor, provisional } = panel;
|
|
50
|
+
const end = provisional && lo === hi ? null : hi;
|
|
51
|
+
const total = lo && end ? drpDays(lo, end) : 0;
|
|
52
|
+
const endMoving = provisional && lo === anchor;
|
|
53
|
+
return (
|
|
54
|
+
<div className="zc-drp__summary">
|
|
55
|
+
<div className="zc-drp__head">
|
|
56
|
+
<span className="zc-drp__heading">
|
|
57
|
+
<span className="zc-drp__title">{title}</span>
|
|
58
|
+
{timezone ? <span className="zc-drp__tz">{tzLabel(timezone)}</span> : null}
|
|
59
|
+
</span>
|
|
60
|
+
{total ? <Badge value={total + (total === 1 ? ' day' : ' days')} pill /> : null}
|
|
61
|
+
</div>
|
|
62
|
+
<div className="zc-drp__tiles" aria-live="polite">
|
|
63
|
+
<Tile role="Start" day={lo} active={!endMoving} />
|
|
64
|
+
<Icon name="caret-right" size="sm" className="zc-drp__arrow" />
|
|
65
|
+
<Tile role="End" day={end} active={endMoving} />
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -6,6 +6,7 @@ import { useEffect, useRef, useState, type ClipboardEvent, type KeyboardEvent, t
|
|
|
6
6
|
|
|
7
7
|
import { cx } from '../../internal/utils/cx';
|
|
8
8
|
import { pad } from './date-utils';
|
|
9
|
+
import { typedKey, type KeyLike } from './typed-key';
|
|
9
10
|
|
|
10
11
|
type Meridiem = 'AM' | 'PM';
|
|
11
12
|
type Segment = 'h' | 'm';
|
|
@@ -70,8 +71,8 @@ export function TimeSegments({
|
|
|
70
71
|
setPendState(v);
|
|
71
72
|
};
|
|
72
73
|
|
|
73
|
-
const hRef = useRef<
|
|
74
|
-
const mRef = useRef<
|
|
74
|
+
const hRef = useRef<HTMLInputElement>(null);
|
|
75
|
+
const mRef = useRef<HTMLInputElement>(null);
|
|
75
76
|
const merRef = useRef<HTMLSpanElement>(null);
|
|
76
77
|
const lastRef = useRef<string | null>(value || null);
|
|
77
78
|
|
|
@@ -102,11 +103,11 @@ export function TimeSegments({
|
|
|
102
103
|
if (onCommit) onCommit(t);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
const focusSeg = (r: RefObject<
|
|
106
|
+
const focusSeg = (r: RefObject<HTMLElement | null>) => {
|
|
106
107
|
if (r.current) r.current.focus();
|
|
107
108
|
};
|
|
108
109
|
|
|
109
|
-
function onHKey(e:
|
|
110
|
+
function onHKey(e: KeyLike) {
|
|
110
111
|
const k = e.key;
|
|
111
112
|
if (/^[0-9]$/.test(k)) {
|
|
112
113
|
const pd = pend && pend.seg === 'h' ? pend.d : null;
|
|
@@ -138,7 +139,7 @@ export function TimeSegments({
|
|
|
138
139
|
e.preventDefault();
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
function onMKey(e:
|
|
142
|
+
function onMKey(e: KeyLike) {
|
|
142
143
|
const k = e.key;
|
|
143
144
|
if (/^[0-9]$/.test(k)) {
|
|
144
145
|
const pd = pend && pend.seg === 'm' ? pend.d : null;
|
|
@@ -239,39 +240,41 @@ export function TimeSegments({
|
|
|
239
240
|
aria-disabled={disabled || undefined}
|
|
240
241
|
onPaste={onPaste}
|
|
241
242
|
>
|
|
242
|
-
<
|
|
243
|
+
<input
|
|
243
244
|
ref={hRef}
|
|
244
245
|
className={segCls(h == null && !(pend && pend.seg === 'h'))}
|
|
245
246
|
role="spinbutton"
|
|
246
|
-
|
|
247
|
+
inputMode="numeric"
|
|
248
|
+
disabled={disabled}
|
|
249
|
+
value={hText}
|
|
247
250
|
aria-label="Hours"
|
|
248
251
|
aria-valuemin={is12 ? 1 : 0}
|
|
249
252
|
aria-valuemax={is12 ? 12 : 23}
|
|
250
253
|
aria-valuenow={h == null ? undefined : is12 ? disp12(h) : h}
|
|
251
254
|
aria-valuetext={h == null ? 'Empty' : hText}
|
|
252
|
-
onKeyDown={
|
|
255
|
+
onKeyDown={onHKey}
|
|
256
|
+
onChange={(e) => onHKey(typedKey(e))}
|
|
253
257
|
onBlur={onSegBlur('h')}
|
|
254
|
-
|
|
255
|
-
{hText}
|
|
256
|
-
</span>
|
|
258
|
+
/>
|
|
257
259
|
<span className="zc-tsg__sep" aria-hidden="true">
|
|
258
260
|
:
|
|
259
261
|
</span>
|
|
260
|
-
<
|
|
262
|
+
<input
|
|
261
263
|
ref={mRef}
|
|
262
264
|
className={segCls(m == null && !(pend && pend.seg === 'm'))}
|
|
263
265
|
role="spinbutton"
|
|
264
|
-
|
|
266
|
+
inputMode="numeric"
|
|
267
|
+
disabled={disabled}
|
|
268
|
+
value={mText}
|
|
265
269
|
aria-label="Minutes"
|
|
266
270
|
aria-valuemin={0}
|
|
267
271
|
aria-valuemax={59}
|
|
268
272
|
aria-valuenow={m == null ? undefined : m}
|
|
269
273
|
aria-valuetext={m == null ? 'Empty' : mText}
|
|
270
|
-
onKeyDown={
|
|
274
|
+
onKeyDown={onMKey}
|
|
275
|
+
onChange={(e) => onMKey(typedKey(e))}
|
|
271
276
|
onBlur={onSegBlur('m')}
|
|
272
|
-
|
|
273
|
-
{mText}
|
|
274
|
-
</span>
|
|
277
|
+
/>
|
|
275
278
|
{is12 ? (
|
|
276
279
|
<span
|
|
277
280
|
ref={merRef}
|
|
@@ -281,6 +284,9 @@ export function TimeSegments({
|
|
|
281
284
|
aria-label="AM or PM"
|
|
282
285
|
aria-valuetext={mer}
|
|
283
286
|
onKeyDown={disabled ? undefined : onMerKey}
|
|
287
|
+
onPointerUp={(e) => {
|
|
288
|
+
if (!disabled && e.pointerType !== 'mouse') setMeridiem(mer === 'AM' ? 'PM' : 'AM');
|
|
289
|
+
}}
|
|
284
290
|
>
|
|
285
291
|
{mer}
|
|
286
292
|
</span>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChangeEvent, KeyboardEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
export type KeyLike = Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'preventDefault'>;
|
|
4
|
+
|
|
5
|
+
export function typedKey(e: ChangeEvent<HTMLInputElement>): KeyLike {
|
|
6
|
+
const input = e.nativeEvent instanceof InputEvent ? e.nativeEvent : null;
|
|
7
|
+
const key = input?.inputType.startsWith('delete') ? 'Backspace' : (input?.data ?? '').slice(-1);
|
|
8
|
+
return { key, metaKey: false, ctrlKey: false, preventDefault: () => {} };
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
export function useMonthView(seed: Date) {
|
|
6
|
+
const [view, setView] = useState<{ y: number; m: number }>({ y: seed.getFullYear(), m: seed.getMonth() });
|
|
7
|
+
const viewIdx = view.y * 12 + view.m;
|
|
8
|
+
|
|
9
|
+
function nav(dir: number) {
|
|
10
|
+
setView((v) => {
|
|
11
|
+
const d = new Date(v.y, v.m + dir, 1);
|
|
12
|
+
return { y: d.getFullYear(), m: d.getMonth() };
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const prevViewIdxRef = useRef(viewIdx);
|
|
17
|
+
const jumpedRef = useRef(false);
|
|
18
|
+
const navDir =
|
|
19
|
+
prevViewIdxRef.current === viewIdx || jumpedRef.current ? 0 : viewIdx > prevViewIdxRef.current ? 1 : -1;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
prevViewIdxRef.current = viewIdx;
|
|
22
|
+
jumpedRef.current = false;
|
|
23
|
+
}, [viewIdx]);
|
|
24
|
+
|
|
25
|
+
function jumpToMonth(y: number, m: number, offset: number) {
|
|
26
|
+
jumpedRef.current = true;
|
|
27
|
+
const base = new Date(y, m - offset, 1);
|
|
28
|
+
setView({ y: base.getFullYear(), m: base.getMonth() });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { view, setView, viewIdx, nav, navDir, jumpToMonth };
|
|
32
|
+
}
|