@blogmcp/mdx-render-vue 0.1.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.
Files changed (249) hide show
  1. package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
  2. package/dist/_virtual/constants.js +4 -0
  3. package/dist/_virtual/index.js +5 -0
  4. package/dist/_virtual/index2.js +4 -0
  5. package/dist/composables/index.d.ts +11 -0
  6. package/dist/composables/index.js +24 -0
  7. package/dist/composables/useAudioPlayer.d.ts +22 -0
  8. package/dist/composables/useAudioPlayer.js +58 -0
  9. package/dist/composables/useCallout.d.ts +43 -0
  10. package/dist/composables/useCallout.js +71 -0
  11. package/dist/composables/useCodeBlock.d.ts +23 -0
  12. package/dist/composables/useCodeBlock.js +67 -0
  13. package/dist/composables/useGallery.d.ts +37 -0
  14. package/dist/composables/useGallery.js +84 -0
  15. package/dist/composables/useMedia.d.ts +18 -0
  16. package/dist/composables/useMedia.js +9 -0
  17. package/dist/composables/useYouTube.d.ts +31 -0
  18. package/dist/composables/useYouTube.js +32 -0
  19. package/dist/edit/AlertEdit.vue.d.ts +12 -0
  20. package/dist/edit/AlertEdit.vue.js +4 -0
  21. package/dist/edit/AlertEdit.vue2.js +18 -0
  22. package/dist/edit/AudioPlayerEdit.vue.d.ts +3 -0
  23. package/dist/edit/AudioPlayerEdit.vue.js +117 -0
  24. package/dist/edit/AudioPlayerEdit.vue2.js +4 -0
  25. package/dist/edit/BadgeEdit.vue.d.ts +2 -0
  26. package/dist/edit/BadgeEdit.vue.js +4 -0
  27. package/dist/edit/BadgeEdit.vue2.js +13 -0
  28. package/dist/edit/ButtonEdit.vue.d.ts +2 -0
  29. package/dist/edit/ButtonEdit.vue.js +4 -0
  30. package/dist/edit/ButtonEdit.vue2.js +13 -0
  31. package/dist/edit/CalloutEdit.vue.d.ts +13 -0
  32. package/dist/edit/CalloutEdit.vue.js +85 -0
  33. package/dist/edit/CalloutEdit.vue2.js +4 -0
  34. package/dist/edit/CardEdit.vue.d.ts +12 -0
  35. package/dist/edit/CardEdit.vue.js +4 -0
  36. package/dist/edit/CardEdit.vue2.js +18 -0
  37. package/dist/edit/CodeBlockEdit.vue.d.ts +12 -0
  38. package/dist/edit/CodeBlockEdit.vue.js +7 -0
  39. package/dist/edit/CodeBlockEdit.vue2.js +89 -0
  40. package/dist/edit/GalleryEdit.vue.d.ts +3 -0
  41. package/dist/edit/GalleryEdit.vue.js +64 -0
  42. package/dist/edit/GalleryEdit.vue2.js +4 -0
  43. package/dist/edit/IconEdit.vue.d.ts +2 -0
  44. package/dist/edit/IconEdit.vue.js +4 -0
  45. package/dist/edit/IconEdit.vue2.js +13 -0
  46. package/dist/edit/TooltipEdit.vue.d.ts +16 -0
  47. package/dist/edit/TooltipEdit.vue.js +4 -0
  48. package/dist/edit/TooltipEdit.vue2.js +24 -0
  49. package/dist/edit/YouTubeEdit.vue.d.ts +3 -0
  50. package/dist/edit/YouTubeEdit.vue.js +41 -0
  51. package/dist/edit/YouTubeEdit.vue2.js +4 -0
  52. package/dist/edit/index.d.ts +29 -0
  53. package/dist/edit/index.js +35 -0
  54. package/dist/index.d.ts +12 -0
  55. package/dist/index.js +75 -0
  56. package/dist/mdx-render-vue.css +31 -0
  57. package/dist/node_modules/@ark-ui/vue/dist/_virtual/_rolldown/runtime.js +13 -0
  58. package/dist/node_modules/@ark-ui/vue/dist/components/factory.js +35 -0
  59. package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence-context.js +6 -0
  60. package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence.js +40 -0
  61. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.js +5 -0
  62. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.vue_vue_type_script_setup_true_lang.js +21 -0
  63. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.js +5 -0
  64. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.vue_vue_type_script_setup_true_lang.js +21 -0
  65. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.js +5 -0
  66. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.vue_vue_type_script_setup_true_lang.js +25 -0
  67. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.js +5 -0
  68. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.vue_vue_type_script_setup_true_lang.js +14 -0
  69. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.js +5 -0
  70. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.vue_vue_type_script_setup_true_lang.js +23 -0
  71. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.js +5 -0
  72. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.vue_vue_type_script_setup_true_lang.js +38 -0
  73. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.js +5 -0
  74. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.vue_vue_type_script_setup_true_lang.js +68 -0
  75. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.js +5 -0
  76. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.vue_vue_type_script_setup_true_lang.js +25 -0
  77. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip.js +22 -0
  78. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip-context.js +6 -0
  79. package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip.js +36 -0
  80. package/dist/node_modules/@ark-ui/vue/dist/providers/environment/use-environment-context.js +13 -0
  81. package/dist/node_modules/@ark-ui/vue/dist/providers/locale/use-locale-context.js +12 -0
  82. package/dist/node_modules/@ark-ui/vue/dist/utils/clean-props.js +8 -0
  83. package/dist/node_modules/@ark-ui/vue/dist/utils/create-context.js +14 -0
  84. package/dist/node_modules/@ark-ui/vue/dist/utils/dynamic.js +34 -0
  85. package/dist/node_modules/@ark-ui/vue/dist/utils/unref-element.js +8 -0
  86. package/dist/node_modules/@ark-ui/vue/dist/utils/use-forward-expose.js +46 -0
  87. package/dist/node_modules/@ark-ui/vue/dist/utils/use-render-strategy.js +5 -0
  88. package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +20 -0
  89. package/dist/node_modules/@braintree/sanitize-url/dist/index.js +75 -0
  90. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +728 -0
  91. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +629 -0
  92. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +176 -0
  93. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +151 -0
  94. package/dist/node_modules/@iconify/vue/dist/iconify.js +1691 -0
  95. package/dist/node_modules/@zag-js/anatomy/dist/create-anatomy.js +29 -0
  96. package/dist/node_modules/@zag-js/core/dist/create-machine.js +28 -0
  97. package/dist/node_modules/@zag-js/core/dist/merge-props.js +55 -0
  98. package/dist/node_modules/@zag-js/core/dist/scope.js +20 -0
  99. package/dist/node_modules/@zag-js/core/dist/state.js +176 -0
  100. package/dist/node_modules/@zag-js/core/dist/types.js +11 -0
  101. package/dist/node_modules/@zag-js/dom-query/dist/chunk-QZ7TP4HQ.js +6 -0
  102. package/dist/node_modules/@zag-js/dom-query/dist/computed-style.js +11 -0
  103. package/dist/node_modules/@zag-js/dom-query/dist/event.js +37 -0
  104. package/dist/node_modules/@zag-js/dom-query/dist/node.js +64 -0
  105. package/dist/node_modules/@zag-js/dom-query/dist/overflow.js +28 -0
  106. package/dist/node_modules/@zag-js/dom-query/dist/platform.js +23 -0
  107. package/dist/node_modules/@zag-js/dom-query/dist/query.js +6 -0
  108. package/dist/node_modules/@zag-js/dom-query/dist/raf.js +52 -0
  109. package/dist/node_modules/@zag-js/dom-query/dist/set.js +22 -0
  110. package/dist/node_modules/@zag-js/dom-query/dist/shared.js +8 -0
  111. package/dist/node_modules/@zag-js/focus-visible/dist/index.js +159 -0
  112. package/dist/node_modules/@zag-js/popper/dist/get-anchor.js +39 -0
  113. package/dist/node_modules/@zag-js/popper/dist/get-placement.js +296 -0
  114. package/dist/node_modules/@zag-js/popper/dist/get-styles.js +47 -0
  115. package/dist/node_modules/@zag-js/popper/dist/middleware.js +79 -0
  116. package/dist/node_modules/@zag-js/popper/dist/placement.js +7 -0
  117. package/dist/node_modules/@zag-js/presence/dist/presence.connect.js +18 -0
  118. package/dist/node_modules/@zag-js/presence/dist/presence.machine.js +175 -0
  119. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.anatomy.js +7 -0
  120. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.connect.js +155 -0
  121. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.dom.js +24 -0
  122. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.machine.js +416 -0
  123. package/dist/node_modules/@zag-js/tooltip/dist/tooltip.store.js +9 -0
  124. package/dist/node_modules/@zag-js/types/dist/prop-types.js +14 -0
  125. package/dist/node_modules/@zag-js/utils/dist/array.js +7 -0
  126. package/dist/node_modules/@zag-js/utils/dist/equal.js +36 -0
  127. package/dist/node_modules/@zag-js/utils/dist/functions.js +11 -0
  128. package/dist/node_modules/@zag-js/utils/dist/guard.js +26 -0
  129. package/dist/node_modules/@zag-js/utils/dist/object.js +16 -0
  130. package/dist/node_modules/@zag-js/utils/dist/store.js +44 -0
  131. package/dist/node_modules/@zag-js/utils/dist/warning.js +31 -0
  132. package/dist/node_modules/@zag-js/vue/dist/bindable.js +48 -0
  133. package/dist/node_modules/@zag-js/vue/dist/machine.js +258 -0
  134. package/dist/node_modules/@zag-js/vue/dist/normalize-props.js +42 -0
  135. package/dist/node_modules/@zag-js/vue/dist/refs.js +14 -0
  136. package/dist/node_modules/@zag-js/vue/dist/track.js +22 -0
  137. package/dist/node_modules/dompurify/dist/purify.es.js +1190 -0
  138. package/dist/registry.d.ts +76 -0
  139. package/dist/registry.js +164 -0
  140. package/dist/render/alert/Alert.vue.d.ts +18 -0
  141. package/dist/render/alert/Alert.vue.js +4 -0
  142. package/dist/render/alert/Alert.vue2.js +43 -0
  143. package/dist/render/alert/index.d.ts +2 -0
  144. package/dist/render/audioplayer/AudioPlayerDefault.vue.d.ts +3 -0
  145. package/dist/render/audioplayer/AudioPlayerDefault.vue.js +116 -0
  146. package/dist/render/audioplayer/AudioPlayerDefault.vue2.js +4 -0
  147. package/dist/render/audioplayer/index.d.ts +5 -0
  148. package/dist/render/audioplayer/index.js +5 -0
  149. package/dist/render/badge/Badge.vue.d.ts +10 -0
  150. package/dist/render/badge/Badge.vue.js +4 -0
  151. package/dist/render/badge/Badge.vue2.js +28 -0
  152. package/dist/render/badge/index.d.ts +2 -0
  153. package/dist/render/button/Button.vue.d.ts +13 -0
  154. package/dist/render/button/Button.vue.js +4 -0
  155. package/dist/render/button/Button.vue2.js +42 -0
  156. package/dist/render/button/index.d.ts +2 -0
  157. package/dist/render/callout/CalloutDefault.vue.d.ts +13 -0
  158. package/dist/render/callout/CalloutDefault.vue.js +86 -0
  159. package/dist/render/callout/CalloutDefault.vue2.js +4 -0
  160. package/dist/render/callout/CalloutMinimal.vue.d.ts +13 -0
  161. package/dist/render/callout/CalloutMinimal.vue.js +27 -0
  162. package/dist/render/callout/CalloutMinimal.vue2.js +4 -0
  163. package/dist/render/callout/index.d.ts +6 -0
  164. package/dist/render/callout/index.js +7 -0
  165. package/dist/render/card/Card.vue.d.ts +15 -0
  166. package/dist/render/card/Card.vue.js +4 -0
  167. package/dist/render/card/Card.vue2.js +29 -0
  168. package/dist/render/card/index.d.ts +2 -0
  169. package/dist/render/codeblock/CodeBlockDefault.vue.d.ts +12 -0
  170. package/dist/render/codeblock/CodeBlockDefault.vue.js +7 -0
  171. package/dist/render/codeblock/CodeBlockDefault.vue2.js +92 -0
  172. package/dist/render/codeblock/index.d.ts +5 -0
  173. package/dist/render/codeblock/index.js +5 -0
  174. package/dist/render/gallery/GalleryGrid.vue.d.ts +3 -0
  175. package/dist/render/gallery/GalleryGrid.vue.js +125 -0
  176. package/dist/render/gallery/GalleryGrid.vue2.js +4 -0
  177. package/dist/render/gallery/GalleryLightbox.vue.d.ts +16 -0
  178. package/dist/render/gallery/GalleryLightbox.vue.js +7 -0
  179. package/dist/render/gallery/GalleryLightbox.vue2.js +170 -0
  180. package/dist/render/gallery/index.d.ts +6 -0
  181. package/dist/render/gallery/index.js +7 -0
  182. package/dist/render/icon/Icon.vue.d.ts +9 -0
  183. package/dist/render/icon/Icon.vue.js +4 -0
  184. package/dist/render/icon/Icon.vue2.js +25 -0
  185. package/dist/render/icon/index.d.ts +2 -0
  186. package/dist/render/index.d.ts +40 -0
  187. package/dist/render/index.js +63 -0
  188. package/dist/render/tooltip/Tooltip.vue.d.ts +18 -0
  189. package/dist/render/tooltip/Tooltip.vue.js +4 -0
  190. package/dist/render/tooltip/Tooltip.vue2.js +58 -0
  191. package/dist/render/tooltip/index.d.ts +2 -0
  192. package/dist/render/youtube/YouTubeDefault.vue.d.ts +3 -0
  193. package/dist/render/youtube/YouTubeDefault.vue.js +79 -0
  194. package/dist/render/youtube/YouTubeDefault.vue2.js +4 -0
  195. package/dist/render/youtube/index.d.ts +5 -0
  196. package/dist/render/youtube/index.js +5 -0
  197. package/dist/useAudioPlayer.d.ts +22 -0
  198. package/dist/useCallout.d.ts +46 -0
  199. package/dist/useCodeBlock.d.ts +25 -0
  200. package/dist/useGallery.d.ts +44 -0
  201. package/dist/useMedia.d.ts +16 -0
  202. package/dist/useYouTube.d.ts +32 -0
  203. package/package.json +125 -0
  204. package/src/composables/index.ts +16 -0
  205. package/src/composables/useAudioPlayer.ts +84 -0
  206. package/src/composables/useCallout.ts +103 -0
  207. package/src/composables/useCodeBlock.ts +90 -0
  208. package/src/composables/useGallery.ts +143 -0
  209. package/src/composables/useMedia.ts +23 -0
  210. package/src/composables/useYouTube.ts +58 -0
  211. package/src/edit/AlertEdit.vue +9 -0
  212. package/src/edit/AudioPlayerEdit.vue +92 -0
  213. package/src/edit/BadgeEdit.vue +7 -0
  214. package/src/edit/ButtonEdit.vue +10 -0
  215. package/src/edit/CalloutEdit.vue +107 -0
  216. package/src/edit/CardEdit.vue +9 -0
  217. package/src/edit/CodeBlockEdit.vue +76 -0
  218. package/src/edit/GalleryEdit.vue +65 -0
  219. package/src/edit/IconEdit.vue +7 -0
  220. package/src/edit/TooltipEdit.vue +15 -0
  221. package/src/edit/YouTubeEdit.vue +33 -0
  222. package/src/edit/index.ts +32 -0
  223. package/src/index.ts +62 -0
  224. package/src/registry.ts +272 -0
  225. package/src/render/alert/Alert.vue +32 -0
  226. package/src/render/alert/index.ts +2 -0
  227. package/src/render/audioplayer/AudioPlayerDefault.vue +89 -0
  228. package/src/render/audioplayer/index.ts +8 -0
  229. package/src/render/badge/Badge.vue +25 -0
  230. package/src/render/badge/index.ts +2 -0
  231. package/src/render/button/Button.vue +41 -0
  232. package/src/render/button/index.ts +2 -0
  233. package/src/render/callout/CalloutDefault.vue +101 -0
  234. package/src/render/callout/CalloutMinimal.vue +31 -0
  235. package/src/render/callout/index.ts +9 -0
  236. package/src/render/card/Card.vue +15 -0
  237. package/src/render/card/index.ts +2 -0
  238. package/src/render/codeblock/CodeBlockDefault.vue +76 -0
  239. package/src/render/codeblock/index.ts +8 -0
  240. package/src/render/gallery/GalleryGrid.vue +162 -0
  241. package/src/render/gallery/GalleryLightbox.vue +162 -0
  242. package/src/render/gallery/index.ts +9 -0
  243. package/src/render/icon/Icon.vue +22 -0
  244. package/src/render/icon/index.ts +2 -0
  245. package/src/render/index.ts +76 -0
  246. package/src/render/tooltip/Tooltip.vue +35 -0
  247. package/src/render/tooltip/index.ts +2 -0
  248. package/src/render/youtube/YouTubeDefault.vue +72 -0
  249. package/src/render/youtube/index.ts +8 -0
