@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,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
import { loop } from '../../../engine';
|
|
6
|
+
import { UIMotion } from '../../../tokens/motion-tokens';
|
|
7
|
+
import { bindInput } from './input';
|
|
8
|
+
import { advance, atRest, clamp, cloneInto, createOptics, measure, settle, type Parts } from './optics';
|
|
9
|
+
import { paint } from './paint';
|
|
10
|
+
|
|
11
|
+
const RADIUS_MIN = 60;
|
|
12
|
+
const RADIUS_MAX = 260;
|
|
13
|
+
const MAGNIFICATION_MIN = 1.2;
|
|
14
|
+
const MAGNIFICATION_MAX = 6;
|
|
15
|
+
const RECLONE_INTERVAL_MS = 90;
|
|
16
|
+
|
|
17
|
+
export function useLens(magnification: number, radius: number, chromatic: boolean) {
|
|
18
|
+
const stageRef = useRef<HTMLDivElement>(null);
|
|
19
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
20
|
+
const glassRef = useRef<HTMLDivElement>(null);
|
|
21
|
+
const coreRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
const rimRef = useRef<HTMLDivElement>(null);
|
|
23
|
+
const fringeRef = useRef<HTMLDivElement>(null);
|
|
24
|
+
const specularRef = useRef<HTMLDivElement>(null);
|
|
25
|
+
const ringRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const settings = useRef({ magnification, radius, chromatic });
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
settings.current = { magnification, radius, chromatic };
|
|
30
|
+
}, [magnification, radius, chromatic]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const parts: Parts | null =
|
|
34
|
+
stageRef.current &&
|
|
35
|
+
contentRef.current &&
|
|
36
|
+
glassRef.current &&
|
|
37
|
+
coreRef.current &&
|
|
38
|
+
rimRef.current &&
|
|
39
|
+
fringeRef.current &&
|
|
40
|
+
specularRef.current &&
|
|
41
|
+
ringRef.current
|
|
42
|
+
? {
|
|
43
|
+
stage: stageRef.current,
|
|
44
|
+
content: contentRef.current,
|
|
45
|
+
glass: glassRef.current,
|
|
46
|
+
core: coreRef.current,
|
|
47
|
+
rim: rimRef.current,
|
|
48
|
+
fringe: fringeRef.current,
|
|
49
|
+
specular: specularRef.current,
|
|
50
|
+
ring: ringRef.current,
|
|
51
|
+
}
|
|
52
|
+
: null;
|
|
53
|
+
if (!parts) return;
|
|
54
|
+
|
|
55
|
+
const optics = createOptics();
|
|
56
|
+
const reduced = UIMotion.reduced;
|
|
57
|
+
const currentRadius = () => clamp(settings.current.radius, RADIUS_MIN, RADIUS_MAX);
|
|
58
|
+
const currentMagnification = () => clamp(settings.current.magnification, MAGNIFICATION_MIN, MAGNIFICATION_MAX);
|
|
59
|
+
|
|
60
|
+
const rebuild = () => {
|
|
61
|
+
const box = parts.content.getBoundingClientRect();
|
|
62
|
+
cloneInto(parts.core, parts.content, box.width, box.height);
|
|
63
|
+
cloneInto(parts.rim, parts.content, box.width, box.height);
|
|
64
|
+
measure(parts, optics);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const render = () => paint(parts, optics, currentRadius(), settings.current.chromatic);
|
|
68
|
+
|
|
69
|
+
const settleNow = () => {
|
|
70
|
+
settle(optics, currentMagnification());
|
|
71
|
+
render();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const wake = () => (reduced ? settleNow() : playback.wake());
|
|
75
|
+
|
|
76
|
+
rebuild();
|
|
77
|
+
|
|
78
|
+
const mutations = new MutationObserver(() => {
|
|
79
|
+
optics.dirty = true;
|
|
80
|
+
if (reduced) rebuild();
|
|
81
|
+
wake();
|
|
82
|
+
});
|
|
83
|
+
mutations.observe(parts.content, { childList: true, subtree: true, characterData: true, attributes: true });
|
|
84
|
+
|
|
85
|
+
const resizes = new ResizeObserver(() => {
|
|
86
|
+
measure(parts, optics);
|
|
87
|
+
wake();
|
|
88
|
+
});
|
|
89
|
+
resizes.observe(parts.content);
|
|
90
|
+
|
|
91
|
+
const controller = new AbortController();
|
|
92
|
+
bindInput(parts, optics, wake, controller.signal);
|
|
93
|
+
|
|
94
|
+
const playback = loop(
|
|
95
|
+
(k, dt) => {
|
|
96
|
+
optics.sinceClone += dt;
|
|
97
|
+
if (optics.dirty && optics.sinceClone > RECLONE_INTERVAL_MS) {
|
|
98
|
+
optics.dirty = false;
|
|
99
|
+
optics.sinceClone = 0;
|
|
100
|
+
rebuild();
|
|
101
|
+
}
|
|
102
|
+
advance(optics, k, currentMagnification());
|
|
103
|
+
if (atRest(optics)) {
|
|
104
|
+
settleNow();
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
render();
|
|
108
|
+
},
|
|
109
|
+
{ el: parts.stage, snap: render },
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
playback.stop();
|
|
114
|
+
mutations.disconnect();
|
|
115
|
+
resizes.disconnect();
|
|
116
|
+
controller.abort();
|
|
117
|
+
};
|
|
118
|
+
}, []);
|
|
119
|
+
|
|
120
|
+
return { stageRef, contentRef, glassRef, coreRef, rimRef, fringeRef, specularRef, ringRef };
|
|
121
|
+
}
|
|
@@ -5,11 +5,24 @@ import './odometer.css';
|
|
|
5
5
|
import { useEffect, useMemo, useRef, useState, type HTMLAttributes } from 'react';
|
|
6
6
|
|
|
7
7
|
import type { DataAttributes } from '../../../dom-props';
|
|
8
|
-
import {
|
|
8
|
+
import { clock } from '../../../engine';
|
|
9
9
|
import type { OdometerStyle } from '../../../tokens/component-styles.generated';
|
|
10
10
|
import { motionFor } from '../../../tokens/motion-tokens';
|
|
11
11
|
import { cx } from '../../internal/utils/cx';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
aim,
|
|
14
|
+
charAt,
|
|
15
|
+
DIGIT,
|
|
16
|
+
hold,
|
|
17
|
+
launch,
|
|
18
|
+
MIN_ROLL,
|
|
19
|
+
motions,
|
|
20
|
+
parts,
|
|
21
|
+
RUN_TEXT,
|
|
22
|
+
snap,
|
|
23
|
+
type Place,
|
|
24
|
+
type Slot,
|
|
25
|
+
} from './roll';
|
|
13
26
|
|
|
14
27
|
const affix = (chars: string) =>
|
|
15
28
|
chars && (
|
|
@@ -49,6 +62,7 @@ export function Odometer({ value, format, speed = 1, className = '', style, html
|
|
|
49
62
|
const strips = useRef<Slot>([]);
|
|
50
63
|
const sim = useRef<Place[]>([]);
|
|
51
64
|
const shown = useRef(0);
|
|
65
|
+
const visible = useRef(true);
|
|
52
66
|
const rate = useRef(speed);
|
|
53
67
|
rate.current = speed;
|
|
54
68
|
|
|
@@ -58,17 +72,33 @@ export function Odometer({ value, format, speed = 1, className = '', style, html
|
|
|
58
72
|
shown.current = value;
|
|
59
73
|
aim(sim.current, grid, core, zero, Math.max(motion.dur.slower, MIN_ROLL), dir);
|
|
60
74
|
if (motion.reduced) snap(sim.current, cols.current, strips.current);
|
|
75
|
+
else launch(sim.current, strips.current, cols.current, rate.current / clock.scale, !visible.current);
|
|
61
76
|
}, [value, core, grid, zero]);
|
|
62
77
|
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
for (const motion of motions(sim.current))
|
|
80
|
+
if (motion.playState !== 'finished') motion.updatePlaybackRate(speed / clock.scale);
|
|
81
|
+
}, [speed]);
|
|
82
|
+
|
|
63
83
|
useEffect(() => {
|
|
64
84
|
const el = rootRef.current;
|
|
65
85
|
if (!el) return;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
let inView = true;
|
|
87
|
+
const sync = () => {
|
|
88
|
+
visible.current = inView && document.visibilityState !== 'hidden';
|
|
89
|
+
hold(sim.current, !visible.current);
|
|
90
|
+
};
|
|
91
|
+
const observer = new IntersectionObserver((entries) => {
|
|
92
|
+
inView = entries[entries.length - 1].isIntersecting;
|
|
93
|
+
sync();
|
|
70
94
|
});
|
|
71
|
-
|
|
95
|
+
observer.observe(el);
|
|
96
|
+
document.addEventListener('visibilitychange', sync);
|
|
97
|
+
return () => {
|
|
98
|
+
observer.disconnect();
|
|
99
|
+
document.removeEventListener('visibilitychange', sync);
|
|
100
|
+
for (const motion of motions(sim.current)) motion.cancel();
|
|
101
|
+
};
|
|
72
102
|
}, []);
|
|
73
103
|
|
|
74
104
|
return (
|
|
@@ -96,11 +126,7 @@ export function Odometer({ value, format, speed = 1, className = '', style, html
|
|
|
96
126
|
strips.current[i] = el;
|
|
97
127
|
}}
|
|
98
128
|
>
|
|
99
|
-
{
|
|
100
|
-
<span key={c} className="zc-odometer__cell">
|
|
101
|
-
{cell}
|
|
102
|
-
</span>
|
|
103
|
-
))}
|
|
129
|
+
{RUN_TEXT}
|
|
104
130
|
</span>
|
|
105
131
|
</span>
|
|
106
132
|
);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
@layer zyncat.reset, zyncat.tokens, zyncat.base, zyncat.components;
|
|
2
2
|
|
|
3
|
+
@property --_odometer-reveal {
|
|
4
|
+
syntax: '<number>';
|
|
5
|
+
inherits: false;
|
|
6
|
+
initial-value: 1;
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
@layer zyncat.components {
|
|
4
10
|
.zc-odometer {
|
|
5
11
|
--_odometer-cell: 1em;
|
|
@@ -47,14 +53,12 @@
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
.zc-odometer__strip {
|
|
50
|
-
display: block;
|
|
51
|
-
will-change: translate;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.zc-odometer__cell {
|
|
55
56
|
display: grid;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
justify-items: center;
|
|
58
|
+
white-space: pre;
|
|
59
|
+
text-align: center;
|
|
60
|
+
line-height: var(--_odometer-cell);
|
|
61
|
+
will-change: translate;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
.zc-odometer__separator {
|
|
@@ -62,6 +66,7 @@
|
|
|
62
66
|
|
|
63
67
|
display: block;
|
|
64
68
|
font-size: calc(1em * var(--_odometer-reveal));
|
|
69
|
+
white-space: pre;
|
|
65
70
|
opacity: var(--_odometer-reveal);
|
|
66
71
|
color: var(--odometer-separator-ink);
|
|
67
72
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { clampedCurve, sample, settleSeconds, wrappedCurve, type Spring } from './spring';
|
|
2
|
+
|
|
1
3
|
const RUN = 10;
|
|
2
4
|
const BOUNCE = 0.28;
|
|
3
5
|
const SETTLE_DECAYS = 4;
|
|
@@ -5,24 +7,20 @@ const CARRY_SOFTENING = 0.88;
|
|
|
5
7
|
const CARRY_FLOOR = 0.55;
|
|
6
8
|
const OPEN_RATE = 1.25;
|
|
7
9
|
const REST_CELL = 0.004;
|
|
8
|
-
const
|
|
10
|
+
const LAP: Keyframe[] = [{ translate: '0 0%' }, { translate: '0 -50%' }];
|
|
11
|
+
const GATE: Keyframe[] = [{ '--_odometer-reveal': 0 }, { '--_odometer-reveal': 1 }];
|
|
9
12
|
|
|
10
13
|
export const MIN_ROLL = 0.08;
|
|
11
14
|
export const DIGIT = /\d/;
|
|
12
|
-
export const
|
|
15
|
+
export const RUN_TEXT = Array.from({ length: RUN * 2 }, (_, i) => i % RUN).join('\n');
|
|
13
16
|
|
|
14
17
|
export type Slot = (HTMLElement | null)[];
|
|
15
18
|
|
|
16
|
-
export interface Place {
|
|
17
|
-
at: number;
|
|
18
|
-
rate: number;
|
|
19
|
-
to: number;
|
|
19
|
+
export interface Place extends Spring {
|
|
20
20
|
digit: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
omega: number;
|
|
25
|
-
settled: boolean;
|
|
21
|
+
roll: Animation | null;
|
|
22
|
+
gate: Spring;
|
|
23
|
+
reveal: Animation | null;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
export const charAt = (core: string, i: number) => (i < core.length ? core[core.length - 1 - i] : '');
|
|
@@ -34,29 +32,62 @@ export function parts(text: string): [string, string, string] {
|
|
|
34
32
|
return [text.slice(0, first), text.slice(first, last + 1), text.slice(last + 1)];
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
export const motions = (places: Place[]) => places.flatMap((p) => [p.roll, p.reveal]).filter((m) => m !== null);
|
|
36
|
+
|
|
37
|
+
function settle(s: Spring): void {
|
|
38
|
+
s.at = s.to;
|
|
39
|
+
s.rate = 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function rebase(p: Place): void {
|
|
43
|
+
const shift = Math.floor(p.at / RUN) * RUN;
|
|
44
|
+
p.at -= shift;
|
|
45
|
+
p.to -= shift;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
+
function land(strip: HTMLElement | null, p: Place): void {
|
|
49
|
+
settle(p);
|
|
50
|
+
rebase(p);
|
|
51
|
+
p.roll?.cancel();
|
|
52
|
+
p.roll = null;
|
|
48
53
|
if (strip) strip.style.translate = `0 calc(var(--_odometer-cell) * ${(-p.at).toFixed(4)})`;
|
|
49
54
|
}
|
|
50
55
|
|
|
56
|
+
function shut(col: HTMLElement | null, p: Place): void {
|
|
57
|
+
settle(p.gate);
|
|
58
|
+
p.reveal?.cancel();
|
|
59
|
+
p.reveal = null;
|
|
60
|
+
col?.style.setProperty('--_odometer-reveal', String(p.gate.to));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function follow(s: Spring, motion: Animation | null): void {
|
|
64
|
+
if (!motion) return;
|
|
65
|
+
if (motion.playState === 'finished') settle(s);
|
|
66
|
+
else [s.at, s.rate] = sample(s, Number(motion.currentTime ?? 0) / 1000);
|
|
67
|
+
}
|
|
68
|
+
|
|
51
69
|
export function aim(places: Place[], grid: string, core: string, zero: number, seconds: number, dir: number): void {
|
|
52
70
|
const zeta = 1 - BOUNCE;
|
|
53
71
|
for (let i = 0, ordinal = 0; i < grid.length; i++) {
|
|
54
72
|
const omega = (SETTLE_DECAYS / (zeta * seconds)) * Math.max(CARRY_FLOOR, CARRY_SOFTENING ** ordinal);
|
|
55
73
|
const open = i < zero ? 1 : 0;
|
|
56
|
-
const p = (places[i] ??= {
|
|
74
|
+
const p = (places[i] ??= {
|
|
75
|
+
at: 0,
|
|
76
|
+
rate: 0,
|
|
77
|
+
to: 0,
|
|
78
|
+
zeta,
|
|
79
|
+
omega,
|
|
80
|
+
digit: 0,
|
|
81
|
+
roll: null,
|
|
82
|
+
gate: { at: open, rate: 0, to: open, omega, zeta: 1 },
|
|
83
|
+
reveal: null,
|
|
84
|
+
});
|
|
85
|
+
follow(p, p.roll);
|
|
86
|
+
rebase(p);
|
|
87
|
+
follow(p.gate, p.reveal);
|
|
57
88
|
p.omega = omega;
|
|
58
|
-
p.
|
|
59
|
-
p.
|
|
89
|
+
p.gate.omega = omega * OPEN_RATE;
|
|
90
|
+
p.gate.to = i < core.length ? 1 : 0;
|
|
60
91
|
const char = charAt(core, i) || charAt(grid, i);
|
|
61
92
|
if (!DIGIT.test(char)) continue;
|
|
62
93
|
const digit = i < core.length ? Number(char) : 0;
|
|
@@ -66,29 +97,43 @@ export function aim(places: Place[], grid: string, core: string, zero: number, s
|
|
|
66
97
|
}
|
|
67
98
|
}
|
|
68
99
|
|
|
69
|
-
export function
|
|
70
|
-
const
|
|
100
|
+
export function launch(places: Place[], strips: Slot, cols: Slot, rate: number, paused: boolean): void {
|
|
101
|
+
const now = document.timeline.currentTime;
|
|
102
|
+
const start = (el: HTMLElement, frames: Keyframe[], seconds: number, easing: string) => {
|
|
103
|
+
const motion = el.animate(frames, { duration: seconds * 1000, easing, fill: 'forwards' });
|
|
104
|
+
motion.playbackRate = rate;
|
|
105
|
+
motion.startTime = now;
|
|
106
|
+
if (paused) motion.pause();
|
|
107
|
+
return motion;
|
|
108
|
+
};
|
|
71
109
|
for (let i = 0; i < places.length; i++) {
|
|
72
110
|
const p = places[i];
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
111
|
+
const [strip, col] = [strips[i], cols[i]];
|
|
112
|
+
const rolling = settleSeconds(p, REST_CELL);
|
|
113
|
+
const opening = settleSeconds(p.gate, REST_CELL);
|
|
114
|
+
if (!rolling) land(strip, p);
|
|
115
|
+
else if (strip) {
|
|
116
|
+
p.roll?.cancel();
|
|
117
|
+
p.roll = start(strip, LAP, rolling, wrappedCurve(p, rolling, RUN));
|
|
118
|
+
}
|
|
119
|
+
if (!opening) shut(col, p);
|
|
120
|
+
else if (col) {
|
|
121
|
+
p.reveal?.cancel();
|
|
122
|
+
p.reveal = start(col, GATE, opening, clampedCurve(p.gate, opening));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function hold(places: Place[], paused: boolean): void {
|
|
128
|
+
for (const motion of motions(places)) {
|
|
129
|
+
if (paused && motion.playState === 'running') motion.pause();
|
|
130
|
+
if (!paused && motion.playState === 'paused') motion.play();
|
|
85
131
|
}
|
|
86
132
|
}
|
|
87
133
|
|
|
88
134
|
export function snap(places: Place[], cols: Slot, strips: Slot): void {
|
|
89
135
|
for (let i = 0; i < places.length; i++) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
write(cols[i], strips[i], places[i]);
|
|
136
|
+
shut(cols[i], places[i]);
|
|
137
|
+
land(strips[i], places[i]);
|
|
93
138
|
}
|
|
94
139
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const TUNED_AT_HZ = 144;
|
|
2
|
+
const DT = 1 / TUNED_AT_HZ;
|
|
3
|
+
const SAMPLE_SECONDS = 1 / 120;
|
|
4
|
+
const CIRCULAR = [Math.cos, Math.sin, Math.acos] as const;
|
|
5
|
+
const HYPERBOLIC = [Math.cosh, Math.sinh, Math.acosh] as const;
|
|
6
|
+
|
|
7
|
+
export interface Spring {
|
|
8
|
+
at: number;
|
|
9
|
+
rate: number;
|
|
10
|
+
to: number;
|
|
11
|
+
omega: number;
|
|
12
|
+
zeta: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Shape {
|
|
16
|
+
a: number;
|
|
17
|
+
b: number;
|
|
18
|
+
decay: number;
|
|
19
|
+
freq: number;
|
|
20
|
+
fade: number;
|
|
21
|
+
cos: (x: number) => number;
|
|
22
|
+
sin: (x: number) => number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const trim = (n: number) => Math.round(n * 1e4) / 1e4;
|
|
26
|
+
const stop = (value: number, progress: number) => `${trim(value)} ${trim(progress * 100)}%`;
|
|
27
|
+
|
|
28
|
+
function shape(s: Spring): Shape {
|
|
29
|
+
const shrink = 1 - 2 * s.zeta * s.omega * DT;
|
|
30
|
+
const radius = Math.sqrt(shrink);
|
|
31
|
+
const ratio = (1 + shrink - s.omega * s.omega * DT * DT) / (2 * radius);
|
|
32
|
+
const realRoots = ratio > 1;
|
|
33
|
+
const [cos, sin, arc] = realRoots ? HYPERBOLIC : CIRCULAR;
|
|
34
|
+
const turn = arc(ratio);
|
|
35
|
+
const a = s.at - s.to;
|
|
36
|
+
const next = a + (s.rate - (s.omega * s.omega * a + 2 * s.zeta * s.omega * s.rate) * DT) * DT;
|
|
37
|
+
const b = (next / radius - a * cos(turn)) / sin(turn);
|
|
38
|
+
const decay = -Math.log(radius) / DT;
|
|
39
|
+
const freq = turn / DT;
|
|
40
|
+
return { a, b, cos, sin, decay, freq, fade: realRoots ? decay - freq : decay };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const offset = (k: Shape, t: number) => Math.exp(-k.decay * t) * (k.a * k.cos(k.freq * t) + k.b * k.sin(k.freq * t));
|
|
44
|
+
|
|
45
|
+
export function sample(s: Spring, t: number): [at: number, rate: number] {
|
|
46
|
+
const k = shape(s);
|
|
47
|
+
const now = offset(k, t);
|
|
48
|
+
return [s.to + now, (now - offset(k, t - DT)) / DT];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function settleSeconds(s: Spring, rest: number): number {
|
|
52
|
+
const k = shape(s);
|
|
53
|
+
const amplitude = Math.hypot(k.a, k.b);
|
|
54
|
+
return amplitude > rest ? Math.log(amplitude / rest) / k.fade : 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function track(s: Spring, seconds: number): [x: number, progress: number][] {
|
|
58
|
+
const k = shape(s);
|
|
59
|
+
const steps = Math.max(1, Math.ceil(seconds / SAMPLE_SECONDS));
|
|
60
|
+
const at = (i: number) => (i === 0 ? s.at : i === steps ? s.to : s.to + offset(k, (i / steps) * seconds));
|
|
61
|
+
return Array.from({ length: steps + 1 }, (_, i) => [at(i), i / steps]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function clampedCurve(s: Spring, seconds: number): string {
|
|
65
|
+
return `linear(${track(s, seconds)
|
|
66
|
+
.map(([x, t]) => stop(Math.min(1, Math.max(0, x)), t))
|
|
67
|
+
.join(', ')})`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function wrappedCurve(s: Spring, seconds: number, run: number): string {
|
|
71
|
+
const wrap = (x: number) => (((x % run) + run) % run) / run;
|
|
72
|
+
const points: string[] = [];
|
|
73
|
+
let [last, then] = [s.at, 0];
|
|
74
|
+
for (const [x, t] of track(s, seconds)) {
|
|
75
|
+
const lap = Math.floor(last / run);
|
|
76
|
+
const next = Math.floor(x / run);
|
|
77
|
+
if (lap !== next) {
|
|
78
|
+
const edge = Math.max(lap, next) * run;
|
|
79
|
+
const progress = then + ((edge - last) / (x - last)) * (t - then);
|
|
80
|
+
points.push(stop(next > lap ? 1 : 0, progress), stop(next > lap ? 0 : 1, progress));
|
|
81
|
+
}
|
|
82
|
+
points.push(stop(wrap(x), t));
|
|
83
|
+
[last, then] = [x, t];
|
|
84
|
+
}
|
|
85
|
+
return `linear(${points.join(', ')})`;
|
|
86
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import type { PointerEvent } from 'react';
|
|
5
|
+
|
|
6
|
+
const FIRST_REPEAT_MS = 400;
|
|
7
|
+
const FASTEST_REPEAT_MS = 40;
|
|
8
|
+
const ACCELERATION = 0.8;
|
|
9
|
+
|
|
10
|
+
export function useHoldRepeat(onStep: (direction: 1 | -1) => boolean) {
|
|
11
|
+
const stepRef = useRef(onStep);
|
|
12
|
+
const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
13
|
+
const repeatedRef = useRef(false);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
stepRef.current = onStep;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const stop = () => clearTimeout(timerRef.current);
|
|
20
|
+
useEffect(() => stop, []);
|
|
21
|
+
|
|
22
|
+
return (direction: 1 | -1) => ({
|
|
23
|
+
onPointerDown: (e: PointerEvent) => {
|
|
24
|
+
if (e.button !== 0 || e.currentTarget.matches(':disabled')) return;
|
|
25
|
+
repeatedRef.current = false;
|
|
26
|
+
let delay = FIRST_REPEAT_MS;
|
|
27
|
+
const tick = () => {
|
|
28
|
+
repeatedRef.current = true;
|
|
29
|
+
if (!stepRef.current(direction)) return;
|
|
30
|
+
delay = Math.max(FASTEST_REPEAT_MS, delay * ACCELERATION);
|
|
31
|
+
timerRef.current = setTimeout(tick, delay);
|
|
32
|
+
};
|
|
33
|
+
timerRef.current = setTimeout(tick, delay);
|
|
34
|
+
},
|
|
35
|
+
onPointerUp: stop,
|
|
36
|
+
onPointerLeave: stop,
|
|
37
|
+
onPointerCancel: stop,
|
|
38
|
+
onClick: () => {
|
|
39
|
+
if (!repeatedRef.current) stepRef.current(direction);
|
|
40
|
+
repeatedRef.current = false;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -35,11 +35,16 @@ export function useScrollEdges(
|
|
|
35
35
|
sync();
|
|
36
36
|
el.addEventListener('scroll', sync, { passive: true });
|
|
37
37
|
const ro = new ResizeObserver(sync);
|
|
38
|
+
const mo = new MutationObserver(sync);
|
|
38
39
|
ro.observe(el);
|
|
39
|
-
if (content && el.firstElementChild)
|
|
40
|
+
if (content && el.firstElementChild) {
|
|
41
|
+
ro.observe(el.firstElementChild);
|
|
42
|
+
mo.observe(el.firstElementChild, { childList: true, subtree: true });
|
|
43
|
+
}
|
|
40
44
|
return () => {
|
|
41
45
|
el.removeEventListener('scroll', sync);
|
|
42
46
|
ro.disconnect();
|
|
47
|
+
mo.disconnect();
|
|
43
48
|
};
|
|
44
49
|
}, [sync, content]);
|
|
45
50
|
return sync;
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
Clock,
|
|
17
17
|
Info,
|
|
18
18
|
MagnifyingGlass,
|
|
19
|
+
Minus,
|
|
20
|
+
Plus,
|
|
19
21
|
Warning,
|
|
20
22
|
WarningCircle,
|
|
21
23
|
X,
|
|
@@ -37,6 +39,8 @@ const REGISTRY = {
|
|
|
37
39
|
'caret-left': CaretLeft,
|
|
38
40
|
'caret-right': CaretRight,
|
|
39
41
|
'magnifying-glass': MagnifyingGlass,
|
|
42
|
+
minus: Minus,
|
|
43
|
+
plus: Plus,
|
|
40
44
|
calendar: Calendar,
|
|
41
45
|
'calendar-dot': CalendarDot,
|
|
42
46
|
clock: Clock,
|
|
@@ -42,7 +42,7 @@ export function trackAnchorMove(el: Element, onMove: () => void): AnchorMoveTrac
|
|
|
42
42
|
(entries) => {
|
|
43
43
|
const ratio = entries[entries.length - 1].intersectionRatio;
|
|
44
44
|
if (ratio !== threshold) {
|
|
45
|
-
if (!settling) arm(false, 1);
|
|
45
|
+
if (!settling || !sameRect(rect, el.getBoundingClientRect())) arm(false, 1);
|
|
46
46
|
else if (ratio > 0) arm(false, ratio);
|
|
47
47
|
else release();
|
|
48
48
|
return;
|
|
@@ -7,7 +7,7 @@ export interface SupportAction {
|
|
|
7
7
|
label: string;
|
|
8
8
|
/** Leading glyph. Any node; the widget sizes the box it sits in. */
|
|
9
9
|
icon?: ReactNode;
|
|
10
|
-
/** Trailing metadata - a wait time, a slot, a ticket number. Set in
|
|
10
|
+
/** Trailing metadata - a wait time, a slot, a ticket number. Set in tabular figures. */
|
|
11
11
|
meta?: string;
|
|
12
12
|
/** Second line under the label. The rail shows it; the fan puts it in the caption. */
|
|
13
13
|
description?: string;
|
|
@@ -13,8 +13,8 @@ const drivesActivation = (pointerType: string | undefined) => pointerType === 'm
|
|
|
13
13
|
let activatedOnPointerDown = false;
|
|
14
14
|
|
|
15
15
|
function isInert(target: EventTarget | null) {
|
|
16
|
-
const el = target as
|
|
17
|
-
return Boolean(el?.disabled) || el?.getAttribute?.('aria-disabled') === 'true';
|
|
16
|
+
const el = target as Element | null;
|
|
17
|
+
return Boolean(el?.matches?.(':disabled')) || el?.getAttribute?.('aria-disabled') === 'true';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function takeFocus(target: EventTarget | null) {
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
.zc-avatar--overflow .zc-avatar__initials {
|
|
189
|
-
font-family: var(--font-
|
|
189
|
+
font-family: var(--font-body);
|
|
190
190
|
font-variant-numeric: tabular-nums;
|
|
191
191
|
font-size: calc(var(--avatar-size) * 0.36);
|
|
192
192
|
letter-spacing: var(--tracking-normal);
|