@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,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import '../../internal/menu/menu-surface.css';
|
|
4
4
|
|
|
5
|
-
import { useEffect, useLayoutEffect, useMemo, useRef,
|
|
5
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, type KeyboardEvent, type RefObject } from 'react';
|
|
6
6
|
|
|
7
7
|
import { GlidePill, useGlide } from '../../../motion/glide';
|
|
8
8
|
import { Presence } from '../../../motion/presence';
|
|
@@ -59,7 +59,8 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
59
59
|
if (seed === 'selected') return flat.findIndex((item) => item.selected && !item.disabled);
|
|
60
60
|
return edgeEnabled(flat, seed === 'last');
|
|
61
61
|
};
|
|
62
|
-
const
|
|
62
|
+
const activeIdx = useRef(-1);
|
|
63
|
+
const activeRow = useRef<HTMLElement | null>(null);
|
|
63
64
|
|
|
64
65
|
const panelRef = refFor('panel:' + level.key);
|
|
65
66
|
const rowFor = (i: number) => refFor('row:' + levelKey(depth, flat[i].id)) as unknown as RefObject<HTMLDivElement>;
|
|
@@ -71,7 +72,6 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
71
72
|
const travel = useRef({ from: null as Point | null, active: false, hovered: -1 });
|
|
72
73
|
|
|
73
74
|
const openIdx = openSubId != null ? (indexOf.get(openSubId) ?? -1) : -1;
|
|
74
|
-
const activeItem = activeIdx >= 0 ? flat[activeIdx] : undefined;
|
|
75
75
|
const cancel = () => chain.cancel(depth);
|
|
76
76
|
const closeSub = () => chain.closeSub(depth);
|
|
77
77
|
|
|
@@ -80,16 +80,23 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
80
80
|
useMotion(panelRef, motion);
|
|
81
81
|
useReturnFocus(panelRef);
|
|
82
82
|
useAnchorWidth(anchorRef, panelRef, !nested && chain.width === 'trigger');
|
|
83
|
-
useAnchorPosition({ ...place, arrow: false, triggerRef: anchorRef, panelRef });
|
|
83
|
+
useAnchorPosition({ ...place, arrow: false, anchor: nested ? null : chain.anchor, triggerRef: anchorRef, panelRef });
|
|
84
84
|
useOutsidePress({ entry, refs: [panelRef, anchorRef], enabled: !nested, onPress: () => chain.dismiss(false) });
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
const row =
|
|
86
|
+
function setActiveIdx(i: number) {
|
|
87
|
+
const row = i >= 0 && i < flat.length ? rowFor(i).current : null;
|
|
88
|
+
activeIdx.current = i;
|
|
89
|
+
if (activeRow.current) {
|
|
90
|
+
activeRow.current.tabIndex = -1;
|
|
91
|
+
activeRow.current.removeAttribute('data-active');
|
|
92
|
+
}
|
|
93
|
+
activeRow.current = row;
|
|
88
94
|
if (!row) return glide.leave();
|
|
95
|
+
row.tabIndex = 0;
|
|
96
|
+
row.setAttribute('data-active', 'true');
|
|
89
97
|
row.focus();
|
|
90
98
|
glide.enter(row);
|
|
91
|
-
|
|
92
|
-
}, [activeIdx]);
|
|
99
|
+
}
|
|
93
100
|
|
|
94
101
|
useLayoutEffect(() => {
|
|
95
102
|
if (seed === 'none') return;
|
|
@@ -173,13 +180,14 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
173
180
|
return i >= 0 ? moveTo(i) : undefined;
|
|
174
181
|
}
|
|
175
182
|
e.preventDefault();
|
|
183
|
+
const activeItem = activeIdx.current >= 0 ? flat[activeIdx.current] : undefined;
|
|
176
184
|
const back = () => (openSubId != null ? closeSub() : cancel());
|
|
177
185
|
const opens = activeItem && !activeItem.disabled && opensLevel(activeItem);
|
|
178
186
|
switch (e.key) {
|
|
179
187
|
case 'ArrowDown':
|
|
180
|
-
return moveTo(stepEnabled(flat, activeIdx, 1));
|
|
188
|
+
return moveTo(stepEnabled(flat, activeIdx.current, 1));
|
|
181
189
|
case 'ArrowUp':
|
|
182
|
-
return moveTo(stepEnabled(flat, activeIdx, -1));
|
|
190
|
+
return moveTo(stepEnabled(flat, activeIdx.current, -1));
|
|
183
191
|
case 'Home':
|
|
184
192
|
return moveTo(edgeEnabled(flat, false));
|
|
185
193
|
case 'End':
|
|
@@ -218,14 +226,13 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
218
226
|
id={menuId + '-item-' + i}
|
|
219
227
|
className="zc-dropdown__item"
|
|
220
228
|
role={radio ? 'menuitemradio' : 'menuitem'}
|
|
221
|
-
tabIndex={
|
|
229
|
+
tabIndex={-1}
|
|
222
230
|
aria-checked={radio ? item.selected : undefined}
|
|
223
231
|
aria-disabled={item.disabled || undefined}
|
|
224
232
|
aria-haspopup={popup ?? undefined}
|
|
225
233
|
aria-expanded={popup ? subOpen : undefined}
|
|
226
234
|
aria-controls={subOpen ? panelId(depth + 1) : undefined}
|
|
227
235
|
aria-keyshortcuts={item.shortcut}
|
|
228
|
-
data-active={i === activeIdx ? 'true' : undefined}
|
|
229
236
|
data-selected={item.selected ? 'true' : undefined}
|
|
230
237
|
data-disabled={item.disabled ? 'true' : undefined}
|
|
231
238
|
data-danger={item.danger ? 'true' : undefined}
|
|
@@ -281,10 +288,11 @@ export function MenuPanel({ chain, depth, ...motion }: { chain: MenuChain; depth
|
|
|
281
288
|
role={contentLevel ? 'dialog' : 'menu'}
|
|
282
289
|
tabIndex={-1}
|
|
283
290
|
aria-label={nested ? undefined : chain.ariaLabel}
|
|
284
|
-
aria-labelledby={
|
|
291
|
+
aria-labelledby={
|
|
292
|
+
nested ? panelId(depth - 1) + '-item-' + level.ownerIdx : chain.ariaLabel ? undefined : chain.triggerId
|
|
293
|
+
}
|
|
285
294
|
data-nested={nested ? 'true' : undefined}
|
|
286
295
|
data-content={contentLevel ? 'true' : undefined}
|
|
287
|
-
data-danger-active={activeItem && activeItem.danger ? 'true' : undefined}
|
|
288
296
|
onKeyDown={contentLevel ? onContentKeyDown : onKeyDown}
|
|
289
297
|
onPointerEnter={() => {
|
|
290
298
|
if (hoverDepth.current > depth) travel.current.from = null;
|
|
@@ -3,6 +3,7 @@ import type { HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
|
3
3
|
import type { DataAttributes } from '../../../dom-props';
|
|
4
4
|
import { normalizeCollection, type NormalizedGroup } from '../../internal/collection/collection';
|
|
5
5
|
import type { MenuHighlight, MenuSize, MenuWeight, MenuWidth } from '../../internal/menu/highlight';
|
|
6
|
+
import type { VirtualAnchor } from '../../internal/overlay/position';
|
|
6
7
|
import type { ActivateOn } from '../../internal/utils/activation';
|
|
7
8
|
|
|
8
9
|
export interface DropdownItem {
|
|
@@ -14,7 +15,7 @@ export interface DropdownItem {
|
|
|
14
15
|
description?: string;
|
|
15
16
|
/** Your own icon node shown before the label. */
|
|
16
17
|
icon?: ReactNode;
|
|
17
|
-
/** Keyboard hint shown at the trailing edge
|
|
18
|
+
/** Keyboard hint shown at the trailing edge. Display only - you still bind the key. */
|
|
18
19
|
shortcut?: string;
|
|
19
20
|
/** Destructive action - the row reads in the danger hue. @default false */
|
|
20
21
|
danger?: boolean;
|
|
@@ -99,6 +100,8 @@ export type SeedFocus = 'first' | 'last' | 'selected' | 'none';
|
|
|
99
100
|
export interface MenuChain {
|
|
100
101
|
levels: Level[];
|
|
101
102
|
menuId: string;
|
|
103
|
+
triggerId: string;
|
|
104
|
+
anchor?: VirtualAnchor | null;
|
|
102
105
|
activateOn?: ActivateOn;
|
|
103
106
|
side: 'top' | 'bottom' | 'left' | 'right';
|
|
104
107
|
align: 'start' | 'center' | 'end';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import './scroll-area.css';
|
|
4
|
+
|
|
5
|
+
import { useImperativeHandle, useRef, type CSSProperties, type ReactNode, type Ref } from 'react';
|
|
6
|
+
|
|
7
|
+
import { motionFor } from '../../../tokens/motion-tokens';
|
|
8
|
+
import { useScrollEdges } from '../../internal/hooks/use-scroll-edges';
|
|
9
|
+
import { Icon } from '../../internal/icon/Icon';
|
|
10
|
+
import { activationProps, type ActivateOn } from '../../internal/utils/activation';
|
|
11
|
+
import { cx } from '../../internal/utils/cx';
|
|
12
|
+
|
|
13
|
+
const SIDES = ['start', 'end'] as const;
|
|
14
|
+
|
|
15
|
+
const scrollBehavior = (el: Element): ScrollBehavior => (motionFor(el).reduced ? 'auto' : 'smooth');
|
|
16
|
+
|
|
17
|
+
export interface ScrollAreaProps {
|
|
18
|
+
/** Scroll direction. `'x'` lays the children out as a rail, one item each, with a paging door
|
|
19
|
+
* on each faded edge for a mouse. @default 'y' */
|
|
20
|
+
axis?: 'x' | 'y';
|
|
21
|
+
/** `'fade'` fades an edge while content hides past it. `'depth'` also shrinks each child as it
|
|
22
|
+
* crosses a faded edge; pass the items as direct children. @default 'fade' */
|
|
23
|
+
variant?: 'fade' | 'depth';
|
|
24
|
+
/** With `axis="x"`, sizes the row to the scroller instead of to its items: `flex: 1` children
|
|
25
|
+
* share its width down to their `min-width` and then scroll, and every child fills its height.
|
|
26
|
+
* For a board or a toolbar. @default false */
|
|
27
|
+
fill?: boolean;
|
|
28
|
+
/** Names the scroller as a region landmark. Omit for an unnamed scroller. */
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
/** The element that scrolls: a virtualizer's `getScrollElement`, an IntersectionObserver's
|
|
31
|
+
* `root`, or `scrollTo` for a jump. */
|
|
32
|
+
ref?: Ref<HTMLDivElement>;
|
|
33
|
+
/** When a rail's edge door pages: on `pointerdown` (snappier) or on `click`. @default 'pointerdown' */
|
|
34
|
+
activateOn?: ActivateOn;
|
|
35
|
+
/** Extra class(es) merged onto the root. */
|
|
36
|
+
className?: string;
|
|
37
|
+
/** Inline styles merged onto the root. A `'y'` scroller takes its height or max-height here. */
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
/** The scrolled content. */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function ScrollArea({
|
|
44
|
+
axis = 'y',
|
|
45
|
+
variant = 'fade',
|
|
46
|
+
fill = false,
|
|
47
|
+
ariaLabel,
|
|
48
|
+
ref,
|
|
49
|
+
activateOn = 'pointerdown',
|
|
50
|
+
className,
|
|
51
|
+
style,
|
|
52
|
+
children,
|
|
53
|
+
}: ScrollAreaProps) {
|
|
54
|
+
const viewportRef = useRef<HTMLDivElement>(null);
|
|
55
|
+
useImperativeHandle(ref, () => viewportRef.current!, []);
|
|
56
|
+
|
|
57
|
+
useScrollEdges(
|
|
58
|
+
viewportRef,
|
|
59
|
+
(edges, el) => {
|
|
60
|
+
const start = axis === 'x' ? edges.left : edges.top;
|
|
61
|
+
const end = axis === 'x' ? edges.right : edges.bottom;
|
|
62
|
+
el.dataset.edges = `${start ? 'start' : ''} ${end ? 'end' : ''}`.trim();
|
|
63
|
+
el.tabIndex = start || end ? 0 : -1;
|
|
64
|
+
},
|
|
65
|
+
{ content: true },
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const page = (side: (typeof SIDES)[number], door: Element) => {
|
|
69
|
+
const el = viewportRef.current;
|
|
70
|
+
if (!el) return;
|
|
71
|
+
const step = el.clientWidth - 2 * door.clientWidth;
|
|
72
|
+
el.scrollBy({ left: side === 'end' ? step : -step, behavior: scrollBehavior(el) });
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={cx(
|
|
78
|
+
'zc-scroll-area',
|
|
79
|
+
`zc-scroll-area--${axis}`,
|
|
80
|
+
variant === 'depth' && 'zc-scroll-area--depth',
|
|
81
|
+
axis === 'x' && fill && 'zc-scroll-area--fill',
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
style={style}
|
|
85
|
+
>
|
|
86
|
+
<div
|
|
87
|
+
ref={viewportRef}
|
|
88
|
+
className="zc-scroll-area__viewport"
|
|
89
|
+
role={ariaLabel ? 'region' : undefined}
|
|
90
|
+
aria-label={ariaLabel}
|
|
91
|
+
onFocus={(e) => {
|
|
92
|
+
if (e.target === e.currentTarget || !e.target.matches(':focus-visible')) return;
|
|
93
|
+
e.target.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: scrollBehavior(e.currentTarget) });
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<div className="zc-scroll-area__content">{children}</div>
|
|
97
|
+
</div>
|
|
98
|
+
{axis === 'x' &&
|
|
99
|
+
SIDES.map((side) => (
|
|
100
|
+
<div
|
|
101
|
+
key={side}
|
|
102
|
+
className="zc-scroll-area__door"
|
|
103
|
+
data-side={side}
|
|
104
|
+
aria-hidden
|
|
105
|
+
{...activationProps((e) => page(side, e.currentTarget), { on: activateOn, holdFocus: true })}
|
|
106
|
+
>
|
|
107
|
+
<span className="zc-scroll-area__chip">
|
|
108
|
+
<Icon name={side === 'start' ? 'caret-left' : 'caret-right'} size="sm" />
|
|
109
|
+
</span>
|
|
110
|
+
</div>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ScrollArea - @zyncat/ui/scroll-area
|
|
2
|
+
|
|
3
|
+
Group: data-display
|
|
4
|
+
Docs: https://ui.zyncat.app/scroll-area
|
|
5
|
+
|
|
6
|
+
One-axis scroller with no scrollbar: an edge fades only while content hides past it, and an x rail pages from its edges - keep overflow: auto for a visible bar or two axes.
|
|
7
|
+
|
|
8
|
+
axis y|x, variant fade|depth, fill (x only), ariaLabel, activateOn pointerdown|click, and ref to the
|
|
9
|
+
element that scrolls. The fades follow resizes and added items on their own. A y scroller needs a
|
|
10
|
+
bounded height - height or max-height on style or className, or flex: 1 inside a bounded flex column,
|
|
11
|
+
since the root already carries min-height: 0.
|
|
12
|
+
An x rail shows a door on each faded edge while a fine pointer hovers it; each pages by the viewport
|
|
13
|
+
less both fades, so nothing under a fade is skipped, and scrolls smoothly unless reduced motion is
|
|
14
|
+
on. The doors are aria-hidden: touch and the keyboard scroll natively.
|
|
15
|
+
The scroller joins the Tab order only while it overflows, its focus ring drawn on the root, and a
|
|
16
|
+
child focused from the keyboard scrolls in clear of the fades. variant depth is a CSS scroll-driven
|
|
17
|
+
animation, skipped under reduced motion and where animation-timeline is unsupported.
|
|
18
|
+
Retune on the root: --scroll-area-fade (fade depth, default --space-7), --scroll-area-gap (between
|
|
19
|
+
rail items, --space-3), --scroll-area-depth (scale at the edge, 0.86).
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<ScrollArea ariaLabel="Recent activity" style={{ maxHeight: 320 }}>
|
|
23
|
+
{events.map((event) => <div key={event.id}>{event.title}</div>)}
|
|
24
|
+
</ScrollArea>
|
|
25
|
+
<ScrollArea axis="x" ariaLabel="Media library">
|
|
26
|
+
{media.map((item) => <img key={item.id} src={item.thumbUrl} alt={item.alt} width={160} />)}
|
|
27
|
+
</ScrollArea>
|
|
28
|
+
```
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@property --_scroll-area-from {
|
|
4
|
+
syntax: '<length>';
|
|
5
|
+
inherits: false;
|
|
6
|
+
initial-value: 0;
|
|
7
|
+
}
|
|
8
|
+
@property --_scroll-area-to {
|
|
9
|
+
syntax: '<length>';
|
|
10
|
+
inherits: false;
|
|
11
|
+
initial-value: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@layer zyncat.components {
|
|
15
|
+
.zc-scroll-area {
|
|
16
|
+
--scroll-area-fade: var(--space-7);
|
|
17
|
+
--scroll-area-gap: var(--space-3);
|
|
18
|
+
--scroll-area-depth: 0.86;
|
|
19
|
+
--_scroll-area-dir: to bottom;
|
|
20
|
+
position: relative;
|
|
21
|
+
display: flex;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
min-height: 0;
|
|
24
|
+
border-radius: var(--radius-md);
|
|
25
|
+
}
|
|
26
|
+
.zc-scroll-area--x {
|
|
27
|
+
--_scroll-area-dir: to right;
|
|
28
|
+
}
|
|
29
|
+
.zc-scroll-area:has(> .zc-scroll-area__viewport:focus-visible) {
|
|
30
|
+
outline: var(--ring-accent);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.zc-scroll-area__viewport {
|
|
34
|
+
flex: 1;
|
|
35
|
+
overflow: hidden auto;
|
|
36
|
+
padding: var(--ring-gutter);
|
|
37
|
+
scroll-padding-block: var(--_scroll-area-from) var(--_scroll-area-to);
|
|
38
|
+
scroll-padding-inline: var(--_scroll-area-from) var(--_scroll-area-to);
|
|
39
|
+
scrollbar-width: none;
|
|
40
|
+
outline: none;
|
|
41
|
+
mask-image: linear-gradient(
|
|
42
|
+
var(--_scroll-area-dir),
|
|
43
|
+
transparent,
|
|
44
|
+
black var(--_scroll-area-from),
|
|
45
|
+
black calc(100% - var(--_scroll-area-to)),
|
|
46
|
+
transparent
|
|
47
|
+
);
|
|
48
|
+
transition:
|
|
49
|
+
--_scroll-area-from var(--duration-base) var(--ease-standard),
|
|
50
|
+
--_scroll-area-to var(--duration-base) var(--ease-standard);
|
|
51
|
+
}
|
|
52
|
+
.zc-scroll-area__viewport::-webkit-scrollbar {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
.zc-scroll-area__viewport[data-edges~='start'] {
|
|
56
|
+
--_scroll-area-from: var(--scroll-area-fade);
|
|
57
|
+
}
|
|
58
|
+
.zc-scroll-area__viewport[data-edges~='end'] {
|
|
59
|
+
--_scroll-area-to: var(--scroll-area-fade);
|
|
60
|
+
}
|
|
61
|
+
.zc-scroll-area--x > .zc-scroll-area__viewport {
|
|
62
|
+
overflow: auto hidden;
|
|
63
|
+
overscroll-behavior-x: contain;
|
|
64
|
+
}
|
|
65
|
+
.zc-scroll-area--x > .zc-scroll-area__viewport > .zc-scroll-area__content {
|
|
66
|
+
display: flex;
|
|
67
|
+
gap: var(--scroll-area-gap);
|
|
68
|
+
width: max-content;
|
|
69
|
+
}
|
|
70
|
+
.zc-scroll-area--fill > .zc-scroll-area__viewport {
|
|
71
|
+
display: flex;
|
|
72
|
+
gap: var(--scroll-area-gap);
|
|
73
|
+
}
|
|
74
|
+
.zc-scroll-area--fill > .zc-scroll-area__viewport > .zc-scroll-area__content {
|
|
75
|
+
display: contents;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.zc-scroll-area__door {
|
|
79
|
+
--_scroll-area-nudge: calc(var(--space-2) * -1);
|
|
80
|
+
position: absolute;
|
|
81
|
+
inset-block: 0;
|
|
82
|
+
left: 0;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
width: var(--scroll-area-fade);
|
|
87
|
+
opacity: 0;
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
transition: opacity var(--duration-fast) var(--ease-standard);
|
|
91
|
+
}
|
|
92
|
+
.zc-scroll-area__door[data-side='end'] {
|
|
93
|
+
--_scroll-area-nudge: var(--space-2);
|
|
94
|
+
left: auto;
|
|
95
|
+
right: 0;
|
|
96
|
+
}
|
|
97
|
+
.zc-scroll-area__chip {
|
|
98
|
+
display: grid;
|
|
99
|
+
place-items: center;
|
|
100
|
+
width: var(--control-height-xs);
|
|
101
|
+
height: var(--control-height-xs);
|
|
102
|
+
border: var(--border-hairline) solid var(--border-default);
|
|
103
|
+
border-radius: var(--radius-full);
|
|
104
|
+
background: var(--bg-surface);
|
|
105
|
+
box-shadow: var(--shadow-sm);
|
|
106
|
+
color: var(--text-body);
|
|
107
|
+
transform: translateX(var(--_scroll-area-nudge));
|
|
108
|
+
transition:
|
|
109
|
+
transform var(--duration-base) var(--ease-standard),
|
|
110
|
+
color var(--duration-fast) var(--ease-standard),
|
|
111
|
+
box-shadow var(--duration-fast) var(--ease-standard);
|
|
112
|
+
}
|
|
113
|
+
@media (hover: hover) and (pointer: fine) {
|
|
114
|
+
.zc-scroll-area:hover > .zc-scroll-area__viewport[data-edges~='start'] ~ .zc-scroll-area__door[data-side='start'],
|
|
115
|
+
.zc-scroll-area:hover > .zc-scroll-area__viewport[data-edges~='end'] ~ .zc-scroll-area__door[data-side='end'] {
|
|
116
|
+
--_scroll-area-nudge: 0;
|
|
117
|
+
opacity: 1;
|
|
118
|
+
pointer-events: auto;
|
|
119
|
+
}
|
|
120
|
+
.zc-scroll-area__door:hover > .zc-scroll-area__chip {
|
|
121
|
+
color: var(--text-strong);
|
|
122
|
+
box-shadow: var(--shadow-md);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@supports (animation-timeline: view()) {
|
|
127
|
+
.zc-scroll-area--depth > .zc-scroll-area__viewport > .zc-scroll-area__content > * {
|
|
128
|
+
animation-name: zc-scroll-area-depth, zc-scroll-area-depth;
|
|
129
|
+
animation-duration: auto;
|
|
130
|
+
animation-timing-function: linear;
|
|
131
|
+
animation-direction: normal, reverse;
|
|
132
|
+
animation-fill-mode: backwards, forwards;
|
|
133
|
+
animation-timeline: view(y);
|
|
134
|
+
animation-range: entry, exit;
|
|
135
|
+
}
|
|
136
|
+
.zc-scroll-area--depth.zc-scroll-area--x > .zc-scroll-area__viewport > .zc-scroll-area__content > * {
|
|
137
|
+
animation-timeline: view(x);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
@keyframes zc-scroll-area-depth {
|
|
141
|
+
from {
|
|
142
|
+
transform: scale(var(--scroll-area-depth));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
@media (prefers-reduced-motion: reduce) {
|
|
146
|
+
.zc-scroll-area--depth > .zc-scroll-area__viewport > .zc-scroll-area__content > * {
|
|
147
|
+
animation: none;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -21,8 +21,10 @@ import {
|
|
|
21
21
|
type SelectMenuHtmlProps,
|
|
22
22
|
type SelectOption,
|
|
23
23
|
} from './core';
|
|
24
|
+
import { PresetRow, type MultiSelectPreset } from './presets';
|
|
24
25
|
|
|
25
26
|
export type { SelectOption, SelectGroup } from './core';
|
|
27
|
+
export type { MultiSelectPreset } from './presets';
|
|
26
28
|
|
|
27
29
|
export interface MultiSelectProps {
|
|
28
30
|
/** The choices - a flat `SelectOption[]`, or `SelectGroup[]` to render labeled sections. @default [] */
|
|
@@ -31,8 +33,12 @@ export interface MultiSelectProps {
|
|
|
31
33
|
value?: string[];
|
|
32
34
|
/** Initial selection when uncontrolled. @default [] */
|
|
33
35
|
defaultValue?: string[];
|
|
34
|
-
/** Fires with the NEXT array and the option that was toggled
|
|
35
|
-
|
|
36
|
+
/** Fires with the NEXT array and the option that was toggled, or no option when a preset replaced
|
|
37
|
+
* the selection. Committing keeps the menu open. */
|
|
38
|
+
onChange?: (value: string[], toggled?: SelectOption) => void;
|
|
39
|
+
/** One-press selections, shown as chips between the filter field and the list. A press replaces
|
|
40
|
+
* the selection with the preset's `value` as given and keeps the menu open. @default [] */
|
|
41
|
+
presets?: MultiSelectPreset[];
|
|
36
42
|
/** Trigger text when nothing is selected. @default 'Select options' */
|
|
37
43
|
placeholder?: string;
|
|
38
44
|
/** Trigger height, type and padding. The menu follows it unless `menuSize` overrides. @default 'md' */
|
|
@@ -108,6 +114,7 @@ export function MultiSelect({
|
|
|
108
114
|
value: controlledValue,
|
|
109
115
|
defaultValue = [],
|
|
110
116
|
onChange,
|
|
117
|
+
presets = [],
|
|
111
118
|
placeholder = 'Select options',
|
|
112
119
|
size = 'md',
|
|
113
120
|
menuSize = size,
|
|
@@ -130,11 +137,7 @@ export function MultiSelect({
|
|
|
130
137
|
animation,
|
|
131
138
|
trigger,
|
|
132
139
|
}: MultiSelectProps) {
|
|
133
|
-
const [value, setValue] = useControllable
|
|
134
|
-
controlledValue,
|
|
135
|
-
defaultValue,
|
|
136
|
-
onChange as ((next: string[], opt?: SelectOption) => void) | undefined,
|
|
137
|
-
);
|
|
140
|
+
const [value, setValue] = useControllable(controlledValue, defaultValue, onChange);
|
|
138
141
|
const values = Array.isArray(value) ? value : [];
|
|
139
142
|
const isSelected = (v: string) => values.indexOf(v) !== -1;
|
|
140
143
|
|
|
@@ -195,6 +198,11 @@ export function MultiSelect({
|
|
|
195
198
|
animation={animation}
|
|
196
199
|
menuProps={menuProps}
|
|
197
200
|
check={(sel) => <OptionMarker marker={marker} checked={sel} size={menuSize} />}
|
|
201
|
+
presets={
|
|
202
|
+
presets.length > 0 && (
|
|
203
|
+
<PresetRow presets={presets} size={menuSize} apply={setValue} onMenuKeyDown={lb.onMenuKeyDown} />
|
|
204
|
+
)
|
|
205
|
+
}
|
|
198
206
|
/>
|
|
199
207
|
</div>
|
|
200
208
|
);
|
|
@@ -13,7 +13,7 @@ import { menuSurfaceAttrs, type MenuSurfaceProps } from '../../../internal/menu/
|
|
|
13
13
|
import { useAnchorWidth } from '../../../internal/menu/use-anchor-width';
|
|
14
14
|
import { useReturnFocus } from '../../../internal/overlay/focus';
|
|
15
15
|
import { OverlayPortal, useOutsidePress, useOverlayEntry } from '../../../internal/overlay/layer';
|
|
16
|
-
import { useAnchorPosition } from '../../../internal/overlay/position';
|
|
16
|
+
import { useAnchorPosition, type VirtualAnchor } from '../../../internal/overlay/position';
|
|
17
17
|
import { cx } from '../../../internal/utils/cx';
|
|
18
18
|
|
|
19
19
|
export type SelectMenuHtmlProps = HTMLAttributes<HTMLDivElement> & DataAttributes;
|
|
@@ -48,6 +48,7 @@ export interface SelectMenuProps extends MenuSurfaceProps {
|
|
|
48
48
|
menuId: string;
|
|
49
49
|
requestClose: () => void;
|
|
50
50
|
triggerRef: RefObject<HTMLElement | null>;
|
|
51
|
+
anchor?: VirtualAnchor | null;
|
|
51
52
|
multiple?: boolean;
|
|
52
53
|
animation?: DisableableAnimation;
|
|
53
54
|
menuProps?: SelectMenuHtmlProps;
|
|
@@ -58,6 +59,7 @@ function MenuSurface({
|
|
|
58
59
|
menuId,
|
|
59
60
|
requestClose,
|
|
60
61
|
triggerRef,
|
|
62
|
+
anchor,
|
|
61
63
|
multiple,
|
|
62
64
|
highlight,
|
|
63
65
|
rail,
|
|
@@ -74,7 +76,7 @@ function MenuSurface({
|
|
|
74
76
|
useMotion(menuRef, { animate, exit });
|
|
75
77
|
useReturnFocus(menuRef);
|
|
76
78
|
useAnchorWidth(triggerRef, menuRef, width === 'trigger');
|
|
77
|
-
useAnchorPosition({ side: 'bottom', align: 'start', arrow: false, triggerRef, panelRef: menuRef });
|
|
79
|
+
useAnchorPosition({ side: 'bottom', align: 'start', arrow: false, anchor, triggerRef, panelRef: menuRef });
|
|
78
80
|
useOutsidePress({ entry, refs: [menuRef, triggerRef], enabled: true, onPress: requestClose });
|
|
79
81
|
|
|
80
82
|
return (
|
|
@@ -97,6 +99,7 @@ export function SelectMenu({
|
|
|
97
99
|
menuId,
|
|
98
100
|
requestClose,
|
|
99
101
|
triggerRef,
|
|
102
|
+
anchor,
|
|
100
103
|
multiple,
|
|
101
104
|
highlight,
|
|
102
105
|
rail,
|
|
@@ -118,6 +121,7 @@ export function SelectMenu({
|
|
|
118
121
|
menuId={menuId}
|
|
119
122
|
requestClose={requestClose}
|
|
120
123
|
triggerRef={triggerRef}
|
|
124
|
+
anchor={anchor}
|
|
121
125
|
multiple={multiple}
|
|
122
126
|
highlight={highlight}
|
|
123
127
|
rail={rail}
|
|
@@ -11,11 +11,11 @@ import { Icon } from '../../../internal/icon/Icon';
|
|
|
11
11
|
import type { MenuSurfaceProps } from '../../../internal/menu/highlight';
|
|
12
12
|
import { MenuGroupLabel, MenuRow } from '../../../internal/menu/menu-row';
|
|
13
13
|
import { activationProps, type ActivateOn } from '../../../internal/utils/activation';
|
|
14
|
-
import { SelectMenu, type SelectMenuHtmlProps } from './menu';
|
|
14
|
+
import { SelectMenu, type SelectMenuHtmlProps, type SelectMenuProps } from './menu';
|
|
15
15
|
import type { ListRow } from './types';
|
|
16
16
|
import type { ListboxState } from './use-listbox';
|
|
17
17
|
|
|
18
|
-
export interface ListboxPanelProps extends MenuSurfaceProps {
|
|
18
|
+
export interface ListboxPanelProps extends MenuSurfaceProps, Pick<SelectMenuProps, 'anchor'> {
|
|
19
19
|
lb: ListboxState;
|
|
20
20
|
loading: boolean;
|
|
21
21
|
searchable: boolean;
|
|
@@ -26,6 +26,7 @@ export interface ListboxPanelProps extends MenuSurfaceProps {
|
|
|
26
26
|
animation?: DisableableAnimation;
|
|
27
27
|
menuProps?: SelectMenuHtmlProps;
|
|
28
28
|
check?: (selected: boolean) => ReactNode;
|
|
29
|
+
presets?: ReactNode;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
const defaultCheck = (selected: boolean) => (selected ? <Icon key="on" name="check" size="sm" weight="bold" /> : null);
|
|
@@ -49,6 +50,7 @@ function EmptyRow({ query }: { query: string }) {
|
|
|
49
50
|
|
|
50
51
|
export function ListboxPanel({
|
|
51
52
|
lb,
|
|
53
|
+
anchor,
|
|
52
54
|
loading,
|
|
53
55
|
searchable,
|
|
54
56
|
searchPlaceholder,
|
|
@@ -63,6 +65,7 @@ export function ListboxPanel({
|
|
|
63
65
|
animation,
|
|
64
66
|
menuProps,
|
|
65
67
|
check = defaultCheck,
|
|
68
|
+
presets,
|
|
66
69
|
}: ListboxPanelProps) {
|
|
67
70
|
const grouped = lb.sections.some((s) => s.label);
|
|
68
71
|
const option = (row: ListRow) => {
|
|
@@ -78,9 +81,8 @@ export function ListboxPanel({
|
|
|
78
81
|
aria-selected={isSel}
|
|
79
82
|
aria-disabled={opt.disabled || undefined}
|
|
80
83
|
data-selected={isSel ? 'true' : undefined}
|
|
81
|
-
data-active={row.index === lb.activeIdx ? 'true' : undefined}
|
|
82
84
|
data-disabled={opt.disabled ? 'true' : undefined}
|
|
83
|
-
onMouseEnter={() => !opt.disabled && lb.
|
|
85
|
+
onMouseEnter={() => !opt.disabled && lb.navigate(row.index)}
|
|
84
86
|
onMouseDown={(e) => e.preventDefault()}
|
|
85
87
|
{...activationProps<HTMLDivElement>(() => lb.commit(opt), { on: activateOn, holdFocus: true })}
|
|
86
88
|
icon={opt.icon}
|
|
@@ -97,6 +99,7 @@ export function ListboxPanel({
|
|
|
97
99
|
menuId={lb.menuId}
|
|
98
100
|
requestClose={lb.requestClose}
|
|
99
101
|
triggerRef={lb.triggerRef}
|
|
102
|
+
anchor={anchor}
|
|
100
103
|
multiple={multiple}
|
|
101
104
|
highlight={highlight}
|
|
102
105
|
rail={rail}
|
|
@@ -117,12 +120,12 @@ export function ListboxPanel({
|
|
|
117
120
|
placeholder={searchPlaceholder}
|
|
118
121
|
aria-label={searchPlaceholder}
|
|
119
122
|
aria-controls={lb.listId}
|
|
120
|
-
aria-activedescendant={lb.adId}
|
|
121
123
|
onChange={(e) => lb.setQuery(e.target.value)}
|
|
122
124
|
onKeyDown={lb.onMenuKeyDown}
|
|
123
125
|
/>
|
|
124
126
|
</div>
|
|
125
127
|
)}
|
|
128
|
+
{!loading && presets}
|
|
126
129
|
|
|
127
130
|
<div
|
|
128
131
|
className="zc-menu-scroller zc-select__list"
|
|
@@ -130,9 +133,8 @@ export function ListboxPanel({
|
|
|
130
133
|
id={lb.listId}
|
|
131
134
|
role="listbox"
|
|
132
135
|
aria-multiselectable={multiple || undefined}
|
|
133
|
-
tabIndex={-1}
|
|
136
|
+
tabIndex={presets && !searchable ? 0 : -1}
|
|
134
137
|
aria-label={ariaLabel}
|
|
135
|
-
aria-activedescendant={searchable ? undefined : lb.adId}
|
|
136
138
|
data-grouped={grouped ? 'true' : undefined}
|
|
137
139
|
onKeyDown={searchable ? undefined : lb.onMenuKeyDown}
|
|
138
140
|
>
|
|
@@ -43,7 +43,7 @@ export function SelectTrigger({
|
|
|
43
43
|
onKeyDown,
|
|
44
44
|
...rest
|
|
45
45
|
}: SelectTriggerProps) {
|
|
46
|
-
const { triggerRef, baseId, open,
|
|
46
|
+
const { triggerRef, baseId, open, show, requestClose } = lb;
|
|
47
47
|
|
|
48
48
|
const toggle = () => {
|
|
49
49
|
if (triggerRef.current) triggerRef.current.focus({ preventScroll: true });
|
|
@@ -68,7 +68,6 @@ export function SelectTrigger({
|
|
|
68
68
|
holdFocus: true,
|
|
69
69
|
attrs: {
|
|
70
70
|
role: 'combobox',
|
|
71
|
-
'aria-activedescendant': adId,
|
|
72
71
|
...(ariaLabel && { 'aria-label': ariaLabel }),
|
|
73
72
|
...(invalid && { 'aria-invalid': true }),
|
|
74
73
|
...(disabled && { 'aria-disabled': true }),
|
|
@@ -87,7 +86,6 @@ export function SelectTrigger({
|
|
|
87
86
|
aria-haspopup="listbox"
|
|
88
87
|
aria-expanded={open}
|
|
89
88
|
aria-controls={baseId + '-list'}
|
|
90
|
-
aria-activedescendant={adId}
|
|
91
89
|
aria-label={ariaLabel}
|
|
92
90
|
aria-invalid={invalid || undefined}
|
|
93
91
|
disabled={disabled}
|