@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,416 @@
|
|
|
1
|
+
import { trackFocusVisible } from "../../focus-visible/dist/index.js";
|
|
2
|
+
import { getPlacement } from "../../popper/dist/get-placement.js";
|
|
3
|
+
import { getActiveTriggerEl, getPositionerEl } from "./tooltip.dom.js";
|
|
4
|
+
import { store } from "./tooltip.store.js";
|
|
5
|
+
import { getOverflowAncestors } from "../../dom-query/dist/overflow.js";
|
|
6
|
+
import { createMachine, createGuards } from "../../core/dist/create-machine.js";
|
|
7
|
+
import { addDomEvent, isComposingEvent } from "../../dom-query/dist/event.js";
|
|
8
|
+
import { ensureProps } from "../../utils/dist/warning.js";
|
|
9
|
+
var { and, not } = createGuards();
|
|
10
|
+
var machine = createMachine({
|
|
11
|
+
initialState: ({ prop }) => {
|
|
12
|
+
const open = prop("open") || prop("defaultOpen");
|
|
13
|
+
return open ? "open" : "closed";
|
|
14
|
+
},
|
|
15
|
+
props({ props }) {
|
|
16
|
+
ensureProps(props, ["id"]);
|
|
17
|
+
const closeOnClick = props.closeOnClick ?? true;
|
|
18
|
+
const closeOnPointerDown = props.closeOnPointerDown ?? closeOnClick;
|
|
19
|
+
return {
|
|
20
|
+
openDelay: 400,
|
|
21
|
+
closeDelay: 150,
|
|
22
|
+
closeOnEscape: true,
|
|
23
|
+
interactive: false,
|
|
24
|
+
closeOnScroll: true,
|
|
25
|
+
disabled: false,
|
|
26
|
+
...props,
|
|
27
|
+
closeOnPointerDown,
|
|
28
|
+
closeOnClick,
|
|
29
|
+
positioning: {
|
|
30
|
+
placement: "bottom",
|
|
31
|
+
...props.positioning
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
effects: ["trackFocusVisible", "trackStore"],
|
|
36
|
+
context: ({ bindable, prop, scope }) => ({
|
|
37
|
+
currentPlacement: bindable(() => ({ defaultValue: void 0 })),
|
|
38
|
+
hasPointerMoveOpened: bindable(() => ({ defaultValue: null })),
|
|
39
|
+
triggerValue: bindable(() => ({
|
|
40
|
+
defaultValue: prop("defaultTriggerValue") ?? null,
|
|
41
|
+
value: prop("triggerValue"),
|
|
42
|
+
onChange(value) {
|
|
43
|
+
const onTriggerValueChange = prop("onTriggerValueChange");
|
|
44
|
+
if (!onTriggerValueChange) return;
|
|
45
|
+
const triggerElement = getActiveTriggerEl(scope, value);
|
|
46
|
+
onTriggerValueChange({ value, triggerElement });
|
|
47
|
+
}
|
|
48
|
+
}))
|
|
49
|
+
}),
|
|
50
|
+
watch({ track, action, prop }) {
|
|
51
|
+
track([() => prop("disabled")], () => {
|
|
52
|
+
action(["closeIfDisabled"]);
|
|
53
|
+
});
|
|
54
|
+
track([() => prop("open")], () => {
|
|
55
|
+
action(["toggleVisibility"]);
|
|
56
|
+
});
|
|
57
|
+
track([() => prop("triggerValue")], () => {
|
|
58
|
+
action(["repositionImmediate"]);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
on: {
|
|
62
|
+
"triggerValue.set": {
|
|
63
|
+
actions: ["setTriggerValue", "repositionImmediate"]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
states: {
|
|
67
|
+
closed: {
|
|
68
|
+
entry: ["clearGlobalId"],
|
|
69
|
+
on: {
|
|
70
|
+
"controlled.open": {
|
|
71
|
+
target: "open"
|
|
72
|
+
},
|
|
73
|
+
open: [
|
|
74
|
+
{
|
|
75
|
+
guard: "isOpenControlled",
|
|
76
|
+
actions: ["setTriggerValue", "invokeOnOpen"]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
target: "open",
|
|
80
|
+
actions: ["setTriggerValue", "invokeOnOpen"]
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"pointer.leave": {
|
|
84
|
+
actions: ["clearPointerMoveOpened"]
|
|
85
|
+
},
|
|
86
|
+
"pointer.move": [
|
|
87
|
+
{
|
|
88
|
+
guard: and("noVisibleTooltip", not("hasPointerMoveOpened")),
|
|
89
|
+
target: "opening",
|
|
90
|
+
actions: ["setTriggerValue"]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
guard: not("hasPointerMoveOpened"),
|
|
94
|
+
target: "open",
|
|
95
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen", "setTriggerValue"]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
opening: {
|
|
101
|
+
effects: ["trackScroll", "trackPointerlockChange", "waitForOpenDelay"],
|
|
102
|
+
on: {
|
|
103
|
+
"after.openDelay": [
|
|
104
|
+
{
|
|
105
|
+
guard: "isOpenControlled",
|
|
106
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
target: "open",
|
|
110
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"controlled.open": {
|
|
114
|
+
target: "open"
|
|
115
|
+
},
|
|
116
|
+
"controlled.close": {
|
|
117
|
+
target: "closed"
|
|
118
|
+
},
|
|
119
|
+
open: [
|
|
120
|
+
{
|
|
121
|
+
guard: "isOpenControlled",
|
|
122
|
+
actions: ["setTriggerValue", "invokeOnOpen"]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
target: "open",
|
|
126
|
+
actions: ["setTriggerValue", "invokeOnOpen"]
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
"pointer.leave": [
|
|
130
|
+
{
|
|
131
|
+
guard: "isOpenControlled",
|
|
132
|
+
// We trigger toggleVisibility manually since the `ctx.open` has not changed yet (at this point)
|
|
133
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose", "toggleVisibility"]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
target: "closed",
|
|
137
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
close: [
|
|
141
|
+
{
|
|
142
|
+
guard: "isOpenControlled",
|
|
143
|
+
// We trigger toggleVisibility manually since the `ctx.open` has not changed yet (at this point)
|
|
144
|
+
actions: ["invokeOnClose", "toggleVisibility"]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
target: "closed",
|
|
148
|
+
actions: ["invokeOnClose"]
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
open: {
|
|
154
|
+
effects: ["trackEscapeKey", "trackScroll", "trackPointerlockChange", "trackPositioning"],
|
|
155
|
+
entry: ["setGlobalId"],
|
|
156
|
+
on: {
|
|
157
|
+
"controlled.close": {
|
|
158
|
+
target: "closed"
|
|
159
|
+
},
|
|
160
|
+
close: [
|
|
161
|
+
{
|
|
162
|
+
guard: "isOpenControlled",
|
|
163
|
+
actions: ["invokeOnClose"]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
target: "closed",
|
|
167
|
+
actions: ["invokeOnClose"]
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"pointer.leave": [
|
|
171
|
+
{
|
|
172
|
+
guard: "isVisible",
|
|
173
|
+
target: "closing",
|
|
174
|
+
actions: ["clearPointerMoveOpened"]
|
|
175
|
+
},
|
|
176
|
+
// == group ==
|
|
177
|
+
{
|
|
178
|
+
guard: "isOpenControlled",
|
|
179
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
target: "closed",
|
|
183
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
"content.pointer.leave": {
|
|
187
|
+
guard: "isInteractive",
|
|
188
|
+
target: "closing"
|
|
189
|
+
},
|
|
190
|
+
"positioning.set": {
|
|
191
|
+
actions: ["reposition"]
|
|
192
|
+
},
|
|
193
|
+
"triggerValue.set": {
|
|
194
|
+
// Transition to closing (which cleans up trackPositioning) then immediately back to open
|
|
195
|
+
// This re-creates the positioning effect with the new trigger
|
|
196
|
+
target: "closing",
|
|
197
|
+
actions: ["setTriggerValue", "immediateReopen"]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
closing: {
|
|
202
|
+
effects: ["trackPositioning", "waitForCloseDelay"],
|
|
203
|
+
on: {
|
|
204
|
+
"after.closeDelay": [
|
|
205
|
+
{
|
|
206
|
+
guard: "isOpenControlled",
|
|
207
|
+
actions: ["invokeOnClose"]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
target: "closed",
|
|
211
|
+
actions: ["invokeOnClose"]
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"controlled.close": {
|
|
215
|
+
target: "closed"
|
|
216
|
+
},
|
|
217
|
+
"controlled.open": {
|
|
218
|
+
target: "open"
|
|
219
|
+
},
|
|
220
|
+
close: [
|
|
221
|
+
{
|
|
222
|
+
guard: "isOpenControlled",
|
|
223
|
+
actions: ["invokeOnClose"]
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
target: "closed",
|
|
227
|
+
actions: ["invokeOnClose"]
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"pointer.move": [
|
|
231
|
+
{
|
|
232
|
+
guard: "isOpenControlled",
|
|
233
|
+
// We trigger toggleVisibility manually since the `ctx.open` has not changed yet (at this point)
|
|
234
|
+
actions: ["setPointerMoveOpened", "setTriggerValue", "invokeOnOpen", "toggleVisibility"]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
target: "open",
|
|
238
|
+
actions: ["setPointerMoveOpened", "setTriggerValue", "invokeOnOpen"]
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"triggerValue.set": {
|
|
242
|
+
target: "open",
|
|
243
|
+
actions: ["setTriggerValue", "repositionImmediate"]
|
|
244
|
+
},
|
|
245
|
+
reopen: {
|
|
246
|
+
target: "open"
|
|
247
|
+
},
|
|
248
|
+
"content.pointer.move": {
|
|
249
|
+
guard: "isInteractive",
|
|
250
|
+
target: "open"
|
|
251
|
+
},
|
|
252
|
+
"positioning.set": {
|
|
253
|
+
actions: ["reposition"]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
implementations: {
|
|
259
|
+
guards: {
|
|
260
|
+
noVisibleTooltip: () => store.get("id") === null,
|
|
261
|
+
isVisible: ({ prop }) => prop("id") === store.get("id"),
|
|
262
|
+
isInteractive: ({ prop }) => !!prop("interactive"),
|
|
263
|
+
hasPointerMoveOpened: ({ context }) => !!context.get("hasPointerMoveOpened"),
|
|
264
|
+
isOpenControlled: ({ prop }) => prop("open") !== void 0
|
|
265
|
+
},
|
|
266
|
+
actions: {
|
|
267
|
+
setGlobalId: ({ prop }) => {
|
|
268
|
+
const prevId = store.get("id");
|
|
269
|
+
const isInstant = prevId !== null && prevId !== prop("id");
|
|
270
|
+
store.update({ id: prop("id"), prevId: isInstant ? prevId : null, instant: isInstant });
|
|
271
|
+
},
|
|
272
|
+
clearGlobalId: ({ prop }) => {
|
|
273
|
+
if (prop("id") === store.get("id")) {
|
|
274
|
+
store.update({ id: null, prevId: null, instant: false });
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
invokeOnOpen: ({ prop }) => {
|
|
278
|
+
prop("onOpenChange")?.({ open: true });
|
|
279
|
+
},
|
|
280
|
+
invokeOnClose: ({ prop }) => {
|
|
281
|
+
prop("onOpenChange")?.({ open: false });
|
|
282
|
+
},
|
|
283
|
+
closeIfDisabled: ({ prop, send }) => {
|
|
284
|
+
if (!prop("disabled")) return;
|
|
285
|
+
send({ type: "close", src: "disabled.change" });
|
|
286
|
+
},
|
|
287
|
+
reposition: ({ context, event, prop, scope }) => {
|
|
288
|
+
if (event.type !== "positioning.set") return;
|
|
289
|
+
const getPositionerEl2 = () => getPositionerEl(scope);
|
|
290
|
+
const getTriggerEl = () => getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
291
|
+
getPlacement(getTriggerEl, getPositionerEl2, {
|
|
292
|
+
...prop("positioning"),
|
|
293
|
+
...event.options,
|
|
294
|
+
listeners: false,
|
|
295
|
+
onComplete(data) {
|
|
296
|
+
context.set("currentPlacement", data.placement);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
repositionImmediate: ({ context, event, prop, scope }) => {
|
|
301
|
+
const triggerValue = event.value ?? context.get("triggerValue");
|
|
302
|
+
const getPositionerEl2 = () => getPositionerEl(scope);
|
|
303
|
+
const getTriggerEl = () => getActiveTriggerEl(scope, triggerValue);
|
|
304
|
+
return getPlacement(getTriggerEl, getPositionerEl2, {
|
|
305
|
+
...prop("positioning"),
|
|
306
|
+
onComplete(data) {
|
|
307
|
+
context.set("currentPlacement", data.placement);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
toggleVisibility: ({ prop, event, send }) => {
|
|
312
|
+
queueMicrotask(() => {
|
|
313
|
+
send({
|
|
314
|
+
type: prop("open") ? "controlled.open" : "controlled.close",
|
|
315
|
+
previousEvent: event
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
setPointerMoveOpened: ({ context, event }) => {
|
|
320
|
+
const triggerId = event.triggerId ?? event.previousEvent?.triggerId;
|
|
321
|
+
context.set("hasPointerMoveOpened", triggerId ?? null);
|
|
322
|
+
},
|
|
323
|
+
clearPointerMoveOpened: ({ context }) => {
|
|
324
|
+
context.set("hasPointerMoveOpened", null);
|
|
325
|
+
},
|
|
326
|
+
setTriggerValue: ({ context, event }) => {
|
|
327
|
+
if (event.value === void 0) return;
|
|
328
|
+
context.set("triggerValue", event.value);
|
|
329
|
+
},
|
|
330
|
+
immediateReopen: ({ send }) => {
|
|
331
|
+
queueMicrotask(() => {
|
|
332
|
+
send({ type: "reopen" });
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
effects: {
|
|
337
|
+
trackFocusVisible: ({ scope }) => {
|
|
338
|
+
return trackFocusVisible({ root: scope.getRootNode?.() });
|
|
339
|
+
},
|
|
340
|
+
trackPositioning: ({ context, prop, scope }) => {
|
|
341
|
+
if (!context.get("currentPlacement")) {
|
|
342
|
+
context.set("currentPlacement", prop("positioning").placement);
|
|
343
|
+
}
|
|
344
|
+
const getPositionerEl2 = () => getPositionerEl(scope);
|
|
345
|
+
const getTriggerEl = () => getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
346
|
+
return getPlacement(getTriggerEl, getPositionerEl2, {
|
|
347
|
+
...prop("positioning"),
|
|
348
|
+
defer: true,
|
|
349
|
+
onComplete(data) {
|
|
350
|
+
context.set("currentPlacement", data.placement);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
},
|
|
354
|
+
trackPointerlockChange: ({ send, scope }) => {
|
|
355
|
+
const doc = scope.getDoc();
|
|
356
|
+
const onChange = () => send({ type: "close", src: "pointerlock:change" });
|
|
357
|
+
return addDomEvent(doc, "pointerlockchange", onChange, false);
|
|
358
|
+
},
|
|
359
|
+
trackScroll: ({ send, prop, scope, context }) => {
|
|
360
|
+
if (!prop("closeOnScroll")) return;
|
|
361
|
+
const triggerValue = context.get("triggerValue");
|
|
362
|
+
const triggerEl = getActiveTriggerEl(scope, triggerValue);
|
|
363
|
+
if (!triggerEl) return;
|
|
364
|
+
const overflowParents = getOverflowAncestors(triggerEl);
|
|
365
|
+
const cleanups = overflowParents.map((overflowParent) => {
|
|
366
|
+
const onScroll = () => {
|
|
367
|
+
send({ type: "close", src: "scroll" });
|
|
368
|
+
};
|
|
369
|
+
return addDomEvent(overflowParent, "scroll", onScroll, {
|
|
370
|
+
passive: true,
|
|
371
|
+
capture: true
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
return () => {
|
|
375
|
+
cleanups.forEach((fn) => fn?.());
|
|
376
|
+
};
|
|
377
|
+
},
|
|
378
|
+
trackStore: ({ prop, send }) => {
|
|
379
|
+
let cleanup;
|
|
380
|
+
queueMicrotask(() => {
|
|
381
|
+
cleanup = store.subscribe(() => {
|
|
382
|
+
if (store.get("id") !== prop("id")) {
|
|
383
|
+
send({ type: "close", src: "id.change" });
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
return () => cleanup?.();
|
|
388
|
+
},
|
|
389
|
+
trackEscapeKey: ({ send, prop }) => {
|
|
390
|
+
if (!prop("closeOnEscape")) return;
|
|
391
|
+
const onKeyDown = (event) => {
|
|
392
|
+
if (isComposingEvent(event)) return;
|
|
393
|
+
if (event.key !== "Escape") return;
|
|
394
|
+
event.stopPropagation();
|
|
395
|
+
send({ type: "close", src: "keydown.escape" });
|
|
396
|
+
};
|
|
397
|
+
return addDomEvent(document, "keydown", onKeyDown, true);
|
|
398
|
+
},
|
|
399
|
+
waitForOpenDelay: ({ send, prop, event }) => {
|
|
400
|
+
const id = setTimeout(() => {
|
|
401
|
+
send({ type: "after.openDelay", previousEvent: event });
|
|
402
|
+
}, prop("openDelay"));
|
|
403
|
+
return () => clearTimeout(id);
|
|
404
|
+
},
|
|
405
|
+
waitForCloseDelay: ({ send, prop, event }) => {
|
|
406
|
+
const id = setTimeout(() => {
|
|
407
|
+
send({ type: "after.closeDelay", previousEvent: event });
|
|
408
|
+
}, prop("closeDelay"));
|
|
409
|
+
return () => clearTimeout(id);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
export {
|
|
415
|
+
machine
|
|
416
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var isArrayLike = (value) => value?.constructor.name === "Array";
|
|
2
|
+
var isArrayEqual = (a, b) => {
|
|
3
|
+
if (a.length !== b.length) return false;
|
|
4
|
+
for (let i = 0; i < a.length; i++) {
|
|
5
|
+
if (!isEqual(a[i], b[i])) return false;
|
|
6
|
+
}
|
|
7
|
+
return true;
|
|
8
|
+
};
|
|
9
|
+
var isEqual = (a, b) => {
|
|
10
|
+
if (Object.is(a, b)) return true;
|
|
11
|
+
if (a == null && b != null || a != null && b == null) return false;
|
|
12
|
+
if (typeof a?.isEqual === "function" && typeof b?.isEqual === "function") {
|
|
13
|
+
return a.isEqual(b);
|
|
14
|
+
}
|
|
15
|
+
if (typeof a === "function" && typeof b === "function") {
|
|
16
|
+
return a.toString() === b.toString();
|
|
17
|
+
}
|
|
18
|
+
if (isArrayLike(a) && isArrayLike(b)) {
|
|
19
|
+
return isArrayEqual(Array.from(a), Array.from(b));
|
|
20
|
+
}
|
|
21
|
+
if (!(typeof a === "object") || !(typeof b === "object")) return false;
|
|
22
|
+
const keys = Object.keys(b ?? /* @__PURE__ */ Object.create(null));
|
|
23
|
+
const length = keys.length;
|
|
24
|
+
for (let i = 0; i < length; i++) {
|
|
25
|
+
const hasKey = Reflect.has(a, keys[i]);
|
|
26
|
+
if (!hasKey) return false;
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < length; i++) {
|
|
29
|
+
const key = keys[i];
|
|
30
|
+
if (!isEqual(a[key], b[key])) return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
isEqual
|
|
36
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var isObjectLike = (v) => v != null && typeof v === "object";
|
|
2
|
+
var isString = (v) => typeof v === "string";
|
|
3
|
+
var isFunction = (v) => typeof v === "function";
|
|
4
|
+
var isNull = (v) => v == null;
|
|
5
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
6
|
+
var baseGetTag = (v) => Object.prototype.toString.call(v);
|
|
7
|
+
var fnToString = Function.prototype.toString;
|
|
8
|
+
var objectCtorString = fnToString.call(Object);
|
|
9
|
+
var isPlainObject = (v) => {
|
|
10
|
+
if (!isObjectLike(v) || baseGetTag(v) != "[object Object]" || isFrameworkElement(v)) return false;
|
|
11
|
+
const proto = Object.getPrototypeOf(v);
|
|
12
|
+
if (proto === null) return true;
|
|
13
|
+
const Ctor = hasProp(proto, "constructor") && proto.constructor;
|
|
14
|
+
return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
|
|
15
|
+
};
|
|
16
|
+
var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
|
|
17
|
+
var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
|
|
18
|
+
var isFrameworkElement = (x) => isReactElement(x) || isVueElement(x);
|
|
19
|
+
export {
|
|
20
|
+
hasProp,
|
|
21
|
+
isFunction,
|
|
22
|
+
isNull,
|
|
23
|
+
isObjectLike,
|
|
24
|
+
isPlainObject,
|
|
25
|
+
isString
|
|
26
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isPlainObject } from "./guard.js";
|
|
2
|
+
function compact(obj) {
|
|
3
|
+
if (!isPlainObject(obj) || obj === void 0) return obj;
|
|
4
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
5
|
+
const filtered = {};
|
|
6
|
+
for (const key of keys) {
|
|
7
|
+
const value = obj[key];
|
|
8
|
+
if (value !== void 0) {
|
|
9
|
+
filtered[key] = compact(value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return filtered;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
compact
|
|
16
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function createStore(initialState, compare = Object.is) {
|
|
2
|
+
let state = { ...initialState };
|
|
3
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4
|
+
const subscribe = (listener) => {
|
|
5
|
+
listeners.add(listener);
|
|
6
|
+
return () => listeners.delete(listener);
|
|
7
|
+
};
|
|
8
|
+
const publish = () => {
|
|
9
|
+
listeners.forEach((listener) => listener());
|
|
10
|
+
};
|
|
11
|
+
const get = (key) => {
|
|
12
|
+
return state[key];
|
|
13
|
+
};
|
|
14
|
+
const set = (key, value) => {
|
|
15
|
+
if (!compare(state[key], value)) {
|
|
16
|
+
state[key] = value;
|
|
17
|
+
publish();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const update = (updates) => {
|
|
21
|
+
let hasChanges = false;
|
|
22
|
+
for (const key in updates) {
|
|
23
|
+
const value = updates[key];
|
|
24
|
+
if (value !== void 0 && !compare(state[key], value)) {
|
|
25
|
+
state[key] = value;
|
|
26
|
+
hasChanges = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (hasChanges) {
|
|
30
|
+
publish();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const snapshot = () => ({ ...state });
|
|
34
|
+
return {
|
|
35
|
+
subscribe,
|
|
36
|
+
get,
|
|
37
|
+
set,
|
|
38
|
+
update,
|
|
39
|
+
snapshot
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
createStore
|
|
44
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function warn(...a) {
|
|
2
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
3
|
+
const c = a.length === 2 ? a[0] : true;
|
|
4
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
5
|
+
console.warn(m);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function invariant(...a) {
|
|
9
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
10
|
+
const c = a.length === 2 ? a[0] : true;
|
|
11
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
12
|
+
throw new Error(m);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function ensure(c, m) {
|
|
16
|
+
if (c == null) throw new Error(m());
|
|
17
|
+
}
|
|
18
|
+
function ensureProps(props, keys, scope) {
|
|
19
|
+
let missingKeys = [];
|
|
20
|
+
for (const key of keys) {
|
|
21
|
+
if (props[key] == null) missingKeys.push(key);
|
|
22
|
+
}
|
|
23
|
+
if (missingKeys.length > 0)
|
|
24
|
+
throw new Error(`[zag-js${""}] missing required props: ${missingKeys.join(", ")}`);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
ensure,
|
|
28
|
+
ensureProps,
|
|
29
|
+
invariant,
|
|
30
|
+
warn
|
|
31
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { shallowRef, computed, onUnmounted } from "vue";
|
|
2
|
+
import { isFunction } from "../../utils/dist/guard.js";
|
|
3
|
+
function bindable(props) {
|
|
4
|
+
const initial = props().defaultValue ?? props().value;
|
|
5
|
+
const eq = props().isEqual ?? Object.is;
|
|
6
|
+
const v = shallowRef(initial);
|
|
7
|
+
const controlled = computed(() => props().value !== void 0);
|
|
8
|
+
const valueRef = shallowRef(controlled.value ? props().value : v.value);
|
|
9
|
+
return {
|
|
10
|
+
initial,
|
|
11
|
+
ref: valueRef,
|
|
12
|
+
get() {
|
|
13
|
+
return controlled.value ? props().value : v.value;
|
|
14
|
+
},
|
|
15
|
+
set(val) {
|
|
16
|
+
const prev = controlled.value ? props().value : v.value;
|
|
17
|
+
const next = isFunction(val) ? val(prev) : val;
|
|
18
|
+
if (props().debug) {
|
|
19
|
+
console.log(`[bindable > ${props().debug}] setValue`, { next, prev });
|
|
20
|
+
}
|
|
21
|
+
if (!controlled.value) v.value = next;
|
|
22
|
+
if (!eq(next, prev)) {
|
|
23
|
+
props().onChange?.(next, prev);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
invoke(nextValue, prevValue) {
|
|
27
|
+
props().onChange?.(nextValue, prevValue);
|
|
28
|
+
},
|
|
29
|
+
hash(value) {
|
|
30
|
+
return props().hash?.(value) ?? String(value);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
bindable.cleanup = (fn) => {
|
|
35
|
+
onUnmounted(() => fn());
|
|
36
|
+
};
|
|
37
|
+
bindable.ref = (defaultValue) => {
|
|
38
|
+
let value = defaultValue;
|
|
39
|
+
return {
|
|
40
|
+
get: () => value,
|
|
41
|
+
set: (next) => {
|
|
42
|
+
value = next;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
bindable
|
|
48
|
+
};
|