@zyncat/ui 0.13.0 → 0.15.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/README.md +72 -13
- package/dist/alert.css +26 -33
- package/dist/alert.js +18 -17
- package/dist/alert.js.map +1 -1
- package/dist/avatar-group.js +2 -2
- package/dist/avatar-group.js.map +1 -1
- package/dist/avatar.css +51 -50
- package/dist/avatar.js +29 -7
- package/dist/avatar.js.map +1 -1
- package/dist/badge.css +30 -36
- package/dist/badge.js +1 -1
- package/dist/button.css +80 -96
- package/dist/button.js +1 -1
- package/dist/checkbox.css +27 -32
- package/dist/checkbox.js +2 -2
- package/dist/{chunk-RJFGWJ4W.js → chunk-3XRVPCIM.js} +6 -6
- package/dist/chunk-3XRVPCIM.js.map +1 -0
- package/dist/{chunk-M43IOM5C.js → chunk-5GBV45YD.js} +3 -3
- package/dist/{chunk-M43IOM5C.js.map → chunk-5GBV45YD.js.map} +1 -1
- package/dist/{chunk-45R4Z5XN.js → chunk-5VC3TUZ2.js} +4 -4
- package/dist/{chunk-45R4Z5XN.js.map → chunk-5VC3TUZ2.js.map} +1 -1
- package/dist/{chunk-A5WTZACK.js → chunk-5W5TKANX.js} +3 -3
- package/dist/{chunk-A5WTZACK.js.map → chunk-5W5TKANX.js.map} +1 -1
- package/dist/{chunk-AADAJL7D.js → chunk-5X3MJRIM.js} +8 -9
- package/dist/chunk-5X3MJRIM.js.map +1 -0
- package/dist/{chunk-TCUCYFT7.js → chunk-6SUHSSOK.js} +3 -3
- package/dist/{chunk-TCUCYFT7.js.map → chunk-6SUHSSOK.js.map} +1 -1
- package/dist/{chunk-DDRSMHN4.js → chunk-6X3G4GIM.js} +3 -3
- package/dist/{chunk-DDRSMHN4.js.map → chunk-6X3G4GIM.js.map} +1 -1
- package/dist/{chunk-TYHR4VNM.js → chunk-AREEMG47.js} +10 -8
- package/dist/chunk-AREEMG47.js.map +1 -0
- package/dist/{chunk-EF6RPXU7.js → chunk-BH4JFWXQ.js} +36 -31
- package/dist/chunk-BH4JFWXQ.js.map +1 -0
- package/dist/{chunk-TVYH4AN7.js → chunk-BTF6DAE3.js} +13 -13
- package/dist/chunk-BTF6DAE3.js.map +1 -0
- package/dist/{chunk-CF4QHO4N.js → chunk-CAXQJSIE.js} +10 -10
- package/dist/{chunk-CF4QHO4N.js.map → chunk-CAXQJSIE.js.map} +1 -1
- package/dist/{chunk-4C5RZXBT.js → chunk-CFRGQJ23.js} +8 -8
- package/dist/chunk-CFRGQJ23.js.map +1 -0
- package/dist/{chunk-IJS7TPGV.js → chunk-FEXUS4SV.js} +6 -5
- package/dist/chunk-FEXUS4SV.js.map +1 -0
- package/dist/{chunk-227ZW4V7.js → chunk-FLQVOSFC.js} +11 -11
- package/dist/chunk-FLQVOSFC.js.map +1 -0
- package/dist/{chunk-FONOS5RN.js → chunk-FVPNICF4.js} +11 -10
- package/dist/chunk-FVPNICF4.js.map +1 -0
- package/dist/{chunk-I45AU6KH.js → chunk-GGDAMIBH.js} +13 -7
- package/dist/chunk-GGDAMIBH.js.map +1 -0
- package/dist/{chunk-4BSHB7R3.js → chunk-GJTHWB6O.js} +9 -9
- package/dist/chunk-GJTHWB6O.js.map +1 -0
- package/dist/{chunk-EAI4POPB.js → chunk-GOLSYGRA.js} +45 -75
- package/dist/chunk-GOLSYGRA.js.map +1 -0
- package/dist/chunk-H3X2263Y.js +17 -0
- package/dist/chunk-H3X2263Y.js.map +1 -0
- package/dist/chunk-K45CWVHS.js +53 -0
- package/dist/chunk-K45CWVHS.js.map +1 -0
- package/dist/{chunk-JY6A2ZJZ.js → chunk-LNAV5E7S.js} +2 -2
- package/dist/{chunk-JY6A2ZJZ.js.map → chunk-LNAV5E7S.js.map} +1 -1
- package/dist/{chunk-TUTXXC3W.js → chunk-MDSRZ4QR.js} +3 -3
- package/dist/{chunk-TUTXXC3W.js.map → chunk-MDSRZ4QR.js.map} +1 -1
- package/dist/chunk-N2GJEO5Z.js +101 -0
- package/dist/chunk-N2GJEO5Z.js.map +1 -0
- package/dist/chunk-PU3QWBEL.js +39 -0
- package/dist/chunk-PU3QWBEL.js.map +1 -0
- package/dist/{chunk-43M6GQ4Q.js → chunk-PWQVSVXR.js} +51 -32
- package/dist/chunk-PWQVSVXR.js.map +1 -0
- package/dist/chunk-QGVFFT2B.js +14 -0
- package/dist/chunk-QGVFFT2B.js.map +1 -0
- package/dist/{chunk-5PZ43DCG.js → chunk-RBSHRRNO.js} +12 -13
- package/dist/chunk-RBSHRRNO.js.map +1 -0
- package/dist/{chunk-XNIYSAMJ.js → chunk-RW2A4M2Q.js} +14 -9
- package/dist/chunk-RW2A4M2Q.js.map +1 -0
- package/dist/{chunk-HY5MPISE.js → chunk-UYSXJ7MH.js} +9 -9
- package/dist/chunk-UYSXJ7MH.js.map +1 -0
- package/dist/chunk-VDOBLABP.js +38 -0
- package/dist/chunk-VDOBLABP.js.map +1 -0
- package/dist/chunk-VNVVG47J.js +12 -0
- package/dist/chunk-VNVVG47J.js.map +1 -0
- package/dist/{chunk-3MPF7FZV.js → chunk-WCWV5IX6.js} +3 -3
- package/dist/{chunk-3MPF7FZV.js.map → chunk-WCWV5IX6.js.map} +1 -1
- package/dist/{chunk-VAXCXZ53.js → chunk-WZUTBJC4.js} +5 -4
- package/dist/chunk-WZUTBJC4.js.map +1 -0
- package/dist/cli.js +137 -25
- package/dist/collapse.css +15 -30
- package/dist/collapse.js +1 -1
- package/dist/confetti.css +19 -12
- package/dist/confetti.js +7 -6
- package/dist/confetti.js.map +1 -1
- package/dist/count-badge.js +2 -2
- package/dist/date-field.js +20 -19
- package/dist/date-field.js.map +1 -1
- package/dist/date-picker.css +131 -154
- package/dist/date-range-field.js +55 -54
- package/dist/date-range-field.js.map +1 -1
- package/dist/datetime-field.js +24 -23
- package/dist/datetime-field.js.map +1 -1
- package/dist/dialog.css +31 -41
- package/dist/dialog.js +23 -22
- package/dist/dialog.js.map +1 -1
- package/dist/digit-strip.css +16 -16
- package/dist/dropdown.css +36 -27
- package/dist/dropdown.js +77 -40
- package/dist/dropdown.js.map +1 -1
- package/dist/emoji-picker.js +44 -45
- package/dist/emoji-picker.js.map +1 -1
- package/dist/facebook-feed.css +145 -148
- package/dist/facebook-feed.js +106 -102
- package/dist/facebook-feed.js.map +1 -1
- package/dist/flow-field.css +8 -4
- package/dist/flow-field.js +7 -6
- package/dist/flow-field.js.map +1 -1
- package/dist/glide.js +4 -3
- package/dist/icon.css +7 -10
- package/dist/input.css +76 -84
- package/dist/instagram-feed.css +65 -66
- package/dist/instagram-feed.js +61 -44
- package/dist/instagram-feed.js.map +1 -1
- package/dist/lens.css +42 -38
- package/dist/lens.js +17 -16
- package/dist/lens.js.map +1 -1
- package/dist/mcp.js +3 -2
- package/dist/menu-surface.css +54 -34
- package/dist/modal.css +2 -4
- package/dist/modal.js +12 -11
- package/dist/modal.js.map +1 -1
- package/dist/morphing-text.css +26 -16
- package/dist/morphing-text.js +14 -13
- package/dist/morphing-text.js.map +1 -1
- package/dist/motion-devtools.css +42 -68
- package/dist/motion-devtools.js +47 -39
- package/dist/motion-devtools.js.map +1 -1
- package/dist/motion-tokens.js +1 -1
- package/dist/multi-select.js +21 -16
- package/dist/multi-select.js.map +1 -1
- package/dist/number-field.js +14 -14
- package/dist/number-field.js.map +1 -1
- package/dist/odometer.css +22 -16
- package/dist/odometer.js +12 -11
- package/dist/odometer.js.map +1 -1
- package/dist/otp-field.js +3 -3
- package/dist/otp-field.js.map +1 -1
- package/dist/overlay.css +4 -9
- package/dist/pagination.css +10 -15
- package/dist/pagination.js +11 -10
- package/dist/pagination.js.map +1 -1
- package/dist/popover.css +13 -15
- package/dist/popover.js +10 -9
- package/dist/radio-group.css +60 -73
- package/dist/radio-group.js +30 -29
- package/dist/radio-group.js.map +1 -1
- package/dist/select.css +66 -75
- package/dist/select.js +19 -14
- package/dist/select.js.map +1 -1
- package/dist/sheet.css +12 -14
- package/dist/sheet.js +11 -10
- package/dist/status-badge.js +9 -9
- package/dist/status-badge.js.map +1 -1
- package/dist/styles.css +34 -34
- package/dist/support-rail.css +116 -100
- package/dist/support-rail.js +41 -40
- package/dist/support-rail.js.map +1 -1
- package/dist/table.css +76 -84
- package/dist/table.js +42 -41
- package/dist/table.js.map +1 -1
- package/dist/tabs.css +82 -90
- package/dist/tabs.js +23 -20
- package/dist/tabs.js.map +1 -1
- package/dist/tag.css +48 -53
- package/dist/tag.js +13 -12
- package/dist/tag.js.map +1 -1
- package/dist/text-field.js +5 -5
- package/dist/textarea.css +46 -49
- package/dist/textarea.js +16 -16
- package/dist/textarea.js.map +1 -1
- package/dist/theme.js +31 -15
- package/dist/theme.js.map +1 -1
- package/dist/tiktok.css +113 -117
- package/dist/tiktok.js +53 -52
- package/dist/tiktok.js.map +1 -1
- package/dist/time-field.js +26 -20
- package/dist/time-field.js.map +1 -1
- package/dist/toast-store.js +2 -1
- package/dist/toast.css +49 -65
- package/dist/toast.js +32 -26
- package/dist/toast.js.map +1 -1
- package/dist/toggle-tag.js +22 -13
- package/dist/toggle-tag.js.map +1 -1
- package/dist/toggle.css +26 -31
- package/dist/toggle.js +7 -7
- package/dist/toggle.js.map +1 -1
- package/dist/tooltip.css +16 -23
- package/dist/tooltip.js +117 -95
- package/dist/tooltip.js.map +1 -1
- package/dist/trigger.css +3 -3
- package/dist/types/components/composites/alert/Alert.d.ts +1 -2
- package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -2
- package/dist/types/components/composites/date-picker/field-shell.d.ts +1 -1
- package/dist/types/components/composites/date-picker/time-core.d.ts +1 -2
- package/dist/types/components/composites/dropdown/Dropdown.d.ts +9 -1
- package/dist/types/components/composites/dropdown/types.d.ts +14 -0
- package/dist/types/components/composites/emoji-picker/EmojiPickerPanel.d.ts +1 -1
- package/dist/types/components/composites/emoji-picker/data.d.ts +2 -5
- package/dist/types/components/composites/emoji-picker/react/useEmojiPicker.d.ts +0 -11
- package/dist/types/components/composites/emoji-picker/types.d.ts +3 -8
- package/dist/types/components/composites/select/MultiSelect.d.ts +6 -1
- package/dist/types/components/composites/select/Select.d.ts +6 -1
- package/dist/types/components/composites/select/core/index.d.ts +1 -1
- package/dist/types/components/composites/select/core/menu.d.ts +3 -3
- package/dist/types/components/composites/select/core/panel.d.ts +3 -3
- package/dist/types/components/composites/tabs/Tabs.d.ts +7 -10
- package/dist/types/components/composites/toast/Toast.d.ts +1 -1
- package/dist/types/components/composites/tooltip/Tooltip.d.ts +9 -1
- package/dist/types/components/composites/tooltip/tooltip-store.d.ts +5 -6
- package/dist/types/components/dev/MotionDevtools.d.ts +3 -1
- package/dist/types/components/internal/hooks/use-host-election.d.ts +8 -0
- package/dist/types/components/internal/icon/Icon.d.ts +1 -3
- package/dist/types/components/internal/menu/highlight.d.ts +7 -0
- package/dist/types/components/internal/utils/activation.d.ts +0 -4
- package/dist/types/components/primitives/avatar/Avatar.d.ts +1 -1
- package/dist/types/components/primitives/button/Button.d.ts +1 -1
- package/dist/types/components/primitives/input/TextField.d.ts +1 -2
- package/dist/types/components/primitives/textarea/Textarea.d.ts +0 -1
- package/dist/types/shared-slot.d.ts +1 -0
- package/dist/types/tokens/component-styles.generated.d.ts +79 -151
- package/dist/types/tokens/motion-defaults.generated.d.ts +34 -0
- package/dist/types/tokens/motion-scale.d.ts +2 -2
- package/dist/types/tokens/motion-tokens.d.ts +7 -0
- package/dist/types/tokens/theme-sync.d.ts +3 -0
- package/dist/types/tokens/theme-tokens.generated.d.ts +669 -1105
- package/dist/typing-lines.css +17 -10
- package/dist/typing-lines.js +9 -8
- package/dist/typing-lines.js.map +1 -1
- package/dist/weight-field.css +31 -17
- package/dist/weight-field.js +4 -4
- package/dist/weight-field.js.map +1 -1
- package/dist/youtube.css +90 -96
- package/dist/youtube.js +87 -86
- package/dist/youtube.js.map +1 -1
- package/package.json +3 -1
- package/skills/zyncat-ui/SKILL.md +5 -3
- package/skills/zyncat-ui/references/components.md +4 -4
- package/skills/zyncat-ui/references/theming.md +105 -34
- package/src/components/composites/alert/Alert.tsx +9 -10
- package/src/components/composites/alert/alert.css +26 -33
- package/src/components/composites/date-picker/DateField.tsx +1 -1
- package/src/components/composites/date-picker/DateRangeField.tsx +1 -1
- package/src/components/composites/date-picker/DateTimeField.tsx +4 -4
- package/src/components/composites/date-picker/TimeField.tsx +8 -5
- package/src/components/composites/date-picker/calendar-panel.tsx +25 -20
- package/src/components/composites/date-picker/date-picker.css +131 -154
- package/src/components/composites/date-picker/field-shell.tsx +7 -7
- package/src/components/composites/date-picker/range-panel.tsx +34 -34
- package/src/components/composites/date-picker/time-core.tsx +4 -6
- package/src/components/composites/date-picker/use-day-focus.ts +1 -1
- package/src/components/composites/dialog/Dialog.tsx +11 -11
- package/src/components/composites/dialog/dialog.css +31 -41
- package/src/components/composites/dropdown/Dropdown.tsx +15 -2
- package/src/components/composites/dropdown/Dropdown.usage.md +7 -4
- package/src/components/composites/dropdown/dropdown.css +36 -27
- package/src/components/composites/dropdown/menu-panel.tsx +56 -27
- package/src/components/composites/dropdown/types.ts +28 -6
- package/src/components/composites/emoji-picker/EmojiPickerPanel.tsx +5 -4
- package/src/components/composites/emoji-picker/EmojiPickerPanel.usage.md +4 -4
- package/src/components/composites/emoji-picker/data.ts +2 -5
- package/src/components/composites/emoji-picker/dom.ts +6 -6
- package/src/components/composites/emoji-picker/react/category-bar.tsx +6 -6
- package/src/components/composites/emoji-picker/react/useEmojiPicker.ts +0 -11
- package/src/components/composites/emoji-picker/scaffold.ts +7 -7
- package/src/components/composites/emoji-picker/search.ts +0 -7
- package/src/components/composites/emoji-picker/styles.css +34 -34
- package/src/components/composites/emoji-picker/types.ts +3 -8
- package/src/components/composites/modal/Modal.tsx +2 -2
- package/src/components/composites/modal/modal.css +2 -4
- package/src/components/composites/pagination/Pagination.tsx +7 -7
- package/src/components/composites/pagination/pagination.css +10 -15
- package/src/components/composites/popover/Popover.tsx +2 -2
- package/src/components/composites/popover/popover.css +13 -15
- package/src/components/composites/select/MultiSelect.tsx +11 -2
- package/src/components/composites/select/MultiSelect.usage.md +2 -1
- package/src/components/composites/select/Select.tsx +10 -1
- package/src/components/composites/select/Select.usage.md +2 -1
- package/src/components/composites/select/core/index.ts +1 -1
- package/src/components/composites/select/core/menu.tsx +19 -4
- package/src/components/composites/select/core/panel.tsx +19 -15
- package/src/components/composites/select/core/trigger.tsx +5 -5
- package/src/components/composites/select/select.css +66 -75
- package/src/components/composites/sheet/Sheet.tsx +2 -2
- package/src/components/composites/sheet/sheet.css +12 -14
- package/src/components/composites/sheet/use-sheet-drag.ts +1 -1
- package/src/components/composites/table/Table.tsx +35 -35
- package/src/components/composites/table/table.css +76 -84
- package/src/components/composites/tabs/Tabs.tsx +20 -21
- package/src/components/composites/tabs/Tabs.usage.md +3 -2
- package/src/components/composites/tabs/tabs.css +82 -90
- package/src/components/composites/toast/Toast.tsx +23 -18
- package/src/components/composites/toast/toast-store.ts +8 -6
- package/src/components/composites/toast/toast.css +49 -65
- package/src/components/composites/tooltip/Tooltip.tsx +40 -19
- package/src/components/composites/tooltip/Tooltip.usage.md +9 -1
- package/src/components/composites/tooltip/tooltip-host.tsx +55 -23
- package/src/components/composites/tooltip/tooltip-store.ts +36 -53
- package/src/components/composites/tooltip/tooltip.css +16 -23
- package/src/components/compound/support-rail/SupportRail.tsx +33 -33
- package/src/components/compound/support-rail/support-rail.css +116 -100
- package/src/components/dev/MotionDevtools.tsx +28 -17
- package/src/components/dev/MotionDevtools.usage.md +2 -2
- package/src/components/dev/motion-devtools.css +42 -68
- package/src/components/dev/slowmo-engine.ts +16 -15
- package/src/components/expressive/confetti/Confetti.tsx +4 -4
- package/src/components/expressive/confetti/confetti.css +19 -12
- package/src/components/expressive/facebook-feed/chrome.tsx +2 -2
- package/src/components/expressive/facebook-feed/facebook-feed.css +145 -148
- package/src/components/expressive/facebook-feed/post.tsx +39 -39
- package/src/components/expressive/facebook-feed/reel.tsx +41 -37
- package/src/components/expressive/facebook-feed/story.tsx +27 -27
- package/src/components/expressive/flow-field/FlowField.tsx +4 -4
- package/src/components/expressive/flow-field/flow-field.css +8 -4
- package/src/components/expressive/instagram-feed/InstagramFeed.tsx +52 -44
- package/src/components/expressive/instagram-feed/instagram-feed.css +65 -66
- package/src/components/expressive/lens/Lens.tsx +14 -14
- package/src/components/expressive/lens/lens.css +42 -38
- package/src/components/expressive/morphing-text/MorphingText.tsx +12 -13
- package/src/components/expressive/morphing-text/morphing-text.css +26 -16
- package/src/components/expressive/odometer/Odometer.tsx +9 -9
- package/src/components/expressive/odometer/odometer.css +22 -16
- package/src/components/expressive/tiktok/TikTok.tsx +54 -54
- package/src/components/expressive/tiktok/tiktok.css +113 -117
- package/src/components/expressive/typing-lines/TypingLines.tsx +0 -0
- package/src/components/expressive/typing-lines/typing-lines.css +17 -10
- package/src/components/expressive/weight-field/WeightField.tsx +4 -4
- package/src/components/expressive/weight-field/weight-field.css +31 -17
- package/src/components/expressive/youtube/YouTube.tsx +4 -4
- package/src/components/expressive/youtube/glyphs.tsx +16 -16
- package/src/components/expressive/youtube/media.tsx +3 -3
- package/src/components/expressive/youtube/post.tsx +28 -28
- package/src/components/expressive/youtube/short.tsx +25 -25
- package/src/components/expressive/youtube/video.tsx +13 -13
- package/src/components/expressive/youtube/youtube.css +90 -96
- package/src/components/internal/glass/glass.css +19 -22
- package/src/components/internal/glass/glint.ts +3 -3
- package/src/components/internal/hooks/use-host-election.ts +46 -0
- package/src/components/internal/icon/Icon.tsx +1 -5
- package/src/components/internal/icon/IconSlot.tsx +1 -1
- package/src/components/internal/icon/icon.css +7 -10
- package/src/components/internal/menu/highlight.ts +12 -0
- package/src/components/internal/menu/menu-row.tsx +5 -5
- package/src/components/internal/menu/menu-surface.css +54 -34
- package/src/components/internal/overlay/layer.tsx +2 -1
- package/src/components/internal/overlay/modal.tsx +5 -4
- package/src/components/internal/overlay/overlay.css +4 -9
- package/src/components/internal/overlay/trigger.css +3 -3
- package/src/components/internal/utils/activation.ts +0 -4
- package/src/components/primitives/avatar/Avatar.tsx +24 -8
- package/src/components/primitives/avatar/AvatarGroup.tsx +4 -4
- package/src/components/primitives/avatar/avatar.css +51 -50
- package/src/components/primitives/badge/Badge.tsx +9 -9
- package/src/components/primitives/badge/StatusBadge.tsx +7 -7
- package/src/components/primitives/badge/badge.css +30 -36
- package/src/components/primitives/badge/digit-strip.css +16 -16
- package/src/components/primitives/badge/digit-strip.tsx +4 -4
- package/src/components/primitives/button/Button.tsx +8 -8
- package/src/components/primitives/button/button.css +80 -96
- package/src/components/primitives/checkbox/Checkbox.tsx +10 -4
- package/src/components/primitives/checkbox/check-glyph.tsx +5 -5
- package/src/components/primitives/checkbox/checkbox.css +27 -32
- package/src/components/primitives/collapse/Collapse.tsx +2 -2
- package/src/components/primitives/collapse/collapse.css +15 -30
- package/src/components/primitives/collapse/collapse.typecheck.tsx +1 -1
- package/src/components/primitives/input/NumberField.tsx +11 -11
- package/src/components/primitives/input/OtpField.tsx +3 -3
- package/src/components/primitives/input/TextField.tsx +9 -10
- package/src/components/primitives/input/field-chrome.tsx +6 -6
- package/src/components/primitives/input/input.css +76 -84
- package/src/components/primitives/radio-group/RadioGroup.tsx +23 -23
- package/src/components/primitives/radio-group/radio-group.css +60 -73
- package/src/components/primitives/tag/Tag.tsx +5 -5
- package/src/components/primitives/tag/ToggleTag.tsx +11 -6
- package/src/components/primitives/tag/tag.css +48 -53
- package/src/components/primitives/textarea/Textarea.tsx +13 -14
- package/src/components/primitives/textarea/textarea.css +46 -49
- package/src/components/primitives/toggle/Toggle.tsx +7 -7
- package/src/components/primitives/toggle/toggle.css +26 -31
- package/src/engine/animate.ts +2 -1
- package/src/engine/flip.ts +2 -1
- package/src/mcp/server.ts +3 -1
- package/src/motion/flip.ts +7 -8
- package/src/motion/glide.tsx +41 -26
- package/src/shared-slot.ts +10 -0
- package/src/styles.css +7 -15
- package/src/tokens/base.css +15 -0
- package/src/tokens/color.css +19 -59
- package/src/tokens/component-styles.generated.ts +79 -151
- package/src/tokens/dark.css +63 -0
- package/src/tokens/decisions.css +26 -0
- package/src/tokens/elevation.css +71 -21
- package/src/tokens/fonts.css +0 -2
- package/src/tokens/glass.css +15 -9
- package/src/tokens/motion-defaults.generated.ts +21 -0
- package/src/tokens/motion-scale.ts +2 -2
- package/src/tokens/motion-tokens.ts +65 -40
- package/src/tokens/motion-tokens.usage.md +5 -2
- package/src/tokens/motion.css +12 -22
- package/src/tokens/radius.css +10 -9
- package/src/tokens/semantic.css +57 -37
- package/src/tokens/spacing.css +5 -6
- package/src/tokens/theme-sync.tsx +15 -0
- package/src/tokens/theme-tokens.generated.ts +682 -1109
- package/src/tokens/theme.tsx +22 -16
- package/src/tokens/theme.usage.md +19 -13
- package/src/tokens/typography.css +16 -19
- package/tailwind.css +193 -0
- package/dist/chunk-227ZW4V7.js.map +0 -1
- package/dist/chunk-43M6GQ4Q.js.map +0 -1
- package/dist/chunk-4BSHB7R3.js.map +0 -1
- package/dist/chunk-4C5RZXBT.js.map +0 -1
- package/dist/chunk-5PZ43DCG.js.map +0 -1
- package/dist/chunk-7IZJERGA.js +0 -80
- package/dist/chunk-7IZJERGA.js.map +0 -1
- package/dist/chunk-AADAJL7D.js.map +0 -1
- package/dist/chunk-CNWTIMIP.js +0 -39
- package/dist/chunk-CNWTIMIP.js.map +0 -1
- package/dist/chunk-EAI4POPB.js.map +0 -1
- package/dist/chunk-EF6RPXU7.js.map +0 -1
- package/dist/chunk-FONOS5RN.js.map +0 -1
- package/dist/chunk-FQEHSKEI.js +0 -38
- package/dist/chunk-FQEHSKEI.js.map +0 -1
- package/dist/chunk-HY5MPISE.js.map +0 -1
- package/dist/chunk-I45AU6KH.js.map +0 -1
- package/dist/chunk-IJS7TPGV.js.map +0 -1
- package/dist/chunk-OWNMRMPN.js +0 -14
- package/dist/chunk-OWNMRMPN.js.map +0 -1
- package/dist/chunk-RJFGWJ4W.js.map +0 -1
- package/dist/chunk-TVYH4AN7.js.map +0 -1
- package/dist/chunk-TYHR4VNM.js.map +0 -1
- package/dist/chunk-VAXCXZ53.js.map +0 -1
- package/dist/chunk-XNIYSAMJ.js.map +0 -1
- package/dist/chunk-Y2YA7QRF.js +0 -17
- package/dist/chunk-Y2YA7QRF.js.map +0 -1
- package/src/tokens/avatar.css +0 -24
- package/src/tokens/icons.css +0 -11
- package/src/tokens/layers.css +0 -11
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
@layer zyncat.tokens, zyncat.components;
|
|
2
2
|
|
|
3
3
|
@layer zyncat.components {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.toast-viewport {
|
|
4
|
+
.zc-toast-viewport {
|
|
7
5
|
position: fixed;
|
|
8
6
|
width: min(22.5rem, calc(100vw - 2 * var(--toast-offset, var(--space-6))));
|
|
9
7
|
z-index: var(--layer-toast);
|
|
10
8
|
margin: 0;
|
|
11
9
|
padding: 0;
|
|
12
10
|
list-style: none;
|
|
13
|
-
pointer-events: none;
|
|
11
|
+
pointer-events: none;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
.toast-viewport[data-position^='top'] {
|
|
14
|
+
.zc-toast-viewport[data-position^='top'] {
|
|
18
15
|
top: var(--toast-offset, var(--space-6));
|
|
19
16
|
}
|
|
20
|
-
.toast-viewport[data-position^='bottom'] {
|
|
17
|
+
.zc-toast-viewport[data-position^='bottom'] {
|
|
21
18
|
bottom: var(--toast-offset, var(--space-6));
|
|
22
19
|
}
|
|
23
|
-
.toast-viewport[data-position$='right'] {
|
|
20
|
+
.zc-toast-viewport[data-position$='right'] {
|
|
24
21
|
right: var(--toast-offset, var(--space-6));
|
|
25
22
|
}
|
|
26
|
-
.toast-viewport[data-position$='left'] {
|
|
23
|
+
.zc-toast-viewport[data-position$='left'] {
|
|
27
24
|
left: var(--toast-offset, var(--space-6));
|
|
28
25
|
}
|
|
29
|
-
.toast-viewport[data-position$='center'] {
|
|
26
|
+
.zc-toast-viewport[data-position$='center'] {
|
|
30
27
|
left: 50%;
|
|
31
28
|
transform: translateX(-50%);
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
.toast {
|
|
36
|
-
/* tone hooks - set by [data-tone] below */
|
|
31
|
+
.zc-toast {
|
|
37
32
|
--toast-hue: var(--text-subtle);
|
|
38
33
|
--glass-fg: var(--text-strong);
|
|
39
34
|
--glass-tint: color-mix(in oklab, var(--glass-tint-neutral) 75%, transparent);
|
|
@@ -43,59 +38,55 @@
|
|
|
43
38
|
left: 0;
|
|
44
39
|
width: 100%;
|
|
45
40
|
box-sizing: border-box;
|
|
46
|
-
overflow: hidden;
|
|
41
|
+
overflow: hidden;
|
|
47
42
|
pointer-events: auto;
|
|
48
43
|
border-radius: var(--radius-lg);
|
|
49
44
|
|
|
50
|
-
/* Motion owns transform - keep only the color/shadow transitions (never smooth Motion's writes) */
|
|
51
45
|
transition:
|
|
52
46
|
background-color var(--duration-base) var(--ease-standard),
|
|
53
47
|
box-shadow var(--duration-base) var(--ease-standard);
|
|
54
48
|
}
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
.toast-viewport[data-position^='bottom'] .toast {
|
|
50
|
+
.zc-toast-viewport[data-position^='bottom'] .zc-toast {
|
|
58
51
|
bottom: 0;
|
|
59
52
|
transform-origin: center bottom;
|
|
60
53
|
}
|
|
61
|
-
.toast-viewport[data-position^='top'] .toast {
|
|
54
|
+
.zc-toast-viewport[data-position^='top'] .zc-toast {
|
|
62
55
|
top: 0;
|
|
63
56
|
transform-origin: center top;
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
.toast[data-tone='success'] {
|
|
59
|
+
.zc-toast[data-tone='success'] {
|
|
68
60
|
--toast-hue: var(--success);
|
|
69
61
|
--glass-fg: var(--success-text);
|
|
70
62
|
--glass-tint: color-mix(in oklab, var(--glass-tint-success) 70%, transparent);
|
|
71
63
|
}
|
|
72
|
-
.toast[data-tone='danger'] {
|
|
64
|
+
.zc-toast[data-tone='danger'] {
|
|
73
65
|
--toast-hue: var(--danger);
|
|
74
66
|
--glass-fg: var(--danger-text);
|
|
75
67
|
--glass-tint: color-mix(in oklab, var(--glass-tint-danger) 70%, transparent);
|
|
76
68
|
}
|
|
77
|
-
.toast[data-tone='warning'] {
|
|
69
|
+
.zc-toast[data-tone='warning'] {
|
|
78
70
|
--toast-hue: var(--warning);
|
|
79
71
|
--glass-fg: var(--warning-text);
|
|
80
72
|
--glass-tint: color-mix(in oklab, var(--glass-tint-warning) 70%, transparent);
|
|
81
73
|
}
|
|
82
|
-
.toast[data-tone='info'] {
|
|
74
|
+
.zc-toast[data-tone='info'] {
|
|
83
75
|
--toast-hue: var(--info);
|
|
84
76
|
--glass-fg: var(--info-text);
|
|
85
77
|
--glass-tint: color-mix(in oklab, var(--glass-tint-info) 70%, transparent);
|
|
86
78
|
}
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
.toast[data-behind] {
|
|
80
|
+
.zc-toast[data-behind] {
|
|
90
81
|
--glass-tint: color-mix(in oklab, var(--glass-tint-neutral) 75%, transparent);
|
|
91
82
|
--glass-sheen-rest: 0.3;
|
|
92
83
|
}
|
|
93
|
-
.toast[data-behind] .toast__inner,
|
|
94
|
-
.toast[data-behind] .toast__custom {
|
|
84
|
+
.zc-toast[data-behind] .zc-toast__inner,
|
|
85
|
+
.zc-toast[data-behind] .zc-toast__custom {
|
|
95
86
|
opacity: 0;
|
|
96
87
|
}
|
|
97
88
|
|
|
98
|
-
.toast__inner {
|
|
89
|
+
.zc-toast__inner {
|
|
99
90
|
display: flex;
|
|
100
91
|
align-items: center;
|
|
101
92
|
gap: var(--space-3);
|
|
@@ -103,8 +94,7 @@
|
|
|
103
94
|
transition: var(--transition-opacity);
|
|
104
95
|
}
|
|
105
96
|
|
|
106
|
-
|
|
107
|
-
.toast__icon {
|
|
97
|
+
.zc-toast__icon {
|
|
108
98
|
position: relative;
|
|
109
99
|
flex: none;
|
|
110
100
|
display: grid;
|
|
@@ -113,36 +103,35 @@
|
|
|
113
103
|
height: calc(var(--icon-md) + 2 * var(--space-2));
|
|
114
104
|
color: var(--toast-hue);
|
|
115
105
|
}
|
|
116
|
-
.toast__icon-glyph {
|
|
106
|
+
.zc-toast__icon-glyph {
|
|
117
107
|
display: grid;
|
|
118
108
|
place-items: center;
|
|
119
109
|
}
|
|
120
110
|
|
|
121
|
-
|
|
122
|
-
.toast__ring {
|
|
111
|
+
.zc-toast__ring {
|
|
123
112
|
position: absolute;
|
|
124
113
|
inset: 0;
|
|
125
114
|
width: 100%;
|
|
126
115
|
height: 100%;
|
|
127
|
-
transform: rotate(-90deg);
|
|
116
|
+
transform: rotate(-90deg);
|
|
128
117
|
pointer-events: none;
|
|
129
118
|
}
|
|
130
|
-
.toast__ring circle {
|
|
119
|
+
.zc-toast__ring circle {
|
|
131
120
|
fill: none;
|
|
132
121
|
stroke-width: var(--border-emphasis);
|
|
133
122
|
}
|
|
134
|
-
.toast__ring-track {
|
|
123
|
+
.zc-toast__ring-track {
|
|
135
124
|
stroke: color-mix(in oklab, var(--toast-hue) 16%, transparent);
|
|
136
125
|
}
|
|
137
|
-
.toast__ring-arc {
|
|
126
|
+
.zc-toast__ring-arc {
|
|
138
127
|
stroke: var(--toast-hue);
|
|
139
128
|
stroke-linecap: round;
|
|
140
|
-
stroke-dasharray: 1; /* pathLength=1
|
|
141
|
-
animation-name: toast-ring;
|
|
129
|
+
stroke-dasharray: 1; /* the circle sets pathLength=1 */
|
|
130
|
+
animation-name: toast-ring; /* the duration is inline, set to the toast's lifetime */
|
|
142
131
|
animation-timing-function: linear;
|
|
143
132
|
animation-fill-mode: both;
|
|
144
133
|
}
|
|
145
|
-
.toast-viewport.is-paused .toast__ring-arc {
|
|
134
|
+
.zc-toast-viewport.zc-is-paused .zc-toast__ring-arc {
|
|
146
135
|
animation-play-state: paused;
|
|
147
136
|
}
|
|
148
137
|
@keyframes toast-ring {
|
|
@@ -154,27 +143,26 @@
|
|
|
154
143
|
}
|
|
155
144
|
}
|
|
156
145
|
|
|
157
|
-
.toast__text {
|
|
146
|
+
.zc-toast__text {
|
|
158
147
|
flex: 1 1 auto;
|
|
159
148
|
min-width: 0;
|
|
160
149
|
}
|
|
161
|
-
.toast__message {
|
|
150
|
+
.zc-toast__message {
|
|
162
151
|
margin: 0;
|
|
163
152
|
font: var(--type-label);
|
|
164
153
|
color: var(--glass-fg);
|
|
165
154
|
text-wrap: pretty;
|
|
166
155
|
}
|
|
167
|
-
.toast__desc {
|
|
156
|
+
.zc-toast__desc {
|
|
168
157
|
margin: var(--space-1) 0 0;
|
|
169
158
|
font: var(--type-caption);
|
|
170
159
|
color: color-mix(in oklab, var(--glass-fg) 76%, transparent);
|
|
171
160
|
text-wrap: pretty;
|
|
172
161
|
}
|
|
173
162
|
|
|
174
|
-
|
|
175
|
-
.toast__count {
|
|
163
|
+
.zc-toast__count {
|
|
176
164
|
flex: none;
|
|
177
|
-
font-family: var(--font-
|
|
165
|
+
font-family: var(--font-code);
|
|
178
166
|
font-size: var(--size-micro);
|
|
179
167
|
line-height: var(--leading-micro);
|
|
180
168
|
font-variant-numeric: tabular-nums;
|
|
@@ -184,12 +172,11 @@
|
|
|
184
172
|
padding: 0 var(--space-1);
|
|
185
173
|
}
|
|
186
174
|
|
|
187
|
-
.toast__action {
|
|
175
|
+
.zc-toast__action {
|
|
188
176
|
flex: none;
|
|
189
177
|
}
|
|
190
178
|
|
|
191
|
-
|
|
192
|
-
.toast__close {
|
|
179
|
+
.zc-toast__close {
|
|
193
180
|
flex: none;
|
|
194
181
|
appearance: none;
|
|
195
182
|
display: grid;
|
|
@@ -208,25 +195,23 @@
|
|
|
208
195
|
var(--transition-control),
|
|
209
196
|
opacity var(--duration-fast) var(--ease-standard);
|
|
210
197
|
}
|
|
211
|
-
.toast:hover .toast__close,
|
|
212
|
-
.toast:focus-within .toast__close {
|
|
198
|
+
.zc-toast:hover .zc-toast__close,
|
|
199
|
+
.zc-toast:focus-within .zc-toast__close {
|
|
213
200
|
opacity: 1;
|
|
214
201
|
}
|
|
215
|
-
.toast__close:hover {
|
|
202
|
+
.zc-toast__close:hover {
|
|
216
203
|
background: color-mix(in oklab, var(--glass-fg) 9%, transparent);
|
|
217
204
|
color: var(--glass-fg);
|
|
218
205
|
}
|
|
219
|
-
.toast__close:active {
|
|
206
|
+
.zc-toast__close:active {
|
|
220
207
|
background: color-mix(in oklab, var(--glass-fg) 14%, transparent);
|
|
221
208
|
}
|
|
222
|
-
.toast__close:focus-visible {
|
|
223
|
-
outline:
|
|
224
|
-
box-shadow: var(--focus-ring);
|
|
209
|
+
.zc-toast__close:focus-visible {
|
|
210
|
+
outline: var(--focus-ring);
|
|
225
211
|
opacity: 1;
|
|
226
212
|
}
|
|
227
213
|
|
|
228
|
-
|
|
229
|
-
.toast__spinner {
|
|
214
|
+
.zc-toast__spinner {
|
|
230
215
|
display: block;
|
|
231
216
|
box-sizing: border-box;
|
|
232
217
|
width: var(--icon-sm);
|
|
@@ -243,18 +228,17 @@
|
|
|
243
228
|
}
|
|
244
229
|
}
|
|
245
230
|
|
|
246
|
-
|
|
247
|
-
.toast__custom {
|
|
231
|
+
.zc-toast__custom {
|
|
248
232
|
padding: var(--space-3) var(--space-4);
|
|
249
233
|
transition: var(--transition-opacity);
|
|
250
234
|
}
|
|
251
235
|
|
|
252
236
|
@media (prefers-reduced-motion: reduce) {
|
|
253
|
-
/*
|
|
254
|
-
.toast,
|
|
255
|
-
.toast__close,
|
|
256
|
-
.toast__inner,
|
|
257
|
-
.toast__custom {
|
|
237
|
+
/* the ring keeps running: it is a clock, not decoration */
|
|
238
|
+
.zc-toast,
|
|
239
|
+
.zc-toast__close,
|
|
240
|
+
.zc-toast__inner,
|
|
241
|
+
.zc-toast__custom {
|
|
258
242
|
transition: none;
|
|
259
243
|
}
|
|
260
244
|
}
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
} from 'react';
|
|
16
16
|
|
|
17
17
|
import type { DataAttributes } from '../../../dom-props';
|
|
18
|
+
import { usePresence } from '../../../motion/presence-context';
|
|
19
|
+
import { useControllable } from '../../internal/hooks/use-controllable';
|
|
18
20
|
import { cx } from '../../internal/utils/cx';
|
|
19
21
|
import { TooltipHost } from './tooltip-host';
|
|
20
22
|
import { CLOSE_GRACE, OPEN_DELAY, store, useHostElection, type Placement } from './tooltip-store';
|
|
@@ -26,6 +28,14 @@ export interface TooltipProps {
|
|
|
26
28
|
shortcut?: string | null;
|
|
27
29
|
/** Preferred side; flips automatically when out of viewport room. */
|
|
28
30
|
placement?: Placement;
|
|
31
|
+
/** Controlled visibility - shows with no hover or focus, and stays until you clear it.
|
|
32
|
+
* Omit to stay uncontrolled. One bubble shows at a time: the newest wins, and the ones
|
|
33
|
+
* under it come back when it leaves. */
|
|
34
|
+
open?: boolean;
|
|
35
|
+
/** Initial state when uncontrolled. Default false. */
|
|
36
|
+
defaultOpen?: boolean;
|
|
37
|
+
/** Fires whenever hover, focus, or Escape asks for a new state. Pair with `open` for controlled use. */
|
|
38
|
+
onOpenChange?: (open: boolean) => void;
|
|
29
39
|
/** Suppress the tooltip entirely (trigger renders untouched). */
|
|
30
40
|
disabled?: boolean;
|
|
31
41
|
/** ms before a cold hover shows; warm hovers + focus are instant. Default 350. */
|
|
@@ -45,6 +55,9 @@ export function Tooltip({
|
|
|
45
55
|
content,
|
|
46
56
|
shortcut = null,
|
|
47
57
|
placement = 'top',
|
|
58
|
+
open: controlledOpen,
|
|
59
|
+
defaultOpen = false,
|
|
60
|
+
onOpenChange,
|
|
48
61
|
disabled = false,
|
|
49
62
|
openDelay = OPEN_DELAY,
|
|
50
63
|
closeDelay = CLOSE_GRACE,
|
|
@@ -54,38 +67,46 @@ export function Tooltip({
|
|
|
54
67
|
}: TooltipProps) {
|
|
55
68
|
const wrapRef = useRef<HTMLSpanElement | null>(null);
|
|
56
69
|
const openTimer = useRef<ReturnType<typeof setTimeout> | 0>(0);
|
|
57
|
-
const
|
|
70
|
+
const autoId = useId();
|
|
71
|
+
const myId = id || 'tip-' + autoId;
|
|
58
72
|
const isHost = useHostElection();
|
|
73
|
+
const { isPresent } = usePresence();
|
|
74
|
+
const [open, setOpen] = useControllable(controlledOpen, defaultOpen, onOpenChange);
|
|
59
75
|
|
|
60
|
-
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!open || disabled || !isPresent) return undefined;
|
|
78
|
+
store.open({
|
|
79
|
+
id: myId,
|
|
80
|
+
content,
|
|
81
|
+
shortcut,
|
|
82
|
+
placement,
|
|
83
|
+
anchor: () => (wrapRef.current?.firstElementChild as HTMLElement) ?? null,
|
|
84
|
+
dismiss: () => setOpen(false),
|
|
85
|
+
});
|
|
86
|
+
return () => store.close(myId, closeDelay);
|
|
87
|
+
}, [open, disabled, isPresent, content, shortcut, placement, closeDelay, myId, setOpen]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!isPresent) store.close(myId, 0);
|
|
91
|
+
}, [isPresent, myId]);
|
|
61
92
|
|
|
62
93
|
useEffect(
|
|
63
94
|
() => () => {
|
|
64
95
|
clearTimeout(openTimer.current);
|
|
65
96
|
store.close(myId, 0);
|
|
66
97
|
},
|
|
67
|
-
[],
|
|
68
|
-
);
|
|
98
|
+
[myId],
|
|
99
|
+
);
|
|
69
100
|
|
|
70
101
|
function show(immediate: boolean) {
|
|
71
|
-
if (disabled) return;
|
|
72
102
|
clearTimeout(openTimer.current);
|
|
73
|
-
if (!
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
id: myId,
|
|
77
|
-
content,
|
|
78
|
-
shortcut,
|
|
79
|
-
placement,
|
|
80
|
-
anchor: anchorEl,
|
|
81
|
-
rect: () => anchorEl()!.getBoundingClientRect(),
|
|
82
|
-
});
|
|
83
|
-
if (immediate || store.isWarm()) open();
|
|
84
|
-
else openTimer.current = setTimeout(open, openDelay);
|
|
103
|
+
if (disabled || !wrapRef.current?.firstElementChild) return;
|
|
104
|
+
if (immediate || store.isWarm()) setOpen(true);
|
|
105
|
+
else openTimer.current = setTimeout(() => setOpen(true), openDelay);
|
|
85
106
|
}
|
|
86
107
|
function hide() {
|
|
87
108
|
clearTimeout(openTimer.current);
|
|
88
|
-
|
|
109
|
+
setOpen(false);
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
const onEnter = (e: PointerEvent) => {
|
|
@@ -100,7 +121,7 @@ export function Tooltip({
|
|
|
100
121
|
<span
|
|
101
122
|
{...htmlProps}
|
|
102
123
|
ref={wrapRef}
|
|
103
|
-
className={cx('tooltip-anchor', htmlProps?.className)}
|
|
124
|
+
className={cx('zc-tooltip-anchor', htmlProps?.className)}
|
|
104
125
|
onPointerEnter={onEnter}
|
|
105
126
|
onPointerLeave={hide}
|
|
106
127
|
onPointerDown={hide}
|
|
@@ -5,10 +5,18 @@ Docs: https://ui.zyncat.app/tooltip
|
|
|
5
5
|
|
|
6
6
|
Transient hint on hover/focus; wraps any child (no ref wiring needed).
|
|
7
7
|
|
|
8
|
-
content, shortcut, placement top|bottom|left|right
|
|
8
|
+
content, shortcut, placement top|bottom|left|right; open/defaultOpen/onOpenChange to drive it yourself, for a
|
|
9
|
+
hint no hover would ever fire. With open set, hover, focus and Escape decide nothing on their own - they only
|
|
10
|
+
report through onOpenChange, so a parent that ignores it keeps the bubble up. Scrolling never closes it: the
|
|
11
|
+
bubble tracks its anchor through page and container scroll, and leaves on pointer out, blur, or a handled Escape.
|
|
12
|
+
It also leaves the moment a surface around it starts animating out, so a tooltip inside a closing Popover or
|
|
13
|
+
Modal goes with it rather than outliving the panel.
|
|
9
14
|
|
|
10
15
|
```tsx
|
|
11
16
|
<Tooltip content="Save changes" shortcut="⌘S">
|
|
12
17
|
<Button>Save</Button>
|
|
13
18
|
</Tooltip>
|
|
19
|
+
<Tooltip content="Drafts land here" open={tour === 'drafts'} onOpenChange={(next) => !next && nextStep()}>
|
|
20
|
+
<Button variant="ghost">Drafts</Button>
|
|
21
|
+
</Tooltip>
|
|
14
22
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Fragment,
|
|
3
|
+
import { Fragment, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
6
6
|
import { Motion } from '../../../motion/element';
|
|
@@ -59,6 +59,8 @@ function targetBox(size: Size, t: DOMRect, want: Placement): TargetBox {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const surface = () => document.getElementById(TOOLTIP_DOM_ID);
|
|
63
|
+
|
|
62
64
|
const fromEdge = (p: Placement) => ({
|
|
63
65
|
x: p === 'left' ? SM.dist.sm : p === 'right' ? -SM.dist.sm : 0,
|
|
64
66
|
y: p === 'top' ? SM.dist.sm : p === 'bottom' ? -SM.dist.sm : 0,
|
|
@@ -66,11 +68,11 @@ const fromEdge = (p: Placement) => ({
|
|
|
66
68
|
|
|
67
69
|
function Body({ a, width }: { a: ActivePayload; width?: number }) {
|
|
68
70
|
return (
|
|
69
|
-
<span className="tooltip__body" style={width ? { width } : undefined}>
|
|
71
|
+
<span className="zc-tooltip__body" style={width ? { width } : undefined}>
|
|
70
72
|
{a.shortcut ? (
|
|
71
|
-
<span className="tooltip__row">
|
|
73
|
+
<span className="zc-tooltip__row">
|
|
72
74
|
<span>{a.content}</span>
|
|
73
|
-
<kbd className="tooltip__shortcut">{a.shortcut}</kbd>
|
|
75
|
+
<kbd className="zc-tooltip__shortcut">{a.shortcut}</kbd>
|
|
74
76
|
</span>
|
|
75
77
|
) : (
|
|
76
78
|
a.content
|
|
@@ -85,7 +87,7 @@ function TipSurface({ a, box }: { a: ActivePayload; box: RenderedBox }) {
|
|
|
85
87
|
<Motion
|
|
86
88
|
layout
|
|
87
89
|
layoutTransition={TIP_LAYOUT}
|
|
88
|
-
className="tooltip"
|
|
90
|
+
className="zc-tooltip"
|
|
89
91
|
id={TOOLTIP_DOM_ID}
|
|
90
92
|
role="tooltip"
|
|
91
93
|
data-placement={box.placement}
|
|
@@ -109,43 +111,73 @@ function TipSurface({ a, box }: { a: ActivePayload; box: RenderedBox }) {
|
|
|
109
111
|
export function TooltipHost() {
|
|
110
112
|
const active = useSyncExternalStore(store.subscribe, store.get);
|
|
111
113
|
const measureRef = useRef<HTMLDivElement>(null);
|
|
112
|
-
const
|
|
114
|
+
const drift = useRef({ x: 0, y: 0 });
|
|
115
|
+
const anchored = useRef({ x: 0, y: 0 });
|
|
116
|
+
const [shown, setShown] = useState<{ a: ActivePayload; box: RenderedBox } | null>(null);
|
|
113
117
|
|
|
114
118
|
useLayoutEffect(() => {
|
|
115
119
|
if (!active) {
|
|
116
|
-
|
|
117
|
-
return;
|
|
120
|
+
setShown(null);
|
|
121
|
+
return undefined;
|
|
118
122
|
}
|
|
119
|
-
const r = measureRef.current.getBoundingClientRect();
|
|
120
|
-
const b = (measureRef.current.firstChild as HTMLElement).getBoundingClientRect();
|
|
121
|
-
setBox({
|
|
122
|
-
...targetBox({ w: Math.ceil(r.width), h: Math.ceil(r.height) }, active.rect(), active.placement),
|
|
123
|
-
bodyW: Math.ceil(b.width),
|
|
124
|
-
});
|
|
125
|
-
}, [active]);
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
const place = () => {
|
|
125
|
+
const anchor = active.anchor();
|
|
126
|
+
const measure = measureRef.current;
|
|
127
|
+
if (!anchor || !measure) return;
|
|
128
|
+
const bubble = measure.getBoundingClientRect();
|
|
129
|
+
const body = (measure.firstChild as HTMLElement).getBoundingClientRect();
|
|
130
|
+
const from = anchor.getBoundingClientRect();
|
|
131
|
+
if (!from.width && !from.height) return;
|
|
132
|
+
if (!surface()) drift.current = { x: 0, y: 0 };
|
|
133
|
+
anchored.current = { x: from.left, y: from.top };
|
|
134
|
+
const to = targetBox({ w: Math.ceil(bubble.width), h: Math.ceil(bubble.height) }, from, active.placement);
|
|
135
|
+
setShown({
|
|
136
|
+
a: active,
|
|
137
|
+
box: { ...to, x: to.x - drift.current.x, y: to.y - drift.current.y, bodyW: Math.ceil(body.width) },
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const track = () => {
|
|
142
|
+
const el = surface();
|
|
143
|
+
const anchor = active.anchor();
|
|
144
|
+
if (!el || !anchor) return;
|
|
145
|
+
const now = anchor.getBoundingClientRect();
|
|
146
|
+
if (!now.width && !now.height) return;
|
|
147
|
+
const at = {
|
|
148
|
+
x: drift.current.x + now.left - anchored.current.x,
|
|
149
|
+
y: drift.current.y + now.top - anchored.current.y,
|
|
150
|
+
};
|
|
151
|
+
drift.current = at;
|
|
152
|
+
anchored.current = { x: now.left, y: now.top };
|
|
153
|
+
el.style.transform = at.x || at.y ? `translate(${at.x}px, ${at.y}px)` : '';
|
|
154
|
+
};
|
|
155
|
+
|
|
129
156
|
const onKey = (e: KeyboardEvent) => {
|
|
130
|
-
if (e.key === 'Escape') store.
|
|
157
|
+
if (e.key === 'Escape') store.dismiss();
|
|
131
158
|
};
|
|
132
|
-
|
|
159
|
+
|
|
160
|
+
place();
|
|
133
161
|
document.addEventListener('keydown', onKey);
|
|
134
|
-
window.addEventListener('scroll',
|
|
162
|
+
window.addEventListener('scroll', track, true);
|
|
163
|
+
window.addEventListener('resize', place);
|
|
135
164
|
return () => {
|
|
136
165
|
document.removeEventListener('keydown', onKey);
|
|
137
|
-
window.removeEventListener('scroll',
|
|
166
|
+
window.removeEventListener('scroll', track, true);
|
|
167
|
+
window.removeEventListener('resize', place);
|
|
138
168
|
};
|
|
139
169
|
}, [active]);
|
|
140
170
|
|
|
171
|
+
const orphaned = !!shown && !shown.a.anchor();
|
|
172
|
+
|
|
141
173
|
return createPortal(
|
|
142
174
|
<Fragment>
|
|
143
175
|
{active && (
|
|
144
|
-
<div className="tooltip tooltip--measure" ref={measureRef} aria-hidden="true">
|
|
176
|
+
<div className="zc-tooltip zc-tooltip--measure" ref={measureRef} aria-hidden="true">
|
|
145
177
|
<Body a={active} />
|
|
146
178
|
</div>
|
|
147
179
|
)}
|
|
148
|
-
<Presence>{active &&
|
|
180
|
+
<Presence>{active && shown && !orphaned && <TipSurface key="tip" a={shown.a} box={shown.box} />}</Presence>
|
|
149
181
|
</Fragment>,
|
|
150
182
|
document.body,
|
|
151
183
|
);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { sharedSlot } from '../../../shared-slot';
|
|
6
|
+
import { hostRegistry, useElectedHost } from '../../internal/hooks/use-host-election';
|
|
4
7
|
|
|
5
8
|
export type Placement = 'top' | 'bottom' | 'left' | 'right';
|
|
6
9
|
|
|
@@ -10,7 +13,7 @@ export interface ActivePayload {
|
|
|
10
13
|
shortcut?: string | null;
|
|
11
14
|
placement: Placement;
|
|
12
15
|
anchor: () => HTMLElement | null;
|
|
13
|
-
|
|
16
|
+
dismiss: () => void;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export const OPEN_DELAY = 350;
|
|
@@ -18,74 +21,54 @@ export const CLOSE_GRACE = 140;
|
|
|
18
21
|
export const TOOLTIP_DOM_ID = 'pds-tooltip';
|
|
19
22
|
const WARM_WINDOW = 300;
|
|
20
23
|
|
|
21
|
-
export const store = {
|
|
22
|
-
|
|
24
|
+
export const store = sharedSlot('tooltip.store@1', () => ({
|
|
25
|
+
stack: [] as ActivePayload[],
|
|
23
26
|
described: null as HTMLElement | null,
|
|
24
|
-
|
|
27
|
+
timers: new Map<string, ReturnType<typeof setTimeout>>(),
|
|
25
28
|
warmUntil: 0,
|
|
26
29
|
listeners: new Set<() => void>(),
|
|
27
|
-
get: () => store.
|
|
30
|
+
get: (): ActivePayload | null => store.stack[store.stack.length - 1] ?? null,
|
|
28
31
|
subscribe(l: () => void) {
|
|
29
32
|
store.listeners.add(l);
|
|
30
33
|
return () => store.listeners.delete(l);
|
|
31
34
|
},
|
|
32
35
|
emit() {
|
|
36
|
+
const el = store.get()?.anchor() ?? null;
|
|
37
|
+
if (el !== store.described) {
|
|
38
|
+
store.described?.removeAttribute('aria-describedby');
|
|
39
|
+
store.described = el;
|
|
40
|
+
el?.setAttribute('aria-describedby', TOOLTIP_DOM_ID);
|
|
41
|
+
}
|
|
33
42
|
store.listeners.forEach((l) => l());
|
|
34
43
|
},
|
|
35
|
-
isWarm: () => store.
|
|
36
|
-
describe(el: HTMLElement | null) {
|
|
37
|
-
if (store.described === el) return;
|
|
38
|
-
store.described?.removeAttribute('aria-describedby');
|
|
39
|
-
store.described = el;
|
|
40
|
-
el?.setAttribute('aria-describedby', TOOLTIP_DOM_ID);
|
|
41
|
-
},
|
|
44
|
+
isWarm: () => store.stack.length > 0 || performance.now() < store.warmUntil,
|
|
42
45
|
open(payload: ActivePayload) {
|
|
43
|
-
clearTimeout(store.
|
|
44
|
-
store.
|
|
45
|
-
store.
|
|
46
|
+
clearTimeout(store.timers.get(payload.id));
|
|
47
|
+
const at = store.stack.findIndex((entry) => entry.id === payload.id);
|
|
48
|
+
if (at < 0) store.stack.push(payload);
|
|
49
|
+
else store.stack[at] = payload;
|
|
46
50
|
store.emit();
|
|
47
51
|
},
|
|
48
52
|
close(id: string, grace = CLOSE_GRACE) {
|
|
49
|
-
clearTimeout(store.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
clearTimeout(store.timers.get(id));
|
|
54
|
+
const drop = () => {
|
|
55
|
+
store.timers.delete(id);
|
|
56
|
+
const at = store.stack.findIndex((entry) => entry.id === id);
|
|
57
|
+
if (at < 0) return;
|
|
58
|
+
store.stack.splice(at, 1);
|
|
59
|
+
if (!store.stack.length) store.warmUntil = performance.now() + WARM_WINDOW;
|
|
60
|
+
store.emit();
|
|
61
|
+
};
|
|
62
|
+
if (grace > 0) store.timers.set(id, setTimeout(drop, grace));
|
|
63
|
+
else drop();
|
|
53
64
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
store.describe(null);
|
|
57
|
-
if (!store.active) return;
|
|
58
|
-
store.warmUntil = performance.now() + WARM_WINDOW;
|
|
59
|
-
store.active = null;
|
|
60
|
-
store.emit();
|
|
65
|
+
dismiss() {
|
|
66
|
+
for (const entry of store.stack.slice()) entry.dismiss();
|
|
61
67
|
},
|
|
62
|
-
};
|
|
68
|
+
}));
|
|
63
69
|
|
|
64
|
-
const hostReg =
|
|
65
|
-
keys: [] as symbol[],
|
|
66
|
-
listeners: new Set<() => void>(),
|
|
67
|
-
subscribe(l: () => void) {
|
|
68
|
-
hostReg.listeners.add(l);
|
|
69
|
-
return () => hostReg.listeners.delete(l);
|
|
70
|
-
},
|
|
71
|
-
register(k: symbol) {
|
|
72
|
-
hostReg.keys.push(k);
|
|
73
|
-
hostReg.listeners.forEach((l) => l());
|
|
74
|
-
return () => {
|
|
75
|
-
const i = hostReg.keys.indexOf(k);
|
|
76
|
-
if (i >= 0) hostReg.keys.splice(i, 1);
|
|
77
|
-
hostReg.listeners.forEach((l) => l());
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
};
|
|
70
|
+
const hostReg = hostRegistry('tooltip.host@1');
|
|
81
71
|
|
|
82
72
|
export function useHostElection(): boolean {
|
|
83
|
-
|
|
84
|
-
if (!keyRef.current) keyRef.current = Symbol('tip-host');
|
|
85
|
-
useEffect(() => hostReg.register(keyRef.current!), []);
|
|
86
|
-
return useSyncExternalStore(
|
|
87
|
-
hostReg.subscribe,
|
|
88
|
-
() => hostReg.keys[0] === keyRef.current,
|
|
89
|
-
() => false,
|
|
90
|
-
);
|
|
73
|
+
return useElectedHost(hostReg, 'tip-host');
|
|
91
74
|
}
|