@frontify/fondue-components 19.1.0 → 19.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components10.js +23 -19
- package/dist/fondue-components10.js.map +1 -1
- package/dist/fondue-components11.js +2 -2
- package/dist/fondue-components12.js +1 -1
- package/dist/fondue-components13.js +34 -24
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components14.js +1 -1
- package/dist/fondue-components15.js +1 -1
- package/dist/fondue-components17.js +1 -1
- package/dist/fondue-components18.js +1 -1
- package/dist/fondue-components19.js +1 -1
- package/dist/fondue-components20.js +1 -1
- package/dist/fondue-components21.js +2 -2
- package/dist/fondue-components22.js +6 -6
- package/dist/fondue-components23.js +1 -1
- package/dist/fondue-components24.js +1 -1
- package/dist/fondue-components25.js +3 -3
- package/dist/fondue-components26.js +3 -3
- package/dist/fondue-components27.js +1 -1
- package/dist/fondue-components28.js +31 -29
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +1 -1
- package/dist/fondue-components30.js +1 -1
- package/dist/fondue-components37.js +1 -1
- package/dist/fondue-components40.js +1 -1
- package/dist/fondue-components42.js +1 -1
- package/dist/fondue-components49.js +5 -60
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components50.js +59 -17
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +18 -19
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +18 -4
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +3 -13
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +13 -3
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +3 -17
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +19 -35
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +35 -5
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +4 -12
- package/dist/fondue-components58.js.map +1 -1
- package/dist/fondue-components59.js +12 -4
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components60.js +4 -24
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +24 -16
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +16 -146
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +151 -19
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +19 -77
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +77 -8
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +8 -35
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +34 -48
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +70 -10
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components69.js +8 -10
- package/dist/fondue-components69.js.map +1 -1
- package/dist/fondue-components70.js +12 -12
- package/dist/fondue-components70.js.map +1 -1
- package/dist/fondue-components71.js +12 -20
- package/dist/fondue-components71.js.map +1 -1
- package/dist/fondue-components72.js +21 -29
- package/dist/fondue-components72.js.map +1 -1
- package/dist/fondue-components73.js +28 -55
- package/dist/fondue-components73.js.map +1 -1
- package/dist/fondue-components74.js +55 -14
- package/dist/fondue-components74.js.map +1 -1
- package/dist/fondue-components75.js +14 -25
- package/dist/fondue-components75.js.map +1 -1
- package/dist/fondue-components76.js +24 -13
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +14 -6
- package/dist/fondue-components77.js.map +1 -1
- package/dist/fondue-components78.js +6 -6
- package/dist/fondue-components79.js +7 -2
- package/dist/fondue-components79.js.map +1 -1
- package/dist/fondue-components82.js +2 -17
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +16 -39
- package/dist/fondue-components83.js.map +1 -1
- package/dist/fondue-components84.js +43 -0
- package/dist/fondue-components84.js.map +1 -0
- package/dist/fondue-components9.js +77 -66
- package/dist/fondue-components9.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,80 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as i from "@radix-ui/react-popover";
|
|
3
|
+
import { Slot as C } from "@radix-ui/react-slot";
|
|
4
|
+
import { isValidElement as V } from "react";
|
|
5
|
+
import { useFondueTheme as g, ThemeProvider as A } from "./fondue-components29.js";
|
|
6
|
+
import n from "./fondue-components67.js";
|
|
7
|
+
import { recursiveMap as D, getSelectOptionValue as M } from "./fondue-components84.js";
|
|
8
|
+
const T = ({
|
|
9
|
+
highlightedIndex: p,
|
|
10
|
+
getMenuProps: l,
|
|
11
|
+
getItemProps: m,
|
|
12
|
+
children: u,
|
|
13
|
+
filterText: c,
|
|
14
|
+
align: f,
|
|
15
|
+
side: d,
|
|
16
|
+
selectedItem: t,
|
|
17
|
+
hasInteractedSinceOpening: h,
|
|
18
|
+
viewportCollisionPadding: v = "compact"
|
|
19
|
+
}) => {
|
|
20
|
+
const P = (e) => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}, O = {
|
|
23
|
+
compact: 8,
|
|
24
|
+
spacious: 24
|
|
25
|
+
}, N = g();
|
|
26
|
+
return /* @__PURE__ */ r(i.Portal, { children: /* @__PURE__ */ r(A, { theme: N, children: /* @__PURE__ */ r(
|
|
27
|
+
i.Content,
|
|
28
|
+
{
|
|
29
|
+
align: f,
|
|
30
|
+
side: d,
|
|
31
|
+
collisionPadding: O[v] + 8,
|
|
32
|
+
onOpenAutoFocus: P,
|
|
33
|
+
className: n.portal,
|
|
34
|
+
children: /* @__PURE__ */ r(
|
|
35
|
+
"ul",
|
|
36
|
+
{
|
|
37
|
+
className: n.menu,
|
|
38
|
+
...l({}, { suppressRefError: !0 }),
|
|
39
|
+
"data-has-interacted": h ? "true" : "false",
|
|
40
|
+
"data-test-id": "fondue-select-menu",
|
|
41
|
+
children: D(
|
|
42
|
+
u,
|
|
43
|
+
(e, s) => {
|
|
44
|
+
if (((o) => (
|
|
45
|
+
// @ts-expect-error - We are explicitly checking for ref
|
|
46
|
+
V(o) && o.ref !== void 0
|
|
47
|
+
))(e)) {
|
|
48
|
+
const o = M(e.props), a = m({
|
|
49
|
+
item: o,
|
|
50
|
+
index: s,
|
|
51
|
+
...e.ref ? { ref: e.ref } : {}
|
|
52
|
+
});
|
|
53
|
+
return /* @__PURE__ */ r(
|
|
54
|
+
C,
|
|
55
|
+
{
|
|
56
|
+
className: n.item,
|
|
57
|
+
"data-highlighted": p === s,
|
|
58
|
+
"data-selected": (t == null ? void 0 : t.value) === o.value,
|
|
59
|
+
onTouchStart: (S) => {
|
|
60
|
+
a.onClick && a.onClick(S);
|
|
61
|
+
},
|
|
62
|
+
...a,
|
|
63
|
+
children: e
|
|
64
|
+
},
|
|
65
|
+
e.props.value
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
c
|
|
70
|
+
).parsedChildren
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
) }) });
|
|
75
|
+
};
|
|
76
|
+
T.displayName = "Select.Menu";
|
|
7
77
|
export {
|
|
8
|
-
|
|
9
|
-
t as SelectSlot
|
|
78
|
+
T as SelectMenu
|
|
10
79
|
};
|
|
11
80
|
//# sourceMappingURL=fondue-components65.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components65.js","sources":["../src/components/Select/
|
|
1
|
+
{"version":3,"file":"fondue-components65.js","sources":["../src/components/Select/SelectMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixPopover from '@radix-ui/react-popover';\nimport { Slot as RadixSlot } from '@radix-ui/react-slot';\nimport { type UseComboboxPropGetters, type UseSelectPropGetters } from 'downshift';\nimport { isValidElement, type ForwardedRef, type MouseEvent, type ReactElement, type ReactNode } from 'react';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport { type SelectItemProps } from './SelectItem';\nimport styles from './styles/select.module.scss';\nimport { getSelectOptionValue, recursiveMap } from './utils';\n\nexport type SelectMenuViewportCollisionPadding = 'compact' | 'spacious';\n\nexport type SelectMenuProps = {\n /**\n * @internal\n * The index of the highlighted item in the menu.\n */\n highlightedIndex: number;\n /**\n * @internal\n * Callback function to retrieve the props for a menu element.\n */\n getMenuProps: UseSelectPropGetters<unknown>['getMenuProps'] | UseComboboxPropGetters<unknown>['getMenuProps'];\n /**\n * @internal\n * Callback function to retrieve the props for a item element.\n */\n getItemProps: UseSelectPropGetters<unknown>['getItemProps'] | UseComboboxPropGetters<unknown>['getItemProps'];\n /**\n * @internal\n * The children of the menu component. This can contain multiple `Select.Item` or `Select.Group` components.\n */\n children: ReactNode;\n /**\n * @internal\n * The filter text shown in the combobox input element.\n */\n filterText?: string;\n /**\n * @internal\n * The alignment of the menu.\n */\n align: 'start' | 'center' | 'end';\n /**\n * @internal\n * Defines the preferred side of the select. It will not be respected if there are collisions with the viewport.\n * @default \"bottom\"\n */\n side: 'left' | 'right' | 'bottom' | 'top';\n /**\n * @internal\n * The type of the menu.\n */\n selectedItem?: {\n value: string;\n } | null;\n /**\n * @internal\n * A boolean to indicate if highlighted item was changed since opening the menu.\n * This is used to determine the style of the selected/highlighted item.\n */\n hasInteractedSinceOpening?: boolean;\n /**\n * Define the minimum distance between the select menu and the viewport edge\n * @default 'compact'\n */\n viewportCollisionPadding?: SelectMenuViewportCollisionPadding;\n};\n\nexport const SelectMenu = ({\n highlightedIndex,\n getMenuProps,\n getItemProps,\n children,\n filterText,\n align,\n side,\n selectedItem,\n hasInteractedSinceOpening,\n viewportCollisionPadding = 'compact',\n}: SelectMenuProps) => {\n const handleOnOpenAutoFocus = (event: Event) => {\n event.preventDefault();\n };\n\n const VIEWPORT_COLLISION_PADDING_MAP: Record<SelectMenuViewportCollisionPadding, number> = {\n compact: 8,\n spacious: 24,\n };\n\n const theme = useFondueTheme();\n return (\n <RadixPopover.Portal>\n <ThemeProvider theme={theme}>\n <RadixPopover.Content\n align={align}\n side={side}\n collisionPadding={VIEWPORT_COLLISION_PADDING_MAP[viewportCollisionPadding] + 8}\n onOpenAutoFocus={handleOnOpenAutoFocus}\n className={styles.portal}\n >\n <ul\n className={styles.menu}\n // TODO: fix this accessibility issue\n // We are mounting/unmounting the menu on open/close\n // We should instead toggle its visibility for accessibility reasons\n // https://github.com/downshift-js/downshift?tab=readme-ov-file#getmenuprops\n {...getMenuProps({}, { suppressRefError: true })}\n data-has-interacted={hasInteractedSinceOpening ? 'true' : 'false'}\n data-test-id=\"fondue-select-menu\"\n >\n {\n recursiveMap(\n children,\n (child, index) => {\n const isValid = <TProps,>(\n child: ReactNode,\n ): child is ReactElement<TProps> & { ref: ForwardedRef<HTMLElement> } =>\n // @ts-expect-error - We are explicitly checking for ref\n isValidElement<TProps>(child) && child.ref !== undefined;\n\n if (isValid<SelectItemProps>(child)) {\n const optionData = getSelectOptionValue(child.props);\n const itemProps = getItemProps({\n item: optionData,\n index,\n ...(child.ref ? { ref: child.ref } : {}),\n });\n\n return (\n <RadixSlot\n className={styles.item}\n data-highlighted={highlightedIndex === index}\n data-selected={selectedItem?.value === optionData.value}\n key={child.props.value}\n // Workaround for the issue where the onClick event is not fired on touch devices because of portal usage\n onTouchStart={(event) => {\n if (itemProps.onClick) {\n itemProps.onClick(event as unknown as MouseEvent<HTMLElement>);\n }\n }}\n {...itemProps}\n >\n {child}\n </RadixSlot>\n );\n }\n },\n filterText,\n ).parsedChildren\n }\n </ul>\n </RadixPopover.Content>\n </ThemeProvider>\n </RadixPopover.Portal>\n );\n};\nSelectMenu.displayName = 'Select.Menu';\n"],"names":["SelectMenu","highlightedIndex","getMenuProps","getItemProps","children","filterText","align","side","selectedItem","hasInteractedSinceOpening","viewportCollisionPadding","handleOnOpenAutoFocus","event","VIEWPORT_COLLISION_PADDING_MAP","theme","useFondueTheme","RadixPopover","jsx","ThemeProvider","styles","recursiveMap","child","index","isValidElement","optionData","getSelectOptionValue","itemProps","RadixSlot"],"mappings":";;;;;;;AAwEO,MAAMA,IAAa,CAAC;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,2BAAAC;AAAA,EACA,0BAAAC,IAA2B;AAC/B,MAAuB;AACb,QAAAC,IAAwB,CAACC,MAAiB;AAC5C,IAAAA,EAAM,eAAe;AAAA,EACzB,GAEMC,IAAqF;AAAA,IACvF,SAAS;AAAA,IACT,UAAU;AAAA,EACd,GAEMC,IAAQC,EAAe;AAC7B,2BACKC,EAAa,QAAb,EACG,UAAA,gBAAAC,EAACC,KAAc,OAAAJ,GACX,UAAA,gBAAAG;AAAA,IAACD,EAAa;AAAA,IAAb;AAAA,MACG,OAAAV;AAAA,MACA,MAAAC;AAAA,MACA,kBAAkBM,EAA+BH,CAAwB,IAAI;AAAA,MAC7E,iBAAiBC;AAAA,MACjB,WAAWQ,EAAO;AAAA,MAElB,UAAA,gBAAAF;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,WAAWE,EAAO;AAAA,UAKjB,GAAGjB,EAAa,IAAI,EAAE,kBAAkB,IAAM;AAAA,UAC/C,uBAAqBO,IAA4B,SAAS;AAAA,UAC1D,gBAAa;AAAA,UAGT,UAAAW;AAAA,YACIhB;AAAA,YACA,CAACiB,GAAOC,MAAU;AAOV,mBANY,CACZD;AAAAA;AAAAA,gBAGAE,EAAuBF,CAAK,KAAKA,EAAM,QAAQ;AAAA,iBAEtBA,CAAK,GAAG;AAC3B,sBAAAG,IAAaC,EAAqBJ,EAAM,KAAK,GAC7CK,IAAYvB,EAAa;AAAA,kBAC3B,MAAMqB;AAAA,kBACN,OAAAF;AAAA,kBACA,GAAID,EAAM,MAAM,EAAE,KAAKA,EAAM,IAAA,IAAQ,CAAA;AAAA,gBAAC,CACzC;AAGG,uBAAA,gBAAAJ;AAAA,kBAACU;AAAAA,kBAAA;AAAA,oBACG,WAAWR,EAAO;AAAA,oBAClB,oBAAkBlB,MAAqBqB;AAAA,oBACvC,kBAAed,KAAA,gBAAAA,EAAc,WAAUgB,EAAW;AAAA,oBAGlD,cAAc,CAACZ,MAAU;AACrB,sBAAIc,EAAU,WACVA,EAAU,QAAQd,CAA2C;AAAA,oBAErE;AAAA,oBACC,GAAGc;AAAA,oBAEH,UAAAL;AAAA,kBAAA;AAAA,kBATIA,EAAM,MAAM;AAAA,gBAUrB;AAAA,cAAA;AAAA,YAGZ;AAAA,YACAhB;AAAA,UAAA,EACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAEV;AAAA,KAER,EACJ,CAAA;AAER;AACAL,EAAW,cAAc;"}
|
|
@@ -1,38 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
icons: n,
|
|
8
|
-
caret: s,
|
|
9
|
-
iconSuccess: r,
|
|
10
|
-
iconError: m,
|
|
11
|
-
menu: a,
|
|
12
|
-
portal: d,
|
|
13
|
-
item: u,
|
|
14
|
-
checkmarkIcon: i,
|
|
15
|
-
itemValue: l,
|
|
16
|
-
group: p,
|
|
17
|
-
groupHeading: g
|
|
18
|
-
};
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d } from "react";
|
|
3
|
+
import m from "./fondue-components67.js";
|
|
4
|
+
const t = ({ children: e, name: o, "data-test-id": r = "fondue-select-slot", ...a }, s) => /* @__PURE__ */ l("div", { "data-test-id": r, ref: s, className: m.slot, "data-name": o, ...a, children: e });
|
|
5
|
+
t.displayName = "Select.Slot";
|
|
6
|
+
const S = d(t);
|
|
19
7
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
e as clear,
|
|
23
|
-
k as default,
|
|
24
|
-
p as group,
|
|
25
|
-
g as groupHeading,
|
|
26
|
-
m as iconError,
|
|
27
|
-
r as iconSuccess,
|
|
28
|
-
n as icons,
|
|
29
|
-
_ as input,
|
|
30
|
-
u as item,
|
|
31
|
-
l as itemValue,
|
|
32
|
-
a as menu,
|
|
33
|
-
d as portal,
|
|
34
|
-
o as root,
|
|
35
|
-
c as selectedValue,
|
|
36
|
-
t as slot
|
|
8
|
+
S as ForwardedRefSelectSlot,
|
|
9
|
+
t as SelectSlot
|
|
37
10
|
};
|
|
38
11
|
//# sourceMappingURL=fondue-components66.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components66.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components66.js","sources":["../src/components/Select/SelectSlot.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { forwardRef, type ForwardedRef, type ReactNode } from 'react';\n\nimport styles from './styles/select.module.scss';\n\nexport type SelectSlotProps = {\n /**\n * The children of the select slot. This can be a custom component.\n */\n children?: ReactNode;\n /**\n * The slot name that is used to determine the placement.\n */\n name: 'menu' | 'left' | 'right' | 'clear';\n /**\n * The data test id of the select slot.\n */\n 'data-test-id'?: string;\n};\n\nexport const SelectSlot = (\n { children, name, 'data-test-id': dataTestId = 'fondue-select-slot', ...props }: SelectSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return (\n <div data-test-id={dataTestId} ref={forwardedRef} className={styles.slot} data-name={name} {...props}>\n {children}\n </div>\n );\n};\nSelectSlot.displayName = 'Select.Slot';\n\nexport const ForwardedRefSelectSlot = forwardRef<HTMLDivElement, SelectSlotProps>(SelectSlot);\n"],"names":["SelectSlot","children","name","dataTestId","props","forwardedRef","jsx","styles","ForwardedRefSelectSlot","forwardRef"],"mappings":";;;AAqBa,MAAAA,IAAa,CACtB,EAAE,UAAAC,GAAU,MAAAC,GAAM,gBAAgBC,IAAa,sBAAsB,GAAGC,EAAM,GAC9EC,MAGK,gBAAAC,EAAA,OAAA,EAAI,gBAAcH,GAAY,KAAKE,GAAc,WAAWE,EAAO,MAAM,aAAWL,GAAO,GAAGE,GAC1F,UAAAH,GACL;AAGRD,EAAW,cAAc;AAEZ,MAAAQ,IAAyBC,EAA4CT,CAAU;"}
|
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, z = (r) => {
|
|
19
|
-
const [t, o] = B(""), { inputSlots: u, menuSlots: l, itemValues: p, clearButton: V } = i(() => {
|
|
20
|
-
const s = [], n = [];
|
|
21
|
-
let m;
|
|
22
|
-
f.toArray(r).some(
|
|
23
|
-
(e) => a(e) && e.type === c
|
|
24
|
-
) ? f.forEach(r, (e) => {
|
|
25
|
-
a(e) && e.type === c && (e.props.name === "menu" ? n.push(e.props.children) : e.props.name === "left" || e.props.name === "right" ? s.push(e) : e.props.name === "clear" && (e.props.children ? m = e : m = E(e, { children: /* @__PURE__ */ w(x, { size: 16 }) })));
|
|
26
|
-
}) : n.push(r);
|
|
27
|
-
const g = S(n);
|
|
28
|
-
return { inputSlots: s, menuSlots: n, itemValues: g, clearButton: m };
|
|
29
|
-
}, [r]), y = i(
|
|
30
|
-
() => p.filter(
|
|
31
|
-
(s) => t === "" || s.label.toLowerCase().includes(t.toLowerCase())
|
|
32
|
-
),
|
|
33
|
-
[p, t]
|
|
34
|
-
), C = v(
|
|
35
|
-
(s) => s ? p.find((n) => n.value === s) : void 0,
|
|
36
|
-
[p]
|
|
37
|
-
);
|
|
38
|
-
return {
|
|
39
|
-
items: y,
|
|
40
|
-
menuSlots: l,
|
|
41
|
-
filterText: t,
|
|
42
|
-
inputSlots: u,
|
|
43
|
-
clearButton: V,
|
|
44
|
-
setFilterText: o,
|
|
45
|
-
getItemByValue: C
|
|
46
|
-
};
|
|
1
|
+
const o = "_root_174md_7", c = "_selectedValue_174md_69", _ = "_input_174md_87", t = "_slot_174md_113", e = "_clear_174md_165", n = "_icons_174md_178", s = "_caret_174md_184", r = "_iconSuccess_174md_212", m = "_iconError_174md_218", a = "_menu_174md_224", d = "_portal_174md_247", u = "_item_174md_263", i = "_checkmarkIcon_174md_304", l = "_itemValue_174md_311", p = "_group_174md_325", g = "_groupHeading_174md_336", k = {
|
|
2
|
+
root: o,
|
|
3
|
+
selectedValue: c,
|
|
4
|
+
input: _,
|
|
5
|
+
slot: t,
|
|
6
|
+
clear: e,
|
|
7
|
+
icons: n,
|
|
8
|
+
caret: s,
|
|
9
|
+
iconSuccess: r,
|
|
10
|
+
iconError: m,
|
|
11
|
+
menu: a,
|
|
12
|
+
portal: d,
|
|
13
|
+
item: u,
|
|
14
|
+
checkmarkIcon: i,
|
|
15
|
+
itemValue: l,
|
|
16
|
+
group: p,
|
|
17
|
+
groupHeading: g
|
|
47
18
|
};
|
|
48
19
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
20
|
+
s as caret,
|
|
21
|
+
i as checkmarkIcon,
|
|
22
|
+
e as clear,
|
|
23
|
+
k as default,
|
|
24
|
+
p as group,
|
|
25
|
+
g as groupHeading,
|
|
26
|
+
m as iconError,
|
|
27
|
+
r as iconSuccess,
|
|
28
|
+
n as icons,
|
|
29
|
+
_ as input,
|
|
30
|
+
u as item,
|
|
31
|
+
l as itemValue,
|
|
32
|
+
a as menu,
|
|
33
|
+
d as portal,
|
|
34
|
+
o as root,
|
|
35
|
+
c as selectedValue,
|
|
36
|
+
t as slot
|
|
51
37
|
};
|
|
52
38
|
//# sourceMappingURL=fondue-components67.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components67.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components67.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { IconCross as w } from "@frontify/fondue-icons";
|
|
3
|
+
import { useState as S, useMemo as b, Children as v, isValidElement as C, cloneElement as B, useCallback as I, useEffect as x } from "react";
|
|
4
|
+
import { ForwardedRefSelectItem as L } from "./fondue-components64.js";
|
|
5
|
+
import { ForwardedRefSelectSlot as y } from "./fondue-components66.js";
|
|
6
|
+
import { getSelectOptionValue as F } from "./fondue-components84.js";
|
|
7
|
+
const O = (n, s) => {
|
|
8
|
+
const [e, r] = S(!1), [m, i] = S(null), [l, f] = S({
|
|
9
|
+
menuComponents: [],
|
|
10
|
+
items: []
|
|
11
|
+
});
|
|
12
|
+
return x(() => {
|
|
13
|
+
i(null), s || f({
|
|
14
|
+
menuComponents: [],
|
|
15
|
+
items: []
|
|
16
|
+
}), s && (r(!0), s(n).then((u) => {
|
|
17
|
+
f({
|
|
18
|
+
menuComponents: u.map((o) => /* @__PURE__ */ E(L, { label: o.label, value: o.value, children: o.content ? o.content : o.label }, o.value)),
|
|
19
|
+
items: u.map((o) => ({ value: o.value, label: o.label, children: o.content }))
|
|
20
|
+
}), r(!1);
|
|
21
|
+
}).catch((u) => {
|
|
22
|
+
i(u), r(!1);
|
|
23
|
+
}));
|
|
24
|
+
}, [n, s]), { isLoading: e, error: m, menuComponents: l.menuComponents, items: l.items };
|
|
25
|
+
}, g = (n) => {
|
|
26
|
+
const s = [];
|
|
27
|
+
return v.forEach(n, (e) => {
|
|
28
|
+
if (C(e) && e.type === L)
|
|
29
|
+
s.push(F(e.props));
|
|
30
|
+
else if (C(e) && e.props.children) {
|
|
31
|
+
const r = g(e.props.children);
|
|
32
|
+
for (const m of r)
|
|
33
|
+
s.push(m);
|
|
34
|
+
}
|
|
35
|
+
}), s;
|
|
36
|
+
}, T = (n, s) => {
|
|
37
|
+
const [e, r] = S(""), { inputSlots: m, menuSlots: i, itemValues: l, clearButton: f } = b(() => {
|
|
38
|
+
const a = [], p = [];
|
|
39
|
+
let V;
|
|
40
|
+
v.toArray(n).some(
|
|
41
|
+
(t) => C(t) && t.type === y
|
|
42
|
+
) ? v.forEach(n, (t) => {
|
|
43
|
+
C(t) && t.type === y && (t.props.name === "menu" ? p.push(t.props.children) : t.props.name === "left" || t.props.name === "right" ? a.push(t) : t.props.name === "clear" && (t.props.children ? V = t : V = B(t, { children: /* @__PURE__ */ E(w, { size: 16 }) })));
|
|
44
|
+
}) : p.push(n);
|
|
45
|
+
const R = g(p);
|
|
46
|
+
return { inputSlots: a, menuSlots: p, itemValues: R, clearButton: V };
|
|
47
|
+
}, [n]), u = b(
|
|
48
|
+
() => l.filter(
|
|
49
|
+
(a) => e === "" || a.label.toLowerCase().includes(e.toLowerCase())
|
|
50
|
+
),
|
|
51
|
+
[l, e]
|
|
52
|
+
), o = I(
|
|
53
|
+
(a) => a ? l.find((p) => p.value === a) : void 0,
|
|
54
|
+
[l]
|
|
55
|
+
), c = O(e, s);
|
|
56
|
+
return {
|
|
57
|
+
items: [...u, ...c.items],
|
|
58
|
+
menuSlots: [...i, ...c.menuComponents],
|
|
59
|
+
filterText: e,
|
|
60
|
+
inputSlots: m,
|
|
61
|
+
clearButton: f,
|
|
62
|
+
setFilterText: r,
|
|
63
|
+
getItemByValue: o,
|
|
64
|
+
asyncItemStatus: {
|
|
65
|
+
isLoading: c.isLoading,
|
|
66
|
+
error: c.error
|
|
67
|
+
}
|
|
68
|
+
};
|
|
6
69
|
};
|
|
7
70
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t as root,
|
|
11
|
-
o as thumb,
|
|
12
|
-
s as track
|
|
71
|
+
g as getRecursiveOptionValues,
|
|
72
|
+
T as useSelectData
|
|
13
73
|
};
|
|
14
74
|
//# sourceMappingURL=fondue-components68.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components68.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
1
|
+
{"version":3,"file":"fondue-components68.js","sources":["../src/components/Select/useSelectData.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCross } from '@frontify/fondue-icons';\nimport {\n Children,\n cloneElement,\n isValidElement,\n useCallback,\n useMemo,\n useState,\n type ReactNode,\n useEffect,\n} from 'react';\n\nimport { ForwardedRefSelectItem, type SelectItemProps } from './SelectItem';\nimport { ForwardedRefSelectSlot, type SelectSlotProps } from './SelectSlot';\nimport { getSelectOptionValue } from './utils';\n\nexport type SelectItemType = {\n value: string;\n label: string;\n};\n\nexport type AsyncItem = { label: string; value: string; content?: ReactNode };\n\nexport type AsyncItemsFetcher = (filterText: string) => Promise<AsyncItem[]>;\n\nconst useAsyncItems = (filterText: string, getAsyncItems?: AsyncItemsFetcher) => {\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [asyncResult, setAsyncResult] = useState<{\n menuComponents: ReactNode[];\n items: { value: string; label: string; children?: ReactNode }[];\n }>({\n menuComponents: [],\n items: [],\n });\n\n useEffect(() => {\n setError(null);\n if (!getAsyncItems) {\n setAsyncResult({\n menuComponents: [],\n items: [],\n });\n }\n\n if (getAsyncItems) {\n setIsLoading(true);\n getAsyncItems(filterText)\n .then((items) => {\n setAsyncResult({\n menuComponents: items.map((item) => (\n <ForwardedRefSelectItem key={item.value} label={item.label} value={item.value}>\n {item.content ? item.content : item.label}\n </ForwardedRefSelectItem>\n )),\n items: items.map((item) => ({ value: item.value, label: item.label, children: item.content })),\n });\n setIsLoading(false);\n })\n .catch((error: Error) => {\n setError(error);\n setIsLoading(false);\n });\n }\n }, [filterText, getAsyncItems]);\n\n return { isLoading, error, menuComponents: asyncResult.menuComponents, items: asyncResult.items };\n};\n\n/**\n * Recursively extracts option values from children.\n * This function traverses through the React component tree and collects all SelectItem values.\n *\n * @param {ReactNode} children - The React children to extract values from.\n * @returns {SelectItemType[]} An array of SelectItemType objects.\n *\n * @example\n * const options = (\n * <SelectItem value=\"1\">Option 1</SelectItem>\n * <SelectItem value=\"2\">Option 2</SelectItem>\n * );\n * const values = getRecursiveOptionValues(options);\n * // Returns: [{ value: '1', label: 'Option 1' }, { value: '2', label: 'Option 2' }]\n */\nexport const getRecursiveOptionValues = (\n children: ReactNode,\n): { value: string; label: string; children?: ReactNode }[] => {\n const values: { value: string; label: string }[] = [];\n Children.forEach(children, (child) => {\n if (isValidElement<SelectItemProps>(child) && child.type === ForwardedRefSelectItem) {\n values.push(getSelectOptionValue(child.props));\n } else if (isValidElement<{ children: ReactNode }>(child) && child.props.children) {\n const optionValues = getRecursiveOptionValues(child.props.children);\n for (const optionValue of optionValues) {\n values.push(optionValue);\n }\n }\n });\n return values;\n};\n\n/**\n * Custom hook for managing select data and filtering.\n *\n * @param {ReactNode} children - The React children to process, typically SelectItem components.\n * @param {AsyncItemsFetcher} [getAsyncItems] - Optional function to fetch items asynchronously based on filter text.\n * @returns {Object} An object containing the processed data.\n */\nexport const useSelectData = (children: ReactNode, getAsyncItems?: AsyncItemsFetcher) => {\n const [filterText, setFilterText] = useState('');\n const { inputSlots, menuSlots, itemValues, clearButton } = useMemo(() => {\n const inputSlots: ReactNode[] = [];\n const menuSlots: ReactNode[] = [];\n let clearButton: ReactNode;\n\n const hasSlots = Children.toArray(children).some(\n (child) => isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot,\n );\n\n if (hasSlots) {\n Children.forEach(children, (child) => {\n if (isValidElement<SelectSlotProps>(child) && child.type === ForwardedRefSelectSlot) {\n if (child.props.name === 'menu') {\n menuSlots.push(child.props.children);\n } else if (child.props.name === 'left' || child.props.name === 'right') {\n inputSlots.push(child);\n } else if (child.props.name === 'clear') {\n if (child.props.children) {\n clearButton = child;\n } else {\n clearButton = cloneElement(child, { children: <IconCross size={16} /> });\n }\n }\n }\n });\n } else {\n menuSlots.push(children);\n }\n\n const itemValues = getRecursiveOptionValues(menuSlots);\n\n return { inputSlots, menuSlots, itemValues, clearButton };\n }, [children]);\n\n const items = useMemo(\n () =>\n itemValues.filter(\n (item) => filterText === '' || item.label.toLowerCase().includes(filterText.toLowerCase()),\n ),\n [itemValues, filterText],\n );\n\n const getItemByValue = useCallback(\n (value?: string | null) => (value ? itemValues.find((item) => item.value === value) : undefined),\n [itemValues],\n );\n\n const asyncItems = useAsyncItems(filterText, getAsyncItems);\n\n return {\n items: [...items, ...asyncItems.items],\n menuSlots: [...menuSlots, ...asyncItems.menuComponents],\n filterText,\n inputSlots,\n clearButton,\n setFilterText,\n getItemByValue,\n asyncItemStatus: {\n isLoading: asyncItems.isLoading,\n error: asyncItems.error,\n },\n };\n};\n"],"names":["useAsyncItems","filterText","getAsyncItems","isLoading","setIsLoading","useState","error","setError","asyncResult","setAsyncResult","useEffect","items","item","jsx","ForwardedRefSelectItem","getRecursiveOptionValues","children","values","Children","child","isValidElement","getSelectOptionValue","optionValues","optionValue","useSelectData","setFilterText","inputSlots","menuSlots","itemValues","clearButton","useMemo","ForwardedRefSelectSlot","cloneElement","IconCross","getItemByValue","useCallback","value","asyncItems"],"mappings":";;;;;;AA2BA,MAAMA,IAAgB,CAACC,GAAoBC,MAAsC;AAC7E,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1C,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAC/C,CAACG,GAAaC,CAAc,IAAIJ,EAGnC;AAAA,IACC,gBAAgB,CAAC;AAAA,IACjB,OAAO,CAAA;AAAA,EAAC,CACX;AAED,SAAAK,EAAU,MAAM;AACZ,IAAAH,EAAS,IAAI,GACRL,KACcO,EAAA;AAAA,MACX,gBAAgB,CAAC;AAAA,MACjB,OAAO,CAAA;AAAA,IAAC,CACX,GAGDP,MACAE,EAAa,EAAI,GACjBF,EAAcD,CAAU,EACnB,KAAK,CAACU,MAAU;AACE,MAAAF,EAAA;AAAA,QACX,gBAAgBE,EAAM,IAAI,CAACC,MACtB,gBAAAC,EAAAC,GAAA,EAAwC,OAAOF,EAAK,OAAO,OAAOA,EAAK,OACnE,YAAK,UAAUA,EAAK,UAAUA,EAAK,MAAA,GADXA,EAAK,KAElC,CACH;AAAA,QACD,OAAOD,EAAM,IAAI,CAACC,OAAU,EAAE,OAAOA,EAAK,OAAO,OAAOA,EAAK,OAAO,UAAUA,EAAK,UAAU;AAAA,MAAA,CAChG,GACDR,EAAa,EAAK;AAAA,IAAA,CACrB,EACA,MAAM,CAACE,MAAiB;AACrB,MAAAC,EAASD,CAAK,GACdF,EAAa,EAAK;AAAA,IAAA,CACrB;AAAA,EACT,GACD,CAACH,GAAYC,CAAa,CAAC,GAEvB,EAAE,WAAAC,GAAW,OAAAG,GAAO,gBAAgBE,EAAY,gBAAgB,OAAOA,EAAY,MAAM;AACpG,GAiBaO,IAA2B,CACpCC,MAC2D;AAC3D,QAAMC,IAA6C,CAAC;AAC3C,SAAAC,EAAA,QAAQF,GAAU,CAACG,MAAU;AAClC,QAAIC,EAAgCD,CAAK,KAAKA,EAAM,SAASL;AACzD,MAAAG,EAAO,KAAKI,EAAqBF,EAAM,KAAK,CAAC;AAAA,aACtCC,EAAwCD,CAAK,KAAKA,EAAM,MAAM,UAAU;AAC/E,YAAMG,IAAeP,EAAyBI,EAAM,MAAM,QAAQ;AAClE,iBAAWI,KAAeD;AACtB,QAAAL,EAAO,KAAKM,CAAW;AAAA,IAC3B;AAAA,EACJ,CACH,GACMN;AACX,GASaO,IAAgB,CAACR,GAAqBd,MAAsC;AACrF,QAAM,CAACD,GAAYwB,CAAa,IAAIpB,EAAS,EAAE,GACzC,EAAE,YAAAqB,GAAY,WAAAC,GAAW,YAAAC,GAAY,aAAAC,EAAY,IAAIC,EAAQ,MAAM;AACrE,UAAMJ,IAA0B,CAAC,GAC3BC,IAAyB,CAAC;AAC5BE,QAAAA;AAMJ,IAJiBX,EAAS,QAAQF,CAAQ,EAAE;AAAA,MACxC,CAACG,MAAUC,EAAgCD,CAAK,KAAKA,EAAM,SAASY;AAAA,IACxE,IAGab,EAAA,QAAQF,GAAU,CAACG,MAAU;AAClC,MAAIC,EAAgCD,CAAK,KAAKA,EAAM,SAASY,MACrDZ,EAAM,MAAM,SAAS,SACrBQ,EAAU,KAAKR,EAAM,MAAM,QAAQ,IAC5BA,EAAM,MAAM,SAAS,UAAUA,EAAM,MAAM,SAAS,UAC3DO,EAAW,KAAKP,CAAK,IACdA,EAAM,MAAM,SAAS,YACxBA,EAAM,MAAM,WACZU,IAAcV,IAEdU,IAAcG,EAAab,GAAO,EAAE,4BAAWc,GAAU,EAAA,MAAM,GAAI,CAAA,GAAI;AAAA,IAGnF,CACH,IAEDN,EAAU,KAAKX,CAAQ;AAGrBY,UAAAA,IAAab,EAAyBY,CAAS;AAE9C,WAAA,EAAE,YAAAD,GAAY,WAAAC,GAAW,YAAAC,GAAY,aAAAC,EAAY;AAAA,EAAA,GACzD,CAACb,CAAQ,CAAC,GAEPL,IAAQmB;AAAA,IACV,MACIF,EAAW;AAAA,MACP,CAAChB,MAASX,MAAe,MAAMW,EAAK,MAAM,cAAc,SAASX,EAAW,YAAa,CAAA;AAAA,IAC7F;AAAA,IACJ,CAAC2B,GAAY3B,CAAU;AAAA,EAC3B,GAEMiC,IAAiBC;AAAA,IACnB,CAACC,MAA2BA,IAAQR,EAAW,KAAK,CAAChB,MAASA,EAAK,UAAUwB,CAAK,IAAI;AAAA,IACtF,CAACR,CAAU;AAAA,EACf,GAEMS,IAAarC,EAAcC,GAAYC,CAAa;AAEnD,SAAA;AAAA,IACH,OAAO,CAAC,GAAGS,GAAO,GAAG0B,EAAW,KAAK;AAAA,IACrC,WAAW,CAAC,GAAGV,GAAW,GAAGU,EAAW,cAAc;AAAA,IACtD,YAAApC;AAAA,IACA,YAAAyB;AAAA,IACA,aAAAG;AAAA,IACA,eAAAJ;AAAA,IACA,gBAAAS;AAAA,IACA,iBAAiB;AAAA,MACb,WAAWG,EAAW;AAAA,MACtB,OAAOA,EAAW;AAAA,IAAA;AAAA,EAE1B;AACJ;"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
const t = "
|
|
1
|
+
const t = "_root_fs3zj_5", o = "_thumb_fs3zj_17", s = "_track_fs3zj_21", _ = "_range_fs3zj_28", r = {
|
|
2
2
|
root: t,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
thumb: s
|
|
3
|
+
thumb: o,
|
|
4
|
+
track: s,
|
|
5
|
+
range: _
|
|
7
6
|
};
|
|
8
7
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o as medium,
|
|
8
|
+
r as default,
|
|
9
|
+
_ as range,
|
|
12
10
|
t as root,
|
|
13
|
-
|
|
14
|
-
s as
|
|
11
|
+
o as thumb,
|
|
12
|
+
s as track
|
|
15
13
|
};
|
|
16
14
|
//# sourceMappingURL=fondue-components69.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components69.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components69.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const r = e.scrollWidth > e.clientWidth;
|
|
8
|
-
e.title = r && e.textContent || "";
|
|
9
|
-
});
|
|
10
|
-
return n.observe(e), () => n.disconnect();
|
|
11
|
-
}, [t]);
|
|
1
|
+
const t = "_root_1g6pz_5", _ = "_small_1g6pz_16", o = "_medium_1g6pz_20", m = "_large_1g6pz_24", s = "_thumb_1g6pz_61", l = {
|
|
2
|
+
root: t,
|
|
3
|
+
small: _,
|
|
4
|
+
medium: o,
|
|
5
|
+
large: m,
|
|
6
|
+
thumb: s
|
|
12
7
|
};
|
|
13
8
|
export {
|
|
14
|
-
|
|
9
|
+
l as default,
|
|
10
|
+
m as large,
|
|
11
|
+
o as medium,
|
|
12
|
+
t as root,
|
|
13
|
+
_ as small,
|
|
14
|
+
s as thumb
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=fondue-components70.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components70.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components70.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useEffect as c } from "react";
|
|
2
|
+
const s = (t) => {
|
|
3
|
+
c(() => {
|
|
4
|
+
if (!t.current)
|
|
5
|
+
return;
|
|
6
|
+
const e = t.current, n = new ResizeObserver(() => {
|
|
7
|
+
const r = e.scrollWidth > e.clientWidth;
|
|
8
|
+
e.title = r && e.textContent || "";
|
|
9
|
+
});
|
|
10
|
+
return n.observe(e), () => n.disconnect();
|
|
11
|
+
}, [t]);
|
|
11
12
|
};
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
-
s as buttonText,
|
|
15
|
-
_ as caption,
|
|
16
|
-
n as cellContent,
|
|
17
|
-
a as default,
|
|
18
|
-
o as headerCell,
|
|
19
|
-
r as row,
|
|
20
|
-
e as rowCell,
|
|
21
|
-
l as sortIndicator,
|
|
22
|
-
t as table
|
|
14
|
+
s as useTextTruncation
|
|
23
15
|
};
|
|
24
16
|
//# sourceMappingURL=fondue-components71.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components71.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components71.js","sources":["../src/hooks/useTextTruncation.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useEffect, type RefObject } from 'react';\n\n/**\n * A custom React hook that automatically manages text truncation and tooltips.\n * It observes the element's size and adds a title attribute with the full text\n * when the content is truncated.\n *\n * @param {RefObject<HTMLElement>} ref - Reference to the HTML element to observe for truncation.\n *\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const textRef = useRef<HTMLDivElement>(null);\n * useTextTruncation(textRef);\n *\n * return <div ref={textRef} className=\"truncate\">Long text content...</div>;\n * });\n * ```\n */\nexport const useTextTruncation = (ref: RefObject<HTMLElement>) => {\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n const element = ref.current;\n const observer = new ResizeObserver(() => {\n const isTruncated = element.scrollWidth > element.clientWidth;\n element.title = isTruncated ? element.textContent || '' : '';\n });\n\n observer.observe(element);\n return () => observer.disconnect();\n }, [ref]);\n};\n"],"names":["useTextTruncation","ref","useEffect","element","observer","isTruncated"],"mappings":";AAqBa,MAAAA,IAAoB,CAACC,MAAgC;AAC9D,EAAAC,EAAU,MAAM;AACR,QAAA,CAACD,EAAI;AACL;AAGJ,UAAME,IAAUF,EAAI,SACdG,IAAW,IAAI,eAAe,MAAM;AAChC,YAAAC,IAAcF,EAAQ,cAAcA,EAAQ;AAClD,MAAAA,EAAQ,QAAQE,KAAcF,EAAQ,eAAe;AAAA,IAAK,CAC7D;AAED,WAAAC,EAAS,QAAQD,CAAO,GACjB,MAAMC,EAAS,WAAW;AAAA,EAAA,GAClC,CAACH,CAAG,CAAC;AACZ;"}
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const r = c(n, t.key);
|
|
13
|
-
r && (t.preventDefault(), r.focus());
|
|
14
|
-
}
|
|
15
|
-
const s = [HTMLButtonElement, HTMLAnchorElement], u = ["button", "link"];
|
|
16
|
-
function f(t) {
|
|
17
|
-
let e = (t == null ? void 0 : t.target) instanceof Element ? t.target : null;
|
|
18
|
-
for (; e && !(e instanceof HTMLTableRowElement); ) {
|
|
19
|
-
if (s.some((r) => e instanceof r))
|
|
20
|
-
return !0;
|
|
21
|
-
const n = e.getAttribute("role");
|
|
22
|
-
if (n && u.includes(n))
|
|
23
|
-
return !0;
|
|
24
|
-
e = e.parentElement;
|
|
25
|
-
}
|
|
26
|
-
return !1;
|
|
27
|
-
}
|
|
1
|
+
const t = "_table_1outv_4", o = "_headerCell_1outv_18", e = "_rowCell_1outv_19", _ = "_caption_1outv_46", n = "_cellContent_1outv_71", l = "_sortIndicator_1outv_96", c = "_body_1outv_100", r = "_row_1outv_19", s = "_buttonText_1outv_164", a = {
|
|
2
|
+
table: t,
|
|
3
|
+
headerCell: o,
|
|
4
|
+
rowCell: e,
|
|
5
|
+
caption: _,
|
|
6
|
+
cellContent: n,
|
|
7
|
+
sortIndicator: l,
|
|
8
|
+
body: c,
|
|
9
|
+
row: r,
|
|
10
|
+
buttonText: s
|
|
11
|
+
};
|
|
28
12
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
c as body,
|
|
14
|
+
s as buttonText,
|
|
15
|
+
_ as caption,
|
|
16
|
+
n as cellContent,
|
|
17
|
+
a as default,
|
|
18
|
+
o as headerCell,
|
|
19
|
+
r as row,
|
|
20
|
+
e as rowCell,
|
|
21
|
+
l as sortIndicator,
|
|
22
|
+
t as table
|
|
31
23
|
};
|
|
32
24
|
//# sourceMappingURL=fondue-components72.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components72.js","sources":[
|
|
1
|
+
{"version":3,"file":"fondue-components72.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|