@lumx/vue 4.4.1-alpha.1 → 4.4.1-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.
@@ -0,0 +1,47 @@
1
+ import { defineComponent as l, provide as i, inject as d, ref as f, watch as s, onBeforeUnmount as p, createVNode as P, Teleport as m, isVNode as b } from "vue";
2
+ const u = /* @__PURE__ */ Symbol("LumxPortal"), v = () => ({
3
+ container: "body"
4
+ }), j = /* @__PURE__ */ l((e, {
5
+ slots: n
6
+ }) => (i(u, e.value), () => n.default?.()), {
7
+ name: "LumxPortalProvider",
8
+ props: {
9
+ value: {
10
+ type: Function,
11
+ required: !0
12
+ }
13
+ }
14
+ });
15
+ function y(e) {
16
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !b(e);
17
+ }
18
+ const L = /* @__PURE__ */ l((e, {
19
+ slots: n
20
+ }) => {
21
+ const c = d(u, v), t = f(null), r = () => {
22
+ e.enabled ? t.value = c() : t.value = null;
23
+ };
24
+ return r(), s(() => e.enabled, r), p(() => {
25
+ t.value?.teardown?.();
26
+ }), () => {
27
+ const o = n.default?.(), a = t.value?.container;
28
+ return !e.enabled || !a ? o : P(m, {
29
+ to: a
30
+ }, y(o) ? o : {
31
+ default: () => [o]
32
+ });
33
+ };
34
+ }, {
35
+ name: "LumxPortal",
36
+ props: {
37
+ enabled: {
38
+ type: Boolean,
39
+ default: !0
40
+ }
41
+ }
42
+ });
43
+ export {
44
+ L as P,
45
+ j as a
46
+ };
47
+ //# sourceMappingURL=CCjQX5wE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CCjQX5wE.js","sources":["../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx"],"sourcesContent":["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"],"names":["PORTAL_KEY","Symbol","defaultPortalInit","container","PortalProvider","props","slots","provide","value","default","name","type","Function","required","_isSlot","s","Object","prototype","toString","call","_isVNode","Portal","portalInit","inject","context","ref","initializePortal","enabled","watch","onBeforeUnmount","teardown","content","_createVNode","Teleport","Boolean"],"mappings":";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MAAMuB;AAAAA,MACNzB,SAAS;AAAA,IACb;AAAA,EACJ;AACJ,CACJ;"}
@@ -1,6 +1,15 @@
1
1
  import { IconButtonProps as UIProps } from '@lumx/core/js/components/Button/IconButton';
2
+ import { TooltipProps } from '../tooltip/Tooltip';
2
3
  import { VueToJSXProps } from '../../utils/VueToJSX';
3
- export type IconButtonProps = VueToJSXProps<UIProps>;
4
+ export type IconButtonProps = VueToJSXProps<UIProps> & {
5
+ /**
6
+ * Props to pass to the tooltip.
7
+ * If undefined or if tooltipProps.label is undefined, the label prop will be used as tooltip label.
8
+ */
9
+ tooltipProps?: Partial<TooltipProps>;
10
+ /** Whether the tooltip should be hidden or not. */
11
+ hideTooltip?: boolean;
12
+ };
4
13
  export declare const emitSchema: {
5
14
  click: (event: MouseEvent) => boolean;
6
15
  };
@@ -14,6 +23,14 @@ declare const IconButton: import('vue').DefineSetupFnComponent<IconButtonProps,
14
23
  click: (event: MouseEvent) => boolean;
15
24
  }, {}, Omit<UIProps, "className" | import('@lumx/core/js/types').PropsToOverride | "children"> & {
16
25
  class?: string;
26
+ } & {
27
+ /**
28
+ * Props to pass to the tooltip.
29
+ * If undefined or if tooltipProps.label is undefined, the label prop will be used as tooltip label.
30
+ */
31
+ tooltipProps?: Partial<TooltipProps>;
32
+ /** Whether the tooltip should be hidden or not. */
33
+ hideTooltip?: boolean;
17
34
  } & {
18
35
  onClick?: ((event: MouseEvent) => any) | undefined;
19
36
  }, import('vue').PublicProps>;
@@ -1,7 +1,6 @@
1
- import { IconButtonProps } from '@lumx/core/js/components/Button/IconButton';
2
1
  import { ButtonGroupProps } from '@lumx/core/js/components/Button/ButtonGroup';
3
2
  import { default as Button, ButtonProps } from './Button';
4
- import { default as IconButton } from './IconButton';
3
+ import { default as IconButton, IconButtonProps } from './IconButton';
5
4
  import { default as ButtonGroup } from './ButtonGroup';
6
5
  export { Button, ButtonGroup, IconButton };
7
6
  export type { ButtonProps, ButtonGroupProps, IconButtonProps };
@@ -1,3 +1,2 @@
1
1
  export { default as GridColumn } from './GridColumn';
