@wow-two-beta/fe 0.0.48 → 0.0.49

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.
@@ -1,14 +1,11 @@
1
- import { defineComponent, useSlots, shallowRef, watch, onBeforeUnmount, computed, ref, openBlock, createElementBlock, Fragment, createBlock, resolveDynamicComponent, unref, withCtx, createVNode, createElementVNode, normalizeClass, renderSlot, createTextVNode, toDisplayString, createCommentVNode, cloneVNode } from "vue";
1
+ import { defineComponent, useSlots, shallowRef, watch, onBeforeUnmount, computed, openBlock, createElementBlock, Fragment, createBlock, resolveDynamicComponent, unref, withCtx, createVNode, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode, cloneVNode } from "vue";
2
2
  import { AriaAttribute } from "../../../foundation/dom/enums/AriaAttribute.js";
3
3
  import { resolveElement } from "../../../foundation/dom/ResolveElement.js";
4
- import { cn } from "../../../foundation/styles/Cn.js";
5
4
  import { useControlled } from "../../../foundation/state/hooks/UseControlled.js";
6
5
  import { useEscape } from "../../../foundation/shortcuts/hooks/UseEscape.js";
7
6
  import { useId } from "../../../foundation/identifiers/UseId.js";
8
- import { useReducedMotion } from "../../../foundation/device/hooks/UseReducedMotion.js";
9
7
  import _sfc_main$1 from "../../../foundation/primitives/portal/Portal.vue.js";
10
8
  import _sfc_main$2 from "../../../foundation/primitives/anchoredPositioner/AnchoredPositioner.vue.js";
11
- import { Presence } from "../../../foundation/primitives/presence/Presence.js";
12
9
  import { renderableChildren } from "../../../foundation/primitives/slot/Slot.js";
13
10
  const _hoisted_1 = ["id"];
14
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -39,51 +36,55 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
39
36
  const tooltipId = useId("tooltip");
40
37
  let openTimer = null;
41
38
  let closeTimer = null;
