@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.
Files changed (32) hide show
  1. package/dist/components/filters/hooks.d.ts +4 -1
  2. package/dist/components/filters/hooks.js +35 -17
  3. package/dist/components/filters/options-menu/include-exclude/multi-select.d.ts +5 -1
  4. package/dist/components/filters/options-menu/include-exclude/multi-select.js +142 -112
  5. package/dist/components/filters/options-menu/index.js +156 -151
  6. package/dist/components/filters/options-menu/options/index.js +141 -114
  7. package/dist/components/filters/options-menu/options/types.d.ts +1 -0
  8. package/dist/components/filters/options-menu/single-select/index.js +83 -97
  9. package/dist/components/filters/options-menu/single-select/styles.d.ts +1 -2
  10. package/dist/components/filters/options-menu/single-select/styles.js +5 -22
  11. package/dist/components/filters/styles.d.ts +2 -1
  12. package/dist/components/filters/styles.js +27 -10
  13. package/dist/components/filters/types.d.ts +2 -2
  14. package/dist/components/form/styles.js +12 -7
  15. package/dist/components/inputs/fields/combobox/field/index.d.ts +1 -1
  16. package/dist/components/inputs/fields/combobox/field/index.js +115 -112
  17. package/dist/components/inputs/fields/combobox/index.d.ts +1 -1
  18. package/dist/components/inputs/fields/combobox/index.js +34 -31
  19. package/dist/components/inputs/fields/combobox/index.stories.d.ts +4 -1
  20. package/dist/components/inputs/fields/combobox/option/index.d.ts +1 -1
  21. package/dist/components/inputs/fields/combobox/option/index.js +79 -68
  22. package/dist/components/inputs/fields/combobox/styles.js +10 -3
  23. package/dist/components/inputs/fields/combobox/types.d.ts +5 -0
  24. package/dist/components/inputs/fields/combobox/utils.d.ts +1 -1
  25. package/dist/components/inputs/fields/combobox/utils.js +10 -10
  26. package/dist/components/loading/index.js +11 -11
  27. package/dist/components/loading/index.stories.d.ts +2 -1
  28. package/dist/components/modal/index.stories.d.ts +4 -1
  29. package/dist/components/modal/modal-confirm/index.d.ts +1 -1
  30. package/dist/components/modal/modal-confirm/index.js +34 -20
  31. package/dist/components/modal/types.d.ts +2 -0
  32. package/package.json +1 -1
@@ -1,49 +1,50 @@
1
- import { jsx as n, Fragment as q, jsxs as w } from "react/jsx-runtime";
2
- import { useVirtualizer as H } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
3
- import J from "../../../../_virtual/dayjs.min.js";
1
+ import { jsx as l, Fragment as J, jsxs as O } from "react/jsx-runtime";
2
+ import { useVirtualizer as K } from "../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
3
+ import Q from "../../../../_virtual/dayjs.min.js";
4
4
  import E from "../../../../_virtual/isNaN.js";
5
- import { useContext as K, useCallback as p, useRef as Q, useState as T } from "react";
6
- import { FiltersContext as W } from "../../context/index.js";
7
- import { NoMatches as X } from "../../search/no-matches/index.js";
8
- import { StyledItem as y, StyledItemCount as Y } from "../../styles.js";
9
- import { SingleSelectSearch as Z } from "../single-select/index.js";
10
- import { Checkbox as O } from "../../../checkbox/index.js";
11
- import { theme as L } from "../../../colors/index.js";
12
- import { Icon as z } from "../../../icon/index.js";
5
+ import { useContext as W, useCallback as m, useRef as X, useState as N } from "react";
6
+ import { FiltersContext as Y } from "../../context/index.js";
7
+ import { NoMatches as Z } from "../../search/no-matches/index.js";
8
+ import { StyledItem as y, StyledItemCount as ee } from "../../styles.js";
9
+ import { MultiSelectSearch as te } from "../include-exclude/multi-select.js";
10
+ import { SingleSelectSearch as oe } from "../single-select/index.js";
11
+ import { Checkbox as V } from "../../../checkbox/index.js";
12
+ import { theme as $ } from "../../../colors/index.js";
13
+ import { Icon as w } from "../../../icon/index.js";
13
14
  import "styled-components";