2
2
  export type { GridColumnProps, GridColumnGapSize } from './GridColumn';
3
- export { CLASSNAME as GRID_COLUMN_CLASSNAME, COMPONENT_NAME as GRID_COLUMN_COMPONENT_NAME } from './GridColumn';
@@ -1,6 +1,4 @@
1
1
  export { default as ProgressCircular } from './ProgressCircular';
2
2
  export type { ProgressCircularProps, ProgressCircularSize } from './ProgressCircular';
3
- export { CLASSNAME as PROGRESS_CIRCULAR_CLASSNAME, COMPONENT_NAME as PROGRESS_CIRCULAR_COMPONENT_NAME } from './ProgressCircular';
4
3
  export { default as ProgressLinear } from './ProgressLinear';
5
4
  export type { ProgressLinearProps } from './ProgressLinear';
6
- export { CLASSNAME as PROGRESS_LINEAR_CLASSNAME, COMPONENT_NAME as PROGRESS_LINEAR_COMPONENT_NAME } from './ProgressLinear';
@@ -1,3 +1,2 @@
1
1
  export { default as Switch } from './Switch';
2
2
  export type { SwitchProps } from './Switch';
3
- export { CLASSNAME, COMPONENT_NAME, DEFAULT_PROPS } from './Switch';
@@ -0,0 +1,14 @@
1
+ import { TooltipProps as CoreTooltipProps, TooltipPlacement } from '@lumx/core/js/components/Tooltip';
2
+ export type { TooltipPlacement };
3
+ /**
4
+ * Defines the props of the component.
5
+ */
6
+ export interface TooltipProps extends CoreTooltipProps {
7
+ /** Class name forwarded to the tooltip popup */
8
+ class?: string;
9
+ }
10
+ /**
11
+ * Vue Tooltip component.
12
+ * Wraps the shared core TooltipPopup with Vue-specific Floating UI, Portal, and slot injection.
13
+ */
14
+ export declare const Tooltip: import('vue').DefineSetupFnComponent<TooltipProps, {}, {}, TooltipProps & {}, import('vue').PublicProps>;
@@ -0,0 +1,51 @@
1
+ declare const _default: {
2
+ component: any;
3
+ argTypes: {
4
+ placement: {
5
+ control: {
6
+ type: "select" | "inline-radio";
7
+ };
8
+ options: string[];
9
+ mapping: Record<string, string> | undefined;
10
+ };
11
+ children: {
12
+ control: boolean;
13
+ };
14
+ closeMode: {
15
+ control: {
16
+ type: "inline-radio";
17
+ };
18
+ options: string[];
19
+ };
20
+ ariaLinkMode: {
21
+ control: {
22
+ type: "inline-radio";
23
+ };
24
+ options: readonly ["aria-describedby", "aria-labelledby"];
25
+ };
26
+ };
27
+ decorators: ((story: any, context: any) => any)[];
28
+ title: string;
29
+ };
30
+ export default _default;
31
+ export declare const OnAButton: {
32
+ render: (args: any) => import("vue/jsx-runtime").JSX.Element;
33
+ };
34
+ export declare const OnADisabledButton: {
35
+ render: (args: any) => import("vue/jsx-runtime").JSX.Element;
36
+ };
37
+ export declare const ForceOpen: {
38
+ render: (args: any) => import("vue/jsx-runtime").JSX.Element;
39
+ args: {
40
+ forceOpen: boolean;
41
+ };
42
+ };
43
+ export declare const CloseModeHide: {
44
+ render: (args: any) => import("vue/jsx-runtime").JSX.Element;
45
+ args: {
46
+ closeMode: string;
47
+ };
48
+ };
49
+ export declare const MultilineTooltip: {
50
+ render: (args: any) => import("vue/jsx-runtime").JSX.Element;
51
+ };
@@ -0,0 +1,63 @@
1
+ declare const _default: {
2
+ component: any;
3
+ tags: string[];
4
+ parameters: {
5
+ chromatic: {
6
+ disableSnapshot: boolean;
7
+ };
8
+ };
9
+ title: string;
10
+ };
11
+ export default _default;
12
+ export declare const TestActivateOnHover: {
13
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
14
+ args: {
15
+ label: string;
16
+ };
17
+ play({ canvas, userEvent }: any): Promise<void>;
18
+ };
19
+ export declare const TestHoverAnchorThenTooltip: {
20
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
21
+ args: {
22
+ label: string;
23
+ };
24
+ play({ canvas, userEvent }: any): Promise<void>;
25
+ };
26
+ export declare const TestFocusVisibleAndEscape: {
27
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
28
+ args: {
29
+ label: string;
30
+ };
31
+ play({ canvas, userEvent }: any): Promise<void>;
32
+ };
33
+ export declare const TestNoActivateOnClickFocus: {
34
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
35
+ args: {
36
+ label: string;
37
+ };
38
+ play({ canvas, userEvent }: any): Promise<void>;
39
+ };
40
+ export declare const TestCloseModeHide: {
41
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
42
+ args: {
43
+ label: string;
44
+ closeMode: string;
45
+ };
46
+ play({ canvas, userEvent }: any): Promise<void>;
47
+ };
48
+ export declare const TestAriaDescribedByOnHover: {
49
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
50
+ play({ canvas, userEvent }: any): Promise<void>;
51
+ };
52
+ export declare const TestAriaDescribedByOnWrapperHover: {
53
+ render(props: any): import("vue/jsx-runtime").JSX.Element;
54
+ play({ canvasElement, userEvent }: any): Promise<void>;
55
+ };
56
+ export declare const TestAriaLabelledByOnHover: {
57
+ render: ({ children, ...args }: any) => import("vue/jsx-runtime").JSX.Element;
58
+ play({ canvas, userEvent }: any): Promise<void>;
59
+ };
60
+ export declare const TestAriaLabelledByOnWrapperHover: {
61
+ render(props: any): import("vue/jsx-runtime").JSX.Element;
62
+ play({ canvasElement, userEvent }: any): Promise<void>;
63
+ };
@@ -0,0 +1,13 @@
1
+ /** Empty object used as marker context value */
2
+ type TooltipContextValue = NonNullable<unknown>;
3
+ /**
4
+ * Provide tooltip context marker to child components.
5
+ * Used to detect when a component is inside a tooltip (e.g., to prevent nested tooltips).
6
+ */
7
+ export declare function provideTooltipContext(): void;
8
+ /**
9
+ * Inject tooltip context marker.
10
+ * Returns the context value if inside a tooltip, undefined otherwise.
11
+ */
12
+ export declare function useTooltipContext(): TooltipContextValue | undefined;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { Tooltip, type TooltipProps, type TooltipPlacement } from './Tooltip';
@@ -0,0 +1,22 @@
1
+ import { VNode } from 'vue';
2
+ interface Options {
3
+ /** Slot content (default slot VNodes) */
4
+ slotContent: VNode[] | undefined;
5
+ /** Set tooltip anchor element */
6
+ setAnchorElement: (el: HTMLElement | null) => void;
7
+ /** Whether the tooltip is mounted */
8
+ isMounted: boolean;
9
+ /** Tooltip id */
10
+ id: string;
11
+ /** Tooltip label */
12
+ label?: string | null | false;
13
+ /** Choose how the tooltip text should link to the anchor */
14
+ ariaLinkMode: 'aria-describedby' | 'aria-labelledby';
15
+ }
16
+ /**
17
+ * Inject ref and ARIA attributes into tooltip anchor slot content.
18
+ * - For a single non-disabled element slot: clone with injected ref and ARIA attributes.
19
+ * - For text/fragment/multiple children/disabled elements: wrap in a div.
20
+ */
21
+ export declare function useInjectTooltipRef(options: Options): VNode;
22
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Ref } from 'vue';
2
+ import { TooltipOpenManager } from '@lumx/core/js/components/Tooltip/tooltipOpenManager';
3
+ /**
4
+ * Vue composable controlling tooltip visibility using mouse hover the anchor and delay.
5
+ *
6
+ * @param delay Delay in millisecond to display the tooltip.
7
+ * @param anchorElement Tooltip anchor element ref.
8
+ * @return whether or not to show the tooltip plus popper mount callback and manager ref.
9
+ */
10
+ export declare function useTooltipOpen(delay: Ref<number | undefined>, anchorElement: Ref<HTMLElement | null>): {
11
+ isOpen: Ref<boolean, boolean>;
12
+ onPopperMount: (el: HTMLElement | null) => void;
13
+ manager: import('vue').ShallowRef<TooltipOpenManager | undefined, TooltipOpenManager | undefined>;
14
+ };
@@ -0,0 +1,13 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Register a global listener on 'Escape' key pressed.
4
+ *
5
+ * If multiple listeners are registered, only the last one is maintained. When a listener is unregistered, the previous
6
+ * one gets activated again.
7
+ *
8
+ * Supports both reactive refs and static values for callback and closeOnEscape.
9
+ *
10
+ * @param callbackRef Callback (or ref to callback)
11
+ * @param closeOnEscapeRef Disables the hook when false (or ref to boolean)
12
+ */
13
+ export declare function useCallbackOnEscape(callbackRef: Ref<(() => void) | undefined> | (() => void) | undefined, closeOnEscapeRef?: Ref<boolean> | boolean): void;
package/index.d.ts CHANGED
@@ -22,3 +22,4 @@ export * from './components/table';
22
22
  export * from './components/text';
23
23
  export * from './components/thumbnail';
24
24
  export * from './components/toolbar';
25
+ export * from './components/tooltip';