42
- function clear() {
43
- if (openTimer) clearTimeout(openTimer);
44
- if (closeTimer) clearTimeout(closeTimer);
39
+ const trigger = { pointer: false, focus: false };
40
+ function cancelOpen() {
41
+ if (openTimer !== null) clearTimeout(openTimer);
45
42
  openTimer = null;
43
+ }
44
+ function cancelClose() {
45
+ if (closeTimer !== null) clearTimeout(closeTimer);
46
46
  closeTimer = null;
47
47
  }
48
- function show() {
49
- clear();
50
- if (props.isDisabled) return;
51
- openTimer = setTimeout(() => {
52
- if (!props.isDisabled) setOpen(true);
53
- }, props.openDelay);
48
+ function clearTimers() {
49
+ cancelOpen();
50
+ cancelClose();
54
51
  }
55
- function hide() {
56
- clear();
57
- closeTimer = setTimeout(() => setOpen(false), props.closeDelay);
52
+ function updateTrigger(channel, active) {
53
+ if (props.isDisabled) return;
54
+ trigger[channel] = active;
55
+ if (trigger.pointer || trigger.focus) {
56
+ cancelClose();
57
+ if (open.value || openTimer !== null) return;
58
+ openTimer = setTimeout(() => {
59
+ openTimer = null;
60
+ if (!props.isDisabled) setOpen(true);
61
+ }, props.openDelay);
62
+ return;
63
+ }
64
+ cancelOpen();
65
+ if (!open.value || closeTimer !== null) return;
66
+ closeTimer = setTimeout(() => {
67
+ closeTimer = null;
68
+ setOpen(false);
69
+ }, props.closeDelay);
58
70
  }
59
71
  watch(
60
72
  () => props.isDisabled,
61
73
  (disabled) => {
62
74
  if (!disabled) return;
63
- clear();
75
+ clearTimers();
76
+ trigger.pointer = false;
77
+ trigger.focus = false;
64
78
  setOpen(false);
65
79
  }
66
80
  );
67
- onBeforeUnmount(clear);
81
+ onBeforeUnmount(clearTimers);
68
82
  useEscape(() => {
69
- clear();
83
+ clearTimers();
70
84
  setOpen(false);
71
85
  }, open);
72
- const reducedMotion = useReducedMotion();
73
86
  const hasContent = computed(() => !!props.content || !!slots.content);
74
87
  const visible = computed(() => !props.isDisabled && open.value && hasContent.value);
75
- const mounted = ref(false);
76
- watch(
77
- [visible, reducedMotion],
78
- ([isVisible, isReduced]) => {
79
- if (isVisible) mounted.value = true;
80
- else if (isReduced) mounted.value = false;
81
- },
82
- { immediate: true }
83
- );
84
- function onAnimationEnd() {
85
- if (!visible.value) mounted.value = false;
86
- }
87
88
  function setAnchor(value) {
88
89
  anchor.value = resolveElement(value);
89
90
  }
@@ -96,46 +97,35 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
96
97
  {
97
98
  ref: setAnchor,
98
99
  [AriaAttribute.DescribedBy]: visible.value ? [own, tooltipId].filter(Boolean).join(" ") : own,
99
- onPointerenter: show,
100
- onPointerleave: hide,
101
- onFocus: show,
102
- onBlur: hide
100
+ onPointerenter: () => updateTrigger("pointer", true),
101
+ onPointerleave: () => updateTrigger("pointer", false),
102
+ onFocus: () => updateTrigger("focus", true),
103
+ onBlur: () => updateTrigger("focus", false)
103
104
  },
104
105
  true
105
106
  );
106
107
  }
107
- const contentClasses = cn(
108
- "rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md",
109
- "motion-safe:data-[state=open]:animate-(--animate-pop-in)",
110
- "motion-safe:data-[state=closed]:animate-(--animate-pop-out)"
111
- );
112
108
  return (_ctx, _cache) => {
113
109
  return openBlock(), createElementBlock(Fragment, null, [
114
110
  (openBlock(), createBlock(resolveDynamicComponent(renderTrigger()))),
115
- mounted.value ? (openBlock(), createBlock(unref(_sfc_main$1), { key: 0 }, {
111
+ visible.value ? (openBlock(), createBlock(unref(_sfc_main$1), { key: 0 }, {
116
112
  default: withCtx(() => [
117
113
  createVNode(unref(_sfc_main$2), {
118
114
  anchor: anchor.value,
119
115
  placement: props.placement,
120
116
  offset: 6,
121
- class: "z-tooltip",
122
- onAnimationend: onAnimationEnd
117
+ class: "z-tooltip"
123
118
  }, {
124
119
  default: withCtx(() => [
125
- createVNode(unref(Presence), { "is-present": visible.value }, {
126
- default: withCtx(() => [
127
- createElementVNode("div", {
128
- id: unref(tooltipId),
129
- role: "tooltip",
130
- class: normalizeClass(unref(contentClasses))
131
- }, [
132
- renderSlot(_ctx.$slots, "content", {}, () => [
133
- createTextVNode(toDisplayString(props.content), 1)
134
- ])
135
- ], 10, _hoisted_1)
136
- ]),
137
- _: 3
138
- }, 8, ["is-present"])
120
+ createElementVNode("div", {
121
+ id: unref(tooltipId),
122
+ role: "tooltip",
123
+ class: "rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md"
124
+ }, [
125
+ renderSlot(_ctx.$slots, "content", {}, () => [
126
+ createTextVNode(toDisplayString(props.content), 1)
127
+ ])
128
+ ], 8, _hoisted_1)
139
129
  ]),
140
130
  _: 3
141
131
  }, 8, ["anchor", "placement"])
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.vue.js","sources":["../../../../src/presentation/overlays/tooltip/Tooltip.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { Placement } from '@floating-ui/vue';\n\nexport interface TooltipProps {\n /** The tooltip body. Rich content goes through the `content` slot. */\n readonly content?: string | number;\n\n /** The Floating UI placement. Default `top`. */\n readonly placement?: Placement;\n\n /** The delay before opening on hover, in ms. Default 700. */\n readonly openDelay?: number;\n\n /** The delay before closing on leave, in ms. Default 0. */\n readonly closeDelay?: number;\n\n /** Controlled axes use their canonical Vue model names; each update event requests caller state. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The disabled mode — suppresses rendering even on hover (e.g. when content is empty). */\n readonly isDisabled?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n cloneVNode,\n computed,\n createCommentVNode,\n onBeforeUnmount,\n ref,\n shallowRef,\n useSlots,\n watch,\n type VNode,\n} from 'vue';\nimport { AriaAttribute, resolveElement } from '../../../foundation/dom';\nimport { cn } from '../../../foundation/styles';\nimport { useControlled } from '../../../foundation/state';\nimport { useEscape } from '../../../foundation/shortcuts';\nimport { useId } from '../../../foundation/identifiers';\nimport { useReducedMotion } from '../../../foundation/device';\nimport { AnchoredPositioner, Portal, Presence, renderableChildren } from '../../../foundation/primitives';\n\n/**\n * Renders a hover- or focus-triggered tooltip into a Portal, positioned by Floating UI.\n *\n * Wraps a single default-slot child as the trigger. Default delays mirror the OS pattern (700ms in, 0 out). Escape\n * dismisses without moving focus (WCAG 1.4.13); the trigger is described by the tooltip via `aria-describedby` while\n * open.\n *\n * `inheritAttrs: false` because the component renders a fragment (trigger + portal) — there is no single root for\n * attrs to land on, exactly as in React.\n */\ndefineOptions({ name: 'Tooltip', inheritAttrs: false });\n\ndefineSlots<{\n /** The single child element — the trigger. Receives the handlers, the ref, and `aria-describedby`. */\n default(): unknown;\n /** The rich override for the `content` prop. */\n content?(): unknown;\n}>();\n\nconst props = withDefaults(defineProps<TooltipProps>(), {\n content: undefined,\n placement: 'top',\n openDelay: 700,\n closeDelay: 0,\n open: undefined,\n defaultOpen: false,\n isDisabled: undefined,\n});\n\nconst emit = defineEmits<{\n /** Fires when the tooltip shows or hides — the `v-model:open` half. */\n 'update:open': [open: boolean];\n}>();\n\nconst slots = useSlots();\n\n/* `useControlled` returns a handle, not React's tuple, and takes `controlled` as a getter so the\n controlled branch tracks the prop. */\nconst { value: open, setValue: setOpen } = useControlled<boolean>({\n controlled: () => props.open,\n default: props.defaultOpen,\n onChange: (next) => {\n emit('update:open', next);\n },\n});\n\nconst anchor = shallowRef<HTMLElement | null>(null);\nconst tooltipId = useId('tooltip');\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\n\nfunction clear(): void {\n if (openTimer) clearTimeout(openTimer);\n if (closeTimer) clearTimeout(closeTimer);\n openTimer = null;\n closeTimer = null;\n}\n\nfunction show(): void {\n clear();\n if (props.isDisabled) return;\n openTimer = setTimeout(() => {\n if (!props.isDisabled) setOpen(true);\n }, props.openDelay);\n}\n\nfunction hide(): void {\n clear();\n closeTimer = setTimeout(() => setOpen(false), props.closeDelay);\n}\n\nwatch(\n () => props.isDisabled,\n (disabled) => {\n if (!disabled) return;\n clear();\n setOpen(false);\n },\n);\n\n/* Clear pending timers on unmount. */\nonBeforeUnmount(clear);\n\n/* WCAG 1.4.13 — Escape dismisses immediately, without moving focus. */\nuseEscape(() => {\n clear();\n setOpen(false);\n}, open);\n\nconst reducedMotion = useReducedMotion();\n\n/**\n * React gated on `!!content`; a Vue consumer can supply the body through the `content` slot\n * instead, so either source counts. An empty tooltip still never opens.\n */\nconst hasContent = computed(() => !!props.content || !!slots.content);\n\nconst visible = computed(() => !props.isDisabled && open.value && hasContent.value);\n\n/* Keep the Portal + positioner mounted while the exit animation plays.\n Becomes true with `visible`; cleared on the body's pop-out `animationend`\n (see `onAnimationEnd` below). With reduced motion no exit animation runs,\n so tear the shell down immediately on close. */\nconst mounted = ref(false);\nwatch(\n [visible, reducedMotion],\n ([isVisible, isReduced]) => {\n if (isVisible) mounted.value = true;\n else if (isReduced) mounted.value = false;\n },\n { immediate: true },\n);\n\nfunction onAnimationEnd(): void {\n if (!visible.value) mounted.value = false;\n}\n\n/** A function ref may receive a component's public instance; the positioner needs the DOM node. */\nfunction setAnchor(value: unknown): void {\n anchor.value = resolveElement(value);\n}\n\n/**\n * React cloned the child element to attach the ref, the handlers and `aria-describedby`.\n * `cloneVNode` is the Vue counterpart and merges through `mergeProps`, so a handler the\n * consumer already put on the trigger is chained rather than replaced — the job React's\n * explicit `trigger.props.onPointerEnter?.(e)` forwarding did.\n *\n * Called from the template, never from a `computed`: a vnode `ref` records the instance rendering\n * at creation as its owner. The scheduler refreshes a dirty computed before the render runs, while\n * no instance renders, and production Vue then throws reading the missing owner's `refs`.\n *\n * The listener keys are all-lowercase after `on` (`onPointerenter`, not `onPointerEnter`):\n * Vue hyphenates the remainder to derive the DOM event name, so the React casing would\n * register `pointer-enter` and never fire.\n */\nfunction renderTrigger(): VNode {\n const child = renderableChildren(slots.default?.())[0];\n if (!child) return createCommentVNode('');\n const own = child.props?.[AriaAttribute.DescribedBy] as string | undefined;\n return cloneVNode(\n child,\n {\n ref: setAnchor,\n [AriaAttribute.DescribedBy]: visible.value ? [own, tooltipId].filter(Boolean).join(' ') : own,\n onPointerenter: show,\n onPointerleave: hide,\n onFocus: show,\n onBlur: hide,\n },\n true,\n );\n}\n\nconst contentClasses = cn(\n 'rounded-md bg-inverse px-2.5 py-1.5 text-xs text-inverse-foreground shadow-md',\n 'motion-safe:data-[state=open]:animate-(--animate-pop-in)',\n 'motion-safe:data-[state=closed]:animate-(--animate-pop-out)',\n);\n</script>\n\n<template>\n <component :is=\"renderTrigger()\" />\n <Portal v-if=\"mounted\">\n <!-- Exit animation bubbles up from the body; once the closed-state pop-out ends, tear down\n the Portal shell. Also covers the reduced-motion path, where no animation runs and\n `Presence` has already unmounted the body.\n z-tooltip (100) sits on this positioned root, as Popover and Menu put their layer on theirs: its\n transform makes the stacking context, so a z-index on the body inside never lifts it above a sticky\n bar (z-sticky, 30) or a modal (z-modal, 70). -->\n <AnchoredPositioner\n :anchor=\"anchor\"\n :placement=\"props.placement\"\n :offset=\"6\"\n class=\"z-tooltip\"\n @animationend=\"onAnimationEnd\"\n >\n <!-- `Presence` clones `data-state` (\"open\" | \"closed\") + its tracking ref onto the body,\n which is what gates the pop-in / pop-out keyframes. Motion sits behind `motion-safe:`\n so reduced-motion users get an instant show/hide. -->\n <Presence :is-present=\"visible\">\n <div :id=\"tooltipId\" role=\"tooltip\" :class=\"contentClasses\">\n <slot name=\"content\">{{ props.content }}</slot>\n </div>\n </Presence>\n </AnchoredPositioner>\n </Portal>\n</template>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_unref","Portal","_createVNode","AnchoredPositioner","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,UAAM,QAAQ;AAUd,UAAM,OAAO;AAKb,UAAM,QAAQ,SAAA;AAId,UAAM,EAAE,OAAO,MAAM,UAAU,QAAA,IAAY,cAAuB;AAAA,MAChE,YAAY,MAAM,MAAM;AAAA,MACxB,SAAS,MAAM;AAAA,MACf,UAAU,CAAC,SAAS;AAClB,aAAK,eAAe,IAAI;AAAA,MAC1B;AAAA,IAAA,CACD;AAED,UAAM,SAAS,WAA+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],"sourcesContent":["<script lang=\"ts\">\nimport type { Placement } from '@floating-ui/vue';\n\nexport interface TooltipProps {\n /** The tooltip body. Rich content goes through the `content` slot. */\n readonly content?: string | number;\n\n /** The Floating UI placement. Default `top`. */\n readonly placement?: Placement;\n\n /** The delay before opening on hover, in ms. Default 700. */\n readonly openDelay?: number;\n\n /** The delay before closing on leave, in ms. Default 0. */\n readonly closeDelay?: number;\n\n /** Controlled axes use their canonical Vue model names; each update event requests caller state. */\n readonly open?: boolean;\n\n /** The initial open state when uncontrolled. Default `false`. */\n readonly defaultOpen?: boolean;\n\n /** The disabled mode — suppresses rendering even on hover (e.g. when content is empty). */\n readonly isDisabled?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n cloneVNode,\n computed,\n createCommentVNode,\n onBeforeUnmount,\n shallowRef,\n useSlots,\n watch,\n type VNode,\n} from 'vue';\nimport { AriaAttribute, resolveElement } from '../../../foundation/dom';\nimport { useControlled } from '../../../foundation/state';\nimport { useEscape } from '../../../foundation/shortcuts';\nimport { useId } from '../../../foundation/identifiers';\nimport { AnchoredPositioner, Portal, renderableChildren } from '../../../foundation/primitives';\n\n/**\n * Renders a hover- or focus-triggered tooltip into a Portal, positioned by Floating UI.\n *\n * Wraps a single default-slot child as the trigger. Default delays mirror the OS pattern (700ms in, 0 out). Escape\n * dismisses without moving focus (WCAG 1.4.13); the trigger is described by the tooltip via `aria-describedby` while\n * open.\n *\n * `inheritAttrs: false` because the component renders a fragment (trigger + portal) — there is no single root for\n * attrs to land on, exactly as in React.\n */\ndefineOptions({ name: 'Tooltip', inheritAttrs: false });\n\ndefineSlots<{\n /** The single child element — the trigger. Receives the handlers, the ref, and `aria-describedby`. */\n default(): unknown;\n /** The rich override for the `content` prop. */\n content?(): unknown;\n}>();\n\nconst props = withDefaults(defineProps<TooltipProps>(), {\n content: undefined,\n placement: 'top',\n openDelay: 700,\n closeDelay: 0,\n open: undefined,\n defaultOpen: false,\n isDisabled: undefined,\n});\n\nconst emit = defineEmits<{\n /** Fires when the tooltip shows or hides — the `v-model:open` half. */\n 'update:open': [open: boolean];\n}>();\n\nconst slots = useSlots();\n\n/* `useControlled` returns a handle, not React's tuple, and takes `controlled` as a getter so the\n controlled branch tracks the prop. */\nconst { value: open, setValue: setOpen } = useControlled<boolean>({\n controlled: () => props.open,\n default: props.defaultOpen,\n onChange: (next) => {\n emit('update:open', next);\n },\n});\n\nconst anchor = shallowRef<HTMLElement | null>(null);\nconst tooltipId = useId('tooltip');\n\nlet openTimer: ReturnType<typeof setTimeout> | null = null;\nlet closeTimer: ReturnType<typeof setTimeout> | null = null;\nconst trigger = { pointer: false, focus: false };\n\nfunction cancelOpen(): void {\n if (openTimer !== null) clearTimeout(openTimer);\n openTimer = null;\n}\n\nfunction cancelClose(): void {\n if (closeTimer !== null) clearTimeout(closeTimer);\n closeTimer = null;\n}\n\nfunction clearTimers(): void {\n cancelOpen();\n cancelClose();\n}\n\nfunction updateTrigger(channel: keyof typeof trigger, active: boolean): void {\n if (props.isDisabled) return;\n trigger[channel] = active;\n if (trigger.pointer || trigger.focus) {\n cancelClose();\n if (open.value || openTimer !== null) return;\n openTimer = setTimeout(() => {\n openTimer = null;\n if (!props.isDisabled) setOpen(true);\n }, props.openDelay);\n return;\n }\n\n cancelOpen();\n if (!open.value || closeTimer !== null) return;\n closeTimer = setTimeout(() => {\n closeTimer = null;\n setOpen(false);\n }, props.closeDelay);\n}\n\nwatch(\n () => props.isDisabled,\n (disabled) => {\n if (!disabled) return;\n clearTimers();\n trigger.pointer = false;\n trigger.focus = false;\n setOpen(false);\n },\n);\n\n/* Clear pending timers on unmount. */\nonBeforeUnmount(clearTimers);\n\n/* WCAG 1.4.13 — Escape dismisses immediately, without moving focus. */\nuseEscape(() => {\n clearTimers();\n setOpen(false);\n}, open);\n\n/**\n * React gated on `!!content`; a Vue consumer can supply the body through the `content` slot\n * instead, so either source counts. An empty tooltip still never opens.\n */\nconst hasContent = computed(() => !!props.content || !!slots.content);\n\nconst visible = computed(() => !props.isDisabled && open.value && hasContent.value);\n\n/** A function ref may receive a component's public instance; the positioner needs the DOM node. */\nfunction setAnchor(value: unknown): void {\n anchor.value = resolveElement(value);\n}\n\n/**\n * React cloned the child element to attach the ref, the handlers and `aria-describedby`.\n * `cloneVNode` is the Vue counterpart and merges through `mergeProps`, so a handler the\n * consumer already put on the trigger is chained rather than replaced — the job React's\n * explicit `trigger.props.onPointerEnter?.(e)` forwarding did.\n *\n * Called from the template, never from a `computed`: a vnode `ref` records the instance rendering\n * at creation as its owner. The scheduler refreshes a dirty computed before the render runs, while\n * no instance renders, and production Vue then throws reading the missing owner's `refs`.\n *\n * The listener keys are all-lowercase after `on` (`onPointerenter`, not `onPointerEnter`):\n * Vue hyphenates the remainder to derive the DOM event name, so the React casing would\n * register `pointer-enter` and never fire.\n */\nfunction renderTrigger(): VNode {\n const child = renderableChildren(slots.default?.())[0];\n if (!child) return createCommentVNode('');\n const own = child.props?.[AriaAttribute.DescribedBy] as string | undefined;\n return cloneVNode(\n child,\n {\n ref: setAnchor,\n [AriaAttribute.DescribedBy]: visible.value ? [own, tooltipId].filter(Boolean).join(' ') : own,\n onPointerenter: () => updateTrigger('pointer', true),\n onPointerleave: () => updateTrigger('pointer', false),\n onFocus: () => updateTrigger('focus', true),\n onBlur: () => updateTrigger('focus', false),\n },\n true,\n );\n}\n</script>\n\n<template>\n <component :is=\"renderTrigger()\" />\n <Portal v-if=\"visible\">\n <!-- Put the layer on the positioned root because its transform creates a stacking context. -->\n <AnchoredPositioner :anchor=\"anchor\" :placement=\"props.placement\" :offset=\"6\" class=\"z-tooltip\">\n <div\n :id=\"tooltipId\"\n role=\"tooltip\"\n class=\"rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md\"\n >\n <slot name=\"content\">{{ props.content }}</slot>\n </div>\n </AnchoredPositioner>\n </Portal>\n</template>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","_unref","Portal","_createVNode","AnchoredPositioner","_createEl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AAA;+BAClF,MAMM;AAAA,gBANNC,mBAMM,OAAA;AAAA,kBALH,IAAIJ,MAAA,SAAA;AAAA,kBACL,MAAK;AAAA,kBACL,OAAM;AAAA,gBAAA;kBAENK,WAA+C,4BAA/C,MAA+C;AAAA,oBAAvBC,gBAAAC,gBAAA,MAAM,OAAO,GAAA,CAAA;AAAA,kBAAA;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wow-two-beta/fe",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "description": "Beta-forever Vue 3 fe sdk for the wow-two ecosystem — components, application adapters and browser capabilities.",
5
5
  "license": "MIT",
6
6
  "repository": {