@frontify/fondue-components 7.0.1 → 8.0.1
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/fondue-components10.js +1 -1
- package/dist/fondue-components11.js +65 -75
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +1 -1
- package/dist/fondue-components14.js +1 -1
- package/dist/fondue-components15.js +1 -1
- package/dist/fondue-components16.js +1 -1
- package/dist/fondue-components17.js +2 -2
- package/dist/fondue-components18.js +6 -6
- package/dist/fondue-components19.js +1 -1
- package/dist/fondue-components20.js +1 -1
- package/dist/fondue-components21.js +46 -46
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +3 -3
- package/dist/fondue-components23.js +1 -1
- package/dist/fondue-components24.js +1 -1
- package/dist/fondue-components25.js +8 -8
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components28.js +1 -1
- package/dist/fondue-components31.js +1 -1
- package/dist/fondue-components33.js +1 -1
- package/dist/fondue-components37.js +10 -25
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components40.js +17 -14
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +17 -18
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +4 -16
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +13 -3
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +3 -13
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +35 -5
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +13 -35
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +4 -12
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +24 -4
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +16 -24
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components50.js +139 -16
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +16 -140
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +70 -16
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +8 -72
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +33 -8
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +48 -32
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +10 -48
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +10 -8
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +7 -12
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +12 -7
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components60.js +20 -12
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +15 -19
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +52 -14
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +14 -52
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +17 -14
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +6 -17
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +2 -7
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +15 -2
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +1 -1
- package/dist/fondue-components9.js +91 -101
- package/dist/fondue-components9.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/dist/fondue-components69.js +0 -18
- package/dist/fondue-components69.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const g = (
|
|
1
|
+
const g = (n) => n.startsWith("aria-") || n === "role", s = {
|
|
2
2
|
m: "margin",
|
|
3
3
|
mx: "margin-x",
|
|
4
4
|
my: "margin-y",
|
|
@@ -18,18 +18,18 @@ const g = (t) => t.startsWith("aria-") || t === "role", s = {
|
|
|
18
18
|
wrap: "flex-wrap",
|
|
19
19
|
columns: "grid-template-columns",
|
|
20
20
|
rows: "grid-template-rows"
|
|
21
|
-
}, m = (
|
|
22
|
-
if (g(
|
|
21
|
+
}, m = (n, r) => n === "columns" || n === "rows" ? typeof r == "number" ? `repeat(${r}, 1fr)` : r : typeof r == "number" ? `${r * 0.25}rem` : r, f = (n, r = {}) => Object.entries(n).reduce((i, [t, o]) => {
|
|
22
|
+
if (g(t))
|
|
23
23
|
return i;
|
|
24
|
-
const e =
|
|
24
|
+
const e = t in r ? r[t] : t in s ? s[t] : t, p = e == null ? void 0 : e.replaceAll(/([\da-z]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
25
25
|
if (typeof o == "object")
|
|
26
|
-
for (const [d,
|
|
27
|
-
|
|
26
|
+
for (const [d, a] of Object.entries(o))
|
|
27
|
+
a !== void 0 && (i[`--${d}-${p}`] = m(t, a));
|
|
28
28
|
else
|
|
29
|
-
i[`--${
|
|
29
|
+
i[`--${p}`] = m(t, o);
|
|
30
30
|
return i;
|
|
31
31
|
}, {});
|
|
32
32
|
export {
|
|
33
|
-
|
|
33
|
+
f as propsToCssVariables
|
|
34
34
|
};
|
|
35
35
|
//# sourceMappingURL=fondue-components25.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components25.js","sources":["../src/helpers/propsToCssVariables.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type CSSProperties } from 'react';\n\nimport { type Breakpoint } from './layout';\n\nconst isAriaProp = (key: string): boolean => {\n return key.startsWith('aria-') || key === 'role';\n};\n\nconst abbreviationToCssProperty: Record<string, string> = {\n m: 'margin',\n mx: 'margin-x',\n my: 'margin-y',\n mt: 'margin-top',\n mr: 'margin-right',\n mb: 'margin-bottom',\n ml: 'margin-left',\n p: 'padding',\n px: 'padding-x',\n py: 'padding-y',\n pt: 'padding-top',\n pr: 'padding-right',\n pb: 'padding-bottom',\n pl: 'padding-left',\n direction: 'flex-direction',\n align: 'align-items',\n wrap: 'flex-wrap',\n columns: 'grid-template-columns',\n rows: 'grid-template-rows',\n};\n\nconst transformValueBasedOnKey = (key: string, value: string | number): string | number => {\n if (key === 'columns' || key === 'rows') {\n if (typeof value === 'number') {\n return `repeat(${value}, 1fr)`;\n }\n return value;\n }\n return value;\n};\n\nexport const propsToCssVariables = (\n props: Record<string, string | number | boolean | { [key in Breakpoint]?: string | number | boolean }>,\n extraAbbreviationToCssProperty: Record<string, string> = {},\n): CSSProperties => {\n return Object.entries(props).reduce((acc, [key, value]) => {\n if (isAriaProp(key)) {\n return acc;\n }\n\n const cssProperty =\n key in extraAbbreviationToCssProperty\n ? extraAbbreviationToCssProperty[key]\n : key in abbreviationToCssProperty\n ? abbreviationToCssProperty[key]\n : key;\n const cssPropertyKebabCase = cssProperty?.replaceAll(/([\\da-z]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();\n\n if (typeof value === 'object') {\n for (const [breakpoint, breakpointValue] of Object.entries(value)) {\n if (breakpointValue !== undefined) {\n // @ts-expect-error CSS variables are not typed into `CSSProperties`\n acc[`--${breakpoint}-${cssPropertyKebabCase}`] = transformValueBasedOnKey(key, breakpointValue);\n }\n }\n } else {\n // @ts-expect-error CSS variables are not typed into `CSSProperties`\n acc[`--${cssPropertyKebabCase}`] = transformValueBasedOnKey(key, value);\n }\n\n return acc;\n }, {} as CSSProperties);\n};\n"],"names":["isAriaProp","key","abbreviationToCssProperty","transformValueBasedOnKey","value","propsToCssVariables","props","extraAbbreviationToCssProperty","acc","cssProperty","cssPropertyKebabCase","breakpoint","breakpointValue"],"mappings":"AAMA,MAAMA,IAAa,CAACC,MACTA,EAAI,WAAW,OAAO,KAAKA,MAAQ,QAGxCC,IAAoD;AAAA,EACtD,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AACV,GAEMC,IAA2B,CAACF,GAAaG,
|
|
1
|
+
{"version":3,"file":"fondue-components25.js","sources":["../src/helpers/propsToCssVariables.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type CSSProperties } from 'react';\n\nimport { type Breakpoint } from './layout';\n\nconst isAriaProp = (key: string): boolean => {\n return key.startsWith('aria-') || key === 'role';\n};\n\nconst abbreviationToCssProperty: Record<string, string> = {\n m: 'margin',\n mx: 'margin-x',\n my: 'margin-y',\n mt: 'margin-top',\n mr: 'margin-right',\n mb: 'margin-bottom',\n ml: 'margin-left',\n p: 'padding',\n px: 'padding-x',\n py: 'padding-y',\n pt: 'padding-top',\n pr: 'padding-right',\n pb: 'padding-bottom',\n pl: 'padding-left',\n direction: 'flex-direction',\n align: 'align-items',\n wrap: 'flex-wrap',\n columns: 'grid-template-columns',\n rows: 'grid-template-rows',\n};\n\nconst transformValueBasedOnKey = (key: string, value: string | number): string | number => {\n if (key === 'columns' || key === 'rows') {\n if (typeof value === 'number') {\n return `repeat(${value}, 1fr)`;\n }\n return value;\n }\n\n // Spacing tokens\n if (typeof value === 'number') {\n return `${value * 0.25}rem`;\n }\n\n return value;\n};\n\nexport const propsToCssVariables = (\n props: Record<string, string | number | boolean | { [key in Breakpoint]?: string | number | boolean }>,\n extraAbbreviationToCssProperty: Record<string, string> = {},\n): CSSProperties => {\n return Object.entries(props).reduce((acc, [key, value]) => {\n if (isAriaProp(key)) {\n return acc;\n }\n\n const cssProperty =\n key in extraAbbreviationToCssProperty\n ? extraAbbreviationToCssProperty[key]\n : key in abbreviationToCssProperty\n ? abbreviationToCssProperty[key]\n : key;\n const cssPropertyKebabCase = cssProperty?.replaceAll(/([\\da-z]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();\n\n if (typeof value === 'object') {\n for (const [breakpoint, breakpointValue] of Object.entries(value)) {\n if (breakpointValue !== undefined) {\n // @ts-expect-error CSS variables are not typed into `CSSProperties`\n acc[`--${breakpoint}-${cssPropertyKebabCase}`] = transformValueBasedOnKey(key, breakpointValue);\n }\n }\n } else {\n // @ts-expect-error CSS variables are not typed into `CSSProperties`\n acc[`--${cssPropertyKebabCase}`] = transformValueBasedOnKey(key, value);\n }\n\n return acc;\n }, {} as CSSProperties);\n};\n"],"names":["isAriaProp","key","abbreviationToCssProperty","transformValueBasedOnKey","value","propsToCssVariables","props","extraAbbreviationToCssProperty","acc","cssProperty","cssPropertyKebabCase","breakpoint","breakpointValue"],"mappings":"AAMA,MAAMA,IAAa,CAACC,MACTA,EAAI,WAAW,OAAO,KAAKA,MAAQ,QAGxCC,IAAoD;AAAA,EACtD,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AACV,GAEMC,IAA2B,CAACF,GAAaG,MACvCH,MAAQ,aAAaA,MAAQ,SACzB,OAAOG,KAAU,WACV,UAAUA,CAAK,WAEnBA,IAIP,OAAOA,KAAU,WACV,GAAGA,IAAQ,IAAI,QAGnBA,GAGEC,IAAsB,CAC/BC,GACAC,IAAyD,OAElD,OAAO,QAAQD,CAAK,EAAE,OAAO,CAACE,GAAK,CAACP,GAAKG,CAAK,MAAM;AACnD,MAAAJ,EAAWC,CAAG;AACP,WAAAO;AAGL,QAAAC,IACFR,KAAOM,IACDA,EAA+BN,CAAG,IAClCA,KAAOC,IACLA,EAA0BD,CAAG,IAC7BA,GACNS,IAAuBD,KAAA,gBAAAA,EAAa,WAAW,+BAA+B,SAAS;AAEzF,MAAA,OAAOL,KAAU;AACjB,eAAW,CAACO,GAAYC,CAAe,KAAK,OAAO,QAAQR,CAAK;AAC5D,MAAIQ,MAAoB,WAEhBJ,EAAA,KAAKG,CAAU,IAAID,CAAoB,EAAE,IAAIP,EAAyBF,GAAKW,CAAe;AAAA;AAKtG,IAAAJ,EAAI,KAAKE,CAAoB,EAAE,IAAIP,EAAyBF,GAAKG,CAAK;AAGnE,SAAAI;AACX,GAAG,EAAmB;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FOCUS_OUTLINE as t } from "./fondue-
|
|
1
|
+
import { FOCUS_OUTLINE as t } from "./fondue-components66.js";
|
|
2
2
|
import { sv as e } from "./fondue-components27.js";
|
|
3
3
|
const o = e({
|
|
4
4
|
base: `tw-group tw-relative tw-flex tw-flex-row tw-gap-2 tw-items-center tw-justify-center tw-cursor-pointer tw-font-body tw-font-medium ${t}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FOCUS_OUTLINE as t } from "./fondue-
|
|
1
|
+
import { FOCUS_OUTLINE as t } from "./fondue-components66.js";
|
|
2
2
|
import { sv as e } from "./fondue-components27.js";
|
|
3
3
|
const s = e({
|
|
4
4
|
base: `tw-peer tw-relative tw-inline-flex tw-bg-base tw-text-white tw-shrink-0 tw-rounded tw-border tw-border-line-x-strong group-hover:tw-border-line-xx-strong hover:tw-border-line-xx-strong tw-transition-colors data-[state="checked"]:tw-border-transparent data-[state="indeterminate"]:tw-border-transparent disabled:tw-border-line-strong disabled:tw-bg-base disabled:tw-cursor-not-allowed data-[state="checked"]:disabled:tw-bg-box-disabled-strong ${t}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as i, jsx as a, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { IconDroplet as h, IconTrashBin as N, IconCaretDown as f } from "@frontify/fondue-icons";
|
|
3
3
|
import { forwardRef as I } from "react";
|
|
4
|
-
import e from "./fondue-
|
|
4
|
+
import e from "./fondue-components67.js";
|
|
5
5
|
import { colorToCss as b } from "./fondue-components36.js";
|
|
6
6
|
const o = ({
|
|
7
7
|
id: c,
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
if (!window)
|
|
4
|
-
throw new Error("Window object not found, this method should be used in a browser environment");
|
|
5
|
-
i.style.maxHeight = "";
|
|
6
|
-
const { top: t, bottom: e } = i.getBoundingClientRect();
|
|
7
|
-
t - 8 < 0 ? i.style.maxHeight = `${e - 8}px` : e + 8 > window.innerHeight && (i.style.maxHeight = `${window.innerHeight - t - 8}px`);
|
|
1
|
+
function s(u, t) {
|
|
2
|
+
t && (typeof t == "function" ? t(u.current) : t && "current" in t && (t.current = u.current));
|
|
8
3
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
return e && o && s;
|
|
4
|
+
function i(u) {
|
|
5
|
+
u.currentTarget.dataset.autoFocusVisible = "false";
|
|
12
6
|
}
|
|
13
|
-
function a(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function h(i) {
|
|
17
|
-
i.currentTarget.dataset.autoFocusVisible = "false";
|
|
18
|
-
}
|
|
19
|
-
function l(i) {
|
|
20
|
-
const t = i.relatedTarget;
|
|
21
|
-
t != null && t.dataset.autoFocusTrigger && (t.dataset.autoFocusVisible === "true" ? i.target.dataset.showFocusRing = "true" : i.target.dataset.showFocusRing = "false", t.dataset.autoFocusVisible = "true");
|
|
7
|
+
function a(u) {
|
|
8
|
+
const t = u.relatedTarget;
|
|
9
|
+
t != null && t.dataset.autoFocusTrigger && (t.dataset.autoFocusVisible === "true" ? u.target.dataset.showFocusRing = "true" : u.target.dataset.showFocusRing = "false", t.dataset.autoFocusVisible = "true");
|
|
22
10
|
}
|
|
23
11
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
r as isElementVisible,
|
|
28
|
-
c as setMaxHeightToAvailableSpace,
|
|
29
|
-
a as syncRefs
|
|
12
|
+
i as addAutoFocusAttribute,
|
|
13
|
+
a as addShowFocusRing,
|
|
14
|
+
s as syncRefs
|
|
30
15
|
};
|
|
31
16
|
//# sourceMappingURL=fondue-components37.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components37.js","sources":["../src/utilities/domUtilities.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type FocusEvent, type MouseEvent as ReactMouseEvent, type ForwardedRef, type RefObject } from 'react';\n\nexport const MAX_HEIGHT_MARGIN = 8;\n\n/**\n * Sets the maximum height for a dialog element based on its position on the viewport.\n * The function calculates the space below the dialog up to the bottom of the viewport window,\n * subtracting a default margin, and sets this value as the max-height style of the dialog.\n *\n * @param {HTMLElement} dialog - The dialog element whose maximum height is to be set.\n *\n * @example\n * // Suppose you have a dialog element with id 'my-dialog'.\n * const dialogElement = myDialogRef.current || document.getElementById('my-dialog');\n * // Setting its max height relative to its current position and the viewport's dimensions.\n * setMaxHeightToAvailableSpace(dialogElement);\n */\nexport function setMaxHeightToAvailableSpace(dialog: HTMLElement) {\n if (!window) {\n throw new Error('Window object not found, this method should be used in a browser environment');\n }\n\n dialog.style.maxHeight = '';\n\n const { top, bottom } = dialog.getBoundingClientRect();\n if (top - MAX_HEIGHT_MARGIN < 0) {\n // if the dialog is overflowing to the top\n dialog.style.maxHeight = `${bottom - MAX_HEIGHT_MARGIN}px`;\n } else if (bottom + MAX_HEIGHT_MARGIN > window.innerHeight) {\n // if the dialog is overflowing to the bottom\n dialog.style.maxHeight = `${window.innerHeight - top - MAX_HEIGHT_MARGIN}px`;\n }\n}\n\n/**\n * Checks if a specified HTML element is visible within the viewport.\n * Visibility is determined by several factors:\n * - The element must have non-zero dimensions.\n * - The element's computed style must not be `display: none`, `visibility: hidden`, or `opacity: 0`.\n * - The element must be within the bounds of the current viewport.\n *\n * @param {HTMLElement} element - The HTML element to check for visibility.\n * @returns {boolean} Returns true if the element is visible according to the criteria specified, otherwise returns false.\n */\nexport function isElementVisible(element: HTMLElement) {\n const rect = element.getBoundingClientRect();\n const hasSize = rect.width > 0 && rect.height > 0;\n\n const style = window.getComputedStyle(element);\n const isVisibleStyle = style.display !== 'none' && style.visibility !== 'hidden' && parseFloat(style.opacity) !== 0;\n\n // Check if the element is within the viewport\n const isInViewport =\n rect.top < window.innerHeight && rect.left < window.innerWidth && rect.bottom > 0 && rect.right > 0;\n\n return hasSize && isVisibleStyle && isInViewport;\n}\n\n/**\n * Assigns a local DOM ref to a forwarded ref.\n *\n * @param {RefObject<HTMLDivElement>} localRef - The local React reference to an HTMLDivElement.\n * @param {ForwardedRef<HTMLDivElement>} forwardedRef - The ref forwarded from a parent component.\n */\nexport function syncRefs<TElement = HTMLElement>(localRef: RefObject<TElement>, forwardedRef: ForwardedRef<TElement>) {\n if (!forwardedRef) {\n return;\n }\n\n if (typeof forwardedRef === 'function') {\n forwardedRef(localRef.current);\n } else if (forwardedRef && 'current' in forwardedRef) {\n forwardedRef.current = localRef.current;\n }\n}\n\n/**\n * Sets the 'autoFocusVisible' data attribute to 'false' on the current target of a mouse event.\n * This function is typically used to indicate that an element has been interacted with via mouse,\n * which should prevent the focus ring from being displayed when the element receives focus.\n *\n * @param mouseEvent - The mouse event object.\n */\nexport function addAutoFocusAttribute(mouseEvent: ReactMouseEvent<HTMLButtonElement, MouseEvent>) {\n mouseEvent.currentTarget.dataset.autoFocusVisible = 'false';\n}\n\n/**\n * Manages the focus ring visibility based on the previous focus state and the current focus event.\n * This function sets the 'showFocusRing' data attribute on the target element and updates the\n * 'autoFocusVisible' data attribute on the previously focused element.\n *\n * ! This function should be used in conjunction with the 'addAutoFocusAttribute' function and the autoFocusVisible data autoFocusTrigger.\n *\n * @param event - The focus event object.\n */\nexport function addShowFocusRing(event: FocusEvent<HTMLDivElement, HTMLElement>) {\n const triggerElement = event.relatedTarget;\n\n if (!triggerElement?.dataset.autoFocusTrigger) {\n return;\n }\n\n if (triggerElement.dataset.autoFocusVisible === 'true') {\n event.target.dataset.showFocusRing = 'true';\n } else {\n event.target.dataset.showFocusRing = 'false';\n }\n\n triggerElement.dataset.autoFocusVisible = 'true';\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"fondue-components37.js","sources":["../src/utilities/domUtilities.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type FocusEvent, type MouseEvent as ReactMouseEvent, type ForwardedRef, type RefObject } from 'react';\n\nexport const MAX_HEIGHT_MARGIN = 8;\n\n/**\n * Sets the maximum height for a dialog element based on its position on the viewport.\n * The function calculates the space below the dialog up to the bottom of the viewport window,\n * subtracting a default margin, and sets this value as the max-height style of the dialog.\n *\n * @param {HTMLElement} dialog - The dialog element whose maximum height is to be set.\n *\n * @example\n * // Suppose you have a dialog element with id 'my-dialog'.\n * const dialogElement = myDialogRef.current || document.getElementById('my-dialog');\n * // Setting its max height relative to its current position and the viewport's dimensions.\n * setMaxHeightToAvailableSpace(dialogElement);\n */\nexport function setMaxHeightToAvailableSpace(dialog: HTMLElement) {\n if (!window) {\n throw new Error('Window object not found, this method should be used in a browser environment');\n }\n\n dialog.style.maxHeight = '';\n\n const { top, bottom } = dialog.getBoundingClientRect();\n if (top - MAX_HEIGHT_MARGIN < 0) {\n // if the dialog is overflowing to the top\n dialog.style.maxHeight = `${bottom - MAX_HEIGHT_MARGIN}px`;\n } else if (bottom + MAX_HEIGHT_MARGIN > window.innerHeight) {\n // if the dialog is overflowing to the bottom\n dialog.style.maxHeight = `${window.innerHeight - top - MAX_HEIGHT_MARGIN}px`;\n }\n}\n\n/**\n * Checks if a specified HTML element is visible within the viewport.\n * Visibility is determined by several factors:\n * - The element must have non-zero dimensions.\n * - The element's computed style must not be `display: none`, `visibility: hidden`, or `opacity: 0`.\n * - The element must be within the bounds of the current viewport.\n *\n * @param {HTMLElement} element - The HTML element to check for visibility.\n * @returns {boolean} Returns true if the element is visible according to the criteria specified, otherwise returns false.\n */\nexport function isElementVisible(element: HTMLElement) {\n const rect = element.getBoundingClientRect();\n const hasSize = rect.width > 0 && rect.height > 0;\n\n const style = window.getComputedStyle(element);\n const isVisibleStyle = style.display !== 'none' && style.visibility !== 'hidden' && parseFloat(style.opacity) !== 0;\n\n // Check if the element is within the viewport\n const isInViewport =\n rect.top < window.innerHeight && rect.left < window.innerWidth && rect.bottom > 0 && rect.right > 0;\n\n return hasSize && isVisibleStyle && isInViewport;\n}\n\n/**\n * Assigns a local DOM ref to a forwarded ref.\n *\n * @param {RefObject<HTMLDivElement>} localRef - The local React reference to an HTMLDivElement.\n * @param {ForwardedRef<HTMLDivElement>} forwardedRef - The ref forwarded from a parent component.\n */\nexport function syncRefs<TElement = HTMLElement>(localRef: RefObject<TElement>, forwardedRef: ForwardedRef<TElement>) {\n if (!forwardedRef) {\n return;\n }\n\n if (typeof forwardedRef === 'function') {\n forwardedRef(localRef.current);\n } else if (forwardedRef && 'current' in forwardedRef) {\n forwardedRef.current = localRef.current;\n }\n}\n\n/**\n * Sets the 'autoFocusVisible' data attribute to 'false' on the current target of a mouse event.\n * This function is typically used to indicate that an element has been interacted with via mouse,\n * which should prevent the focus ring from being displayed when the element receives focus.\n *\n * @param mouseEvent - The mouse event object.\n */\nexport function addAutoFocusAttribute(mouseEvent: ReactMouseEvent<HTMLButtonElement, MouseEvent>) {\n mouseEvent.currentTarget.dataset.autoFocusVisible = 'false';\n}\n\n/**\n * Manages the focus ring visibility based on the previous focus state and the current focus event.\n * This function sets the 'showFocusRing' data attribute on the target element and updates the\n * 'autoFocusVisible' data attribute on the previously focused element.\n *\n * ! This function should be used in conjunction with the 'addAutoFocusAttribute' function and the autoFocusVisible data autoFocusTrigger.\n *\n * @param event - The focus event object.\n */\nexport function addShowFocusRing(event: FocusEvent<HTMLDivElement, HTMLElement>) {\n const triggerElement = event.relatedTarget;\n\n if (!triggerElement?.dataset.autoFocusTrigger) {\n return;\n }\n\n if (triggerElement.dataset.autoFocusVisible === 'true') {\n event.target.dataset.showFocusRing = 'true';\n } else {\n event.target.dataset.showFocusRing = 'false';\n }\n\n triggerElement.dataset.autoFocusVisible = 'true';\n}\n"],"names":["syncRefs","localRef","forwardedRef","addAutoFocusAttribute","mouseEvent","addShowFocusRing","event","triggerElement"],"mappings":"AAkEgB,SAAAA,EAAiCC,GAA+BC,GAAsC;AAClH,EAAKA,MAID,OAAOA,KAAiB,aACxBA,EAAaD,EAAS,OAAO,IACtBC,KAAgB,aAAaA,MACpCA,EAAa,UAAUD,EAAS;AAExC;AASO,SAASE,EAAsBC,GAA4D;AACnF,EAAAA,EAAA,cAAc,QAAQ,mBAAmB;AACxD;AAWO,SAASC,EAAiBC,GAAgD;AAC7E,QAAMC,IAAiBD,EAAM;AAEzB,EAACC,KAAA,QAAAA,EAAgB,QAAQ,qBAIzBA,EAAe,QAAQ,qBAAqB,SACtCD,EAAA,OAAO,QAAQ,gBAAgB,SAE/BA,EAAA,OAAO,QAAQ,gBAAgB,SAGzCC,EAAe,QAAQ,mBAAmB;AAC9C;"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as c, isValidElement as r, cloneElement as i, Children as p } from "react";
|
|
3
|
+
const o = (e) => {
|
|
4
|
+
const t = [];
|
|
5
|
+
for (const n of p.toArray(e))
|
|
6
|
+
r(n) ? t.push(n) : t.push(/* @__PURE__ */ s("span", { children: n }));
|
|
7
|
+
return t.length === 1 ? t[0] : t;
|
|
8
|
+
}, u = (e) => c(() => {
|
|
9
|
+
const t = r(e) && e.type === "a";
|
|
10
|
+
if (t) {
|
|
11
|
+
const n = i(e, {
|
|
12
|
+
children: o(e.props.children)
|
|
7
13
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
setMaxHeight: e
|
|
13
|
-
};
|
|
14
|
-
}
|
|
14
|
+
return { isLink: t, content: n };
|
|
15
|
+
}
|
|
16
|
+
return { isLink: t, content: o(e) };
|
|
17
|
+
}, [e]);
|
|
15
18
|
export {
|
|
16
|
-
u as
|
|
19
|
+
u as useProcessedChildren
|
|
17
20
|
};
|
|
18
21
|
//# sourceMappingURL=fondue-components40.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components40.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"fondue-components40.js","sources":["../src/components/Dropdown/hooks/useProcessedChildren.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Children, cloneElement, isValidElement, type ReactNode, useMemo } from 'react';\n\nconst wrapFloatingText = (children: ReactNode) => {\n const content = [];\n for (const child of Children.toArray(children)) {\n if (isValidElement(child)) {\n content.push(child);\n } else {\n content.push(<span>{child}</span>);\n }\n }\n return content.length === 1 ? content[0] : content;\n};\n\nexport const useProcessedChildren = (children: ReactNode) => {\n return useMemo(() => {\n const isLink =\n isValidElement<{\n children: ReactNode;\n }>(children) && children.type === 'a';\n\n if (isLink) {\n const element = cloneElement(children, {\n children: wrapFloatingText(children.props.children),\n });\n return { isLink, content: element };\n }\n\n return { isLink, content: wrapFloatingText(children) };\n }, [children]);\n};\n"],"names":["wrapFloatingText","children","content","child","Children","isValidElement","jsx","useProcessedChildren","useMemo","isLink","element","cloneElement"],"mappings":";;AAIA,MAAMA,IAAmB,CAACC,MAAwB;AAC9C,QAAMC,IAAU,CAAC;AACjB,aAAWC,KAASC,EAAS,QAAQH,CAAQ;AACrC,IAAAI,EAAeF,CAAK,IACpBD,EAAQ,KAAKC,CAAK,IAElBD,EAAQ,KAAK,gBAAAI,EAAC,QAAM,EAAA,UAAAH,EAAA,CAAM,CAAO;AAGzC,SAAOD,EAAQ,WAAW,IAAIA,EAAQ,CAAC,IAAIA;AAC/C,GAEaK,IAAuB,CAACN,MAC1BO,EAAQ,MAAM;AACjB,QAAMC,IACFJ,EAEGJ,CAAQ,KAAKA,EAAS,SAAS;AAEtC,MAAIQ,GAAQ;AACF,UAAAC,IAAUC,EAAaV,GAAU;AAAA,MACnC,UAAUD,EAAiBC,EAAS,MAAM,QAAQ;AAAA,IAAA,CACrD;AACM,WAAA,EAAE,QAAAQ,GAAQ,SAASC,EAAQ;AAAA,EAAA;AAGtC,SAAO,EAAE,QAAAD,GAAQ,SAAST,EAAiBC,CAAQ,EAAE;AAAA,GACtD,CAACA,CAAQ,CAAC;"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (t) {
|
|
11
|
-
const n = i(e, {
|
|
12
|
-
children: o(e.props.children)
|
|
13
|
-
});
|
|
14
|
-
return { isLink: t, content: n };
|
|
15
|
-
}
|
|
16
|
-
return { isLink: t, content: o(e) };
|
|
17
|
-
}, [e]);
|
|
1
|
+
const t = "_content_cv72f_5", n = "_subContent_cv72f_6", o = "_item_cv72f_20", s = "_subTrigger_cv72f_20", c = "_subMenuIndicator_cv72f_102", _ = "_group_cv72f_108", e = "_slot_cv72f_115", u = {
|
|
2
|
+
content: t,
|
|
3
|
+
subContent: n,
|
|
4
|
+
item: o,
|
|
5
|
+
subTrigger: s,
|
|
6
|
+
subMenuIndicator: c,
|
|
7
|
+
group: _,
|
|
8
|
+
slot: e
|
|
9
|
+
};
|
|
18
10
|
export {
|
|
19
|
-
|
|
11
|
+
t as content,
|
|
12
|
+
u as default,
|
|
13
|
+
_ as group,
|
|
14
|
+
o as item,
|
|
15
|
+
e as slot,
|
|
16
|
+
n as subContent,
|
|
17
|
+
c as subMenuIndicator,
|
|
18
|
+
s as subTrigger
|
|
20
19
|
};
|
|
21
20
|
//# sourceMappingURL=fondue-components41.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components41.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components41.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
subContent: n,
|
|
4
|
-
item: o,
|
|
5
|
-
subTrigger: s,
|
|
6
|
-
subMenuIndicator: _,
|
|
7
|
-
group: e,
|
|
8
|
-
slot: b
|
|
1
|
+
const o = "_root_gh190_5", t = {
|
|
2
|
+
root: o
|
|
9
3
|
};
|
|
10
4
|
export {
|
|
11
|
-
t as
|
|
12
|
-
|
|
13
|
-
e as group,
|
|
14
|
-
o as item,
|
|
15
|
-
b as slot,
|
|
16
|
-
n as subContent,
|
|
17
|
-
_ as subMenuIndicator,
|
|
18
|
-
s as subTrigger
|
|
5
|
+
t as default,
|
|
6
|
+
o as root
|
|
19
7
|
};
|
|
20
8
|
//# sourceMappingURL=fondue-components42.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components42.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components42.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
const o = "
|
|
2
|
-
root: o
|
|
1
|
+
const o = "_root_15cpq_5", e = "_overlay_15cpq_42", _ = "_header_15cpq_59", c = "_body_15cpq_79", t = "_footer_15cpq_97", r = "_close_15cpq_117", s = {
|
|
2
|
+
root: o,
|
|
3
|
+
overlay: e,
|
|
4
|
+
header: _,
|
|
5
|
+
body: c,
|
|
6
|
+
footer: t,
|
|
7
|
+
close: r
|
|
3
8
|
};
|
|
4
9
|
export {
|
|
5
|
-
|
|
10
|
+
c as body,
|
|
11
|
+
r as close,
|
|
12
|
+
s as default,
|
|
13
|
+
t as footer,
|
|
14
|
+
_ as header,
|
|
15
|
+
e as overlay,
|
|
6
16
|
o as root
|
|
7
17
|
};
|
|
8
18
|
//# sourceMappingURL=fondue-components43.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components43.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components43.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
const o = "
|
|
2
|
-
root: o
|
|
3
|
-
overlay: e,
|
|
4
|
-
header: _,
|
|
5
|
-
body: t,
|
|
6
|
-
footer: r,
|
|
7
|
-
close: s
|
|
1
|
+
const o = "_root_umks5_5", t = {
|
|
2
|
+
root: o
|
|
8
3
|
};
|
|
9
4
|
export {
|
|
10
|
-
t as
|
|
11
|
-
s as close,
|
|
12
|
-
c as default,
|
|
13
|
-
r as footer,
|
|
14
|
-
_ as header,
|
|
15
|
-
e as overlay,
|
|
5
|
+
t as default,
|
|
16
6
|
o as root
|
|
17
7
|
};
|
|
18
8
|
//# sourceMappingURL=fondue-components44.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components44.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components44.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,8 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { sv as t } from "./fondue-components27.js";
|
|
2
|
+
const i = t({
|
|
3
|
+
base: "tw-relative tw-w-full tw-overflow-hidden",
|
|
4
|
+
variants: {
|
|
5
|
+
rounded: {
|
|
6
|
+
true: "tw-rounded"
|
|
7
|
+
},
|
|
8
|
+
size: {
|
|
9
|
+
small: "tw-h-1",
|
|
10
|
+
medium: "tw-h-2",
|
|
11
|
+
large: "tw-h-3",
|
|
12
|
+
"x-large": "tw-h-4"
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
default: "tw-bg-box-selected",
|
|
16
|
+
positive: "tw-bg-box-positive",
|
|
17
|
+
negative: "tw-bg-box-negative"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}), a = t({
|
|
21
|
+
base: "tw-h-full tw-w-full",
|
|
22
|
+
variants: {
|
|
23
|
+
variant: {
|
|
24
|
+
default: "tw-bg-text-interactive",
|
|
25
|
+
positive: "tw-bg-text-positive",
|
|
26
|
+
negative: "tw-bg-text-negative"
|
|
27
|
+
},
|
|
28
|
+
indeterminateState: {
|
|
29
|
+
true: "tw-animate-loading-bar-infinite tw-origin-left-right",
|
|
30
|
+
false: "tw-transition-all tw-origin-left tw-scale-x-[--loading-bar-proportion]"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
4
34
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
35
|
+
i as loadingBarContainerStyles,
|
|
36
|
+
a as loadingBarStyles
|
|
7
37
|
};
|
|
8
38
|
//# sourceMappingURL=fondue-components45.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components45.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components45.js","sources":["../src/components/LoadingBar/styles/loadingBarStyles.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { sv } from '#/utilities/styleUtilities';\n\nexport const loadingBarContainerStyles = sv({\n base: 'tw-relative tw-w-full tw-overflow-hidden',\n variants: {\n rounded: {\n true: 'tw-rounded',\n },\n size: {\n small: 'tw-h-1',\n medium: 'tw-h-2',\n large: 'tw-h-3',\n 'x-large': 'tw-h-4',\n },\n variant: {\n default: 'tw-bg-box-selected',\n positive: 'tw-bg-box-positive',\n negative: 'tw-bg-box-negative',\n },\n },\n});\n\nexport const loadingBarStyles = sv({\n base: 'tw-h-full tw-w-full',\n variants: {\n variant: {\n default: 'tw-bg-text-interactive',\n positive: 'tw-bg-text-positive',\n negative: 'tw-bg-text-negative',\n },\n indeterminateState: {\n true: 'tw-animate-loading-bar-infinite tw-origin-left-right',\n false: 'tw-transition-all tw-origin-left tw-scale-x-[--loading-bar-proportion]',\n },\n },\n});\n"],"names":["loadingBarContainerStyles","sv","loadingBarStyles"],"mappings":";AAIO,MAAMA,IAA4BC,EAAG;AAAA,EACxC,MAAM;AAAA,EACN,UAAU;AAAA,IACN,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,IACA,MAAM;AAAA,MACF,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,WAAW;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACL,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,IAAA;AAAA,EACd;AAER,CAAC,GAEYC,IAAmBD,EAAG;AAAA,EAC/B,MAAM;AAAA,EACN,UAAU;AAAA,IACN,SAAS;AAAA,MACL,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,IACd;AAAA,IACA,oBAAoB;AAAA,MAChB,MAAM;AAAA,MACN,OAAO;AAAA,IAAA;AAAA,EACX;AAER,CAAC;"}
|
|
@@ -1,38 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
size: {
|
|
9
|
-
small: "tw-h-1",
|
|
10
|
-
medium: "tw-h-2",
|
|
11
|
-
large: "tw-h-3",
|
|
12
|
-
"x-large": "tw-h-4"
|
|
13
|
-
},
|
|
14
|
-
variant: {
|
|
15
|
-
default: "tw-bg-box-selected",
|
|
16
|
-
positive: "tw-bg-box-positive",
|
|
17
|
-
negative: "tw-bg-box-negative"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}), a = t({
|
|
21
|
-
base: "tw-h-full tw-w-full",
|
|
22
|
-
variants: {
|
|
23
|
-
variant: {
|
|
24
|
-
default: "tw-bg-text-interactive",
|
|
25
|
-
positive: "tw-bg-text-positive",
|
|
26
|
-
negative: "tw-bg-text-negative"
|
|
27
|
-
},
|
|
28
|
-
indeterminateState: {
|
|
29
|
-
true: "tw-animate-loading-bar-infinite tw-origin-left-right",
|
|
30
|
-
false: "tw-transition-all tw-origin-left tw-scale-x-[--loading-bar-proportion]"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
1
|
+
const o = "_root_uxsne_3", r = "_viewport_uxsne_10", t = "_scrollbar_uxsne_19", s = "_thumb_uxsne_51", _ = "_corner_uxsne_69", e = {
|
|
2
|
+
root: o,
|
|
3
|
+
viewport: r,
|
|
4
|
+
scrollbar: t,
|
|
5
|
+
thumb: s,
|
|
6
|
+
corner: _
|
|
7
|
+
};
|
|
34
8
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
_ as corner,
|
|
10
|
+
e as default,
|
|
11
|
+
o as root,
|
|
12
|
+
t as scrollbar,
|
|
13
|
+
s as thumb,
|
|
14
|
+
r as viewport
|
|
37
15
|
};
|
|
38
16
|
//# sourceMappingURL=fondue-components46.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components46.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components46.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
const o = "
|
|
2
|
-
root: o
|
|
3
|
-
viewport: r,
|
|
4
|
-
scrollbar: t,
|
|
5
|
-
thumb: s,
|
|
6
|
-
corner: _
|
|
1
|
+
const o = "_root_yrjuz_5", t = {
|
|
2
|
+
root: o
|
|
7
3
|
};
|
|
8
4
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o as root,
|
|
12
|
-
t as scrollbar,
|
|
13
|
-
s as thumb,
|
|
14
|
-
r as viewport
|
|
5
|
+
t as default,
|
|
6
|
+
o as root
|
|
15
7
|
};
|
|
16
8
|
//# sourceMappingURL=fondue-components47.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components47.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components47.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { useMemo as f, useCallback as d, useState as v, useRef as S, useEffect as m } from "react";
|
|
2
|
+
const U = ({
|
|
3
|
+
prop: e,
|
|
4
|
+
defaultProp: n,
|
|
5
|
+
onChange: s = () => {
|
|
6
|
+
}
|
|
7
|
+
}) => {
|
|
8
|
+
const [o, c] = b({ defaultProp: n, onChange: s }), t = e !== void 0, i = t ? e : o, r = f(() => s, [s]), a = d(
|
|
9
|
+
(l) => {
|
|
10
|
+
if (t) {
|
|
11
|
+
const u = typeof l == "function" ? l(e) : l;
|
|
12
|
+
u !== e && r(u);
|
|
13
|
+
} else
|
|
14
|
+
c(l);
|
|
15
|
+
},
|
|
16
|
+
[t, e, c, r]
|
|
17
|
+
);
|
|
18
|
+
return [i, a];
|
|
19
|
+
}, b = ({ defaultProp: e, onChange: n }) => {
|
|
20
|
+
const s = v(e), [o] = s, c = S(o), t = f(() => n, [n]);
|
|
21
|
+
return m(() => {
|
|
22
|
+
c.current !== o && (t == null || t(o), c.current = o);
|
|
23
|
+
}, [o, c, t]), s;
|
|
3
24
|
};
|
|
4
25
|
export {
|
|
5
|
-
|
|
6
|
-
o as root
|
|
26
|
+
U as useControllableState
|
|
7
27
|
};
|
|
8
28
|
//# sourceMappingURL=fondue-components48.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components48.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components48.js","sources":["../src/hooks/useControllableState.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type Dispatch, type SetStateAction, useCallback, useMemo, useState, useRef, useEffect } from 'react';\n\n// Radix UI handy hook for handling controlled and uncontrolled state\n// Source: https://github.com/radix-ui/primitives/blob/main/packages/react/use-controllable-state/src/useControllableState.tsx\n\ntype UseControllableStateParams<TValue> = {\n prop?: TValue;\n defaultProp?: TValue;\n onChange?: (state: TValue) => void;\n};\n\ntype SetStateFn<T> = (prevState?: T) => T;\n\nexport const useControllableState = <TValue>({\n prop,\n defaultProp,\n onChange = () => {},\n}: UseControllableStateParams<TValue>) => {\n const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });\n const isControlled = prop !== undefined;\n const value = isControlled ? prop : uncontrolledProp;\n const handleChange = useMemo(() => onChange, [onChange]);\n\n const setValue: Dispatch<SetStateAction<TValue | undefined>> = useCallback(\n (nextValue) => {\n if (isControlled) {\n const setter = nextValue as SetStateFn<TValue>;\n const value = typeof nextValue === 'function' ? setter(prop) : nextValue;\n if (value !== prop) {\n handleChange(value as TValue);\n }\n } else {\n setUncontrolledProp(nextValue);\n }\n },\n [isControlled, prop, setUncontrolledProp, handleChange],\n );\n\n return [value, setValue] as const;\n};\n\nconst useUncontrolledState = <TValue>({ defaultProp, onChange }: Omit<UseControllableStateParams<TValue>, 'prop'>) => {\n const uncontrolledState = useState<TValue | undefined>(defaultProp);\n const [value] = uncontrolledState;\n const prevValueRef = useRef(value);\n const handleChange = useMemo(() => onChange, [onChange]);\n\n useEffect(() => {\n if (prevValueRef.current !== value) {\n handleChange?.(value as TValue);\n prevValueRef.current = value;\n }\n }, [value, prevValueRef, handleChange]);\n\n return uncontrolledState;\n};\n"],"names":["useControllableState","prop","defaultProp","onChange","uncontrolledProp","setUncontrolledProp","useUncontrolledState","isControlled","value","handleChange","useMemo","setValue","useCallback","nextValue","uncontrolledState","useState","prevValueRef","useRef","useEffect"],"mappings":";AAeO,MAAMA,IAAuB,CAAS;AAAA,EACzC,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC,IAAW,MAAM;AAAA,EAAA;AACrB,MAA0C;AAChC,QAAA,CAACC,GAAkBC,CAAmB,IAAIC,EAAqB,EAAE,aAAAJ,GAAa,UAAAC,GAAU,GACxFI,IAAeN,MAAS,QACxBO,IAAQD,IAAeN,IAAOG,GAC9BK,IAAeC,EAAQ,MAAMP,GAAU,CAACA,CAAQ,CAAC,GAEjDQ,IAAyDC;AAAA,IAC3D,CAACC,MAAc;AACX,UAAIN,GAAc;AAEd,cAAMC,IAAQ,OAAOK,KAAc,aADpBA,EACwCZ,CAAI,IAAIY;AAC/D,QAAIL,MAAUP,KACVQ,EAAaD,CAAe;AAAA,MAChC;AAEA,QAAAH,EAAoBQ,CAAS;AAAA,IAErC;AAAA,IACA,CAACN,GAAcN,GAAMI,GAAqBI,CAAY;AAAA,EAC1D;AAEO,SAAA,CAACD,GAAOG,CAAQ;AAC3B,GAEML,IAAuB,CAAS,EAAE,aAAAJ,GAAa,UAAAC,QAAiE;AAC5G,QAAAW,IAAoBC,EAA6Bb,CAAW,GAC5D,CAACM,CAAK,IAAIM,GACVE,IAAeC,EAAOT,CAAK,GAC3BC,IAAeC,EAAQ,MAAMP,GAAU,CAACA,CAAQ,CAAC;AAEvD,SAAAe,EAAU,MAAM;AACR,IAAAF,EAAa,YAAYR,MACzBC,KAAA,QAAAA,EAAeD,IACfQ,EAAa,UAAUR;AAAA,EAE5B,GAAA,CAACA,GAAOQ,GAAcP,CAAY,CAAC,GAE/BK;AACX;"}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
(l) => {
|
|
10
|
-
if (t) {
|
|
11
|
-
const u = typeof l == "function" ? l(e) : l;
|
|
12
|
-
u !== e && r(u);
|
|
13
|
-
} else
|
|
14
|
-
c(l);
|
|
15
|
-
},
|
|
16
|
-
[t, e, c, r]
|
|
17
|
-
);
|
|
18
|
-
return [i, a];
|
|
19
|
-
}, b = ({ defaultProp: e, onChange: n }) => {
|
|
20
|
-
const s = v(e), [o] = s, c = S(o), t = f(() => n, [n]);
|
|
21
|
-
return m(() => {
|
|
22
|
-
c.current !== o && (t == null || t(o), c.current = o);
|
|
23
|
-
}, [o, c, t]), s;
|
|
1
|
+
const t = "_root_2wdi8_5", e = "_item_2wdi8_26", i = "_itemLabel_2wdi8_46", a = "_itemLabelActive_2wdi8_65", o = "_itemLabelInactive_2wdi8_94", _ = "_activeIndicator_2wdi8_124", c = "_separator_2wdi8_221", n = {
|
|
2
|
+
root: t,
|
|
3
|
+
item: e,
|
|
4
|
+
itemLabel: i,
|
|
5
|
+
itemLabelActive: a,
|
|
6
|
+
itemLabelInactive: o,
|
|
7
|
+
activeIndicator: _,
|
|
8
|
+
separator: c
|
|
24
9
|
};
|
|
25
10
|
export {
|
|
26
|
-
|
|
11
|
+
_ as activeIndicator,
|
|
12
|
+
n as default,
|
|
13
|
+
e as item,
|
|
14
|
+
i as itemLabel,
|
|
15
|
+
a as itemLabelActive,
|
|
16
|
+
o as itemLabelInactive,
|
|
17
|
+
t as root,
|
|
18
|
+
c as separator
|
|
27
19
|
};
|
|
28
20
|
//# sourceMappingURL=fondue-components49.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components49.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components49.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|