@fluidattacks/design 10.1.0 → 10.3.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/components/filters/hooks.d.ts +4 -1
- package/dist/components/filters/hooks.js +35 -17
- package/dist/components/filters/options-menu/include-exclude/multi-select.d.ts +5 -1
- package/dist/components/filters/options-menu/include-exclude/multi-select.js +142 -112
- package/dist/components/filters/options-menu/index.js +156 -151
- package/dist/components/filters/options-menu/options/index.js +141 -114
- package/dist/components/filters/options-menu/options/types.d.ts +1 -0
- package/dist/components/filters/options-menu/single-select/index.js +83 -97
- package/dist/components/filters/options-menu/single-select/styles.d.ts +1 -2
- package/dist/components/filters/options-menu/single-select/styles.js +5 -22
- package/dist/components/filters/styles.d.ts +2 -1
- package/dist/components/filters/styles.js +27 -10
- package/dist/components/filters/types.d.ts +2 -2
- package/dist/components/form/styles.js +12 -7
- package/dist/components/inputs/fields/combobox/field/index.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/field/index.js +115 -112
- package/dist/components/inputs/fields/combobox/index.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/index.js +34 -31
- package/dist/components/inputs/fields/combobox/index.stories.d.ts +4 -1
- package/dist/components/inputs/fields/combobox/option/index.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/option/index.js +79 -68
- package/dist/components/inputs/fields/combobox/styles.js +10 -3
- package/dist/components/inputs/fields/combobox/types.d.ts +5 -0
- package/dist/components/inputs/fields/combobox/utils.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/utils.js +10 -10
- package/dist/components/loading/index.js +11 -11
- package/dist/components/loading/index.stories.d.ts +2 -1
- package/dist/components/modal/index.stories.d.ts +4 -1
- package/dist/components/modal/modal-confirm/index.d.ts +1 -1
- package/dist/components/modal/modal-confirm/index.js +34 -20
- package/dist/components/modal/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,275 +1,280 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { l as
|
|
4
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as u, jsxs as V } from "react/jsx-runtime";
|
|
2
|
+
import C from "../../../_virtual/dayjs.min.js";
|
|
3
|
+
import { l as Z } from "../../../_virtual/lodash.js";
|
|
4
|
+
import { forwardRef as ee, useContext as te, useMemo as se, useCallback as S, Fragment as le } from "react";
|
|
5
5
|
import { useTheme as oe } from "styled-components";
|
|
6
|
-
import { IncludeExcludeMenu as
|
|
7
|
-
import { Options as
|
|
8
|
-
import { formatValue as
|
|
9
|
-
import { FiltersContext as
|
|
10
|
-
import { StyledModalContainer as
|
|
11
|
-
import { MAX_FILTERS_LENGTH as
|
|
12
|
-
import { Container as
|
|
13
|
-
import { Search as
|
|
14
|
-
import { Toggle as
|
|
6
|
+
import { IncludeExcludeMenu as ne } from "./include-exclude/index.js";
|
|
7
|
+
import { Options as re } from "./options/index.js";
|
|
8
|
+
import { formatValue as A } from "./utils.js";
|
|
9
|
+
import { FiltersContext as ce } from "../context/index.js";
|
|
10
|
+
import { StyledModalContainer as ae, StyledFloatingActions as ie, StyledHeader as de, StyledContent as ue, StyledActionButton as H } from "../styles.js";
|
|
11
|
+
import { MAX_FILTERS_LENGTH as me } from "../utils.js";
|
|
12
|
+
import { Container as F } from "../../container/index.js";
|
|
13
|
+
import { Search as fe } from "../../search/index.js";
|
|
14
|
+
import { Toggle as he } from "../../toggle/index.js";
|
|
15
15
|
import "../../typography/heading/index.js";
|
|
16
16
|
import "../../typography/span/index.js";
|
|
17
|
-
import { Text as
|
|
18
|
-
import { parseCheckboxesFilterValue as
|
|
19
|
-
const
|
|
20
|
-
const
|
|
17
|
+
import { Text as Y } from "../../typography/text/index.js";
|
|
18
|
+
import { parseCheckboxesFilterValue as y, formatCheckboxesFilterValue as I } from "../../../utils/filters.js";
|
|
19
|
+
const z = (p) => p.type === "combobox" || p.type === "multiSelect", xe = (p, f) => {
|
|
20
|
+
const g = new Set(
|
|
21
|
+
(f ?? []).filter((a) => a.type === "list" || a.type === "combobox").flatMap((a) => (a.items ?? []).map((k) => k.value))
|
|
22
|
+
);
|
|
23
|
+
return p.filter((a) => !g.has(a));
|
|
24
|
+
}, Oe = ee(function({ hideTitle: f = !1, label: g, options: a }, k) {
|
|
25
|
+
const R = oe(), {
|
|
21
26
|
id: t,
|
|
22
|
-
searchValues: { searchFilter:
|
|
23
|
-
setSearchValues:
|
|
24
|
-
values:
|
|
25
|
-
setValues:
|
|
26
|
-
scrollState:
|
|
27
|
-
} =
|
|
28
|
-
(e) => e
|
|
29
|
-
),
|
|
27
|
+
searchValues: { searchFilter: x },
|
|
28
|
+
setSearchValues: L,
|
|
29
|
+
values: B,
|
|
30
|
+
setValues: h,
|
|
31
|
+
scrollState: D
|
|
32
|
+
} = te(ce), { ref: T } = D, b = B[t], $ = (a ?? []).some(
|
|
33
|
+
(e) => !z(e) && (e.items ?? []).length > me
|
|
34
|
+
), O = a?.find(
|
|
30
35
|
(e) => e.type === "includeExclude"
|
|
31
|
-
),
|
|
36
|
+
), M = a?.find(
|
|
32
37
|
(e) => e.type === "checkboxes" && e.excludeLabel
|
|
33
|
-
), { mode:
|
|
38
|
+
), { mode: W, values: _ } = y(b ?? ""), G = W === "exclude", X = _.length > 0, v = !f || $ || M !== void 0, w = se(() => a?.map((e) => {
|
|
34
39
|
const s = e?.items ?? [];
|
|
35
|
-
return e
|
|
36
|
-
(
|
|
40
|
+
return z(e) ? s : s.filter(
|
|
41
|
+
(m) => m.label?.toLowerCase().includes(x.toLowerCase()) ?? !1
|
|
37
42
|
);
|
|
38
|
-
}) ?? [], [
|
|
39
|
-
|
|
40
|
-
}, [
|
|
41
|
-
|
|
42
|
-
const { mode: s, values:
|
|
43
|
+
}) ?? [], [a, x]), q = S(() => {
|
|
44
|
+
h((e) => ({ ...e, [t]: "" }));
|
|
45
|
+
}, [h, t]), J = S(() => {
|
|
46
|
+
h((e) => {
|
|
47
|
+
const { mode: s, values: m } = y(
|
|
43
48
|
e[t] ?? ""
|
|
44
|
-
),
|
|
45
|
-
...
|
|
46
|
-
|
|
49
|
+
), l = [
|
|
50
|
+
...m,
|
|
51
|
+
...w.flat().map((r) => r.value)
|
|
47
52
|
];
|
|
48
53
|
return {
|
|
49
54
|
...e,
|
|
50
|
-
[t]:
|
|
55
|
+
[t]: I({ mode: s, values: l })
|
|
51
56
|
};
|
|
52
57
|
});
|
|
53
|
-
}, [
|
|
54
|
-
|
|
55
|
-
const { mode: s, values:
|
|
58
|
+
}, [h, t, w]), K = S(() => {
|
|
59
|
+
h((e) => {
|
|
60
|
+
const { mode: s, values: m } = y(
|
|
56
61
|
e[t] ?? ""
|
|
57
62
|
);
|
|
58
63
|
return {
|
|
59
64
|
...e,
|
|
60
|
-
[t]:
|
|
65
|
+
[t]: I({
|
|
61
66
|
mode: s === "exclude" ? "include" : "exclude",
|
|
62
|
-
values:
|
|
67
|
+
values: m
|
|
63
68
|
})
|
|
64
69
|
};
|
|
65
70
|
});
|
|
66
|
-
}, [
|
|
71
|
+
}, [h, t]), P = S(
|
|
67
72
|
(e) => {
|
|
68
|
-
|
|
73
|
+
L((s) => ({
|
|
69
74
|
...s,
|
|
70
75
|
searchFilter: e.target.value
|
|
71
76
|
}));
|
|
72
77
|
},
|
|
73
|
-
[
|
|
74
|
-
),
|
|
75
|
-
(e, s,
|
|
76
|
-
|
|
77
|
-
if (s === "checkboxes") {
|
|
78
|
-
const { mode:
|
|
79
|
-
|
|
80
|
-
), c =
|
|
78
|
+
[L]
|
|
79
|
+
), Q = S(
|
|
80
|
+
(e, s, m) => {
|
|
81
|
+
h((l) => {
|
|
82
|
+
if (s === "checkboxes" || s === "multiSelect") {
|
|
83
|
+
const { mode: r, values: c } = y(
|
|
84
|
+
l[t] ?? ""
|
|
85
|
+
), n = s === "multiSelect" ? xe(c, a) : c, o = n.includes(e) ? n.filter((d) => d !== e) : [...n, e];
|
|
81
86
|
return {
|
|
82
|
-
...
|
|
83
|
-
[t]:
|
|
87
|
+
...l,
|
|
88
|
+
[t]: I({ mode: r, values: o })
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
if (s === "dateRange") {
|
|
87
|
-
const
|
|
88
|
-
(
|
|
89
|
-
),
|
|
90
|
-
(
|
|
91
|
-
),
|
|
92
|
-
return
|
|
92
|
+
const r = A(l[t] ?? ""), c = r.filter(
|
|
93
|
+
(i) => i !== "-" && !RegExp(/^\d+\-\d+\-\d+$/).test(i.trim())
|
|
94
|
+
), n = r.filter(
|
|
95
|
+
(i) => C(i).isValid() && C(i).isAfter(C("1903-01-01"))
|
|
96
|
+
), o = C(e, "YYYY-MM-DD", !0), d = ["-", "-"];
|
|
97
|
+
return n.length === 2 ? (d[0] = n[0], d[1] = n[1]) : n.length === 1 && (o.isAfter(C(n[0])) ? (d[0] = n[0], d[1] = e) : (d[0] = e, d[1] = n[0])), d[m ?? 0] = e, { ...l, [t]: [...c, ...d].join(",") };
|
|
93
98
|
}
|
|
94
99
|
if (s === "numberRange") {
|
|
95
|
-
const
|
|
96
|
-
(
|
|
97
|
-
),
|
|
98
|
-
(
|
|
99
|
-
),
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
RegExp(/^\d+$/).test(
|
|
100
|
+
const r = A(l[t] ?? ""), c = r.filter(
|
|
101
|
+
(i) => i !== "-" && !RegExp(/^\d+$/).test(i.trim())
|
|
102
|
+
), n = r.filter(
|
|
103
|
+
(i) => i === "-" || RegExp(/^\d+$/).test(i.trim())
|
|
104
|
+
), o = ["-", "-"];
|
|
105
|
+
n.forEach((i, E) => {
|
|
106
|
+
if (E >= 2) return;
|
|
107
|
+
const j = i.trim();
|
|
108
|
+
RegExp(/^\d+$/).test(j) ? o[E] = Number(j) : j === "-" && (o[E] = "-");
|
|
104
109
|
});
|
|
105
|
-
const
|
|
110
|
+
const d = m ?? 0;
|
|
106
111
|
if (e === "" || e === void 0 || e === null)
|
|
107
|
-
|
|
112
|
+
o[d] = "-";
|
|
108
113
|
else {
|
|
109
|
-
const
|
|
110
|
-
|
|
114
|
+
const i = Number(e);
|
|
115
|
+
o[d] = Z.isNaN(i) ? "-" : i;
|
|
111
116
|
}
|
|
112
|
-
return
|
|
113
|
-
...
|
|
114
|
-
[t]:
|
|
117
|
+
return o[0] === "-" && o[1] === "-" ? {
|
|
118
|
+
...l,
|
|
119
|
+
[t]: c.length > 0 ? c.join(",") : ""
|
|
115
120
|
} : {
|
|
116
|
-
...
|
|
117
|
-
[t]: [...
|
|
121
|
+
...l,
|
|
122
|
+
[t]: [...o, ...c].join(",")
|
|
118
123
|
};
|
|
119
124
|
}
|
|
120
125
|
if (s === "combobox" || s === "list") {
|
|
121
|
-
const
|
|
122
|
-
(
|
|
123
|
-
(
|
|
126
|
+
const r = A(l[t] ?? ""), c = new Set(
|
|
127
|
+
(a ?? []).flatMap(
|
|
128
|
+
(o) => (o.items ?? []).map((d) => d.value)
|
|
124
129
|
)
|
|
125
|
-
),
|
|
126
|
-
(
|
|
130
|
+
), n = r.filter(
|
|
131
|
+
(o) => !c.has(o.trim()) && (o === "-" || RegExp(/^\d+$/).test(o) || RegExp(/^\d+\-\d+\-\d+$/).test(o.trim()))
|
|
127
132
|
);
|
|
128
|
-
return { ...
|
|
133
|
+
return { ...l, [t]: [...n, e].join(",") };
|
|
129
134
|
}
|
|
130
135
|
if (s === "textCheckbox") {
|
|
131
|
-
const
|
|
132
|
-
return !
|
|
136
|
+
const r = l[t] ?? "", c = r.match(/^textCheck:(true|false),(.*)$/), n = c ? c[2] : r, o = e === "true";
|
|
137
|
+
return !o && n === "" ? { ...l, [t]: "" } : { ...l, [t]: `textCheck:${o},${n}` };
|
|
133
138
|
}
|
|
134
139
|
if (s === "text") {
|
|
135
|
-
const
|
|
136
|
-
return
|
|
140
|
+
const c = (l[t] ?? "").match(/^textCheck:(true|false),/);
|
|
141
|
+
return c ? e === "" && c[1] === "false" ? { ...l, [t]: "" } : { ...l, [t]: `textCheck:${c[1]},${e}` } : { ...l, [t]: e };
|
|
137
142
|
}
|
|
138
|
-
return { ...
|
|
143
|
+
return { ...l, [t]: e };
|
|
139
144
|
});
|
|
140
145
|
},
|
|
141
|
-
[t,
|
|
146
|
+
[t, a, h]
|
|
142
147
|
);
|
|
143
|
-
if (
|
|
144
|
-
return /* @__PURE__ */
|
|
145
|
-
|
|
148
|
+
if (O)
|
|
149
|
+
return /* @__PURE__ */ u(
|
|
150
|
+
ne,
|
|
146
151
|
{
|
|
147
152
|
id: t,
|
|
148
|
-
label:
|
|
149
|
-
option:
|
|
150
|
-
ref:
|
|
153
|
+
label: g,
|
|
154
|
+
option: O,
|
|
155
|
+
ref: k
|
|
151
156
|
}
|
|
152
157
|
);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
const U = b !== void 0 && b !== "" && x === "" || $ && x !== "", N = /* @__PURE__ */ V(le, { children: [
|
|
159
|
+
b && x === "" ? /* @__PURE__ */ u(
|
|
160
|
+
H,
|
|
156
161
|
{
|
|
157
162
|
$variant: "lowRelevance",
|
|
158
163
|
"data-testid": "reset-all-filters",
|
|
159
|
-
onClick:
|
|
164
|
+
onClick: q,
|
|
160
165
|
type: "button",
|
|
161
166
|
children: "Reset all"
|
|
162
167
|
}
|
|
163
168
|
) : void 0,
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
$ && x !== "" ? /* @__PURE__ */ u(
|
|
170
|
+
H,
|
|
166
171
|
{
|
|
167
172
|
$variant: "lowRelevance",
|
|
168
173
|
"data-testid": "select-all-filters",
|
|
169
|
-
onClick:
|
|
174
|
+
onClick: J,
|
|
170
175
|
type: "button",
|
|
171
176
|
children: "Select all"
|
|
172
177
|
}
|
|
173
178
|
) : void 0
|
|
174
179
|
] });
|
|
175
|
-
return /* @__PURE__ */
|
|
176
|
-
|
|
180
|
+
return /* @__PURE__ */ V(
|
|
181
|
+
ae,
|
|
177
182
|
{
|
|
178
183
|
$left: "346px",
|
|
179
184
|
"data-testid": "options-menu",
|
|
180
|
-
ref:
|
|
185
|
+
ref: k,
|
|
181
186
|
children: [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
|
|
187
|
+
f && !v && U ? /* @__PURE__ */ u(ie, { "data-testid": "options-menu-floating-actions", children: N }) : void 0,
|
|
188
|
+
v ? /* @__PURE__ */ V(de, { "data-testid": "options-menu-header", children: [
|
|
189
|
+
/* @__PURE__ */ V(
|
|
190
|
+
F,
|
|
186
191
|
{
|
|
187
192
|
display: "flex",
|
|
188
|
-
justify:
|
|
193
|
+
justify: f ? "flex-end" : "space-between",
|
|
189
194
|
width: "100%",
|
|
190
195
|
children: [
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
f ? void 0 : /* @__PURE__ */ u(
|
|
197
|
+
Y,
|
|
193
198
|
{
|
|
194
|
-
color:
|
|
199
|
+
color: R.palette.gray[800],
|
|
195
200
|
fontWeight: "bold",
|
|
196
201
|
size: "md",
|
|
197
|
-
children: `Select ${
|
|
202
|
+
children: `Select ${g}`
|
|
198
203
|
}
|
|
199
204
|
),
|
|
200
|
-
|
|
205
|
+
N
|
|
201
206
|
]
|
|
202
207
|
}
|
|
203
208
|
),
|
|
204
|
-
|
|
205
|
-
|
|
209
|
+
M ? /* @__PURE__ */ u(
|
|
210
|
+
F,
|
|
206
211
|
{
|
|
207
212
|
"data-testid": "exclude-toggle-row",
|
|
208
213
|
display: "flex",
|
|
209
214
|
justify: "space-between",
|
|
210
215
|
width: "100%",
|
|
211
|
-
children: /* @__PURE__ */
|
|
212
|
-
|
|
216
|
+
children: /* @__PURE__ */ u(
|
|
217
|
+
he,
|
|
213
218
|
{
|
|
214
|
-
defaultChecked:
|
|
215
|
-
disabled: !
|
|
219
|
+
defaultChecked: G,
|
|
220
|
+
disabled: !X,
|
|
216
221
|
justify: "space-between",
|
|
217
|
-
leftText:
|
|
222
|
+
leftText: M.excludeLabel,
|
|
218
223
|
name: `${t}-exclude`,
|
|
219
|
-
onChange:
|
|
224
|
+
onChange: K,
|
|
220
225
|
variant: "inline"
|
|
221
226
|
}
|
|
222
227
|
)
|
|
223
228
|
}
|
|
224
229
|
) : void 0,
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
$ ? /* @__PURE__ */ u(
|
|
231
|
+
fe,
|
|
227
232
|
{
|
|
228
233
|
name: "options-search",
|
|
229
|
-
onChange:
|
|
230
|
-
placeholder: `Search ${
|
|
231
|
-
value:
|
|
234
|
+
onChange: P,
|
|
235
|
+
placeholder: `Search ${g}...`,
|
|
236
|
+
value: x
|
|
232
237
|
}
|
|
233
238
|
) : void 0
|
|
234
239
|
] }) : void 0,
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
|
|
240
|
+
/* @__PURE__ */ u(
|
|
241
|
+
F,
|
|
237
242
|
{
|
|
238
243
|
"data-testid": "options-scrollable-menu",
|
|
239
|
-
ref:
|
|
244
|
+
ref: T,
|
|
240
245
|
scroll: "y",
|
|
241
246
|
width: "100%",
|
|
242
|
-
children:
|
|
243
|
-
const
|
|
244
|
-
return /* @__PURE__ */
|
|
247
|
+
children: a?.map((e, s, m) => {
|
|
248
|
+
const l = e.type === "checkboxes", r = !l || (w[s]?.length ?? 0) > 0;
|
|
249
|
+
return /* @__PURE__ */ u(
|
|
245
250
|
"div",
|
|
246
251
|
{
|
|
247
252
|
style: { position: "relative" },
|
|
248
|
-
children: /* @__PURE__ */
|
|
249
|
-
|
|
253
|
+
children: /* @__PURE__ */ V(
|
|
254
|
+
ue,
|
|
250
255
|
{
|
|
251
|
-
$border:
|
|
252
|
-
$overflow:
|
|
253
|
-
style: { padding:
|
|
256
|
+
$border: m.length > 1 && s > 0,
|
|
257
|
+
$overflow: l,
|
|
258
|
+
style: { padding: r ? R.spacing[0.875] : 0 },
|
|
254
259
|
children: [
|
|
255
|
-
|
|
256
|
-
|
|
260
|
+
f || e.showLabel === !0 || m.length > 1 && !l ? /* @__PURE__ */ u(
|
|
261
|
+
Y,
|
|
257
262
|
{
|
|
258
|
-
color:
|
|
263
|
+
color: R.palette.gray[f ? 800 : 400],
|
|
259
264
|
fontWeight: "bold",
|
|
260
265
|
mb: 0.5,
|
|
261
266
|
size: "md",
|
|
262
267
|
children: e.label
|
|
263
268
|
}
|
|
264
269
|
) : void 0,
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
|
|
270
|
+
/* @__PURE__ */ u(
|
|
271
|
+
re,
|
|
267
272
|
{
|
|
268
|
-
filterValue:
|
|
269
|
-
filteredItems:
|
|
273
|
+
filterValue: b,
|
|
274
|
+
filteredItems: w[s] ?? [],
|
|
270
275
|
id: t,
|
|
271
|
-
label:
|
|
272
|
-
onChange:
|
|
276
|
+
label: g,
|
|
277
|
+
onChange: Q,
|
|
273
278
|
option: e
|
|
274
279
|
}
|
|
275
280
|
)
|
|
@@ -287,5 +292,5 @@ const Ie = U(function({ hideTitle: x = !1, label: V, options: m }, F) {
|
|
|
287
292
|
);
|
|
288
293
|
});
|
|
289
294
|
export {
|
|
290
|
-
|
|
295
|
+
Oe as OptionsMenu
|
|
291
296
|
};
|