@lumx/vue 4.5.1 → 4.5.2-alpha.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/_internal/DCsEMm-b.js +117 -0
- package/_internal/DCsEMm-b.js.map +1 -0
- package/components/popover/Popover.d.ts +46 -0
- package/components/popover/Popover.stories.d.ts +114 -0
- package/components/popover/Popover.test.stories.d.ts +16 -0
- package/components/popover/index.d.ts +2 -0
- package/components/popover/usePopoverStyle.d.ts +24 -0
- package/composables/useFocus.d.ts +9 -0
- package/composables/useFocusTrap.d.ts +11 -0
- package/composables/useRestoreFocusOnClose.d.ts +11 -0
- package/composables/useTheme.d.ts +1 -10
- package/index.d.ts +1 -0
- package/index.js +2478 -1834
- package/index.js.map +1 -1
- package/package.json +5 -4
- package/utils/index.d.ts +1 -0
- package/utils/index.js +16 -66
- package/utils/index.js.map +1 -1
- package/utils/theme/ThemeProvider.d.ts +10 -0
- package/utils/theme/index.d.ts +3 -0
- package/utils/theme/useTheme.d.ts +10 -0
- package/_internal/CCjQX5wE.js +0 -47
- package/_internal/CCjQX5wE.js.map +0 -1
- /package/utils/{ResetTheme.d.ts → theme/ResetTheme.d.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { inject as l, computed as m, unref as P, defineComponent as c, provide as i, ref as y, watch as b, onBeforeUnmount as p, createVNode as C, Teleport as R, isVNode as x, onMounted as L } from "vue";
|
|
2
|
+
import { Theme as T } from "@lumx/core/js/constants";
|
|
3
|
+
function S(e = { defaultTheme: T.light }) {
|
|
4
|
+
const { defaultTheme: n } = e, o = l("theme", void 0);
|
|
5
|
+
return m(() => P(o) || n);
|
|
6
|
+
}
|
|
7
|
+
const g = c(
|
|
8
|
+
(e, { slots: n }) => (i(
|
|
9
|
+
"theme",
|
|
10
|
+
m(() => e.value)
|
|
11
|
+
), () => n.default?.()),
|
|
12
|
+
{
|
|
13
|
+
name: "LumxThemeProvider",
|
|
14
|
+
props: { value: { type: String, default: void 0 } }
|
|
15
|
+
}
|
|
16
|
+
), v = /* @__PURE__ */ Symbol("LumxPortal"), A = () => ({
|
|
17
|
+
container: "body"
|
|
18
|
+
}), O = /* @__PURE__ */ c((e, {
|
|
19
|
+
slots: n
|
|
20
|
+
}) => (i(v, e.value), () => n.default?.()), {
|
|
21
|
+
name: "LumxPortalProvider",
|
|
22
|
+
props: {
|
|
23
|
+
value: {
|
|
24
|
+
type: Function,
|
|
25
|
+
required: !0
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
function w(e) {
|
|
30
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !x(e);
|
|
31
|
+
}
|
|
32
|
+
const Y = /* @__PURE__ */ c((e, {
|
|
33
|
+
slots: n
|
|
34
|
+
}) => {
|
|
35
|
+
const o = l(v, A), t = y(null), u = () => {
|
|
36
|
+
e.enabled ? t.value = o() : t.value = null;
|
|
37
|
+
};
|
|
38
|
+
return u(), b(() => e.enabled, u), p(() => {
|
|
39
|
+
t.value?.teardown?.();
|
|
40
|
+
}), () => {
|
|
41
|
+
const r = n.default?.(), a = t.value?.container;
|
|
42
|
+
return !e.enabled || !a ? r : C(R, {
|
|
43
|
+
to: a
|
|
44
|
+
}, w(r) ? r : {
|
|
45
|
+
default: () => [r]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
name: "LumxPortal",
|
|
50
|
+
props: {
|
|
51
|
+
enabled: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: !0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}), s = ["mousedown", "touchstart"];
|
|
57
|
+
function E(e, n) {
|
|
58
|
+
return !n.some((o) => e.some((t) => o?.contains(t)));
|
|
59
|
+
}
|
|
60
|
+
function j(e, n) {
|
|
61
|
+
if (!n)
|
|
62
|
+
return;
|
|
63
|
+
const o = (t) => {
|
|
64
|
+
const u = [t.composedPath?.()[0], t.target], r = e();
|
|
65
|
+
E(u, r) && n(t);
|
|
66
|
+
};
|
|
67
|
+
return s.forEach((t) => document.addEventListener(t, o)), () => {
|
|
68
|
+
s.forEach((t) => document.removeEventListener(t, o));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const f = /* @__PURE__ */ Symbol("LumxClickAway"), I = /* @__PURE__ */ c((e, {
|
|
72
|
+
slots: n
|
|
73
|
+
}) => {
|
|
74
|
+
const o = l(f, null), t = [], u = {
|
|
75
|
+
childrenRefs: t,
|
|
76
|
+
addRefs(...a) {
|
|
77
|
+
for (const h of a) {
|
|
78
|
+
const d = h.value;
|
|
79
|
+
d && t.push(d);
|
|
80
|
+
}
|
|
81
|
+
o && (o.addRefs(...a), e.parentRef && o.addRefs(e.parentRef));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
i(f, u);
|
|
85
|
+
let r;
|
|
86
|
+
return L(() => {
|
|
87
|
+
const a = e.childrenRefs.value;
|
|
88
|
+
a && u.addRefs(...a), r = j(() => t, e.callback);
|
|
89
|
+
}), p(() => {
|
|
90
|
+
r?.();
|
|
91
|
+
}), () => n.default?.();
|
|
92
|
+
}, {
|
|
93
|
+
name: "LumxClickAwayProvider",
|
|
94
|
+
props: {
|
|
95
|
+
callback: {
|
|
96
|
+
type: [Function, Boolean, void 0],
|
|
97
|
+
default: void 0
|
|
98
|
+
},
|
|
99
|
+
childrenRefs: {
|
|
100
|
+
type: Object,
|
|
101
|
+
required: !0
|
|
102
|
+
},
|
|
103
|
+
parentRef: {
|
|
104
|
+
type: Object,
|
|
105
|
+
default: void 0
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
export {
|
|
110
|
+
I as C,
|
|
111
|
+
Y as P,
|
|
112
|
+
g as T,
|
|
113
|
+
O as a,
|
|
114
|
+
j as s,
|
|
115
|
+
S as u
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=DCsEMm-b.js.map
|
|
@@ -0,0 +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,I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iB;AACxB,iBAAWC,KAAUD,GAAiB;AAClC,cAAME,IAAKD,EAAO9C;AAClB,QAAI+C,KACAN,EAAoBO,KAAKD,CAAE;AAAA,MAEnC;AACA,MAAIP,MACAA,EAAcI,QAAQ,GAAGC,CAAe,GACpCrD,EAAMyD,aACNT,EAAcI,QAAQpD,EAAMyD,SAAS;AAAA,IAGjD;AAAA;AAGJvD,EAAAA,EAAQ4C,GAAgBI,CAAc;AAEtC,MAAIrB;AAEJ6B,SAAAA,EAAU,MAAM;AACZ,UAAMC,IAAO3D,EAAMmD,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;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { PopoverProps as CorePopoverProps } from '@lumx/core/js/components/Popover';
|
|
3
|
+
import { VueToJSXProps } from '../../utils/VueToJSX';
|
|
4
|
+
/**
|
|
5
|
+
* Vue Popover props derived from core PopoverProps.
|
|
6
|
+
* Omits framework-specific props and narrows element ref types to raw HTMLElement.
|
|
7
|
+
* `isOpen` is made optional (defaults to false at runtime via keysOf).
|
|
8
|
+
*/
|
|
9
|
+
export type PopoverProps = VueToJSXProps<CorePopoverProps, 'anchorRef' | 'boundaryRef' | 'focusElement' | 'parentElement' | 'focusTrapZoneElement' | 'isOpen'> & {
|
|
10
|
+
/** Reference to the DOM element used to set the position of the popover. Accepts a Vue Ref for reactive positioning. */
|
|
11
|
+
anchorRef?: Ref<HTMLElement | undefined> | HTMLElement;
|
|
12
|
+
/** Element which will act as boundary when opening the popover. Accepts a Vue Ref for reactive positioning. */
|
|
13
|
+
boundaryRef?: Ref<HTMLElement | undefined> | HTMLElement;
|
|
14
|
+
/** Element to focus when opening the popover. */
|
|
15
|
+
focusElement?: HTMLElement;
|
|
16
|
+
/** Whether the popover is open or not. */
|
|
17
|
+
isOpen?: boolean;
|
|
18
|
+
/** Reference to the parent element that triggered the popover. */
|
|
19
|
+
parentElement?: HTMLElement;
|
|
20
|
+
/** The element in which the focus trap should be set. Default to popover. */
|
|
21
|
+
focusTrapZoneElement?: HTMLElement;
|
|
22
|
+
};
|
|
23
|
+
export declare const emitSchema: {
|
|
24
|
+
close: () => boolean;
|
|
25
|
+
};
|
|
26
|
+
declare const Popover: import('vue').DefineSetupFnComponent<PopoverProps, {
|
|
27
|
+
close: () => boolean;
|
|
28
|
+
}, {}, Omit<CorePopoverProps, "className" | import('@lumx/core/js/types').PropsToOverride | "children" | "isOpen" | "anchorRef" | "boundaryRef" | "focusElement" | "parentElement" | "focusTrapZoneElement"> & {
|
|
29
|
+
class?: string;
|
|
30
|
+
} & {
|
|
31
|
+
/** Reference to the DOM element used to set the position of the popover. Accepts a Vue Ref for reactive positioning. */
|
|
32
|
+
anchorRef?: Ref<HTMLElement | undefined> | HTMLElement;
|
|
33
|
+
/** Element which will act as boundary when opening the popover. Accepts a Vue Ref for reactive positioning. */
|
|
34
|
+
boundaryRef?: Ref<HTMLElement | undefined> | HTMLElement;
|
|
35
|
+
/** Element to focus when opening the popover. */
|
|
36
|
+
focusElement?: HTMLElement;
|
|
37
|
+
/** Whether the popover is open or not. */
|
|
38
|
+
isOpen?: boolean;
|
|
39
|
+
/** Reference to the parent element that triggered the popover. */
|
|
40
|
+
parentElement?: HTMLElement;
|
|
41
|
+
/** The element in which the focus trap should be set. Default to popover. */
|
|
42
|
+
focusTrapZoneElement?: HTMLElement;
|
|
43
|
+
} & {
|
|
44
|
+
onClose?: (() => any) | undefined;
|
|
45
|
+
}, import('vue').PublicProps>;
|
|
46
|
+
export default Popover;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
component: any;
|
|
3
|
+
render: any;
|
|
4
|
+
args: {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
anchorText: string;
|
|
7
|
+
anchorClassName: string;
|
|
8
|
+
anchorRef?: import('../..').CommonRef;
|
|
9
|
+
as?: string | undefined;
|
|
10
|
+
boundaryRef?: import('../..').CommonRef;
|
|
11
|
+
closeOnClickAway?: boolean | undefined;
|
|
12
|
+
closeOnEscape?: boolean | undefined;
|
|
13
|
+
elevation?: import('../..').Elevation | undefined;
|
|
14
|
+
fitToAnchorWidth?: (import('@lumx/core/js/components/Popover/constants').FitAnchorWidth | boolean) | undefined;
|
|
15
|
+
fitWithinViewportHeight?: boolean | undefined;
|
|
16
|
+
focusElement?: import('../..').CommonRef;
|
|
17
|
+
focusAnchorOnClose?: boolean | undefined;
|
|
18
|
+
hasArrow?: boolean | undefined;
|
|
19
|
+
offset?: import('../..').Offset | undefined;
|
|
20
|
+
parentElement?: import('../..').CommonRef;
|
|
21
|
+
placement?: import('../..').Placement | undefined;
|
|
22
|
+
usePortal?: boolean | undefined;
|
|
23
|
+
focusTrapZoneElement?: import('../..').CommonRef;
|
|
24
|
+
zIndex?: number | undefined;
|
|
25
|
+
withFocusTrap?: boolean | undefined;
|
|
26
|
+
handleClose?: (() => void) | undefined;
|
|
27
|
+
className?: string | undefined;
|
|
28
|
+
theme?: import('../..').Theme | undefined;
|
|
29
|
+
};
|
|
30
|
+
argTypes: {
|
|
31
|
+
isOpen: {
|
|
32
|
+
control: string;
|
|
33
|
+
};
|
|
34
|
+
hasArrow: {
|
|
35
|
+
control: string;
|
|
36
|
+
};
|
|
37
|
+
placement: {
|
|
38
|
+
control: {
|
|
39
|
+
type: "select" | "inline-radio";
|
|
40
|
+
};
|
|
41
|
+
options: ("top" | "right" | "bottom" | "left" | "auto" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-end" | "bottom-start" | "left-end" | "left-start" | "auto-end" | "auto-start")[];
|
|
42
|
+
mapping: Record<string, "top" | "right" | "bottom" | "left" | "auto" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-end" | "bottom-start" | "left-end" | "left-start" | "auto-end" | "auto-start"> | undefined;
|
|
43
|
+
};
|
|
44
|
+
elevation: {
|
|
45
|
+
control: {
|
|
46
|
+
type: "select" | "inline-radio";
|
|
47
|
+
};
|
|
48
|
+
options: import('../..').Elevation[];
|
|
49
|
+
mapping: Record<string, import('../..').Elevation> | undefined;
|
|
50
|
+
};
|
|
51
|
+
ref: {
|
|
52
|
+
control: boolean;
|
|
53
|
+
};
|
|
54
|
+
parentElement: {
|
|
55
|
+
control: boolean;
|
|
56
|
+
};
|
|
57
|
+
focusElement: {
|
|
58
|
+
control: boolean;
|
|
59
|
+
};
|
|
60
|
+
anchorRef: {
|
|
61
|
+
control: boolean;
|
|
62
|
+
};
|
|
63
|
+
boundaryRef: {
|
|
64
|
+
control: boolean;
|
|
65
|
+
};
|
|
66
|
+
children: {
|
|
67
|
+
control: boolean;
|
|
68
|
+
};
|
|
69
|
+
anchorText: {
|
|
70
|
+
control: boolean;
|
|
71
|
+
};
|
|
72
|
+
anchorClassName: {
|
|
73
|
+
control: boolean;
|
|
74
|
+
};
|
|
75
|
+
popoverClassName: {
|
|
76
|
+
control: boolean;
|
|
77
|
+
};
|
|
78
|
+
textColor: {
|
|
79
|
+
control: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
decorators: ((story: any, context: any) => any)[];
|
|
83
|
+
title: string;
|
|
84
|
+
};
|
|
85
|
+
export default _default;
|
|
86
|
+
export declare const Simple: {};
|
|
87
|
+
export declare const DarkTheme: {
|
|
88
|
+
args: {
|
|
89
|
+
theme: string;
|
|
90
|
+
hasArrow: boolean;
|
|
91
|
+
textColor: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export declare const WithoutPortal: {
|
|
95
|
+
args: {
|
|
96
|
+
usePortal: boolean;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export declare const Placements: {
|
|
100
|
+
argTypes: {
|
|
101
|
+
placement: {
|
|
102
|
+
control: boolean;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
decorators: ((story: any, context: any) => any)[];
|
|
106
|
+
};
|
|
107
|
+
export declare const FitToAnchorWidth: {
|
|
108
|
+
args: {
|
|
109
|
+
anchorClassName: string;
|
|
110
|
+
popoverClassName: string;
|
|
111
|
+
placement: "bottom";
|
|
112
|
+
};
|
|
113
|
+
decorators: ((story: any, context: any) => any)[];
|
|
114
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
parameters: {
|
|
4
|
+
chromatic: {
|
|
5
|
+
disable: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
11
|
+
/**
|
|
12
|
+
* Testing update of the popover on anchor and popover resize and move
|
|
13
|
+
*/
|
|
14
|
+
export declare const TestUpdatingChildrenAndMovingAnchor: {
|
|
15
|
+
render(): import("vue/jsx-runtime").JSX.Element;
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref, CSSProperties } from 'vue';
|
|
2
|
+
import { Placement, Offset } from '@lumx/core/js/components/Popover/constants';
|
|
3
|
+
export interface UsePopoverStyleOptions {
|
|
4
|
+
anchorRef: Ref<HTMLElement | undefined>;
|
|
5
|
+
offset?: Ref<Offset | undefined>;
|
|
6
|
+
hasArrow?: Ref<boolean | undefined>;
|
|
7
|
+
fitToAnchorWidth?: Ref<string | boolean | undefined>;
|
|
8
|
+
fitWithinViewportHeight?: Ref<boolean | undefined>;
|
|
9
|
+
boundaryRef?: Ref<HTMLElement | undefined>;
|
|
10
|
+
placement?: Ref<Placement | undefined>;
|
|
11
|
+
style?: Ref<CSSProperties | undefined>;
|
|
12
|
+
zIndex?: Ref<number | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export interface UsePopoverStyleOutput {
|
|
15
|
+
styles: {
|
|
16
|
+
arrow: Ref<CSSProperties | undefined>;
|
|
17
|
+
popover: Ref<CSSProperties>;
|
|
18
|
+
};
|
|
19
|
+
isPositioned: Ref<boolean>;
|
|
20
|
+
position: Ref<Placement | undefined>;
|
|
21
|
+
floatingRef: Ref<HTMLElement | undefined>;
|
|
22
|
+
arrowRef: Ref<HTMLElement | undefined>;
|
|
23
|
+
}
|
|
24
|
+
export declare function usePopoverStyle(options: UsePopoverStyleOptions): UsePopoverStyleOutput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Composable focusing an element when defined and `shouldFocus` becomes `true`.
|
|
4
|
+
* Only focuses once per transition to `true` (one-shot).
|
|
5
|
+
*
|
|
6
|
+
* @param elementRef Element to focus (or ref to it).
|
|
7
|
+
* @param shouldFocusRef Boolean flag to trigger the focus (or ref to it).
|
|
8
|
+
*/
|
|
9
|
+
export declare function useFocus(elementRef: Ref<HTMLElement | null | undefined> | HTMLElement | null | undefined, shouldFocusRef?: Ref<boolean> | boolean): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Trap 'Tab' focus switch inside the `focusZoneElement`.
|
|
4
|
+
*
|
|
5
|
+
* If multiple focus traps are activated, only the last one is maintained and when a focus trap closes, the previous one
|
|
6
|
+
* gets activated again.
|
|
7
|
+
*
|
|
8
|
+
* @param focusZoneElementRef The element in which to trap the focus (or ref to it). Falsy disables the trap.
|
|
9
|
+
* @param focusElementRef The element to focus when the focus trap is activated (or ref to it).
|
|
10
|
+
*/
|
|
11
|
+
export declare function useFocusTrap(focusZoneElementRef: Ref<HTMLElement | null | undefined | false> | HTMLElement | null | undefined | false, focusElementRef?: Ref<HTMLElement | null | undefined> | HTMLElement | null | undefined): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Restores focus to the anchor or parent element when the popover is unmounted,
|
|
4
|
+
* if focus was within the popover at the time of unmount.
|
|
5
|
+
*
|
|
6
|
+
* @param focusAnchorOnClose Whether to restore focus on close.
|
|
7
|
+
* @param anchorRef Reference to the anchor element.
|
|
8
|
+
* @param parentElementRef Reference to the parent element (optional override for focus target).
|
|
9
|
+
* @param popoverElementRef Reference to the popover element.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useRestoreFocusOnClose(focusAnchorOnClose: Ref<boolean | undefined>, anchorRef: Ref<HTMLElement | undefined>, parentElementRef: Ref<HTMLElement | undefined> | undefined, popoverElementRef: Ref<HTMLElement | undefined>): void;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Theme } from '@lumx/core/js/constants';
|
|
3
|
-
export interface UseTheme {
|
|
4
|
-
defaultTheme?: Theme;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves the globally applied theme.
|
|
8
|
-
* @returns computed theme value (auto-updates when the provided theme changes)
|
|
9
|
-
*/
|
|
10
|
-
export declare function useTheme(options?: UseTheme): ComputedRef<Theme | undefined>;
|
|
1
|
+
export { useTheme, type UseTheme } from '../utils/theme/useTheme';
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './components/input-helper';
|
|
|
14
14
|
export * from './components/input-label';
|
|
15
15
|
export * from './components/link';
|
|
16
16
|
export * from './components/message';
|
|
17
|
+
export * from './components/popover';
|
|
17
18
|
export * from './components/progress';
|
|
18
19
|
export * from './components/radio-button';
|
|
19
20
|
export * from './components/skeleton';
|