@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
|
@@ -6,18 +6,16 @@ import type { DataAttributes } from '../../../dom-props';
|
|
|
6
6
|
import { usePressFeedback } from '../../internal/hooks/use-press-feedback';
|
|
7
7
|
import { cx } from '../../internal/utils/cx';
|
|
8
8
|
import { Spinner } from '../spinner/Spinner';
|
|
9
|
-
import { buttonClass, type
|
|
9
|
+
import { buttonClass, type ButtonStyleProps, type ButtonVariant } from './button-style';
|
|
10
10
|
|
|
11
11
|
export { buttonClass } from './button-style';
|
|
12
12
|
export type { ButtonSize, ButtonStyleProps, ButtonVariant } from './button-style';
|
|
13
13
|
|
|
14
|
-
interface ButtonOwnProps {
|
|
14
|
+
interface ButtonOwnProps extends Pick<ButtonStyleProps, 'size' | 'iconOnly' | 'fullWidth'> {
|
|
15
15
|
/** Visual weight / intent. @default 'primary' */
|
|
16
16
|
variant?: ButtonVariant;
|
|
17
17
|
/** Forwarded to the underlying <button> (React 19 ref-as-prop). */
|
|
18
18
|
ref?: Ref<HTMLButtonElement>;
|
|
19
|
-
/** Control height. sm 28px - md 32px (default) - lg 37px. @default 'md' */
|
|
20
|
-
size?: ButtonSize;
|
|
21
19
|
/** `submit` / `reset` / `button`. @default 'button' */
|
|
22
20
|
type?: 'button' | 'submit' | 'reset';
|
|
23
21
|
/** Disable the control (also implied by `loading`). */
|
|
@@ -25,13 +23,11 @@ interface ButtonOwnProps {
|
|
|
25
23
|
/** Loading - swaps the label for a spinner and makes the button inert. The label stays
|
|
26
24
|
* mounted but invisible, so the button holds its width. */
|
|
27
25
|
loading?: boolean;
|
|
28
|
-
/** Stretch to fill the container width. */
|
|
29
|
-
fullWidth?: boolean;
|
|
30
26
|
/** Extra class(es) merged onto the button. */
|
|
31
27
|
className?: string;
|
|
32
28
|
/** Inline styles merged onto the button. */
|
|
33
29
|
style?: CSSProperties;
|
|
34
|
-
/** Button label. */
|
|
30
|
+
/** Button label. An svg child takes the size's glyph; a class or style of your own on it wins. */
|
|
35
31
|
children?: ReactNode;
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -53,6 +49,7 @@ export interface ButtonProps extends ButtonOwnProps, ButtonRestProps {
|
|
|
53
49
|
export function Button({
|
|
54
50
|
variant = 'primary',
|
|
55
51
|
size = 'md',
|
|
52
|
+
iconOnly = false,
|
|
56
53
|
type = 'button',
|
|
57
54
|
disabled = false,
|
|
58
55
|
loading = false,
|
|
@@ -66,7 +63,7 @@ export function Button({
|
|
|
66
63
|
}: ButtonProps) {
|
|
67
64
|
const inert = disabled || loading;
|
|
68
65
|
const press = usePressFeedback(inert);
|
|
69
|
-
const cls = cx(buttonClass({ variant, size, fullWidth, className }), loading && 'zc-is-loading');
|
|
66
|
+
const cls = cx(buttonClass({ variant, size, iconOnly, fullWidth, className }), loading && 'zc-is-loading');
|
|
70
67
|
const merged = { ...rest, ...htmlProps };
|
|
71
68
|
|
|
72
69
|
return (
|
|
@@ -5,10 +5,11 @@ Docs: https://ui.zyncat.app/button
|
|
|
5
5
|
|
|
6
6
|
One control for every click; exactly one primary per view.
|
|
7
7
|
|
|
8
|
-
variant primary|secondary|ghost|danger|link, size sm|md|lg|
|
|
9
|
-
children - Button lays them out in a centered row with gap
|
|
8
|
+
variant primary|secondary|ghost|danger|link, size xs|sm|md|lg|xl, iconOnly, loading, disabled. Icons
|
|
9
|
+
are plain children - Button lays them out in a centered row with gap and sizes an svg to the size's
|
|
10
|
+
glyph, no iconLeft/iconRight slots.
|
|
10
11
|
|
|
11
12
|
```tsx
|
|
12
|
-
<Button variant="primary"><
|
|
13
|
-
<Button size="
|
|
13
|
+
<Button variant="primary"><PlusIcon />Schedule post</Button>
|
|
14
|
+
<Button size="sm" iconOnly aria-label="Close"><XIcon /></Button>
|
|
14
15
|
```
|
|
@@ -3,25 +3,31 @@ import './button.css';
|
|
|
3
3
|
import { cx } from '../../internal/utils/cx';
|
|
4
4
|
|
|
5
5
|
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'link';
|
|
6
|
-
export type ButtonSize = 'sm' | 'md' | 'lg' | '
|
|
6
|
+
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
7
|
|
|
8
8
|
export interface ButtonStyleProps {
|
|
9
9
|
/** Visual weight / intent. Omit for base chrome only - sizing, focus ring, layout -
|
|
10
10
|
* with no skin, for a local re-skin through `className`. */
|
|
11
11
|
variant?: ButtonVariant;
|
|
12
|
-
/** Control height
|
|
13
|
-
size
|
|
12
|
+
/** Control height: the `--control-height-*` step, so it lines up with a field of the same size.
|
|
13
|
+
* Type, padding and glyph step with it. `'icon'` is deprecated: it is `size="sm" iconOnly`.
|
|
14
|
+
* @default 'md' */
|
|
15
|
+
size?: ButtonSize | 'icon';
|
|
16
|
+
/** A square of the control height for one glyph. Name it with `aria-label`. @default false */
|
|
17
|
+
iconOnly?: boolean;
|
|
14
18
|
/** Stretch to fill the container width. */
|
|
15
19
|
fullWidth?: boolean;
|
|
16
20
|
/** Extra class(es) merged onto the result. */
|
|
17
21
|
className?: string;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
export function buttonClass({ variant, size = 'md', fullWidth, className }: ButtonStyleProps = {}): string {
|
|
24
|
+
export function buttonClass({ variant, size = 'md', iconOnly, fullWidth, className }: ButtonStyleProps = {}): string {
|
|
25
|
+
const step = size === 'icon' ? 'sm' : size;
|
|
21
26
|
return cx(
|
|
22
27
|
'zc-btn',
|
|
23
28
|
variant && `zc-btn--${variant}`,
|
|
24
|
-
|
|
29
|
+
step !== 'md' && `zc-btn--${step}`,
|
|
30
|
+
(iconOnly || size === 'icon') && 'zc-btn--icon',
|
|
25
31
|
fullWidth && 'zc-btn--block',
|
|
26
32
|
className,
|
|
27
33
|
);
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
@layer zyncat.components {
|
|
15
15
|
.zc-btn {
|
|
16
|
+
--btn-h: var(--control-height);
|
|
17
|
+
--btn-glyph: calc((var(--btn-h) - var(--space-1)) / 2);
|
|
16
18
|
--btn-shadow: none;
|
|
17
19
|
--btn-ring: var(--ring-accent);
|
|
18
20
|
--btn-gap: var(--space-2);
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
justify-content: center;
|
|
27
29
|
gap: var(--btn-gap);
|
|
28
30
|
|
|
29
|
-
height: var(--
|
|
31
|
+
height: var(--btn-h);
|
|
30
32
|
padding: 0 var(--space-4);
|
|
31
33
|
border: var(--border-hairline) solid transparent;
|
|
32
34
|
border-radius: var(--radius-md);
|
|
@@ -43,7 +45,6 @@
|
|
|
43
45
|
cursor: pointer;
|
|
44
46
|
user-select: none;
|
|
45
47
|
-webkit-user-select: none;
|
|
46
|
-
-webkit-tap-highlight-color: transparent;
|
|
47
48
|
appearance: none;
|
|
48
49
|
box-shadow: var(--btn-shadow);
|
|
49
50
|
|
|
@@ -68,26 +69,35 @@
|
|
|
68
69
|
transform: scale(var(--btn-press-scale));
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
.zc-btn--xs,
|
|
71
73
|
.zc-btn--sm {
|
|
72
|
-
|
|
73
|
-
padding: 0 var(--space-3);
|
|
74
|
+
--btn-gap: var(--space-1);
|
|
74
75
|
font-size: var(--size-caption);
|
|
75
76
|
border-radius: var(--radius-sm);
|
|
76
|
-
|
|
77
|
+
}
|
|
78
|
+
.zc-btn--xs {
|
|
79
|
+
--btn-h: var(--control-height-xs);
|
|
80
|
+
padding: 0 var(--space-2);
|
|
81
|
+
}
|
|
82
|
+
.zc-btn--sm {
|
|
83
|
+
--btn-h: var(--control-height-sm);
|
|
84
|
+
padding: 0 var(--space-3);
|
|
77
85
|
}
|
|
78
86
|
.zc-btn--lg {
|
|
79
|
-
|
|
87
|
+
--btn-h: var(--control-height-lg);
|
|
80
88
|
padding: 0 var(--space-5);
|
|
81
|
-
|
|
89
|
+
}
|
|
90
|
+
.zc-btn--xl {
|
|
91
|
+
--btn-h: var(--control-height-xl);
|
|
92
|
+
padding: 0 var(--space-6);
|
|
93
|
+
font-size: var(--size-body-lg);
|
|
82
94
|
}
|
|
83
95
|
.zc-btn--block {
|
|
84
96
|
width: 100%;
|
|
85
97
|
}
|
|
86
98
|
.zc-btn--icon {
|
|
87
|
-
width: var(--
|
|
88
|
-
height: var(--control-height-sm);
|
|
99
|
+
width: var(--btn-h);
|
|
89
100
|
padding: 0;
|
|
90
|
-
border-radius: var(--radius-sm);
|
|
91
101
|
}
|
|
92
102
|
|
|
93
103
|
.zc-btn__label {
|
|
@@ -96,22 +106,10 @@
|
|
|
96
106
|
gap: var(--btn-gap);
|
|
97
107
|
}
|
|
98
108
|
|
|
99
|
-
.zc-
|
|
100
|
-
display: inline-flex;
|
|
109
|
+
.zc-btn__label > svg {
|
|
101
110
|
flex: none;
|
|
102
|
-
width:
|
|
103
|
-
height:
|
|
104
|
-
}
|
|
105
|
-
.zc-btn__icon svg {
|
|
106
|
-
display: block;
|
|
107
|
-
width: 100%;
|
|
108
|
-
height: 100%;
|
|
109
|
-
}
|
|
110
|
-
.zc-btn__icon:first-child {
|
|
111
|
-
margin-left: calc(var(--space-1) * -1);
|
|
112
|
-
}
|
|
113
|
-
.zc-btn__icon:last-child {
|
|
114
|
-
margin-right: calc(var(--space-1) * -1);
|
|
111
|
+
width: var(--btn-glyph);
|
|
112
|
+
height: var(--btn-glyph);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
.zc-btn--primary {
|
|
@@ -273,8 +271,7 @@
|
|
|
273
271
|
text-decoration: none;
|
|
274
272
|
}
|
|
275
273
|
|
|
276
|
-
.zc-btn.zc-is-loading .zc-btn__label
|
|
277
|
-
.zc-btn.zc-is-loading .zc-btn__icon {
|
|
274
|
+
.zc-btn.zc-is-loading .zc-btn__label {
|
|
278
275
|
opacity: 0;
|
|
279
276
|
}
|
|
280
277
|
.zc-btn__spinner {
|
|
@@ -33,8 +33,9 @@ interface CollapseOwnProps extends TimingProps {
|
|
|
33
33
|
axis?: 'height' | 'width';
|
|
34
34
|
/** Also cross-fade contents while resizing; follows `duration` / `ease`. */
|
|
35
35
|
fade?: boolean;
|
|
36
|
-
/** Class applied to the inner
|
|
37
|
-
*
|
|
36
|
+
/** Class applied to the inner wrapper - the clipping element (`overflow: clip` on the animated
|
|
37
|
+
* axis). Its padding stays while closed, so content whose focus ring sits flush to the clipped
|
|
38
|
+
* edge gets its room as `var(--ring-gutter)` of padding on a child. */
|
|
38
39
|
innerClassName?: string;
|
|
39
40
|
/** Size (and fade) transition timing - motion tokens only, each field one token or
|
|
40
41
|
* `{ open, close }`, e.g. `{ duration: { close: 'fast' }, ease: { close: 'exit' } }`.
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import './input.css';
|
|
4
4
|
|
|
5
|
-
import { useId
|
|
5
|
+
import { useId } from 'react';
|
|
6
6
|
import type { CSSProperties, InputHTMLAttributes } from 'react';
|
|
7
7
|
|
|
8
8
|
import type { DataAttributes } from '../../../dom-props';
|
|
9
|
-
import {
|
|
9
|
+
import { useHoldRepeat } from '../../internal/hooks/use-hold-repeat';
|
|
10
10
|
import { Icon } from '../../internal/icon/Icon';
|
|
11
11
|
import { cx } from '../../internal/utils/cx';
|
|
12
12
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type FieldCoreMessagingProps,
|
|
18
18
|
type FieldIdProps,
|
|
19
19
|
} from './field-chrome';
|
|
20
|
+
import { useNumberValue } from './use-number-value';
|
|
20
21
|
|
|
21
22
|
interface NumberFieldOwnProps extends FieldIdProps, FieldCoreMessagingProps {
|
|
22
23
|
/** Unit suffix shown inside the field (e.g. "days", "%"). */
|
|
@@ -25,7 +26,7 @@ interface NumberFieldOwnProps extends FieldIdProps, FieldCoreMessagingProps {
|
|
|
25
26
|
min?: number;
|
|
26
27
|
/** Maximum value - steps and committed typing clamp down to this; the increase stepper disables here. @default Infinity */
|
|
27
28
|
max?: number;
|
|
28
|
-
/** Amount added/removed per ArrowUp/ArrowDown press and per
|
|
29
|
+
/** Amount added/removed per ArrowUp/ArrowDown press and per minus/plus click; holding a button repeats it. Decimals work. @default 1 */
|
|
29
30
|
step?: number;
|
|
30
31
|
/** Controlled numeric value. Omit for uncontrolled (use `defaultValue`). */
|
|
31
32
|
value?: number | string;
|
|
@@ -52,6 +53,12 @@ export interface NumberFieldProps extends NumberFieldOwnProps {
|
|
|
52
53
|
DataAttributes;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
const STEPPERS = [
|
|
57
|
+
{ direction: -1, label: 'Decrease', icon: 'minus' },
|
|
58
|
+
{ direction: 1, label: 'Increase', icon: 'plus' },
|
|
59
|
+
] as const;
|
|
60
|
+
const ARROW_STEP: Partial<Record<string, 1 | -1>> = { ArrowUp: 1, ArrowDown: -1 };
|
|
61
|
+
|
|
55
62
|
export function NumberField({
|
|
56
63
|
id,
|
|
57
64
|
label,
|
|
@@ -71,22 +78,14 @@ export function NumberField({
|
|
|
71
78
|
htmlProps,
|
|
72
79
|
}: NumberFieldProps) {
|
|
73
80
|
const autoId = useId();
|
|
81
|
+
const fieldId = id ?? autoId;
|
|
74
82
|
const message = error || helper;
|
|
75
|
-
const msgId = fieldMessageId(
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const [draft, setDraft] = useState<string | null>(null);
|
|
79
|
-
const v = draft !== null ? parseFloat(draft) || 0 : num;
|
|
80
|
-
const snap = (n: number) => parseFloat(n.toFixed(10));
|
|
81
|
-
const clamp = (n: number) => Math.min(max, Math.max(min, snap(n)));
|
|
82
|
-
const commit = (n: number) => {
|
|
83
|
-
setDraft(null);
|
|
84
|
-
setNum(clamp(n));
|
|
85
|
-
};
|
|
83
|
+
const msgId = fieldMessageId(fieldId, message);
|
|
84
|
+
const { v, text, commit, stepBy, type } = useNumberValue({ value, defaultValue, onChange, min, max, step });
|
|
85
|
+
const holdStep = useHoldRepeat(stepBy);
|
|
86
86
|
const cls = cx(
|
|
87
87
|
'zc-fld',
|
|
88
88
|
'zc-numf',
|
|
89
|
-
unit && 'zc-numf--unit',
|
|
90
89
|
size === 'sm' ? 'zc-fld--sm' : size === 'lg' ? 'zc-fld--lg' : '',
|
|
91
90
|
error && 'zc-is-error',
|
|
92
91
|
className,
|
|
@@ -94,30 +93,30 @@ export function NumberField({
|
|
|
94
93
|
|
|
95
94
|
return (
|
|
96
95
|
<div className={cls} style={style}>
|
|
97
|
-
<FieldLabel id={
|
|
98
|
-
<div
|
|
96
|
+
<FieldLabel id={fieldId} label={label} />
|
|
97
|
+
<div
|
|
98
|
+
className="zc-fld__control"
|
|
99
|
+
style={{ '--numf-len': text.length, '--numf-unit-len': unit?.length } as CSSProperties}
|
|
100
|
+
>
|
|
99
101
|
<input
|
|
100
|
-
id={
|
|
102
|
+
id={fieldId}
|
|
101
103
|
className="zc-fld__input"
|
|
102
104
|
type="text"
|
|
103
105
|
inputMode="decimal"
|
|
106
|
+
role="spinbutton"
|
|
107
|
+
aria-valuenow={v}
|
|
108
|
+
aria-valuemin={min}
|
|
109
|
+
aria-valuemax={max === Infinity ? undefined : max}
|
|
104
110
|
disabled={disabled}
|
|
105
111
|
aria-invalid={error ? true : undefined}
|
|
106
|
-
value={
|
|
107
|
-
onChange={(e) =>
|
|
108
|
-
const text = e.target.value.replace(/[^\d.-]/g, '');
|
|
109
|
-
setDraft(text);
|
|
110
|
-
setNum(clamp(parseFloat(text) || 0));
|
|
111
|
-
}}
|
|
112
|
+
value={text}
|
|
113
|
+
onChange={(e) => type(e.target.value)}
|
|
112
114
|
onBlur={() => commit(v)}
|
|
113
115
|
onKeyDown={(e) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
commit(v + step);
|
|
117
|
-
}
|
|
118
|
-
if (e.key === 'ArrowDown') {
|
|
116
|
+
const direction = ARROW_STEP[e.key];
|
|
117
|
+
if (direction) {
|
|
119
118
|
e.preventDefault();
|
|
120
|
-
|
|
119
|
+
stepBy(direction);
|
|
121
120
|
}
|
|
122
121
|
if (e.key === 'Enter') commit(v);
|
|
123
122
|
}}
|
|
@@ -125,26 +124,19 @@ export function NumberField({
|
|
|
125
124
|
aria-describedby={joinIds(msgId, htmlProps?.['aria-describedby'])}
|
|
126
125
|
/>
|
|
127
126
|
{unit && <span className="zc-numf__unit">{unit}</span>}
|
|
128
|
-
|
|
129
|
-
<button
|
|
130
|
-
type="button"
|
|
131
|
-
className="zc-numf__step"
|
|
132
|
-
aria-label="Increase"
|
|
133
|
-
disabled={disabled || v >= max}
|
|
134
|
-
onClick={() => commit(v + step)}
|
|
135
|
-
>
|
|
136
|
-
<Icon name="caret-up" size="sm" />
|
|
137
|
-
</button>
|
|
127
|
+
{STEPPERS.map(({ direction, label, icon }) => (
|
|
138
128
|
<button
|
|
129
|
+
key={icon}
|
|
139
130
|
type="button"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
tabIndex={-1}
|
|
132
|
+
className={`zc-numf__step zc-numf__step--${icon}`}
|
|
133
|
+
aria-label={label}
|
|
134
|
+
disabled={disabled || (direction > 0 ? v >= max : v <= min)}
|
|
135
|
+
{...holdStep(direction)}
|
|
144
136
|
>
|
|
145
|
-
<Icon name=
|
|
137
|
+
<Icon name={icon} size="sm" />
|
|
146
138
|
</button>
|
|
147
|
-
|
|
139
|
+
))}
|
|
148
140
|
</div>
|
|
149
141
|
<FieldMessage id={msgId} message={message} icon={error ? 'warning-circle' : null} />
|
|
150
142
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import './input.css';
|
|
4
4
|
|
|
5
|
-
import { useRef } from 'react';
|
|
5
|
+
import { useLayoutEffect, useRef } from 'react';
|
|
6
6
|
import type {
|
|
7
7
|
ChangeEvent,
|
|
8
8
|
ClipboardEvent,
|
|
@@ -15,8 +15,13 @@ import type {
|
|
|
15
15
|
} from 'react';
|
|
16
16
|
|
|
17
17
|
import type { DataAttributes } from '../../../dom-props';
|
|
18
|
+
import { animate } from '../../../engine';
|
|
19
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
18
20
|
import { cx } from '../../internal/utils/cx';
|
|
19
21
|
|
|
22
|
+
const ACCEPT_LIFT = 1.08;
|
|
23
|
+
const ACCEPT_STAGGER = 0.03;
|
|
24
|
+
|
|
20
25
|
interface OtpFieldOwnProps {
|
|
21
26
|
/** Number of slots. @default 6 */
|
|
22
27
|
length?: number;
|
|
@@ -28,6 +33,10 @@ interface OtpFieldOwnProps {
|
|
|
28
33
|
group?: number;
|
|
29
34
|
/** Error state (red slots + ring). */
|
|
30
35
|
error?: boolean;
|
|
36
|
+
/** Accepted state: the slots take the accent, and a ripple runs across them as it turns on. */
|
|
37
|
+
success?: boolean;
|
|
38
|
+
/** Keep the digits on show but refuse edits - while the code is being checked. */
|
|
39
|
+
readOnly?: boolean;
|
|
31
40
|
/** Disable every slot. */
|
|
32
41
|
disabled?: boolean;
|
|
33
42
|
/** Slot width, height and digit type. @default 'md' */
|
|
@@ -49,6 +58,8 @@ export function OtpField({
|
|
|
49
58
|
onChange,
|
|
50
59
|
group,
|
|
51
60
|
error,
|
|
61
|
+
success,
|
|
62
|
+
readOnly,
|
|
52
63
|
disabled,
|
|
53
64
|
size = 'md',
|
|
54
65
|
className = '',
|
|
@@ -56,6 +67,20 @@ export function OtpField({
|
|
|
56
67
|
htmlProps,
|
|
57
68
|
}: OtpFieldProps) {
|
|
58
69
|
const refs = useRef<(HTMLInputElement | null)[]>([]);
|
|
70
|
+
const accepted = useRef(Boolean(success));
|
|
71
|
+
useLayoutEffect(() => {
|
|
72
|
+
const was = accepted.current;
|
|
73
|
+
accepted.current = Boolean(success);
|
|
74
|
+
if (!success || was) return;
|
|
75
|
+
refs.current.forEach((slot, i) => {
|
|
76
|
+
if (!slot) return;
|
|
77
|
+
const motion = motionFor(slot);
|
|
78
|
+
animate(slot, {
|
|
79
|
+
scale: [1, ACCEPT_LIFT, 1],
|
|
80
|
+
timing: { duration: motion.dur.moderate, ease: motion.ease.entrance, delay: i * ACCEPT_STAGGER },
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}, [success]);
|
|
59
84
|
const chars = String(value).slice(0, length).padEnd(length).split('');
|
|
60
85
|
const emit = (s: string) => onChange && onChange(s.replace(/ +$/, '').slice(0, length));
|
|
61
86
|
const setAt = (i: number, ch: string) => {
|
|
@@ -86,7 +111,13 @@ export function OtpField({
|
|
|
86
111
|
go(Math.min(start + digits.length, length - 1));
|
|
87
112
|
};
|
|
88
113
|
|
|
89
|
-
const cls = cx(
|
|
114
|
+
const cls = cx(
|
|
115
|
+
'zc-otp',
|
|
116
|
+
size === 'sm' && 'zc-otp--sm',
|
|
117
|
+
error && 'zc-is-error',
|
|
118
|
+
success && 'zc-is-success',
|
|
119
|
+
className,
|
|
120
|
+
);
|
|
90
121
|
|
|
91
122
|
const cells: ReactNode[] = [];
|
|
92
123
|
for (let i = 0; i < length; i++) {
|
|
@@ -101,7 +132,9 @@ export function OtpField({
|
|
|
101
132
|
inputMode="numeric"
|
|
102
133
|
autoComplete="one-time-code"
|
|
103
134
|
disabled={disabled}
|
|
135
|
+
readOnly={readOnly}
|
|
104
136
|
aria-invalid={error || undefined}
|
|
137
|
+
style={{ '--_otp-delay': `${i * ACCEPT_STAGGER}s` } as CSSProperties}
|
|
105
138
|
value={chars[i].trim()}
|
|
106
139
|
data-filled={chars[i].trim() ? 'true' : 'false'}
|
|
107
140
|
onFocus={(e: FocusEvent<HTMLInputElement>) => caretEnd(e.target)}
|
|
@@ -5,7 +5,8 @@ Docs: https://ui.zyncat.app/otp-field
|
|
|
5
5
|
|
|
6
6
|
Segmented one-time code; auto-advance, paste-to-fill.
|
|
7
7
|
|
|
8
|
-
length, group, error, size.
|
|
8
|
+
length, group, error, success, readOnly, size. `success` tints the slots with the accent and
|
|
9
|
+
ripples across them as it turns on; `readOnly` holds the digits while the code is checked.
|
|
9
10
|
|
|
10
11
|
```tsx
|
|
11
12
|
<OtpField length={6} group={3} value={code} onChange={setCode} />
|
|
@@ -37,7 +37,7 @@ interface TextFieldOwnProps extends FieldMessagingProps, TextFieldNative {
|
|
|
37
37
|
leadingIcon?: ReactNode;
|
|
38
38
|
/** Show a clear button when there's a value. */
|
|
39
39
|
clearable?: boolean;
|
|
40
|
-
/** Control height:
|
|
40
|
+
/** Control height: the `--control-height-*` step of the same name, md by default. */
|
|
41
41
|
size?: 'sm' | 'md' | 'lg';
|
|
42
42
|
/** Extra class(es) merged onto the field root. */
|
|
43
43
|
className?: string;
|
|
@@ -71,7 +71,8 @@ export function TextField({
|
|
|
71
71
|
const { state, msg, msgIcon } = resolveFieldMessage(error, warning, success, helper);
|
|
72
72
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
73
73
|
const autoId = useId();
|
|
74
|
-
const
|
|
74
|
+
const fieldId = rest.id ?? autoId;
|
|
75
|
+
const msgId = fieldMessageId(fieldId, msg);
|
|
75
76
|
const showClear = clearable && value && !rest.disabled && !rest.readOnly;
|
|
76
77
|
|
|
77
78
|
function clear() {
|
|
@@ -93,7 +94,7 @@ export function TextField({
|
|
|
93
94
|
|
|
94
95
|
return (
|
|
95
96
|
<div className={cls} style={style}>
|
|
96
|
-
<FieldLabel id={
|
|
97
|
+
<FieldLabel id={fieldId} label={label} required={rest.required} optional={optional} />
|
|
97
98
|
<div className="zc-fld__control">
|
|
98
99
|
{leadingIcon && (
|
|
99
100
|
<span className="zc-fld__icon zc-fld__icon--lead">
|
|
@@ -106,6 +107,7 @@ export function TextField({
|
|
|
106
107
|
value={value}
|
|
107
108
|
aria-invalid={error ? true : undefined}
|
|
108
109
|
{...rest}
|
|
110
|
+
id={fieldId}
|
|
109
111
|
{...htmlProps}
|
|
110
112
|
aria-describedby={joinIds(msgId, htmlProps?.['aria-describedby'])}
|
|
111
113
|
/>
|
|
@@ -38,12 +38,13 @@ export interface FieldMessagingProps extends FieldIdProps, FieldRequirementProps
|
|
|
38
38
|
export interface FieldLabelProps extends FieldIdProps, FieldRequirementProps {
|
|
39
39
|
/** Label text (sentence case). */
|
|
40
40
|
label?: ReactNode;
|
|
41
|
+
labelId?: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export function FieldLabel({ id, label, required, optional }: FieldLabelProps) {
|
|
44
|
+
export function FieldLabel({ id, labelId, label, required, optional }: FieldLabelProps) {
|
|
44
45
|
if (!label) return null;
|
|
45
46
|
return (
|
|
46
|
-
<label className="zc-fld__label" htmlFor={id}>
|
|
47
|
+
<label className="zc-fld__label" id={labelId} htmlFor={id}>
|
|
47
48
|
{label}
|
|
48
49
|
{required && (
|
|
49
50
|
<span className="zc-fld__req" aria-hidden="true">
|
|
@@ -177,48 +177,63 @@
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
.zc-numf {
|
|
180
|
-
--numf-
|
|
180
|
+
--numf-h: var(--control-height);
|
|
181
|
+
--numf-inset: var(--space-1);
|
|
182
|
+
}
|
|
183
|
+
.zc-numf.zc-fld--sm {
|
|
184
|
+
--numf-h: var(--control-height-sm);
|
|
185
|
+
}
|
|
186
|
+
.zc-numf.zc-fld--lg {
|
|
187
|
+
--numf-h: var(--control-height-lg);
|
|
181
188
|
}
|
|
182
189
|
.zc-numf .zc-fld__input {
|
|
190
|
+
padding-inline: var(--numf-h);
|
|
191
|
+
text-align: center;
|
|
183
192
|
font-variant-numeric: tabular-nums;
|
|
184
193
|
font-feature-settings: 'tnum';
|
|
185
|
-
padding-right: calc(var(--numf-stepper-w) + var(--space-2));
|
|
186
194
|
}
|
|
187
|
-
.zc-
|
|
188
|
-
padding-right:
|
|
195
|
+
.zc-fld__control:has(.zc-numf__unit) .zc-fld__input {
|
|
196
|
+
padding-right: clamp(
|
|
197
|
+
var(--numf-h),
|
|
198
|
+
var(--numf-h) + var(--numf-unit-len) * 1ch + var(--space-1),
|
|
199
|
+
100% - var(--numf-h) - 2 * var(--border-hairline)
|
|
200
|
+
);
|
|
189
201
|
}
|
|
190
202
|
.zc-numf__unit {
|
|
191
203
|
position: absolute;
|
|
192
|
-
|
|
204
|
+
left: min(
|
|
205
|
+
50% + (var(--numf-len) - var(--numf-unit-len)) * 0.5ch + var(--space-1) / 2,
|
|
206
|
+
100% - var(--numf-h) - var(--numf-unit-len) * 1ch
|
|
207
|
+
);
|
|
208
|
+
font: var(--type-body);
|
|
209
|
+
font-variant-numeric: tabular-nums;
|
|
193
210
|
color: var(--text-subtle);
|
|
194
|
-
font: var(--type-caption);
|
|
195
211
|
pointer-events: none;
|
|
196
212
|
}
|
|
197
|
-
.zc-
|
|
198
|
-
|
|
199
|
-
top: var(--border-hairline);
|
|
200
|
-
right: var(--border-hairline);
|
|
201
|
-
bottom: var(--border-hairline);
|
|
202
|
-
width: var(--numf-stepper-w);
|
|
203
|
-
display: grid;
|
|
204
|
-
grid-template-rows: 1fr 1fr;
|
|
205
|
-
border-left: var(--border-hairline) solid var(--border-default);
|
|
213
|
+
.zc-fld--sm .zc-numf__unit {
|
|
214
|
+
font-size: var(--size-caption);
|
|
206
215
|
}
|
|
207
216
|
.zc-numf__step {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
position: absolute;
|
|
218
|
+
inset-block: var(--numf-inset);
|
|
219
|
+
width: calc(var(--numf-h) - var(--numf-inset) * 2);
|
|
211
220
|
display: grid;
|
|
212
221
|
place-items: center;
|
|
222
|
+
padding: 0;
|
|
223
|
+
border: 0;
|
|
224
|
+
border-radius: var(--radius-sm);
|
|
225
|
+
background: transparent;
|
|
226
|
+
color: var(--text-muted);
|
|
213
227
|
cursor: pointer;
|
|
228
|
+
touch-action: manipulation;
|
|
229
|
+
user-select: none;
|
|
214
230
|
transition: var(--transition-control);
|
|
215
|
-
padding: 0;
|
|
216
231
|
}
|
|
217
|
-
.zc-numf__step
|
|
218
|
-
|
|
232
|
+
.zc-numf__step--minus {
|
|
233
|
+
left: var(--numf-inset);
|
|
219
234
|
}
|
|
220
|
-
.zc-numf__step
|
|
221
|
-
|
|
235
|
+
.zc-numf__step--plus {
|
|
236
|
+
right: var(--numf-inset);
|
|
222
237
|
}
|
|
223
238
|
.zc-numf__step:hover {
|
|
224
239
|
background: var(--neutral-wash);
|
|
@@ -230,16 +245,7 @@
|
|
|
230
245
|
.zc-numf__step:disabled {
|
|
231
246
|
color: var(--text-disabled);
|
|
232
247
|
cursor: not-allowed;
|
|
233
|
-
background:
|
|
234
|
-
}
|
|
235
|
-
.zc-numf__step:focus-visible {
|
|
236
|
-
outline: var(--ring-accent);
|
|
237
|
-
}
|
|
238
|
-
.zc-numf__step + .zc-numf__step {
|
|
239
|
-
border-top: var(--border-hairline) solid var(--border-default);
|
|
240
|
-
}
|
|
241
|
-
.zc-numf .zc-fld__input:focus ~ .zc-numf__steppers {
|
|
242
|
-
border-color: var(--accent);
|
|
248
|
+
background: transparent;
|
|
243
249
|
}
|
|
244
250
|
|
|
245
251
|
/* Bespoke px: the token ramp has no correctly proportioned code cell. */
|
|
@@ -252,8 +258,9 @@
|
|
|
252
258
|
width: 44px;
|
|
253
259
|
height: 52px;
|
|
254
260
|
text-align: center;
|
|
255
|
-
font-family: var(--font-
|
|
261
|
+
font-family: var(--font-body);
|
|
256
262
|
font-size: var(--size-title);
|
|
263
|
+
font-variant-numeric: tabular-nums;
|
|
257
264
|
font-weight: var(--weight-medium);
|
|
258
265
|
color: var(--text-strong);
|
|
259
266
|
background: var(--bg-surface);
|
|
@@ -300,4 +307,17 @@
|
|
|
300
307
|
.zc-otp.zc-is-error .zc-otp__slot:focus {
|
|
301
308
|
outline: var(--ring-danger);
|
|
302
309
|
}
|
|
310
|
+
.zc-otp.zc-is-success .zc-otp__slot {
|
|
311
|
+
border-color: var(--accent);
|
|
312
|
+
background: var(--accent-subtle);
|
|
313
|
+
color: var(--text-accent);
|
|
314
|
+
transition-delay: var(--_otp-delay, 0s);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@media (pointer: coarse) {
|
|
318
|
+
.zc-fld input.zc-fld__input,
|
|
319
|
+
.zc-fld .zc-numf__unit {
|
|
320
|
+
font-size: var(--size-body-lg);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
303
323
|
}
|