@fuf-stack/pixels 2.0.0-next.3 → 2.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion/accordionVariants.d.mts +62 -62
- package/dist/Accordion/accordionVariants.mjs +3 -3
- package/dist/Accordion/accordionVariants.mjs.map +1 -1
- package/dist/Alert/alertVariants.d.mts +50 -50
- package/dist/Alert/alertVariants.mjs +10 -10
- package/dist/Alert/alertVariants.mjs.map +1 -1
- package/dist/Avatar/avatarVariants.d.mts +53 -53
- package/dist/Avatar/avatarVariants.mjs +4 -4
- package/dist/Avatar/avatarVariants.mjs.map +1 -1
- package/dist/AvatarGroup/avatarGroupVariants.d.mts +2 -2
- package/dist/Badge/badgeVariants.d.mts +30 -30
- package/dist/Badge/badgeVariants.mjs +4 -4
- package/dist/Badge/badgeVariants.mjs.map +1 -1
- package/dist/Breadcrumb/breadcrumbVariants.d.mts +160 -160
- package/dist/Breadcrumb/breadcrumbVariants.mjs +2 -2
- package/dist/Breadcrumb/breadcrumbVariants.mjs.map +1 -1
- package/dist/Button/Button.d.mts +7 -7
- package/dist/Button/Button.d.mts.map +1 -1
- package/dist/Button/Button.mjs +5 -5
- package/dist/Button/Button.mjs.map +1 -1
- package/dist/Button/buttonVariants.d.mts +29 -29
- package/dist/Button/buttonVariants.mjs +3 -3
- package/dist/Button/buttonVariants.mjs.map +1 -1
- package/dist/Card/Card.d.mts.map +1 -1
- package/dist/Card/Card.mjs.map +1 -1
- package/dist/Card/cardVariants.d.mts +18 -18
- package/dist/Card/cardVariants.mjs +2 -2
- package/dist/Card/cardVariants.mjs.map +1 -1
- package/dist/Drawer/drawerVariants.d.mts +93 -93
- package/dist/Drawer/drawerVariants.mjs +1 -1
- package/dist/Drawer/drawerVariants.mjs.map +1 -1
- package/dist/Json/Json.mjs +1 -1
- package/dist/Json/subcomponents/CopiedRenderer.mjs +2 -2
- package/dist/Json/subcomponents/CopiedRenderer.mjs.map +1 -1
- package/dist/Label/labelVariants.d.mts +86 -86
- package/dist/Label/labelVariants.mjs +3 -3
- package/dist/Label/labelVariants.mjs.map +1 -1
- package/dist/Menu/Menu.d.mts +6 -6
- package/dist/Menu/Menu.d.mts.map +1 -1
- package/dist/Menu/Menu.mjs +2 -2
- package/dist/Menu/Menu.mjs.map +1 -1
- package/dist/Menu/menuVariants.d.mts +36 -36
- package/dist/Menu/menuVariants.mjs +7 -7
- package/dist/Menu/menuVariants.mjs.map +1 -1
- package/dist/Modal/modalVariants.d.mts +43 -43
- package/dist/Modal/modalVariants.mjs +6 -6
- package/dist/Modal/modalVariants.mjs.map +1 -1
- package/dist/Popover/popoverVariants.d.mts +36 -36
- package/dist/Popover/popoverVariants.mjs +8 -8
- package/dist/Popover/popoverVariants.mjs.map +1 -1
- package/dist/Progress/progressVariants.d.mts +42 -42
- package/dist/ProgressCircular/progressCircularVariants.d.mts +80 -80
- package/dist/ScrollShadow/scrollShadowVariants.d.mts +1 -1
- package/dist/SearchInput/searchInputVariants.d.mts +26 -26
- package/dist/SearchInput/searchInputVariants.mjs +6 -6
- package/dist/SearchInput/searchInputVariants.mjs.map +1 -1
- package/dist/Table/tableVariants.d.mts +50 -50
- package/dist/Table/tableVariants.mjs +8 -8
- package/dist/Table/tableVariants.mjs.map +1 -1
- package/dist/Tabs/Tabs.d.mts +4 -4
- package/dist/Tabs/Tabs.d.mts.map +1 -1
- package/dist/Tabs/Tabs.mjs +4 -4
- package/dist/Tabs/Tabs.mjs.map +1 -1
- package/dist/Tabs/tabsVariants.d.mts +88 -88
- package/dist/Tabs/tabsVariants.mjs +5 -5
- package/dist/Tabs/tabsVariants.mjs.map +1 -1
- package/dist/Toast/Toaster.d.mts +4 -4
- package/dist/Toast/Toaster.d.mts.map +1 -1
- package/dist/Toast/Toaster.mjs +4 -4
- package/dist/Toast/Toaster.mjs.map +1 -1
- package/dist/Toast/toast.d.mts +2 -2
- package/dist/Toast/toast.d.mts.map +1 -1
- package/dist/Toast/toast.mjs +6 -6
- package/dist/Toast/toast.mjs.map +1 -1
- package/dist/Tooltip/subcomponents/TooltipTextTrigger.mjs +4 -1
- package/dist/Tooltip/subcomponents/TooltipTextTrigger.mjs.map +1 -1
- package/dist/Tooltip/subcomponents/TooltipTriggerElement.mjs +47 -3
- package/dist/Tooltip/subcomponents/TooltipTriggerElement.mjs.map +1 -1
- package/dist/Tooltip/tooltipVariants.d.mts +54 -54
- package/package.json +4 -4
package/dist/Toast/Toaster.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from "react";
|
|
2
|
-
import { Toaster } from "sonner";
|
|
3
|
-
export type ToasterProps = Pick<ComponentProps<typeof Toaster>, 'visibleToasts' | 'position' | 'style' | 'className' | 'toastOptions'>;
|
|
4
|
-
declare const Toaster
|
|
5
|
-
export { Toaster
|
|
2
|
+
import { Toaster as Toaster$1 } from "sonner";
|
|
3
|
+
export type ToasterProps = Pick<ComponentProps<typeof Toaster$1>, 'visibleToasts' | 'position' | 'style' | 'className' | 'toastOptions'>;
|
|
4
|
+
declare const Toaster: ({ toastOptions, ...rest }: ToasterProps) => import("react").JSX.Element;
|
|
5
|
+
export { Toaster as default };
|
|
6
6
|
//# sourceMappingURL=Toaster.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toaster.d.mts","names":["SonnerToaster"
|
|
1
|
+
{"version":3,"file":"Toaster.d.mts","names":["SonnerToaster"],"sources":["../../src/Toast/Toaster.tsx"],"mappings":";;YAQY,eAAe,KACzB,sBAAsBA;cAIlB,YAAW,iBAAA,QAA2B,iCAAY,IAAA"}
|
package/dist/Toast/Toaster.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { cn } from "@fuf-stack/pixel-utils";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Toaster } from "sonner";
|
|
4
|
+
import { Toaster as Toaster$1 } from "sonner";
|
|
5
5
|
// src/Toast/Toaster.tsx
|
|
6
|
-
const Toaster
|
|
6
|
+
const Toaster = ({ toastOptions, ...rest }) => {
|
|
7
7
|
const ref = useRef(null);
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
ref.current?.setAttribute("data-react-aria-top-layer", "true");
|
|
10
10
|
ref.current?.setAttribute("data-component", "toaster");
|
|
11
11
|
}, []);
|
|
12
12
|
const className = cn("w-[var(--width)]", toastOptions?.className);
|
|
13
|
-
return /* @__PURE__ */ jsx(Toaster, {
|
|
13
|
+
return /* @__PURE__ */ jsx(Toaster$1, {
|
|
14
14
|
ref,
|
|
15
15
|
...rest,
|
|
16
16
|
toastOptions: {
|
|
@@ -19,6 +19,6 @@ const Toaster$1 = ({ toastOptions, ...rest }) => {
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
export { Toaster
|
|
22
|
+
export { Toaster as default };
|
|
23
23
|
|
|
24
24
|
//# sourceMappingURL=Toaster.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toaster.mjs","names":["
|
|
1
|
+
{"version":3,"file":"Toaster.mjs","names":["SonnerToaster"],"sources":["../../src/Toast/Toaster.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\n\nimport { useEffect, useRef } from 'react';\n\nimport { Toaster as SonnerToaster } from 'sonner';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nexport type ToasterProps = Pick<\n ComponentProps<typeof SonnerToaster>,\n 'visibleToasts' | 'position' | 'style' | 'className' | 'toastOptions'\n>;\n\nconst Toaster = ({ toastOptions, ...rest }: ToasterProps) => {\n // mark toasts as a React Aria top layer so modal outside-interaction handling\n // neither blocks toast actions nor dismisses the modal when they are clicked\n // this also keeps toasts accessible to screen readers while a modal is open\n // Sonner forwards the root ref but not arbitrary DOM attributes\n const ref = useRef<HTMLElement>(null);\n useEffect(() => {\n ref.current?.setAttribute('data-react-aria-top-layer', 'true');\n ref.current?.setAttribute('data-component', 'toaster');\n }, []);\n\n // Force each toast to take the configured Toaster `--width` so that toasts\n // with short content do not shrink and stay centered when the position is\n // `top-center` / `bottom-center`. Sonner only applies `width: var(--width)`\n // to its built-in styled toasts; our toasts use `toast.custom` and would\n // otherwise size to their content.\n const className = cn('w-[var(--width)]', toastOptions?.className);\n return (\n <SonnerToaster\n ref={ref}\n {...rest}\n toastOptions={{ ...toastOptions, className }}\n />\n );\n};\n\nexport default Toaster;\n"],"mappings":";;;;;AAaA,MAAM,WAAW,EAAE,cAAc,GAAG,WAAyB;CAK3D,MAAM,MAAM,OAAoB,IAAI;CACpC,gBAAgB;EACd,IAAI,SAAS,aAAa,6BAA6B,MAAM;EAC7D,IAAI,SAAS,aAAa,kBAAkB,SAAS;CACvD,GAAG,CAAC,CAAC;CAOL,MAAM,YAAY,GAAG,oBAAoB,cAAc,SAAS;CAChE,OACE,oBAACA,WAAD;EACO;EACL,GAAI;EACJ,cAAc;GAAE,GAAG;GAAc;EAAU;CAC5C,CAAA;AAEL"}
|
package/dist/Toast/toast.d.mts
CHANGED
|
@@ -42,7 +42,7 @@ export interface ToastOptions {
|
|
|
42
42
|
title?: string;
|
|
43
43
|
}
|
|
44
44
|
/** Toast object with convenience methods for different severity levels */
|
|
45
|
-
declare const toast
|
|
45
|
+
declare const toast: {
|
|
46
46
|
/**
|
|
47
47
|
* Show a default toast.
|
|
48
48
|
* @returns The toast id which can be passed to `toast.close()`
|
|
@@ -71,5 +71,5 @@ declare const toast$1: {
|
|
|
71
71
|
/** Close a toast by its id, or close all toasts when no id is given */
|
|
72
72
|
close: (toastId?: string | number) => void;
|
|
73
73
|
};
|
|
74
|
-
export { toast
|
|
74
|
+
export { toast as default };
|
|
75
75
|
//# sourceMappingURL=toast.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.d.mts","names":[
|
|
1
|
+
{"version":3,"file":"toast.d.mts","names":[],"sources":["../../src/Toast/toast.tsx"],"mappings":";;;;KAUK,eAAe,YAAY;;iBAGf;;EAEf;;EAEA;;EAEA,aAAa;;EAEb,OAAO;;EAEP,SAAS;;EAET,QAAQ;;EAER,SAAS;;;iBAIM;;EAEf;;EAEA;;EAEA,aAAa;;EAEb,OAAO;;EAEP,cAAc;;EAEd,UAAU;;EAEV,WAAW;;EAEX,UAAU,OAAO,qBAAqB;;EAEtC;;;cAyDI;;;;;EAKe,UAAA,SAAA,WAAS,UAAY;;;;;EAOxB,OAAA,SAAA,WAAS,UAAY;;;;;EAOrB,OAAA,SAAA,WAAS,UAAY;;;;;EAWlB,UAAA,SAAA,WAAS,UAAY;;;;;EAOvB,QAAA,SAAA,WAAS,UAAY;;EAQpB,QAAA"}
|
package/dist/Toast/toast.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Alert from "../Alert/Alert.mjs";
|
|
2
2
|
import { cn } from "@fuf-stack/pixel-utils";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { toast } from "sonner";
|
|
4
|
+
import { toast as toast$1 } from "sonner";
|
|
5
5
|
// src/Toast/toast.tsx
|
|
6
6
|
const showToast = (message, variant, options) => {
|
|
7
7
|
const { onClose, closable, title, endContent, icon, render, ...rest } = options ?? {};
|
|
@@ -10,9 +10,9 @@ const showToast = (message, variant, options) => {
|
|
|
10
10
|
onDismiss: onClose,
|
|
11
11
|
...rest
|
|
12
12
|
};
|
|
13
|
-
return toast.custom((id) => {
|
|
13
|
+
return toast$1.custom((id) => {
|
|
14
14
|
const close = () => {
|
|
15
|
-
return toast.dismiss(id);
|
|
15
|
+
return toast$1.dismiss(id);
|
|
16
16
|
};
|
|
17
17
|
if (render) return render({
|
|
18
18
|
closable,
|
|
@@ -36,7 +36,7 @@ const showToast = (message, variant, options) => {
|
|
|
36
36
|
}, sonnerOptions);
|
|
37
37
|
};
|
|
38
38
|
/** Toast object with convenience methods for different severity levels */
|
|
39
|
-
const toast
|
|
39
|
+
const toast = {
|
|
40
40
|
/**
|
|
41
41
|
* Show a default toast.
|
|
42
42
|
* @returns The toast id which can be passed to `toast.close()`
|
|
@@ -82,9 +82,9 @@ const toast$1 = {
|
|
|
82
82
|
},
|
|
83
83
|
/** Close a toast by its id, or close all toasts when no id is given */
|
|
84
84
|
close: (toastId) => {
|
|
85
|
-
toast.dismiss(toastId);
|
|
85
|
+
toast$1.dismiss(toastId);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
export { toast
|
|
88
|
+
export { toast as default };
|
|
89
89
|
|
|
90
90
|
//# sourceMappingURL=toast.mjs.map
|
package/dist/Toast/toast.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.mjs","names":["sonnerToast"
|
|
1
|
+
{"version":3,"file":"toast.mjs","names":["sonnerToast"],"sources":["../../src/Toast/toast.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport type { ExternalToast } from 'sonner';\nimport type { AlertProps } from '../Alert';\n\nimport { toast as sonnerToast } from 'sonner';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { Alert } from '../Alert';\n\ntype AlertVariant = NonNullable<AlertProps['variant']>;\n\n/** Props passed to a custom render function */\nexport interface ToastRenderProps {\n /** Whether the toast can be closed by the user */\n closable?: boolean;\n /** Function to close the toast */\n close: () => void;\n /** Content displayed at the end of the toast */\n endContent?: ReactNode;\n /** Icon displayed at the start of the toast */\n icon?: ReactNode;\n /** The toast message */\n message: ReactNode;\n /** Title displayed above the toast message */\n title?: ReactNode;\n /** The color/severity of the toast */\n variant: AlertVariant;\n}\n\n/** Options passed to each toast method */\nexport interface ToastOptions {\n /** Whether the toast can be closed by the user */\n closable?: boolean;\n /** Duration in milliseconds before the toast auto-closes */\n duration?: number;\n /** Content displayed at the end of the toast */\n endContent?: ReactNode;\n /** Icon displayed at the start of the toast */\n icon?: ReactNode;\n /** Callback fired when the toast auto-closes */\n onAutoClose?: ExternalToast['onAutoClose'];\n /** Callback fired when the toast is closed */\n onClose?: ExternalToast['onDismiss'];\n /** Position of the toast on the screen */\n position?: ExternalToast['position'];\n /** Custom render function to override the default Alert */\n render?: (props: ToastRenderProps) => ReactElement;\n /** Title of the toast message */\n title?: string;\n}\n\nconst showToast = (\n message: ReactNode,\n variant: AlertVariant,\n options?: ToastOptions,\n) => {\n // Map custom ToastOptions to Sonner's ExternalToast format:\n // - onClose is mapped to Sonner's onDismiss\n // - closable is handled separately (not a Sonner option)\n // - position defaults to 'top-center'\n const { onClose, closable, title, endContent, icon, render, ...rest } =\n options ?? {};\n const sonnerOptions: ExternalToast = {\n position: 'top-center' as const,\n onDismiss: onClose,\n ...rest,\n };\n return sonnerToast.custom((id) => {\n // Close function passed to custom render or Alert\n const close = () => {\n return sonnerToast.dismiss(id);\n };\n\n // Allow custom rendering via render prop\n if (render) {\n return render({\n closable,\n close,\n endContent,\n icon,\n message,\n title,\n variant,\n });\n }\n\n // Default: render Alert\n return (\n <Alert\n // default toast in light mode is white, in dark mode is background\n className={cn({ 'bg-white dark:bg-background': variant === 'default' })}\n closable={closable}\n endContent={endContent}\n icon={icon}\n onClose={closable ? close : undefined}\n title={title}\n variant={variant}\n >\n {message}\n </Alert>\n );\n }, sonnerOptions);\n};\n\n/** Toast object with convenience methods for different severity levels */\nconst toast = {\n /**\n * Show a default toast.\n * @returns The toast id which can be passed to `toast.close()`\n */\n default: (message: ReactNode, options?: ToastOptions) => {\n return showToast(message, 'default', options);\n },\n /**\n * Show an info toast.\n * @returns The toast id which can be passed to `toast.close()`\n */\n info: (message: ReactNode, options?: ToastOptions) => {\n return showToast(message, 'info', options);\n },\n /**\n * Show a warning toast.\n * @returns The toast id which can be passed to `toast.close()`\n */\n warn: (message: ReactNode, options?: ToastOptions) => {\n return showToast(message, 'warning', {\n duration: 60000,\n closable: true,\n ...options,\n });\n },\n /**\n * Show a success toast.\n * @returns The toast id which can be passed to `toast.close()`\n */\n success: (message: ReactNode, options?: ToastOptions) => {\n return showToast(message, 'success', options);\n },\n /**\n * Show an error toast.\n * @returns The toast id which can be passed to `toast.close()`\n */\n error: (message: ReactNode, options?: ToastOptions) => {\n return showToast(message, 'danger', {\n duration: 60000,\n closable: true,\n ...options,\n });\n },\n /** Close a toast by its id, or close all toasts when no id is given */\n close: (toastId?: string | number) => {\n sonnerToast.dismiss(toastId);\n },\n};\n\nexport default toast;\n"],"mappings":";;;;;AAoDA,MAAM,aACJ,SACA,SACA,YACG;CAKH,MAAM,EAAE,SAAS,UAAU,OAAO,YAAY,MAAM,QAAQ,GAAG,SAC7D,WAAW,CAAC;CACd,MAAM,gBAA+B;EACnC,UAAU;EACV,WAAW;EACX,GAAG;CACL;CACA,OAAOA,QAAY,QAAQ,OAAO;EAEhC,MAAM,cAAc;GAClB,OAAOA,QAAY,QAAQ,EAAE;EAC/B;EAGA,IAAI,QACF,OAAO,OAAO;GACZ;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EAIH,OACE,oBAAC,OAAD;GAEE,WAAW,GAAG,EAAE,+BAA+B,YAAY,UAAU,CAAC;GAC5D;GACE;GACN;GACN,SAAS,WAAW,QAAQ,KAAA;GACrB;GACE;GAER,UAAA;EACI,CAAA;CAEX,GAAG,aAAa;AAClB;;AAGA,MAAM,QAAQ;;;;;CAKZ,UAAU,SAAoB,YAA2B;EACvD,OAAO,UAAU,SAAS,WAAW,OAAO;CAC9C;;;;;CAKA,OAAO,SAAoB,YAA2B;EACpD,OAAO,UAAU,SAAS,QAAQ,OAAO;CAC3C;;;;;CAKA,OAAO,SAAoB,YAA2B;EACpD,OAAO,UAAU,SAAS,WAAW;GACnC,UAAU;GACV,UAAU;GACV,GAAG;EACL,CAAC;CACH;;;;;CAKA,UAAU,SAAoB,YAA2B;EACvD,OAAO,UAAU,SAAS,WAAW,OAAO;CAC9C;;;;;CAKA,QAAQ,SAAoB,YAA2B;EACrD,OAAO,UAAU,SAAS,UAAU;GAClC,UAAU;GACV,UAAU;GACV,GAAG;EACL,CAAC;CACH;;CAEA,QAAQ,YAA8B;EACpC,QAAY,QAAQ,OAAO;CAC7B;AACF"}
|
|
@@ -3,7 +3,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useFocusable } from "react-aria";
|
|
4
4
|
// src/Tooltip/subcomponents/TooltipTextTrigger.tsx
|
|
5
5
|
/**
|
|
6
|
-
* Hover
|
|
6
|
+
* Hover wrapper for text and non-interactive trigger content
|
|
7
|
+
*
|
|
8
|
+
* Components such as labels or icons often neither forward a ref nor have an
|
|
9
|
+
* interactive role, so the wrapper receives the hover props instead
|
|
7
10
|
*
|
|
8
11
|
* @see https://react-aria.adobe.com/Tooltip
|
|
9
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipTextTrigger.mjs","names":[],"sources":["../../../src/Tooltip/subcomponents/TooltipTextTrigger.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\nimport { useFocusable } from 'react-aria';\n\ninterface TooltipTextTriggerProps {\n /**
|
|
1
|
+
{"version":3,"file":"TooltipTextTrigger.mjs","names":[],"sources":["../../../src/Tooltip/subcomponents/TooltipTextTrigger.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\nimport { useFocusable } from 'react-aria';\n\ninterface TooltipTextTriggerProps {\n /** Text or other non-interactive trigger content */\n children: ReactNode;\n /** CSS class name */\n className: string;\n}\n\n/**\n * Hover wrapper for text and non-interactive trigger content\n *\n * Components such as labels or icons often neither forward a ref nor have an\n * interactive role, so the wrapper receives the hover props instead\n *\n * @see https://react-aria.adobe.com/Tooltip\n */\nconst TooltipTextTrigger = ({\n children,\n className,\n}: TooltipTextTriggerProps) => {\n const ref = useRef<HTMLSpanElement>(null);\n const { focusableProps } = useFocusable({}, ref);\n\n return (\n <span\n {...focusableProps}\n ref={ref}\n className={className}\n tabIndex={undefined}\n >\n {children}\n </span>\n );\n};\n\nexport default TooltipTextTrigger;\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAM,sBAAsB,EAC1B,UACA,gBAC6B;CAC7B,MAAM,MAAM,OAAwB,IAAI;CACxC,MAAM,EAAE,mBAAmB,aAAa,CAAC,GAAG,GAAG;CAE/C,OACE,oBAAC,QAAD;EACE,GAAI;EACC;EACM;EACX,UAAU,KAAA;EAET;CACG,CAAA;AAEV"}
|
|
@@ -3,13 +3,57 @@ import { isValidElement } from "react";
|
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Focusable } from "react-aria-components";
|
|
5
5
|
// src/Tooltip/subcomponents/TooltipTriggerElement.tsx
|
|
6
|
+
const INTERACTIVE_TAGS = /* @__PURE__ */ new Set([
|
|
7
|
+
"a",
|
|
8
|
+
"button",
|
|
9
|
+
"input",
|
|
10
|
+
"select",
|
|
11
|
+
"summary",
|
|
12
|
+
"textarea"
|
|
13
|
+
]);
|
|
14
|
+
const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
15
|
+
"button",
|
|
16
|
+
"checkbox",
|
|
17
|
+
"combobox",
|
|
18
|
+
"link",
|
|
19
|
+
"menuitem",
|
|
20
|
+
"option",
|
|
21
|
+
"radio",
|
|
22
|
+
"slider",
|
|
23
|
+
"spinbutton",
|
|
24
|
+
"switch",
|
|
25
|
+
"tab",
|
|
26
|
+
"textbox"
|
|
27
|
+
]);
|
|
28
|
+
const FORWARD_REF = Symbol.for("react.forward_ref");
|
|
29
|
+
const MEMO = Symbol.for("react.memo");
|
|
30
|
+
/** Whether a component type forwards its ref, also through memo */
|
|
31
|
+
const forwardsRef = (type) => {
|
|
32
|
+
if (typeof type !== "object" || type === null) return false;
|
|
33
|
+
const { $$typeof, type: inner } = type;
|
|
34
|
+
if ($$typeof === FORWARD_REF) return true;
|
|
35
|
+
return $$typeof === MEMO && forwardsRef(inner);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Whether Focusable can connect a child as tooltip trigger
|
|
39
|
+
*
|
|
40
|
+
* Interactive DOM elements and components that forward their ref receive the
|
|
41
|
+
* trigger props, so focus opens the tooltip and the control references it.
|
|
42
|
+
* Other content only needs hover and keeps the wrapper.
|
|
43
|
+
*/
|
|
44
|
+
const isFocusableTrigger = (child) => {
|
|
45
|
+
if (typeof child.type !== "string") return forwardsRef(child.type);
|
|
46
|
+
const { role, tabIndex } = child.props;
|
|
47
|
+
return INTERACTIVE_TAGS.has(child.type) || role !== void 0 && INTERACTIVE_ROLES.has(role) || tabIndex !== void 0 && tabIndex >= 0;
|
|
48
|
+
};
|
|
6
49
|
/**
|
|
7
|
-
* Connects a focusable child or
|
|
50
|
+
* Connects a focusable child, or a hover wrapper around other content, to
|
|
51
|
+
* TooltipTrigger
|
|
8
52
|
*
|
|
9
53
|
* @see https://react-aria.adobe.com/Tooltip
|
|
10
54
|
*/
|
|
11
55
|
const TooltipTriggerElement = ({ children, className }) => {
|
|
12
|
-
if (isValidElement(children)) return /* @__PURE__ */ jsx("span", {
|
|
56
|
+
if (isValidElement(children) && isFocusableTrigger(children)) return /* @__PURE__ */ jsx("span", {
|
|
13
57
|
className,
|
|
14
58
|
children: /* @__PURE__ */ jsx(Focusable, { children })
|
|
15
59
|
});
|
|
@@ -18,6 +62,6 @@ const TooltipTriggerElement = ({ children, className }) => {
|
|
|
18
62
|
children
|
|
19
63
|
});
|
|
20
64
|
};
|
|
21
|
-
export { TooltipTriggerElement as default };
|
|
65
|
+
export { TooltipTriggerElement as default, isFocusableTrigger };
|
|
22
66
|
|
|
23
67
|
//# sourceMappingURL=TooltipTriggerElement.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipTriggerElement.mjs","names":[],"sources":["../../../src/Tooltip/subcomponents/TooltipTriggerElement.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { isValidElement } from 'react';\nimport { Focusable } from 'react-aria-components';\n\nimport TooltipTextTrigger from './TooltipTextTrigger';\n\ninterface TooltipTriggerElementProps {\n /** Trigger content, use a focusable child for keyboard access */\n children: ReactNode;\n /** CSS class name */\n className: string;\n}\n\n/**\n * Connects a focusable child or
|
|
1
|
+
{"version":3,"file":"TooltipTriggerElement.mjs","names":[],"sources":["../../../src/Tooltip/subcomponents/TooltipTriggerElement.tsx"],"sourcesContent":["import type { ComponentProps, ReactElement, ReactNode } from 'react';\n\nimport { isValidElement } from 'react';\nimport { Focusable } from 'react-aria-components';\n\nimport TooltipTextTrigger from './TooltipTextTrigger';\n\nconst INTERACTIVE_TAGS = new Set([\n 'a',\n 'button',\n 'input',\n 'select',\n 'summary',\n 'textarea',\n]);\n\nconst INTERACTIVE_ROLES = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'link',\n 'menuitem',\n 'option',\n 'radio',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n]);\n\nconst FORWARD_REF = Symbol.for('react.forward_ref');\nconst MEMO = Symbol.for('react.memo');\n\n/** Whether a component type forwards its ref, also through memo */\nconst forwardsRef = (type: unknown): boolean => {\n if (typeof type !== 'object' || type === null) {\n return false;\n }\n const { $$typeof, type: inner } = type as {\n $$typeof?: symbol;\n type?: unknown;\n };\n if ($$typeof === FORWARD_REF) {\n return true;\n }\n return $$typeof === MEMO && forwardsRef(inner);\n};\n\n/**\n * Whether Focusable can connect a child as tooltip trigger\n *\n * Interactive DOM elements and components that forward their ref receive the\n * trigger props, so focus opens the tooltip and the control references it.\n * Other content only needs hover and keeps the wrapper.\n */\nexport const isFocusableTrigger = (child: ReactElement): boolean => {\n if (typeof child.type !== 'string') {\n return forwardsRef(child.type);\n }\n const { role, tabIndex } = child.props as {\n role?: string;\n tabIndex?: number;\n };\n return (\n INTERACTIVE_TAGS.has(child.type) ||\n (role !== undefined && INTERACTIVE_ROLES.has(role)) ||\n (tabIndex !== undefined && tabIndex >= 0)\n );\n};\n\ninterface TooltipTriggerElementProps {\n /** Trigger content, use a focusable child for keyboard access */\n children: ReactNode;\n /** CSS class name */\n className: string;\n}\n\n/**\n * Connects a focusable child, or a hover wrapper around other content, to\n * TooltipTrigger\n *\n * @see https://react-aria.adobe.com/Tooltip\n */\nconst TooltipTriggerElement = ({\n children,\n className,\n}: TooltipTriggerElementProps) => {\n if (isValidElement(children) && isFocusableTrigger(children)) {\n return (\n <span className={className}>\n <Focusable>\n {children as ComponentProps<typeof Focusable>['children']}\n </Focusable>\n </span>\n );\n }\n\n return (\n <TooltipTextTrigger className={className}>{children}</TooltipTextTrigger>\n );\n};\n\nexport default TooltipTriggerElement;\n"],"mappings":";;;;;AAOA,MAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,cAAc,OAAO,IAAI,mBAAmB;AAClD,MAAM,OAAO,OAAO,IAAI,YAAY;;AAGpC,MAAM,eAAe,SAA2B;CAC9C,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO;CAET,MAAM,EAAE,UAAU,MAAM,UAAU;CAIlC,IAAI,aAAa,aACf,OAAO;CAET,OAAO,aAAa,QAAQ,YAAY,KAAK;AAC/C;;;;;;;;AASA,MAAa,sBAAsB,UAAiC;CAClE,IAAI,OAAO,MAAM,SAAS,UACxB,OAAO,YAAY,MAAM,IAAI;CAE/B,MAAM,EAAE,MAAM,aAAa,MAAM;CAIjC,OACE,iBAAiB,IAAI,MAAM,IAAI,KAC9B,SAAS,KAAA,KAAa,kBAAkB,IAAI,IAAI,KAChD,aAAa,KAAA,KAAa,YAAY;AAE3C;;;;;;;AAeA,MAAM,yBAAyB,EAC7B,UACA,gBACgC;CAChC,IAAI,eAAe,QAAQ,KAAK,mBAAmB,QAAQ,GACzD,OACE,oBAAC,QAAD;EAAiB;EACf,UAAA,oBAAC,WAAD,EACG,SACQ,CAAA;CACP,CAAA;CAIV,OACE,oBAAC,oBAAD;EAA+B;EAAY;CAA6B,CAAA;AAE5E"}
|