@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.
- package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/_virtual/constants.js +4 -0
- package/dist/_virtual/index.js +5 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/composables/index.d.ts +11 -0
- package/dist/composables/index.js +24 -0
- package/dist/composables/useAudioPlayer.d.ts +22 -0
- package/dist/composables/useAudioPlayer.js +58 -0
- package/dist/composables/useCallout.d.ts +43 -0
- package/dist/composables/useCallout.js +71 -0
- package/dist/composables/useCodeBlock.d.ts +23 -0
- package/dist/composables/useCodeBlock.js +67 -0
- package/dist/composables/useGallery.d.ts +37 -0
- package/dist/composables/useGallery.js +84 -0
- package/dist/composables/useMedia.d.ts +18 -0
- package/dist/composables/useMedia.js +9 -0
- package/dist/composables/useYouTube.d.ts +31 -0
- package/dist/composables/useYouTube.js +32 -0
- package/dist/edit/AlertEdit.vue.d.ts +12 -0
- package/dist/edit/AlertEdit.vue.js +4 -0
- package/dist/edit/AlertEdit.vue2.js +18 -0
- package/dist/edit/AudioPlayerEdit.vue.d.ts +3 -0
- package/dist/edit/AudioPlayerEdit.vue.js +117 -0
- package/dist/edit/AudioPlayerEdit.vue2.js +4 -0
- package/dist/edit/BadgeEdit.vue.d.ts +2 -0
- package/dist/edit/BadgeEdit.vue.js +4 -0
- package/dist/edit/BadgeEdit.vue2.js +13 -0
- package/dist/edit/ButtonEdit.vue.d.ts +2 -0
- package/dist/edit/ButtonEdit.vue.js +4 -0
- package/dist/edit/ButtonEdit.vue2.js +13 -0
- package/dist/edit/CalloutEdit.vue.d.ts +13 -0
- package/dist/edit/CalloutEdit.vue.js +85 -0
- package/dist/edit/CalloutEdit.vue2.js +4 -0
- package/dist/edit/CardEdit.vue.d.ts +12 -0
- package/dist/edit/CardEdit.vue.js +4 -0
- package/dist/edit/CardEdit.vue2.js +18 -0
- package/dist/edit/CodeBlockEdit.vue.d.ts +12 -0
- package/dist/edit/CodeBlockEdit.vue.js +7 -0
- package/dist/edit/CodeBlockEdit.vue2.js +89 -0
- package/dist/edit/GalleryEdit.vue.d.ts +3 -0
- package/dist/edit/GalleryEdit.vue.js +64 -0
- package/dist/edit/GalleryEdit.vue2.js +4 -0
- package/dist/edit/IconEdit.vue.d.ts +2 -0
- package/dist/edit/IconEdit.vue.js +4 -0
- package/dist/edit/IconEdit.vue2.js +13 -0
- package/dist/edit/TooltipEdit.vue.d.ts +16 -0
- package/dist/edit/TooltipEdit.vue.js +4 -0
- package/dist/edit/TooltipEdit.vue2.js +24 -0
- package/dist/edit/YouTubeEdit.vue.d.ts +3 -0
- package/dist/edit/YouTubeEdit.vue.js +41 -0
- package/dist/edit/YouTubeEdit.vue2.js +4 -0
- package/dist/edit/index.d.ts +29 -0
- package/dist/edit/index.js +35 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +75 -0
- package/dist/mdx-render-vue.css +31 -0
- package/dist/node_modules/@ark-ui/vue/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/factory.js +35 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence-context.js +6 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/presence/use-presence.js +40 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow-tip.vue_vue_type_script_setup_true_lang.js +21 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-arrow.vue_vue_type_script_setup_true_lang.js +21 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-content.vue_vue_type_script_setup_true_lang.js +25 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-context.vue_vue_type_script_setup_true_lang.js +14 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-positioner.vue_vue_type_script_setup_true_lang.js +23 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root-provider.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-root.vue_vue_type_script_setup_true_lang.js +68 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.js +5 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip-trigger.vue_vue_type_script_setup_true_lang.js +25 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/tooltip.js +22 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip-context.js +6 -0
- package/dist/node_modules/@ark-ui/vue/dist/components/tooltip/use-tooltip.js +36 -0
- package/dist/node_modules/@ark-ui/vue/dist/providers/environment/use-environment-context.js +13 -0
- package/dist/node_modules/@ark-ui/vue/dist/providers/locale/use-locale-context.js +12 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/clean-props.js +8 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/create-context.js +14 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/dynamic.js +34 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/unref-element.js +8 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/use-forward-expose.js +46 -0
- package/dist/node_modules/@ark-ui/vue/dist/utils/use-render-strategy.js +5 -0
- package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +20 -0
- package/dist/node_modules/@braintree/sanitize-url/dist/index.js +75 -0
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +728 -0
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +629 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +176 -0
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +151 -0
- package/dist/node_modules/@iconify/vue/dist/iconify.js +1691 -0
- package/dist/node_modules/@zag-js/anatomy/dist/create-anatomy.js +29 -0
- package/dist/node_modules/@zag-js/core/dist/create-machine.js +28 -0
- package/dist/node_modules/@zag-js/core/dist/merge-props.js +55 -0
- package/dist/node_modules/@zag-js/core/dist/scope.js +20 -0
- package/dist/node_modules/@zag-js/core/dist/state.js +176 -0
- package/dist/node_modules/@zag-js/core/dist/types.js +11 -0
- package/dist/node_modules/@zag-js/dom-query/dist/chunk-QZ7TP4HQ.js +6 -0
- package/dist/node_modules/@zag-js/dom-query/dist/computed-style.js +11 -0
- package/dist/node_modules/@zag-js/dom-query/dist/event.js +37 -0
- package/dist/node_modules/@zag-js/dom-query/dist/node.js +64 -0
- package/dist/node_modules/@zag-js/dom-query/dist/overflow.js +28 -0
- package/dist/node_modules/@zag-js/dom-query/dist/platform.js +23 -0
- package/dist/node_modules/@zag-js/dom-query/dist/query.js +6 -0
- package/dist/node_modules/@zag-js/dom-query/dist/raf.js +52 -0
- package/dist/node_modules/@zag-js/dom-query/dist/set.js +22 -0
- package/dist/node_modules/@zag-js/dom-query/dist/shared.js +8 -0
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +159 -0
- package/dist/node_modules/@zag-js/popper/dist/get-anchor.js +39 -0
- package/dist/node_modules/@zag-js/popper/dist/get-placement.js +296 -0
- package/dist/node_modules/@zag-js/popper/dist/get-styles.js +47 -0
- package/dist/node_modules/@zag-js/popper/dist/middleware.js +79 -0
- package/dist/node_modules/@zag-js/popper/dist/placement.js +7 -0
- package/dist/node_modules/@zag-js/presence/dist/presence.connect.js +18 -0
- package/dist/node_modules/@zag-js/presence/dist/presence.machine.js +175 -0
- package/dist/node_modules/@zag-js/tooltip/dist/tooltip.anatomy.js +7 -0
- package/dist/node_modules/@zag-js/tooltip/dist/tooltip.connect.js +155 -0
- package/dist/node_modules/@zag-js/tooltip/dist/tooltip.dom.js +24 -0
- package/dist/node_modules/@zag-js/tooltip/dist/tooltip.machine.js +416 -0
- package/dist/node_modules/@zag-js/tooltip/dist/tooltip.store.js +9 -0
- package/dist/node_modules/@zag-js/types/dist/prop-types.js +14 -0
- package/dist/node_modules/@zag-js/utils/dist/array.js +7 -0
- package/dist/node_modules/@zag-js/utils/dist/equal.js +36 -0
- package/dist/node_modules/@zag-js/utils/dist/functions.js +11 -0
- package/dist/node_modules/@zag-js/utils/dist/guard.js +26 -0
- package/dist/node_modules/@zag-js/utils/dist/object.js +16 -0
- package/dist/node_modules/@zag-js/utils/dist/store.js +44 -0
- package/dist/node_modules/@zag-js/utils/dist/warning.js +31 -0
- package/dist/node_modules/@zag-js/vue/dist/bindable.js +48 -0
- package/dist/node_modules/@zag-js/vue/dist/machine.js +258 -0
- package/dist/node_modules/@zag-js/vue/dist/normalize-props.js +42 -0
- package/dist/node_modules/@zag-js/vue/dist/refs.js +14 -0
- package/dist/node_modules/@zag-js/vue/dist/track.js +22 -0
- package/dist/node_modules/dompurify/dist/purify.es.js +1190 -0
- package/dist/registry.d.ts +76 -0
- package/dist/registry.js +164 -0
- package/dist/render/alert/Alert.vue.d.ts +18 -0
- package/dist/render/alert/Alert.vue.js +4 -0
- package/dist/render/alert/Alert.vue2.js +43 -0
- package/dist/render/alert/index.d.ts +2 -0
- package/dist/render/audioplayer/AudioPlayerDefault.vue.d.ts +3 -0
- package/dist/render/audioplayer/AudioPlayerDefault.vue.js +116 -0
- package/dist/render/audioplayer/AudioPlayerDefault.vue2.js +4 -0
- package/dist/render/audioplayer/index.d.ts +5 -0
- package/dist/render/audioplayer/index.js +5 -0
- package/dist/render/badge/Badge.vue.d.ts +10 -0
- package/dist/render/badge/Badge.vue.js +4 -0
- package/dist/render/badge/Badge.vue2.js +28 -0
- package/dist/render/badge/index.d.ts +2 -0
- package/dist/render/button/Button.vue.d.ts +13 -0
- package/dist/render/button/Button.vue.js +4 -0
- package/dist/render/button/Button.vue2.js +42 -0
- package/dist/render/button/index.d.ts +2 -0
- package/dist/render/callout/CalloutDefault.vue.d.ts +13 -0
- package/dist/render/callout/CalloutDefault.vue.js +86 -0
- package/dist/render/callout/CalloutDefault.vue2.js +4 -0
- package/dist/render/callout/CalloutMinimal.vue.d.ts +13 -0
- package/dist/render/callout/CalloutMinimal.vue.js +27 -0
- package/dist/render/callout/CalloutMinimal.vue2.js +4 -0
- package/dist/render/callout/index.d.ts +6 -0
- package/dist/render/callout/index.js +7 -0
- package/dist/render/card/Card.vue.d.ts +15 -0
- package/dist/render/card/Card.vue.js +4 -0
- package/dist/render/card/Card.vue2.js +29 -0
- package/dist/render/card/index.d.ts +2 -0
- package/dist/render/codeblock/CodeBlockDefault.vue.d.ts +12 -0
- package/dist/render/codeblock/CodeBlockDefault.vue.js +7 -0
- package/dist/render/codeblock/CodeBlockDefault.vue2.js +92 -0
- package/dist/render/codeblock/index.d.ts +5 -0
- package/dist/render/codeblock/index.js +5 -0
- package/dist/render/gallery/GalleryGrid.vue.d.ts +3 -0
- package/dist/render/gallery/GalleryGrid.vue.js +125 -0
- package/dist/render/gallery/GalleryGrid.vue2.js +4 -0
- package/dist/render/gallery/GalleryLightbox.vue.d.ts +16 -0
- package/dist/render/gallery/GalleryLightbox.vue.js +7 -0
- package/dist/render/gallery/GalleryLightbox.vue2.js +170 -0
- package/dist/render/gallery/index.d.ts +6 -0
- package/dist/render/gallery/index.js +7 -0
- package/dist/render/icon/Icon.vue.d.ts +9 -0
- package/dist/render/icon/Icon.vue.js +4 -0
- package/dist/render/icon/Icon.vue2.js +25 -0
- package/dist/render/icon/index.d.ts +2 -0
- package/dist/render/index.d.ts +40 -0
- package/dist/render/index.js +63 -0
- package/dist/render/tooltip/Tooltip.vue.d.ts +18 -0
- package/dist/render/tooltip/Tooltip.vue.js +4 -0
- package/dist/render/tooltip/Tooltip.vue2.js +58 -0
- package/dist/render/tooltip/index.d.ts +2 -0
- package/dist/render/youtube/YouTubeDefault.vue.d.ts +3 -0
- package/dist/render/youtube/YouTubeDefault.vue.js +79 -0
- package/dist/render/youtube/YouTubeDefault.vue2.js +4 -0
- package/dist/render/youtube/index.d.ts +5 -0
- package/dist/render/youtube/index.js +5 -0
- package/dist/useAudioPlayer.d.ts +22 -0
- package/dist/useCallout.d.ts +46 -0
- package/dist/useCodeBlock.d.ts +25 -0
- package/dist/useGallery.d.ts +44 -0
- package/dist/useMedia.d.ts +16 -0
- package/dist/useYouTube.d.ts +32 -0
- package/package.json +125 -0
- package/src/composables/index.ts +16 -0
- package/src/composables/useAudioPlayer.ts +84 -0
- package/src/composables/useCallout.ts +103 -0
- package/src/composables/useCodeBlock.ts +90 -0
- package/src/composables/useGallery.ts +143 -0
- package/src/composables/useMedia.ts +23 -0
- package/src/composables/useYouTube.ts +58 -0
- package/src/edit/AlertEdit.vue +9 -0
- package/src/edit/AudioPlayerEdit.vue +92 -0
- package/src/edit/BadgeEdit.vue +7 -0
- package/src/edit/ButtonEdit.vue +10 -0
- package/src/edit/CalloutEdit.vue +107 -0
- package/src/edit/CardEdit.vue +9 -0
- package/src/edit/CodeBlockEdit.vue +76 -0
- package/src/edit/GalleryEdit.vue +65 -0
- package/src/edit/IconEdit.vue +7 -0
- package/src/edit/TooltipEdit.vue +15 -0
- package/src/edit/YouTubeEdit.vue +33 -0
- package/src/edit/index.ts +32 -0
- package/src/index.ts +62 -0
- package/src/registry.ts +272 -0
- package/src/render/alert/Alert.vue +32 -0
- package/src/render/alert/index.ts +2 -0
- package/src/render/audioplayer/AudioPlayerDefault.vue +89 -0
- package/src/render/audioplayer/index.ts +8 -0
- package/src/render/badge/Badge.vue +25 -0
- package/src/render/badge/index.ts +2 -0
- package/src/render/button/Button.vue +41 -0
- package/src/render/button/index.ts +2 -0
- package/src/render/callout/CalloutDefault.vue +101 -0
- package/src/render/callout/CalloutMinimal.vue +31 -0
- package/src/render/callout/index.ts +9 -0
- package/src/render/card/Card.vue +15 -0
- package/src/render/card/index.ts +2 -0
- package/src/render/codeblock/CodeBlockDefault.vue +76 -0
- package/src/render/codeblock/index.ts +8 -0
- package/src/render/gallery/GalleryGrid.vue +162 -0
- package/src/render/gallery/GalleryLightbox.vue +162 -0
- package/src/render/gallery/index.ts +9 -0
- package/src/render/icon/Icon.vue +22 -0
- package/src/render/icon/index.ts +2 -0
- package/src/render/index.ts +76 -0
- package/src/render/tooltip/Tooltip.vue +35 -0
- package/src/render/tooltip/index.ts +2 -0
- package/src/render/youtube/YouTubeDefault.vue +72 -0
- 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,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
|
+
};
|