@zyncat/ui 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert.js +11 -10
- package/dist/alert.js.map +1 -1
- package/dist/avatar.css +1 -1
- package/dist/badge.css +20 -11
- package/dist/badge.js +4 -1
- package/dist/{bloom-HV23M4AW.js → bloom-5MZXLNKG.js} +23 -5
- package/dist/bloom-5MZXLNKG.js.map +1 -0
- package/dist/button.css +24 -27
- package/dist/button.js +3 -3
- package/dist/checkbox.css +0 -1
- package/dist/chunk-2EPNCOLN.js +177 -0
- package/dist/chunk-2EPNCOLN.js.map +1 -0
- package/dist/{chunk-LNAV5E7S.js → chunk-2GYZ3HP3.js} +8 -4
- package/dist/chunk-2GYZ3HP3.js.map +1 -0
- package/dist/chunk-4M5FMCFJ.js +16 -0
- package/dist/chunk-4M5FMCFJ.js.map +1 -0
- package/dist/{chunk-ODRO3KS6.js → chunk-7GTACTZD.js} +8 -6
- package/dist/chunk-7GTACTZD.js.map +1 -0
- package/dist/{chunk-V6QAAOA5.js → chunk-AK2AXGEC.js} +38 -8
- package/dist/chunk-AK2AXGEC.js.map +1 -0
- package/dist/{chunk-5VC3TUZ2.js → chunk-BA4ALXQW.js} +2 -2
- package/dist/{chunk-5VC3TUZ2.js.map → chunk-BA4ALXQW.js.map} +1 -1
- package/dist/{chunk-N43NDSME.js → chunk-CF6ZFXRV.js} +19 -11
- package/dist/chunk-CF6ZFXRV.js.map +1 -0
- package/dist/{chunk-BRKGYLEQ.js → chunk-DOAR4PJ3.js} +9 -4
- package/dist/chunk-DOAR4PJ3.js.map +1 -0
- package/dist/{tide-DJZMDAFT.js → chunk-DVLKB3CZ.js} +15 -12
- package/dist/chunk-DVLKB3CZ.js.map +1 -0
- package/dist/chunk-EUAXI6OF.js +16 -0
- package/dist/chunk-EUAXI6OF.js.map +1 -0
- package/dist/{chunk-RLNCRDAL.js → chunk-G2TOUG2A.js} +7 -6
- package/dist/chunk-G2TOUG2A.js.map +1 -0
- package/dist/{chunk-VQFILXQN.js → chunk-HRP4UFWN.js} +70 -8
- package/dist/chunk-HRP4UFWN.js.map +1 -0
- package/dist/chunk-INK2GJTA.js +102 -0
- package/dist/chunk-INK2GJTA.js.map +1 -0
- package/dist/chunk-ITW5UCVU.js +24 -0
- package/dist/chunk-ITW5UCVU.js.map +1 -0
- package/dist/{chunk-F64Z42PJ.js → chunk-JJHEVW4M.js} +5 -6
- package/dist/chunk-JJHEVW4M.js.map +1 -0
- package/dist/{chunk-7NHY2CRA.js → chunk-JUC35N3C.js} +2 -2
- package/dist/chunk-JUC35N3C.js.map +1 -0
- package/dist/{chunk-PXQBJMPJ.js → chunk-LFJ4C7ZP.js} +7 -7
- package/dist/chunk-LFJ4C7ZP.js.map +1 -0
- package/dist/{chunk-TDHLZY6I.js → chunk-MCOIR3CK.js} +77 -18
- package/dist/chunk-MCOIR3CK.js.map +1 -0
- package/dist/chunk-NATK4DDW.js +108 -0
- package/dist/chunk-NATK4DDW.js.map +1 -0
- package/dist/{chunk-BIDVNLJO.js → chunk-O3RMSMBP.js} +8 -3
- package/dist/{chunk-BIDVNLJO.js.map → chunk-O3RMSMBP.js.map} +1 -1
- package/dist/{chunk-UKPX3RIP.js → chunk-ODO2TCTS.js} +27 -13
- package/dist/chunk-ODO2TCTS.js.map +1 -0
- package/dist/{chunk-M2KGLH2G.js → chunk-P3QSWNED.js} +11 -11
- package/dist/{chunk-M2KGLH2G.js.map → chunk-P3QSWNED.js.map} +1 -1
- package/dist/{chunk-QDAN43B6.js → chunk-Q4K337QY.js} +6 -6
- package/dist/chunk-Q4K337QY.js.map +1 -0
- package/dist/{chunk-2YGHPQ66.js → chunk-Q5N24VII.js} +2 -2
- package/dist/{chunk-2YGHPQ66.js.map → chunk-Q5N24VII.js.map} +1 -1
- package/dist/{chunk-VJXP256V.js → chunk-RLRZJAF7.js} +20 -8
- package/dist/chunk-RLRZJAF7.js.map +1 -0
- package/dist/{chunk-VZXML7EH.js → chunk-SY5UA6WS.js} +39 -10
- package/dist/chunk-SY5UA6WS.js.map +1 -0
- package/dist/{chunk-XKDR22VE.js → chunk-TFC5SCAB.js} +37 -14
- package/dist/chunk-TFC5SCAB.js.map +1 -0
- package/dist/{chunk-HBWRKEW4.js → chunk-VBALIMST.js} +3 -3
- package/dist/{chunk-HBWRKEW4.js.map → chunk-VBALIMST.js.map} +1 -1
- package/dist/{chunk-JINATP4N.js → chunk-VXQ7A6ZI.js} +8 -9
- package/dist/chunk-VXQ7A6ZI.js.map +1 -0
- package/dist/{chunk-TBLPZQSI.js → chunk-W7CHDHRV.js} +114 -42
- package/dist/chunk-W7CHDHRV.js.map +1 -0
- package/dist/{chunk-AIAPXRCI.js → chunk-WBWVOOKM.js} +201 -123
- package/dist/chunk-WBWVOOKM.js.map +1 -0
- package/dist/{chunk-6H3IJ752.js → chunk-WJEZWKEY.js} +20 -10
- package/dist/chunk-WJEZWKEY.js.map +1 -0
- package/dist/{chunk-TRPAKUIB.js → chunk-WMTOAYGP.js} +9 -9
- package/dist/{chunk-TRPAKUIB.js.map → chunk-WMTOAYGP.js.map} +1 -1
- package/dist/{chunk-C3D32LE3.js → chunk-WTHIUPVJ.js} +3 -3
- package/dist/{chunk-C3D32LE3.js.map → chunk-WTHIUPVJ.js.map} +1 -1
- package/dist/{chunk-F2TB3TT6.js → chunk-XCTMTOGT.js} +5 -5
- package/dist/{chunk-F2TB3TT6.js.map → chunk-XCTMTOGT.js.map} +1 -1
- package/dist/chunk-XMJ343KF.js +18 -0
- package/dist/chunk-XMJ343KF.js.map +1 -0
- package/dist/collapse.js +1 -1
- package/dist/combobox.css +7 -0
- package/dist/combobox.js +183 -0
- package/dist/combobox.js.map +1 -0
- package/dist/confetti.js +2 -2
- package/dist/crossfade-UHUQBUVG.js +133 -0
- package/dist/crossfade-UHUQBUVG.js.map +1 -0
- package/dist/date-field.js +27 -22
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +25 -41
- package/dist/date-range-field.js +463 -279
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +28 -23
- package/dist/datetime-field.js.map +1 -1
- package/dist/dialog-sheet.css +31 -0
- package/dist/dialog.css +3 -0
- package/dist/dialog.js +44 -42
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown.css +14 -11
- package/dist/dropdown.js +79 -37
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +22 -21
- package/dist/emoji-picker.js.map +1 -1
- package/dist/flow-field.js +2 -2
- package/dist/glide.js +3 -3
- package/dist/input.css +54 -34
- package/dist/instagram-feed.js +3 -3
- package/dist/lens.js +184 -160
- package/dist/lens.js.map +1 -1
- package/dist/mcp.js +29 -22
- package/dist/menu-surface.css +81 -7
- package/dist/modal.js +11 -10
- package/dist/modal.js.map +1 -1
- package/dist/morphing-text.js +2 -2
- package/dist/motion-devtools.css +6 -5
- package/dist/motion-devtools.js +6 -6
- package/dist/motion-tokens.js +1 -1
- package/dist/motion.js +10 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.js +63 -24
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +122 -75
- package/dist/number-field.js.map +1 -1
- package/dist/odometer.css +27 -16
- package/dist/odometer.js +225 -73
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +49 -12
- package/dist/otp-field.js.map +1 -1
- package/dist/overlay.css +1 -0
- package/dist/pagination.css +1 -1
- package/dist/pagination.js +6 -6
- package/dist/{paint-CJQCM6ZO.js → paint-NLTI6TEF.js} +5 -3
- package/dist/paint-NLTI6TEF.js.map +1 -0
- package/dist/popover.js +12 -11
- package/dist/radio-group.css +9 -6
- package/dist/radio-group.js +9 -8
- package/dist/radio-group.js.map +1 -1
- package/dist/range-sheet-days.css +35 -0
- package/dist/range-sheet.css +80 -0
- package/dist/range-summary.css +67 -0
- package/dist/scroll-area.css +150 -0
- package/dist/scroll-area.js +85 -0
- package/dist/scroll-area.js.map +1 -0
- package/dist/select.css +55 -7
- package/dist/select.js +29 -15
- package/dist/select.js.map +1 -1
- package/dist/sheet.js +12 -11
- package/dist/support-rail.css +2 -2
- package/dist/support-rail.js +17 -15
- package/dist/support-rail.js.map +1 -1
- package/dist/table-detail.css +27 -0
- package/dist/table.css +41 -14
- package/dist/table.js +341 -172
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +32 -13
- package/dist/tabs.js +69 -55
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +2 -4
- package/dist/tag.js +8 -7
- package/dist/tag.js.map +1 -1
- package/dist/text-field.js +4 -4
- package/dist/textarea.css +26 -41
- package/dist/textarea.js +43 -32
- package/dist/textarea.js.map +1 -1
- package/dist/theme-grid.js +8 -7
- package/dist/theme-switcher.js +19 -18
- package/dist/theme-switcher.js.map +1 -1
- package/dist/{theme-transition-VGLPZDJI.js → theme-transition-F3CBENM5.js} +29 -9
- package/dist/theme-transition-F3CBENM5.js.map +1 -0
- package/dist/theme-transition.css +49 -0
- package/dist/theme.js +5 -4
- package/dist/theme.js.map +1 -1
- package/dist/tide-AGGMQEJV.js +4 -0
- package/dist/tide-AGGMQEJV.js.map +1 -0
- package/dist/tiktok.js +3 -3
- package/dist/time-field.js +15 -8
- package/dist/time-field.js.map +1 -1
- package/dist/toast.css +1 -1
- package/dist/toast.js +11 -10
- package/dist/toast.js.map +1 -1
- package/dist/toggle-tag.js +2 -2
- package/dist/toggle-tag.js.map +1 -1
- package/dist/toggle.css +0 -1
- package/dist/toggle.js +4 -15
- package/dist/toggle.js.map +1 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +22 -17
- package/dist/tooltip.js.map +1 -1
- package/dist/trigger.css +0 -1
- package/dist/types/components/composites/combobox/Combobox.d.ts +51 -0
- package/dist/types/components/composites/combobox/caret.d.ts +8 -0
- package/dist/types/components/composites/combobox/use-combobox.d.ts +52 -0
- package/dist/types/components/composites/date-picker/DateField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/DateRangeField.d.ts +6 -3
- package/dist/types/components/composites/date-picker/DateTimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/date-utils.d.ts +2 -0
- package/dist/types/components/composites/date-picker/field-shell.d.ts +8 -1
- package/dist/types/components/composites/date-picker/month-swipe.d.ts +3 -0
- package/dist/types/components/composites/date-picker/range-day.d.ts +11 -0
- package/dist/types/components/composites/date-picker/range-month.d.ts +14 -0
- package/dist/types/components/composites/date-picker/range-panel.d.ts +4 -18
- package/dist/types/components/composites/date-picker/range-presets.d.ts +24 -0
- package/dist/types/components/composites/date-picker/range-sheet.d.ts +12 -0
- package/dist/types/components/composites/date-picker/range-summary.d.ts +9 -0
- package/dist/types/components/composites/date-picker/typed-key.d.ts +3 -0
- package/dist/types/components/composites/date-picker/use-month-view.d.ts +14 -0
- package/dist/types/components/composites/date-picker/use-range-panel.d.ts +44 -0
- package/dist/types/components/composites/dialog/Dialog.d.ts +3 -2
- package/dist/types/components/composites/dialog/surface.d.ts +17 -0
- package/dist/types/components/composites/dropdown/Dropdown.d.ts +21 -4
- package/dist/types/components/composites/dropdown/types.d.ts +9 -3
- package/dist/types/components/composites/scroll-area/ScrollArea.d.ts +29 -0
- package/dist/types/components/composites/select/MultiSelect.d.ts +31 -5
- package/dist/types/components/composites/select/Select.d.ts +20 -4
- package/dist/types/components/composites/select/core/index.d.ts +2 -1
- package/dist/types/components/composites/select/core/menu.d.ts +10 -5
- package/dist/types/components/composites/select/core/panel.d.ts +7 -4
- package/dist/types/components/composites/select/core/trigger.d.ts +7 -2
- package/dist/types/components/composites/select/core/types.d.ts +9 -0
- package/dist/types/components/composites/select/core/use-listbox.d.ts +8 -6
- package/dist/types/components/composites/select/presets.d.ts +17 -0
- package/dist/types/components/composites/table/Table.d.ts +3 -74
- package/dist/types/components/composites/table/body.d.ts +15 -0
- package/dist/types/components/composites/table/detail.d.ts +24 -0
- package/dist/types/components/composites/table/head.d.ts +16 -0
- package/dist/types/components/composites/table/types.d.ts +86 -0
- package/dist/types/components/composites/table/use-scroller.d.ts +12 -0
- package/dist/types/components/composites/table/use-table-state.d.ts +16 -0
- package/dist/types/components/composites/tabs/Tabs.d.ts +4 -69
- package/dist/types/components/composites/tabs/tab-panel.d.ts +26 -0
- package/dist/types/components/composites/tabs/types.d.ts +48 -0
- package/dist/types/components/composites/tabs/use-ink.d.ts +5 -0
- package/dist/types/components/composites/tooltip/Tooltip.d.ts +1 -1
- package/dist/types/components/compound/support-rail/SupportRail.d.ts +1 -1
- package/dist/types/components/expressive/lens/Lens.d.ts +1 -1
- package/dist/types/components/expressive/lens/input.d.ts +2 -0
- package/dist/types/components/expressive/lens/optics.d.ts +37 -0
- package/dist/types/components/expressive/lens/paint.d.ts +2 -0
- package/dist/types/components/expressive/lens/use-lens.d.ts +10 -0
- package/dist/types/components/expressive/odometer/Odometer.d.ts +1 -1
- package/dist/types/components/expressive/odometer/roll.d.ts +18 -0
- package/dist/types/components/expressive/odometer/spring.d.ts +11 -0
- package/dist/types/components/expressive/theme-transition/scene.d.ts +3 -0
- package/dist/types/components/internal/hooks/use-hold-repeat.d.ts +8 -0
- package/dist/types/components/internal/icon/Icon.d.ts +2 -0
- package/dist/types/components/internal/menu/highlight.d.ts +9 -1
- package/dist/types/components/internal/menu/menu-row.d.ts +4 -0
- package/dist/types/components/internal/menu/use-anchor-width.d.ts +2 -0
- package/dist/types/components/internal/overlay/layer.d.ts +5 -8
- package/dist/types/components/internal/overlay/track-anchor.d.ts +5 -0
- package/dist/types/components/internal/support/types.d.ts +1 -1
- package/dist/types/components/internal/utils/activation.d.ts +1 -0
- package/dist/types/components/primitives/badge/Badge.d.ts +17 -8
- package/dist/types/components/primitives/badge/morph-label.d.ts +3 -0
- package/dist/types/components/primitives/badge/use-glint-on-change.d.ts +2 -0
- package/dist/types/components/primitives/button/Button.d.ts +4 -8
- package/dist/types/components/primitives/button/button-style.d.ts +8 -4
- package/dist/types/components/primitives/collapse/Collapse.d.ts +3 -2
- package/dist/types/components/primitives/input/NumberField.d.ts +1 -1
- package/dist/types/components/primitives/input/OtpField.d.ts +7 -3
- package/dist/types/components/primitives/input/TextField.d.ts +1 -1
- package/dist/types/components/primitives/input/field-chrome.d.ts +2 -1
- package/dist/types/components/primitives/input/use-number-value.d.ts +16 -0
- package/dist/types/components/primitives/tag/Tag.d.ts +1 -1
- package/dist/types/components/primitives/tag/ToggleTag.d.ts +2 -2
- package/dist/types/components/primitives/textarea/Textarea.d.ts +5 -3
- package/dist/types/components/primitives/textarea/char-meter.d.ts +6 -0
- package/dist/types/components/primitives/toggle/switch-glyph.d.ts +6 -0
- package/dist/types/engine/flip.d.ts +3 -1
- package/dist/types/engine/index.d.ts +2 -2
- package/dist/types/engine/loop.d.ts +5 -2
- package/dist/types/motion/before-paint.d.ts +4 -0
- package/dist/types/motion/crossfade.d.ts +4 -0
- package/dist/types/motion/element.d.ts +16 -4
- package/dist/types/motion/flip.d.ts +12 -3
- package/dist/types/motion/holders.d.ts +4 -0
- package/dist/types/motion/motion.d.ts +7 -0
- package/dist/types/motion/use-motion.d.ts +3 -1
- package/dist/types/theme-scope.d.ts +5 -0
- package/dist/types/tokens/component-styles.generated.d.ts +0 -2
- package/dist/types/tokens/motion-defaults.generated.d.ts +2 -0
- package/dist/types/tokens/motion-scale.d.ts +18 -15
- package/dist/types/tokens/motion-tokens.d.ts +1 -1
- package/dist/types/tokens/theme-store.d.ts +4 -4
- package/dist/types/tokens/theme-tokens.generated.d.ts +77 -59
- package/dist/types/tokens/theme.d.ts +1 -1
- package/dist/typing-lines.js +2 -2
- package/dist/youtube.js +3 -3
- package/package.json +16 -11
- package/skills/zyncat-ui/SKILL.md +8 -8
- package/skills/zyncat-ui/references/components.md +6 -5
- package/skills/zyncat-ui/references/recipes.md +1 -1
- package/skills/zyncat-ui/references/theming.md +3 -3
- package/src/components/composites/combobox/Combobox.tsx +100 -0
- package/src/components/composites/combobox/Combobox.usage.md +32 -0
- package/src/components/composites/combobox/caret.ts +41 -0
- package/src/components/composites/combobox/combobox.css +7 -0
- package/src/components/composites/combobox/use-combobox.ts +112 -0
- package/src/components/composites/date-picker/DateField.tsx +4 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +15 -18
- package/src/components/composites/date-picker/DateTimeField.tsx +4 -0
- package/src/components/composites/date-picker/TimeField.tsx +12 -4
- package/src/components/composites/date-picker/date-picker.css +25 -41
- package/src/components/composites/date-picker/date-utils.ts +4 -0
- package/src/components/composites/date-picker/field-shell.tsx +45 -8
- package/src/components/composites/date-picker/month-swipe.ts +41 -0
- package/src/components/composites/date-picker/range-day.tsx +112 -0
- package/src/components/composites/date-picker/range-month.tsx +79 -0
- package/src/components/composites/date-picker/range-panel.tsx +30 -356
- package/src/components/composites/date-picker/range-presets.tsx +104 -0
- package/src/components/composites/date-picker/range-sheet-days.css +35 -0
- package/src/components/composites/date-picker/range-sheet.css +80 -0
- package/src/components/composites/date-picker/range-sheet.tsx +72 -0
- package/src/components/composites/date-picker/range-summary.css +67 -0
- package/src/components/composites/date-picker/range-summary.tsx +69 -0
- package/src/components/composites/date-picker/time-core.tsx +23 -17
- package/src/components/composites/date-picker/typed-key.ts +9 -0
- package/src/components/composites/date-picker/use-month-view.ts +32 -0
- package/src/components/composites/date-picker/use-range-panel.ts +145 -0
- package/src/components/composites/dialog/Dialog.tsx +28 -110
- package/src/components/composites/dialog/dialog-sheet.css +31 -0
- package/src/components/composites/dialog/dialog.css +3 -0
- package/src/components/composites/dialog/surface.tsx +93 -0
- package/src/components/composites/dropdown/Dropdown.tsx +49 -7
- package/src/components/composites/dropdown/Dropdown.usage.md +2 -0
- package/src/components/composites/dropdown/dropdown.css +14 -11
- package/src/components/composites/dropdown/menu-panel.tsx +49 -26
- package/src/components/composites/dropdown/types.ts +9 -3
- package/src/components/composites/pagination/pagination.css +1 -1
- package/src/components/composites/scroll-area/ScrollArea.tsx +114 -0
- package/src/components/composites/scroll-area/ScrollArea.usage.md +28 -0
- package/src/components/composites/scroll-area/scroll-area.css +150 -0
- package/src/components/composites/select/MultiSelect.tsx +71 -12
- package/src/components/composites/select/MultiSelect.usage.md +10 -0
- package/src/components/composites/select/Select.tsx +32 -2
- package/src/components/composites/select/Select.usage.md +13 -1
- package/src/components/composites/select/core/index.ts +2 -1
- package/src/components/composites/select/core/menu.tsx +34 -17
- package/src/components/composites/select/core/panel.tsx +62 -55
- package/src/components/composites/select/core/trigger.tsx +44 -13
- package/src/components/composites/select/core/types.ts +10 -0
- package/src/components/composites/select/core/use-listbox.ts +91 -38
- package/src/components/composites/select/presets.tsx +47 -0
- package/src/components/composites/select/select.css +55 -7
- package/src/components/composites/sheet/use-sheet-drag.ts +13 -0
- package/src/components/composites/table/Table.tsx +65 -305
- package/src/components/composites/table/Table.usage.md +19 -2
- package/src/components/composites/table/body.tsx +147 -0
- package/src/components/composites/table/detail.tsx +76 -0
- package/src/components/composites/table/head.tsx +90 -0
- package/src/components/composites/table/table-detail.css +27 -0
- package/src/components/composites/table/table.css +41 -14
- package/src/components/composites/table/types.ts +97 -0
- package/src/components/composites/table/use-scroller.ts +53 -0
- package/src/components/composites/table/use-table-state.ts +98 -0
- package/src/components/composites/tabs/Tabs.tsx +23 -188
- package/src/components/composites/tabs/tab-panel.tsx +63 -0
- package/src/components/composites/tabs/tabs.css +32 -13
- package/src/components/composites/tabs/types.ts +51 -0
- package/src/components/composites/tabs/use-ink.ts +87 -0
- package/src/components/composites/toast/toast.css +1 -1
- package/src/components/composites/tooltip/Tooltip.tsx +6 -5
- package/src/components/composites/tooltip/tooltip-host.tsx +10 -6
- package/src/components/composites/tooltip/tooltip.css +1 -1
- package/src/components/compound/support-rail/SupportRail.tsx +3 -2
- package/src/components/compound/support-rail/support-rail.css +2 -2
- package/src/components/dev/motion-devtools.css +6 -5
- package/src/components/expressive/lens/Lens.tsx +11 -368
- package/src/components/expressive/lens/input.ts +91 -0
- package/src/components/expressive/lens/optics.ts +119 -0
- package/src/components/expressive/lens/paint.ts +60 -0
- package/src/components/expressive/lens/use-lens.ts +121 -0
- package/src/components/expressive/odometer/Odometer.tsx +78 -99
- package/src/components/expressive/odometer/Odometer.usage.md +2 -2
- package/src/components/expressive/odometer/odometer.css +27 -16
- package/src/components/expressive/odometer/roll.ts +139 -0
- package/src/components/expressive/odometer/spring.ts +86 -0
- package/src/components/expressive/theme-transition/bloom.ts +22 -2
- package/src/components/expressive/theme-transition/paint.ts +2 -0
- package/src/components/expressive/theme-transition/scene.ts +3 -0
- package/src/components/expressive/theme-transition/theme-transition.css +49 -0
- package/src/components/expressive/theme-transition/theme-transition.ts +21 -1
- package/src/components/expressive/theme-transition/tide.ts +15 -10
- package/src/components/internal/hooks/use-hold-repeat.ts +43 -0
- package/src/components/internal/hooks/use-scroll-edges.ts +6 -1
- package/src/components/internal/icon/Icon.tsx +4 -0
- package/src/components/internal/menu/highlight.ts +20 -2
- package/src/components/internal/menu/menu-row.tsx +36 -8
- package/src/components/internal/menu/menu-surface.css +81 -7
- package/src/components/internal/menu/use-anchor-width.ts +26 -0
- package/src/components/internal/overlay/layer.tsx +11 -23
- package/src/components/internal/overlay/overlay.css +1 -0
- package/src/components/internal/overlay/position.ts +17 -6
- package/src/components/internal/overlay/track-anchor.ts +69 -0
- package/src/components/internal/overlay/trigger.css +0 -1
- package/src/components/internal/support/types.ts +1 -1
- package/src/components/internal/utils/activation.ts +7 -2
- package/src/components/primitives/avatar/avatar.css +1 -1
- package/src/components/primitives/badge/Badge.tsx +38 -15
- package/src/components/primitives/badge/Badge.usage.md +12 -5
- package/src/components/primitives/badge/badge.css +20 -11
- package/src/components/primitives/badge/morph-label.tsx +71 -0
- package/src/components/primitives/badge/use-glint-on-change.ts +16 -0
- package/src/components/primitives/button/Button.tsx +5 -8
- package/src/components/primitives/button/Button.usage.md +5 -4
- package/src/components/primitives/button/button-style.ts +11 -5
- package/src/components/primitives/button/button.css +24 -27
- package/src/components/primitives/checkbox/checkbox.css +0 -1
- package/src/components/primitives/collapse/Collapse.tsx +3 -2
- package/src/components/primitives/input/NumberField.tsx +38 -46
- package/src/components/primitives/input/OtpField.tsx +52 -11
- package/src/components/primitives/input/OtpField.usage.md +2 -1
- package/src/components/primitives/input/TextField.tsx +5 -3
- package/src/components/primitives/input/field-chrome.tsx +3 -2
- package/src/components/primitives/input/input.css +54 -34
- package/src/components/primitives/input/use-number-value.ts +38 -0
- package/src/components/primitives/radio-group/radio-group.css +9 -6
- package/src/components/primitives/tag/Tag.tsx +1 -1
- package/src/components/primitives/tag/ToggleTag.tsx +2 -2
- package/src/components/primitives/tag/tag.css +2 -4
- package/src/components/primitives/textarea/Textarea.tsx +44 -30
- package/src/components/primitives/textarea/char-meter.tsx +19 -0
- package/src/components/primitives/textarea/textarea.css +26 -41
- package/src/components/primitives/toggle/Toggle.tsx +3 -12
- package/src/components/primitives/toggle/switch-glyph.tsx +25 -0
- package/src/components/primitives/toggle/toggle.css +0 -1
- package/src/engine/animate.ts +5 -3
- package/src/engine/flip.ts +28 -4
- package/src/engine/index.ts +2 -2
- package/src/engine/loop.ts +17 -6
- package/src/mcp/server.ts +30 -20
- package/src/motion/before-paint.ts +15 -0
- package/src/motion/crossfade.ts +143 -0
- package/src/motion/element.tsx +29 -8
- package/src/motion/flip.ts +102 -31
- package/src/motion/glide.tsx +5 -0
- package/src/motion/holders.ts +10 -0
- package/src/motion/motion.ts +7 -0
- package/src/motion/motion.usage.md +34 -0
- package/src/motion/presence.tsx +22 -9
- package/src/motion/use-motion.ts +45 -6
- package/src/theme-scope.ts +19 -0
- package/src/tokens/base.css +7 -5
- package/src/tokens/color.css +17 -15
- package/src/tokens/component-styles.generated.ts +0 -2
- package/src/tokens/dark.css +8 -5
- package/src/tokens/decisions.css +5 -3
- package/src/tokens/motion-defaults.generated.ts +15 -8
- package/src/tokens/motion-scale.ts +18 -15
- package/src/tokens/motion-tokens.ts +4 -4
- package/src/tokens/motion.css +19 -11
- package/src/tokens/reset.css +1 -0
- package/src/tokens/semantic.css +20 -14
- package/src/tokens/spacing.css +5 -3
- package/src/tokens/theme-store.ts +4 -4
- package/src/tokens/theme-sync.tsx +4 -2
- package/src/tokens/theme-tokens.generated.ts +78 -59
- package/src/tokens/theme.tsx +1 -1
- package/tailwind.css +6 -0
- package/dist/bloom-HV23M4AW.js.map +0 -1
- package/dist/chunk-2DNKZ57E.js +0 -72
- package/dist/chunk-2DNKZ57E.js.map +0 -1
- package/dist/chunk-6H3IJ752.js.map +0 -1
- package/dist/chunk-7NHY2CRA.js.map +0 -1
- package/dist/chunk-AIAPXRCI.js.map +0 -1
- package/dist/chunk-BRKGYLEQ.js.map +0 -1
- package/dist/chunk-F64Z42PJ.js.map +0 -1
- package/dist/chunk-JINATP4N.js.map +0 -1
- package/dist/chunk-KSAJ6DED.js +0 -16
- package/dist/chunk-KSAJ6DED.js.map +0 -1
- package/dist/chunk-LNAV5E7S.js.map +0 -1
- package/dist/chunk-N43NDSME.js.map +0 -1
- package/dist/chunk-ODRO3KS6.js.map +0 -1
- package/dist/chunk-PXQBJMPJ.js.map +0 -1
- package/dist/chunk-QDAN43B6.js.map +0 -1
- package/dist/chunk-RJENXXTI.js +0 -93
- package/dist/chunk-RJENXXTI.js.map +0 -1
- package/dist/chunk-RLNCRDAL.js.map +0 -1
- package/dist/chunk-RW2A4M2Q.js +0 -57
- package/dist/chunk-RW2A4M2Q.js.map +0 -1
- package/dist/chunk-TBLPZQSI.js.map +0 -1
- package/dist/chunk-TDHLZY6I.js.map +0 -1
- package/dist/chunk-UKPX3RIP.js.map +0 -1
- package/dist/chunk-V6QAAOA5.js.map +0 -1
- package/dist/chunk-VDOBLABP.js +0 -38
- package/dist/chunk-VDOBLABP.js.map +0 -1
- package/dist/chunk-VJXP256V.js.map +0 -1
- package/dist/chunk-VQFILXQN.js.map +0 -1
- package/dist/chunk-VZXML7EH.js.map +0 -1
- package/dist/chunk-XKDR22VE.js.map +0 -1
- package/dist/count-badge.js +0 -13
- package/dist/count-badge.js.map +0 -1
- package/dist/paint-CJQCM6ZO.js.map +0 -1
- package/dist/status-badge.js +0 -72
- package/dist/status-badge.js.map +0 -1
- package/dist/theme-transition-VGLPZDJI.js.map +0 -1
- package/dist/tide-DJZMDAFT.js.map +0 -1
- package/dist/types/components/primitives/badge/CountBadge.d.ts +0 -8
- package/dist/types/components/primitives/badge/StatusBadge.d.ts +0 -15
- package/src/components/primitives/badge/CountBadge.tsx +0 -20
- package/src/components/primitives/badge/CountBadge.usage.md +0 -13
- package/src/components/primitives/badge/StatusBadge.tsx +0 -113
- package/src/components/primitives/badge/StatusBadge.usage.md +0 -14
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, useRef, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { TableColumn, TableSort } from './types';
|
|
6
|
+
|
|
7
|
+
function tblCompare(a: unknown, b: unknown) {
|
|
8
|
+
if (a == null && b == null) return 0;
|
|
9
|
+
if (a == null) return 1;
|
|
10
|
+
if (b == null) return -1;
|
|
11
|
+
if (typeof a === 'number' && typeof b === 'number') return a - b;
|
|
12
|
+
return String(a).localeCompare(String(b), undefined, { numeric: true, sensitivity: 'base' });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useSort<Row>(
|
|
16
|
+
rows: Row[],
|
|
17
|
+
columns: TableColumn<Row>[],
|
|
18
|
+
defaultSort: TableSort | null,
|
|
19
|
+
onSortChange?: (sort: TableSort) => void,
|
|
20
|
+
) {
|
|
21
|
+
const [sort, setSort] = useState<TableSort | null>(defaultSort);
|
|
22
|
+
|
|
23
|
+
const sortedRows = useMemo(() => {
|
|
24
|
+
if (!sort) return rows;
|
|
25
|
+
const col = columns.find((c) => c.key === sort.key);
|
|
26
|
+
if (!col) return rows;
|
|
27
|
+
const get =
|
|
28
|
+
typeof col.sortBy === 'function'
|
|
29
|
+
? col.sortBy
|
|
30
|
+
: col.sortBy
|
|
31
|
+
? (r: Row) => (r as Record<string, unknown>)[col.sortBy as string]
|
|
32
|
+
: (r: Row) => (r as Record<string, unknown>)[col.key];
|
|
33
|
+
const dir = sort.dir === 'desc' ? -1 : 1;
|
|
34
|
+
return rows.slice().sort((a, b) => dir * tblCompare(get(a), get(b)));
|
|
35
|
+
}, [rows, columns, sort]);
|
|
36
|
+
|
|
37
|
+
function cycleSort(col: TableColumn<Row>) {
|
|
38
|
+
const next: TableSort =
|
|
39
|
+
sort && sort.key === col.key
|
|
40
|
+
? { key: col.key, dir: sort.dir === 'asc' ? 'desc' : 'asc' }
|
|
41
|
+
: { key: col.key, dir: 'asc' };
|
|
42
|
+
setSort(next);
|
|
43
|
+
if (onSortChange) onSortChange(next);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { sort, sortedRows, cycleSort };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function useSelection<Row>(
|
|
50
|
+
rows: Row[],
|
|
51
|
+
keyOf: (row: Row) => string | number,
|
|
52
|
+
onSelectionChange?: (keys: Array<string | number>) => void,
|
|
53
|
+
) {
|
|
54
|
+
const [selected, setSelected] = useState<Set<string | number>>(() => new Set());
|
|
55
|
+
const lastIdxRef = useRef(-1);
|
|
56
|
+
const shiftRef = useRef(false);
|
|
57
|
+
|
|
58
|
+
const allSelected = rows.length > 0 && rows.every((r) => selected.has(keyOf(r)));
|
|
59
|
+
const someSelected = selected.size > 0 && !allSelected;
|
|
60
|
+
|
|
61
|
+
function commitSelection(next: Set<string | number>) {
|
|
62
|
+
setSelected(next);
|
|
63
|
+
if (onSelectionChange) onSelectionChange(Array.from(next));
|
|
64
|
+
}
|
|
65
|
+
function clearSelection() {
|
|
66
|
+
lastIdxRef.current = -1;
|
|
67
|
+
commitSelection(new Set());
|
|
68
|
+
}
|
|
69
|
+
function toggleAll() {
|
|
70
|
+
const next = new Set<string | number>();
|
|
71
|
+
if (!allSelected) rows.forEach((r) => next.add(keyOf(r)));
|
|
72
|
+
commitSelection(next);
|
|
73
|
+
}
|
|
74
|
+
function toggleRow(idx: number) {
|
|
75
|
+
const next = new Set(selected);
|
|
76
|
+
const on = !next.has(keyOf(rows[idx]));
|
|
77
|
+
if (shiftRef.current && lastIdxRef.current >= 0 && lastIdxRef.current !== idx) {
|
|
78
|
+
const lo = Math.min(lastIdxRef.current, idx);
|
|
79
|
+
const hi = Math.max(lastIdxRef.current, idx);
|
|
80
|
+
for (let i = lo; i <= hi; i++) {
|
|
81
|
+
const k = keyOf(rows[i]);
|
|
82
|
+
if (on) next.add(k);
|
|
83
|
+
else next.delete(k);
|
|
84
|
+
}
|
|
85
|
+
} else if (on) {
|
|
86
|
+
next.add(keyOf(rows[idx]));
|
|
87
|
+
} else {
|
|
88
|
+
next.delete(keyOf(rows[idx]));
|
|
89
|
+
}
|
|
90
|
+
lastIdxRef.current = idx;
|
|
91
|
+
shiftRef.current = false;
|
|
92
|
+
commitSelection(next);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { selected, allSelected, someSelected, shiftRef, clearSelection, toggleAll, toggleRow };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type Selection = ReturnType<typeof useSelection>;
|
|
@@ -2,74 +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
|
-
/** Stretch the row to its container and split it evenly between the tabs. */
|
|
59
|
-
fill?: boolean;
|
|
60
|
-
/** Extra class(es) merged onto the root. */
|
|
61
|
-
className?: string;
|
|
62
|
-
/** Inline styles merged onto the root. */
|
|
63
|
-
style?: CSSProperties;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface TabsProps extends TabsOwnProps {
|
|
67
|
-
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
68
|
-
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabsOwnProps> & DataAttributes;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const TABS_EDGE_PAD = 24;
|
|
72
|
-
const TABS_ENTER_X = 20;
|
|
19
|
+
export type { TabItem, TabsProps } from './types';
|
|
20
|
+
export { TabPanel, type TabPanelProps } from './tab-panel';
|
|
73
21
|
|
|
74
22
|
export function Tabs({
|
|
75
23
|
items = [],
|
|
@@ -79,6 +27,7 @@ export function Tabs({
|
|
|
79
27
|
ariaLabel,
|
|
80
28
|
activateOn = 'pointerdown',
|
|
81
29
|
variant = 'underline',
|
|
30
|
+
size = 'sm',
|
|
82
31
|
fill = false,
|
|
83
32
|
className = '',
|
|
84
33
|
style,
|
|
@@ -89,82 +38,13 @@ export function Tabs({
|
|
|
89
38
|
const pill = variant === 'pill';
|
|
90
39
|
|
|
91
40
|
const listRef = useRef<HTMLDivElement>(null);
|
|
92
|
-
const inkRef = useRef<HTMLSpanElement>(null);
|
|
93
|
-
const tabRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
|
94
|
-
const placedRef = useRef(false);
|
|
95
|
-
const valueRef = useRef(value);
|
|
96
|
-
valueRef.current = value;
|
|
97
|
-
|
|
98
41
|
const glide = useGlide(listRef);
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const el = valueRef.current != null ? tabRefs.current[valueRef.current] : null;
|
|
104
|
-
if (!list || !ink) return;
|
|
105
|
-
if (!el) {
|
|
106
|
-
ink.style.opacity = '0';
|
|
107
|
-
placedRef.current = false;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const next = { x: el.offsetLeft, w: el.offsetWidth };
|
|
111
|
-
ink.style.opacity = '1';
|
|
112
|
-
|
|
113
|
-
const motion = motionFor(list);
|
|
114
|
-
|
|
115
|
-
if (!animated || !placedRef.current || motion.reduced) {
|
|
116
|
-
set(ink, { x: [next.x], width: [next.w] });
|
|
117
|
-
} else {
|
|
118
|
-
const lr = list.getBoundingClientRect();
|
|
119
|
-
const ir = ink.getBoundingClientRect();
|
|
120
|
-
const cur = { x: ir.left - lr.left + list.scrollLeft, w: ir.width };
|
|
121
|
-
if (Math.abs(cur.x - next.x) > 0.5 || Math.abs(cur.w - next.w) > 0.5) {
|
|
122
|
-
const dir = next.x + next.w / 2 >= cur.x + cur.w / 2 ? 1 : -1;
|
|
123
|
-
const span = dir === 1 ? next.x + next.w - cur.x : cur.x + cur.w - next.x;
|
|
124
|
-
const lead = dir === 1 ? cur.x : next.x;
|
|
125
|
-
animate(ink, {
|
|
126
|
-
x: [cur.x, lead, next.x],
|
|
127
|
-
width: [cur.w, span, next.w],
|
|
128
|
-
timing: {
|
|
129
|
-
duration: motion.dur.slow,
|
|
130
|
-
times: [0, 0.55, 1],
|
|
131
|
-
ease: [motion.ease.standard, motion.ease.entrance],
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
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),
|
|
137
46
|
};
|
|
138
47
|
|
|
139
|
-
const syncEdges = useScrollEdges(listRef, (edges, el) => {
|
|
140
|
-
el.dataset.fade = ((edges.left ? 'start ' : '') + (edges.right ? 'end' : '')).trim();
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
useLayoutEffect(() => {
|
|
144
|
-
place(true);
|
|
145
|
-
const l = listRef.current,
|
|
146
|
-
el = value != null ? tabRefs.current[value] : null;
|
|
147
|
-
if (l && el && l.scrollWidth > l.clientWidth) {
|
|
148
|
-
const behavior: ScrollBehavior = motionFor(l).reduced ? 'auto' : 'smooth';
|
|
149
|
-
if (el.offsetLeft < l.scrollLeft + TABS_EDGE_PAD) {
|
|
150
|
-
l.scrollTo({ left: el.offsetLeft - TABS_EDGE_PAD, behavior });
|
|
151
|
-
} else if (el.offsetLeft + el.offsetWidth > l.scrollLeft + l.clientWidth - TABS_EDGE_PAD) {
|
|
152
|
-
l.scrollTo({ left: el.offsetLeft + el.offsetWidth - l.clientWidth + TABS_EDGE_PAD, behavior });
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, [value]);
|
|
156
|
-
|
|
157
|
-
useLayoutEffect(() => {
|
|
158
|
-
const ro = new ResizeObserver(() => {
|
|
159
|
-
place(false);
|
|
160
|
-
syncEdges();
|
|
161
|
-
});
|
|
162
|
-
if (listRef.current) ro.observe(listRef.current);
|
|
163
|
-
Object.values(tabRefs.current).forEach((el) => el && ro.observe(el));
|
|
164
|
-
syncEdges();
|
|
165
|
-
return () => ro.disconnect();
|
|
166
|
-
}, [items.length]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
167
|
-
|
|
168
48
|
const select = (v: string) => {
|
|
169
49
|
if (v === value || !onChange) return;
|
|
170
50
|
const idx = (x: string | null | undefined) => items.findIndex((i) => i.value === x);
|
|
@@ -200,6 +80,7 @@ export function Tabs({
|
|
|
200
80
|
className={cx('zc-tabs', pill && 'zc-tabs--pill', fill && 'zc-tabs--fill', className)}
|
|
201
81
|
style={style}
|
|
202
82
|
{...htmlProps}
|
|
83
|
+
data-size={size}
|
|
203
84
|
>
|
|
204
85
|
<div
|
|
205
86
|
className="zc-tabs__list"
|
|
@@ -234,7 +115,13 @@ export function Tabs({
|
|
|
234
115
|
<span className="zc-tab__pad">
|
|
235
116
|
{it.icon && <IconSlot size="sm">{it.icon}</IconSlot>}
|
|
236
117
|
<span className="zc-tab__label">{it.label}</span>
|
|
237
|
-
|
|
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>
|
|
238
125
|
</span>
|
|
239
126
|
</button>
|
|
240
127
|
);
|
|
@@ -244,55 +131,3 @@ export function Tabs({
|
|
|
244
131
|
</div>
|
|
245
132
|
);
|
|
246
133
|
}
|
|
247
|
-
|
|
248
|
-
interface TabPanelOwnProps {
|
|
249
|
-
/** The active tab's value - changing it cuts to the new content. */
|
|
250
|
-
tab: string;
|
|
251
|
-
/** Same `name` as the paired Tabs - wires role/id/aria-labelledby. */
|
|
252
|
-
name?: string;
|
|
253
|
-
/** Direction of travel from Tabs' onChange; 0 = plain fade. */
|
|
254
|
-
dir?: -1 | 0 | 1;
|
|
255
|
-
/** Panel content - only this inner node animates in on `tab` change; the root chrome stays static. */
|
|
256
|
-
children?: ReactNode;
|
|
257
|
-
/** Entrance timing for the inner content - motion tokens only, or `null` to disable.
|
|
258
|
-
* @default duration 'base' + ease 'entrance' */
|
|
259
|
-
animation?: DisableableAnimation;
|
|
260
|
-
/** Extra class(es) merged onto the root. */
|
|
261
|
-
className?: string;
|
|
262
|
-
/** Inline styles merged onto the root. */
|
|
263
|
-
style?: CSSProperties;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export interface TabPanelProps extends TabPanelOwnProps {
|
|
267
|
-
/** Standard <div> attributes (data-*, aria-*, ...) forwarded to the root. */
|
|
268
|
-
htmlProps?: Omit<HTMLAttributes<HTMLDivElement>, keyof TabPanelOwnProps> & DataAttributes;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const TABPANEL_TIMING = {
|
|
272
|
-
open: { duration: 'base', ease: 'entrance' },
|
|
273
|
-
close: { duration: 'base', ease: 'entrance' },
|
|
274
|
-
} as const;
|
|
275
|
-
|
|
276
|
-
export function TabPanel({ tab, name, dir = 0, className = '', style, children, animation, htmlProps }: TabPanelProps) {
|
|
277
|
-
const panelRef = useRef<HTMLElement>(null);
|
|
278
|
-
const enter = resolveMotionTiming(animation, TABPANEL_TIMING, panelRef.current).open;
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
<Motion
|
|
282
|
-
ref={panelRef}
|
|
283
|
-
layout
|
|
284
|
-
layoutTransition={{ size: 'morph', timing: enter }}
|
|
285
|
-
role="tabpanel"
|
|
286
|
-
tabIndex={0}
|
|
287
|
-
id={name ? `${name}-panel-${tab}` : undefined}
|
|
288
|
-
aria-labelledby={name ? `${name}-tab-${tab}` : undefined}
|
|
289
|
-
className={cx('zc-tab-panel', className)}
|
|
290
|
-
style={style}
|
|
291
|
-
{...htmlProps}
|
|
292
|
-
>
|
|
293
|
-
<Motion className="zc-tab-panel__inner" animate={{ x: [dir * TABS_ENTER_X, 0], timing: enter }} deps={[tab]}>
|
|
294
|
-
{children}
|
|
295
|
-
</Motion>
|
|
296
|
-
</Motion>
|
|
297
|
-
);
|
|
298
|
-
}
|
|
@@ -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,9 +4,26 @@
|
|
|
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
|
|
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);
|
|
11
|
+
--_tabs-tab-pad: var(--space-2);
|
|
12
|
+
--_tabs-tab-type: var(--type-caption);
|
|
8
13
|
position: relative;
|
|
9
14
|
}
|
|
15
|
+
.zc-tabs[data-size='md'] {
|
|
16
|
+
--_tabs-h: var(--control-height);
|
|
17
|
+
--_tabs-radius: var(--radius-md);
|
|
18
|
+
--_tabs-tab-pad: var(--space-3);
|
|
19
|
+
--_tabs-tab-type: var(--type-label);
|
|
20
|
+
}
|
|
21
|
+
.zc-tabs[data-size='lg'] {
|
|
22
|
+
--_tabs-h: var(--control-height-lg);
|
|
23
|
+
--_tabs-radius: var(--radius-md);
|
|
24
|
+
--_tabs-tab-pad: var(--space-4);
|
|
25
|
+
--_tabs-tab-type: var(--type-label);
|
|
26
|
+
}
|
|
10
27
|
.zc-tabs::after {
|
|
11
28
|
content: '';
|
|
12
29
|
position: absolute;
|
|
@@ -58,8 +75,7 @@
|
|
|
58
75
|
display: block;
|
|
59
76
|
font-family: var(--font-body);
|
|
60
77
|
cursor: pointer;
|
|
61
|
-
-
|
|
62
|
-
border-radius: var(--radius-md);
|
|
78
|
+
border-radius: var(--_tabs-radius);
|
|
63
79
|
transition: var(--transition-control);
|
|
64
80
|
}
|
|
65
81
|
.zc-tab:focus-visible {
|
|
@@ -71,10 +87,11 @@
|
|
|
71
87
|
display: flex;
|
|
72
88
|
align-items: center;
|
|
73
89
|
gap: var(--space-2);
|
|
74
|
-
height: var(--
|
|
75
|
-
padding-inline: var(--
|
|
76
|
-
border-radius: var(--radius
|
|
77
|
-
font: var(--type
|
|
90
|
+
height: var(--_tabs-tab-h);
|
|
91
|
+
padding-inline: var(--_tabs-tab-pad);
|
|
92
|
+
border-radius: var(--_tabs-radius);
|
|
93
|
+
font: var(--_tabs-tab-type);
|
|
94
|
+
font-weight: var(--weight-medium);
|
|
78
95
|
line-height: 1;
|
|
79
96
|
white-space: nowrap;
|
|
80
97
|
color: var(--text-subtle);
|
|
@@ -104,7 +121,7 @@
|
|
|
104
121
|
}
|
|
105
122
|
|
|
106
123
|
.zc-tab__count {
|
|
107
|
-
font-family: var(--font-
|
|
124
|
+
font-family: var(--font-body);
|
|
108
125
|
font-size: var(--size-micro);
|
|
109
126
|
line-height: 1;
|
|
110
127
|
font-variant-numeric: tabular-nums;
|
|
@@ -129,7 +146,7 @@
|
|
|
129
146
|
top: 0;
|
|
130
147
|
left: 0;
|
|
131
148
|
z-index: 0;
|
|
132
|
-
border-radius: var(--radius
|
|
149
|
+
border-radius: var(--_tabs-radius);
|
|
133
150
|
background: var(--neutral-wash);
|
|
134
151
|
pointer-events: none;
|
|
135
152
|
will-change: transform, opacity;
|
|
@@ -147,12 +164,14 @@
|
|
|
147
164
|
}
|
|
148
165
|
|
|
149
166
|
.zc-tabs--pill {
|
|
167
|
+
--_tabs-tab-h: calc(var(--_tabs-h) - 2 * var(--space-1));
|
|
150
168
|
display: flex;
|
|
151
169
|
width: fit-content;
|
|
152
170
|
max-width: 100%;
|
|
153
|
-
padding: var(--space-1);
|
|
154
|
-
border
|
|
155
|
-
|
|
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);
|
|
174
|
+
background: var(--bg-muted);
|
|
156
175
|
}
|
|
157
176
|
.zc-tabs--pill::after {
|
|
158
177
|
content: none;
|
|
@@ -182,7 +201,7 @@
|
|
|
182
201
|
.zc-tabs--pill .zc-tabs__ink {
|
|
183
202
|
top: var(--space-1);
|
|
184
203
|
bottom: auto;
|
|
185
|
-
height: var(--
|
|
204
|
+
height: var(--_tabs-tab-h);
|
|
186
205
|
border-radius: var(--tabs-pill-radius);
|
|
187
206
|
background: var(--bg-surface);
|
|
188
207
|
box-shadow: var(--shadow-xs);
|
|
@@ -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
|
+
}
|