@iress-oss/ids-components 6.4.1 → 6.4.3
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.
|
@@ -50,6 +50,6 @@ export interface IressSelectMenuItemProps extends Omit<IressMenuItemProps<'butto
|
|
|
50
50
|
hiddenOnMobile?: boolean;
|
|
51
51
|
}
|
|
52
52
|
export declare const IressSelectMenu: {
|
|
53
|
-
<TMultiple extends boolean = false>({ heading, hideSelectedItems, items, limitDesktop, limitMobile, multiSelect, noResults, onChange, role, selected, selectedFirst, ...restProps }: IressSelectMenuProps<TMultiple>): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
<TMultiple extends boolean = false>({ heading, hideSelectedItems, items, limitDesktop, limitMobile, multiSelect, noResults, onChange, onMouseDown, role, selected, selectedFirst, ...restProps }: IressSelectMenuProps<TMultiple>): import("react/jsx-runtime").JSX.Element;
|
|
54
54
|
displayName: string;
|
|
55
55
|
};
|
|
@@ -3,84 +3,88 @@ import { GlobalCSSClass as t } from "../../../enums.js";
|
|
|
3
3
|
import { propagateTestid as n } from "../../../helpers/utility/propagateTestid.js";
|
|
4
4
|
import { toArray as r } from "../../../helpers/formatting/toArray.js";
|
|
5
5
|
import { useIdIfNeeded as i } from "../../../hooks/useIdIfNeeded.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
6
|
+
import { usePopover as a } from "../../Popover/hooks/usePopover.js";
|
|
7
|
+
import { getFormControlValueAsString as o } from "../../../helpers/form/getFormControlValueAsString.js";
|
|
8
|
+
import { getFormControlValueAsStringIfDefined as s } from "../../../helpers/form/getFormControlValueAsStringIfDefined.js";
|
|
9
|
+
import { IressMenu as c } from "../../Menu/Menu.js";
|
|
10
|
+
import { IressMenuText as l } from "../../Menu/MenuText/MenuText.js";
|
|
11
|
+
import { IressMenuGroup as u } from "../../Menu/MenuGroup/MenuGroup.js";
|
|
12
|
+
import { getValueFromLabelValues as d } from "../../../helpers/label-value/getValueFromLabelValues.js";
|
|
13
|
+
import { IressSelectMenuItem as f } from "./SelectMenuItem.js";
|
|
14
|
+
import { selectMenu as p } from "./SelectMenu.styles.js";
|
|
15
|
+
import { IressSelectHeading as m } from "../SelectHeading/SelectHeading.js";
|
|
16
|
+
import { createElement as h, useCallback as g, useMemo as _ } from "react";
|
|
17
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
17
18
|
//#region src/components/Select/SelectMenu/SelectMenu.tsx
|
|
18
|
-
var
|
|
19
|
-
let
|
|
20
|
-
let e =
|
|
21
|
-
if (
|
|
22
|
-
let t = r(
|
|
19
|
+
var b = ({ heading: b, hideSelectedItems: C, items: T = [], limitDesktop: E, limitMobile: D, multiSelect: O, noResults: k, onChange: A, onMouseDown: j, role: M = "listbox", selected: N, selectedFirst: P, ...F }) => {
|
|
20
|
+
let I = a(), L = `${i({ id: F.id })}--label`, R = _(() => d(N, O), [O, N]), z = _(() => {
|
|
21
|
+
let e = P ? x(T, R) : T;
|
|
22
|
+
if (C) {
|
|
23
|
+
let t = r(R);
|
|
23
24
|
e = e.map((e) => {
|
|
24
25
|
if (e.children && e.children.length > 0) {
|
|
25
|
-
let n = e.children.filter((e) => !t.includes(
|
|
26
|
+
let n = e.children.filter((e) => !t.includes(s(e.value) ?? e.label));
|
|
26
27
|
return n.length > 0 ? {
|
|
27
28
|
...e,
|
|
28
29
|
children: n
|
|
29
30
|
} : null;
|
|
30
31
|
}
|
|
31
|
-
return t.includes(
|
|
32
|
+
return t.includes(s(e.value) ?? e.label) ? null : e;
|
|
32
33
|
}).filter((e) => e !== null);
|
|
33
34
|
}
|
|
34
|
-
return
|
|
35
|
+
return S(e, E, D);
|
|
35
36
|
}, [
|
|
36
|
-
|
|
37
|
-
w,
|
|
37
|
+
C,
|
|
38
38
|
T,
|
|
39
39
|
E,
|
|
40
|
-
F,
|
|
41
|
-
M
|
|
42
|
-
]), L = I.length === 0, R = h((e) => {
|
|
43
|
-
let t = C(w, j, e ?? void 0);
|
|
44
|
-
k?.(D ? t : t[0]);
|
|
45
|
-
}, [
|
|
46
|
-
w,
|
|
47
40
|
D,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]), z =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
R,
|
|
42
|
+
P
|
|
43
|
+
]), B = z.length === 0, V = g((e) => {
|
|
44
|
+
let t = w(T, N, e ?? void 0);
|
|
45
|
+
A?.(O ? t : t[0]);
|
|
46
|
+
}, [
|
|
47
|
+
T,
|
|
48
|
+
O,
|
|
49
|
+
A,
|
|
50
|
+
N
|
|
51
|
+
]), H = p();
|
|
52
|
+
return /* @__PURE__ */ y(c, {
|
|
53
|
+
...F,
|
|
54
|
+
"aria-labelledby": typeof b == "string" ? L : F["aria-labelledby"],
|
|
55
|
+
multiSelect: O,
|
|
56
|
+
onChange: V,
|
|
57
|
+
onMouseDown: (e) => {
|
|
58
|
+
j?.(e), I?.isVirtualFocus && e.target instanceof Element && e.target.closest(`.${t.MenuGroup}`) && e.preventDefault();
|
|
59
|
+
},
|
|
60
|
+
role: M,
|
|
61
|
+
selected: R,
|
|
62
|
+
className: e(H.root, t.SelectMenu, F.className),
|
|
59
63
|
children: [
|
|
60
|
-
typeof
|
|
61
|
-
id:
|
|
62
|
-
children:
|
|
63
|
-
}) :
|
|
64
|
-
|
|
64
|
+
typeof b == "string" ? /* @__PURE__ */ v(m, {
|
|
65
|
+
id: L,
|
|
66
|
+
children: b
|
|
67
|
+
}) : b,
|
|
68
|
+
z.map((e, t) => e.children && e.children.length > 0 ? /* @__PURE__ */ v(u, {
|
|
65
69
|
label: e.label,
|
|
66
|
-
"data-testid": n(
|
|
70
|
+
"data-testid": n(F?.["data-testid"], "menu-group"),
|
|
67
71
|
divider: e.divider,
|
|
68
|
-
children: e.children.map((e, t) => /* @__PURE__ */
|
|
72
|
+
children: e.children.map((e, t) => /* @__PURE__ */ h(f, {
|
|
69
73
|
...e,
|
|
70
|
-
"data-testid": n(
|
|
71
|
-
key: `${
|
|
74
|
+
"data-testid": n(F?.["data-testid"], "menu-item"),
|
|
75
|
+
key: `${o(e.value ?? e.label)}-${t}`
|
|
72
76
|
}))
|
|
73
|
-
}, `group-${
|
|
77
|
+
}, `group-${o(e.value ?? e.label)}-${t}`) : /* @__PURE__ */ h(f, {
|
|
74
78
|
...e,
|
|
75
|
-
"data-testid": n(
|
|
76
|
-
key: `${
|
|
79
|
+
"data-testid": n(F?.["data-testid"], "menu-item"),
|
|
80
|
+
key: `${o(e.value ?? e.label)}-${t}`
|
|
77
81
|
})),
|
|
78
|
-
|
|
82
|
+
B && (typeof k == "string" ? /* @__PURE__ */ v(l, { children: k }) : k)
|
|
79
83
|
]
|
|
80
84
|
});
|
|
81
85
|
};
|
|
82
|
-
|
|
83
|
-
var
|
|
86
|
+
b.displayName = "IressSelectMenu";
|
|
87
|
+
var x = (e, t) => {
|
|
84
88
|
let n = r(t), i = [], a = [];
|
|
85
89
|
for (let t of e) t.children && t.children.length > 0 ? t.children.some((e) => n.includes(e.value ?? e.label)) ? i.push(t) : a.push(t) : n.includes(t.value ?? t.label) ? i.push(t) : a.push(t);
|
|
86
90
|
return i.length && a.length ? i.concat([{
|
|
@@ -88,7 +92,7 @@ var b = (e, t) => {
|
|
|
88
92
|
value: "",
|
|
89
93
|
divider: !0
|
|
90
94
|
}]).concat(a) : i.concat(a);
|
|
91
|
-
},
|
|
95
|
+
}, S = (e, t, n) => {
|
|
92
96
|
let r = {
|
|
93
97
|
mobileCount: 0,
|
|
94
98
|
desktopCount: 0
|
|
@@ -96,7 +100,7 @@ var b = (e, t) => {
|
|
|
96
100
|
for (let a of e) {
|
|
97
101
|
if (t && r.desktopCount >= t) break;
|
|
98
102
|
if (a.children && a.children.length > 0) {
|
|
99
|
-
let e =
|
|
103
|
+
let e = C(a.children, r, t, n);
|
|
100
104
|
e.length > 0 && i.push({
|
|
101
105
|
...a,
|
|
102
106
|
children: e
|
|
@@ -107,7 +111,7 @@ var b = (e, t) => {
|
|
|
107
111
|
}), r.mobileCount++, r.desktopCount++;
|
|
108
112
|
}
|
|
109
113
|
return i;
|
|
110
|
-
},
|
|
114
|
+
}, C = (e, t, n, r) => {
|
|
111
115
|
let i = [];
|
|
112
116
|
for (let a of e) {
|
|
113
117
|
if (n && t.desktopCount >= n) break;
|
|
@@ -117,10 +121,10 @@ var b = (e, t) => {
|
|
|
117
121
|
}), t.mobileCount++, t.desktopCount++;
|
|
118
122
|
}
|
|
119
123
|
return i;
|
|
120
|
-
}, C = (e, t, n) => {
|
|
121
|
-
let i = r(t);
|
|
122
|
-
return r(n).map((t) => w(e, i, t)).filter((e) => e !== void 0);
|
|
123
124
|
}, w = (e, t, n) => {
|
|
125
|
+
let i = r(t);
|
|
126
|
+
return r(n).map((t) => T(e, i, t)).filter((e) => e !== void 0);
|
|
127
|
+
}, T = (e, t, n) => {
|
|
124
128
|
let r = e?.find((e) => e.value === n || e.value === void 0 && e.label === n);
|
|
125
129
|
if (!r) {
|
|
126
130
|
for (let t of e) if (t.children && t.children.length > 0 && (r = t.children.find((e) => e.value === n || e.value === void 0 && e.label === n), r)) break;
|
|
@@ -128,4 +132,4 @@ var b = (e, t) => {
|
|
|
128
132
|
return r ?? t.find((e) => e.value === n || e.value === void 0 && e.label === n);
|
|
129
133
|
};
|
|
130
134
|
//#endregion
|
|
131
|
-
export {
|
|
135
|
+
export { b as IressSelectMenu };
|