14
15
  import "../../../../_virtual/lodash.js";
15
16
  import "react-dom";
16
17
  import "../../../typography/heading/index.js";
17
- import { Span as ee } from "../../../typography/span/index.js";
18
+ import { Span as re } from "../../../typography/span/index.js";
18
19
  import "../../../typography/text/index.js";
19
20
  import "../../../inputs/styles.js";
20
21
  import "../../../container/index.js";
21
- import { Tag as te } from "../../../tag/index.js";
22
+ import { Tag as ne } from "../../../tag/index.js";
22
23
  import "../../../icon-button/index.js";
23
24
  import "../../../button/index.js";
24
- import { InputDateRange as oe } from "../../../inputs/fields/date-range/index.js";
25
- import { TextInput as re } from "../../../inputs/fields/text-input/index.js";
25
+ import { InputDateRange as le } from "../../../inputs/fields/date-range/index.js";
26
+ import { TextInput as ae } from "../../../inputs/fields/text-input/index.js";
26
27
  import "../../../layout/categories/buttons/index.js";
27
28
  import "../../../inputs/utils/action-button/index.js";
28
- import { InputNumberRange as ne } from "../../../inputs/fields/number-range/index.js";
29
+ import { InputNumberRange as ie } from "../../../inputs/fields/number-range/index.js";
29
30
  import "../../../../node_modules/react-international-phone/dist/index.js";
