@lumx/vue 4.9.0-alpha.1 → 4.9.0-alpha.2
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,11 +1,11 @@
|
|
|
1
|
-
import { inject as
|
|
1
|
+
import { inject as i, computed as m, unref as P, defineComponent as c, provide as l, ref as y, watch as b, onBeforeUnmount as p, createVNode as C, Teleport as R, isVNode as x, onMounted as L } from "vue";
|
|
2
2
|
import { Theme as T } from "@lumx/core/js/constants";
|
|
3
3
|
function S(e = { defaultTheme: T.light }) {
|
|
4
|
-
const { defaultTheme: n } = e, o =
|
|
4
|
+
const { defaultTheme: n } = e, o = i("theme", void 0);
|
|
5
5
|
return m(() => P(o) || n);
|
|
6
6
|
}
|
|
7
7
|
const g = c(
|
|
8
|
-
(e, { slots: n }) => (
|
|
8
|
+
(e, { slots: n }) => (l(
|
|
9
9
|
"theme",
|
|
10
10
|
m(() => e.value)
|
|
11
11
|
), () => n.default?.()),
|
|
@@ -15,9 +15,9 @@ const g = c(
|
|
|
15
15
|
}
|
|
16
16
|
), v = /* @__PURE__ */ Symbol("LumxPortal"), A = () => ({
|
|
17
17
|
container: "body"
|
|
18
|
-
}),
|
|
18
|
+
}), N = /* @__PURE__ */ c((e, {
|
|
19
19
|
slots: n
|
|
20
|
-
}) => (
|
|
20
|
+
}) => (l(v, e.value), () => n.default?.()), {
|
|
21
21
|
name: "LumxPortalProvider",
|
|
22
22
|
props: {
|
|
23
23
|
value: {
|
|
@@ -29,20 +29,20 @@ const g = c(
|
|
|
29
29
|
function w(e) {
|
|
30
30
|
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !x(e);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const O = /* @__PURE__ */ c((e, {
|
|
33
33
|
slots: n
|
|
34
34
|
}) => {
|
|
35
|
-
const o =
|
|
35
|
+
const o = i(v, A), t = y(null), u = () => {
|
|
36
36
|
e.enabled ? t.value = o() : t.value = null;
|
|
37
37
|
};
|
|
38
38
|
return u(), b(() => e.enabled, u), p(() => {
|
|
39
39
|
t.value?.teardown?.();
|
|
40
40
|
}), () => {
|
|
41
|
-
const
|
|
42
|
-
return !e.enabled || !
|
|
43
|
-
to:
|
|
44
|
-
}, w(
|
|
45
|
-
default: () => [
|
|
41
|
+
const a = n.default?.(), r = t.value?.container;
|
|
42
|
+
return !e.enabled || !r ? a : C(R, {
|
|
43
|
+
to: r
|
|
44
|
+
}, w(a) ? a : {
|
|
45
|
+
default: () => [a]
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
}, {
|
|
@@ -55,39 +55,39 @@ const Y = /* @__PURE__ */ c((e, {
|
|
|
55
55
|
}
|
|
56
56
|
}), s = ["mousedown", "touchstart"];
|
|
57
57
|
function E(e, n) {
|
|
58
|
-
return !n.some((o) => e.some((t) => o
|
|
58
|
+
return !n.some((o) => o instanceof Node && e.some((t) => o.contains(t)));
|
|
59
59
|
}
|
|
60
60
|
function j(e, n) {
|
|
61
61
|
if (!n)
|
|
62
62
|
return;
|
|
63
63
|
const o = (t) => {
|
|
64
|
-
const u = [t.composedPath?.()[0], t.target]
|
|
65
|
-
E(u,
|
|
64
|
+
const u = [t.composedPath?.()[0], t.target].filter((r) => r instanceof Node), a = e();
|
|
65
|
+
E(u, a) && n(t);
|
|
66
66
|
};
|
|
67
67
|
return s.forEach((t) => document.addEventListener(t, o)), () => {
|
|
68
68
|
s.forEach((t) => document.removeEventListener(t, o));
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
const f = /* @__PURE__ */ Symbol("LumxClickAway"),
|
|
71
|
+
const f = /* @__PURE__ */ Symbol("LumxClickAway"), Y = /* @__PURE__ */ c((e, {
|
|
72
72
|
slots: n
|
|
73
73
|
}) => {
|
|
74
|
-
const o =
|
|
74
|
+
const o = i(f, null), t = [], u = {
|
|
75
75
|
childrenRefs: t,
|
|
76
|
-
addRefs(...
|
|
77
|
-
for (const h of
|
|
76
|
+
addRefs(...r) {
|
|
77
|
+
for (const h of r) {
|
|
78
78
|
const d = h.value;
|
|
79
79
|
d && t.push(d);
|
|
80
80
|
}
|
|
81
|
-
o && (o.addRefs(...
|
|
81
|
+
o && (o.addRefs(...r), e.parentRef && o.addRefs(e.parentRef));
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
let
|
|
84
|
+
l(f, u);
|
|
85
|
+
let a;
|
|
86
86
|
return L(() => {
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const r = e.childrenRefs.value;
|
|
88
|
+
r && u.addRefs(...r), a = j(() => t, e.callback);
|
|
89
89
|
}), p(() => {
|
|
90
|
-
|
|
90
|
+
a?.();
|
|
91
91
|
}), () => n.default?.();
|
|
92
92
|
}, {
|
|
93
93
|
name: "LumxClickAwayProvider",
|
|
@@ -107,11 +107,11 @@ const f = /* @__PURE__ */ Symbol("LumxClickAway"), I = /* @__PURE__ */ c((e, {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
Y as C,
|
|
111
|
+
O as P,
|
|
112
112
|
g as T,
|
|
113
|
-
|
|
113
|
+
N as a,
|
|
114
114
|
j as s,
|
|
115
115
|
S as u
|
|
116
116
|
};
|
|
117
|
-
//# sourceMappingURL=
|
|
117
|
+
//# sourceMappingURL=BrPeaE_u.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DCsEMm-b.js","sources":["../../src/utils/theme/useTheme.ts","../../src/utils/theme/ThemeProvider.ts","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx","../../../lumx-core/src/js/utils/ClickAway/index.ts","../../src/utils/ClickAway/ClickAwayProvider.tsx"],"sourcesContent":["import { type ComputedRef, type Ref, computed, inject, unref } from 'vue';\n\nimport { Theme } from '@lumx/core/js/constants';\n\nexport interface UseTheme {\n defaultTheme?: Theme;\n}\n/**\n * Retrieves the globally applied theme.\n * @returns computed theme value (auto-updates when the provided theme changes)\n */\nexport function useTheme(options: UseTheme = { defaultTheme: Theme.light }): ComputedRef<Theme | undefined> {\n const { defaultTheme } = options;\n const injected = inject<Theme | Ref<Theme | undefined> | undefined>('theme', undefined);\n return computed(() => unref(injected) || defaultTheme);\n}\n","import { computed, defineComponent, provide, type PropType } from 'vue';\nimport type { Theme } from '@lumx/core/js/constants';\n\n/**\n * ThemeProvider for Vue: wraps children with `provide('theme', value)` for theme isolation.\n * Vue's `provide()` requires a component boundary, so this is a component.\n */\nexport const ThemeProvider = defineComponent(\n (props: { value: Theme | undefined }, { slots }) => {\n provide(\n 'theme',\n computed(() => props.value),\n );\n return () => slots.default?.();\n },\n {\n name: 'LumxThemeProvider',\n props: { value: { type: String as PropType<Theme | undefined>, default: undefined } },\n },\n);\n","import { defineComponent, provide, type PropType, type InjectionKey } from 'vue';\n\nexport type { PortalInit, PortalProviderProps } from '@lumx/core/js/utils/Portal';\nimport type { PortalInit, PortalProviderProps } from '@lumx/core/js/utils/Portal';\n\nexport const PORTAL_KEY: InjectionKey<PortalInit> = Symbol('LumxPortal');\n\nexport const defaultPortalInit: PortalInit = () => ({ container: 'body' });\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider = defineComponent(\n (props: PortalProviderProps, { slots }) => {\n provide(PORTAL_KEY, props.value);\n return () => slots.default?.();\n },\n {\n name: 'LumxPortalProvider',\n props: {\n value: {\n type: Function as PropType<PortalInit>,\n required: true,\n },\n },\n },\n);\n","import { defineComponent, inject, onBeforeUnmount, Teleport, ref, watch } from 'vue';\nimport { PORTAL_KEY, defaultPortalInit } from './PortalProvider';\n\nexport type { PortalProps } from '@lumx/core/js/utils/Portal';\nimport type { PortalProps } from '@lumx/core/js/utils/Portal';\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalProvider)\n */\nexport const Portal = defineComponent(\n (props: PortalProps, { slots }) => {\n const portalInit = inject(PORTAL_KEY, defaultPortalInit);\n const context = ref<ReturnType<typeof portalInit> | null>(null);\n\n // Initialize portal context when enabled\n const initializePortal = () => {\n if (props.enabled) {\n context.value = portalInit();\n } else {\n context.value = null;\n }\n };\n\n // Initialize on mount and when enabled changes\n initializePortal();\n watch(() => props.enabled, initializePortal);\n\n // Register teardown on unmount\n onBeforeUnmount(() => {\n context.value?.teardown?.();\n });\n\n return () => {\n const content = slots.default?.();\n const container = context.value?.container;\n\n // If disabled or no container, render inline\n if (!props.enabled || !container) {\n return content;\n }\n\n // Render in portal using Teleport\n return <Teleport to={container}>{content}</Teleport>;\n };\n },\n {\n name: 'LumxPortal',\n props: {\n enabled: {\n type: Boolean,\n default: true,\n },\n },\n },\n);\n","/**\n * Shared types and logic for ClickAway detection.\n *\n * ClickAway detects clicks outside a set of elements and triggers a callback.\n * The core logic (event listening + target checking) is framework-agnostic.\n * Framework-specific wrappers (React hook, Vue composable) and context providers\n * (React context, Vue provide/inject) are implemented in each framework package.\n */\n\nimport type { Falsy } from '@lumx/core/js/types';\n\n/** Event types that trigger click away detection. */\nexport const CLICK_AWAY_EVENT_TYPES = ['mousedown', 'touchstart'] as const;\n\n/** Callback triggered when a click away is detected. */\nexport type ClickAwayCallback = EventListener | Falsy;\n\n/**\n * Check if the click event targets are outside all the given elements.\n *\n * @param targets - The event target elements (from `event.target` and `event.composedPath()`).\n * @param elements - The elements considered \"inside\" the click away context.\n * @returns `true` if the click is outside all elements (i.e. a click away).\n */\nexport function isClickAway(targets: HTMLElement[], elements: HTMLElement[]): boolean {\n return !elements.some((element) => targets.some((target) => element?.contains(target)));\n}\n\n/**\n * Imperative setup for click away detection.\n * Adds mousedown/touchstart listeners on `document` and calls the callback when a click\n * occurs outside the elements returned by `getElements`.\n *\n * Note: when `getElements` returns an empty array, any click is considered a click away.\n * Callers should guard against calling `setupClickAway` when no refs are registered.\n *\n * @param getElements - Getter returning the current list of elements considered \"inside\".\n * @param callback - Callback to invoke on click away.\n * @returns A teardown function that removes the event listeners.\n */\nexport function setupClickAway(\n getElements: () => HTMLElement[],\n callback: ClickAwayCallback,\n): (() => void) | undefined {\n if (!callback) {\n return undefined;\n }\n\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n const elements = getElements();\n if (isClickAway(targets, elements)) {\n callback(evt);\n }\n };\n\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n}\n","import {\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue';\nimport { setupClickAway, type ClickAwayCallback } from '@lumx/core/js/utils/ClickAway';\n\ninterface ContextValue {\n childrenRefs: HTMLElement[];\n addRefs(...newChildrenRefs: Array<Ref<HTMLElement | undefined>>): void;\n}\n\nexport const CLICK_AWAY_KEY: InjectionKey<ContextValue> = Symbol('LumxClickAway');\n\n/**\n * Component combining click away detection with Vue's provide/inject to hook into the component tree\n * and take into account both the DOM tree and the component tree to detect click away.\n */\nexport const ClickAwayProvider = defineComponent(\n (\n props: {\n callback: ClickAwayCallback;\n childrenRefs: Ref<Array<Ref<HTMLElement | undefined>>>;\n parentRef?: Ref<HTMLElement | undefined>;\n },\n { slots },\n ) => {\n const parentContext = inject(CLICK_AWAY_KEY, null);\n\n const contextChildrenRefs: HTMLElement[] = [];\n\n const currentContext: ContextValue = {\n childrenRefs: contextChildrenRefs,\n addRefs(...newChildrenRefs) {\n for (const newRef of newChildrenRefs) {\n const el = newRef.value;\n if (el) {\n contextChildrenRefs.push(el);\n }\n }\n if (parentContext) {\n parentContext.addRefs(...newChildrenRefs);\n if (props.parentRef) {\n parentContext.addRefs(props.parentRef);\n }\n }\n },\n };\n\n provide(CLICK_AWAY_KEY, currentContext);\n\n let teardown: (() => void) | undefined;\n\n onMounted(() => {\n const refs = props.childrenRefs.value;\n if (refs) {\n currentContext.addRefs(...refs);\n }\n\n // Setup click away using the context's collected refs directly\n teardown = setupClickAway(() => contextChildrenRefs, props.callback);\n });\n\n onBeforeUnmount(() => {\n teardown?.();\n });\n\n return () => slots.default?.();\n },\n {\n name: 'LumxClickAwayProvider',\n props: {\n callback: {\n type: [Function, Boolean, undefined] as PropType<ClickAwayCallback>,\n default: undefined,\n },\n childrenRefs: {\n type: Object as PropType<Ref<Array<Ref<HTMLElement | undefined>>>>,\n required: true,\n },\n parentRef: {\n type: Object as PropType<Ref<HTMLElement | undefined>>,\n default: undefined,\n },\n },\n },\n);\n"],"names":["useTheme","options","Theme","defaultTheme","injected","inject","computed","unref","ThemeProvider","defineComponent","props","slots","provide","PORTAL_KEY","Symbol","defaultPortalInit","container","PortalProvider","value","default","name","type","Function","required","_isSlot","s","Object","prototype","toString","call","_isVNode","Portal","portalInit","context","ref","initializePortal","enabled","watch","onBeforeUnmount","teardown","content","_createVNode","Teleport","Boolean","CLICK_AWAY_EVENT_TYPES","isClickAway","targets","elements","element","target","setupClickAway","getElements","callback","listener","evt","evtType","CLICK_AWAY_KEY","ClickAwayProvider","parentContext","contextChildrenRefs","currentContext","childrenRefs","addRefs","newChildrenRefs","newRef","el","push","parentRef","onMounted","refs","undefined"],"mappings":";;AAWO,SAASA,EAASC,IAAoB,EAAE,cAAcC,EAAM,SAAyC;AACxG,QAAM,EAAE,cAAAC,MAAiBF,GACnBG,IAAWC,EAAmD,SAAS,MAAS;AACtF,SAAOC,EAAS,MAAMC,EAAMH,CAAQ,KAAKD,CAAY;AACzD;ACRO,MAAMK,IAAgBC;AAAA,EACzB,CAACC,GAAqC,EAAE,OAAAC,SACpCC;AAAA,IACI;AAAA,IACAN,EAAS,MAAMI,EAAM,KAAK;AAAA,EAAA,GAEvB,MAAMC,EAAM,UAAA;AAAA,EAEvB;AAAA,IACI,MAAM;AAAA,IACN,OAAO,EAAE,OAAO,EAAE,MAAM,QAAuC,SAAS,SAAU;AAAA,EAAE;AAE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D,aAAa3C;AAChC,IAAImD,KACAT,EAAeE,QAAQ,GAAGO,CAAI,GAIlC9B,IAAWW,EAAe,MAAMS,GAAqBjD,EAAM0C,QAAQ;AAAA,EACvE,CAAC,GAEDd,EAAgB,MAAM;AAClBC,IAAAA,IAAQ;AAAA,EACZ,CAAC,GAEM,MAAM5B,EAAMQ,UAAO;AAC9B,GACA;AAAA,EACIC,MAAM;AAAA,EACNV,OAAO;AAAA,IACH0C,UAAU;AAAA,MACN/B,MAAM,CAACC,UAAUqB,SAAS2B,MAAS;AAAA,MACnCnD,SAASmD;AAAAA;IAEbT,cAAc;AAAA,MACVxC,MAAMK;AAAAA,MACNH,UAAU;AAAA;IAEd4C,WAAW;AAAA,MACP9C,MAAMK;AAAAA,MACNP,SAASmD;AAAAA,IACb;AAAA,EACJ;AACJ,CACJ;"}
|
|
1
|
+
{"version":3,"file":"BrPeaE_u.js","sources":["../../src/utils/theme/useTheme.ts","../../src/utils/theme/ThemeProvider.ts","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx","../../../lumx-core/src/js/utils/ClickAway/index.ts","../../src/utils/ClickAway/ClickAwayProvider.tsx"],"sourcesContent":["import { type ComputedRef, type Ref, computed, inject, unref } from 'vue';\n\nimport { Theme } from '@lumx/core/js/constants';\n\nexport interface UseTheme {\n defaultTheme?: Theme;\n}\n/**\n * Retrieves the globally applied theme.\n * @returns computed theme value (auto-updates when the provided theme changes)\n */\nexport function useTheme(options: UseTheme = { defaultTheme: Theme.light }): ComputedRef<Theme | undefined> {\n const { defaultTheme } = options;\n const injected = inject<Theme | Ref<Theme | undefined> | undefined>('theme', undefined);\n return computed(() => unref(injected) || defaultTheme);\n}\n","import { computed, defineComponent, provide, type PropType } from 'vue';\nimport type { Theme } from '@lumx/core/js/constants';\n\n/**\n * ThemeProvider for Vue: wraps children with `provide('theme', value)` for theme isolation.\n * Vue's `provide()` requires a component boundary, so this is a component.\n */\nexport const ThemeProvider = defineComponent(\n (props: { value: Theme | undefined }, { slots }) => {\n provide(\n 'theme',\n computed(() => props.value),\n );\n return () => slots.default?.();\n },\n {\n name: 'LumxThemeProvider',\n props: { value: { type: String as PropType<Theme | undefined>, default: undefined } },\n },\n);\n","import { defineComponent, provide, type PropType, type InjectionKey } from 'vue';\n\nexport type { PortalInit, PortalProviderProps } from '@lumx/core/js/utils/Portal';\nimport type { PortalInit, PortalProviderProps } from '@lumx/core/js/utils/Portal';\n\nexport const PORTAL_KEY: InjectionKey<PortalInit> = Symbol('LumxPortal');\n\nexport const defaultPortalInit: PortalInit = () => ({ container: 'body' });\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider = defineComponent(\n (props: PortalProviderProps, { slots }) => {\n provide(PORTAL_KEY, props.value);\n return () => slots.default?.();\n },\n {\n name: 'LumxPortalProvider',\n props: {\n value: {\n type: Function as PropType<PortalInit>,\n required: true,\n },\n },\n },\n);\n","import { defineComponent, inject, onBeforeUnmount, Teleport, ref, watch } from 'vue';\nimport { PORTAL_KEY, defaultPortalInit } from './PortalProvider';\n\nexport type { PortalProps } from '@lumx/core/js/utils/Portal';\nimport type { PortalProps } from '@lumx/core/js/utils/Portal';\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalProvider)\n */\nexport const Portal = defineComponent(\n (props: PortalProps, { slots }) => {\n const portalInit = inject(PORTAL_KEY, defaultPortalInit);\n const context = ref<ReturnType<typeof portalInit> | null>(null);\n\n // Initialize portal context when enabled\n const initializePortal = () => {\n if (props.enabled) {\n context.value = portalInit();\n } else {\n context.value = null;\n }\n };\n\n // Initialize on mount and when enabled changes\n initializePortal();\n watch(() => props.enabled, initializePortal);\n\n // Register teardown on unmount\n onBeforeUnmount(() => {\n context.value?.teardown?.();\n });\n\n return () => {\n const content = slots.default?.();\n const container = context.value?.container;\n\n // If disabled or no container, render inline\n if (!props.enabled || !container) {\n return content;\n }\n\n // Render in portal using Teleport\n return <Teleport to={container}>{content}</Teleport>;\n };\n },\n {\n name: 'LumxPortal',\n props: {\n enabled: {\n type: Boolean,\n default: true,\n },\n },\n },\n);\n","/**\n * Shared types and logic for ClickAway detection.\n *\n * ClickAway detects clicks outside a set of elements and triggers a callback.\n * The core logic (event listening + target checking) is framework-agnostic.\n * Framework-specific wrappers (React hook, Vue composable) and context providers\n * (React context, Vue provide/inject) are implemented in each framework package.\n */\n\nimport type { Falsy } from '@lumx/core/js/types';\n\n/** Event types that trigger click away detection. */\nexport const CLICK_AWAY_EVENT_TYPES = ['mousedown', 'touchstart'] as const;\n\n/** Callback triggered when a click away is detected. */\nexport type ClickAwayCallback = EventListener | Falsy;\n\n/**\n * Check if the click event targets are outside all the given elements.\n *\n * @param targets - The event target elements (from `event.target` and `event.composedPath()`).\n * @param elements - The elements considered \"inside\" the click away context.\n * @returns `true` if the click is outside all elements (i.e. a click away).\n */\nexport function isClickAway(targets: HTMLElement[], elements: HTMLElement[]): boolean {\n return !elements.some((element) => element instanceof Node && targets.some((target) => element.contains(target)));\n}\n\n/**\n * Imperative setup for click away detection.\n * Adds mousedown/touchstart listeners on `document` and calls the callback when a click\n * occurs outside the elements returned by `getElements`.\n *\n * Note: when `getElements` returns an empty array, any click is considered a click away.\n * Callers should guard against calling `setupClickAway` when no refs are registered.\n *\n * @param getElements - Getter returning the current list of elements considered \"inside\".\n * @param callback - Callback to invoke on click away.\n * @returns A teardown function that removes the event listeners.\n */\nexport function setupClickAway(\n getElements: () => HTMLElement[],\n callback: ClickAwayCallback,\n): (() => void) | undefined {\n if (!callback) {\n return undefined;\n }\n\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target].filter((t): t is HTMLElement => t instanceof Node);\n const elements = getElements();\n if (isClickAway(targets, elements)) {\n callback(evt);\n }\n };\n\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n}\n","import {\n defineComponent,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n type InjectionKey,\n type PropType,\n type Ref,\n} from 'vue';\nimport { setupClickAway, type ClickAwayCallback } from '@lumx/core/js/utils/ClickAway';\n\ninterface ContextValue {\n childrenRefs: HTMLElement[];\n addRefs(...newChildrenRefs: Array<Ref<HTMLElement | undefined>>): void;\n}\n\nexport const CLICK_AWAY_KEY: InjectionKey<ContextValue> = Symbol('LumxClickAway');\n\n/**\n * Component combining click away detection with Vue's provide/inject to hook into the component tree\n * and take into account both the DOM tree and the component tree to detect click away.\n */\nexport const ClickAwayProvider = defineComponent(\n (\n props: {\n callback: ClickAwayCallback;\n childrenRefs: Ref<Array<Ref<HTMLElement | undefined>>>;\n parentRef?: Ref<HTMLElement | undefined>;\n },\n { slots },\n ) => {\n const parentContext = inject(CLICK_AWAY_KEY, null);\n\n const contextChildrenRefs: HTMLElement[] = [];\n\n const currentContext: ContextValue = {\n childrenRefs: contextChildrenRefs,\n addRefs(...newChildrenRefs) {\n for (const newRef of newChildrenRefs) {\n const el = newRef.value;\n if (el) {\n contextChildrenRefs.push(el);\n }\n }\n if (parentContext) {\n parentContext.addRefs(...newChildrenRefs);\n if (props.parentRef) {\n parentContext.addRefs(props.parentRef);\n }\n }\n },\n };\n\n provide(CLICK_AWAY_KEY, currentContext);\n\n let teardown: (() => void) | undefined;\n\n onMounted(() => {\n const refs = props.childrenRefs.value;\n if (refs) {\n currentContext.addRefs(...refs);\n }\n\n // Setup click away using the context's collected refs directly\n teardown = setupClickAway(() => contextChildrenRefs, props.callback);\n });\n\n onBeforeUnmount(() => {\n teardown?.();\n });\n\n return () => slots.default?.();\n },\n {\n name: 'LumxClickAwayProvider',\n props: {\n callback: {\n type: [Function, Boolean, undefined] as PropType<ClickAwayCallback>,\n default: undefined,\n },\n childrenRefs: {\n type: Object as PropType<Ref<Array<Ref<HTMLElement | undefined>>>>,\n required: true,\n },\n parentRef: {\n type: Object as PropType<Ref<HTMLElement | undefined>>,\n default: undefined,\n },\n },\n },\n);\n"],"names":["useTheme","options","Theme","defaultTheme","injected","inject","computed","unref","ThemeProvider","defineComponent","props","slots","provide","PORTAL_KEY","Symbol","defaultPortalInit","container","PortalProvider","value","default","name","type","Function","required","_isSlot","s","Object","prototype","toString","call","_isVNode","Portal","portalInit","context","ref","initializePortal","enabled","watch","onBeforeUnmount","teardown","content","_createVNode","Teleport","Boolean","CLICK_AWAY_EVENT_TYPES","isClickAway","targets","elements","element","target","setupClickAway","getElements","callback","listener","evt","t","evtType","CLICK_AWAY_KEY","ClickAwayProvider","parentContext","contextChildrenRefs","currentContext","childrenRefs","addRefs","newChildrenRefs","newRef","el","push","parentRef","onMounted","refs","undefined"],"mappings":";;AAWO,SAASA,EAASC,IAAoB,EAAE,cAAcC,EAAM,SAAyC;AACxG,QAAM,EAAE,cAAAC,MAAiBF,GACnBG,IAAWC,EAAmD,SAAS,MAAS;AACtF,SAAOC,EAAS,MAAMC,EAAMH,CAAQ,KAAKD,CAAY;AACzD;ACRO,MAAMK,IAAgBC;AAAA,EACzB,CAACC,GAAqC,EAAE,OAAAC,SACpCC;AAAA,IACI;AAAA,IACAN,EAAS,MAAMI,EAAM,KAAK;AAAA,EAAA,GAEvB,MAAMC,EAAM,UAAA;AAAA,EAEvB;AAAA,IACI,MAAM;AAAA,IACN,OAAO,EAAE,OAAO,EAAE,MAAM,QAAuC,SAAS,SAAU;AAAA,EAAE;AAE5F,GCdaE,IAAuCC,uBAAO,YAAY,GAE1DC,IAAgCA,OAAO;AAAA,EAAEC,WAAW;AAAO,IAK3DC,sBACT,CAACP,GAA4B;AAAA,EAAEC,OAAAA;AAAM,OACjCC,EAAQC,GAAYH,EAAMQ,KAAK,GACxB,MAAMP,EAAMQ,UAAO,IAE9B;AAAA,EACIC,MAAM;AAAA,EACNV,OAAO;AAAA,IACHQ,OAAO;AAAA,MACHG,MAAMC;AAAAA,MACNC,UAAU;AAAA,IACd;AAAA,EACJ;AACJ,CACJ;ACzB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AAAA,MACN/B,MAAM,CAACC,UAAUqB,SAAS4B,MAAS;AAAA,MACnCpD,SAASoD;AAAAA;IAEbT,cAAc;AAAA,MACVzC,MAAMK;AAAAA,MACNH,UAAU;AAAA;IAEd6C,WAAW;AAAA,MACP/C,MAAMK;AAAAA,MACNP,SAASoD;AAAAA,IACb;AAAA,EACJ;AACJ,CACJ;"}
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ColorVariant as jl, VISUALLY_HIDDEN as zl, AspectRatio as bi, Size as H
|
|
|
2
2
|
export * from "@lumx/core/js/constants";
|
|
3
3
|
export * from "@lumx/core/js/types";
|
|
4
4
|
import { createVNode as f, mergeProps as y, isVNode as ie, Fragment as Pe, inject as ba, computed as w, unref as aa, getCurrentInstance as gi, ref as j, watch as Q, onBeforeUnmount as yi, nextTick as Wl, defineComponent as k, useAttrs as $, toRef as Ie, toRaw as ze, provide as ga, getCurrentScope as Ai, onScopeDispose as wi, toValue as ya, shallowRef as Aa, onMounted as Ul, useSlots as mt, useTemplateRef as Gl, shallowReadonly as Me, watchEffect as pt, isRef as ye, onUnmounted as _i, h as La, Comment as Kl, Text as Xl, cloneVNode as Yl, toRefs as Zl, reactive as Jl, watchPostEffect as Ql } from "vue";
|
|
5
|
-
import { u as F, P as Pi, C as ec, T as tc } from "./_internal/
|
|
5
|
+
import { u as F, P as Pi, C as ec, T as tc } from "./_internal/BrPeaE_u.js";
|
|
6
6
|
import { classNames as de } from "@lumx/core/js/utils";
|
|
7
7
|
import { mdiImageBroken as nc } from "@lumx/icons/esm/image-broken.js";
|
|
8
8
|
import { mdiAlertCircle as lt } from "@lumx/icons/esm/alert-circle.js";
|
package/package.json
CHANGED
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"sideEffects": false,
|
|
36
|
-
"version": "4.9.0-alpha.
|
|
36
|
+
"version": "4.9.0-alpha.2",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/vue": "^1.1.10",
|
|
39
|
-
"@lumx/core": "^4.9.0-alpha.
|
|
40
|
-
"@lumx/icons": "^4.9.0-alpha.
|
|
39
|
+
"@lumx/core": "^4.9.0-alpha.2",
|
|
40
|
+
"@lumx/icons": "^4.9.0-alpha.2",
|
|
41
41
|
"@vueuse/core": "^14.1.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
package/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s } from "../_internal/
|
|
2
|
-
import { C as P, P as v, a as w, T as d, u as C } from "../_internal/
|
|
1
|
+
import { s } from "../_internal/BrPeaE_u.js";
|
|
2
|
+
import { C as P, P as v, a as w, T as d, u as C } from "../_internal/BrPeaE_u.js";
|
|
3
3
|
import { watchEffect as n, onBeforeUnmount as l } from "vue";
|
|
4
4
|
function u({ callback: t, childrenRefs: o }) {
|
|
5
5
|
let e;
|