@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
package/src/motion/crossfade.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { animate, measure, type Box, type FlipOptions, type Playback } from '../engine';
|
|
1
|
+
import { animate, measure, offscreen, type Box, type FlipOptions, type Layer, type Playback } from '../engine';
|
|
2
2
|
import { claim } from '../engine/animate';
|
|
3
|
+
import type { Timing } from '../engine/ease';
|
|
3
4
|
import { sharedSlot } from '../shared-slot';
|
|
4
5
|
import { inheritedThemeAttrs } from '../theme-scope';
|
|
6
|
+
import { flushBeforePaint } from './before-paint';
|
|
5
7
|
|
|
6
8
|
const SHOWN_BY = 0.45;
|
|
7
9
|
const GONE_BY = 0.5;
|
|
@@ -15,6 +17,7 @@ interface Copy {
|
|
|
15
17
|
|
|
16
18
|
const kept = sharedSlot('motion.crossfade@2', () => new Map<string, Copy>());
|
|
17
19
|
const riding = new WeakMap<HTMLElement, Copy>();
|
|
20
|
+
const twins = new WeakMap<HTMLElement, HTMLElement>();
|
|
18
21
|
|
|
19
22
|
function onto(el: HTMLElement, box: Box, target: Box): { x: number; y: number; scale: number } {
|
|
20
23
|
const [px, py] = getComputedStyle(el).transformOrigin.split(' ').map(parseFloat);
|
|
@@ -26,11 +29,11 @@ function onto(el: HTMLElement, box: Box, target: Box): { x: number; y: number; s
|
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
function copyOf(el: HTMLElement, box: Box, look: HTMLElement = el): HTMLElement {
|
|
30
33
|
const copy = el.cloneNode(true) as HTMLElement;
|
|
31
34
|
for (const node of [copy, ...copy.querySelectorAll('[id]')]) node.removeAttribute('id');
|
|
32
35
|
for (const [name, value] of Object.entries(inheritedThemeAttrs(el))) if (value) copy.setAttribute(name, value);
|
|
33
|
-
const { font, color, opacity } = getComputedStyle(
|
|
36
|
+
const { font, color, opacity } = getComputedStyle(look);
|
|
34
37
|
Object.assign(copy.style, {
|
|
35
38
|
position: 'fixed',
|
|
36
39
|
left: `${box.left - window.scrollX}px`,
|
|
@@ -50,13 +53,49 @@ export function keep(id: string, el: HTMLElement, box: Box, { timing }: FlipOpti
|
|
|
50
53
|
copy.inert = true;
|
|
51
54
|
copy.setAttribute('aria-hidden', 'true');
|
|
52
55
|
document.body.append(copy);
|
|
56
|
+
return copy;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clipping(from: Element | null): Element | null {
|
|
60
|
+
for (let node = from; node; node = node.parentElement) {
|
|
61
|
+
const { overflowX, overflowY } = getComputedStyle(node);
|
|
62
|
+
if (overflowX !== 'visible' || overflowY !== 'visible') return node;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function clipTo(copy: HTMLElement, box: Box, stage: Element | null): void {
|
|
68
|
+
const x = box.left - window.scrollX;
|
|
69
|
+
const y = box.top - window.scrollY;
|
|
70
|
+
let [top, right, bottom, left] = [0, 0, 0, 0];
|
|
71
|
+
for (let node = stage; node; node = clipping(node.parentElement)) {
|
|
72
|
+
const rect = node.getBoundingClientRect();
|
|
73
|
+
top = Math.max(top, rect.top - y);
|
|
74
|
+
right = Math.max(right, x + box.width - rect.right);
|
|
75
|
+
bottom = Math.max(bottom, y + box.height - rect.bottom);
|
|
76
|
+
left = Math.max(left, rect.left - x);
|
|
77
|
+
}
|
|
78
|
+
if (top || right || bottom || left) copy.style.clipPath = `inset(${top}px ${right}px ${bottom}px ${left}px)`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function keep(id: string, el: HTMLElement, box: Box, timing?: Timing, margin?: number): void {
|
|
82
|
+
const twin = twins.get(el);
|
|
83
|
+
const copy = copyOf(el, box, twin?.isConnected ? twin : el);
|
|
84
|
+
const stage = clipping(el.parentElement);
|
|
53
85
|
const entry: Copy = { el: copy, box, of: el };
|
|
54
86
|
kept.set(id, entry);
|
|
55
87
|
queueMicrotask(() => {
|
|
56
|
-
|
|
88
|
+
flushBeforePaint();
|
|
89
|
+
if (kept.get(id) !== entry) {
|
|
90
|
+
if (!entry.play) copy.remove();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
57
93
|
kept.delete(id);
|
|
58
|
-
if (el.isConnected) copy.remove();
|
|
59
|
-
else
|
|
94
|
+
if (el.isConnected || stage?.isConnected === false || offscreen(margin, box)) copy.remove();
|
|
95
|
+
else {
|
|
96
|
+
clipTo(copy, box, stage);
|
|
97
|
+
animate(copy, { opacity: [0], timing }).finished.then(() => copy.remove());
|
|
98
|
+
}
|
|
60
99
|
});
|
|
61
100
|
}
|
|
62
101
|
|
|
@@ -87,11 +126,18 @@ export function play(id: string, el: HTMLElement, from: Box, { timing }: FlipOpt
|
|
|
87
126
|
run.finished.then(() => {
|
|
88
127
|
if (copy.play === run) copy.el.remove();
|
|
89
128
|
});
|
|
90
|
-
|
|
129
|
+
const arrive = (opacity: number[]): Layer => ({
|
|
91
130
|
x: [back.x, 0],
|
|
92
131
|
y: [back.y, 0],
|
|
93
132
|
scale: [back.scale, 1],
|
|
94
|
-
opacity
|
|
133
|
+
opacity,
|
|
95
134
|
timing: { fill: 'backwards', ...timing, times: [0, SHOWN_BY, 1] },
|
|
96
135
|
});
|
|
136
|
+
const twin = copyOf(el, to);
|
|
137
|
+
twin.style.zIndex = 'var(--layer-infinity)';
|
|
138
|
+
twins.set(el, twin);
|
|
139
|
+
animate(twin, arrive([0, rest, rest]));
|
|
140
|
+
const flight = animate(el, arrive([0, 0, 0]));
|
|
141
|
+
flight.finished.then(() => twin.remove());
|
|
142
|
+
return flight;
|
|
97
143
|
}
|
package/src/motion/element.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { createElement, useCallback, useLayoutEffect, useRef, type ReactNode, type Ref } from 'react';
|
|
3
|
+
import { Component, createElement, useCallback, useLayoutEffect, useRef, type ReactNode, type Ref } from 'react';
|
|
4
4
|
|
|
5
5
|
import { useFlip, type FlipTuning } from './flip';
|
|
6
6
|
import { usePresence } from './presence-context';
|
|
@@ -20,12 +20,26 @@ export interface MotionProps extends MotionSpecs {
|
|
|
20
20
|
[prop: string]: unknown;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
class BeforeCommit extends Component<{ read: () => void; children?: ReactNode }> {
|
|
24
|
+
getSnapshotBeforeUpdate(): null {
|
|
25
|
+
this.props.read();
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
componentDidUpdate() {}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
return this.props.children;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
export function Motion({
|
|
24
37
|
as = 'div',
|
|
25
38
|
animate,
|
|
26
39
|
exit,
|
|
27
40
|
initial,
|
|
28
41
|
deps,
|
|
42
|
+
offscreenMargin,
|
|
29
43
|
layout,
|
|
30
44
|
layoutId,
|
|
31
45
|
layoutTransition,
|
|
@@ -34,12 +48,12 @@ export function Motion({
|
|
|
34
48
|
...rest
|
|
35
49
|
}: MotionProps) {
|
|
36
50
|
const { isPresent } = usePresence();
|
|
37
|
-
const flip = useFlip<HTMLElement>(layoutId ?? null, layoutTransition, !!layout);
|
|
51
|
+
const flip = useFlip<HTMLElement>(layoutId ?? null, { ...layoutTransition, offscreenMargin }, !!layout);
|
|
38
52
|
const host = useRef<HTMLElement | null>(null);
|
|
39
53
|
const forwarded = useRef(ref);
|
|
40
54
|
forwarded.current = ref;
|
|
41
55
|
|
|
42
|
-
useMotion(host, { animate, exit, initial, deps });
|
|
56
|
+
useMotion(host, { animate, exit, initial, deps, offscreenMargin });
|
|
43
57
|
useLayoutEffect(flip.play);
|
|
44
58
|
|
|
45
59
|
const attach = useCallback(
|
|
@@ -53,5 +67,9 @@ export function Motion({
|
|
|
53
67
|
[flip.ref],
|
|
54
68
|
);
|
|
55
69
|
|
|
56
|
-
return createElement(
|
|
70
|
+
return createElement(
|
|
71
|
+
BeforeCommit,
|
|
72
|
+
{ read: flip.snapshot },
|
|
73
|
+
createElement(as, { ...rest, 'data-exiting': isPresent ? undefined : 'true', ref: attach }, children),
|
|
74
|
+
);
|
|
57
75
|
}
|
package/src/motion/flip.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { useLayoutEffect, useRef, type RefObject } from 'react';
|
|
3
|
+
import { useLayoutEffect, useRef, type EffectCallback, type RefObject } from 'react';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
animate,
|
|
6
7
|
dropShared,
|
|
7
|
-
flip,
|
|
8
8
|
keepShared,
|
|
9
9
|
measure,
|
|
10
|
+
offscreen,
|
|
10
11
|
readShared,
|
|
11
12
|
type Box,
|
|
12
13
|
type FlipOptions,
|
|
13
14
|
type Playback,
|
|
14
15
|
} from '../engine';
|
|
15
|
-
import {
|
|
16
|
+
import { flipLayers } from '../engine/flip';
|
|
16
17
|
import { UIMotion } from '../tokens/motion-tokens';
|
|
18
|
+
import { beforePaint } from './before-paint';
|
|
19
|
+
import { leaving, measureHolders, sharedOwner } from './holders';
|
|
17
20
|
|
|
18
21
|
export interface FlipTuning extends FlipOptions {
|
|
19
22
|
/** Keep the element that last held the `layoutId` on screen through the handoff: a copy of it takes the same path and fades out while this one fades in. */
|
|
@@ -22,8 +25,6 @@ export interface FlipTuning extends FlipOptions {
|
|
|
22
25
|
|
|
23
26
|
const SAME_BOX_PX = 0.5;
|
|
24
27
|
|
|
25
|
-
const sharedOwner = sharedSlot('motion.flip-owner@1', () => new Map<string, HTMLElement>());
|
|
26
|
-
|
|
27
28
|
let loadedCrossfade: typeof import('./crossfade') | null = null;
|
|
28
29
|
|
|
29
30
|
const loadCrossfade = (): void => {
|
|
@@ -37,55 +38,66 @@ const sameBox = (a: Box, b: Box): boolean =>
|
|
|
37
38
|
|
|
38
39
|
export function useFlip<T extends HTMLElement>(
|
|
39
40
|
sharedId: string | null,
|
|
40
|
-
tuning: FlipTuning = {},
|
|
41
|
+
tuning: FlipTuning & { offscreenMargin?: number } = {},
|
|
41
42
|
inPlace: boolean,
|
|
42
|
-
): { ref: RefObject<T | null>; play: () => void } {
|
|
43
|
+
): { ref: RefObject<T | null>; play: EffectCallback; snapshot: () => void } {
|
|
43
44
|
const ref = useRef<T | null>(null);
|
|
45
|
+
const lastCommitted = useRef<Box | null>(null);
|
|
44
46
|
const playing = useRef<{ play: Playback; el: T } | null>(null);
|
|
47
|
+
const superseded = useRef<Playback | null>(null);
|
|
48
|
+
const queued = useRef<object | null>(null);
|
|
49
|
+
const held = useRef<string | null>(null);
|
|
45
50
|
const interrupted = useRef<Box | null>(null);
|
|
46
51
|
const origin = useRef<Box | null>(null);
|
|
47
52
|
const latest = useRef(tuning);
|
|
48
53
|
latest.current = tuning;
|
|
49
|
-
const { size, timing, crossfade } = tuning;
|
|
54
|
+
const { size, timing, crossfade, offscreenMargin } = tuning;
|
|
50
55
|
const enabled = inPlace || sharedId !== null;
|
|
51
|
-
|
|
56
|
+
if (enabled) measureHolders();
|
|
57
|
+
const holder = sharedId === null ? undefined : sharedOwner.get(sharedId);
|
|
58
|
+
if (holder && holder !== ref.current && holder.isConnected) leaving.set(holder, measure(holder));
|
|
52
59
|
|
|
53
60
|
useLayoutEffect(() => {
|
|
54
61
|
const el = ref.current;
|
|
55
62
|
if (!el || !enabled) return;
|
|
63
|
+
leaving.clear();
|
|
56
64
|
if (crossfade) loadCrossfade();
|
|
57
65
|
const live = playing.current;
|
|
58
66
|
const midFlight = live?.el === el;
|
|
59
|
-
const moved = !!lastCommitted && !sameBox(lastCommitted, measure(el));
|
|
67
|
+
const moved = !!lastCommitted.current && !sameBox(lastCommitted.current, measure(el));
|
|
60
68
|
if (midFlight && !moved) return;
|
|
61
|
-
let from = moved ? lastCommitted : null;
|
|
69
|
+
let from = moved ? lastCommitted.current : null;
|
|
62
70
|
if (sharedId !== null && !midFlight) {
|
|
63
71
|
if (interrupted.current) from = interrupted.current;
|
|
64
72
|
else if (sharedOwner.get(sharedId) !== el) from = readShared(sharedId);
|
|
65
73
|
}
|
|
66
|
-
live?.play
|
|
74
|
+
superseded.current = live?.play ?? null;
|
|
67
75
|
playing.current = null;
|
|
68
76
|
interrupted.current = null;
|
|
69
77
|
if (sharedId !== null) {
|
|
70
78
|
keepShared(sharedId, measure(el));
|
|
71
79
|
sharedOwner.set(sharedId, el);
|
|
72
80
|
}
|
|
73
|
-
origin.current
|
|
81
|
+
origin.current ??= from;
|
|
74
82
|
});
|
|
75
83
|
|
|
76
84
|
useLayoutEffect(() => {
|
|
77
85
|
if (sharedId === null) return;
|
|
86
|
+
held.current = sharedId;
|
|
78
87
|
return () => {
|
|
88
|
+
held.current = null;
|
|
79
89
|
const live = playing.current;
|
|
80
|
-
|
|
90
|
+
measureHolders();
|
|
91
|
+
let box: Box | null = (ref.current && leaving.get(ref.current)) ?? (live ? measure(live.el) : null);
|
|
81
92
|
if (!usable(box)) box = ref.current ? measure(ref.current) : null;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
playing.current = null;
|
|
93
|
+
const painted = !origin.current;
|
|
94
|
+
if (painted && latest.current.crossfade && loadedCrossfade && ref.current && usable(box) && !UIMotion.reduced)
|
|
95
|
+
loadedCrossfade.keep(sharedId, ref.current, box, latest.current.timing, latest.current.offscreenMargin);
|
|
86
96
|
if (usable(box)) keepShared(sharedId, box);
|
|
87
97
|
const mine = readShared(sharedId);
|
|
88
98
|
queueMicrotask(() => {
|
|
99
|
+
if (held.current === sharedId) return;
|
|
100
|
+
if (live && !live.el.isConnected) live.play.stop();
|
|
89
101
|
if (readShared(sharedId) === mine) dropShared(sharedId);
|
|
90
102
|
const owner = sharedOwner.get(sharedId);
|
|
91
103
|
if (owner && !owner.isConnected) sharedOwner.delete(sharedId);
|
|
@@ -94,25 +106,45 @@ export function useFlip<T extends HTMLElement>(
|
|
|
94
106
|
}, [sharedId]);
|
|
95
107
|
|
|
96
108
|
const play = () => {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
origin.current
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
const stale = superseded.current;
|
|
110
|
+
superseded.current = null;
|
|
111
|
+
if (!origin.current && !stale) return;
|
|
112
|
+
const job = {};
|
|
113
|
+
queued.current = job;
|
|
114
|
+
beforePaint(() => {
|
|
115
|
+
if (queued.current !== job) return;
|
|
116
|
+
const el = ref.current;
|
|
117
|
+
const from = origin.current;
|
|
118
|
+
origin.current = null;
|
|
119
|
+
if (!el || !usable(from) || UIMotion.reduced) return;
|
|
120
|
+
const to = measure(el);
|
|
121
|
+
if (offscreen(offscreenMargin, from, to)) return;
|
|
122
|
+
const layers = flipLayers(el, from, to, { size, timing });
|
|
123
|
+
return () => {
|
|
124
|
+
const handoff =
|
|
125
|
+
sharedId !== null && crossfade && loadedCrossfade
|
|
126
|
+
? loadedCrossfade.play(sharedId, el, from, { timing })
|
|
127
|
+
: undefined;
|
|
128
|
+
const next = handoff === undefined ? layers && animate(el, ...layers) : handoff;
|
|
129
|
+
if (!next) return;
|
|
130
|
+
playing.current = { play: next, el };
|
|
131
|
+
interrupted.current = from;
|
|
132
|
+
next.finished.then(() => {
|
|
133
|
+
if (playing.current?.play === next) {
|
|
134
|
+
playing.current = null;
|
|
135
|
+
interrupted.current = null;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
}, stale?.stop);
|
|
140
|
+
return () => {
|
|
141
|
+
queued.current = null;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const snapshot = () => {
|
|
146
|
+
lastCommitted.current = ref.current && (inPlace || playing.current) ? measure(ref.current) : null;
|
|
115
147
|
};
|
|
116
148
|
|
|
117
|
-
return { ref, play };
|
|
149
|
+
return { ref, play, snapshot };
|
|
118
150
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { measure, type Box } from '../engine';
|
|
2
|
+
import { sharedSlot } from '../shared-slot';
|
|
3
|
+
|
|
4
|
+
export const sharedOwner = sharedSlot('motion.flip-owner@1', () => new Map<string, HTMLElement>());
|
|
5
|
+
export const leaving = sharedSlot('motion.flip-leaving@1', () => new Map<HTMLElement, Box>());
|
|
6
|
+
|
|
7
|
+
export function measureHolders(): void {
|
|
8
|
+
if (leaving.size || !sharedOwner.size) return;
|
|
9
|
+
for (const holder of sharedOwner.values()) if (holder.isConnected) leaving.set(holder, measure(holder));
|
|
10
|
+
}
|
package/src/motion/presence.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type ReactNode,
|
|
13
13
|
} from 'react';
|
|
14
14
|
|
|
15
|
-
import { PresenceContext } from './presence-context';
|
|
15
|
+
import { PresenceContext, type PresenceState } from './presence-context';
|
|
16
16
|
|
|
17
17
|
interface Entry {
|
|
18
18
|
key: string;
|
|
@@ -64,6 +64,7 @@ export function Presence({ children, initial = true, mode = 'sync', onExitComple
|
|
|
64
64
|
const signature = incoming.map((entry) => entry.key).join('|');
|
|
65
65
|
const claims = useRef<Claims>(new Map());
|
|
66
66
|
const latest = useRef<Latest>(new Map());
|
|
67
|
+
const values = useRef({ membership: '', byKey: new Map<string, PresenceState>() });
|
|
67
68
|
for (const entry of incoming) latest.current.set(entry.key, entry.node);
|
|
68
69
|
const [tracked, setTracked] = useState<Tracked>({ shown: incoming, signature });
|
|
69
70
|
const bornAtMount = useRef(new Set(incoming.map((entry) => entry.key)));
|
|
@@ -115,20 +116,28 @@ export function Presence({ children, initial = true, mode = 'sync', onExitComple
|
|
|
115
116
|
const fresh = new Map(incoming.map((entry) => [entry.key, entry.node]));
|
|
116
117
|
const visible = mode === 'wait' && leaving ? shown.filter((entry) => entry.exiting) : shown;
|
|
117
118
|
|
|
119
|
+
const membership = visible.map((entry) => entry.key).join('|');
|
|
120
|
+
const reflowed = values.current.membership !== membership;
|
|
121
|
+
const priorValues = values.current.byKey;
|
|
122
|
+
values.current = { membership, byKey: new Map() };
|
|
123
|
+
const valueFor = ({ key, exiting }: Entry): PresenceState => {
|
|
124
|
+
const born = initial || !bornAtMount.current.has(key);
|
|
125
|
+
const kept = reflowed ? undefined : priorValues.get(key);
|
|
126
|
+
const value =
|
|
127
|
+
kept?.isPresent === !exiting && kept.initial === born
|
|
128
|
+
? kept
|
|
129
|
+
: { isPresent: !exiting, initial: born, claimExit: claimExit(key) };
|
|
130
|
+
values.current.byKey.set(key, value);
|
|
131
|
+
return value;
|
|
132
|
+
};
|
|
133
|
+
|
|
118
134
|
return createElement(
|
|
119
135
|
Fragment,
|
|
120
136
|
null,
|
|
121
137
|
visible.map((entry) =>
|
|
122
138
|
createElement(
|
|
123
139
|
PresenceContext.Provider,
|
|
124
|
-
{
|
|
125
|
-
key: entry.key,
|
|
126
|
-
value: {
|
|
127
|
-
isPresent: !entry.exiting,
|
|
128
|
-
initial: initial || !bornAtMount.current.has(entry.key),
|
|
129
|
-
claimExit: claimExit(entry.key),
|
|
130
|
-
},
|
|
131
|
-
},
|
|
140
|
+
{ key: entry.key, value: valueFor(entry) },
|
|
132
141
|
fresh.get(entry.key) ?? entry.node,
|
|
133
142
|
),
|
|
134
143
|
),
|
package/src/motion/use-motion.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { useLayoutEffect, useRef, type RefObject } from 'react';
|
|
4
4
|
|
|
5
|
-
import { animate, type Layer, type Playback } from '../engine';
|
|
5
|
+
import { animate, measure, offscreen, type Layer, type Playback } from '../engine';
|
|
6
|
+
import { beforePaint } from './before-paint';
|
|
6
7
|
import { usePresence } from './presence-context';
|
|
7
8
|
|
|
8
9
|
export type Plays = Playback | Playback[] | null | undefined | void;
|
|
@@ -16,6 +17,9 @@ export function run(spec: MotionSpec | undefined, el: HTMLElement): Playback[] {
|
|
|
16
17
|
return [Array.isArray(spec) ? animate(el, ...spec) : animate(el, spec)];
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
const landed = (layers: Layer[]): Layer[] =>
|
|
21
|
+
layers.map((layer) => ({ ...layer, timing: { duration: 0, fill: layer.timing?.fill } }));
|
|
22
|
+
|
|
19
23
|
const sameDeps = (a: unknown[], b: unknown[]): boolean =>
|
|
20
24
|
a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
|
|
21
25
|
|
|
@@ -31,12 +35,19 @@ export interface MotionSpecs {
|
|
|
31
35
|
initial?: boolean;
|
|
32
36
|
/** Replay `animate` when these change. Must keep a stable length. @default [] */
|
|
33
37
|
deps?: unknown[];
|
|
38
|
+
/** How far outside the viewport, in px, this element still animates; further out, `animate` and layout moves land on their end state at once. `Infinity` always animates. @default 100 */
|
|
39
|
+
offscreenMargin?: number;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
/** Drives `<Motion>`; use it directly on elements you hold a ref to but do not render. */
|
|
37
|
-
export function useMotion(
|
|
43
|
+
export function useMotion(
|
|
44
|
+
ref: RefObject<HTMLElement | null>,
|
|
45
|
+
{ animate, exit, initial, deps, offscreenMargin }: MotionSpecs,
|
|
46
|
+
): void {
|
|
38
47
|
const presence = usePresence();
|
|
39
48
|
const playing = useRef<Playback[]>([]);
|
|
49
|
+
const pending = useRef<object | null>(null);
|
|
50
|
+
const mounted = useRef(false);
|
|
40
51
|
const ran = useRef<unknown[] | null>(null);
|
|
41
52
|
const exiting = useRef(false);
|
|
42
53
|
const spec = useRef({ animate, exit, initial });
|
|
@@ -45,6 +56,7 @@ export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, i
|
|
|
45
56
|
const ownsExit = !!exit;
|
|
46
57
|
|
|
47
58
|
const stop = () => {
|
|
59
|
+
pending.current = null;
|
|
48
60
|
for (const play of playing.current) play.stop();
|
|
49
61
|
playing.current = [];
|
|
50
62
|
};
|
|
@@ -65,9 +77,23 @@ export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, i
|
|
|
65
77
|
const previous = ran.current;
|
|
66
78
|
ran.current = current;
|
|
67
79
|
const atMount = !previous || sameDeps(previous, current);
|
|
80
|
+
if (previous && atMount && (pending.current || playing.current.length)) return;
|
|
68
81
|
if (atMount && (spec.current.initial ?? presence.initial) === false) return;
|
|
69
82
|
stop();
|
|
70
|
-
|
|
83
|
+
const animation = spec.current.animate;
|
|
84
|
+
if (!animation || typeof animation === 'function') {
|
|
85
|
+
playing.current = run(animation, el);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const token = {};
|
|
89
|
+
pending.current = token;
|
|
90
|
+
beforePaint(() => {
|
|
91
|
+
if (pending.current !== token) return;
|
|
92
|
+
const layers = offscreen(offscreenMargin, measure(el)) ? landed([animation].flat()) : animation;
|
|
93
|
+
return () => {
|
|
94
|
+
playing.current = run(layers, el);
|
|
95
|
+
};
|
|
96
|
+
});
|
|
71
97
|
}, deps ?? []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
72
98
|
|
|
73
99
|
useLayoutEffect(() => {
|
|
@@ -89,5 +115,13 @@ export function useMotion(ref: RefObject<HTMLElement | null>, { animate, exit, i
|
|
|
89
115
|
});
|
|
90
116
|
}, [presence.isPresent]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
91
117
|
|
|
92
|
-
useLayoutEffect(() =>
|
|
118
|
+
useLayoutEffect(() => {
|
|
119
|
+
mounted.current = true;
|
|
120
|
+
return () => {
|
|
121
|
+
mounted.current = false;
|
|
122
|
+
queueMicrotask(() => {
|
|
123
|
+
if (!mounted.current) stop();
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}, []);
|
|
93
127
|
}
|
package/src/tokens/base.css
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.base {
|
|
4
|
-
/* Drives native scrollbars, caret, select popups, and autofill background. */
|
|
5
|
-
:root {
|
|
6
|
-
color-scheme: light dark;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
/* Only reaches these four; scoped so it stops inheriting everywhere. */
|
|
10
5
|
:where(input[type='checkbox'], input[type='radio'], input[type='range'], progress) {
|
|
11
6
|
accent-color: var(--accent);
|
package/src/tokens/dark.css
CHANGED
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
|
|
35
35
|
/* A light face reads as a light source on dark, so the fills drop a step while the lift stays put. */
|
|
36
36
|
--accent-fill: oklch(from var(--accent) calc(l - 0.06) calc(c - 0.01) h);
|
|
37
|
-
--accent-subtle: oklch(from var(--accent) 0.27 0.045 h);
|
|
38
|
-
--accent-border: oklch(from var(--accent) 0.45 0.09 h);
|
|
39
|
-
--accent-disabled: oklch(from var(--accent) 0.42 0.06 h);
|
|
37
|
+
--accent-subtle: oklch(from var(--accent) 0.27 min(c, 0.045) h);
|
|
38
|
+
--accent-border: oklch(from var(--accent) 0.45 min(c, 0.09) h);
|
|
39
|
+
--accent-disabled: oklch(from var(--accent) 0.42 min(c, 0.06) h);
|
|
40
40
|
--accent-wash: oklch(from var(--accent) l c h / 0.14);
|
|
41
41
|
--text-accent: oklch(from var(--accent) calc(l + 0.14) calc(c - 0.012) h);
|
|
42
42
|
|
|
43
|
-
--info-subtle: oklch(from var(--info) 0.265 0.045 h);
|
|
43
|
+
--info-subtle: oklch(from var(--info) 0.265 min(c, 0.045) h);
|
|
44
44
|
--info-text: oklch(from var(--info) calc(l + 0.22) calc(c - 0.014) h);
|
|
45
|
-
--info-wash: oklch(from var(--info) 0.63 0.118 h / 0.14);
|
|
45
|
+
--info-wash: oklch(from var(--info) 0.63 min(c, 0.118) h / 0.14);
|
|
46
46
|
|
|
47
47
|
--success-subtle: oklch(from var(--success) 0.265 0.05 h);
|
|
48
48
|
--success-text: oklch(from var(--success) calc(l + 0.23) calc(c - 0.02) h);
|
|
@@ -5,16 +5,23 @@
|
|
|
5
5
|
* Generated from the token and component CSS by `scripts/gen-theme.mjs` - `pnpm sync` rebuilds it.
|
|
6
6
|
*/
|
|
7
7
|
export const motionDefaults = {
|
|
8
|
-
duration: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
duration: {
|
|
9
|
+
fast: 140,
|
|
10
|
+
base: 240,
|
|
11
|
+
moderate: 320,
|
|
12
|
+
slow: 420,
|
|
13
|
+
slower: 600,
|
|
14
|
+
slowest: 800,
|
|
15
|
+
spin: 1000,
|
|
16
|
+
pulse: 1600,
|
|
17
|
+
} satisfies Record<string, number>,
|
|
12
18
|
ease: {
|
|
13
19
|
standard: [0.2, 0, 0, 1],
|
|
14
|
-
entrance: [0.
|
|
15
|
-
exit: [0.
|
|
16
|
-
spring: [0.
|
|
17
|
-
glide: [0.
|
|
20
|
+
entrance: [0.22, 1, 0.36, 1],
|
|
21
|
+
exit: [0.3, 0, 0.3, 1],
|
|
22
|
+
spring: [0.3, 1.5, 0.5, 1],
|
|
23
|
+
glide: [0.22, 1, 0.36, 1],
|
|
24
|
+
move: [0.55, 0, 0.15, 1],
|
|
18
25
|
} satisfies Record<string, [number, number, number, number]>,
|
|
19
26
|
distance: { sm: 8, md: 16, lg: 24 } satisfies Record<string, number>,
|
|
20
27
|
scale: { panel: 0.98, floating: 0.96, chip: 0.9 } satisfies Record<string, number>,
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
/** Names of the UI-transition duration scale (`--duration-*`):
|
|
2
|
-
* - `fast` 140ms - micro feedback: hover washes, presses, control tint/border/shadow.
|
|
3
|
-
* - `base`
|
|
4
|
-
* - `
|
|
5
|
-
* - `
|
|
6
|
-
* - `
|
|
7
|
-
*
|
|
8
|
-
|
|
1
|
+
/** Names of the UI-transition duration scale (`--duration-*`), the studio's motion:
|
|
2
|
+
* - `fast` 140ms - micro feedback: hover washes, presses, control tint/border/shadow, an exit.
|
|
3
|
+
* - `base` 240ms - standard element transitions: fades, toggles, a pill gliding between rows.
|
|
4
|
+
* - `moderate` 320ms - small layout movement: a fold opening, a reorder, a FLIP to a new place.
|
|
5
|
+
* - `slow` 420ms - layout-scale movement: Collapse, panel resizes, a larger block arriving.
|
|
6
|
+
* - `slower` 600ms - large-surface movement: dialogs, sheets, an element flying across the page.
|
|
7
|
+
* - `slowest` 800ms - hero-scale movement: container morphs, slow cross-fades of a whole view. The
|
|
8
|
+
* scale's ceiling: anything longer is choreography and belongs to Motion, not a transition token. */
|
|
9
|
+
export type DurationToken = 'fast' | 'base' | 'moderate' | 'slow' | 'slower' | 'slowest';
|
|
9
10
|
|
|
10
11
|
/** Names of the brand easing curves (`--ease-*`):
|
|
11
|
-
* - `standard` cubic-bezier(0.2, 0, 0, 1) - brisk start, soft landing;
|
|
12
|
-
* - `entrance` cubic-bezier(0.
|
|
13
|
-
* - `exit` cubic-bezier(0.
|
|
14
|
-
* - `spring` cubic-bezier(0.
|
|
15
|
-
* - `glide` cubic-bezier(0.
|
|
16
|
-
* new target, never enter/exit.
|
|
17
|
-
|
|
12
|
+
* - `standard` cubic-bezier(0.2, 0, 0, 1) - brisk start, soft landing; state changes and the press.
|
|
13
|
+
* - `entrance` cubic-bezier(0.22, 1, 0.36, 1) - hard deceleration; content arriving on screen.
|
|
14
|
+
* - `exit` cubic-bezier(0.3, 0, 0.3, 1) - soft at both ends; content leaving (pair with a faster duration).
|
|
15
|
+
* - `spring` cubic-bezier(0.3, 1.5, 0.5, 1) - overshoots then settles; pop-ins and confirmations.
|
|
16
|
+
* - `glide` cubic-bezier(0.22, 1, 0.36, 1) - fast out, soft landing; a persistent element moving to a
|
|
17
|
+
* new target, never enter/exit.
|
|
18
|
+
* - `move` cubic-bezier(0.55, 0, 0.15, 1) - gathers, then lands; travel across space: a fold, a FLIP,
|
|
19
|
+
* a flight. */
|
|
20
|
+
export type EaseToken = 'standard' | 'entrance' | 'exit' | 'spring' | 'glide' | 'move';
|
|
18
21
|
|
|
19
22
|
export type DistanceToken = 'sm' | 'md' | 'lg';
|
|
20
23
|
|
|
@@ -27,7 +27,7 @@ export type Bezier = [number, number, number, number];
|
|
|
27
27
|
export type { DistanceToken, DurationToken, EaseToken, ScaleToken } from './motion-scale';
|
|
28
28
|
|
|
29
29
|
export interface MotionTokens {
|
|
30
|
-
/** seconds - fast 0.14 - base 0.
|
|
30
|
+
/** seconds - fast 0.14 - base 0.24 - moderate 0.32 - slow 0.42 - slower 0.6 - slowest 0.8 */
|
|
31
31
|
dur: Record<DurationToken, number>;
|
|
32
32
|
ease: Record<EaseToken, Bezier>;
|
|
33
33
|
dist: Record<DistanceToken, number>;
|
|
@@ -45,8 +45,8 @@ export interface MotionTokens {
|
|
|
45
45
|
|
|
46
46
|
type MotionScales = Pick<MotionTokens, 'dur' | 'ease' | 'dist' | 'scale'>;
|
|
47
47
|
|
|
48
|
-
const DURATION_TOKENS: DurationToken[] = ['fast', 'base', 'slow', 'slower', 'slowest'];
|
|
49
|
-
const EASE_TOKENS: EaseToken[] = ['standard', 'entrance', 'exit', 'spring', 'glide'];
|
|
48
|
+
const DURATION_TOKENS: DurationToken[] = ['fast', 'base', 'moderate', 'slow', 'slower', 'slowest'];
|
|
49
|
+
const EASE_TOKENS: EaseToken[] = ['standard', 'entrance', 'exit', 'spring', 'glide', 'move'];
|
|
50
50
|
const DISTANCE_TOKENS: DistanceToken[] = ['sm', 'md', 'lg'];
|
|
51
51
|
const SCALE_TOKENS: ScaleToken[] = ['panel', 'floating', 'chip'];
|
|
52
52
|
|
|
@@ -69,7 +69,7 @@ function build(scales: MotionScales): MotionTokens {
|
|
|
69
69
|
t: {
|
|
70
70
|
enter: { duration: dur.base, ease: ease.entrance },
|
|
71
71
|
exit: { duration: dur.fast, ease: ease.exit },
|
|
72
|
-
layout: { duration: dur.
|
|
72
|
+
layout: { duration: dur.base, ease: ease.entrance },
|
|
73
73
|
settle: reduced ? { duration: 0 } : { type: 'spring', visualDuration: dur.fast, bounce: 0.25 },
|
|
74
74
|
glide: { duration: dur.base, ease: ease.glide },
|
|
75
75
|
},
|