30
- import { useDebouncedCallback as le } from "../../../../hooks/use-debounced-callback.js";
31
- import { useMountEffect as ae } from "../../../../hooks/use-mount-effect.js";
32
- import { parseCheckboxesFilterValue as ie, parseTextFilterValue as se } from "../../../../utils/filters.js";
33
- const ce = ({
31
+ import { useDebouncedCallback as se } from "../../../../hooks/use-debounced-callback.js";
32
+ import { useMountEffect as ce } from "../../../../hooks/use-mount-effect.js";
33
+ import { parseCheckboxesFilterValue as z, parseTextFilterValue as me } from "../../../../utils/filters.js";
34
+ const pe = ({
34
35
  id: i,
35
- filterValue: l,
36
+ filterValue: n,
36
37
  label: a,
37
38
  onTextValue: t,
38
39
  checkboxLabel: s,
39
40
  onCheckboxChange: e,
40
41
  debounceMs: r
41
42
  }) => {
42
- const { text: c, checked: f } = se(
43
- l ?? ""
44
- ), [u, d] = T(c), [g, R] = T(c), h = Number.isFinite(r) && (r ?? 0) >= 0 ? Math.min(r ?? 0, 5e3) : 0, b = le(t, h);
43
+ const { text: c, checked: f } = me(
44
+ n ?? ""
45
+ ), [u, d] = N(c), [g, R] = N(c), h = Number.isFinite(r) && (r ?? 0) >= 0 ? Math.min(r ?? 0, 5e3) : 0, b = se(t, h);
45
46
  c !== g && (R(c), d(c), b.cancel());
46
- const k = p(
47
+ const k = m(
47
48
  (x) => {
48
49
  x.stopPropagation(), x.preventDefault();
49
50
  const v = x.target.value;
@@ -51,18 +52,18 @@ const ce = ({
51
52
  },
52
53
  [h, b, t]
53
54
  );
54
- return /* @__PURE__ */ w(
55
+ return /* @__PURE__ */ O(
55
56
  "div",
56
57
  {
57
58
  style: {
58
59
  display: "flex",
59
60
  flexDirection: "column",
60
- gap: L.spacing[0.25],
61
+ gap: $.spacing[0.25],
61
62
  width: "100%"
62
63
  },
63
64
  children: [
64
- s ? /* @__PURE__ */ n(
65
- O,
65
+ s ? /* @__PURE__ */ l(
66
+ V,
66
67
  {
67
68
  checked: f,
68
69
  label: s,
@@ -71,8 +72,8 @@ const ce = ({
71
72
  value: "textCheck"
72
73
  }
73
74
  ) : void 0,
74
- /* @__PURE__ */ n(
75
- re,
75
+ /* @__PURE__ */ l(
76
+ ae,
76
77
  {
77
78
  name: i,
78
79
  onChange: k,
@@ -83,21 +84,21 @@ const ce = ({
83
84
  ]
84
85
  }
85
86
  );
86
- }, me = {
87
+ }, ue = {
87
88
  text: ({
88
89
  id: i,
89
- filterValue: l,
90
+ filterValue: n,
90
91
  label: a,
91
92
  onTextValue: t,
92
93
  checkboxLabel: s,
93
94
  onCheckboxChange: e,
94
95
  debounceMs: r
95
- }) => t === void 0 ? null : /* @__PURE__ */ n(
96
- ce,
96
+ }) => t === void 0 ? null : /* @__PURE__ */ l(
97
+ pe,
97
98
  {
98
99
  checkboxLabel: s,
99
100
  debounceMs: r,
100
- filterValue: l,
101
+ filterValue: n,
101
102
  id: i,
102
103
  label: a,
103
104
  onCheckboxChange: e,
@@ -106,7 +107,7 @@ const ce = ({
106
107
  ),
107
108
  checkboxes: ({
108
109
  items: i,
109
- virtualItems: l,
110
+ virtualItems: n,
110
111
  filterValue: a,
111
112
  listRef: t,
112
113
  ref: s,
@@ -115,11 +116,11 @@ const ce = ({
115
116
  onChange: c
116
117
  }) => {
117
118
  const f = new Set(
118
- ie(a ?? "").values
119
+ z(a ?? "").values
119
120
  );
120
- return l.length > 0 ? (
121
+ return n.length > 0 ? (
121
122
  // Positioning context for the absolute rows, and it reserves their height
122
- /* @__PURE__ */ n(
123
+ /* @__PURE__ */ l(
123
124
  "div",
124
125
  {
125
126
  "data-testid": "options-virtual-list",
@@ -129,9 +130,9 @@ const ce = ({
129
130
  position: "relative",
130
131
  width: "100%"
131
132
  },
132
- children: l.map((u) => {
133
+ children: n.map((u) => {
133
134
  const d = i[u.index], g = f.has(d?.value);
134
- return /* @__PURE__ */ n(
135
+ return /* @__PURE__ */ l(
135
136
  "div",
136
137
  {
137
138
  "data-index": u.index,
@@ -142,8 +143,8 @@ const ce = ({
142
143
  left: 0,
143
144
  width: "100%"
144
145
  },
145
- children: /* @__PURE__ */ n(y, { "aria-selected": g, children: /* @__PURE__ */ n(
146
- O,
146
+ children: /* @__PURE__ */ l(y, { "aria-selected": g, children: /* @__PURE__ */ l(
147
+ V,
147
148
  {
148
149
  checked: g,
149
150
  label: d?.label,
@@ -158,33 +159,53 @@ const ce = ({
158
159
  })
159
160
  }
160
161
  )
161
- ) : /* @__PURE__ */ n(X, {});
162
+ ) : /* @__PURE__ */ l(Z, {});
162
163
  },
163
164
  combobox: ({
164
165
  id: i,
165
- items: l,
166
+ items: n,
166
167
  filterValue: a,
167
168
  label: t,
168
169
  onSelectChange: s
169
- }) => /* @__PURE__ */ n(
170
- Z,
170
+ }) => /* @__PURE__ */ l(
171
+ oe,
171
172
  {
172
- items: l,
173
+ items: n,
173
174
  name: i,
174
175
  onSelect: s,
175
176
  placeholder: `Search ${t}`,
176
- selected: a?.split(",").map((e) => e.trim()).find((e) => l.some((r) => r.value === e)) ?? null
177
+ selected: a?.split(",").map((e) => e.trim()).find((e) => n.some((r) => r.value === e)) ?? null
177
178
  }
178
179
  ),
179
- list: ({ items: i, filterValue: l, onListChange: a }) => i.map((t) => /* @__PURE__ */ w(
180
+ multiSelect: ({
181
+ id: i,
182
+ items: n,
183
+ filterValue: a,
184
+ label: t,
185
+ onMultiSelectToggle: s
186
+ }) => /* @__PURE__ */ l(
187
+ te,
188
+ {
189
+ items: [...n],
190
+ name: i,
191
+ onToggle: s,
192
+ placeholder: `Search ${t}`,
193
+ portal: !0,
194
+ selected: z(a ?? "").values.filter(
195
+ (e) => n.some((r) => r.value === e)
196
+ ),
197
+ showValues: !1
198
+ }
199
+ ),
200
+ list: ({ items: i, filterValue: n, onListChange: a }) => i.map((t) => /* @__PURE__ */ O(
180
201
  y,
181
202
  {
182
- "aria-selected": l?.split(",").includes(t?.value),
203
+ "aria-selected": n?.split(",").includes(t?.value),
183
204
  as: "button",
184
205
  onClick: a?.(t.value),
185
206
  children: [
186
- t.icon ? /* @__PURE__ */ n(
187
- z,
207
+ t.icon ? /* @__PURE__ */ l(
208
+ w,
188
209
  {
189
210
  icon: t.icon,
190
211
  iconColor: t.iconColor,
@@ -192,10 +213,10 @@ const ce = ({
192
213
  iconType: t.iconType ?? "fa-light"
193
214
  }
194
215
  ) : void 0,
195
- /* @__PURE__ */ n(
196
- ee,
216
+ /* @__PURE__ */ l(
217
+ re,
197
218
  {
198
- color: L.palette.gray[800],
219
+ color: $.palette.gray[800],
199
220
  display: "block",
200
221
  overflow: "hidden",
201
222
  size: "md",
@@ -205,16 +226,16 @@ const ce = ({
205
226
  children: t.label
206
227
  }
207
228
  ),
208
- /* @__PURE__ */ n("span", { className: "filter-item" }),
209
- t.count === void 0 ? void 0 : /* @__PURE__ */ n(Y, { children: /* @__PURE__ */ n(
210
- te,
229
+ /* @__PURE__ */ l("span", { className: "filter-item" }),
230
+ t.count === void 0 ? void 0 : /* @__PURE__ */ l(ee, { children: /* @__PURE__ */ l(
231
+ ne,
211
232
  {
212
233
  tagLabel: t.count.toLocaleString("en-US"),
213
234
  variant: "default"
214
235
  }
215
236
  ) }),
216
- l?.split(",").includes(t?.value) ? /* @__PURE__ */ n("div", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ n(
217
- z,
237
+ n?.split(",").includes(t?.value) ? /* @__PURE__ */ l("div", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ l(
238
+ w,
218
239
  {
219
240
  icon: "check",
220
241
  iconClass: "selected",
@@ -228,13 +249,13 @@ const ce = ({
228
249
  )),
229
250
  dateRange: ({
230
251
  id: i,
231
- filterValue: l,
252
+ filterValue: n,
232
253
  onRangeChange: a,
233
254
  updateCalendarState: t
234
255
  }) => {
235
- const [s, e] = l?.split(",").filter((r) => J(r).isValid() || r === "-") ?? [];
236
- return /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n(
237
- oe,
256
+ const [s, e] = n?.split(",").filter((r) => Q(r).isValid() || r === "-") ?? [];
257
+ return /* @__PURE__ */ l(y, { children: /* @__PURE__ */ l(
258
+ le,
238
259
  {
239
260
  name: i,
240
261
  onOpenCalendar: t,
@@ -254,14 +275,14 @@ const ce = ({
254
275
  },
255
276
  numberRange: ({
256
277
  id: i,
257
- filterValue: l,
278
+ filterValue: n,
258
279
  minValue: a,
259
280
  maxValue: t,
260
281
  onRangeNumberChange: s
261
282
  }) => {
262
- const e = l?.split(",") ?? [], r = e[0]?.trim(), c = e[1]?.trim(), f = r && r !== "" && r !== "-" && !E(Number(r)) ? Number(r) : void 0, u = c && c !== "" && c !== "-" && !E(Number(c)) ? Number(c) : void 0;
263
- return /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n(
264
- ne,
283
+ const e = n?.split(",") ?? [], r = e[0]?.trim(), c = e[1]?.trim(), f = r && r !== "" && r !== "-" && !E(Number(r)) ? Number(r) : void 0, u = c && c !== "" && c !== "-" && !E(Number(c)) ? Number(c) : void 0;
284
+ return /* @__PURE__ */ l(y, { children: /* @__PURE__ */ l(
285
+ ie,
265
286
  {
266
287
  name: i,
267
288
  propsMax: {
@@ -284,114 +305,120 @@ const ce = ({
284
305
  }
285
306
  ) });
286
307
  }
287
- }, Ue = ({
308
+ }, He = ({
288
309
  id: i,
289
- filteredItems: l,
310
+ filteredItems: n,
290
311
  filterValue: a,
291
312
  label: t,
292
313
  option: s,
293
314
  onChange: e
294
315
  }) => {
295
- const { type: r, minValue: c, maxValue: f, checkboxLabel: u, debounceMs: d } = s ?? {}, g = r && me[r], {
316
+ const { type: r, minValue: c, maxValue: f, checkboxLabel: u, debounceMs: d } = s ?? {}, g = r && ue[r], {
296
317
  calendarState: { updateCalendarState: R },
297
318
  scrollState: h
298
- } = K(W), b = p(() => 36, []), k = p(
319
+ } = W(Y), b = m(() => 36, []), k = m(
299
320
  () => h.ref.current,
300
321
  [h.ref]
301
- ), x = Q(null), [v, V] = T(0), M = p(() => {
302
- const o = h.ref.current, m = x.current;
303
- if (o && m) {
304
- const S = m.getBoundingClientRect().top - o.getBoundingClientRect().top + o.scrollTop;
305
- V(
322
+ ), x = X(null), [v, L] = N(0), M = m(() => {
323
+ const o = h.ref.current, p = x.current;
324
+ if (o && p) {
325
+ const S = p.getBoundingClientRect().top - o.getBoundingClientRect().top + o.scrollTop;
326
+ L(
306
327
  (C) => C === S ? C : S
307
328
  );
308
329
  }
309
- }, [h.ref]), $ = p(
330
+ }, [h.ref]), D = m(
310
331
  (o) => {
311
332
  x.current = o, M();
312
333
  },
313
334
  [M]
314
335
  );
315
- ae(() => {
336
+ ce(() => {
316
337
  const o = h.ref.current;
317
338
  if (o === null || typeof ResizeObserver > "u")
318
339
  return;
319
- const m = new ResizeObserver(M), S = () => {
320
- m.disconnect(), Array.from(o.children).forEach((_) => {
321
- m.observe(_);
340
+ const p = new ResizeObserver(M), S = () => {
341
+ p.disconnect(), Array.from(o.children).forEach((H) => {
342
+ p.observe(H);
322
343
  });
323
344
  }, C = new MutationObserver(S);
324
345
  return C.observe(o, { childList: !0 }), S(), () => {
325
- C.disconnect(), m.disconnect();
346
+ C.disconnect(), p.disconnect();
326
347
  };
327
348
  });
328
- const N = H({
329
- count: l.length,
349
+ const T = K({
350
+ count: n.length,
330
351
  estimateSize: b,
331
352
  getScrollElement: k,
332
353
  scrollMargin: v,
333
354
  useFlushSync: !1
334
- }), D = N.getVirtualItems(), F = p(
355
+ }), F = T.getVirtualItems(), P = m(
335
356
  (o) => {
336
357
  o.stopPropagation(), o.preventDefault(), e(o.target.value, r ?? "");
337
358
  },
338
359
  [e, r]
339
- ), P = p(
340
- (o) => (m) => {
341
- e(m, "dateRange", o);
360
+ ), I = m(
361
+ (o) => (p) => {
362
+ e(p, "dateRange", o);
342
363
  },
343
364
  [e]
344
- ), I = p(
345
- (o) => (m) => {
346
- m.stopPropagation(), m.preventDefault(), e(m.target.value, "numberRange", o);
365
+ ), j = m(
366
+ (o) => (p) => {
367
+ p.stopPropagation(), p.preventDefault(), e(p.target.value, "numberRange", o);
347
368
  },
348
369
  [e]
349
- ), j = p(
370
+ ), A = m(
350
371
  (o) => () => {
351
372
  e(o, "list");
352
373
  },
353
374
  [e]
354
- ), A = p(
375
+ ), B = m(
355
376
  (o) => () => {
356
377
  e(o, "combobox");
357
378
  },
358
379
  [e]
359
- ), B = p(
380
+ ), G = m(
381
+ (o) => {
382
+ e(o, "multiSelect");
383
+ },
384
+ [e]
385
+ ), U = m(
360
386
  (o) => {
361
387
  o.stopPropagation(), e(o.target.checked ? "true" : "false", "textCheckbox");
362
388
  },
363
389
  [e]
364
- ), G = p(
390
+ ), _ = m(
365
391
  (o) => {
366
392
  e(o, r ?? "text");
367
393
  },
368
394
  [e, r]
369
- ), U = N.getTotalSize();
370
- return /* @__PURE__ */ n(q, { children: g?.({
371
- items: l,
395
+ ), q = T.getTotalSize();
396
+ return /* @__PURE__ */ l(J, { children: g?.({
397
+ items: n,
372
398
  label: t,
373
- virtualItems: D,
399
+ virtualItems: F,
374
400
  id: i,
375
401
  filterValue: a,
376
- onChange: F,
377
- onListChange: j,
378
- onSelectChange: A,
379
- onRangeChange: P,
380
- onRangeNumberChange: I,
381
- onTextValue: G,
402
+ onChange: P,
403
+ onListChange: A,
404
+ onSelectChange: B,
405
+ onMultiSelectToggle: G,
406
+ onRangeChange: I,
407
+ onRangeNumberChange: j,
408
+ onTextValue: _,
382
409
  debounceMs: d,
383
- listRef: $,
384
- ref: N.measureElement,
410
+ listRef: D,
411
+ ref: T.measureElement,
385
412
  scrollMargin: v,
386
- totalSize: U,
413
+ totalSize: q,
387
414
  updateCalendarState: R,
388
415
  minValue: c,
389
416
  maxValue: f,
390
417
  checkboxLabel: u,
391
- onCheckboxChange: B
418
+ onCheckboxChange: U
392
419
  }) ?? null });
393
420
  };
394
421
  export {
395
- Ue as Options,
396
- ce as TextFilterRenderer
422
+ He as Options,
423
+ pe as TextFilterRenderer
397
424
  };
@@ -21,6 +21,7 @@ interface IRendererConfig {
21
21
  onChange: (event: Readonly<ChangeEvent<HTMLInputElement>>) => void;
22
22
  onListChange: (value: string) => VoidFunction;
23
23
  onSelectChange: (value: string) => VoidFunction;
24
+ onMultiSelectToggle: (value: string) => void;
24
25
  onRangeChange?: (index: number) => (value: string) => void;
25
26
  onRangeNumberChange?: (index: number) => (event: Readonly<ChangeEvent<HTMLInputElement>>) => void;
26
27
  ref: (node: Readonly<Element | null>) => void;