@canonical/maas-react-components 2.7.0 → 2.7.2

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 (78) hide show
  1. package/dist/@canonical/maas-react-components.es.js +2 -678
  2. package/dist/components/DynamicTable/DynamicTable.d.ts +3 -3
  3. package/dist/components/DynamicTable/DynamicTable.stories.d.ts +1 -1
  4. package/dist/components/FileUpload/FileUpload.stories.d.ts +1 -1
  5. package/dist/components/GenericTable/GenericTable.stories.d.ts +1 -1
  6. package/dist/components/GenericTable/components/PaginationBar/ControlsBar/ControlsBar.d.ts +2 -2
  7. package/dist/components/GenericTable/components/TableCheckbox/TableCheckbox.d.ts +2 -2
  8. package/dist/components/GenericTable/utils/renderDataRows.d.ts +1 -1
  9. package/dist/components/GenericTable/utils/renderLoadingRows.d.ts +1 -1
  10. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +1 -1
  11. package/dist/components/NestedFormGroup/NestedFormGroup.d.ts +1 -1
  12. package/dist/components/NestedFormGroup/NestedFormGroup.stories.d.ts +2 -2
  13. package/dist/components/Pagination/Pagination.stories.d.ts +3 -3
  14. package/dist/components/QueryInput/QueryInput.stories.d.ts +1 -1
  15. package/dist/components/Stepper/Stepper.stories.d.ts +1 -1
  16. package/dist/components/TableCaption/TableCaption.d.ts +3 -3
  17. package/dist/components/TableCaption/TableCaption.stories.d.ts +1 -1
  18. package/dist/constants.d.ts +6 -0
  19. package/dist/elements/ExternalLink/ExternalLink.d.ts +1 -1
  20. package/dist/elements/ExternalLink/ExternalLink.stories.d.ts +1 -1
  21. package/dist/elements/Meter/Meter.d.ts +2 -2
  22. package/dist/elements/Meter/Meter.stories.d.ts +2 -2
  23. package/dist/elements/Placeholder/Placeholder.stories.d.ts +1 -1
  24. package/dist/lib-BEVV6FLF.mjs +2018 -0
  25. package/dist/maas-react-components.css +2 -1
  26. package/dist/sections/ContentSection/ContentSection.d.ts +6 -6
  27. package/dist/sections/ContentSection/ContentSection.stories.d.ts +5 -5
  28. package/dist/sections/FormSection/FormSection.d.ts +4 -4
  29. package/dist/sections/FormSection/FormSection.stories.d.ts +3 -3
  30. package/dist/sections/InputGroup/InputGroup.d.ts +3 -3
  31. package/dist/sections/InputGroup/InputGroup.stories.d.ts +3 -3
  32. package/dist/sections/MainToolbar/MainToolbar.d.ts +4 -4
  33. package/dist/sections/MainToolbar/MainToolbar.stories.d.ts +2 -2
  34. package/dist/sections/Navigation/Banner/Banner.d.ts +1 -1
  35. package/dist/sections/Navigation/Banner/Banner.stories.d.ts +2 -2
  36. package/dist/sections/Navigation/CollapseToggle/CollapseToggle.stories.d.ts +1 -1
  37. package/dist/sections/Navigation/Content/Content.d.ts +1 -1
  38. package/dist/sections/Navigation/Content/Content.stories.d.ts +2 -2
  39. package/dist/sections/Navigation/Controls/Controls.d.ts +1 -1
  40. package/dist/sections/Navigation/Controls/Controls.stories.d.ts +2 -2
  41. package/dist/sections/Navigation/Drawer/Drawer.d.ts +1 -1
  42. package/dist/sections/Navigation/Drawer/Drawer.stories.d.ts +2 -2
  43. package/dist/sections/Navigation/Footer/Footer.d.ts +1 -1
  44. package/dist/sections/Navigation/Footer/Footer.stories.d.ts +2 -2
  45. package/dist/sections/Navigation/Header/Header.d.ts +1 -1
  46. package/dist/sections/Navigation/Header/Header.stories.d.ts +2 -2
  47. package/dist/sections/Navigation/Icon/Icon.d.ts +1 -1
  48. package/dist/sections/Navigation/Icon/Icon.stories.d.ts +1 -1
  49. package/dist/sections/Navigation/Item/Item.d.ts +1 -1
  50. package/dist/sections/Navigation/Item/Item.stories.d.ts +3 -3
  51. package/dist/sections/Navigation/Label/Label.d.ts +1 -1
  52. package/dist/sections/Navigation/Label/Label.stories.d.ts +1 -1
  53. package/dist/sections/Navigation/Link/Link.d.ts +2 -2
  54. package/dist/sections/Navigation/Link/Link.stories.d.ts +3 -3
  55. package/dist/sections/Navigation/List/List.d.ts +1 -1
  56. package/dist/sections/Navigation/List/List.stories.d.ts +2 -2
  57. package/dist/sections/Navigation/Logo/Logo.d.ts +2 -2
  58. package/dist/sections/Navigation/Logo/Logo.stories.d.ts +2 -2
  59. package/dist/sections/Navigation/LogoIcon/LogoIcon.stories.d.ts +2 -2
  60. package/dist/sections/Navigation/LogoName/LogoName.d.ts +1 -1
  61. package/dist/sections/Navigation/LogoName/LogoName.stories.d.ts +1 -1
  62. package/dist/sections/Navigation/LogoTag/LogoTag.d.ts +1 -1
  63. package/dist/sections/Navigation/LogoTag/LogoTag.stories.d.ts +2 -2
  64. package/dist/sections/Navigation/LogoText/LogoText.d.ts +1 -1
  65. package/dist/sections/Navigation/MenuButton/MenuButton.d.ts +1 -1
  66. package/dist/sections/Navigation/MenuButton/MenuButton.stories.d.ts +1 -1
  67. package/dist/sections/Navigation/Navigation.d.ts +19 -19
  68. package/dist/sections/Navigation/Navigation.stories.d.ts +3 -3
  69. package/dist/sections/Navigation/Text/Text.d.ts +1 -1
  70. package/dist/sections/SidePanel/SidePanel.stories.d.ts +1 -1
  71. package/dist/sections/SidePanel/index.d.ts +1 -0
  72. package/dist/testing/index.es.js +112 -129
  73. package/dist/testing/mockSidePanel.d.ts +3 -2
  74. package/dist/testing/spyOnMutation.d.ts +2 -1
  75. package/dist/types.d.ts +7 -0
  76. package/dist/utils/formatBytes/formatBytes.stories.d.ts +1 -1
  77. package/package.json +12 -15
  78. package/dist/QueryInput-D7uXzKgr.mjs +0 -1648