@@ -0,0 +1,175 @@
1
+ import { createMachine } from "../../core/dist/create-machine.js";
2
+ import { setStyle } from "../../dom-query/dist/set.js";
3
+ import { nextTick, raf } from "../../dom-query/dist/raf.js";
4
+ import { getComputedStyle } from "../../dom-query/dist/computed-style.js";
5
+ import { getWindow } from "../../dom-query/dist/node.js";
6
+ import { getEventTarget } from "../../dom-query/dist/event.js";
7
+ var machine = createMachine({
8
+ props({ props }) {
9
+ return { ...props, present: !!props.present };
10
+ },
11
+ initialState({ prop }) {
12
+ return prop("present") ? "mounted" : "unmounted";
13
+ },
14
+ refs() {
15
+ return {
16
+ node: null,
17
+ styles: null
18
+ };
19
+ },
20
+ context({ bindable }) {
21
+ return {
22
+ unmountAnimationName: bindable(() => ({ defaultValue: null })),
23
+ prevAnimationName: bindable(() => ({ defaultValue: null })),
24
+ present: bindable(() => ({ defaultValue: false })),
25
+ initial: bindable(() => ({
26
+ sync: true,
27
+ defaultValue: false
28
+ }))
29
+ };
30
+ },
31
+ exit: ["cleanupNode"],
32
+ watch({ track, prop, send }) {
33
+ track([() => prop("present")], () => {
34
+ send({ type: "PRESENCE.CHANGED" });
35
+ });
36
+ },
37
+ on: {
38
+ "NODE.SET": {
39
+ actions: ["setupNode"]
40
+ },
41
+ "PRESENCE.CHANGED": {
42
+ actions: ["setInitial", "syncPresence"]
43
+ }
44
+ },
45
+ states: {
46
+ mounted: {
47
+ on: {
48
+ UNMOUNT: {
49
+ target: "unmounted",
50
+ actions: ["clearPrevAnimationName", "invokeOnExitComplete"]
51
+ },
52
+ "UNMOUNT.SUSPEND": {
53
+ target: "unmountSuspended"
54
+ }
55
+ }
56
+ },
57
+ unmountSuspended: {
58
+ effects: ["trackAnimationEvents"],
59
+ on: {
60
+ MOUNT: {
61
+ target: "mounted",
62
+ actions: ["setPrevAnimationName"]
63
+ },
64
+ UNMOUNT: {
65
+ target: "unmounted",
66
+ actions: ["clearPrevAnimationName", "invokeOnExitComplete"]
67
+ }
68
+ }
69
+ },
70
+ unmounted: {
71
+ on: {
72
+ MOUNT: {
73
+ target: "mounted",
74
+ actions: ["setPrevAnimationName"]
75
+ }
76
+ }
77
+ }
78
+ },
79
+ implementations: {
80
+ actions: {
81
+ setInitial: ({ context }) => {
82
+ if (context.get("initial")) return;
83
+ queueMicrotask(() => {
84
+ context.set("initial", true);
85
+ });
86
+ },
87
+ invokeOnExitComplete: ({ prop, refs }) => {
88
+ prop("onExitComplete")?.();
89
+ const node = refs.get("node");
90
+ if (!node) return;
91
+ const win = getWindow(node);
92
+ const event = new win.CustomEvent("exitcomplete", { bubbles: false });
93
+ node.dispatchEvent(event);
94
+ },
95
+ setupNode: ({ refs, event }) => {
96
+ if (refs.get("node") === event.node) return;
97
+ refs.set("node", event.node);
98
+ refs.set("styles", getComputedStyle(event.node));
99
+ },
100
+ cleanupNode: ({ refs }) => {
101
+ refs.set("node", null);
102
+ refs.set("styles", null);
103
+ },
104
+ syncPresence: ({ context, refs, send, prop }) => {
105
+ const presentProp = prop("present");
106
+ if (presentProp) {
107
+ return send({ type: "MOUNT", src: "presence.changed" });
108
+ }
109
+ const node = refs.get("node");
110
+ if (!presentProp && node?.ownerDocument.visibilityState === "hidden") {
111
+ return send({ type: "UNMOUNT", src: "visibilitychange" });
112
+ }
113
+ raf(() => {
114
+ if (prop("present")) return;
115
+ const animationName = getAnimationName(refs.get("styles"));
116
+ context.set("unmountAnimationName", animationName);
117
+ if (animationName === "none" || animationName === context.get("prevAnimationName") || refs.get("styles")?.display === "none" || refs.get("styles")?.animationDuration === "0s") {
118
+ send({ type: "UNMOUNT", src: "presence.changed" });
119
+ } else {
120
+ send({ type: "UNMOUNT.SUSPEND" });
121
+ }
122
+ });
123
+ },
124
+ setPrevAnimationName: ({ context, refs }) => {
125
+ raf(() => {
126
+ context.set("prevAnimationName", getAnimationName(refs.get("styles")));
127
+ });
128
+ },
129
+ clearPrevAnimationName: ({ context }) => {
130
+ context.set("prevAnimationName", null);
131
+ }
132
+ },
133
+ effects: {
134
+ trackAnimationEvents: ({ context, refs, send, prop }) => {
135
+ const node = refs.get("node");
136
+ if (!node) return;
137
+ const onStart = (event) => {
138
+ const target = event.composedPath?.()?.[0] ?? event.target;
139
+ if (target === node) {
140
+ context.set("prevAnimationName", getAnimationName(refs.get("styles")));
141
+ }
142
+ };
143
+ const onEnd = (event) => {
144
+ const animationName = getAnimationName(refs.get("styles"));
145
+ const target = getEventTarget(event);
146
+ if (target === node && animationName === context.get("unmountAnimationName") && !prop("present")) {
147
+ send({ type: "UNMOUNT", src: "animationend" });
148
+ }
149
+ };
150
+ const onCancel = (event) => {
151
+ const target = getEventTarget(event);
152
+ if (target === node && !prop("present")) {
153
+ send({ type: "UNMOUNT", src: "animationcancel" });
154
+ }
155
+ };
156
+ node.addEventListener("animationstart", onStart);
157
+ node.addEventListener("animationcancel", onCancel);
158
+ node.addEventListener("animationend", onEnd);
159
+ const cleanupStyles = setStyle(node, { animationFillMode: "forwards" });
160
+ return () => {
161
+ node.removeEventListener("animationstart", onStart);
162
+ node.removeEventListener("animationcancel", onCancel);
163
+ node.removeEventListener("animationend", onEnd);
164
+ nextTick(() => cleanupStyles());
165
+ };
166
+ }
167
+ }
168
+ }
169
+ });
170
+ function getAnimationName(styles) {
171
+ return styles?.animationName || "none";
172
+ }
173
+ export {
174
+ machine
175
+ };
@@ -0,0 +1,7 @@
1
+ import { createAnatomy } from "../../anatomy/dist/create-anatomy.js";
2
+ var anatomy = createAnatomy("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content");
3
+ var parts = anatomy.build();
4
+ export {
5
+ anatomy,
6
+ parts
7
+ };
@@ -0,0 +1,155 @@
1
+ import { isLeftClick } from "../../dom-query/dist/event.js";
2
+ import { dataAttr } from "../../dom-query/dist/shared.js";
3
+ import { isFocusVisible } from "../../focus-visible/dist/index.js";
4
+ import { getPlacementStyles } from "../../popper/dist/get-styles.js";
5
+ import { parts } from "./tooltip.anatomy.js";
6
+ import { getContentId, getPositionerId, getArrowId, getTriggerId } from "./tooltip.dom.js";
7
+ import { store } from "./tooltip.store.js";
8
+ function connect(service, normalize) {
9
+ const { state, context, send, scope, prop } = service;
10
+ const id = prop("id");
11
+ const hasAriaLabel = !!prop("aria-label");
12
+ const open = state.matches("open", "closing");
13
+ const triggerValue = context.get("triggerValue");
14
+ const contentId = getContentId(scope);
15
+ const disabled = prop("disabled");
16
+ const popperStyles = getPlacementStyles({
17
+ ...prop("positioning"),
18
+ placement: context.get("currentPlacement")
19
+ });
20
+ return {
21
+ open,
22
+ setOpen(nextOpen) {
23
+ const open2 = state.matches("open", "closing");
24
+ if (open2 === nextOpen) return;
25
+ send({ type: nextOpen ? "open" : "close" });
26
+ },
27
+ triggerValue,
28
+ setTriggerValue(value) {
29
+ send({ type: "triggerValue.set", value: value ?? void 0 });
30
+ },
31
+ reposition(options = {}) {
32
+ send({ type: "positioning.set", options });
33
+ },
34
+ getTriggerProps(props = {}) {
35
+ const { value } = props;
36
+ const current = value == null ? false : triggerValue === value;
37
+ const triggerId = getTriggerId(scope, value);
38
+ return normalize.button({
39
+ ...parts.trigger.attrs,
40
+ id: triggerId,
41
+ "data-ownedby": scope.id,
42
+ "data-value": value,
43
+ "data-current": dataAttr(current),
44
+ dir: prop("dir"),
45
+ "data-expanded": dataAttr(open),
46
+ "data-state": open ? "open" : "closed",
47
+ "aria-describedby": open ? contentId : void 0,
48
+ onClick(event) {
49
+ if (event.defaultPrevented) return;
50
+ if (disabled) return;
51
+ if (!prop("closeOnClick")) return;
52
+ const shouldSwitch = open && value != null && !current;
53
+ send({ type: shouldSwitch ? "triggerValue.set" : "close", src: "trigger.click", value, triggerId });
54
+ },
55
+ onFocus(event) {
56
+ if (event.defaultPrevented) return;
57
+ if (disabled) return;
58
+ if (!isFocusVisible()) return;
59
+ const shouldSwitch = open && value != null && !current;
60
+ send({ type: shouldSwitch ? "triggerValue.set" : "open", src: "trigger.focus", value, triggerId });
61
+ },
62
+ onBlur(event) {
63
+ if (event.defaultPrevented) return;
64
+ if (disabled) return;
65
+ if (id !== store.get("id")) return;
66
+ const activeEl = event.relatedTarget ?? scope.getDoc().activeElement;
67
+ const focusedAnotherTrigger = activeEl?.closest(`[data-ownedby="${scope.id}"]`) != null;
68
+ if (!focusedAnotherTrigger) {
69
+ send({ type: "close", src: "trigger.blur", value, triggerId });
70
+ }
71
+ },
72
+ onPointerDown(event) {
73
+ if (event.defaultPrevented) return;
74
+ if (disabled) return;
75
+ if (!isLeftClick(event)) return;
76
+ if (!prop("closeOnPointerDown")) return;
77
+ if (id === store.get("id")) {
78
+ send({ type: "close", src: "trigger.pointerdown", value, triggerId });
79
+ }
80
+ },
81
+ onPointerMove(event) {
82
+ if (event.defaultPrevented) return;
83
+ if (disabled) return;
84
+ if (event.pointerType === "touch") return;
85
+ const shouldSwitch = open && value != null && !current;
86
+ send({ type: shouldSwitch ? "triggerValue.set" : "pointer.move", value, triggerId });
87
+ },
88
+ onPointerOver(event) {
89
+ if (event.defaultPrevented) return;
90
+ if (disabled) return;
91
+ if (event.pointerType === "touch") return;
92
+ send({ type: "pointer.move", value, triggerId });
93
+ },
94
+ onPointerLeave() {
95
+ if (disabled) return;
96
+ send({ type: "pointer.leave" });
97
+ },
98
+ onPointerCancel() {
99
+ if (disabled) return;
100
+ send({ type: "pointer.leave" });
101
+ }
102
+ });
103
+ },
104
+ getArrowProps() {
105
+ return normalize.element({
106
+ id: getArrowId(scope),
107
+ ...parts.arrow.attrs,
108
+ dir: prop("dir"),
109
+ style: popperStyles.arrow
110
+ });
111
+ },
112
+ getArrowTipProps() {
113
+ return normalize.element({
114
+ ...parts.arrowTip.attrs,
115
+ dir: prop("dir"),
116
+ style: popperStyles.arrowTip
117
+ });
118
+ },
119
+ getPositionerProps() {
120
+ return normalize.element({
121
+ id: getPositionerId(scope),
122
+ ...parts.positioner.attrs,
123
+ dir: prop("dir"),
124
+ style: popperStyles.floating
125
+ });
126
+ },
127
+ getContentProps() {
128
+ const isCurrentTooltip = store.get("id") === id;
129
+ const isPrevTooltip = store.get("prevId") === id;
130
+ const instant = store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
131
+ return normalize.element({
132
+ ...parts.content.attrs,
133
+ dir: prop("dir"),
134
+ hidden: !open,
135
+ "data-state": open ? "open" : "closed",
136
+ "data-instant": dataAttr(instant),
137
+ role: hasAriaLabel ? void 0 : "tooltip",
138
+ id: hasAriaLabel ? void 0 : contentId,
139
+ "data-placement": context.get("currentPlacement"),
140
+ onPointerEnter() {
141
+ send({ type: "content.pointer.move" });
142
+ },
143
+ onPointerLeave() {
144
+ send({ type: "content.pointer.leave" });
145
+ },
146
+ style: {
147
+ pointerEvents: prop("interactive") ? "auto" : "none"
148
+ }
149
+ });
150
+ }
151
+ };
152
+ }
153
+ export {
154
+ connect
155
+ };
@@ -0,0 +1,24 @@
1
+ import { isFunction } from "../../utils/dist/guard.js";
2
+ import { queryAll } from "../../dom-query/dist/query.js";
3
+ var getTriggerId = (scope, value) => {
4
+ const customId = scope.ids?.trigger;
5
+ if (customId != null) return isFunction(customId) ? customId(value) : customId;
6
+ return value ? `tooltip:${scope.id}:trigger:${value}` : `tooltip:${scope.id}:trigger`;
7
+ };
8
+ var getContentId = (scope) => scope.ids?.content ?? `tooltip:${scope.id}:content`;
9
+ var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
10
+ var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
11
+ var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
12
+ var getTriggerEls = (scope) => queryAll(scope.getDoc(), `[data-scope="tooltip"][data-part="trigger"][data-ownedby="${scope.id}"]`);
13
+ var getActiveTriggerEl = (scope, value) => {
14
+ return value == null ? getTriggerEls(scope)[0] : scope.getById(getTriggerId(scope, value));
15
+ };
16
+ export {
17
+ getActiveTriggerEl,
18
+ getArrowId,
19
+ getContentId,
20
+ getPositionerEl,
21
+ getPositionerId,
22
+ getTriggerEls,
23
+ getTriggerId
24
+ };