mcr-design-systems 1.0.214 → 1.0.216
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/components/Icon/generated/FileErrorIcon.d.ts +38 -0
- package/dist/components/Icon/generated/FileErrorIcon.js +56 -0
- package/dist/components/Icon/generated/FileSuccessIcon.d.ts +38 -0
- package/dist/components/Icon/generated/FileSuccessIcon.js +56 -0
- package/dist/components/Icon/helper/index.d.ts +1 -1
- package/dist/components/Icon/helper/mapicon.js +3 -1
- package/dist/components/Select/index.d.ts +5 -0
- package/dist/components/Select/index.js +234 -233
- package/dist/shared/hooks/useChipOverflow.js +62 -57
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface FileErrorIconProps {
|
|
3
|
+
/**
|
|
4
|
+
* Icon size in pixels
|
|
5
|
+
* @default 24
|
|
6
|
+
*/
|
|
7
|
+
size?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Icon color - CSS color value
|
|
10
|
+
* @default 'currentColor'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Additional CSS class names
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom styles
|
|
19
|
+
*/
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
/**
|
|
22
|
+
* Click handler
|
|
23
|
+
*/
|
|
24
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* ARIA label for accessibility
|
|
27
|
+
*/
|
|
28
|
+
'aria-label'?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Title attribute for tooltip
|
|
31
|
+
*/
|
|
32
|
+
title?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* FileError icon component
|
|
36
|
+
*/
|
|
37
|
+
export declare const FileErrorIcon: React.FC<FileErrorIconProps>;
|
|
38
|
+
export default FileErrorIcon;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import u from "react";
|
|
3
|
+
const v = ({
|
|
4
|
+
size: r = 24,
|
|
5
|
+
color: i = "currentColor",
|
|
6
|
+
className: C,
|
|
7
|
+
style: s,
|
|
8
|
+
onClick: o,
|
|
9
|
+
"aria-label": g,
|
|
10
|
+
title: a
|
|
11
|
+
}) => {
|
|
12
|
+
const c = u.useMemo(() => {
|
|
13
|
+
const t = new DOMParser().parseFromString(`<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
14
|
+
<path d="M7 21.2002V10.7998C7 9.97632 6.99898 9.29843 7.04395 8.74805C7.08988 8.18599 7.18827 7.6689 7.43555 7.1836C7.81902 6.43109 8.43109 5.81902 9.1836 5.43555C9.6689 5.18827 10.186 5.08988 10.748 5.04395C11.2984 4.99898 11.9763 5 12.7998 5H18L18.0986 5.00488C18.3276 5.02757 18.5429 5.12883 18.707 5.29297L24.707 11.293C24.8946 11.4805 25 11.7348 25 12V21.2002C25 22.0237 25.001 22.7016 24.9561 23.252C24.9101 23.814 24.8117 24.3311 24.5645 24.8164C24.181 25.5689 23.5689 26.181 22.8164 26.5645C22.3311 26.8117 21.814 26.9101 21.252 26.9561C20.7016 27.001 20.0237 27 19.2002 27H12.7998C11.9763 27 11.2984 27.001 10.748 26.9561C10.186 26.9101 9.6689 26.8117 9.1836 26.5645C8.43109 26.181 7.81902 25.5689 7.43555 24.8164C7.18827 24.3311 7.08988 23.814 7.04395 23.252C6.99898 22.7016 7 22.0237 7 21.2002ZM20 20C20.5523 20 21 20.4477 21 21C21 21.5523 20.5523 22 20 22H12C11.4477 22 11 21.5523 11 21C11 20.4477 11.4477 20 12 20H20ZM20 16C20.5523 16 21 16.4477 21 17C21 17.5523 20.5523 18 20 18H12C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16H20ZM14 12C14.5523 12 15 12.4477 15 13C15 13.5523 14.5523 14 14 14H12C11.4477 14 11 13.5523 11 13C11 12.4477 11.4477 12 12 12H14ZM9 21.2002C9 22.0566 9.00035 22.6388 9.03711 23.0889C9.07293 23.5273 9.13809 23.7518 9.21778 23.9082C9.40951 24.2845 9.71555 24.5905 10.0918 24.7822C10.2482 24.8619 10.4727 24.9271 10.9111 24.9629C11.3612 24.9997 11.9434 25 12.7998 25H19.2002C20.0566 25 20.6388 24.9997 21.0889 24.9629C21.5273 24.9271 21.7518 24.8619 21.9082 24.7822C22.2845 24.5905 22.5905 24.2845 22.7822 23.9082C22.8619 23.7518 22.9271 23.5273 22.9629 23.0889C22.9997 22.6388 23 22.0566 23 21.2002V13H19.5996C19.3362 13 19.0781 13.0011 18.8613 12.9834C18.6328 12.9647 18.3631 12.9204 18.0918 12.7822C17.7155 12.5905 17.4095 12.2845 17.2178 11.9082C17.0795 11.6369 17.0353 11.3672 17.0166 11.1387C16.9989 10.9218 17 10.6638 17 10.4004V7H12.7998C11.9434 7 11.3612 7.00035 10.9111 7.03711C10.4727 7.07293 10.2482 7.13809 10.0918 7.21778C9.71555 7.40951 9.40951 7.71555 9.21778 8.0918C9.13809 8.2482 9.07293 8.47272 9.03711 8.91113C9.00035 9.36117 9 9.94342 9 10.7998V21.2002ZM19 10.4004C19 10.6967 19.0012 10.859 19.0107 10.9756C19.0111 10.98 19.0114 10.9843 19.0117 10.9883C19.0157 10.9887 19.0199 10.9899 19.0244 10.9902C19.141 10.9998 19.3033 11 19.5996 11H21.5859L19 8.41406V10.4004Z" fill="black"/>
|
|
15
|
+
<path d="M32 26C32 22.6863 29.3137 20 26 20C22.6863 20 20 22.6863 20 26C20 29.3137 22.6863 32 26 32C29.3137 32 32 29.3137 32 26Z" fill="white"/>
|
|
16
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M26 20.5C22.9624 20.5 20.5 22.9624 20.5 26C20.5 29.0376 22.9624 31.5 26 31.5C29.0376 31.5 31.5 29.0376 31.5 26C31.5 22.9624 29.0376 20.5 26 20.5ZM26.5 24C26.5 23.7239 26.2761 23.5 26 23.5C25.7239 23.5 25.5 23.7239 25.5 24V26C25.5 26.2761 25.7239 26.5 26 26.5C26.2761 26.5 26.5 26.2761 26.5 26V24ZM26 27.5C25.7239 27.5 25.5 27.7239 25.5 28C25.5 28.2761 25.7239 28.5 26 28.5H26.005C26.2811 28.5 26.505 28.2761 26.505 28C26.505 27.7239 26.2811 27.5 26.005 27.5H26Z" fill="#DC2626"/>
|
|
17
|
+
</svg>
|
|
18
|
+
`, "image/svg+xml").querySelector("svg");
|
|
19
|
+
if (!t) return "";
|
|
20
|
+
if (t.setAttribute("width", r.toString()), t.setAttribute("height", r.toString()), t.querySelectorAll(
|
|
21
|
+
"path, circle, rect, polygon, polyline, line, ellipse"
|
|
22
|
+
).forEach((e) => {
|
|
23
|
+
const l = e.getAttribute("fill"), n = e.getAttribute("stroke");
|
|
24
|
+
l && l !== "none" && e.setAttribute("fill", i), n && n !== "none" && e.setAttribute("stroke", i);
|
|
25
|
+
}), C) {
|
|
26
|
+
const e = t.getAttribute("class") || "";
|
|
27
|
+
t.setAttribute(
|
|
28
|
+
"class",
|
|
29
|
+
`${e} ${C}`.trim()
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return new XMLSerializer().serializeToString(t);
|
|
33
|
+
}, [r, i, C]);
|
|
34
|
+
return /* @__PURE__ */ f(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: C,
|
|
38
|
+
style: {
|
|
39
|
+
display: "inline-flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
flexShrink: 0,
|
|
43
|
+
lineHeight: 0,
|
|
44
|
+
...s
|
|
45
|
+
},
|
|
46
|
+
onClick: o,
|
|
47
|
+
"aria-label": g || "file-error icon",
|
|
48
|
+
title: a,
|
|
49
|
+
dangerouslySetInnerHTML: { __html: c }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
v as FileErrorIcon,
|
|
55
|
+
v as default
|
|
56
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface FileSuccessIconProps {
|
|
3
|
+
/**
|
|
4
|
+
* Icon size in pixels
|
|
5
|
+
* @default 24
|
|
6
|
+
*/
|
|
7
|
+
size?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Icon color - CSS color value
|
|
10
|
+
* @default 'currentColor'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Additional CSS class names
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom styles
|
|
19
|
+
*/
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
/**
|
|
22
|
+
* Click handler
|
|
23
|
+
*/
|
|
24
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* ARIA label for accessibility
|
|
27
|
+
*/
|
|
28
|
+
'aria-label'?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Title attribute for tooltip
|
|
31
|
+
*/
|
|
32
|
+
title?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* FileSuccess icon component
|
|
36
|
+
*/
|
|
37
|
+
export declare const FileSuccessIcon: React.FC<FileSuccessIconProps>;
|
|
38
|
+
export default FileSuccessIcon;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import f from "react";
|
|
3
|
+
const A = ({
|
|
4
|
+
size: r = 24,
|
|
5
|
+
color: i = "currentColor",
|
|
6
|
+
className: C,
|
|
7
|
+
style: n,
|
|
8
|
+
onClick: o,
|
|
9
|
+
"aria-label": c,
|
|
10
|
+
title: g
|
|
11
|
+
}) => {
|
|
12
|
+
const a = f.useMemo(() => {
|
|
13
|
+
const t = new DOMParser().parseFromString(`<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
14
|
+
<path d="M7 21.2002V10.7998C7 9.97632 6.99898 9.29843 7.04395 8.74805C7.08988 8.18599 7.18827 7.6689 7.43555 7.1836C7.81902 6.43109 8.43109 5.81902 9.1836 5.43555C9.6689 5.18827 10.186 5.08988 10.748 5.04395C11.2984 4.99898 11.9763 5 12.7998 5H18L18.0986 5.00488C18.3276 5.02757 18.5429 5.12883 18.707 5.29297L24.707 11.293C24.8946 11.4805 25 11.7348 25 12V21.2002C25 22.0237 25.001 22.7016 24.9561 23.252C24.9101 23.814 24.8117 24.3311 24.5645 24.8164C24.181 25.5689 23.5689 26.181 22.8164 26.5645C22.3311 26.8117 21.814 26.9101 21.252 26.9561C20.7016 27.001 20.0237 27 19.2002 27H12.7998C11.9763 27 11.2984 27.001 10.748 26.9561C10.186 26.9101 9.6689 26.8117 9.1836 26.5645C8.43109 26.181 7.81902 25.5689 7.43555 24.8164C7.18827 24.3311 7.08988 23.814 7.04395 23.252C6.99898 22.7016 7 22.0237 7 21.2002ZM20 20C20.5523 20 21 20.4477 21 21C21 21.5523 20.5523 22 20 22H12C11.4477 22 11 21.5523 11 21C11 20.4477 11.4477 20 12 20H20ZM20 16C20.5523 16 21 16.4477 21 17C21 17.5523 20.5523 18 20 18H12C11.4477 18 11 17.5523 11 17C11 16.4477 11.4477 16 12 16H20ZM14 12C14.5523 12 15 12.4477 15 13C15 13.5523 14.5523 14 14 14H12C11.4477 14 11 13.5523 11 13C11 12.4477 11.4477 12 12 12H14ZM9 21.2002C9 22.0566 9.00035 22.6388 9.03711 23.0889C9.07293 23.5273 9.13809 23.7518 9.21778 23.9082C9.40951 24.2845 9.71555 24.5905 10.0918 24.7822C10.2482 24.8619 10.4727 24.9271 10.9111 24.9629C11.3612 24.9997 11.9434 25 12.7998 25H19.2002C20.0566 25 20.6388 24.9997 21.0889 24.9629C21.5273 24.9271 21.7518 24.8619 21.9082 24.7822C22.2845 24.5905 22.5905 24.2845 22.7822 23.9082C22.8619 23.7518 22.9271 23.5273 22.9629 23.0889C22.9997 22.6388 23 22.0566 23 21.2002V13H19.5996C19.3362 13 19.0781 13.0011 18.8613 12.9834C18.6328 12.9647 18.3631 12.9204 18.0918 12.7822C17.7155 12.5905 17.4095 12.2845 17.2178 11.9082C17.0795 11.6369 17.0353 11.3672 17.0166 11.1387C16.9989 10.9218 17 10.6638 17 10.4004V7H12.7998C11.9434 7 11.3612 7.00035 10.9111 7.03711C10.4727 7.07293 10.2482 7.13809 10.0918 7.21778C9.71555 7.40951 9.40951 7.71555 9.21778 8.0918C9.13809 8.2482 9.07293 8.47272 9.03711 8.91113C9.00035 9.36117 9 9.94342 9 10.7998V21.2002ZM19 10.4004C19 10.6967 19.0012 10.859 19.0107 10.9756C19.0111 10.98 19.0114 10.9843 19.0117 10.9883C19.0157 10.9887 19.0199 10.9899 19.0244 10.9902C19.141 10.9998 19.3033 11 19.5996 11H21.5859L19 8.41406V10.4004Z" fill="black"/>
|
|
15
|
+
<path d="M32 26C32 29.3137 29.3137 32 26 32C22.6863 32 20 29.3137 20 26C20 22.6863 22.6863 20 26 20C29.3137 20 32 22.6863 32 26Z" fill="white"/>
|
|
16
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M26 20.5C22.9624 20.5 20.5 22.9624 20.5 26C20.5 29.0376 22.9624 31.5 26 31.5C29.0376 31.5 31.5 29.0376 31.5 26C31.5 22.9624 29.0376 20.5 26 20.5ZM28.6036 24.8536C28.7988 24.6583 28.7988 24.3417 28.6036 24.1464C28.4083 23.9512 28.0917 23.9512 27.8964 24.1464L25.25 26.7929L24.1036 25.6464C23.9083 25.4512 23.5917 25.4512 23.3964 25.6464C23.2012 25.8417 23.2012 26.1583 23.3964 26.3536L24.8964 27.8536C25.0917 28.0488 25.4083 28.0488 25.6036 27.8536L28.6036 24.8536Z" fill="#16A34A"/>
|
|
17
|
+
</svg>
|
|
18
|
+
`, "image/svg+xml").querySelector("svg");
|
|
19
|
+
if (!t) return "";
|
|
20
|
+
if (t.setAttribute("width", r.toString()), t.setAttribute("height", r.toString()), t.querySelectorAll(
|
|
21
|
+
"path, circle, rect, polygon, polyline, line, ellipse"
|
|
22
|
+
).forEach((e) => {
|
|
23
|
+
const l = e.getAttribute("fill"), s = e.getAttribute("stroke");
|
|
24
|
+
l && l !== "none" && e.setAttribute("fill", i), s && s !== "none" && e.setAttribute("stroke", i);
|
|
25
|
+
}), C) {
|
|
26
|
+
const e = t.getAttribute("class") || "";
|
|
27
|
+
t.setAttribute(
|
|
28
|
+
"class",
|
|
29
|
+
`${e} ${C}`.trim()
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return new XMLSerializer().serializeToString(t);
|
|
33
|
+
}, [r, i, C]);
|
|
34
|
+
return /* @__PURE__ */ u(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
className: C,
|
|
38
|
+
style: {
|
|
39
|
+
display: "inline-flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
flexShrink: 0,
|
|
43
|
+
lineHeight: 0,
|
|
44
|
+
...n
|
|
45
|
+
},
|
|
46
|
+
onClick: o,
|
|
47
|
+
"aria-label": c || "file-success icon",
|
|
48
|
+
title: g,
|
|
49
|
+
dangerouslySetInnerHTML: { __html: a }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
A as FileSuccessIcon,
|
|
55
|
+
A as default
|
|
56
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type IconName = 'activity' | 'activity-heart' | 'alarm-clock' | 'alarm-clock-check' | 'alert-circle' | 'alert-octagon' | 'alert-triangle' | 'align-left' | 'align-right' | 'arrow-down' | 'arrow-square-down' | 'arrow-square-up' | 'arrow-up' | 'bank-note-03' | 'bell-01' | 'bell-off-01' | 'bookmark-x' | 'building-02' | 'calendar' | 'camera-01' | 'check' | 'check-circle' | 'check-circle-broken' | 'chevron-down' | 'chevron-left' | 'chevron-left-double' | 'chevron-right' | 'chevron-right-double' | 'chevron-up' | 'circle' | 'clock-rewind' | 'credit-card-02' | 'credit-card-check' | 'credit-card-x' | 'dots-horizontal' | 'dots-vertical' | 'download-01' | 'edit-02' | 'eye' | 'eye-off' | 'file-06' | 'file-search-02' | 'filter-funnel-01' | 'folder-shield' | 'gift-02' | 'globe-01' | 'grid-01' | 'headphones-02' | 'heart' | 'help-circle' | 'home-02' | 'hourglass-03' | 'id-card' | 'image-03' | 'image-plus' | 'info-circle' | 'layers-three-01' | 'link-external-01' | 'list' | 'loading-01' | 'log-out-01' | 'mail-01' | 'map-01' | 'mark' | 'marker-pin-01' | 'marker-pin-02' | 'message-question-square' | 'minus' | 'navigation-pointer-01' | 'phone' | 'plus' | 'refresh-cw-01' | 'refresh-cw-01-rotate' | 'refresh-cw_05' | 'reset-password' | 'sale-03' | 'search-lg' | 'search-md' | 'settings-01' | 'shield-tick' | 'switch-horizontal-01' | 'tag-01' | 'trash-01' | 'upload-01' | 'user-01' | 'user-03' | 'user-circle' | 'x-circle' | 'x-close';
|
|
1
|
+
export type IconName = 'activity' | 'activity-heart' | 'alarm-clock' | 'alarm-clock-check' | 'alert-circle' | 'alert-octagon' | 'alert-triangle' | 'align-left' | 'align-right' | 'arrow-down' | 'arrow-square-down' | 'arrow-square-up' | 'arrow-up' | 'bank-note-03' | 'bell-01' | 'bell-off-01' | 'bookmark-x' | 'building-02' | 'calendar' | 'camera-01' | 'check' | 'check-circle' | 'check-circle-broken' | 'chevron-down' | 'chevron-left' | 'chevron-left-double' | 'chevron-right' | 'chevron-right-double' | 'chevron-up' | 'circle' | 'clock-rewind' | 'credit-card-02' | 'credit-card-check' | 'credit-card-x' | 'dots-horizontal' | 'dots-vertical' | 'download-01' | 'edit-02' | 'eye' | 'eye-off' | 'file-06' | 'file-error' | 'file-search-02' | 'file-success' | 'filter-funnel-01' | 'folder-shield' | 'gift-02' | 'globe-01' | 'grid-01' | 'headphones-02' | 'heart' | 'help-circle' | 'home-02' | 'hourglass-03' | 'id-card' | 'image-03' | 'image-plus' | 'info-circle' | 'layers-three-01' | 'link-external-01' | 'list' | 'loading-01' | 'log-out-01' | 'mail-01' | 'map-01' | 'mark' | 'marker-pin-01' | 'marker-pin-02' | 'message-question-square' | 'minus' | 'navigation-pointer-01' | 'phone' | 'plus' | 'refresh-cw-01' | 'refresh-cw-01-rotate' | 'refresh-cw_05' | 'reset-password' | 'sale-03' | 'search-lg' | 'search-md' | 'settings-01' | 'shield-tick' | 'switch-horizontal-01' | 'tag-01' | 'trash-01' | 'upload-01' | 'user-01' | 'user-03' | 'user-circle' | 'x-circle' | 'x-close';
|
|
@@ -173,7 +173,9 @@ const i = {
|
|
|
173
173
|
"refresh-cw-01-rotate-solid": () => import("../generated/RefreshCw01RotateSolidIcon.js"),
|
|
174
174
|
"refresh-cw-01-rotate": () => import("../generated/RefreshCw01RotateIcon.js"),
|
|
175
175
|
"image-plus": () => import("../generated/ImagePlusIcon.js"),
|
|
176
|
-
"image-plus-solid": () => import("../generated/ImagePlusSolidIcon.js")
|
|
176
|
+
"image-plus-solid": () => import("../generated/ImagePlusSolidIcon.js"),
|
|
177
|
+
"file-error": () => import("../generated/FileErrorIcon.js"),
|
|
178
|
+
"file-success": () => import("../generated/FileSuccessIcon.js")
|
|
177
179
|
};
|
|
178
180
|
export {
|
|
179
181
|
i as MAP_ICON
|
|
@@ -125,6 +125,11 @@ export interface SelectProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
125
125
|
* Test identifier
|
|
126
126
|
*/
|
|
127
127
|
'data-testid'?: string;
|
|
128
|
+
/**
|
|
129
|
+
* All items (unfiltered) for selectedItems mapping when using search
|
|
130
|
+
* This ensures selected items always have proper labels even when filtered
|
|
131
|
+
*/
|
|
132
|
+
allItems?: (DropdownItem | DropdownGroup)[];
|
|
128
133
|
/**
|
|
129
134
|
* Custom width for select and dropdown
|
|
130
135
|
*/
|
|
@@ -1,104 +1,105 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { dataTestId as
|
|
5
|
-
import { Typography as
|
|
1
|
+
import { jsxs as g, jsx as t, Fragment as Re } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Te, useState as ke, useRef as je, useCallback as T, useMemo as P, memo as De } from "react";
|
|
3
|
+
import { cn as d } from "../../shared/utils/cn.js";
|
|
4
|
+
import { dataTestId as Ee } from "../../shared/utils/dataTestId.js";
|
|
5
|
+
import { Typography as z } from "../Typography/index.js";
|
|
6
6
|
import C from "../Icon/Icon.js";
|
|
7
|
-
import { Dropdown as
|
|
8
|
-
import { selectVariants as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { useChipOverflow as
|
|
12
|
-
const
|
|
7
|
+
import { Dropdown as ie } from "../Dropdown/index.js";
|
|
8
|
+
import { selectVariants as Fe } from "./helper/variants.js";
|
|
9
|
+
import ce from "../Chip/index.js";
|
|
10
|
+
import Pe from "../TextField/HelperText.js";
|
|
11
|
+
import { useChipOverflow as ze } from "../../shared/hooks/useChipOverflow.js";
|
|
12
|
+
const me = Te(
|
|
13
13
|
({
|
|
14
14
|
items: M = [],
|
|
15
15
|
value: r,
|
|
16
16
|
onChange: y,
|
|
17
17
|
placeholder: b = "Select an option...",
|
|
18
18
|
disabled: a = !1,
|
|
19
|
-
readOnly:
|
|
20
|
-
loading:
|
|
21
|
-
showCheckmark:
|
|
22
|
-
emptyText:
|
|
23
|
-
state:
|
|
24
|
-
label:
|
|
25
|
-
helpText:
|
|
26
|
-
required:
|
|
27
|
-
leadingIcon:
|
|
28
|
-
trailingIcon:
|
|
19
|
+
readOnly: n = !1,
|
|
20
|
+
loading: V = !1,
|
|
21
|
+
showCheckmark: q = !1,
|
|
22
|
+
emptyText: G = "No options available",
|
|
23
|
+
state: k,
|
|
24
|
+
label: J,
|
|
25
|
+
helpText: pe,
|
|
26
|
+
required: fe = !1,
|
|
27
|
+
leadingIcon: c,
|
|
28
|
+
trailingIcon: m,
|
|
29
29
|
mode: o = "single",
|
|
30
|
-
displayType:
|
|
31
|
-
maxDisplayChips:
|
|
30
|
+
displayType: ue = "chip",
|
|
31
|
+
maxDisplayChips: Ve,
|
|
32
32
|
// eslint-disable-line @typescript-eslint/no-unused-vars -- kept for backward compatibility
|
|
33
|
-
moreItemsText:
|
|
34
|
-
trigger:
|
|
35
|
-
side:
|
|
36
|
-
align:
|
|
37
|
-
sideOffset:
|
|
38
|
-
enableVirtualization:
|
|
39
|
-
itemHeight:
|
|
40
|
-
maxHeight:
|
|
41
|
-
size:
|
|
42
|
-
variant:
|
|
43
|
-
fullWidth:
|
|
44
|
-
className:
|
|
45
|
-
iconsSize:
|
|
33
|
+
moreItemsText: he = "+{count}",
|
|
34
|
+
trigger: de,
|
|
35
|
+
side: K = "bottom",
|
|
36
|
+
align: L = "start",
|
|
37
|
+
sideOffset: Q = 4,
|
|
38
|
+
enableVirtualization: U,
|
|
39
|
+
itemHeight: W = 32,
|
|
40
|
+
maxHeight: X = 300,
|
|
41
|
+
size: s = "md",
|
|
42
|
+
variant: j = "default",
|
|
43
|
+
fullWidth: D = !1,
|
|
44
|
+
className: ge,
|
|
45
|
+
iconsSize: xe,
|
|
46
46
|
"data-testid": l,
|
|
47
47
|
width: A,
|
|
48
|
-
error:
|
|
49
|
-
haveIcon:
|
|
50
|
-
iconsCustom:
|
|
51
|
-
onBlur:
|
|
52
|
-
dropdownProps:
|
|
53
|
-
allowSearch:
|
|
54
|
-
title:
|
|
55
|
-
onSearchChange:
|
|
56
|
-
searchValue:
|
|
57
|
-
showClearButton:
|
|
58
|
-
searchPlaceholder:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
error: Y,
|
|
49
|
+
haveIcon: Ne,
|
|
50
|
+
iconsCustom: ve,
|
|
51
|
+
onBlur: Z,
|
|
52
|
+
dropdownProps: _,
|
|
53
|
+
allowSearch: H,
|
|
54
|
+
title: E,
|
|
55
|
+
onSearchChange: B,
|
|
56
|
+
searchValue: I,
|
|
57
|
+
showClearButton: O = !1,
|
|
58
|
+
searchPlaceholder: ee = "Search...",
|
|
59
|
+
allItems: S,
|
|
60
|
+
...Ce
|
|
61
|
+
}, ye) => {
|
|
62
|
+
const [p, $] = ke(!1), be = je(null), i = Fe({
|
|
63
|
+
size: s,
|
|
64
|
+
variant: j,
|
|
65
|
+
fullWidth: D,
|
|
66
|
+
state: k,
|
|
66
67
|
disabled: a,
|
|
67
|
-
readOnly:
|
|
68
|
-
}),
|
|
68
|
+
readOnly: n
|
|
69
|
+
}), Ae = T(
|
|
69
70
|
(e) => {
|
|
70
|
-
if (o === "multiple" && Array.isArray(r) && !a && !
|
|
71
|
-
const
|
|
72
|
-
y?.(
|
|
71
|
+
if (o === "multiple" && Array.isArray(r) && !a && !n) {
|
|
72
|
+
const u = r.filter((h) => h !== e);
|
|
73
|
+
y?.(u);
|
|
73
74
|
}
|
|
74
75
|
},
|
|
75
|
-
[o, r, y, a,
|
|
76
|
-
),
|
|
77
|
-
o === "multiple" && Array.isArray(r) && r.length > 0 && !a && !
|
|
78
|
-
}, [o, r, y, a,
|
|
76
|
+
[o, r, y, a, n]
|
|
77
|
+
), te = T(() => {
|
|
78
|
+
o === "multiple" && Array.isArray(r) && r.length > 0 && !a && !n && y?.([]);
|
|
79
|
+
}, [o, r, y, a, n]), f = P(() => {
|
|
79
80
|
if (!r) return [];
|
|
80
|
-
const e = Array.isArray(r) ? r : [r],
|
|
81
|
-
return ((
|
|
82
|
-
|
|
83
|
-
"items" in v ? v.items.forEach((
|
|
84
|
-
|
|
85
|
-
}) :
|
|
81
|
+
const e = Array.isArray(r) ? r : [r], u = S && S.length > 0 ? S : M, h = /* @__PURE__ */ new Map();
|
|
82
|
+
return ((w) => {
|
|
83
|
+
w.forEach((v) => {
|
|
84
|
+
"items" in v ? v.items.forEach((le) => {
|
|
85
|
+
h.set(le.value, le);
|
|
86
|
+
}) : h.set(v.value, v);
|
|
86
87
|
});
|
|
87
|
-
})(
|
|
88
|
-
const v =
|
|
88
|
+
})(u), e.map((w) => {
|
|
89
|
+
const v = h.get(w);
|
|
89
90
|
return v || {
|
|
90
|
-
value:
|
|
91
|
-
label:
|
|
91
|
+
value: w,
|
|
92
|
+
label: w
|
|
92
93
|
};
|
|
93
94
|
});
|
|
94
|
-
}, [r, M]),
|
|
95
|
+
}, [r, M, S]), F = P(() => {
|
|
95
96
|
if (o === "single") {
|
|
96
|
-
const e =
|
|
97
|
+
const e = f[0];
|
|
97
98
|
return e ? e.label : b;
|
|
98
99
|
}
|
|
99
|
-
return o === "multiple" ? r?.length === 0 ? b :
|
|
100
|
-
}, [o,
|
|
101
|
-
items: o === "multiple" && Array.isArray(r) ?
|
|
100
|
+
return o === "multiple" ? r?.length === 0 ? b : E ? `${E} ` : "" : "";
|
|
101
|
+
}, [o, f, b, E, r]), x = ze({
|
|
102
|
+
items: o === "multiple" && Array.isArray(r) ? f.map((e) => ({
|
|
102
103
|
value: e.value,
|
|
103
104
|
label: e.label
|
|
104
105
|
})) : [],
|
|
@@ -107,36 +108,36 @@ const ie = $e(
|
|
|
107
108
|
minChipsToShow: 1,
|
|
108
109
|
moreChipWidth: 60
|
|
109
110
|
// Estimated width for "+X more" chip
|
|
110
|
-
}),
|
|
111
|
+
}), R = P(() => {
|
|
111
112
|
if (o !== "multiple" || !Array.isArray(r))
|
|
112
113
|
return {
|
|
113
114
|
displayItems: [],
|
|
114
115
|
remainingCount: 0,
|
|
115
116
|
hasMore: !1
|
|
116
117
|
};
|
|
117
|
-
const
|
|
118
|
-
displayItems:
|
|
119
|
-
(
|
|
118
|
+
const u = {
|
|
119
|
+
displayItems: x.displayItems.map((h) => f.find(
|
|
120
|
+
(oe) => oe.value === h.value
|
|
120
121
|
) || {
|
|
121
|
-
value:
|
|
122
|
-
label:
|
|
122
|
+
value: h.value,
|
|
123
|
+
label: h.label
|
|
123
124
|
}),
|
|
124
|
-
remainingCount:
|
|
125
|
-
hasMore:
|
|
125
|
+
remainingCount: x.remainingCount,
|
|
126
|
+
hasMore: x.hasMore
|
|
126
127
|
};
|
|
127
|
-
return
|
|
128
|
-
displayItems: [
|
|
129
|
-
remainingCount: Math.max(0,
|
|
130
|
-
hasMore:
|
|
131
|
-
} :
|
|
128
|
+
return f.length > 0 && u.displayItems.length === 0 && !u.hasMore ? {
|
|
129
|
+
displayItems: [f[0]],
|
|
130
|
+
remainingCount: Math.max(0, f.length - 1),
|
|
131
|
+
hasMore: f.length > 1
|
|
132
|
+
} : u;
|
|
132
133
|
}, [
|
|
133
134
|
o,
|
|
134
135
|
r,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]),
|
|
136
|
+
x.displayItems,
|
|
137
|
+
x.remainingCount,
|
|
138
|
+
x.hasMore,
|
|
139
|
+
f
|
|
140
|
+
]), we = A ? { width: typeof A == "number" ? `${A}px` : A } : {}, Me = d(i.container(), ge), N = (e) => {
|
|
140
141
|
switch (e) {
|
|
141
142
|
case "sm":
|
|
142
143
|
return 16;
|
|
@@ -147,7 +148,7 @@ const ie = $e(
|
|
|
147
148
|
default:
|
|
148
149
|
return 16;
|
|
149
150
|
}
|
|
150
|
-
},
|
|
151
|
+
}, re = (e) => {
|
|
151
152
|
switch (e) {
|
|
152
153
|
case "sm":
|
|
153
154
|
return "small";
|
|
@@ -158,157 +159,157 @@ const ie = $e(
|
|
|
158
159
|
default:
|
|
159
160
|
return "medium";
|
|
160
161
|
}
|
|
161
|
-
},
|
|
162
|
+
}, ae = T((e) => !!(e.closest('[data-testid*="chip"]') || e.closest('[data-testid*="clear-all"]') || e.closest('[data-no-trigger="true"]') || e.closest('[role="button"]') && e.closest('[data-testid*="chip"]')), []), ne = T(
|
|
162
163
|
(e) => {
|
|
163
|
-
const
|
|
164
|
-
return
|
|
164
|
+
const u = e.target;
|
|
165
|
+
return ae(u) ? (e.preventDefault(), e.stopPropagation(), !0) : !1;
|
|
165
166
|
},
|
|
166
|
-
[
|
|
167
|
+
[ae]
|
|
167
168
|
), se = (e) => {
|
|
168
|
-
|
|
169
|
+
$(e), !e && Z && Z(
|
|
169
170
|
new FocusEvent("blur")
|
|
170
171
|
);
|
|
171
|
-
},
|
|
172
|
+
}, Se = () => /* @__PURE__ */ g(
|
|
172
173
|
"div",
|
|
173
174
|
{
|
|
174
175
|
className: i.trigger(),
|
|
175
|
-
"data-state":
|
|
176
|
+
"data-state": p ? "open" : "closed",
|
|
176
177
|
children: [
|
|
177
|
-
|
|
178
|
+
c && /* @__PURE__ */ t("span", { className: i.leadingIcon(), children: c.node || c.name && /* @__PURE__ */ t(
|
|
178
179
|
C,
|
|
179
180
|
{
|
|
180
|
-
name:
|
|
181
|
-
size:
|
|
182
|
-
"aria-label":
|
|
181
|
+
name: c.name,
|
|
182
|
+
size: N(s),
|
|
183
|
+
"aria-label": c["aria-label"]
|
|
183
184
|
}
|
|
184
185
|
) }),
|
|
185
186
|
/* @__PURE__ */ t(
|
|
186
187
|
"span",
|
|
187
188
|
{
|
|
188
|
-
className:
|
|
189
|
+
className: d(
|
|
189
190
|
"flex-1 truncate text-left",
|
|
190
|
-
|
|
191
|
+
f.length > 0 ? "text-fg-neutral-main" : i.placeholder()
|
|
191
192
|
),
|
|
192
|
-
children:
|
|
193
|
+
children: F
|
|
193
194
|
}
|
|
194
195
|
),
|
|
195
|
-
|
|
196
|
+
m ? /* @__PURE__ */ t("span", { className: i.trailingIcon(), children: m.node || m.name && /* @__PURE__ */ t(
|
|
196
197
|
C,
|
|
197
198
|
{
|
|
198
|
-
name:
|
|
199
|
-
size:
|
|
200
|
-
"aria-label":
|
|
199
|
+
name: m.name,
|
|
200
|
+
size: N(s),
|
|
201
|
+
"aria-label": m["aria-label"]
|
|
201
202
|
}
|
|
202
203
|
) }) : /* @__PURE__ */ t(
|
|
203
204
|
C,
|
|
204
205
|
{
|
|
205
|
-
name:
|
|
206
|
-
size:
|
|
207
|
-
className:
|
|
206
|
+
name: p ? "chevron-up" : "chevron-down",
|
|
207
|
+
size: N(s),
|
|
208
|
+
className: d(i.chevron(), p && "rotate-180")
|
|
208
209
|
}
|
|
209
210
|
)
|
|
210
211
|
]
|
|
211
212
|
}
|
|
212
213
|
);
|
|
213
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ g(
|
|
214
215
|
"div",
|
|
215
216
|
{
|
|
216
|
-
ref:
|
|
217
|
-
className:
|
|
218
|
-
style:
|
|
219
|
-
...
|
|
220
|
-
...
|
|
217
|
+
ref: ye,
|
|
218
|
+
className: Me,
|
|
219
|
+
style: we,
|
|
220
|
+
...Ee(l || "select"),
|
|
221
|
+
...Ce,
|
|
221
222
|
children: [
|
|
222
|
-
|
|
223
|
-
/* @__PURE__ */ t(
|
|
224
|
-
|
|
223
|
+
J && /* @__PURE__ */ g("div", { className: "mb-1 flex items-center gap-[2px]", children: [
|
|
224
|
+
/* @__PURE__ */ t(z, { variants: "action", size: "sm", color: "fg-neutral-subtle", children: J }),
|
|
225
|
+
fe && /* @__PURE__ */ t(z, { variants: "action", size: "sm", color: "fg-accent-error", children: "*" })
|
|
225
226
|
] }),
|
|
226
227
|
/* @__PURE__ */ t("div", { className: "relative h-11", children: o === "multiple" ? /* @__PURE__ */ t(
|
|
227
|
-
|
|
228
|
+
ie,
|
|
228
229
|
{
|
|
229
|
-
...
|
|
230
|
+
..._,
|
|
230
231
|
items: M,
|
|
231
232
|
value: r,
|
|
232
233
|
onValueChange: (e) => {
|
|
233
|
-
a ||
|
|
234
|
+
a || n || y?.(Array.isArray(e) ? e : [e]);
|
|
234
235
|
},
|
|
235
236
|
fullWidthContent: !0,
|
|
236
237
|
placeholder: b,
|
|
237
238
|
disabled: a,
|
|
238
|
-
loading:
|
|
239
|
-
showCheckmark:
|
|
240
|
-
emptyText:
|
|
241
|
-
state:
|
|
242
|
-
open:
|
|
239
|
+
loading: V,
|
|
240
|
+
showCheckmark: q,
|
|
241
|
+
emptyText: G,
|
|
242
|
+
state: k,
|
|
243
|
+
open: p,
|
|
243
244
|
onOpenChange: se,
|
|
244
|
-
side:
|
|
245
|
-
align:
|
|
246
|
-
search:
|
|
247
|
-
sideOffset:
|
|
248
|
-
enableVirtualization:
|
|
245
|
+
side: K,
|
|
246
|
+
align: L,
|
|
247
|
+
search: H,
|
|
248
|
+
sideOffset: Q,
|
|
249
|
+
enableVirtualization: U,
|
|
249
250
|
selectionMode: "separated",
|
|
250
251
|
multiSelect: !0,
|
|
251
|
-
itemHeight:
|
|
252
|
-
maxHeight:
|
|
253
|
-
size:
|
|
254
|
-
variant:
|
|
255
|
-
fullWidth:
|
|
256
|
-
searchPlaceholder:
|
|
252
|
+
itemHeight: W,
|
|
253
|
+
maxHeight: X,
|
|
254
|
+
size: s,
|
|
255
|
+
variant: j,
|
|
256
|
+
fullWidth: D,
|
|
257
|
+
searchPlaceholder: ee,
|
|
257
258
|
width: A,
|
|
258
259
|
"data-testid": l ? `${l}-dropdown` : void 0,
|
|
259
|
-
showClearButton:
|
|
260
|
-
onClear:
|
|
261
|
-
searchValue:
|
|
262
|
-
onSearchChange:
|
|
260
|
+
showClearButton: O,
|
|
261
|
+
onClear: te,
|
|
262
|
+
searchValue: I,
|
|
263
|
+
onSearchChange: B,
|
|
263
264
|
className: "flex items-center",
|
|
264
|
-
children: /* @__PURE__ */
|
|
265
|
+
children: /* @__PURE__ */ g(
|
|
265
266
|
"div",
|
|
266
267
|
{
|
|
267
|
-
ref:
|
|
268
|
-
className:
|
|
268
|
+
ref: be,
|
|
269
|
+
className: d(
|
|
269
270
|
i.trigger({
|
|
270
|
-
state:
|
|
271
|
+
state: Y ? "error" : void 0
|
|
271
272
|
}),
|
|
272
273
|
"flex"
|
|
273
274
|
),
|
|
274
|
-
"data-state":
|
|
275
|
-
onPointerDown:
|
|
275
|
+
"data-state": p ? "open" : "closed",
|
|
276
|
+
onPointerDown: ne,
|
|
276
277
|
onClick: (e) => {
|
|
277
|
-
a ||
|
|
278
|
+
a || n || ne(e) || $(!p);
|
|
278
279
|
},
|
|
279
280
|
children: [
|
|
280
|
-
|
|
281
|
+
c && /* @__PURE__ */ t("span", { className: i.leadingIcon(), children: c.node || c.name && /* @__PURE__ */ t(
|
|
281
282
|
C,
|
|
282
283
|
{
|
|
283
|
-
name:
|
|
284
|
-
size:
|
|
285
|
-
"aria-label":
|
|
284
|
+
name: c.name,
|
|
285
|
+
size: N(s),
|
|
286
|
+
"aria-label": c["aria-label"],
|
|
286
287
|
className: "cursor-pointer"
|
|
287
288
|
}
|
|
288
289
|
) }),
|
|
289
290
|
/* @__PURE__ */ t(
|
|
290
291
|
"div",
|
|
291
292
|
{
|
|
292
|
-
className:
|
|
293
|
+
className: d(
|
|
293
294
|
"flex-1 flex flex-nowrap gap-1 min-h-0 overflow-hidden",
|
|
294
|
-
!a && !
|
|
295
|
+
!a && !n && "cursor-pointer"
|
|
295
296
|
),
|
|
296
|
-
children: Array.isArray(
|
|
297
|
+
children: Array.isArray(R) ? null : /* @__PURE__ */ t(Re, { children: ue === "chip" ? /* @__PURE__ */ g(
|
|
297
298
|
"div",
|
|
298
299
|
{
|
|
299
|
-
ref:
|
|
300
|
+
ref: x.containerRef,
|
|
300
301
|
className: "flex items-center gap-xs-3 flex-nowrap w-full max-w-full overflow-hidden",
|
|
301
302
|
children: [
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
R.displayItems.map((e) => /* @__PURE__ */ t(
|
|
304
|
+
ce,
|
|
304
305
|
{
|
|
305
|
-
size:
|
|
306
|
-
onRemove: !a && !
|
|
307
|
-
|
|
306
|
+
size: re(s),
|
|
307
|
+
onRemove: !a && !n ? () => {
|
|
308
|
+
Ae(e.value);
|
|
308
309
|
} : void 0,
|
|
309
310
|
className: "bg-bg-surface-level-3 flex-shrink-0",
|
|
310
311
|
variant: "neutral",
|
|
311
|
-
trailingIcon: !a && !
|
|
312
|
+
trailingIcon: !a && !n ? {
|
|
312
313
|
name: "x-close",
|
|
313
314
|
"aria-label": "Remove option"
|
|
314
315
|
} : void 0,
|
|
@@ -318,17 +319,17 @@ const ie = $e(
|
|
|
318
319
|
},
|
|
319
320
|
e.value
|
|
320
321
|
)),
|
|
321
|
-
|
|
322
|
-
|
|
322
|
+
R.hasMore && /* @__PURE__ */ t(
|
|
323
|
+
ce,
|
|
323
324
|
{
|
|
324
|
-
size:
|
|
325
|
+
size: re(s),
|
|
325
326
|
variant: "neutral",
|
|
326
327
|
className: "bg-bg-surface-level-3 flex-shrink-0",
|
|
327
328
|
dataTestIdName: `${l || "select"}-chip-more`,
|
|
328
329
|
onClick: (e) => e.stopPropagation(),
|
|
329
|
-
children:
|
|
330
|
+
children: he.replace(
|
|
330
331
|
"{count}",
|
|
331
|
-
|
|
332
|
+
R.remainingCount.toString()
|
|
332
333
|
)
|
|
333
334
|
}
|
|
334
335
|
)
|
|
@@ -339,45 +340,45 @@ const ie = $e(
|
|
|
339
340
|
/* @__PURE__ */ t(
|
|
340
341
|
"div",
|
|
341
342
|
{
|
|
342
|
-
className:
|
|
343
|
+
className: d(
|
|
343
344
|
i.placeholder(),
|
|
344
|
-
!a && !
|
|
345
|
+
!a && !n && "cursor-pointer"
|
|
345
346
|
),
|
|
346
|
-
children: Array.isArray(r) ? r?.length > 0 ? /* @__PURE__ */
|
|
347
|
-
|
|
347
|
+
children: Array.isArray(r) ? r?.length > 0 ? /* @__PURE__ */ g(
|
|
348
|
+
z,
|
|
348
349
|
{
|
|
349
350
|
variants: "body",
|
|
350
351
|
size: "md",
|
|
351
352
|
color: "fg-neutral-main",
|
|
352
353
|
children: [
|
|
353
|
-
|
|
354
|
-
/* @__PURE__ */
|
|
354
|
+
F,
|
|
355
|
+
/* @__PURE__ */ g("span", { className: "text-fg-brand-rest", children: [
|
|
355
356
|
"(",
|
|
356
357
|
r?.length,
|
|
357
358
|
")"
|
|
358
359
|
] })
|
|
359
360
|
]
|
|
360
361
|
}
|
|
361
|
-
) : b :
|
|
362
|
+
) : b : F
|
|
362
363
|
}
|
|
363
364
|
)
|
|
364
365
|
) })
|
|
365
366
|
}
|
|
366
367
|
),
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ g("div", { className: "flex items-center gap-xs", children: [
|
|
368
369
|
Array.isArray(r) && r.length > 0 && /* @__PURE__ */ t(
|
|
369
370
|
"button",
|
|
370
371
|
{
|
|
371
372
|
type: "button",
|
|
372
373
|
onClick: (e) => {
|
|
373
|
-
e.stopPropagation(),
|
|
374
|
+
e.stopPropagation(), te();
|
|
374
375
|
},
|
|
375
|
-
className:
|
|
376
|
+
className: d(
|
|
376
377
|
"flex items-center justify-center rounded-sm transition-colors",
|
|
377
|
-
!a && !
|
|
378
|
-
a ||
|
|
378
|
+
!a && !n && "cursor-pointer hover:bg-bg-neutral-subtle",
|
|
379
|
+
a || n ? "opacity-50 cursor-not-allowed" : ""
|
|
379
380
|
),
|
|
380
|
-
disabled: a ||
|
|
381
|
+
disabled: a || n,
|
|
381
382
|
"aria-label": "Clear all selections",
|
|
382
383
|
"data-testid": l ? `${l}-clear-all` : void 0,
|
|
383
384
|
"data-no-trigger": "true",
|
|
@@ -386,7 +387,7 @@ const ie = $e(
|
|
|
386
387
|
{
|
|
387
388
|
name: "x-circle",
|
|
388
389
|
variant: "solid",
|
|
389
|
-
size:
|
|
390
|
+
size: N(s),
|
|
390
391
|
className: "text-fg-neutral-subtle"
|
|
391
392
|
}
|
|
392
393
|
)
|
|
@@ -397,28 +398,28 @@ const ie = $e(
|
|
|
397
398
|
{
|
|
398
399
|
type: "button",
|
|
399
400
|
onClick: (e) => {
|
|
400
|
-
e.stopPropagation(), !a && !
|
|
401
|
+
e.stopPropagation(), !a && !n && $(!p);
|
|
401
402
|
},
|
|
402
|
-
className:
|
|
403
|
+
className: d(
|
|
403
404
|
"flex items-center justify-center dropdown-toggle-btn",
|
|
404
|
-
!a && !
|
|
405
|
+
!a && !n && "cursor-pointer"
|
|
405
406
|
),
|
|
406
407
|
"data-testid": l ? `${l}-dropdown-toggle` : "dropdown-toggle",
|
|
407
|
-
children:
|
|
408
|
+
children: m ? /* @__PURE__ */ t("span", { className: i.trailingIcon(), children: m.node || m.name && /* @__PURE__ */ t(
|
|
408
409
|
C,
|
|
409
410
|
{
|
|
410
|
-
name:
|
|
411
|
-
size:
|
|
412
|
-
"aria-label":
|
|
411
|
+
name: m.name,
|
|
412
|
+
size: N(s),
|
|
413
|
+
"aria-label": m["aria-label"]
|
|
413
414
|
}
|
|
414
415
|
) }) : /* @__PURE__ */ t(
|
|
415
416
|
C,
|
|
416
417
|
{
|
|
417
|
-
name:
|
|
418
|
-
size:
|
|
419
|
-
className:
|
|
418
|
+
name: p ? "chevron-up" : "chevron-down",
|
|
419
|
+
size: N(s),
|
|
420
|
+
className: d(
|
|
420
421
|
i.chevron(),
|
|
421
|
-
|
|
422
|
+
p && "rotate-180"
|
|
422
423
|
)
|
|
423
424
|
}
|
|
424
425
|
)
|
|
@@ -432,51 +433,51 @@ const ie = $e(
|
|
|
432
433
|
) : (
|
|
433
434
|
/* Single mode - use Dropdown normally */
|
|
434
435
|
/* @__PURE__ */ t(
|
|
435
|
-
|
|
436
|
+
ie,
|
|
436
437
|
{
|
|
437
|
-
...
|
|
438
|
+
..._,
|
|
438
439
|
items: M,
|
|
439
440
|
value: r,
|
|
440
441
|
onValueChange: (e) => {
|
|
441
|
-
a ||
|
|
442
|
+
a || n || (y?.(e), $(!1));
|
|
442
443
|
},
|
|
443
444
|
placeholder: b,
|
|
444
445
|
disabled: a,
|
|
445
|
-
loading:
|
|
446
|
-
showCheckmark:
|
|
447
|
-
emptyText:
|
|
448
|
-
state:
|
|
449
|
-
open:
|
|
446
|
+
loading: V,
|
|
447
|
+
showCheckmark: q,
|
|
448
|
+
emptyText: G,
|
|
449
|
+
state: k,
|
|
450
|
+
open: p,
|
|
450
451
|
onOpenChange: se,
|
|
451
|
-
side:
|
|
452
|
-
align:
|
|
453
|
-
sideOffset:
|
|
454
|
-
enableVirtualization:
|
|
455
|
-
itemHeight:
|
|
456
|
-
maxHeight:
|
|
457
|
-
size:
|
|
458
|
-
variant:
|
|
459
|
-
fullWidth:
|
|
452
|
+
side: K,
|
|
453
|
+
align: L,
|
|
454
|
+
sideOffset: Q,
|
|
455
|
+
enableVirtualization: U,
|
|
456
|
+
itemHeight: W,
|
|
457
|
+
maxHeight: X,
|
|
458
|
+
size: s,
|
|
459
|
+
variant: j,
|
|
460
|
+
fullWidth: D,
|
|
460
461
|
width: A,
|
|
461
462
|
"data-testid": l ? `${l}-dropdown` : void 0,
|
|
462
|
-
search:
|
|
463
|
-
searchPlaceholder:
|
|
464
|
-
searchValue:
|
|
465
|
-
onSearchChange:
|
|
466
|
-
showClearButton:
|
|
467
|
-
children:
|
|
463
|
+
search: H,
|
|
464
|
+
searchPlaceholder: ee,
|
|
465
|
+
searchValue: I,
|
|
466
|
+
onSearchChange: B,
|
|
467
|
+
showClearButton: O,
|
|
468
|
+
children: de || Se()
|
|
468
469
|
}
|
|
469
470
|
)
|
|
470
471
|
) }),
|
|
471
472
|
/* @__PURE__ */ t(
|
|
472
|
-
|
|
473
|
+
Pe,
|
|
473
474
|
{
|
|
474
475
|
className: "mt-1",
|
|
475
|
-
text:
|
|
476
|
-
error:
|
|
477
|
-
haveIcon:
|
|
478
|
-
iconsSize:
|
|
479
|
-
iconsCustom:
|
|
476
|
+
text: pe,
|
|
477
|
+
error: Y,
|
|
478
|
+
haveIcon: Ne,
|
|
479
|
+
iconsSize: xe,
|
|
480
|
+
iconsCustom: ve
|
|
480
481
|
}
|
|
481
482
|
)
|
|
482
483
|
]
|
|
@@ -484,8 +485,8 @@ const ie = $e(
|
|
|
484
485
|
);
|
|
485
486
|
}
|
|
486
487
|
);
|
|
487
|
-
|
|
488
|
-
const
|
|
488
|
+
me.displayName = "Select";
|
|
489
|
+
const _e = De(me);
|
|
489
490
|
export {
|
|
490
|
-
|
|
491
|
+
_e as default
|
|
491
492
|
};
|
|
@@ -1,99 +1,104 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
const
|
|
3
|
-
items:
|
|
4
|
-
gap:
|
|
5
|
-
minChipsToShow:
|
|
6
|
-
moreChipWidth:
|
|
1
|
+
import { useRef as W, useState as E, useEffect as C, useCallback as I } from "react";
|
|
2
|
+
const z = ({
|
|
3
|
+
items: r,
|
|
4
|
+
gap: c = 8,
|
|
5
|
+
minChipsToShow: x = 1,
|
|
6
|
+
moreChipWidth: M = 60
|
|
7
7
|
}) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const d = W(null), [b, a] = E(r.length), m = W(r), A = W(r.length);
|
|
9
|
+
C(() => {
|
|
10
|
+
m.current = r, A.current = r.length;
|
|
11
|
+
});
|
|
12
|
+
const n = I(() => {
|
|
13
|
+
const t = m.current;
|
|
14
|
+
if (!d.current || t.length === 0) {
|
|
15
|
+
a(t.length);
|
|
11
16
|
return;
|
|
12
17
|
}
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
|
|
18
|
+
const h = d.current, i = h.clientWidth;
|
|
19
|
+
if (i === 0) {
|
|
20
|
+
a(t.length);
|
|
16
21
|
return;
|
|
17
22
|
}
|
|
18
23
|
if (t.length <= 4) {
|
|
19
|
-
const e =
|
|
24
|
+
const e = h.querySelectorAll(
|
|
20
25
|
'[data-testid*="chip"]:not([data-testid*="chip-more"])'
|
|
21
26
|
);
|
|
22
|
-
let
|
|
23
|
-
e.length > 0 && (
|
|
24
|
-
const
|
|
25
|
-
if (t.length *
|
|
26
|
-
|
|
27
|
+
let s = 75;
|
|
28
|
+
e.length > 0 && (s = e[0].offsetWidth);
|
|
29
|
+
const u = Math.max(0, t.length - 1) * c;
|
|
30
|
+
if (t.length * s + u <= i) {
|
|
31
|
+
a(t.length);
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
const l =
|
|
35
|
+
const l = h.querySelectorAll(
|
|
31
36
|
'[data-testid*="chip"]:not([data-testid*="chip-more"])'
|
|
32
37
|
);
|
|
33
38
|
if (l.length === 0) {
|
|
34
|
-
|
|
39
|
+
a(t.length);
|
|
35
40
|
return;
|
|
36
41
|
}
|
|
37
|
-
let
|
|
38
|
-
l.length > 0 && (
|
|
39
|
-
let
|
|
42
|
+
let p = 0;
|
|
43
|
+
l.length > 0 && (p = Array.from(l).reduce((s, u) => s + u.offsetWidth, 0) / l.length), p === 0 && (p = 80);
|
|
44
|
+
let v = 0, o = 0;
|
|
40
45
|
for (let e = 0; e < t.length; e++) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
46
|
+
const s = e < l.length ? l[e].offsetWidth : p;
|
|
47
|
+
if (s === 0)
|
|
43
48
|
break;
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
|
|
49
|
+
const u = e === t.length - 1, g = v + s + (e > 0 ? c : 0);
|
|
50
|
+
let f;
|
|
51
|
+
if (u)
|
|
52
|
+
f = i;
|
|
48
53
|
else {
|
|
49
|
-
const
|
|
50
|
-
|
|
54
|
+
const y = s;
|
|
55
|
+
g + c + y > i ? f = i - M - c : f = i;
|
|
51
56
|
}
|
|
52
|
-
if (
|
|
53
|
-
|
|
57
|
+
if (g <= f)
|
|
58
|
+
v = g, o = e + 1;
|
|
54
59
|
else
|
|
55
60
|
break;
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
const h = setTimeout(n, 0),
|
|
62
|
+
o = Math.max(o, Math.min(x, t.length));
|
|
63
|
+
const k = o >= t.length ? t.length : o, q = t.length > 0 ? Math.max(1, k) : 0;
|
|
64
|
+
a(q);
|
|
65
|
+
}, [c, x, M]);
|
|
66
|
+
C(() => {
|
|
67
|
+
const t = d.current;
|
|
68
|
+
if (!t) return;
|
|
69
|
+
const h = setTimeout(n, 0), i = new ResizeObserver(() => {
|
|
65
70
|
n();
|
|
66
71
|
});
|
|
67
|
-
return
|
|
68
|
-
clearTimeout(h),
|
|
72
|
+
return i.observe(t), () => {
|
|
73
|
+
clearTimeout(h), i.disconnect();
|
|
69
74
|
};
|
|
70
|
-
}, [n]),
|
|
75
|
+
}, [n]), C(() => {
|
|
71
76
|
n();
|
|
72
|
-
const
|
|
77
|
+
const t = setTimeout(() => {
|
|
73
78
|
n();
|
|
74
79
|
}, 10), h = setTimeout(() => {
|
|
75
80
|
n();
|
|
76
81
|
}, 50);
|
|
77
82
|
return () => {
|
|
78
|
-
clearTimeout(
|
|
83
|
+
clearTimeout(t), clearTimeout(h);
|
|
79
84
|
};
|
|
80
|
-
}, [
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
85
|
+
}, [r.length, n]), C(() => {
|
|
86
|
+
if (r.length > 0) {
|
|
87
|
+
const t = requestAnimationFrame(() => {
|
|
83
88
|
n();
|
|
84
89
|
});
|
|
85
|
-
return () => cancelAnimationFrame(
|
|
90
|
+
return () => cancelAnimationFrame(t);
|
|
86
91
|
}
|
|
87
|
-
}, [
|
|
88
|
-
const
|
|
92
|
+
}, [r.length, n]);
|
|
93
|
+
const R = m.current.slice(0, b), T = Math.max(0, m.current.length - b), w = T > 0;
|
|
89
94
|
return {
|
|
90
|
-
containerRef:
|
|
91
|
-
displayItems:
|
|
92
|
-
remainingCount:
|
|
93
|
-
hasMore:
|
|
95
|
+
containerRef: d,
|
|
96
|
+
displayItems: R,
|
|
97
|
+
remainingCount: T,
|
|
98
|
+
hasMore: w,
|
|
94
99
|
recalculate: n
|
|
95
100
|
};
|
|
96
101
|
};
|
|
97
102
|
export {
|
|
98
|
-
|
|
103
|
+
z as useChipOverflow
|
|
99
104
|
};
|