@zyncat/ui 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert.js +10 -9
- package/dist/alert.js.map +1 -1
- package/dist/avatar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/badge.js +5 -100
- package/dist/badge.js.map +1 -1
- package/dist/button.css +24 -27
- package/dist/button.js +3 -3
- package/dist/checkbox.css +0 -1
- package/dist/chunk-2EPNCOLN.js +177 -0
- package/dist/chunk-2EPNCOLN.js.map +1 -0
- package/dist/{chunk-3HE7N3UK.js → chunk-2GYZ3HP3.js} +3 -3
- package/dist/chunk-2GYZ3HP3.js.map +1 -0
- package/dist/{chunk-ODRO3KS6.js → chunk-7GTACTZD.js} +8 -6
- package/dist/chunk-7GTACTZD.js.map +1 -0
- package/dist/{chunk-BWGK3OD6.js → chunk-AK2AXGEC.js} +33 -6
- package/dist/chunk-AK2AXGEC.js.map +1 -0
- package/dist/{chunk-5VC3TUZ2.js → chunk-BA4ALXQW.js} +2 -2
- package/dist/{chunk-5VC3TUZ2.js.map → chunk-BA4ALXQW.js.map} +1 -1
- package/dist/{chunk-AXZBD7LY.js → chunk-CF6ZFXRV.js} +16 -11
- package/dist/chunk-CF6ZFXRV.js.map +1 -0
- package/dist/{chunk-AQMR7ZYO.js → chunk-DOAR4PJ3.js} +4 -4
- package/dist/{chunk-AQMR7ZYO.js.map → chunk-DOAR4PJ3.js.map} +1 -1
- package/dist/chunk-EUAXI6OF.js +16 -0
- package/dist/chunk-EUAXI6OF.js.map +1 -0
- package/dist/{chunk-AOEO2LCZ.js → chunk-G2TOUG2A.js} +6 -5
- package/dist/chunk-G2TOUG2A.js.map +1 -0
- package/dist/{chunk-CYZKPUCG.js → chunk-HRP4UFWN.js} +3 -3
- package/dist/chunk-HRP4UFWN.js.map +1 -0
- package/dist/chunk-INK2GJTA.js +102 -0
- package/dist/chunk-INK2GJTA.js.map +1 -0
- package/dist/{chunk-GM7IPTTT.js → chunk-JJHEVW4M.js} +5 -5
- package/dist/{chunk-GM7IPTTT.js.map → chunk-JJHEVW4M.js.map} +1 -1
- package/dist/{chunk-7NHY2CRA.js → chunk-JUC35N3C.js} +2 -2
- package/dist/chunk-JUC35N3C.js.map +1 -0
- package/dist/{chunk-LC6NQQER.js → chunk-LFJ4C7ZP.js} +7 -7
- package/dist/chunk-LFJ4C7ZP.js.map +1 -0
- package/dist/{chunk-JQZ3FTHP.js → chunk-MCOIR3CK.js} +3 -3
- package/dist/{chunk-JQZ3FTHP.js.map → chunk-MCOIR3CK.js.map} +1 -1
- package/dist/{chunk-TXJQUN7C.js → chunk-NATK4DDW.js} +15 -15
- package/dist/{chunk-TXJQUN7C.js.map → chunk-NATK4DDW.js.map} +1 -1
- package/dist/{chunk-BIDVNLJO.js → chunk-O3RMSMBP.js} +8 -3
- package/dist/{chunk-BIDVNLJO.js.map → chunk-O3RMSMBP.js.map} +1 -1
- package/dist/{chunk-47OMFFIB.js → chunk-ODO2TCTS.js} +27 -13
- package/dist/chunk-ODO2TCTS.js.map +1 -0
- package/dist/{chunk-LV442ZOR.js → chunk-P3QSWNED.js} +11 -11
- package/dist/{chunk-LV442ZOR.js.map → chunk-P3QSWNED.js.map} +1 -1
- package/dist/{chunk-QDAN43B6.js → chunk-Q4K337QY.js} +6 -6
- package/dist/chunk-Q4K337QY.js.map +1 -0
- package/dist/{chunk-ZSP4ZTII.js → chunk-RLRZJAF7.js} +20 -8
- package/dist/chunk-RLRZJAF7.js.map +1 -0
- package/dist/{chunk-V4ZN5RD4.js → chunk-SY5UA6WS.js} +29 -9
- package/dist/chunk-SY5UA6WS.js.map +1 -0
- package/dist/{chunk-SPFHWHJ6.js → chunk-TFC5SCAB.js} +32 -13
- package/dist/chunk-TFC5SCAB.js.map +1 -0
- package/dist/{chunk-HBWRKEW4.js → chunk-VBALIMST.js} +3 -3
- package/dist/{chunk-HBWRKEW4.js.map → chunk-VBALIMST.js.map} +1 -1
- package/dist/{chunk-2W7FOMWE.js → chunk-VXQ7A6ZI.js} +8 -8
- package/dist/{chunk-2W7FOMWE.js.map → chunk-VXQ7A6ZI.js.map} +1 -1
- package/dist/{chunk-TBLPZQSI.js → chunk-W7CHDHRV.js} +114 -42
- package/dist/chunk-W7CHDHRV.js.map +1 -0
- package/dist/{chunk-DEZIQTBW.js → chunk-WBWVOOKM.js} +58 -53
- package/dist/chunk-WBWVOOKM.js.map +1 -0
- package/dist/{chunk-6H3IJ752.js → chunk-WJEZWKEY.js} +20 -10
- package/dist/chunk-WJEZWKEY.js.map +1 -0
- package/dist/{chunk-TBIY5YR5.js → chunk-WMTOAYGP.js} +9 -9
- package/dist/{chunk-TBIY5YR5.js.map → chunk-WMTOAYGP.js.map} +1 -1
- package/dist/{chunk-C3D32LE3.js → chunk-WTHIUPVJ.js} +3 -3
- package/dist/{chunk-C3D32LE3.js.map → chunk-WTHIUPVJ.js.map} +1 -1
- package/dist/{chunk-PNFFK5HY.js → chunk-XCTMTOGT.js} +5 -5
- package/dist/{chunk-PNFFK5HY.js.map → chunk-XCTMTOGT.js.map} +1 -1
- package/dist/chunk-XMJ343KF.js +18 -0
- package/dist/chunk-XMJ343KF.js.map +1 -0
- package/dist/collapse.js +1 -1
- package/dist/combobox.css +7 -0
- package/dist/combobox.js +183 -0
- package/dist/combobox.js.map +1 -0
- package/dist/confetti.js +2 -2
- package/dist/{crossfade-XFZLFLT7.js → crossfade-UHUQBUVG.js} +53 -11
- package/dist/crossfade-UHUQBUVG.js.map +1 -0
- package/dist/date-field.js +23 -20
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +25 -40
- package/dist/date-range-field.js +458 -276
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +24 -21
- package/dist/datetime-field.js.map +1 -1
- package/dist/dialog-sheet.css +31 -0
- package/dist/dialog.css +3 -0
- package/dist/dialog.js +42 -40
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown.css +2 -2
- package/dist/dropdown.js +56 -31
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +20 -19
- package/dist/emoji-picker.js.map +1 -1
- package/dist/flow-field.js +2 -2
- package/dist/glide.js +3 -3
- package/dist/input.css +54 -34
- package/dist/instagram-feed.js +3 -3
- package/dist/lens.js +184 -160
- package/dist/lens.js.map +1 -1
- package/dist/mcp.js +29 -22
- package/dist/modal.js +10 -9
- package/dist/modal.js.map +1 -1
- package/dist/morphing-text.js +2 -2
- package/dist/motion-devtools.css +6 -5
- package/dist/motion-devtools.js +6 -6
- package/dist/motion-tokens.js +1 -1
- package/dist/motion.js +6 -5
- package/dist/multi-select.js +41 -20
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +121 -74
- package/dist/number-field.js.map +1 -1
- package/dist/odometer.css +12 -7
- package/dist/odometer.js +158 -39
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +32 -3
- package/dist/otp-field.js.map +1 -1
- package/dist/overlay.css +1 -0
- package/dist/pagination.css +1 -1
- package/dist/pagination.js +6 -6
- package/dist/popover.js +11 -10
- package/dist/radio-group.css +1 -2
- package/dist/radio-group.js +9 -8
- package/dist/radio-group.js.map +1 -1
- package/dist/range-sheet-days.css +35 -0
- package/dist/range-sheet.css +80 -0
- package/dist/range-summary.css +67 -0
- package/dist/scroll-area.css +150 -0
- package/dist/scroll-area.js +85 -0
- package/dist/scroll-area.js.map +1 -0
- package/dist/select.css +22 -1
- package/dist/select.js +15 -14
- package/dist/select.js.map +1 -1
- package/dist/sheet.js +11 -10
- package/dist/support-rail.css +2 -2
- package/dist/support-rail.js +15 -13
- package/dist/support-rail.js.map +1 -1
- package/dist/table-detail.css +27 -0
- package/dist/table.css +35 -13
- package/dist/table.js +341 -172
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +16 -11
- package/dist/tabs.js +68 -56
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +2 -4
- package/dist/tag.js +8 -7
- package/dist/tag.js.map +1 -1
- package/dist/text-field.js +4 -4
- package/dist/textarea.css +15 -42
- package/dist/textarea.js +24 -26
- package/dist/textarea.js.map +1 -1
- package/dist/theme-grid.js +8 -7
- package/dist/theme-switcher.js +17 -16
- package/dist/theme-switcher.js.map +1 -1
- package/dist/{theme-transition-FDF2REFD.js → theme-transition-F3CBENM5.js} +5 -5
- package/dist/{theme-transition-FDF2REFD.js.map → theme-transition-F3CBENM5.js.map} +1 -1
- package/dist/theme.js +5 -4
- package/dist/theme.js.map +1 -1
- package/dist/tiktok.js +3 -3
- package/dist/time-field.js +13 -8
- package/dist/time-field.js.map +1 -1
- package/dist/toast.css +1 -1
- package/dist/toast.js +11 -10
- package/dist/toast.js.map +1 -1
- package/dist/toggle-tag.js.map +1 -1
- package/dist/toggle.css +0 -1
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +21 -15
- package/dist/tooltip.js.map +1 -1
- package/dist/types/components/composites/combobox/Combobox.d.ts +51 -0
- package/dist/types/components/composites/combobox/caret.d.ts +8 -0
- package/dist/types/components/composites/combobox/use-combobox.d.ts +52 -0
- package/dist/types/components/composites/date-picker/DateField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/DateRangeField.d.ts +6 -3
- package/dist/types/components/composites/date-picker/DateTimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -1
- package/dist/types/components/composites/date-picker/date-utils.d.ts +2 -0
- package/dist/types/components/composites/date-picker/field-shell.d.ts +4 -1
- package/dist/types/components/composites/date-picker/month-swipe.d.ts +3 -0
- package/dist/types/components/composites/date-picker/range-day.d.ts +11 -0
- package/dist/types/components/composites/date-picker/range-month.d.ts +14 -0
- package/dist/types/components/composites/date-picker/range-panel.d.ts +4 -18
- package/dist/types/components/composites/date-picker/range-presets.d.ts +24 -0
- package/dist/types/components/composites/date-picker/range-sheet.d.ts +12 -0
- package/dist/types/components/composites/date-picker/range-summary.d.ts +9 -0
- package/dist/types/components/composites/date-picker/typed-key.d.ts +3 -0
- package/dist/types/components/composites/date-picker/use-month-view.d.ts +14 -0
- package/dist/types/components/composites/date-picker/use-range-panel.d.ts +44 -0
- package/dist/types/components/composites/dialog/Dialog.d.ts +3 -2
- package/dist/types/components/composites/dialog/surface.d.ts +17 -0
- package/dist/types/components/composites/dropdown/Dropdown.d.ts +9 -3
- package/dist/types/components/composites/dropdown/types.d.ts +4 -1
- package/dist/types/components/composites/scroll-area/ScrollArea.d.ts +29 -0
- package/dist/types/components/composites/select/MultiSelect.d.ts +9 -3
- package/dist/types/components/composites/select/core/menu.d.ts +3 -1
- package/dist/types/components/composites/select/core/panel.d.ts +4 -3
- package/dist/types/components/composites/select/core/use-listbox.d.ts +5 -5
- package/dist/types/components/composites/select/presets.d.ts +17 -0
- package/dist/types/components/composites/table/Table.d.ts +3 -74
- package/dist/types/components/composites/table/body.d.ts +15 -0
- package/dist/types/components/composites/table/detail.d.ts +24 -0
- package/dist/types/components/composites/table/head.d.ts +16 -0
- package/dist/types/components/composites/table/types.d.ts +86 -0
- package/dist/types/components/composites/table/use-scroller.d.ts +12 -0
- package/dist/types/components/composites/table/use-table-state.d.ts +16 -0
- package/dist/types/components/composites/tabs/Tabs.d.ts +3 -71
- package/dist/types/components/composites/tabs/tab-panel.d.ts +26 -0
- package/dist/types/components/composites/tabs/types.d.ts +48 -0
- package/dist/types/components/composites/tabs/use-ink.d.ts +5 -0
- package/dist/types/components/composites/tooltip/Tooltip.d.ts +1 -1
- package/dist/types/components/compound/support-rail/SupportRail.d.ts +1 -1
- package/dist/types/components/expressive/lens/Lens.d.ts +1 -1
- package/dist/types/components/expressive/lens/input.d.ts +2 -0
- package/dist/types/components/expressive/lens/optics.d.ts +37 -0
- package/dist/types/components/expressive/lens/paint.d.ts +2 -0
- package/dist/types/components/expressive/lens/use-lens.d.ts +10 -0
- package/dist/types/components/expressive/odometer/roll.d.ts +9 -11
- package/dist/types/components/expressive/odometer/spring.d.ts +11 -0
- package/dist/types/components/internal/hooks/use-hold-repeat.d.ts +8 -0
- package/dist/types/components/internal/icon/Icon.d.ts +2 -0
- package/dist/types/components/internal/support/types.d.ts +1 -1
- package/dist/types/components/primitives/button/Button.d.ts +4 -8
- package/dist/types/components/primitives/button/button-style.d.ts +8 -4
- package/dist/types/components/primitives/collapse/Collapse.d.ts +3 -2
- package/dist/types/components/primitives/input/NumberField.d.ts +1 -1
- package/dist/types/components/primitives/input/OtpField.d.ts +5 -1
- package/dist/types/components/primitives/input/TextField.d.ts +1 -1
- package/dist/types/components/primitives/input/field-chrome.d.ts +2 -1
- package/dist/types/components/primitives/input/use-number-value.d.ts +16 -0
- package/dist/types/components/primitives/tag/Tag.d.ts +1 -1
- package/dist/types/components/primitives/tag/ToggleTag.d.ts +2 -2
- package/dist/types/components/primitives/textarea/Textarea.d.ts +3 -1
- package/dist/types/engine/flip.d.ts +3 -1
- package/dist/types/engine/index.d.ts +2 -2
- package/dist/types/engine/loop.d.ts +5 -2
- package/dist/types/motion/before-paint.d.ts +4 -0
- package/dist/types/motion/crossfade.d.ts +2 -1
- package/dist/types/motion/element.d.ts +14 -5
- package/dist/types/motion/flip.d.ts +6 -3
- package/dist/types/motion/holders.d.ts +4 -0
- package/dist/types/motion/use-motion.d.ts +3 -1
- package/dist/types/tokens/motion-defaults.generated.d.ts +2 -0
- package/dist/types/tokens/motion-scale.d.ts +18 -15
- package/dist/types/tokens/motion-tokens.d.ts +1 -1
- package/dist/types/tokens/theme-store.d.ts +4 -4
- package/dist/types/tokens/theme-tokens.generated.d.ts +43 -31
- package/dist/types/tokens/theme.d.ts +1 -1
- package/dist/typing-lines.js +2 -2
- package/dist/youtube.js +3 -3
- package/package.json +11 -1
- package/skills/zyncat-ui/SKILL.md +6 -6
- package/skills/zyncat-ui/references/components.md +4 -2
- package/skills/zyncat-ui/references/recipes.md +1 -1
- package/src/components/composites/combobox/Combobox.tsx +100 -0
- package/src/components/composites/combobox/Combobox.usage.md +32 -0
- package/src/components/composites/combobox/caret.ts +41 -0
- package/src/components/composites/combobox/combobox.css +7 -0
- package/src/components/composites/combobox/use-combobox.ts +112 -0
- package/src/components/composites/date-picker/DateField.tsx +2 -0
- package/src/components/composites/date-picker/DateRangeField.tsx +13 -18
- package/src/components/composites/date-picker/DateTimeField.tsx +2 -0
- package/src/components/composites/date-picker/TimeField.tsx +10 -4
- package/src/components/composites/date-picker/date-picker.css +25 -40
- package/src/components/composites/date-picker/date-utils.ts +4 -0
- package/src/components/composites/date-picker/field-shell.tsx +31 -7
- package/src/components/composites/date-picker/month-swipe.ts +41 -0
- package/src/components/composites/date-picker/range-day.tsx +112 -0
- package/src/components/composites/date-picker/range-month.tsx +79 -0
- package/src/components/composites/date-picker/range-panel.tsx +30 -356
- package/src/components/composites/date-picker/range-presets.tsx +104 -0
- package/src/components/composites/date-picker/range-sheet-days.css +35 -0
- package/src/components/composites/date-picker/range-sheet.css +80 -0
- package/src/components/composites/date-picker/range-sheet.tsx +72 -0
- package/src/components/composites/date-picker/range-summary.css +67 -0
- package/src/components/composites/date-picker/range-summary.tsx +69 -0
- package/src/components/composites/date-picker/time-core.tsx +23 -17
- package/src/components/composites/date-picker/typed-key.ts +9 -0
- package/src/components/composites/date-picker/use-month-view.ts +32 -0
- package/src/components/composites/date-picker/use-range-panel.ts +145 -0
- package/src/components/composites/dialog/Dialog.tsx +28 -110
- package/src/components/composites/dialog/dialog-sheet.css +31 -0
- package/src/components/composites/dialog/dialog.css +3 -0
- package/src/components/composites/dialog/surface.tsx +93 -0
- package/src/components/composites/dropdown/Dropdown.tsx +31 -6
- package/src/components/composites/dropdown/dropdown.css +2 -2
- package/src/components/composites/dropdown/menu-panel.tsx +22 -14
- package/src/components/composites/dropdown/types.ts +4 -1
- package/src/components/composites/pagination/pagination.css +1 -1
- package/src/components/composites/scroll-area/ScrollArea.tsx +114 -0
- package/src/components/composites/scroll-area/ScrollArea.usage.md +28 -0
- package/src/components/composites/scroll-area/scroll-area.css +150 -0
- package/src/components/composites/select/MultiSelect.tsx +15 -7
- package/src/components/composites/select/core/menu.tsx +6 -2
- package/src/components/composites/select/core/panel.tsx +9 -7
- package/src/components/composites/select/core/trigger.tsx +1 -3
- package/src/components/composites/select/core/use-listbox.ts +35 -28
- package/src/components/composites/select/presets.tsx +47 -0
- package/src/components/composites/select/select.css +22 -1
- package/src/components/composites/sheet/use-sheet-drag.ts +13 -0
- package/src/components/composites/table/Table.tsx +65 -305
- package/src/components/composites/table/Table.usage.md +19 -2
- package/src/components/composites/table/body.tsx +147 -0
- package/src/components/composites/table/detail.tsx +76 -0
- package/src/components/composites/table/head.tsx +90 -0
- package/src/components/composites/table/table-detail.css +27 -0
- package/src/components/composites/table/table.css +35 -13
- package/src/components/composites/table/types.ts +97 -0
- package/src/components/composites/table/use-scroller.ts +53 -0
- package/src/components/composites/table/use-table-state.ts +98 -0
- package/src/components/composites/tabs/Tabs.tsx +21 -191
- package/src/components/composites/tabs/tab-panel.tsx +63 -0
- package/src/components/composites/tabs/tabs.css +16 -11
- package/src/components/composites/tabs/types.ts +51 -0
- package/src/components/composites/tabs/use-ink.ts +87 -0
- package/src/components/composites/toast/toast.css +1 -1
- package/src/components/composites/tooltip/Tooltip.tsx +6 -5
- package/src/components/composites/tooltip/tooltip-host.tsx +9 -5
- package/src/components/composites/tooltip/tooltip.css +1 -1
- package/src/components/compound/support-rail/SupportRail.tsx +3 -2
- package/src/components/compound/support-rail/support-rail.css +2 -2
- package/src/components/dev/motion-devtools.css +6 -5
- package/src/components/expressive/lens/Lens.tsx +11 -368
- package/src/components/expressive/lens/input.ts +91 -0
- package/src/components/expressive/lens/optics.ts +119 -0
- package/src/components/expressive/lens/paint.ts +60 -0
- package/src/components/expressive/lens/use-lens.ts +121 -0
- package/src/components/expressive/odometer/Odometer.tsx +38 -12
- package/src/components/expressive/odometer/odometer.css +12 -7
- package/src/components/expressive/odometer/roll.ts +85 -40
- package/src/components/expressive/odometer/spring.ts +86 -0
- package/src/components/internal/hooks/use-hold-repeat.ts +43 -0
- package/src/components/internal/hooks/use-scroll-edges.ts +6 -1
- package/src/components/internal/icon/Icon.tsx +4 -0
- package/src/components/internal/overlay/overlay.css +1 -0
- package/src/components/internal/overlay/track-anchor.ts +1 -1
- package/src/components/internal/support/types.ts +1 -1
- package/src/components/internal/utils/activation.ts +2 -2
- package/src/components/primitives/avatar/avatar.css +1 -1
- package/src/components/primitives/badge/badge.css +1 -1
- package/src/components/primitives/button/Button.tsx +5 -8
- package/src/components/primitives/button/Button.usage.md +5 -4
- package/src/components/primitives/button/button-style.ts +11 -5
- package/src/components/primitives/button/button.css +24 -27
- package/src/components/primitives/checkbox/checkbox.css +0 -1
- package/src/components/primitives/collapse/Collapse.tsx +3 -2
- package/src/components/primitives/input/NumberField.tsx +38 -46
- package/src/components/primitives/input/OtpField.tsx +35 -2
- package/src/components/primitives/input/OtpField.usage.md +2 -1
- package/src/components/primitives/input/TextField.tsx +5 -3
- package/src/components/primitives/input/field-chrome.tsx +3 -2
- package/src/components/primitives/input/input.css +54 -34
- package/src/components/primitives/input/use-number-value.ts +38 -0
- package/src/components/primitives/radio-group/radio-group.css +1 -2
- package/src/components/primitives/tag/Tag.tsx +1 -1
- package/src/components/primitives/tag/ToggleTag.tsx +2 -2
- package/src/components/primitives/tag/tag.css +2 -4
- package/src/components/primitives/textarea/Textarea.tsx +24 -6
- package/src/components/primitives/textarea/char-meter.tsx +1 -16
- package/src/components/primitives/textarea/textarea.css +15 -42
- package/src/components/primitives/toggle/toggle.css +0 -1
- package/src/engine/animate.ts +5 -3
- package/src/engine/flip.ts +23 -3
- package/src/engine/index.ts +2 -2
- package/src/engine/loop.ts +17 -6
- package/src/mcp/server.ts +30 -20
- package/src/motion/before-paint.ts +15 -0
- package/src/motion/crossfade.ts +54 -8
- package/src/motion/element.tsx +22 -4
- package/src/motion/flip.ts +69 -37
- package/src/motion/holders.ts +10 -0
- package/src/motion/presence.tsx +18 -9
- package/src/motion/use-motion.ts +38 -4
- package/src/tokens/base.css +0 -5
- package/src/tokens/dark.css +5 -5
- package/src/tokens/motion-defaults.generated.ts +15 -8
- package/src/tokens/motion-scale.ts +18 -15
- package/src/tokens/motion-tokens.ts +4 -4
- package/src/tokens/motion.css +19 -11
- package/src/tokens/reset.css +1 -0
- package/src/tokens/semantic.css +8 -8
- package/src/tokens/spacing.css +5 -3
- package/src/tokens/theme-store.ts +4 -4
- package/src/tokens/theme-sync.tsx +4 -2
- package/src/tokens/theme-tokens.generated.ts +44 -31
- package/src/tokens/theme.tsx +1 -1
- package/tailwind.css +4 -0
- package/dist/chunk-3HE7N3UK.js.map +0 -1
- package/dist/chunk-47OMFFIB.js.map +0 -1
- package/dist/chunk-6BY5G7BI.js +0 -122
- package/dist/chunk-6BY5G7BI.js.map +0 -1
- package/dist/chunk-6H3IJ752.js.map +0 -1
- package/dist/chunk-7NHY2CRA.js.map +0 -1
- package/dist/chunk-AOEO2LCZ.js.map +0 -1
- package/dist/chunk-AXZBD7LY.js.map +0 -1
- package/dist/chunk-BWGK3OD6.js.map +0 -1
- package/dist/chunk-CYZKPUCG.js.map +0 -1
- package/dist/chunk-DEZIQTBW.js.map +0 -1
- package/dist/chunk-KSAJ6DED.js +0 -16
- package/dist/chunk-KSAJ6DED.js.map +0 -1
- package/dist/chunk-LC6NQQER.js.map +0 -1
- package/dist/chunk-ODRO3KS6.js.map +0 -1
- package/dist/chunk-QDAN43B6.js.map +0 -1
- package/dist/chunk-SPFHWHJ6.js.map +0 -1
- package/dist/chunk-TBLPZQSI.js.map +0 -1
- package/dist/chunk-V4ZN5RD4.js.map +0 -1
- package/dist/chunk-ZSP4ZTII.js.map +0 -1
- package/dist/crossfade-XFZLFLT7.js.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useId, useRef, useState, type KeyboardEvent } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useGlide } from '../../../motion/glide';
|
|
6
|
+
import { add, clampKey, parse, today, toKey, within } from './date-utils';
|
|
7
|
+
import { drpDays, type DateRange, type DrpPreset } from './range-presets';
|
|
8
|
+
import { useDayFocus } from './use-day-focus';
|
|
9
|
+
import { useMonthView } from './use-month-view';
|
|
10
|
+
|
|
11
|
+
export interface RangeOptions {
|
|
12
|
+
value: DateRange | null;
|
|
13
|
+
commit: (value: DateRange) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
min?: string;
|
|
16
|
+
max?: string;
|
|
17
|
+
maxDays?: number;
|
|
18
|
+
months: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useRangePanel({ value, commit, close, min, max, maxDays, months }: RangeOptions) {
|
|
22
|
+
const seedKey = (value && value.start) || today();
|
|
23
|
+
const seed = parse(seedKey);
|
|
24
|
+
const { view, setView, viewIdx, nav, navDir, jumpToMonth } = useMonthView(seed);
|
|
25
|
+
|
|
26
|
+
const [draft, setDraft] = useState(value);
|
|
27
|
+
const [anchor, setAnchor] = useState<string | null>(null);
|
|
28
|
+
const [hoverKey, setHoverKey] = useState<string | null>(null);
|
|
29
|
+
const [focusKey, setFocusKey] = useState<string>(seedKey);
|
|
30
|
+
|
|
31
|
+
const daysRef = useRef<HTMLDivElement>(null);
|
|
32
|
+
const armFocus = useDayFocus(daysRef, focusKey, viewIdx);
|
|
33
|
+
|
|
34
|
+
const uid = useId();
|
|
35
|
+
const gridGlide = useGlide(daysRef);
|
|
36
|
+
const capLoId = 'drp-cap-lo-' + uid;
|
|
37
|
+
const capHiId = 'drp-cap-hi-' + uid;
|
|
38
|
+
|
|
39
|
+
const floor = anchor && maxDays ? clampKey(add(anchor, 1 - maxDays), min, max) : min;
|
|
40
|
+
const ceil = anchor && maxDays ? clampKey(add(anchor, maxDays - 1), min, max) : max;
|
|
41
|
+
const inBounds = (key: string): boolean => within(key, floor, ceil);
|
|
42
|
+
const fits = (p: DrpPreset): boolean =>
|
|
43
|
+
within(p.start, min, max) && within(p.end, min, max) && !(maxDays && drpDays(p.start, p.end) > maxDays);
|
|
44
|
+
|
|
45
|
+
let lo: string | null = null,
|
|
46
|
+
hi: string | null = null,
|
|
47
|
+
provisional = false;
|
|
48
|
+
if (anchor) {
|
|
49
|
+
const other = clampKey(hoverKey || anchor, floor, ceil);
|
|
50
|
+
lo = anchor < other ? anchor : other;
|
|
51
|
+
hi = anchor < other ? other : anchor;
|
|
52
|
+
provisional = true;
|
|
53
|
+
} else if (draft && draft.start && draft.end) {
|
|
54
|
+
lo = draft.start;
|
|
55
|
+
hi = draft.end;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function pickDay(key: string) {
|
|
59
|
+
if (!inBounds(key)) return;
|
|
60
|
+
if (!anchor) {
|
|
61
|
+
setAnchor(key);
|
|
62
|
+
setHoverKey(key);
|
|
63
|
+
} else {
|
|
64
|
+
const start = anchor < key ? anchor : key;
|
|
65
|
+
const end = anchor < key ? key : anchor;
|
|
66
|
+
setAnchor(null);
|
|
67
|
+
setHoverKey(null);
|
|
68
|
+
setDraft({ start: start, end: end });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function applyPreset(p: DrpPreset) {
|
|
73
|
+
setAnchor(null);
|
|
74
|
+
setHoverKey(null);
|
|
75
|
+
const d = parse(p.start);
|
|
76
|
+
setView({ y: d.getFullYear(), m: d.getMonth() });
|
|
77
|
+
setFocusKey(p.start);
|
|
78
|
+
setDraft({ start: p.start, end: p.end });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function done() {
|
|
82
|
+
if (lo && hi && !(value && value.start === lo && value.end === hi)) commit({ start: lo, end: hi });
|
|
83
|
+
close();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function moveFocus(deltaDays: number, deltaMonths = 0) {
|
|
87
|
+
const d = parse(focusKey);
|
|
88
|
+
if (deltaMonths) d.setMonth(d.getMonth() + deltaMonths);
|
|
89
|
+
if (deltaDays) d.setDate(d.getDate() + deltaDays);
|
|
90
|
+
const key = toKey(d);
|
|
91
|
+
armFocus();
|
|
92
|
+
setFocusKey(key);
|
|
93
|
+
if (anchor) setHoverKey(key);
|
|
94
|
+
const idx = d.getFullYear() * 12 + d.getMonth();
|
|
95
|
+
const last = viewIdx + (months - 1);
|
|
96
|
+
if (idx < viewIdx) setView({ y: d.getFullYear(), m: d.getMonth() });
|
|
97
|
+
else if (idx > last) {
|
|
98
|
+
const back = new Date(d.getFullYear(), d.getMonth() - (months - 1), 1);
|
|
99
|
+
setView({ y: back.getFullYear(), m: back.getMonth() });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function onGridKeyDown(e: KeyboardEvent<HTMLDivElement>) {
|
|
103
|
+
const k = e.key;
|
|
104
|
+
if (k === 'ArrowLeft') moveFocus(-1);
|
|
105
|
+
else if (k === 'ArrowRight') moveFocus(1);
|
|
106
|
+
else if (k === 'ArrowUp') moveFocus(-7);
|
|
107
|
+
else if (k === 'ArrowDown') moveFocus(7);
|
|
108
|
+
else if (k === 'PageUp') moveFocus(0, -1);
|
|
109
|
+
else if (k === 'PageDown') moveFocus(0, 1);
|
|
110
|
+
else if (k === 'Enter' || k === ' ') pickDay(focusKey);
|
|
111
|
+
else if (k === 'Escape' && anchor) {
|
|
112
|
+
setAnchor(null);
|
|
113
|
+
setHoverKey(null);
|
|
114
|
+
} else return;
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
view,
|
|
120
|
+
viewIdx,
|
|
121
|
+
navDir,
|
|
122
|
+
nav,
|
|
123
|
+
jumpToMonth,
|
|
124
|
+
draft: anchor ? null : draft,
|
|
125
|
+
anchor,
|
|
126
|
+
focusKey,
|
|
127
|
+
setHoverKey,
|
|
128
|
+
daysRef,
|
|
129
|
+
gridGlide,
|
|
130
|
+
capLoId,
|
|
131
|
+
capHiId,
|
|
132
|
+
inBounds,
|
|
133
|
+
fits,
|
|
134
|
+
lo,
|
|
135
|
+
hi,
|
|
136
|
+
provisional,
|
|
137
|
+
pickDay,
|
|
138
|
+
applyPreset,
|
|
139
|
+
done,
|
|
140
|
+
onGridKeyDown,
|
|
141
|
+
todayKey: today(),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type RangePanel = ReturnType<typeof useRangePanel>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import './dialog.css';
|
|
4
|
+
import './dialog-sheet.css';
|
|
4
5
|
|
|
5
6
|
import { Fragment, useId, useRef, type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
|
|
6
7
|
|
|
@@ -10,13 +11,14 @@ import { Presence } from '../../../motion/presence';
|
|
|
10
11
|
import type { DisableableAnimation } from '../../../motion/timing';
|
|
11
12
|
import { UIMotion } from '../../../tokens/motion-tokens';
|
|
12
13
|
import { useControllable } from '../../internal/hooks/use-controllable';
|
|
13
|
-
import {
|
|
14
|
-
import { Icon } from '../../internal/icon/Icon';
|
|
15
|
-
import { IconSlot } from '../../internal/icon/IconSlot';
|
|
14
|
+
import { useMediaQuery } from '../../internal/hooks/use-media-query';
|
|
16
15
|
import { ovCloneTrigger, OverlayPortal } from '../../internal/overlay/layer';
|
|
17
16
|
import { ModalShell, OV_TAKEOVER_TIMING } from '../../internal/overlay/modal';
|
|
18
17
|
import type { ActivateOn } from '../../internal/utils/activation';
|
|
19
|
-
import {
|
|
18
|
+
import { Sheet } from '../sheet/Sheet';
|
|
19
|
+
import { DialogSurface } from './surface';
|
|
20
|
+
|
|
21
|
+
const SHEET_VIEWPORT = '(max-width: 40rem)';
|
|
20
22
|
|
|
21
23
|
export interface DialogProps {
|
|
22
24
|
/** Controlled open state. Omit for uncontrolled (use defaultOpen + trigger). */
|
|
@@ -33,7 +35,7 @@ export interface DialogProps {
|
|
|
33
35
|
title?: ReactNode;
|
|
34
36
|
/** Subtext under the title - wired to `aria-describedby`. @default null */
|
|
35
37
|
description?: ReactNode;
|
|
36
|
-
/** Panel width. @default 'md' */
|
|
38
|
+
/** Panel width. Below 40rem the dialog opens as a bottom sheet, and 'lg' fills its height. @default 'md' */
|
|
37
39
|
size?: 'sm' | 'md' | 'lg';
|
|
38
40
|
/** 'danger' tints the header icon badge + is the convention for destructive confirms. */
|
|
39
41
|
tone?: 'default' | 'danger';
|
|
@@ -57,113 +59,42 @@ export interface DialogProps {
|
|
|
57
59
|
animation?: DisableableAnimation;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
interface DialogSurfaceProps {
|
|
61
|
-
panelId: string;
|
|
62
|
-
size: 'sm' | 'md' | 'lg';
|
|
63
|
-
tone: 'default' | 'danger';
|
|
64
|
-
icon: ReactNode;
|
|
65
|
-
title: ReactNode;
|
|
66
|
-
description: ReactNode;
|
|
67
|
-
dismissible: boolean;
|
|
68
|
-
footerContent: ReactNode;
|
|
69
|
-
requestClose: () => void;
|
|
70
|
-
htmlProps?: HTMLAttributes<HTMLElement> & DataAttributes;
|
|
71
|
-
children?: ReactNode;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function DialogSurface({
|
|
75
|
-
panelId,
|
|
76
|
-
size,
|
|
77
|
-
tone,
|
|
78
|
-
icon,
|
|
79
|
-
title,
|
|
80
|
-
description,
|
|
81
|
-
dismissible,
|
|
82
|
-
footerContent,
|
|
83
|
-
requestClose,
|
|
84
|
-
htmlProps,
|
|
85
|
-
children,
|
|
86
|
-
}: DialogSurfaceProps) {
|
|
87
|
-
const bodyRef = useRef<HTMLDivElement>(null);
|
|
88
|
-
const titleId = panelId + '-title';
|
|
89
|
-
const descId = panelId + '-desc';
|
|
90
|
-
|
|
91
|
-
useScrollEdges(bodyRef, (edges, el) => {
|
|
92
|
-
el.toggleAttribute('data-scroll-top', edges.top);
|
|
93
|
-
el.toggleAttribute('data-scroll-bottom', edges.bottom);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<section
|
|
98
|
-
{...htmlProps}
|
|
99
|
-
className={cx('zc-dialog', htmlProps?.className)}
|
|
100
|
-
role="dialog"
|
|
101
|
-
aria-modal="true"
|
|
102
|
-
data-size={size === 'md' ? undefined : size}
|
|
103
|
-
data-tone={tone === 'default' ? undefined : tone}
|
|
104
|
-
aria-labelledby={title ? titleId : undefined}
|
|
105
|
-
aria-describedby={description ? descId : undefined}
|
|
106
|
-
>
|
|
107
|
-
{(icon || title || description || dismissible) && (
|
|
108
|
-
<header className="zc-dialog__header">
|
|
109
|
-
{icon && (
|
|
110
|
-
<span className="zc-dialog__icon">
|
|
111
|
-
<IconSlot size="md">{icon}</IconSlot>
|
|
112
|
-
</span>
|
|
113
|
-
)}
|
|
114
|
-
<div className="zc-dialog__heading">
|
|
115
|
-
{title && (
|
|
116
|
-
<h2 className="zc-dialog__title" id={titleId}>
|
|
117
|
-
{title}
|
|
118
|
-
</h2>
|
|
119
|
-
)}
|
|
120
|
-
{description && (
|
|
121
|
-
<p className="zc-dialog__desc" id={descId}>
|
|
122
|
-
{description}
|
|
123
|
-
</p>
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
{dismissible && (
|
|
127
|
-
<button type="button" className="zc-dialog__close" aria-label="Close dialog" onClick={requestClose}>
|
|
128
|
-
<Icon name="x" size="sm" weight="bold" />
|
|
129
|
-
</button>
|
|
130
|
-
)}
|
|
131
|
-
</header>
|
|
132
|
-
)}
|
|
133
|
-
|
|
134
|
-
<div className="zc-dialog__body" ref={bodyRef}>
|
|
135
|
-
{children}
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
{footerContent && <footer className="zc-dialog__footer">{footerContent}</footer>}
|
|
139
|
-
</section>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
62
|
export function Dialog({
|
|
144
63
|
open: controlledOpen,
|
|
145
64
|
defaultOpen = false,
|
|
146
65
|
onOpenChange,
|
|
147
66
|
trigger = null,
|
|
148
67
|
activateOn,
|
|
149
|
-
title,
|
|
150
|
-
description = null,
|
|
151
|
-
size = 'md',
|
|
152
|
-
tone = 'default',
|
|
153
|
-
icon = null,
|
|
154
68
|
dismissible = true,
|
|
155
69
|
container = null,
|
|
156
|
-
footer = null,
|
|
157
|
-
children,
|
|
158
70
|
id,
|
|
159
|
-
htmlProps,
|
|
160
71
|
animation,
|
|
72
|
+
...surfaceProps
|
|
161
73
|
}: DialogProps) {
|
|
162
74
|
const autoId = useId();
|
|
163
75
|
const panelId = id || 'dialog-' + autoId;
|
|
164
76
|
const [open, setOpen] = useControllable(controlledOpen, defaultOpen, onOpenChange);
|
|
165
77
|
const triggerRef = useRef<HTMLElement>(null);
|
|
78
|
+
const asSheet = useMediaQuery(SHEET_VIEWPORT);
|
|
166
79
|
const close = () => setOpen(false);
|
|
80
|
+
const surface = <DialogSurface {...surfaceProps} panelId={panelId} dismissible={dismissible} requestClose={close} />;
|
|
81
|
+
|
|
82
|
+
if (asSheet)
|
|
83
|
+
return (
|
|
84
|
+
<Sheet
|
|
85
|
+
side="bottom"
|
|
86
|
+
open={open}
|
|
87
|
+
onOpenChange={setOpen}
|
|
88
|
+
trigger={trigger}
|
|
89
|
+
activateOn={activateOn}
|
|
90
|
+
dismissible={dismissible}
|
|
91
|
+
container={container}
|
|
92
|
+
id={panelId}
|
|
93
|
+
animation={animation}
|
|
94
|
+
>
|
|
95
|
+
{surface}
|
|
96
|
+
</Sheet>
|
|
97
|
+
);
|
|
167
98
|
|
|
168
99
|
const timings = resolveMotionTiming(animation, OV_TAKEOVER_TIMING, container ?? triggerRef.current);
|
|
169
100
|
|
|
@@ -197,20 +128,7 @@ export function Dialog({
|
|
|
197
128
|
container={container}
|
|
198
129
|
requestClose={close}
|
|
199
130
|
>
|
|
200
|
-
|
|
201
|
-
panelId={panelId}
|
|
202
|
-
size={size}
|
|
203
|
-
tone={tone}
|
|
204
|
-
icon={icon}
|
|
205
|
-
title={title}
|
|
206
|
-
description={description}
|
|
207
|
-
dismissible={dismissible}
|
|
208
|
-
footerContent={typeof footer === 'function' ? footer(close) : footer}
|
|
209
|
-
requestClose={close}
|
|
210
|
-
htmlProps={htmlProps}
|
|
211
|
-
>
|
|
212
|
-
{children}
|
|
213
|
-
</DialogSurface>
|
|
131
|
+
{surface}
|
|
214
132
|
</ModalShell>
|
|
215
133
|
)}
|
|
216
134
|
</Presence>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
|
+
|
|
3
|
+
@layer zyncat.components {
|
|
4
|
+
.zc-overlay-panel--sheet-bottom:has(> .zc-dialog) {
|
|
5
|
+
grid-template-rows: minmax(0, 1fr);
|
|
6
|
+
max-height: calc(100% - var(--space-7));
|
|
7
|
+
border-radius: var(--radius-xl) var(--radius-xl) 0 0;
|
|
8
|
+
}
|
|
9
|
+
.zc-overlay-panel--sheet-bottom:has(> .zc-dialog[data-size='lg']) {
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
.zc-overlay-panel--sheet-bottom > .zc-dialog {
|
|
13
|
+
width: auto;
|
|
14
|
+
max-height: none;
|
|
15
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
16
|
+
border: none;
|
|
17
|
+
border-radius: inherit;
|
|
18
|
+
box-shadow: none;
|
|
19
|
+
}
|
|
20
|
+
.zc-overlay-panel--sheet-bottom[data-drag] > .zc-dialog::before {
|
|
21
|
+
content: '';
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: var(--space-2);
|
|
24
|
+
inset-inline: 0;
|
|
25
|
+
width: var(--space-6);
|
|
26
|
+
height: var(--space-1);
|
|
27
|
+
margin-inline: auto;
|
|
28
|
+
border-radius: var(--radius-full);
|
|
29
|
+
background: var(--border-strong);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -133,6 +133,9 @@
|
|
|
133
133
|
.zc-dialog__body:first-child {
|
|
134
134
|
padding-top: var(--space-5);
|
|
135
135
|
}
|
|
136
|
+
.zc-dialog__body:empty {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
136
139
|
.zc-dialog:has(.zc-dialog__icon) .zc-dialog__body {
|
|
137
140
|
padding-left: calc(var(--space-5) + 2.25rem + var(--space-3));
|
|
138
141
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { DataAttributes } from '../../../dom-props';
|
|
6
|
+
import { useScrollEdges } from '../../internal/hooks/use-scroll-edges';
|
|
7
|
+
import { Icon } from '../../internal/icon/Icon';
|
|
8
|
+
import { IconSlot } from '../../internal/icon/IconSlot';
|
|
9
|
+
import { cx } from '../../internal/utils/cx';
|
|
10
|
+
|
|
11
|
+
interface DialogSurfaceProps {
|
|
12
|
+
panelId: string;
|
|
13
|
+
size?: 'sm' | 'md' | 'lg';
|
|
14
|
+
tone?: 'default' | 'danger';
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
title?: ReactNode;
|
|
17
|
+
description?: ReactNode;
|
|
18
|
+
dismissible: boolean;
|
|
19
|
+
footer?: ReactNode | ((close: () => void) => ReactNode);
|
|
20
|
+
requestClose: () => void;
|
|
21
|
+
htmlProps?: HTMLAttributes<HTMLElement> & DataAttributes;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function DialogSurface({
|
|
26
|
+
panelId,
|
|
27
|
+
size = 'md',
|
|
28
|
+
tone = 'default',
|
|
29
|
+
icon,
|
|
30
|
+
title,
|
|
31
|
+
description,
|
|
32
|
+
dismissible,
|
|
33
|
+
footer,
|
|
34
|
+
requestClose,
|
|
35
|
+
htmlProps,
|
|
36
|
+
children,
|
|
37
|
+
}: DialogSurfaceProps) {
|
|
38
|
+
const bodyRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
const titleId = panelId + '-title';
|
|
40
|
+
const descId = panelId + '-desc';
|
|
41
|
+
const footerContent = typeof footer === 'function' ? footer(requestClose) : footer;
|
|
42
|
+
|
|
43
|
+
useScrollEdges(bodyRef, (edges, el) => {
|
|
44
|
+
el.toggleAttribute('data-scroll-top', edges.top);
|
|
45
|
+
el.toggleAttribute('data-scroll-bottom', edges.bottom);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<section
|
|
50
|
+
{...htmlProps}
|
|
51
|
+
className={cx('zc-dialog', htmlProps?.className)}
|
|
52
|
+
role="dialog"
|
|
53
|
+
aria-modal="true"
|
|
54
|
+
data-size={size === 'md' ? undefined : size}
|
|
55
|
+
data-tone={tone === 'default' ? undefined : tone}
|
|
56
|
+
aria-labelledby={title ? titleId : undefined}
|
|
57
|
+
aria-describedby={description ? descId : undefined}
|
|
58
|
+
>
|
|
59
|
+
{(icon || title || description || dismissible) && (
|
|
60
|
+
<header className="zc-dialog__header">
|
|
61
|
+
{icon && (
|
|
62
|
+
<span className="zc-dialog__icon">
|
|
63
|
+
<IconSlot size="md">{icon}</IconSlot>
|
|
64
|
+
</span>
|
|
65
|
+
)}
|
|
66
|
+
<div className="zc-dialog__heading">
|
|
67
|
+
{title && (
|
|
68
|
+
<h2 className="zc-dialog__title" id={titleId}>
|
|
69
|
+
{title}
|
|
70
|
+
</h2>
|
|
71
|
+
)}
|
|
72
|
+
{description && (
|
|
73
|
+
<p className="zc-dialog__desc" id={descId}>
|
|
74
|
+
{description}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
{dismissible && (
|
|
79
|
+
<button type="button" className="zc-dialog__close" aria-label="Close dialog" onClick={requestClose}>
|
|
80
|
+
<Icon name="x" size="sm" weight="bold" />
|
|
81
|
+
</button>
|
|
82
|
+
)}
|
|
83
|
+
</header>
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
<div className="zc-dialog__body" ref={bodyRef}>
|
|
87
|
+
{children}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{footerContent && <footer className="zc-dialog__footer">{footerContent}</footer>}
|
|
91
|
+
</section>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -4,6 +4,7 @@ import './dropdown.css';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
Fragment,
|
|
7
|
+
useEffect,
|
|
7
8
|
useId,
|
|
8
9
|
useMemo,
|
|
9
10
|
useRef,
|
|
@@ -22,6 +23,7 @@ import { motionFor } from '../../../tokens/motion-tokens';
|
|
|
22
23
|
import { useControllable } from '../../internal/hooks/use-controllable';
|
|
23
24
|
import type { MenuSize, MenuWeight, MenuWidth } from '../../internal/menu/highlight';
|
|
24
25
|
import { ovCloneTrigger, OverlayPortal } from '../../internal/overlay/layer';
|
|
26
|
+
import type { VirtualAnchor } from '../../internal/overlay/position';
|
|
25
27
|
import { pressedByKeyboard, type ActivateOn } from '../../internal/utils/activation';
|
|
26
28
|
import { MenuPanel } from './menu-panel';
|
|
27
29
|
import {
|
|
@@ -40,13 +42,20 @@ const DROPDOWN_TIMING = {
|
|
|
40
42
|
open: { duration: 'base', ease: 'entrance' },
|
|
41
43
|
close: { duration: 'fast', ease: 'exit' },
|
|
42
44
|
} as const;
|
|
45
|
+
const ROOT_SEED = { key: ROOT_LEVEL, focus: 'selected' as SeedFocus };
|
|
46
|
+
const NO_PATH: string[] = [];
|
|
43
47
|
|
|
44
48
|
export interface DropdownProps {
|
|
45
49
|
/** The rows - a flat `DropdownItem[]`, or `DropdownGroup[]` to render divided sections.
|
|
46
50
|
* A row with its own `items` opens a submenu instead of committing. @default [] */
|
|
47
51
|
items: DropdownItems;
|
|
48
|
-
/** Cloned to toggle the menu, and used as the anchor
|
|
49
|
-
|
|
52
|
+
/** Cloned to toggle the menu, and used as the anchor unless `anchor` is set. Gets the
|
|
53
|
+
* `aria-haspopup="menu"` wiring. */
|
|
54
|
+
trigger?: ReactElement | null;
|
|
55
|
+
/** Anchor to an arbitrary rect instead of the trigger - any `{ getBoundingClientRect() }`, which an element
|
|
56
|
+
* also satisfies. Drive `open` yourself, name the menu with `ariaLabel` when there is no trigger, and pass
|
|
57
|
+
* a new object to re-place a moving anchor. Submenus always anchor to their row. */
|
|
58
|
+
anchor?: VirtualAnchor | null;
|
|
50
59
|
/** Whether the trigger and the rows fire on `pointerdown` (snappier) or wait for `click`. @default 'pointerdown' */
|
|
51
60
|
activateOn?: ActivateOn;
|
|
52
61
|
|
|
@@ -94,7 +103,8 @@ export interface DropdownProps {
|
|
|
94
103
|
|
|
95
104
|
export function Dropdown({
|
|
96
105
|
items = [],
|
|
97
|
-
trigger,
|
|
106
|
+
trigger = null,
|
|
107
|
+
anchor,
|
|
98
108
|
activateOn = 'pointerdown',
|
|
99
109
|
open: controlledOpen,
|
|
100
110
|
defaultOpen = false,
|
|
@@ -114,13 +124,14 @@ export function Dropdown({
|
|
|
114
124
|
animation,
|
|
115
125
|
}: DropdownProps) {
|
|
116
126
|
const [open, setOpen] = useControllable(controlledOpen, defaultOpen, onOpenChange);
|
|
117
|
-
const [path, setPath] = useState
|
|
118
|
-
const [seed, setSeed] = useState(
|
|
127
|
+
const [path, setPath] = useState(NO_PATH);
|
|
128
|
+
const [seed, setSeed] = useState(ROOT_SEED);
|
|
119
129
|
|
|
120
130
|
const refs = useRef(new Map<string, RefObject<HTMLElement>>());
|
|
121
131
|
const hoverDepth = useRef(-1);
|
|
122
132
|
const autoId = useId();
|
|
123
133
|
const menuId = id || 'dropdown-' + autoId;
|
|
134
|
+
const triggerId = (trigger?.props as { id?: string } | undefined)?.id ?? menuId + '-trigger';
|
|
124
135
|
const levels = useMemo(() => resolveLevels(items, path), [items, path]);
|
|
125
136
|
|
|
126
137
|
const refFor = (key: string): RefObject<HTMLElement> => {
|
|
@@ -130,6 +141,12 @@ export function Dropdown({
|
|
|
130
141
|
const triggerRef = refFor('trigger');
|
|
131
142
|
const timings = resolveMotionTiming(animation, DROPDOWN_TIMING, triggerRef.current);
|
|
132
143
|
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (open) return;
|
|
146
|
+
setSeed(ROOT_SEED);
|
|
147
|
+
setPath(NO_PATH);
|
|
148
|
+
}, [open]);
|
|
149
|
+
|
|
133
150
|
const dismiss = (refocus: boolean) => {
|
|
134
151
|
setPath([]);
|
|
135
152
|
hoverDepth.current = -1;
|
|
@@ -146,6 +163,8 @@ export function Dropdown({
|
|
|
146
163
|
const chain: MenuChain = {
|
|
147
164
|
levels,
|
|
148
165
|
menuId,
|
|
166
|
+
triggerId,
|
|
167
|
+
anchor,
|
|
149
168
|
activateOn,
|
|
150
169
|
side,
|
|
151
170
|
align,
|
|
@@ -184,7 +203,11 @@ export function Dropdown({
|
|
|
184
203
|
<Fragment>
|
|
185
204
|
{ovCloneTrigger(trigger, {
|
|
186
205
|
open,
|
|
187
|
-
onPress: (e) =>
|
|
206
|
+
onPress: (e) => {
|
|
207
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
208
|
+
if (open) dismiss(false);
|
|
209
|
+
else show(pressedByKeyboard(e) ? 'first' : 'selected');
|
|
210
|
+
},
|
|
188
211
|
onKeyDown: (e) => {
|
|
189
212
|
if (open || (e.key !== 'ArrowDown' && e.key !== 'ArrowUp')) return;
|
|
190
213
|
e.preventDefault();
|
|
@@ -194,6 +217,8 @@ export function Dropdown({
|
|
|
194
217
|
haspopup: 'menu',
|
|
195
218
|
triggerRef,
|
|
196
219
|
activateOn,
|
|
220
|
+
holdFocus: true,
|
|
221
|
+
attrs: { id: triggerId },
|
|
197
222
|
})}
|
|
198
223
|
<OverlayPortal scope={triggerRef.current}>
|
|
199
224
|
<Presence>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
--menu-max-height: min(26rem, 70vh);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.zc-dropdown__menu[data-
|
|
9
|
+
.zc-dropdown__menu:has(.zc-dropdown__item[data-active='true'][data-danger='true']) {
|
|
10
10
|
--menu-glide-fill: var(--danger-wash);
|
|
11
11
|
--menu-glide-rail: var(--danger);
|
|
12
12
|
}
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
|
|
70
70
|
.zc-dropdown__item-shortcut {
|
|
71
71
|
flex: 0 0 auto;
|
|
72
|
-
font: var(--type-
|
|
72
|
+
font: var(--type-caption);
|
|
73
73
|
font-variant-numeric: tabular-nums;
|
|
74
74
|
color: var(--text-subtle);
|
|
75
75
|
padding-left: var(--space-2);
|