@@ -1,678 +1,2 @@
1
- import { C as Re, D as Ae, F as Me, G as Le, I as Fe, L as De, a as Be, M as Oe, N as Ue, b as je, e as Ve, f as Te, P as qe, S as Ge, c as Ke, T as Qe, d as $e, m as He, t as ze, u as Ze } from "../QueryInput-D7uXzKgr.mjs";
2
- import { jsx as a, jsxs as w, Fragment as te } from "react/jsx-runtime";
3
- import { Link as ne, Spinner as H, Label as le, Button as V, Icon as K, CheckboxInput as se, useClickOutside as oe, useOnEscapePressed as ae, SearchBox as z } from "@canonical/react-components";
4
- import L from "classnames";
5
- import { useReducer as ie, useCallback as S, useId as q, useMemo as O, useState as U, useEffect as G, useRef as T } from "react";
6
- import { useDropzone as re } from "react-dropzone";
7
- const Ne = ({ children: t, to: l, ...e }) => /* @__PURE__ */ a(ne, { ...e, href: l, rel: "noreferrer noopener", target: "_blank", children: t }), ce = ({
8
- percentComplete: t
9
- }) => /* @__PURE__ */ w("small", { className: "progress-indicator", children: [
10
- t,
11
- "% ",
12
- /* @__PURE__ */ a(H, { className: "progress-indicator__spinner" })
13
- ] }), Z = ({
14
- children: t,
15
- className: l,
16
- isVisible: e
17
- }) => /* @__PURE__ */ a(
18
- "div",
19
- {
20
- className: L("fade-in--down", l),
21
- "aria-hidden": e ? "false" : "true",
22
- style: { visibility: e ? "visible" : "hidden" },
23
- children: t
24
- }
25
- ), we = ({
26
- children: t,
27
- ...l
28
- }) => /* @__PURE__ */ a(Z, { isVisible: !l["aria-hidden"], children: /* @__PURE__ */ a("div", { className: "p-form__nested-group", ...l, children: t }) }), Se = ({ activeStep: t, items: l }) => /* @__PURE__ */ a("ol", { className: "stepper", children: l.map((e, n) => {
29
- const r = n === t, p = n < t;
30
- return /* @__PURE__ */ a("li", { "aria-label": e, className: "stepper__item", children: /* @__PURE__ */ a(
31
- "p",
32
- {
33
- "aria-label": p ? `${e} (completed)` : e,
34
- className: L("stepper__title", {
35
- "stepper__title--is-active": r,
36
- "stepper__title--is-complete": p
37
- }),
38
- children: e
39
- }
40
- ) }, n);
41
- }) }), de = () => {
42
- const t = (u, g) => {
43
- switch (g.type) {
44
- case "add-files":
45
- return {
46
- acceptedFiles: [
47
- ...u.acceptedFiles,
48
- ...g.payload.acceptedFiles
49
- ],
50
- fileRejections: [
51
- ...u.fileRejections,
52
- ...g.payload.fileRejections
53
- ]
54
- };
55
- case "remove-accepted":
56
- return {
57
- ...u,
58
- acceptedFiles: u.acceptedFiles.filter(
59
- (v) => v !== g.payload
60
- )
61
- };
62
- case "remove-rejected":
63
- return {
64
- ...u,
65
- fileRejections: u.fileRejections.filter(
66
- (v) => v !== g.payload
67
- )
68
- };
69
- }
70
- }, [{ acceptedFiles: l, fileRejections: e }, n] = ie(
71
- t,
72
- {
73
- acceptedFiles: [],
74
- fileRejections: []
75
- }
76
- ), r = S(
77
- (u, g) => n({
78
- type: "add-files",
79
- payload: { acceptedFiles: u, fileRejections: g }
80
- }),
81
- [n]
82
- );
83
- return { acceptedFiles: l, fileRejections: e, onFileUpload: r, removeFile: (u) => n({ type: "remove-accepted", payload: u }), removeRejectedFile: (u) => n({ type: "remove-rejected", payload: u }) };
84
- }, Ie = ({
85
- accept: t,
86
- error: l,
87
- files: e,
88
- help: n,
89
- label: r,
90
- maxFiles: p,
91
- maxSize: m,
92
- minSize: u,
93
- onFileUpload: g,
94
- onRemoveFile: v,
95
- rejectedFiles: C
96
- }) => {
97
- const d = de(), b = e ?? d.acceptedFiles, f = C ?? d.fileRejections, E = g ?? d.onFileUpload, h = (c) => {
98
- v ? v(c) : "file" in c && "errors" in c ? d.removeRejectedFile(c) : d.removeFile(c);
99
- }, { getRootProps: x, getInputProps: i } = re({
100
- accept: t,
101
- maxFiles: p,
102
- maxSize: m,
103
- minSize: u,
104
- onDrop: E
105
- }), y = q();
106
- return /* @__PURE__ */ w(
107
- "div",
108
- {
109
- className: L("p-form__group p-form-validation", {
110
- "is-error": !!l
111
- }),
112
- children: [
113
- r && /* @__PURE__ */ a(le, { id: y, children: r }),
114
- n && /* @__PURE__ */ a("p", { className: "p-form-help-text", children: n }),
115
- /* @__PURE__ */ w("div", { className: "p-form__control", children: [
116
- !p || b.length + f.length < p ? /* @__PURE__ */ a("div", { className: "file-upload__wrapper", children: /* @__PURE__ */ w(
117
- "div",
118
- {
119
- ...x(),
120
- "aria-labelledby": r ? y : void 0,
121
- className: "file-upload",
122
- "data-testid": "file-upload",
123
- children: [
124
- /* @__PURE__ */ a("input", { ...i() }),
125
- /* @__PURE__ */ a("button", { className: "file-upload__button", type: "button", children: "Drag and drop files here or click to upload" })
126
- ]
127
- }
128
- ) }) : null,
129
- /* @__PURE__ */ w("div", { className: "file-upload__files-list", children: [
130
- f && f.map((c) => /* @__PURE__ */ a("span", { className: "is-error", children: /* @__PURE__ */ w("div", { className: "file-upload__file is-rejected", children: [
131
- c.file.name,
132
- /* @__PURE__ */ a(
133
- V,
134
- {
135
- appearance: "base",
136
- className: "file-upload__file-remove-button",
137
- onClick: () => h(c),
138
- type: "button",
139
- children: /* @__PURE__ */ a(K, { name: "close", children: "Remove file" })
140
- }
141
- )
142
- ] }) }, c.file.name)),
143
- b && b.map((c) => /* @__PURE__ */ w("div", { className: "file-upload__file", children: [
144
- c.name,
145
- c.percentUploaded !== void 0 ? /* @__PURE__ */ a(ce, { percentComplete: c.percentUploaded }) : /* @__PURE__ */ a(
146
- V,
147
- {
148
- appearance: "base",
149
- className: "file-upload__file-remove-button",
150
- onClick: () => h(c),
151
- type: "button",
152
- children: /* @__PURE__ */ a(K, { name: "close", children: "Remove file" })
153
- }
154
- )
155
- ] }, c.name))
156
- ] }),
157
- l ? /* @__PURE__ */ w("p", { className: "p-form-validation__message", children: [
158
- /* @__PURE__ */ a("strong", { children: "Error: " }),
159
- l
160
- ] }) : null
161
- ] })
162
- ]
163
- }
164
- );
165
- }, X = (t, l) => t.label.localeCompare(l.label, "en", { numeric: !0 }), ue = (t) => (l, e) => {
166
- if (t) {
167
- const n = t.has(l.value), r = t.has(e.value);
168
- if (n && !r) return -1;
169
- if (!n && r) return 1;
170
- }
171
- return 0;
172
- }, pe = (t) => {
173
- const l = /* @__PURE__ */ new Map();
174
- return t.forEach((e) => {
175
- const n = e.group || "Ungrouped", r = l.get(n) || [];
176
- r.push(e), l.set(n, r);
177
- }), Array.from(l, ([e, n]) => ({ group: e, items: n }));
178
- }, he = ({
179
- items: t,
180
- selectedItems: l,
181
- disabledItems: e,
182
- header: n,
183
- updateItems: r,
184
- isOpen: p,
185
- footer: m,
186
- sortFn: u = X,
187
- groupFn: g = pe,
188
- ...v
189
- }) => {
190
- const C = O(
191
- () => new Set(l.map((i) => i.value)),
192
- [l]
193
- ), d = O(
194
- () => new Set(e.map((i) => i.value)),
195
- [e]
196
- ), [b, f] = U(new Set(C));
197
- G(() => {
198
- p && f(new Set(C));
199
- }, [p]);
200
- const E = O(() => t.some((i) => i.group), [t]), h = O(
201
- () => E ? g(t) : [{ group: "Ungrouped", items: t }],
202
- [t, g]
203
- ), x = (i) => {
204
- const { checked: y, value: c } = i.target, P = t.find((I) => `${I.value}` === c);
205
- if (P) {
206
- const I = y ? [...l, P] : l.filter((F) => `${F.value}` !== c) ?? [];
207
- r(I);
208
- }
209
- };
210
- return /* @__PURE__ */ a(Z, { isVisible: p, className: "put-above", children: /* @__PURE__ */ w("div", { className: "multi-select__dropdown", role: "listbox", ...v, children: [
211
- n || null,
212
- h.map(({ group: i, items: y }) => /* @__PURE__ */ w("div", { className: "multi-select__group", children: [
213
- E ? /* @__PURE__ */ a("h5", { className: "multi-select__dropdown-header", children: i }) : null,
214
- /* @__PURE__ */ a("ul", { className: "multi-select__dropdown-list", "aria-label": i, children: y.sort(u).sort(ue(b)).map((c) => /* @__PURE__ */ a("li", { className: "multi-select__dropdown-item", children: /* @__PURE__ */ a(
215
- se,
216
- {
217
- disabled: d.has(c.value),
218
- label: c.label,
219
- checked: C.has(c.value),
220
- value: c.value,
221
- onChange: x
222
- },
223
- c.value
224
- ) }, c.value)) })
225
- ] }, i)),
226
- m ? /* @__PURE__ */ a("div", { className: "multi-select__footer", children: m }) : null
227
- ] }) });
228
- }, Ce = ({
229
- disabled: t,
230
- selectedItems: l = [],
231
- label: e,
232
- onItemsUpdate: n,
233
- placeholder: r,
234
- required: p = !1,
235
- items: m = [],
236
- disabledItems: u = [],
237
- dropdownHeader: g,
238
- dropdownFooter: v,
239
- variant: C = "search"
240
- }) => {
241
- const d = oe(() => {
242
- f(!1), h("");
243
- });
244
- ae(() => {
245
- f(!1), h("");
246
- });
247
- const [b, f] = U(!1), [E, h] = U("");
248
- G(() => {
249
- b || h("");
250
- }, [b]);
251
- const [x, i] = U([]), y = l || x, c = (_) => {
252
- const R = Array.from(new Set(_));
253
- i(R), n && n(R);
254
- }, P = q(), I = q(), F = y.filter(
255
- (_) => m.some((R) => R.value === _.value)
256
- ).sort(X).map((_) => _.label).join(", ");
257
- return /* @__PURE__ */ a("div", { ref: d, children: /* @__PURE__ */ w("div", { className: "multi-select", children: [
258
- C === "search" ? /* @__PURE__ */ a(
259
- z,
260
- {
261
- externallyControlled: !0,
262
- "aria-controls": P,
263
- "aria-expanded": b,
264
- id: I,
265
- role: "combobox",
266
- "aria-label": e || r || "Search",
267
- disabled: t,
268
- autoComplete: "off",
269
- onChange: (_) => {
270
- h(_), f(!0);
271
- },
272
- onFocus: () => f(!0),
273
- placeholder: r ?? "Search",
274
- required: p,
275
- type: "text",
276
- value: E,
277
- className: "multi-select__input"
278
- }
279
- ) : /* @__PURE__ */ a(
280
- "button",
281
- {
282
- role: "combobox",
283
- type: "button",
284
- "aria-label": e || r || "Select items",
285
- "aria-controls": P,
286
- "aria-expanded": b,
287
- className: "multi-select__select-button",
288
- onClick: () => {
289
- f((_) => !_);
290
- },
291
- children: /* @__PURE__ */ a("span", { className: "multi-select__condensed-text", children: y.length > 0 ? F : r ?? "Select items" })
292
- }
293
- ),
294
- /* @__PURE__ */ a(
295
- he,
296
- {
297
- id: P,
298
- isOpen: b,
299
- items: E.length > 0 ? m.filter(
300
- (_) => _.label.toLowerCase().includes(E.toLowerCase())
301
- ) : m,
302
- selectedItems: y,
303
- disabledItems: u,
304
- header: g,
305
- updateItems: c,
306
- footer: v || /* @__PURE__ */ w(te, { children: [
307
- /* @__PURE__ */ a(
308
- V,
309
- {
310
- appearance: "link",
311
- onClick: () => {
312
- const _ = m.filter(
313
- (R) => !u.some(
314
- (D) => D.value === R.value
315
- )
316
- );
317
- c([...y, ..._]);
318
- },
319
- type: "button",
320
- children: "Select all"
321
- }
322
- ),
323
- /* @__PURE__ */ a(
324
- V,
325
- {
326
- appearance: "link",
327
- onClick: () => {
328
- const _ = y.filter(
329
- (R) => u.some(
330
- (D) => D.value === R.value
331
- )
332
- );
333
- c(_);
334
- },
335
- type: "button",
336
- children: "Clear"
337
- }
338
- )
339
- ] })
340
- }
341
- )
342
- ] }) });
343
- }, Q = {
344
- DEFAULT: 4,
345
- EXPANDED: 15
346
- }, k = {
347
- OPEN_PAREN: "(",
348
- CLOSE_PAREN: ")",
349
- EQUALS: "=",
350
- COLON: ":",
351
- COMMA: ","
352
- }, j = (t, l = t.length) => {
353
- const e = me(t, l), { token: n, tokenStart: r, tokenEnd: p } = fe(t, l);
354
- return { context: e, token: n, tokenStart: r, tokenEnd: p };
355
- }, me = (t, l) => {
356
- let e = 0;
357
- for (let n = l - 1; n >= 0; n--) {
358
- const r = t[n];
359
- if (r === k.CLOSE_PAREN)
360
- e++;
361
- else if (r === k.OPEN_PAREN) {
362
- if (e === 0) {
363
- const m = t.slice(0, n).trimEnd().match(/([a-zA-Z0-9_-]+)\s*:\s*$/);
364
- return (m == null ? void 0 : m[1]) || "";
365
- }
366
- e--;
367
- }
368
- }
369
- return "";
370
- }, fe = (t, l) => {
371
- let e = l, n = l;
372
- for (; n < t.length && /[^\s=(),]/.test(t[n]); )
373
- n++;
374
- for (; e > 0 && /[^\s=(),]/.test(t[e - 1]); )
375
- e--;
376
- return { token: t.slice(e, n), tokenStart: e, tokenEnd: n };
377
- }, $ = (t, l) => {
378
- const e = t.charAt(l - 1);
379
- return l > 0 && (e === k.CLOSE_PAREN || e === k.COMMA);
380
- }, Ee = ({
381
- className: t,
382
- disabled: l = !1,
383
- search: e,
384
- setSearch: n,
385
- context: r,
386
- setContext: p,
387
- setToken: m,
388
- suggestions: u,
389
- isLoading: g = !1,
390
- placeholder: v,
391
- ...C
392
- }) => {
393
- const [d, b] = U({
394
- isVisible: !1,
395
- highlightedIndex: -1,
396
- showingMore: !1,
397
- cursorPosition: 0
398
- }), f = T(null), E = T(null), h = T(null), x = O(() => {
399
- const s = d.showingMore ? Q.EXPANDED : Q.DEFAULT, o = u.slice(0, s);
400
- return !d.showingMore && u.length > s ? [...o, { value: "Show more...", type: "more" }] : o;
401
- }, [u, d.showingMore]), i = S(
402
- (s) => {
403
- b(typeof s == "function" ? (o) => ({ ...o, ...s(o) }) : (o) => ({ ...o, ...s }));
404
- },
405
- []
406
- ), y = S(
407
- (s) => {
408
- f.current && !f.current.contains(s.target) && i({
409
- isVisible: !1,
410
- highlightedIndex: -1
411
- });
412
- },
413
- [i]
414
- ), c = S(
415
- (s, o) => {
416
- const { tokenStart: N, tokenEnd: A } = o;
417
- if (s.type === "filter") {
418
- const B = s.value + k.COLON + k.OPEN_PAREN;
419
- return e.slice(0, N) + B + e.slice(A);
420
- }
421
- if (r.length === 0) {
422
- const B = s.type + k.COLON + k.OPEN_PAREN + k.EQUALS + s.value;
423
- return e.slice(0, N) + B + e.slice(A);
424
- }
425
- const M = e.charAt(N - 1) === k.EQUALS ? s.value : k.EQUALS + s.value;
426
- return e.slice(0, N) + M + e.slice(A);
427
- },
428
- [e, r]
429
- ), P = S(
430
- (s) => {
431
- const o = x[s];
432
- if (!o) return;
433
- if (o.type === "more") {
434
- i({ showingMore: !0 });
435
- return;
436
- }
437
- const N = j(
438
- e,
439
- d.cursorPosition
440
- ), A = c(o, N), M = N.tokenStart + (o.type === "filter" ? o.value.length + 2 : r.length === 0 ? o.type.length + o.value.length + 3 : o.value.length + 1), { context: B, token: ee } = j(
441
- A,
442
- M
443
- );
444
- p(B), m(ee), n(A), setTimeout(() => {
445
- h.current && (h.current.focus(), h.current.setSelectionRange(
446
- M,
447
- M
448
- ));
449
- }, 0), i({
450
- highlightedIndex: 0,
451
- showingMore: !1,
452
- isVisible: o.type === "filter",
453
- cursorPosition: M
454
- });
455
- },
456
- [
457
- x,
458
- c,
459
- e,
460
- d.cursorPosition,
461
- r,
462
- p,
463
- m,
464
- n,
465
- i
466
- ]
467
- ), I = S(() => {
468
- if (!h.current) return;
469
- const s = h.current.selectionStart || 0, { context: o, token: N } = j(
470
- e,
471
- s
472
- );
473
- p(o), m(N), i((A) => ({
474
- ...A,
475
- isVisible: !$(e, s),
476
- cursorPosition: s
477
- }));
478
- }, [e, p, m, i]), F = S(
479
- (s) => {
480
- const { key: o } = s;
481
- if (d.isVisible) {
482
- const N = x.length;
483
- switch (o) {
484
- case "Tab":
485
- case "ArrowDown":
486
- s.preventDefault(), i({
487
- highlightedIndex: (d.highlightedIndex + 1) % N
488
- });
489
- return;
490
- case "ArrowUp":
491
- s.preventDefault(), i({
492
- highlightedIndex: d.highlightedIndex <= 0 ? N - 1 : d.highlightedIndex - 1
493
- });
494
- return;
495
- case "Enter":
496
- s.preventDefault(), d.highlightedIndex >= 0 ? P(d.highlightedIndex) : i({ isVisible: !1 });
497
- return;
498
- case "Escape":
499
- s.preventDefault(), i({
500
- isVisible: !1,
501
- highlightedIndex: -1
502
- });
503
- return;
504
- }
505
- }
506
- (o === "ArrowLeft" || o === "ArrowRight" || o === "Home" || o === "End") && setTimeout(I, 0);
507
- },
508
- [
509
- d,
510
- x.length,
511
- i,
512
- P,
513
- I
514
- ]
515
- ), _ = S(
516
- (s) => {
517
- const { key: o } = s;
518
- (o === "ArrowLeft" || o === "ArrowRight" || o === "Home" || o === "End") && I();
519
- },
520
- [I]
521
- ), R = S(() => {
522
- i({
523
- isVisible: !0,
524
- highlightedIndex: 0
525
- });
526
- }, [i]), D = S(
527
- (s) => {
528
- var M;
529
- const o = ((M = h.current) == null ? void 0 : M.selectionStart) || s.length, { context: N, token: A } = j(
530
- s,
531
- o
532
- );
533
- p(N), m(A), n(s), i({
534
- highlightedIndex: 0,
535
- isVisible: !$(s, o),
536
- showingMore: !1,
537
- cursorPosition: o
538
- });
539
- },
540
- [p, m, n, i]
541
- ), Y = S(() => {
542
- setTimeout(I, 0);
543
- }, [I]), J = S(() => {
544
- i({
545
- isVisible: !1,
546
- highlightedIndex: -1
547
- });
548
- }, [i]), W = S(
549
- (s) => {
550
- i({ highlightedIndex: s });
551
- },
552
- [i]
553
- );
554
- return G(() => (document.addEventListener("mousedown", y), () => document.removeEventListener("mousedown", y)), [y]), /* @__PURE__ */ w(
555
- "div",
556
- {
557
- className: L("p-query-input", t),
558
- "data-testid": "p-query-input",
559
- ref: f,
560
- ...C,
561
- children: [
562
- /* @__PURE__ */ a(
563
- z,
564
- {
565
- disabled: l,
566
- placeholder: v,
567
- value: e,
568
- externallyControlled: !0,
569
- autoComplete: "off",
570
- id: "query-input",
571
- name: "query-input",
572
- ref: h,
573
- onFocus: R,
574
- onChange: D,
575
- onKeyDown: F,
576
- onKeyUp: _,
577
- onClear: J,
578
- onClick: Y,
579
- "aria-disabled": l,
580
- "aria-expanded": d.isVisible,
581
- "aria-haspopup": "listbox",
582
- "aria-owns": "query-suggestions"
583
- }
584
- ),
585
- d.isVisible && u.length > 0 && /* @__PURE__ */ a(
586
- "ul",
587
- {
588
- className: "p-query-input__list",
589
- ref: E,
590
- id: "query-suggestions",
591
- role: "listbox",
592
- "aria-label": "Search suggestions",
593
- children: g ? /* @__PURE__ */ a("div", { className: "p-query-input__loading", children: /* @__PURE__ */ a(H, { text: "Loading..." }) }) : x.map((s, o) => /* @__PURE__ */ w(
594
- "li",
595
- {
596
- className: L("p-query-input__item", {
597
- highlight: o === d.highlightedIndex
598
- }),
599
- onClick: () => P(o),
600
- onKeyDown: () => P(o),
601
- onMouseEnter: () => W(o),
602
- role: "option",
603
- "aria-selected": o === d.highlightedIndex,
604
- tabIndex: -1,
605
- children: [
606
- /* @__PURE__ */ w("span", { className: "p-query-input__item-label", children: [
607
- /* @__PURE__ */ a(
608
- "span",
609
- {
610
- className: L({
611
- "u-text--muted": s.type === "more"
612
- }),
613
- children: s.value
614
- }
615
- ),
616
- s.type === "filter" && /* @__PURE__ */ a("span", { className: "u-text--muted", children: ":()" })
617
- ] }),
618
- s.type !== "more" && /* @__PURE__ */ a("span", { className: "u-text--muted u-align-text--right", children: s.type })
619
- ]
620
- },
621
- `${s.value}-${o}`
622
- ))
623
- }
624
- )
625
- ]
626
- }
627
- );
628
- }, xe = ({ value: t, unit: l }, {
629
- binary: e = !1,
630
- convertTo: n,
631
- decimals: r = 2,
632
- roundFunc: p = "round"
633
- } = {}) => {
634
- const m = t < 0, u = Math.abs(t);
635
- if (u === 0)
636
- return { value: 0, unit: n || "B" };
637
- const g = e ? 1024 : 1e3, v = e ? ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], C = v.findIndex((h) => h === l) || 0, d = u * Math.pow(g, C), b = n ? v.findIndex((h) => h === n) : Math.floor(Math.log(d) / Math.log(g));
638
- let f = d / Math.pow(g, b);
639
- if (f % 1 !== 0) {
640
- const h = Math.pow(10, r);
641
- f = Math[p](f * h) / h;
642
- }
643
- return {
644
- value: m ? -f : f,
645
- unit: v[b]
646
- };
647
- };
648
- export {
649
- Re as ContentSection,
650
- Ae as DynamicTable,
651
- Ne as ExternalLink,
652
- Ie as FileUpload,
653
- Me as FormSection,
654
- Le as GenericTable,
655
- Fe as InputGroup,
656
- De as Layout,
657
- Be as MainToolbar,
658
- Oe as Meter,
659
- Ce as MultiSelect,
660
- he as MultiSelectDropdown,
661
- Ue as Navigation,
662
- je as NavigationBar,
663
- we as NestedFormGroup,
664
- Ve as Pagination,
665
- Te as PaginationContainer,
666
- qe as Placeholder,
667
- ce as ProgressIndicator,
668
- Ee as QueryInput,
669
- Ge as SidePanel,
670
- Ke as SidePanelContextProvider,
671
- Se as Stepper,
672
- Qe as TableCaption,
673
- $e as defaultFilledColors,
674
- xe as formatBytes,
675
- He as meterColor,
676
- ze as testIds,
677
- Ze as useSidePanel
678
- };
1
+ import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, k as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T, v as E, w as D, x as O, y as k } from "../lib-BEVV6FLF.mjs";
2
+ export { t as ContentSection, c as DynamicTable, r as ExternalLink, u as FileUpload, a as FormSection, S as GenericTable, O as InputGroup, p as Layout, m as MainToolbar, n as Meter, b as MultiSelect, C as MultiSelectDropdown, x as Navigation, v as NavigationBar, f as NestedFormGroup, T as Pagination, d as PaginationContainer, D as Placeholder, o as ProgressIndicator, y as QueryInput, E as SidePanel, k as SidePanelContextProvider, _ as Stepper, h as TableCaption, i as defaultFilledColors, w as formatBytes, s as lazyLoadSidePanel, g as meterColor, e as testIds, l as useSidePanel };
@@ -15,15 +15,15 @@ export type DynamicTableProps = PropsWithChildren<{
15
15
  * @returns
16
16
  */
17
17
  export declare const DynamicTable: {
18
- ({ className, children, variant, ...props }: DynamicTableProps): import("react/jsx-runtime").JSX.Element;
19
- Body: ({ className, children, style, ...props }: DynamicTableBodyProps) => import("react/jsx-runtime").JSX.Element;
18
+ ({ className, children, variant, ...props }: DynamicTableProps): import("react").JSX.Element;
19
+ Body: ({ className, children, style, ...props }: DynamicTableBodyProps) => import("react").JSX.Element;
20
20
  Loading: <TData extends RowData>({ className, table, }: {
21
21
  className?: string;
22
22
  table?: Table<TData>;
23
23
  placeholderLengths?: {
24
24
  [key: string]: string;
25
25
  };
26
- }) => import("react/jsx-runtime").JSX.Element;
26
+ }) => import("react").JSX.Element;
27
27
  };
28
28
  interface DynamicTableBodyProps extends AriaAttributes {
29
29
  className?: string;
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { DynamicTable } from './DynamicTable';
3
3
  declare const meta: Meta<typeof DynamicTable>;
4
4
  export default meta;