@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
|
@@ -2,77 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import './tabs.css';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
useId,
|
|
7
|
-
useLayoutEffect,
|
|
8
|
-
useRef,
|
|
9
|
-
type CSSProperties,
|
|
10
|
-
type HTMLAttributes,
|
|
11
|
-
type KeyboardEvent,
|
|
12
|
-
type ReactNode,
|
|
13
|
-
} from 'react';
|
|
5
|
+
import { useId, useRef, type KeyboardEvent } from 'react';
|
|
14
6
|
|
|
15
|
-
import type { DataAttributes } from '../../../dom-props';
|
|
16
|
-
import { animate, set } from '../../../engine';
|
|
17
7
|
import { Motion } from '../../../motion/element';
|
|
18
8
|
import { GlidePill, useGlide } from '../../../motion/glide';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { useScrollEdges } from '../../internal/hooks/use-scroll-edges';
|
|
9
|
+
import { Presence } from '../../../motion/presence';
|
|
10
|
+
import { popIn, popOut } from '../../../motion/presets';
|
|
11
|
+
import { UIMotion } from '../../../tokens/motion-tokens';
|
|
23
12
|
import { IconSlot } from '../../internal/icon/IconSlot';
|
|
24
|
-
import { activationProps
|
|
13
|
+
import { activationProps } from '../../internal/utils/activation';
|
|
25
14
|
import { cx } from '../../internal/utils/cx';
|
|
15
|
+
import { DigitStrip } from '../../primitives/badge/digit-strip';
|
|
16
|
+
import type { TabItem, TabsProps } from './types';
|
|
17
|
+
import { useInk } from './use-ink';
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
/** Stable identity - also used in the tab/panel id pair. */
|
|
30
|
-
value: string;
|
|
31
|
-
/** Visible tab text. */
|
|
32
|
-
label: ReactNode;
|
|
33
|
-
/** Leading icon - your own node. */
|
|
34
|
-
icon?: ReactNode;
|
|
35
|
-
/** Rendered mono + tabular. Pass a number or a preformatted string. */
|
|
36
|
-
count?: number | string;
|
|
37
|
-
/** Dims the tab, blocks selection, and skips it during arrow-key travel. */
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface TabsOwnProps {
|
|
42
|
-
/** The tab row, in order. @default [] */
|
|
43
|
-
items: TabItem[];
|
|
44
|
-
/** Controlled - the value of the active tab (null/undefined hides the ink). */
|
|
45
|
-
value: string | null | undefined;
|
|
46
|
-
/** Fires on click and on arrow-key travel. `dir` is the direction of travel (+1 right, -1 left);
|
|
47
|
-
* hand it to TabPanel so content enters from that side. */
|
|
48
|
-
onChange?: (value: string, dir: 1 | -1) => void;
|
|
49
|
-
/** Shared id prefix wiring tab and panel aria. Give Tabs and its TabPanel the same `name`;
|
|
50
|
-
* omit it when the tabs have no managed panel. */
|
|
51
|
-
name?: string;
|
|
52
|
-
/** Accessible name for the tablist (e.g. "Section views"). */
|
|
53
|
-
ariaLabel?: string;
|
|
54
|
-
/** Whether a tab switches on `pointerdown` (snappier) or waits for `click`. @default 'pointerdown' */
|
|
55
|
-
activateOn?: ActivateOn;
|
|
56
|
-
/** Skin: an underline that reaches across (default), or a segmented pill riding an inset track. */
|
|
57
|
-
variant?: 'underline' | 'pill';
|
|
58
|
-
/** Tab height, type and padding. `'md'` and `'lg'` match `Button`'s steps; the default row sits
|
|
59
|
-
* just under them. @default 'sm' */
|
|
60
|
-
size?: 'sm' | 'md' | 'lg';
|
|
61
|
-
/** Stretch the row to its container and split it evenly between the tabs. */
|
|
62
|
-
fill?: boolean;
|
|
63
|
-
/** Extra class(es) merged onto the root. */
|
|
64
|
-
className?: string;
|
|
65
|
-
/** Inline styles merged onto the root. */
|
|
66
|
-
style?: CSSProperties;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface TabsProps extends TabsOwnProps {
|
|
70
|
-
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
71
|
-
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabsOwnProps> & DataAttributes;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const TABS_EDGE_PAD = 24;
|
|
75
|
-
const TABS_ENTER_X = 20;
|
|
19
|
+
export type { TabItem, TabsProps } from './types';
|
|
20
|
+
export { TabPanel, type TabPanelProps } from './tab-panel';
|
|
76
21
|
|
|
77
22
|
export function Tabs({
|
|
78
23
|
items = [],
|
|
@@ -93,82 +38,13 @@ export function Tabs({
|
|
|
93
38
|
const pill = variant === 'pill';
|
|
94
39
|
|
|
95
40
|
const listRef = useRef<HTMLDivElement>(null);
|
|
96
|
-
const inkRef = useRef<HTMLSpanElement>(null);
|
|
97
|
-
const tabRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
|
98
|
-
const placedRef = useRef(false);
|
|
99
|
-
const valueRef = useRef(value);
|
|
100
|
-
valueRef.current = value;
|
|
101
|
-
|
|
102
41
|
const glide = useGlide(listRef);
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const el = valueRef.current != null ? tabRefs.current[valueRef.current] : null;
|
|
108
|
-
if (!list || !ink) return;
|
|
109
|
-
if (!el) {
|
|
110
|
-
ink.style.opacity = '0';
|
|
111
|
-
placedRef.current = false;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const next = { x: el.offsetLeft, w: el.offsetWidth };
|
|
115
|
-
ink.style.opacity = '1';
|
|
116
|
-
|
|
117
|
-
const motion = motionFor(list);
|
|
118
|
-
|
|
119
|
-
if (!animated || !placedRef.current || motion.reduced) {
|
|
120
|
-
set(ink, { x: [next.x], width: [next.w] });
|
|
121
|
-
} else {
|
|
122
|
-
const lr = list.getBoundingClientRect();
|
|
123
|
-
const ir = ink.getBoundingClientRect();
|
|
124
|
-
const cur = { x: ir.left - lr.left + list.scrollLeft, w: ir.width };
|
|
125
|
-
if (Math.abs(cur.x - next.x) > 0.5 || Math.abs(cur.w - next.w) > 0.5) {
|
|
126
|
-
const dir = next.x + next.w / 2 >= cur.x + cur.w / 2 ? 1 : -1;
|
|
127
|
-
const span = dir === 1 ? next.x + next.w - cur.x : cur.x + cur.w - next.x;
|
|
128
|
-
const lead = dir === 1 ? cur.x : next.x;
|
|
129
|
-
animate(ink, {
|
|
130
|
-
x: [cur.x, lead, next.x],
|
|
131
|
-
width: [cur.w, span, next.w],
|
|
132
|
-
timing: {
|
|
133
|
-
duration: motion.dur.slow,
|
|
134
|
-
times: [0, 0.55, 1],
|
|
135
|
-
ease: [motion.ease.standard, motion.ease.entrance],
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
placedRef.current = true;
|
|
42
|
+
const { inkRef, tabRefs } = useInk(listRef, value, items.length);
|
|
43
|
+
const countMotion = {
|
|
44
|
+
animate: popIn(UIMotion.scale.chip, UIMotion.t.enter),
|
|
45
|
+
exit: popOut(UIMotion.scale.chip, UIMotion.t.exit),
|
|
141
46
|
};
|
|
142
47
|
|
|
143
|
-
const syncEdges = useScrollEdges(listRef, (edges, el) => {
|
|
144
|
-
el.dataset.fade = ((edges.left ? 'start ' : '') + (edges.right ? 'end' : '')).trim();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
useLayoutEffect(() => {
|
|
148
|
-
place(true);
|
|
149
|
-
const l = listRef.current,
|
|
150
|
-
el = value != null ? tabRefs.current[value] : null;
|
|
151
|
-
if (l && el && l.scrollWidth > l.clientWidth) {
|
|
152
|
-
const behavior: ScrollBehavior = motionFor(l).reduced ? 'auto' : 'smooth';
|
|
153
|
-
if (el.offsetLeft < l.scrollLeft + TABS_EDGE_PAD) {
|
|
154
|
-
l.scrollTo({ left: el.offsetLeft - TABS_EDGE_PAD, behavior });
|
|
155
|
-
} else if (el.offsetLeft + el.offsetWidth > l.scrollLeft + l.clientWidth - TABS_EDGE_PAD) {
|
|
156
|
-
l.scrollTo({ left: el.offsetLeft + el.offsetWidth - l.clientWidth + TABS_EDGE_PAD, behavior });
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}, [value]);
|
|
160
|
-
|
|
161
|
-
useLayoutEffect(() => {
|
|
162
|
-
const ro = new ResizeObserver(() => {
|
|
163
|
-
place(false);
|
|
164
|
-
syncEdges();
|
|
165
|
-
});
|
|
166
|
-
if (listRef.current) ro.observe(listRef.current);
|
|
167
|
-
Object.values(tabRefs.current).forEach((el) => el && ro.observe(el));
|
|
168
|
-
syncEdges();
|
|
169
|
-
return () => ro.disconnect();
|
|
170
|
-
}, [items.length]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
171
|
-
|
|
172
48
|
const select = (v: string) => {
|
|
173
49
|
if (v === value || !onChange) return;
|
|
174
50
|
const idx = (x: string | null | undefined) => items.findIndex((i) => i.value === x);
|
|
@@ -239,7 +115,13 @@ export function Tabs({
|
|
|
239
115
|
<span className="zc-tab__pad">
|
|
240
116
|
{it.icon && <IconSlot size="sm">{it.icon}</IconSlot>}
|
|
241
117
|
<span className="zc-tab__label">{it.label}</span>
|
|
242
|
-
|
|
118
|
+
<Presence initial={false}>
|
|
119
|
+
{it.count != null && (
|
|
120
|
+
<Motion as="span" key="count" className="zc-tab__count" {...countMotion}>
|
|
121
|
+
<DigitStrip value={it.count} />
|
|
122
|
+
</Motion>
|
|
123
|
+
)}
|
|
124
|
+
</Presence>
|
|
243
125
|
</span>
|
|
244
126
|
</button>
|
|
245
127
|
);
|
|
@@ -249,55 +131,3 @@ export function Tabs({
|
|
|
249
131
|
</div>
|
|
250
132
|
);
|
|
251
133
|
}
|
|
252
|
-
|
|
253
|
-
interface TabPanelOwnProps {
|
|
254
|
-
/** The active tab's value - changing it cuts to the new content. */
|
|
255
|
-
tab: string;
|
|
256
|
-
/** Same `name` as the paired Tabs - wires role/id/aria-labelledby. */
|
|
257
|
-
name?: string;
|
|
258
|
-
/** Direction of travel from Tabs' onChange; 0 = plain fade. */
|
|
259
|
-
dir?: -1 | 0 | 1;
|
|
260
|
-
/** Panel content - only this inner node animates in on `tab` change; the root chrome stays static. */
|
|
261
|
-
children?: ReactNode;
|
|
262
|
-
/** Entrance timing for the inner content - motion tokens only, or `null` to disable.
|
|
263
|
-
* @default duration 'base' + ease 'entrance' */
|
|
264
|
-
animation?: DisableableAnimation;
|
|
265
|
-
/** Extra class(es) merged onto the root. */
|
|
266
|
-
className?: string;
|
|
267
|
-
/** Inline styles merged onto the root. */
|
|
268
|
-
style?: CSSProperties;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export interface TabPanelProps extends TabPanelOwnProps {
|
|
272
|
-
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
273
|
-
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabPanelOwnProps> & DataAttributes;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const TABPANEL_TIMING = {
|
|
277
|
-
open: { duration: 'base', ease: 'entrance' },
|
|
278
|
-
close: { duration: 'base', ease: 'entrance' },
|
|
279
|
-
} as const;
|
|
280
|
-
|
|
281
|
-
export function TabPanel({ tab, name, dir = 0, className = '', style, children, animation, htmlProps }: TabPanelProps) {
|
|
282
|
-
const panelRef = useRef<HTMLElement>(null);
|
|
283
|
-
const enter = resolveMotionTiming(animation, TABPANEL_TIMING, panelRef.current).open;
|
|
284
|
-
|
|
285
|
-
return (
|
|
286
|
-
<Motion
|
|
287
|
-
ref={panelRef}
|
|
288
|
-
layout
|
|
289
|
-
layoutTransition={{ size: 'morph', timing: enter }}
|
|
290
|
-
role="tabpanel"
|
|
291
|
-
tabIndex={0}
|
|
292
|
-
id={name ? `${name}-panel-${tab}` : undefined}
|
|
293
|
-
aria-labelledby={name ? `${name}-tab-${tab}` : undefined}
|
|
294
|
-
className={cx('zc-tab-panel', className)}
|
|
295
|
-
style={style}
|
|
296
|
-
{...htmlProps}
|
|
297
|
-
>
|
|
298
|
-
<Motion className="zc-tab-panel__inner" animate={{ x: [dir * TABS_ENTER_X, 0], timing: enter }} deps={[tab]}>
|
|
299
|
-
{children}
|
|
300
|
-
</Motion>
|
|
301
|
-
</Motion>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { DataAttributes } from '../../../dom-props';
|
|
6
|
+
import { Motion } from '../../../motion/element';
|
|
7
|
+
import { resolveMotionTiming } from '../../../motion/motion-timing';
|
|
8
|
+
import { type DisableableAnimation } from '../../../motion/timing';
|
|
9
|
+
import { cx } from '../../internal/utils/cx';
|
|
10
|
+
|
|
11
|
+
const TABS_ENTER_X = 20;
|
|
12
|
+
|
|
13
|
+
interface TabPanelOwnProps {
|
|
14
|
+
/** The active tab's value - changing it cuts to the new content. */
|
|
15
|
+
tab: string;
|
|
16
|
+
/** Same `name` as the paired Tabs - wires role/id/aria-labelledby. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Direction of travel from Tabs' onChange; 0 = plain fade. */
|
|
19
|
+
dir?: -1 | 0 | 1;
|
|
20
|
+
/** Panel content - only this inner node animates in on `tab` change; the root chrome stays static. */
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/** Entrance timing for the inner content - motion tokens only, or `null` to disable.
|
|
23
|
+
* @default duration 'base' + ease 'entrance' */
|
|
24
|
+
animation?: DisableableAnimation;
|
|
25
|
+
/** Extra class(es) merged onto the root. */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Inline styles merged onto the root. */
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TabPanelProps extends TabPanelOwnProps {
|
|
32
|
+
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
33
|
+
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabPanelOwnProps> & DataAttributes;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const TABPANEL_TIMING = {
|
|
37
|
+
open: { duration: 'base', ease: 'entrance' },
|
|
38
|
+
close: { duration: 'base', ease: 'entrance' },
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
export function TabPanel({ tab, name, dir = 0, className = '', style, children, animation, htmlProps }: TabPanelProps) {
|
|
42
|
+
const panelRef = useRef<HTMLElement>(null);
|
|
43
|
+
const enter = resolveMotionTiming(animation, TABPANEL_TIMING, panelRef.current).open;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Motion
|
|
47
|
+
ref={panelRef}
|
|
48
|
+
layout
|
|
49
|
+
layoutTransition={{ size: 'morph', timing: enter }}
|
|
50
|
+
role="tabpanel"
|
|
51
|
+
tabIndex={0}
|
|
52
|
+
id={name ? `${name}-panel-${tab}` : undefined}
|
|
53
|
+
aria-labelledby={name ? `${name}-tab-${tab}` : undefined}
|
|
54
|
+
className={cx('zc-tab-panel', className)}
|
|
55
|
+
style={style}
|
|
56
|
+
{...htmlProps}
|
|
57
|
+
>
|
|
58
|
+
<Motion className="zc-tab-panel__inner" animate={{ x: [dir * TABS_ENTER_X, 0], timing: enter }} deps={[tab]}>
|
|
59
|
+
{children}
|
|
60
|
+
</Motion>
|
|
61
|
+
</Motion>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -4,19 +4,23 @@
|
|
|
4
4
|
.zc-tabs {
|
|
5
5
|
/* 2px, not --border-emphasis: 1.5px renders as sub-pixel fuzz on 1x screens. */
|
|
6
6
|
--tabs-ink-h: 2px;
|
|
7
|
-
--tabs-pill-radius: var(--radius
|
|
8
|
-
--_tabs-
|
|
7
|
+
--tabs-pill-radius: var(--_tabs-radius);
|
|
8
|
+
--_tabs-h: var(--control-height-sm);
|
|
9
|
+
--_tabs-radius: var(--radius-sm);
|
|
10
|
+
--_tabs-tab-h: var(--_tabs-h);
|
|
9
11
|
--_tabs-tab-pad: var(--space-2);
|
|
10
12
|
--_tabs-tab-type: var(--type-caption);
|
|
11
13
|
position: relative;
|
|
12
14
|
}
|
|
13
15
|
.zc-tabs[data-size='md'] {
|
|
14
|
-
--_tabs-
|
|
16
|
+
--_tabs-h: var(--control-height);
|
|
17
|
+
--_tabs-radius: var(--radius-md);
|
|
15
18
|
--_tabs-tab-pad: var(--space-3);
|
|
16
19
|
--_tabs-tab-type: var(--type-label);
|
|
17
20
|
}
|
|
18
21
|
.zc-tabs[data-size='lg'] {
|
|
19
|
-
--_tabs-
|
|
22
|
+
--_tabs-h: var(--control-height-lg);
|
|
23
|
+
--_tabs-radius: var(--radius-md);
|
|
20
24
|
--_tabs-tab-pad: var(--space-4);
|
|
21
25
|
--_tabs-tab-type: var(--type-label);
|
|
22
26
|
}
|
|
@@ -71,8 +75,7 @@
|
|
|
71
75
|
display: block;
|
|
72
76
|
font-family: var(--font-body);
|
|
73
77
|
cursor: pointer;
|
|
74
|
-
-
|
|
75
|
-
border-radius: var(--radius-md);
|
|
78
|
+
border-radius: var(--_tabs-radius);
|
|
76
79
|
transition: var(--transition-control);
|
|
77
80
|
}
|
|
78
81
|
.zc-tab:focus-visible {
|
|
@@ -86,7 +89,7 @@
|
|
|
86
89
|
gap: var(--space-2);
|
|
87
90
|
height: var(--_tabs-tab-h);
|
|
88
91
|
padding-inline: var(--_tabs-tab-pad);
|
|
89
|
-
border-radius: var(--radius
|
|
92
|
+
border-radius: var(--_tabs-radius);
|
|
90
93
|
font: var(--_tabs-tab-type);
|
|
91
94
|
font-weight: var(--weight-medium);
|
|
92
95
|
line-height: 1;
|
|
@@ -118,7 +121,7 @@
|
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
.zc-tab__count {
|
|
121
|
-
font-family: var(--font-
|
|
124
|
+
font-family: var(--font-body);
|
|
122
125
|
font-size: var(--size-micro);
|
|
123
126
|
line-height: 1;
|
|
124
127
|
font-variant-numeric: tabular-nums;
|
|
@@ -143,7 +146,7 @@
|
|
|
143
146
|
top: 0;
|
|
144
147
|
left: 0;
|
|
145
148
|
z-index: 0;
|
|
146
|
-
border-radius: var(--radius
|
|
149
|
+
border-radius: var(--_tabs-radius);
|
|
147
150
|
background: var(--neutral-wash);
|
|
148
151
|
pointer-events: none;
|
|
149
152
|
will-change: transform, opacity;
|
|
@@ -161,11 +164,13 @@
|
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
.zc-tabs--pill {
|
|
167
|
+
--_tabs-tab-h: calc(var(--_tabs-h) - 2 * var(--space-1));
|
|
164
168
|
display: flex;
|
|
165
169
|
width: fit-content;
|
|
166
170
|
max-width: 100%;
|
|
167
|
-
padding: var(--space-1);
|
|
168
|
-
border
|
|
171
|
+
padding: calc(var(--space-1) - var(--border-hairline));
|
|
172
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
173
|
+
border-radius: var(--tabs-pill-radius);
|
|
169
174
|
background: var(--bg-muted);
|
|
170
175
|
}
|
|
171
176
|
.zc-tabs--pill::after {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { DataAttributes } from '../../../dom-props';
|
|
4
|
+
import type { ActivateOn } from '../../internal/utils/activation';
|
|
5
|
+
|
|
6
|
+
/** One tab in the row. */
|
|
7
|
+
export interface TabItem {
|
|
8
|
+
/** Stable identity - also used in the tab/panel id pair. */
|
|
9
|
+
value: string;
|
|
10
|
+
/** Visible tab text. */
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
/** Leading icon - your own node. */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/** Rendered with tabular figures. Pass a number or a preformatted string. */
|
|
15
|
+
count?: number | string;
|
|
16
|
+
/** Dims the tab, blocks selection, and skips it during arrow-key travel. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface TabsOwnProps {
|
|
21
|
+
/** The tab row, in order. @default [] */
|
|
22
|
+
items: TabItem[];
|
|
23
|
+
/** Controlled - the value of the active tab (null/undefined hides the ink). */
|
|
24
|
+
value: string | null | undefined;
|
|
25
|
+
/** Fires on click and on arrow-key travel. `dir` is the direction of travel (+1 right, -1 left);
|
|
26
|
+
* hand it to TabPanel so content enters from that side. */
|
|
27
|
+
onChange?: (value: string, dir: 1 | -1) => void;
|
|
28
|
+
/** Shared id prefix wiring tab and panel aria. Give Tabs and its TabPanel the same `name`;
|
|
29
|
+
* omit it when the tabs have no managed panel. */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** Accessible name for the tablist (e.g. "Section views"). */
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
/** Whether a tab switches on `pointerdown` (snappier) or waits for `click`. @default 'pointerdown' */
|
|
34
|
+
activateOn?: ActivateOn;
|
|
35
|
+
/** Skin: an underline that reaches across (default), or a segmented pill riding an inset track. */
|
|
36
|
+
variant?: 'underline' | 'pill';
|
|
37
|
+
/** Tab height, type and padding. `'md'` and `'lg'` match `Button`'s steps; the default row sits
|
|
38
|
+
* just under them. @default 'sm' */
|
|
39
|
+
size?: 'sm' | 'md' | 'lg';
|
|
40
|
+
/** Stretch the row to its container and split it evenly between the tabs. */
|
|
41
|
+
fill?: boolean;
|
|
42
|
+
/** Extra class(es) merged onto the root. */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** Inline styles merged onto the root. */
|
|
45
|
+
style?: CSSProperties;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface TabsProps extends TabsOwnProps {
|
|
49
|
+
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
50
|
+
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabsOwnProps> & DataAttributes;
|
|
51
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, type RefObject } from 'react';
|
|
4
|
+
|
|
5
|
+
import { animate, set } from '../../../engine';
|
|
6
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
7
|
+
import { useScrollEdges } from '../../internal/hooks/use-scroll-edges';
|
|
8
|
+
|
|
9
|
+
const TABS_EDGE_PAD = 24;
|
|
10
|
+
|
|
11
|
+
export function useInk(listRef: RefObject<HTMLDivElement | null>, value: string | null | undefined, count: number) {
|
|
12
|
+
const inkRef = useRef<HTMLSpanElement>(null);
|
|
13
|
+
const tabRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
|
14
|
+
const placedRef = useRef(false);
|
|
15
|
+
const valueRef = useRef(value);
|
|
16
|
+
valueRef.current = value;
|
|
17
|
+
|
|
18
|
+
const place = (animated: boolean) => {
|
|
19
|
+
const list = listRef.current,
|
|
20
|
+
ink = inkRef.current;
|
|
21
|
+
const el = valueRef.current != null ? tabRefs.current[valueRef.current] : null;
|
|
22
|
+
if (!list || !ink) return;
|
|
23
|
+
if (!el) {
|
|
24
|
+
ink.style.opacity = '0';
|
|
25
|
+
placedRef.current = false;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const next = { x: el.offsetLeft, w: el.offsetWidth };
|
|
29
|
+
ink.style.opacity = '1';
|
|
30
|
+
|
|
31
|
+
const motion = motionFor(list);
|
|
32
|
+
|
|
33
|
+
if (!animated || !placedRef.current || motion.reduced) {
|
|
34
|
+
set(ink, { x: [next.x], width: [next.w] });
|
|
35
|
+
} else {
|
|
36
|
+
const lr = list.getBoundingClientRect();
|
|
37
|
+
const ir = ink.getBoundingClientRect();
|
|
38
|
+
const cur = { x: ir.left - lr.left + list.scrollLeft, w: ir.width };
|
|
39
|
+
if (Math.abs(cur.x - next.x) > 0.5 || Math.abs(cur.w - next.w) > 0.5) {
|
|
40
|
+
const dir = next.x + next.w / 2 >= cur.x + cur.w / 2 ? 1 : -1;
|
|
41
|
+
const span = dir === 1 ? next.x + next.w - cur.x : cur.x + cur.w - next.x;
|
|
42
|
+
const lead = dir === 1 ? cur.x : next.x;
|
|
43
|
+
animate(ink, {
|
|
44
|
+
x: [cur.x, lead, next.x],
|
|
45
|
+
width: [cur.w, span, next.w],
|
|
46
|
+
timing: {
|
|
47
|
+
duration: motion.dur.slow,
|
|
48
|
+
times: [0, 0.55, 1],
|
|
49
|
+
ease: [motion.ease.standard, motion.ease.entrance],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
placedRef.current = true;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const syncEdges = useScrollEdges(listRef, (edges, el) => {
|
|
58
|
+
el.dataset.fade = ((edges.left ? 'start ' : '') + (edges.right ? 'end' : '')).trim();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
useLayoutEffect(() => {
|
|
62
|
+
place(true);
|
|
63
|
+
const l = listRef.current,
|
|
64
|
+
el = value != null ? tabRefs.current[value] : null;
|
|
65
|
+
if (l && el && l.scrollWidth > l.clientWidth) {
|
|
66
|
+
const behavior: ScrollBehavior = motionFor(l).reduced ? 'auto' : 'smooth';
|
|
67
|
+
if (el.offsetLeft < l.scrollLeft + TABS_EDGE_PAD) {
|
|
68
|
+
l.scrollTo({ left: el.offsetLeft - TABS_EDGE_PAD, behavior });
|
|
69
|
+
} else if (el.offsetLeft + el.offsetWidth > l.scrollLeft + l.clientWidth - TABS_EDGE_PAD) {
|
|
70
|
+
l.scrollTo({ left: el.offsetLeft + el.offsetWidth - l.clientWidth + TABS_EDGE_PAD, behavior });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [value]);
|
|
74
|
+
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const ro = new ResizeObserver(() => {
|
|
77
|
+
place(false);
|
|
78
|
+
syncEdges();
|
|
79
|
+
});
|
|
80
|
+
if (listRef.current) ro.observe(listRef.current);
|
|
81
|
+
Object.values(tabRefs.current).forEach((el) => el && ro.observe(el));
|
|
82
|
+
syncEdges();
|
|
83
|
+
return () => ro.disconnect();
|
|
84
|
+
}, [count]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
85
|
+
|
|
86
|
+
return { inkRef, tabRefs };
|
|
87
|
+
}
|
|
@@ -24,7 +24,7 @@ import { CLOSE_GRACE, OPEN_DELAY, store, useHostElection, type Placement } from
|
|
|
24
24
|
export interface TooltipProps {
|
|
25
25
|
/** The hint - a string or small node; never interactive content. */
|
|
26
26
|
content: ReactNode;
|
|
27
|
-
/** Optional keyboard hint, rendered as
|
|
27
|
+
/** Optional keyboard hint, rendered as small metadata ("⌘↩", "S"). */
|
|
28
28
|
shortcut?: string | null;
|
|
29
29
|
/** Preferred side; flips automatically when out of viewport room. */
|
|
30
30
|
placement?: Placement;
|
|
@@ -98,9 +98,9 @@ export function Tooltip({
|
|
|
98
98
|
[myId],
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
function show(immediate: boolean) {
|
|
101
|
+
function show(immediate: boolean, from: EventTarget) {
|
|
102
102
|
clearTimeout(openTimer.current);
|
|
103
|
-
if (disabled || !wrapRef.current?.firstElementChild) return;
|
|
103
|
+
if (disabled || !wrapRef.current?.firstElementChild || !wrapRef.current.contains(from as Node)) return;
|
|
104
104
|
if (immediate || store.isWarm()) setOpen(true);
|
|
105
105
|
else openTimer.current = setTimeout(() => setOpen(true), openDelay);
|
|
106
106
|
}
|
|
@@ -110,10 +110,10 @@ export function Tooltip({
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
const onEnter = (e: PointerEvent) => {
|
|
113
|
-
if (e.pointerType !== 'touch') show(false);
|
|
113
|
+
if (e.pointerType !== 'touch') show(false, e.target);
|
|
114
114
|
};
|
|
115
115
|
const onFocusIn = (e: FocusEvent) => {
|
|
116
|
-
if ((e.target as HTMLElement).matches(':focus-visible')) show(true);
|
|
116
|
+
if ((e.target as HTMLElement).matches(':focus-visible')) show(true, e.target);
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
return (
|
|
@@ -125,6 +125,7 @@ export function Tooltip({
|
|
|
125
125
|
onPointerEnter={onEnter}
|
|
126
126
|
onPointerLeave={hide}
|
|
127
127
|
onPointerDown={hide}
|
|
128
|
+
onClick={hide}
|
|
128
129
|
onFocus={onFocusIn}
|
|
129
130
|
onBlur={hide}
|
|
130
131
|
>
|
|
@@ -12,6 +12,8 @@ import { tokenPx } from '../../internal/utils/token-px';
|
|
|
12
12
|
import { store, TOOLTIP_DOM_ID, type ActivePayload, type Placement } from './tooltip-store';
|
|
13
13
|
|
|
14
14
|
const tipLayout = (scope?: Element | null) => ({ size: 'morph' as const, timing: motionFor(scope).t.layout });
|
|
15
|
+
const OPPOSITE: Record<Placement, Placement> = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' };
|
|
16
|
+
const CROSS_FALLBACK: Placement[] = ['bottom', 'top'];
|
|
15
17
|
|
|
16
18
|
interface Size {
|
|
17
19
|
w: number;
|
|
@@ -31,11 +33,13 @@ function targetBox(size: Size, t: DOMRect, want: Placement, scope?: Element | nu
|
|
|
31
33
|
vh = window.innerHeight,
|
|
32
34
|
TIP_GAP = tokenPx('--space-2', 8, scope) || 8,
|
|
33
35
|
M = TIP_GAP;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const room: Record<Placement, boolean> = {
|
|
37
|
+
top: t.top - size.h - TIP_GAP >= M,
|
|
38
|
+
bottom: t.bottom + size.h + TIP_GAP <= vh - M,
|
|
39
|
+
left: t.left - size.w - TIP_GAP >= M,
|
|
40
|
+
right: t.right + size.w + TIP_GAP <= vw - M,
|
|
41
|
+
};
|
|
42
|
+
const p = [want, OPPOSITE[want], ...CROSS_FALLBACK].find((side) => room[side]) ?? want;
|
|
39
43
|
let x, y;
|
|
40
44
|
if (p === 'top') {
|
|
41
45
|
x = t.left + t.width / 2 - size.w / 2;
|
|
@@ -144,7 +144,8 @@ function SupportRailBody({
|
|
|
144
144
|
</div>
|
|
145
145
|
<Button
|
|
146
146
|
variant="ghost"
|
|
147
|
-
size="
|
|
147
|
+
size="sm"
|
|
148
|
+
iconOnly
|
|
148
149
|
className="zc-support-rail__close"
|
|
149
150
|
aria-label="Close"
|
|
150
151
|
onClick={requestClose}
|
|
@@ -195,7 +196,7 @@ export interface SupportRailOwnProps {
|
|
|
195
196
|
actions: SupportAction[];
|
|
196
197
|
/** Panel heading, and the panel's accessible name. @default 'Talk to us' */
|
|
197
198
|
title?: string;
|
|
198
|
-
/** Small
|
|
199
|
+
/** Small line under the heading - opening hours, queue depth, a shift note. */
|
|
199
200
|
status?: string;
|
|
200
201
|
/** Container edge the rail pins to. Flips the tab, the morph origin and the panel's border. @default 'right' */
|
|
201
202
|
side?: 'right' | 'left';
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
}
|
|
152
152
|
.zc-support-rail__status {
|
|
153
153
|
margin-top: var(--space-2);
|
|
154
|
-
font-family: var(--font-
|
|
154
|
+
font-family: var(--font-body);
|
|
155
155
|
font-size: var(--size-micro);
|
|
156
156
|
line-height: var(--leading-micro);
|
|
157
157
|
color: var(--text-subtle);
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
color: var(--text-secondary);
|
|
244
244
|
}
|
|
245
245
|
.zc-support-rail__row-meta {
|
|
246
|
-
font-family: var(--font-
|
|
246
|
+
font-family: var(--font-body);
|
|
247
247
|
font-size: var(--size-micro);
|
|
248
248
|
letter-spacing: var(--tracking-caps);
|
|
249
249
|
color: var(--text-subtle);
|