@frontify/fondue-components 7.0.0 → 8.0.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.
Files changed (90) hide show
  1. package/dist/fondue-components10.js +31 -27
  2. package/dist/fondue-components10.js.map +1 -1
  3. package/dist/fondue-components11.js +75 -72
  4. package/dist/fondue-components11.js.map +1 -1
  5. package/dist/fondue-components12.js +29 -26
  6. package/dist/fondue-components12.js.map +1 -1
  7. package/dist/fondue-components14.js +1 -1
  8. package/dist/fondue-components15.js +1 -1
  9. package/dist/fondue-components16.js +32 -29
  10. package/dist/fondue-components16.js.map +1 -1
  11. package/dist/fondue-components17.js +2 -2
  12. package/dist/fondue-components18.js +6 -6
  13. package/dist/fondue-components19.js +1 -1
  14. package/dist/fondue-components20.js +1 -1
  15. package/dist/fondue-components21.js +4 -4
  16. package/dist/fondue-components22.js +3 -3
  17. package/dist/fondue-components23.js +1 -1
  18. package/dist/fondue-components24.js +1 -1
  19. package/dist/fondue-components25.js +8 -8
  20. package/dist/fondue-components25.js.map +1 -1
  21. package/dist/fondue-components28.js +1 -1
  22. package/dist/fondue-components3.js +28 -25
  23. package/dist/fondue-components3.js.map +1 -1
  24. package/dist/fondue-components31.js +1 -1
  25. package/dist/fondue-components33.js +1 -1
  26. package/dist/fondue-components41.js +18 -19
  27. package/dist/fondue-components41.js.map +1 -1
  28. package/dist/fondue-components42.js +16 -4
  29. package/dist/fondue-components42.js.map +1 -1
  30. package/dist/fondue-components43.js +3 -11
  31. package/dist/fondue-components43.js.map +1 -1
  32. package/dist/fondue-components44.js +13 -3
  33. package/dist/fondue-components44.js.map +1 -1
  34. package/dist/fondue-components45.js +5 -35
  35. package/dist/fondue-components45.js.map +1 -1
  36. package/dist/fondue-components46.js +35 -13
  37. package/dist/fondue-components46.js.map +1 -1
  38. package/dist/fondue-components47.js +12 -4
  39. package/dist/fondue-components47.js.map +1 -1
  40. package/dist/fondue-components48.js +4 -24
  41. package/dist/fondue-components48.js.map +1 -1
  42. package/dist/fondue-components49.js +24 -16
  43. package/dist/fondue-components49.js.map +1 -1
  44. package/dist/fondue-components50.js +16 -139
  45. package/dist/fondue-components50.js.map +1 -1
  46. package/dist/fondue-components51.js +140 -16
  47. package/dist/fondue-components51.js.map +1 -1
  48. package/dist/fondue-components52.js +16 -72
  49. package/dist/fondue-components52.js.map +1 -1
  50. package/dist/fondue-components53.js +72 -8
  51. package/dist/fondue-components53.js.map +1 -1
  52. package/dist/fondue-components54.js +8 -33
  53. package/dist/fondue-components54.js.map +1 -1
  54. package/dist/fondue-components55.js +32 -48
  55. package/dist/fondue-components55.js.map +1 -1
  56. package/dist/fondue-components56.js +48 -10
  57. package/dist/fondue-components56.js.map +1 -1
  58. package/dist/fondue-components57.js +8 -10
  59. package/dist/fondue-components57.js.map +1 -1
  60. package/dist/fondue-components58.js +12 -7
  61. package/dist/fondue-components58.js.map +1 -1
  62. package/dist/fondue-components59.js +7 -12
  63. package/dist/fondue-components59.js.map +1 -1
  64. package/dist/fondue-components60.js +12 -18
  65. package/dist/fondue-components60.js.map +1 -1
  66. package/dist/fondue-components61.js +19 -15
  67. package/dist/fondue-components61.js.map +1 -1
  68. package/dist/fondue-components62.js +14 -52
  69. package/dist/fondue-components62.js.map +1 -1
  70. package/dist/fondue-components63.js +52 -14
  71. package/dist/fondue-components63.js.map +1 -1
  72. package/dist/fondue-components64.js +12 -15
  73. package/dist/fondue-components64.js.map +1 -1
  74. package/dist/fondue-components65.js +17 -6
  75. package/dist/fondue-components65.js.map +1 -1
  76. package/dist/fondue-components66.js +7 -2
  77. package/dist/fondue-components66.js.map +1 -1
  78. package/dist/fondue-components67.js +2 -15
  79. package/dist/fondue-components67.js.map +1 -1
  80. package/dist/fondue-components68.js +14 -38
  81. package/dist/fondue-components68.js.map +1 -1
  82. package/dist/fondue-components69.js +42 -0
  83. package/dist/fondue-components69.js.map +1 -0
  84. package/dist/fondue-components8.js +28 -28
  85. package/dist/fondue-components8.js.map +1 -1
  86. package/dist/fondue-components9.js +102 -92
  87. package/dist/fondue-components9.js.map +1 -1
  88. package/dist/index.d.ts +122 -138
  89. package/dist/style.css +1 -1
  90. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const g = (t) => t.startsWith("aria-") || t === "role", s = {
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 = (t, n) => (t === "columns" || t === "rows") && typeof n == "number" ? `repeat(${n}, 1fr)` : n, l = (t, n = {}) => Object.entries(t).reduce((i, [r, o]) => {
22
- if (g(r))
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 = r in n ? n[r] : r in s ? s[r] : r, a = e == null ? void 0 : e.replaceAll(/([\da-z]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
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, p] of Object.entries(o))
27
- p !== void 0 && (i[`--${d}-${a}`] = m(r, p));
26
+ for (const [d, a] of Object.entries(o))
27
+ a !== void 0 && (i[`--${d}-${p}`] = m(t, a));
28
28
  else
29
- i[`--${a}`] = m(r, o);
29
+ i[`--${p}`] = m(t, o);
30
30
  return i;
31
31
  }, {});
32
32
  export {
33
- l as propsToCssVariables
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,OACvCH,MAAQ,aAAaA,MAAQ,WACzB,OAAOG,KAAU,WACV,UAAUA,CAAK,WAIvBA,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
+ {"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-components66.js";
1
+ import { FOCUS_OUTLINE as t } from "./fondue-components67.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,33 +1,36 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
+ import { forwardRef as f } from "react";
2
3
  import { propsToCssVariables as n } from "./fondue-components25.js";
3
4
  import x from "./fondue-components26.js";
4
- const y = ({
5
- as: a = "div",
6
- "data-test-id": e = "fondue-box",
7
- children: r,
8
- role: i,
9
- "aria-label": d,
10
- "aria-hidden": s,
11
- "aria-describedby": o,
12
- "aria-labelledby": l,
13
- "aria-expanded": p,
14
- "aria-haspopup": t,
15
- ...b
16
- }) => /* @__PURE__ */ m(
17
- a,
18
- {
19
- className: x.root,
20
- "data-test-id": e,
21
- style: n(b),
5
+ const y = f(
6
+ ({
7
+ as: a = "div",
8
+ "data-test-id": r = "fondue-box",
9
+ children: e,
22
10
  role: i,
23
11
  "aria-label": d,
24
- "aria-hidden": s,
25
- "aria-describedby": o,
26
- "aria-labelledby": l,
27
- "aria-expanded": p,
28
- "aria-haspopup": t,
29
- children: r
30
- }
12
+ "aria-hidden": o,
13
+ "aria-describedby": s,
14
+ "aria-labelledby": p,
15
+ "aria-expanded": t,
16
+ "aria-haspopup": l,
17
+ ...b
18
+ }) => /* @__PURE__ */ m(
19
+ a,
20
+ {
21
+ className: x.root,
22
+ "data-test-id": r,
23
+ style: n(b),
24
+ role: i,
25
+ "aria-label": d,
26
+ "aria-hidden": o,
27
+ "aria-describedby": s,
28
+ "aria-labelledby": p,
29
+ "aria-expanded": t,
30
+ "aria-haspopup": l,
31
+ children: e
32
+ }
33
+ )
31
34
  );
32
35
  y.displayName = "Box";
33
36
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components3.js","sources":["../src/components/Box/Box.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { type Responsive, type LayoutComponentProps } from '#/helpers/layout';\nimport { propsToCssVariables } from '#/helpers/propsToCssVariables';\n\nimport styles from './styles/box.module.scss';\n\nexport type BoxProps = LayoutComponentProps & {\n /**\n * The element to render the Box component as.\n * @default 'div'\n */\n as?: 'div' | 'span';\n /**\n * The display property.\n * @default 'block'\n */\n display?: Responsive<'none' | 'block' | 'inline-block' | 'inline'>;\n\n children?: ReactNode;\n 'data-test-id'?: string;\n} & CommonAriaProps;\n\nexport const Box = ({\n as: Component = 'div',\n 'data-test-id': dataTestId = 'fondue-box',\n children,\n role,\n 'aria-label': ariaLabel,\n 'aria-hidden': ariaHidden,\n 'aria-describedby': ariaDescribedBy,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-expanded': ariaExpanded,\n 'aria-haspopup': ariaHasPopup,\n ...props\n}: BoxProps) => {\n return (\n <Component\n className={styles.root}\n data-test-id={dataTestId}\n style={propsToCssVariables(props)}\n role={role}\n aria-label={ariaLabel}\n aria-hidden={ariaHidden}\n aria-describedby={ariaDescribedBy}\n aria-labelledby={ariaLabelledBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n >\n {children}\n </Component>\n );\n};\nBox.displayName = 'Box';\n"],"names":["Box","Component","dataTestId","children","role","ariaLabel","ariaHidden","ariaDescribedBy","ariaLabelledBy","ariaExpanded","ariaHasPopup","props","jsx","styles","propsToCssVariables"],"mappings":";;;AA0BO,MAAMA,IAAM,CAAC;AAAA,EAChB,IAAIC,IAAY;AAAA,EAChB,gBAAgBC,IAAa;AAAA,EAC7B,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAcC;AAAA,EACd,eAAeC;AAAA,EACf,oBAAoBC;AAAA,EACpB,mBAAmBC;AAAA,EACnB,iBAAiBC;AAAA,EACjB,iBAAiBC;AAAA,EACjB,GAAGC;AACP,MAEQ,gBAAAC;AAAA,EAACX;AAAA,EAAA;AAAA,IACG,WAAWY,EAAO;AAAA,IAClB,gBAAcX;AAAA,IACd,OAAOY,EAAoBH,CAAK;AAAA,IAChC,MAAAP;AAAA,IACA,cAAYC;AAAA,IACZ,eAAaC;AAAA,IACb,oBAAkBC;AAAA,IAClB,mBAAiBC;AAAA,IACjB,iBAAeC;AAAA,IACf,iBAAeC;AAAA,IAEd,UAAAP;AAAA,EAAA;AACL;AAGRH,EAAI,cAAc;"}
1
+ {"version":3,"file":"fondue-components3.js","sources":["../src/components/Box/Box.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { forwardRef, type ReactNode } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { type Responsive, type LayoutComponentProps } from '#/helpers/layout';\nimport { propsToCssVariables } from '#/helpers/propsToCssVariables';\n\nimport styles from './styles/box.module.scss';\n\nexport type BoxProps = LayoutComponentProps & {\n /**\n * The element to render the Box component as.\n * @default 'div'\n */\n as?: 'div' | 'span';\n /**\n * The display property.\n * @default 'block'\n */\n display?: Responsive<'none' | 'block' | 'inline-block' | 'inline'>;\n\n children?: ReactNode;\n 'data-test-id'?: string;\n} & CommonAriaProps;\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n ({\n as: Component = 'div',\n 'data-test-id': dataTestId = 'fondue-box',\n children,\n role,\n 'aria-label': ariaLabel,\n 'aria-hidden': ariaHidden,\n 'aria-describedby': ariaDescribedBy,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-expanded': ariaExpanded,\n 'aria-haspopup': ariaHasPopup,\n ...props\n }: BoxProps) => {\n return (\n <Component\n className={styles.root}\n data-test-id={dataTestId}\n style={propsToCssVariables(props)}\n role={role}\n aria-label={ariaLabel}\n aria-hidden={ariaHidden}\n aria-describedby={ariaDescribedBy}\n aria-labelledby={ariaLabelledBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n >\n {children}\n </Component>\n );\n },\n);\nBox.displayName = 'Box';\n"],"names":["Box","forwardRef","Component","dataTestId","children","role","ariaLabel","ariaHidden","ariaDescribedBy","ariaLabelledBy","ariaExpanded","ariaHasPopup","props","jsx","styles","propsToCssVariables"],"mappings":";;;;AA0BO,MAAMA,IAAMC;AAAA,EACf,CAAC;AAAA,IACG,IAAIC,IAAY;AAAA,IAChB,gBAAgBC,IAAa;AAAA,IAC7B,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAcC;AAAA,IACd,eAAeC;AAAA,IACf,oBAAoBC;AAAA,IACpB,mBAAmBC;AAAA,IACnB,iBAAiBC;AAAA,IACjB,iBAAiBC;AAAA,IACjB,GAAGC;AAAA,EAAA,MAGC,gBAAAC;AAAA,IAACX;AAAA,IAAA;AAAA,MACG,WAAWY,EAAO;AAAA,MAClB,gBAAcX;AAAA,MACd,OAAOY,EAAoBH,CAAK;AAAA,MAChC,MAAAP;AAAA,MACA,cAAYC;AAAA,MACZ,eAAaC;AAAA,MACb,oBAAkBC;AAAA,MAClB,mBAAiBC;AAAA,MACjB,iBAAeC;AAAA,MACf,iBAAeC;AAAA,MAEd,UAAAP;AAAA,IAAA;AAAA,EACL;AAGZ;AACAJ,EAAI,cAAc;"}
@@ -1,4 +1,4 @@
1
- import { FOCUS_OUTLINE as t } from "./fondue-components66.js";
1
+ import { FOCUS_OUTLINE as t } from "./fondue-components67.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-components67.js";
4
+ import e from "./fondue-components68.js";
5
5
  import { colorToCss as b } from "./fondue-components36.js";
6
6
  const o = ({
7
7
  id: c,
@@ -1,22 +1,21 @@
1
- const t = "_content_zlne2_5", n = "_subContent_zlne2_6", e = "_item_zlne2_19", o = "_subTrigger_zlne2_19", s = "_itemContent_zlne2_95", _ = "_subMenuIndicator_zlne2_106", u = "_group_zlne2_112", c = "_slot_zlne2_119", l = {
2
- content: t,
3
- subContent: n,
4
- item: e,
5
- subTrigger: o,
6
- itemContent: s,
7
- subMenuIndicator: _,
8
- group: u,
9
- slot: c
10
- };
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)
13
+ });
14
+ return { isLink: t, content: n };
15
+ }
16
+ return { isLink: t, content: o(e) };
17
+ }, [e]);
11
18
  export {
12
- t as content,
13
- l as default,
14
- u as group,
15
- e as item,
16
- s as itemContent,
17
- c as slot,
18
- n as subContent,
19
- _ as subMenuIndicator,
20
- o as subTrigger
19
+ u as useProcessedChildren
21
20
  };
22
21
  //# sourceMappingURL=fondue-components41.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components41.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"fondue-components41.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,8 +1,20 @@
1
- const o = "_root_gh190_5", t = {
2
- root: o
1
+ const t = "_content_bam12_5", n = "_subContent_bam12_6", o = "_item_bam12_19", s = "_subTrigger_bam12_19", _ = "_subMenuIndicator_bam12_101", e = "_group_bam12_107", b = "_slot_bam12_114", u = {
2
+ content: t,
3
+ subContent: n,
4
+ item: o,
5
+ subTrigger: s,
6
+ subMenuIndicator: _,
7
+ group: e,
8
+ slot: b
3
9
  };
4
10
  export {
5
- t as default,
6
- o as root
11
+ t as content,
12
+ u as default,
13
+ e as group,
14
+ o as item,
15
+ b as slot,
16
+ n as subContent,
17
+ _ as subMenuIndicator,
18
+ s as subTrigger
7
19
  };
8
20
  //# 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,16 +1,8 @@
1
- const o = "_root_1elpk_5", e = "_header_1elpk_56", t = "_body_1elpk_76", _ = "_footer_1elpk_94", s = "_close_1elpk_114", l = {
2
- root: o,
3
- header: e,
4
- body: t,
5
- footer: _,
6
- close: s
1
+ const o = "_root_gh190_5", t = {
2
+ root: o
7
3
  };
8
4
  export {
9
- t as body,
10
- s as close,
11
- l as default,
12
- _ as footer,
13
- e as header,
5
+ t as default,
14
6
  o as root
15
7
  };
16
8
  //# 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,8 +1,18 @@
1
- const o = "_root_umks5_5", t = {
2
- root: o
1
+ const o = "_root_ngv6y_5", e = "_overlay_ngv6y_41", _ = "_header_ngv6y_58", t = "_body_ngv6y_78", n = "_footer_ngv6y_96", r = "_close_ngv6y_116", s = {
2
+ root: o,
3
+ overlay: e,
4
+ header: _,
5
+ body: t,
6
+ footer: n,
7
+ close: r
3
8
  };
4
9
  export {
5
- t as default,
10
+ t as body,
11
+ r as close,
12
+ s as default,
13
+ n as footer,
14
+ _ as header,
15
+ e as overlay,
6
16
  o as root
7
17
  };
8
18
  //# 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,38 +1,8 @@
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
- });
1
+ const o = "_root_umks5_5", t = {
2
+ root: o
3
+ };
34
4
  export {
35
- i as loadingBarContainerStyles,
36
- a as loadingBarStyles
5
+ t as default,
6
+ o as root
37
7
  };
38
8
  //# sourceMappingURL=fondue-components45.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"fondue-components45.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,16 +1,38 @@
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
- };
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
+ });
8
34
  export {
9
- _ as corner,
10
- e as default,
11
- o as root,
12
- t as scrollbar,
13
- s as thumb,
14
- r as viewport
35
+ i as loadingBarContainerStyles,
36
+ a as loadingBarStyles
15
37
  };
16
38
  //# sourceMappingURL=fondue-components46.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components46.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"fondue-components46.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,8 +1,16 @@
1
- const o = "_root_yrjuz_5", t = {
2
- root: o
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: _
3
7
  };
4
8
  export {
5
- t as default,
6
- o as root
9
+ _ as corner,
10
+ e as default,
11
+ o as root,
12
+ t as scrollbar,
13
+ s as thumb,
14
+ r as viewport
7
15
  };
8
16
  //# 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,28 +1,8 @@
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;
1
+ const o = "_root_yrjuz_5", t = {
2
+ root: o
24
3
  };
25
4
  export {
26
- U as useControllableState
5
+ t as default,
6
+ o as root
27
7
  };
28
8
  //# sourceMappingURL=fondue-components48.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"fondue-components48.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,20 +1,28 @@
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
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;
9
24
  };
10
25
  export {
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
26
+ U as useControllableState
19
27
  };
20
28
  //# sourceMappingURL=fondue-components49.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fondue-components49.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"fondue-components49.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;"}