@tedi-design-system/react 19.1.0-rc.9 → 19.1.1

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 (131) hide show
  1. package/bundle-stats.html +1 -1
  2. package/community.cjs.js +1 -1
  3. package/community.es.js +215 -223
  4. package/component.manifest.json +63 -20
  5. package/external/@floating-ui/core/dist/floating-ui.core.es.js +1 -1
  6. package/external/@floating-ui/dom/dist/floating-ui.dom.es.js +2 -2
  7. package/external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js +5 -5
  8. package/external/@mui/x-date-pickers/DatePicker/shared.es.js +1 -1
  9. package/external/@mui/x-date-pickers/DateTimePicker/shared.es.js +1 -1
  10. package/index.css +1 -1
  11. package/package.json +2 -2
  12. package/src/community/components/accordion/accordion.cjs.js +1 -1
  13. package/src/community/components/accordion/accordion.es.js +14 -9
  14. package/src/community/components/card/card-notification/card-notification.cjs.js +1 -1
  15. package/src/community/components/card/card-notification/card-notification.es.js +10 -8
  16. package/src/community/components/dock-panel/dock-panel.cjs.js +2 -0
  17. package/src/community/components/dock-panel/dock-panel.d.ts +110 -0
  18. package/src/community/components/dock-panel/dock-panel.es.js +138 -0
  19. package/src/community/components/dock-panel/dock-panel.module.scss.cjs.js +1 -0
  20. package/src/community/components/dock-panel/dock-panel.module.scss.es.js +18 -0
  21. package/src/community/components/dropdown/dropdown.cjs.js +1 -1
  22. package/src/community/components/dropdown/dropdown.es.js +34 -32
  23. package/src/community/components/form/category-search/category-search.cjs.js +1 -0
  24. package/src/community/components/form/category-search/category-search.d.ts +9 -0
  25. package/src/community/components/form/category-search/category-search.es.js +297 -0
  26. package/src/community/components/form/category-search/category-search.module.scss.cjs.js +1 -0
  27. package/src/community/components/form/category-search/category-search.module.scss.es.js +21 -0
  28. package/src/community/components/form/category-search/category-search.types.d.ts +162 -0
  29. package/src/community/components/form/category-search/define-category-search-category.cjs.js +1 -0
  30. package/src/community/components/form/category-search/define-category-search-category.d.ts +7 -0
  31. package/src/community/components/form/category-search/define-category-search-category.es.js +25 -0
  32. package/src/community/components/form/category-search/index.d.ts +3 -0
  33. package/src/community/components/form/category-search/use-category-search.cjs.js +1 -0
  34. package/src/community/components/form/category-search/use-category-search.d.ts +17 -0
  35. package/src/community/components/form/category-search/use-category-search.es.js +64 -0
  36. package/src/community/components/form/file-upload/file-upload.cjs.js +1 -1
  37. package/src/community/components/form/file-upload/file-upload.es.js +43 -41
  38. package/src/community/components/form/pickers/calendar/calendar.cjs.js +1 -1
  39. package/src/community/components/form/pickers/calendar/calendar.es.js +41 -39
  40. package/src/community/components/form/pickers/timepicker/timepicker.cjs.js +1 -1
  41. package/src/community/components/form/pickers/timepicker/timepicker.es.js +33 -31
  42. package/src/community/components/form/toggle/toggle.cjs.js +1 -1
  43. package/src/community/components/form/toggle/toggle.es.js +30 -28
  44. package/src/community/components/map-components/base-map-selection/base-map-selection.cjs.js +1 -1
  45. package/src/community/components/map-components/base-map-selection/base-map-selection.es.js +19 -19
  46. package/src/community/components/map-components/carousel/carousel.cjs.js +1 -1
  47. package/src/community/components/map-components/carousel/carousel.es.js +19 -17
  48. package/src/community/components/map-components/map-button/map-button.cjs.js +1 -1
  49. package/src/community/components/map-components/map-button/map-button.d.ts +10 -1
  50. package/src/community/components/map-components/map-button/map-button.es.js +31 -29
  51. package/src/community/components/status/status.cjs.js +1 -1
  52. package/src/community/components/status/status.es.js +14 -12
  53. package/src/community/components/stepper/stepper.cjs.js +1 -1
  54. package/src/community/components/stepper/stepper.es.js +33 -31
  55. package/src/community/components/table/table.cjs.js +1 -1
  56. package/src/community/components/table/table.es.js +9 -9
  57. package/src/community/components/table-of-contents/table-of-contents.cjs.js +1 -1
  58. package/src/community/components/table-of-contents/table-of-contents.es.js +21 -19
  59. package/src/community/components/tabs/tabs/tabs.cjs.js +1 -1
  60. package/src/community/components/tabs/tabs/tabs.es.js +29 -27
  61. package/src/community/components/vertical-stepper/vertical-stepper.cjs.js +1 -1
  62. package/src/community/components/vertical-stepper/vertical-stepper.es.js +8 -6
  63. package/src/community/deprecated-exports.cjs.js +1 -0
  64. package/src/community/deprecated-exports.d.ts +19 -0
  65. package/src/community/deprecated-exports.es.js +112 -0
  66. package/src/community/index.d.ts +3 -0
  67. package/src/tedi/components/content/card/card.d.ts +4 -0
  68. package/src/tedi/components/content/carousel/carousel.cjs.js +1 -1
  69. package/src/tedi/components/content/carousel/carousel.d.ts +5 -0
  70. package/src/tedi/components/content/carousel/carousel.es.js +20 -20
  71. package/src/tedi/components/content/carousel/use-carousel.cjs.js +1 -1
  72. package/src/tedi/components/content/carousel/use-carousel.d.ts +1 -1
  73. package/src/tedi/components/content/carousel/use-carousel.es.js +127 -127
  74. package/src/tedi/components/content/table-card/index.d.ts +1 -0
  75. package/src/tedi/components/content/table-card/table-card.cjs.js +1 -0
  76. package/src/tedi/components/content/table-card/table-card.d.ts +131 -0
  77. package/src/tedi/components/content/table-card/table-card.es.js +206 -0
  78. package/src/tedi/components/content/table-card/table-card.module.scss.cjs.js +1 -0
  79. package/src/tedi/components/content/table-card/table-card.module.scss.es.js +18 -0
  80. package/src/tedi/components/content/text-group/text-group-list/text-group-list.cjs.js +1 -1
  81. package/src/tedi/components/content/text-group/text-group-list/text-group-list.d.ts +42 -0
  82. package/src/tedi/components/content/text-group/text-group-list/text-group-list.es.js +41 -23
  83. package/src/tedi/components/content/text-group/text-group.cjs.js +1 -1
  84. package/src/tedi/components/content/text-group/text-group.d.ts +10 -0
  85. package/src/tedi/components/content/text-group/text-group.es.js +14 -13
  86. package/src/tedi/components/content/text-group/text-group.module.scss.cjs.js +1 -1
  87. package/src/tedi/components/content/text-group/text-group.module.scss.es.js +5 -1
  88. package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -1
  89. package/src/tedi/components/form/date-field/date-field-helpers.d.ts +12 -19
  90. package/src/tedi/components/form/date-field/date-field-helpers.es.js +27 -21
  91. package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
  92. package/src/tedi/components/form/date-field/date-field.d.ts +1 -1
  93. package/src/tedi/components/form/date-field/date-field.es.js +169 -164
  94. package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
  95. package/src/tedi/components/form/date-time-field/date-time-field.es.js +181 -176
  96. package/src/tedi/components/form/search/index.d.ts +1 -0
  97. package/src/tedi/components/form/search/search.cjs.js +1 -1
  98. package/src/tedi/components/form/search/search.d.ts +92 -1
  99. package/src/tedi/components/form/search/search.es.js +265 -69
  100. package/src/tedi/components/form/search/search.module.scss.cjs.js +1 -1
  101. package/src/tedi/components/form/search/search.module.scss.es.js +9 -1
  102. package/src/tedi/components/form/slider/slider.cjs.js +1 -1
  103. package/src/tedi/components/form/slider/slider.es.js +38 -38
  104. package/src/tedi/components/form/slider/slider.module.scss.cjs.js +1 -1
  105. package/src/tedi/components/form/slider/slider.module.scss.es.js +0 -1
  106. package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
  107. package/src/tedi/components/form/textfield/textfield.es.js +21 -21
  108. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.cjs.js +1 -1
  109. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.d.ts +1 -1
  110. package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.es.js +28 -27
  111. package/src/tedi/components/layout/mobile-nav/mobile-nav.cjs.js +1 -1
  112. package/src/tedi/components/layout/mobile-nav/mobile-nav.d.ts +1 -1
  113. package/src/tedi/components/layout/mobile-nav/mobile-nav.es.js +124 -92
  114. package/src/tedi/components/layout/sidenav/sidenav.module.scss.cjs.js +1 -1
  115. package/src/tedi/components/layout/sidenav/sidenav.module.scss.es.js +1 -0
  116. package/src/tedi/components/navigation/tabs/tabs-helpers.cjs.js +1 -1
  117. package/src/tedi/components/navigation/tabs/tabs-helpers.d.ts +5 -0
  118. package/src/tedi/components/navigation/tabs/tabs-helpers.es.js +7 -4
  119. package/src/tedi/components/navigation/tabs/tabs-trigger/tabs-trigger.cjs.js +1 -1
  120. package/src/tedi/components/navigation/tabs/tabs-trigger/tabs-trigger.es.js +17 -17
  121. package/src/tedi/components/overlays/dropdown/dropdown.cjs.js +1 -1
  122. package/src/tedi/components/overlays/dropdown/dropdown.es.js +8 -6
  123. package/src/tedi/helpers/warn-deprecated/warn-deprecated.cjs.js +1 -0
  124. package/src/tedi/helpers/warn-deprecated/warn-deprecated.d.ts +12 -0
  125. package/src/tedi/helpers/warn-deprecated/warn-deprecated.es.js +11 -0
  126. package/src/tedi/index.d.ts +2 -1
  127. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  128. package/src/tedi/providers/label-provider/labels-map.d.ts +30 -2
  129. package/src/tedi/providers/label-provider/labels-map.es.js +29 -1
  130. package/tedi.cjs.js +1 -1
  131. package/tedi.es.js +326 -324
@@ -0,0 +1,297 @@
1
+ import { jsx as t, jsxs as u, Fragment as H } from "react/jsx-runtime";
2
+ import { useFloating as Ce } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
3
+ import q from "../../../../../external/classnames/index.es.js";
4
+ import { forwardRef as Se, useId as be, useState as j, useRef as R, useImperativeHandle as xe, useEffect as ee } from "react";
5
+ import { Icon as Re } from "../../../../tedi/components/base/icon/icon.es.js";
6
+ import { Button as m } from "../../../../tedi/components/buttons/button/button.es.js";
7
+ import { InputGroup as B } from "../../../../tedi/components/form/input-group/input-group.es.js";
8
+ import { Search as ke } from "../../../../tedi/components/form/search/search.es.js";
9
+ import { Dropdown as k } from "../../../../tedi/components/overlays/dropdown/dropdown.es.js";
10
+ import n from "./category-search.module.scss.es.js";
11
+ import { useCategorySearch as Fe } from "./use-category-search.es.js";
12
+ import { autoUpdate as Ee } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
13
+ import { shift as $e, size as Te } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
14
+ const De = {
15
+ category: "Search category",
16
+ searchInput: "Search",
17
+ search: "Search",
18
+ clear: "Clear",
19
+ close: "Close",
20
+ filter: "Filter",
21
+ cancelFilter: "Clear filter",
22
+ showFilters: "Show filters",
23
+ showResults: "Show results",
24
+ results: "Results",
25
+ loading: "Searching…",
26
+ noResults: "No results found.",
27
+ searchError: "The search failed. Please try again.",
28
+ filtersChanged: "Filters edited since searching.",
29
+ resultCount: (p) => `${p} results`
30
+ }, Le = Se(
31
+ ({
32
+ categories: p,
33
+ id: re,
34
+ categoryId: K,
35
+ defaultCategoryId: te,
36
+ onCategoryChange: F,
37
+ open: z,
38
+ defaultOpen: le = !1,
39
+ onOpenChange: E,
40
+ disabled: s = !1,
41
+ size: a = "default",
42
+ labels: ie,
43
+ panelWidth: $ = "100%",
44
+ maxPanelHeight: T = "min(32rem, 70dvh)",
45
+ className: se
46
+ }, ne) => {
47
+ var X, Y, Z;
48
+ const ae = be(), y = re ?? `category-search-${ae}`, D = `${y}-panel`, l = { ...De, ...ie }, [oe, ce] = j(te ?? ((X = p[0]) == null ? void 0 : X.id)), [de, ue] = j(le), { states: fe, changeDraft: L, search: G, clear: he, cancel: O } = Fe(p), [pe, _] = j(), S = R(null), Q = R(null), U = R(null), w = R(!1), me = K ?? oe, e = p.find((r) => r.id === me) ?? p[0], i = e ? fe.get(e.id) : void 0, h = i == null ? void 0 : i.completedSearch, P = (i == null ? void 0 : i.status) === "loading", b = (i == null ? void 0 : i.status) === "error", N = !!(h || P || b), c = (e == null ? void 0 : e.mode) === "search", ge = z ?? de;
49
+ let f = "closed";
50
+ ge && e && i && (c ? i.draft && N && (f = "results") : N && pe !== e.id ? f = "results" : f = "filters");
51
+ const g = f !== "closed", v = h ? ((Y = e == null ? void 0 : e.getResultCount) == null ? void 0 : Y.call(e, h.result)) ?? (Array.isArray(h.result) ? h.result.length : void 0) : void 0, { refs: x, floatingStyles: ve } = Ce({
52
+ open: g,
53
+ placement: "bottom-start",
54
+ whileElementsMounted: Ee,
55
+ middleware: [
56
+ c && $e(),
57
+ Te({
58
+ apply({ rects: r, availableWidth: d, elements: o }) {
59
+ c ? (o.floating.style.width = "", o.floating.style.maxWidth = `${Math.max(0, d)}px`) : (o.floating.style.width = `${r.reference.width}px`, o.floating.style.maxWidth = "");
60
+ }
61
+ })
62
+ ]
63
+ });
64
+ let V = l.filter, J = !1;
65
+ f === "results" ? V = l.showFilters : N && (V = l.showResults, J = !0), xe(ne, () => S.current), ee(() => {
66
+ _(void 0);
67
+ }, [e == null ? void 0 : e.id]), ee(() => {
68
+ var d, o;
69
+ if (f === "closed" || !w.current) return;
70
+ w.current = !1;
71
+ const r = document.activeElement;
72
+ (r === document.body || r && ((d = S.current) != null && d.contains(r))) && ((o = x.floating.current) == null || o.focus());
73
+ }, [f, e == null ? void 0 : e.id, i, x.floating]);
74
+ function I(r) {
75
+ z === void 0 && ue(r), E == null || E(r);
76
+ }
77
+ function ye(r) {
78
+ s || (K === void 0 && ce(r.id), F == null || F(r.id), I(!0));
79
+ }
80
+ function W() {
81
+ var r, d, o;
82
+ c ? (d = (r = U.current) == null ? void 0 : r.input) == null || d.focus() : (o = Q.current) == null || o.focus();
83
+ }
84
+ function C() {
85
+ w.current = !1, I(!1), W();
86
+ }
87
+ function A() {
88
+ !e || s || (he(e), _(void 0), w.current = !1, I(!c), W());
89
+ }
90
+ function _e(r) {
91
+ if (!(!e || s)) {
92
+ if (L(e.id, r), w.current = !1, I(r.length > 0), !r) {
93
+ O(e.id);
94
+ return;
95
+ }
96
+ G(e, r);
97
+ }
98
+ }
99
+ function we(r) {
100
+ !e || !c || s || (O(e.id), L(e.id, r), C());
101
+ }
102
+ function M() {
103
+ !e || !i || s || c && !i.draft || (_(void 0), w.current = !0, I(!0), G(e, i.draft));
104
+ }
105
+ function Ie() {
106
+ f === "closed" ? (_(void 0), I(!0)) : f === "results" ? _(e == null ? void 0 : e.id) : N ? _(void 0) : C();
107
+ }
108
+ function Ne(r) {
109
+ var o;
110
+ if (r.key !== "Escape" || r.defaultPrevented || !g) return;
111
+ const d = r.target;
112
+ (o = S.current) != null && o.contains(d) && (d.closest('[role="combobox"][aria-expanded="true"]') || (r.stopPropagation(), r.preventDefault(), C()));
113
+ }
114
+ return /* @__PURE__ */ t(
115
+ "div",
116
+ {
117
+ id: y,
118
+ ref: S,
119
+ className: q(n["tedi-category-search"], n[`tedi-category-search--${a}`], se),
120
+ style: {
121
+ "--category-search-panel-width": typeof $ == "number" ? `${$}px` : $,
122
+ "--category-search-panel-max-height": typeof T == "number" ? `${T}px` : T
123
+ },
124
+ onKeyDown: Ne,
125
+ children: e && i && /* @__PURE__ */ u(H, { children: [
126
+ /* @__PURE__ */ t("div", { className: n["tedi-category-search__bar"], children: /* @__PURE__ */ u(
127
+ B,
128
+ {
129
+ id: `${y}-input`,
130
+ label: c ? l.searchInput : null,
131
+ hideLabel: !0,
132
+ disabled: s,
133
+ children: [
134
+ /* @__PURE__ */ t("div", { ref: x.setReference, className: n["tedi-category-search__main"], children: c ? /* @__PURE__ */ t(B.Input, { children: /* @__PURE__ */ t(
135
+ ke,
136
+ {
137
+ ref: U,
138
+ id: `${y}-input`,
139
+ name: `${y}-query`,
140
+ value: i.draft,
141
+ disabled: s,
142
+ size: a,
143
+ ariaLabel: e.label,
144
+ placeholder: e.placeholder,
145
+ onChange: _e,
146
+ onClear: A,
147
+ onSearch: M,
148
+ button: {
149
+ icon: "search",
150
+ size: a,
151
+ disabled: s,
152
+ "aria-label": l.search
153
+ },
154
+ input: { "aria-controls": g ? D : void 0 }
155
+ }
156
+ ) }) : /* @__PURE__ */ u("div", { className: n["tedi-category-search__actions"], children: [
157
+ /* @__PURE__ */ u(
158
+ m,
159
+ {
160
+ id: `${y}-input`,
161
+ ref: Q,
162
+ size: a,
163
+ visualType: "link",
164
+ iconLeft: "tune",
165
+ disabled: s,
166
+ "aria-expanded": g,
167
+ "aria-controls": g ? D : void 0,
168
+ onClick: Ie,
169
+ children: [
170
+ V,
171
+ J && v !== void 0 ? ` (${v})` : ""
172
+ ]
173
+ }
174
+ ),
175
+ N && /* @__PURE__ */ t(
176
+ m,
177
+ {
178
+ size: a,
179
+ visualType: "link",
180
+ iconLeft: "close",
181
+ disabled: s,
182
+ onClick: A,
183
+ children: l.cancelFilter
184
+ }
185
+ )
186
+ ] }) }),
187
+ /* @__PURE__ */ t(B.Suffix, { className: n["tedi-category-search__suffix"], children: /* @__PURE__ */ u(
188
+ k,
189
+ {
190
+ defaultActiveIndex: p.indexOf(e),
191
+ modal: !1,
192
+ placement: "bottom-end",
193
+ className: q(n["tedi-category-search__menu"], n[`tedi-category-search__menu--${a}`]),
194
+ children: [
195
+ /* @__PURE__ */ t(k.Trigger, { children: /* @__PURE__ */ u(
196
+ m,
197
+ {
198
+ noStyle: !0,
199
+ size: a,
200
+ disabled: s,
201
+ "aria-label": `${l.category}: ${e.label}`,
202
+ children: [
203
+ /* @__PURE__ */ t("span", { className: n["tedi-category-search__category-label"], children: e.label }),
204
+ /* @__PURE__ */ t(Re, { name: "arrow_drop_down", color: "inherit" })
205
+ ]
206
+ }
207
+ ) }),
208
+ /* @__PURE__ */ t(k.Content, { children: p.map((r, d) => /* @__PURE__ */ t(
209
+ k.Item,
210
+ {
211
+ index: d,
212
+ className: n["tedi-category-search__menu-item"],
213
+ role: "menuitemradio",
214
+ "aria-checked": e.id === r.id,
215
+ active: e.id === r.id,
216
+ disabled: s,
217
+ onClick: () => ye(r),
218
+ children: r.label
219
+ },
220
+ r.id
221
+ )) })
222
+ ]
223
+ }
224
+ ) })
225
+ ]
226
+ }
227
+ ) }),
228
+ g && /* @__PURE__ */ t(
229
+ "section",
230
+ {
231
+ id: D,
232
+ ref: x.setFloating,
233
+ style: ve,
234
+ tabIndex: -1,
235
+ "aria-label": `${e.label}: ${f === "results" ? l.results : l.filter}`,
236
+ className: n["tedi-category-search__panel"],
237
+ children: f === "filters" ? /* @__PURE__ */ u(
238
+ "form",
239
+ {
240
+ onSubmit: (r) => {
241
+ r.preventDefault(), r.stopPropagation(), M();
242
+ },
243
+ children: [
244
+ /* @__PURE__ */ u("fieldset", { disabled: s, className: n["tedi-category-search__fields"], children: [
245
+ /* @__PURE__ */ t("legend", { className: n["tedi-category-search__sr-only"], children: e.label }),
246
+ (Z = e.renderFilters) == null ? void 0 : Z.call(e, {
247
+ values: i.draft,
248
+ onChange: (r) => L(e.id, r),
249
+ disabled: s,
250
+ size: a
251
+ })
252
+ ] }),
253
+ /* @__PURE__ */ u("div", { className: n["tedi-category-search__footer"], children: [
254
+ /* @__PURE__ */ t(m, { size: a, visualType: "link", onClick: C, children: l.close }),
255
+ /* @__PURE__ */ t(m, { size: a, visualType: "secondary", disabled: s, onClick: A, children: l.clear }),
256
+ /* @__PURE__ */ t(m, { size: a, type: "submit", formNoValidate: !1, disabled: s, children: l.search })
257
+ ] })
258
+ ]
259
+ }
260
+ ) : /* @__PURE__ */ u(H, { children: [
261
+ P && /* @__PURE__ */ t("p", { role: "status", children: l.loading }),
262
+ b && /* @__PURE__ */ t("p", { role: "alert", children: l.searchError }),
263
+ h && /* @__PURE__ */ u("div", { "aria-label": l.results, children: [
264
+ !c && i.draft !== h.input && /* @__PURE__ */ t("p", { children: l.filtersChanged }),
265
+ !c && v !== void 0 && /* @__PURE__ */ t("p", { children: l.resultCount(v) }),
266
+ v === 0 ? /* @__PURE__ */ t("p", { children: l.noResults }) : e.renderResults({
267
+ value: h.input,
268
+ result: h.result,
269
+ selectResult: we
270
+ })
271
+ ] }),
272
+ /* @__PURE__ */ u("div", { className: n["tedi-category-search__footer"], children: [
273
+ /* @__PURE__ */ t(m, { size: a, visualType: "link", onClick: C, children: l.close }),
274
+ c && b && /* @__PURE__ */ t(m, { size: a, disabled: s, onClick: M, children: l.search })
275
+ ] })
276
+ ] })
277
+ }
278
+ ),
279
+ /* @__PURE__ */ t(
280
+ "span",
281
+ {
282
+ className: n["tedi-category-search__sr-only"],
283
+ role: "status",
284
+ "aria-live": "polite",
285
+ "aria-atomic": "true",
286
+ children: g && !P && !b && h ? `${e.label}: ${v !== void 0 ? l.resultCount(v) : l.results}` : ""
287
+ }
288
+ )
289
+ ] })
290
+ }
291
+ );
292
+ }
293
+ );
294
+ Le.displayName = "CategorySearch";
295
+ export {
296
+ Le as CategorySearch
297
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-category-search":"tedi-category-search-c689f0ce","tedi-category-search__bar":"tedi-category-search__bar-bee91c0f","tedi-category-search__main":"tedi-category-search__main-9130cfc8","tedi-category-search__actions":"tedi-category-search__actions-9cabc74c","tedi-category-search__suffix":"tedi-category-search__suffix-c0bbe721","tedi-category-search__category-label":"tedi-category-search__category-label-49a8230f","tedi-category-search--small":"tedi-category-search--small-8c067c1c","tedi-category-search--large":"tedi-category-search--large-1b4ac54d","tedi-category-search__menu":"tedi-category-search__menu-9d28f550","tedi-category-search__menu-item":"tedi-category-search__menu-item-16e86083","tedi-category-search__menu--small":"tedi-category-search__menu--small-6ed1c765","tedi-category-search__menu--large":"tedi-category-search__menu--large-e4805fc7","tedi-category-search__panel":"tedi-category-search__panel-d64a4656","tedi-category-search__fields":"tedi-category-search__fields-ddd8b4f9","tedi-category-search__footer":"tedi-category-search__footer-35ae925e","tedi-category-search__sr-only":"tedi-category-search__sr-only-c10e75fa"};exports.default=e;
@@ -0,0 +1,21 @@
1
+ const e = {
2
+ "tedi-category-search": "tedi-category-search-c689f0ce",
3
+ "tedi-category-search__bar": "tedi-category-search__bar-bee91c0f",
4
+ "tedi-category-search__main": "tedi-category-search__main-9130cfc8",
5
+ "tedi-category-search__actions": "tedi-category-search__actions-9cabc74c",
6
+ "tedi-category-search__suffix": "tedi-category-search__suffix-c0bbe721",
7
+ "tedi-category-search__category-label": "tedi-category-search__category-label-49a8230f",
8
+ "tedi-category-search--small": "tedi-category-search--small-8c067c1c",
9
+ "tedi-category-search--large": "tedi-category-search--large-1b4ac54d",
10
+ "tedi-category-search__menu": "tedi-category-search__menu-9d28f550",
11
+ "tedi-category-search__menu-item": "tedi-category-search__menu-item-16e86083",
12
+ "tedi-category-search__menu--small": "tedi-category-search__menu--small-6ed1c765",
13
+ "tedi-category-search__menu--large": "tedi-category-search__menu--large-e4805fc7",
14
+ "tedi-category-search__panel": "tedi-category-search__panel-d64a4656",
15
+ "tedi-category-search__fields": "tedi-category-search__fields-ddd8b4f9",
16
+ "tedi-category-search__footer": "tedi-category-search__footer-35ae925e",
17
+ "tedi-category-search__sr-only": "tedi-category-search__sr-only-c10e75fa"
18
+ };
19
+ export {
20
+ e as default
21
+ };
@@ -0,0 +1,162 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export type CategorySearchSize = 'small' | 'default' | 'large';
3
+ export interface CategorySearchRequestContext {
4
+ /** Aborted by a newer search, an empty query, selection, Clear, category removal, or unmount. */
5
+ signal: AbortSignal;
6
+ }
7
+ export interface CategorySearchFilterContext<Filters> {
8
+ /** Current draft. Treat nested values as immutable React state. */
9
+ values: Filters;
10
+ /**
11
+ * Replace edited filter objects, including changed nested objects; never mutate them.
12
+ * This preserves the submitted input associated with saved results.
13
+ */
14
+ onChange: (values: Filters) => void;
15
+ /** Whether the rendered fields should be disabled. */
16
+ disabled: boolean;
17
+ /** Resolved component size. Pass it to fields that support this size. */
18
+ size: CategorySearchSize;
19
+ }
20
+ export interface CategorySearchFilterDefinition<Filters, Result> {
21
+ /** Stable and unique within one CategorySearch instance. */
22
+ id: string;
23
+ /** Category name shown in the selector and used to name the panel. */
24
+ label: string;
25
+ /** Display this category's custom filter form. */
26
+ mode: 'category';
27
+ /** Return a fresh value. Called when this category is added and whenever it is cleared. */
28
+ initialFilters: () => Filters;
29
+ /** Render fields only; CategorySearch provides the form and its action buttons. */
30
+ renderFilters: (context: CategorySearchFilterContext<Filters>) => ReactNode;
31
+ /** Search a submitted draft. Do not mutate filters; honor signal when supported. */
32
+ onSearch: (filters: Filters, context: CategorySearchRequestContext) => Result | Promise<Result>;
33
+ /** Render the last successful result alongside the filters that produced it. */
34
+ renderResults: (context: {
35
+ result: Result;
36
+ filters: Filters;
37
+ }) => ReactNode;
38
+ /** Supply this when the result is paginated or is not a plain array. */
39
+ getResultCount?: (result: Result) => number;
40
+ }
41
+ export interface CategorySearchTextDefinition<Result> {
42
+ /** Stable and unique within one CategorySearch instance. */
43
+ id: string;
44
+ /** Category name shown in the selector and used to name the panel. */
45
+ label: string;
46
+ /** Display the standard text search field. */
47
+ mode: 'search';
48
+ /** Initial query restored by clear; defaults to an empty string. */
49
+ initialQuery?: string;
50
+ /** Search input placeholder. The hidden input label comes from labels.searchInput. */
51
+ placeholder?: string;
52
+ /** Search on each non-empty text change and explicit submission; honor signal when supported. */
53
+ onSearch: (query: string, context: CategorySearchRequestContext) => Result | Promise<Result>;
54
+ /** Render the last successful result alongside the query that produced it. */
55
+ renderResults: (context: {
56
+ result: Result;
57
+ query: string;
58
+ /** Put a result label in the input, close the panel, and cancel any pending lookup. */
59
+ selectResult: (text: string) => void;
60
+ }) => ReactNode;
61
+ /** Supply this when the result is paginated or is not a plain array. */
62
+ getResultCount?: (result: Result) => number;
63
+ }
64
+ /**
65
+ * Common shape for storing different categories in one array.
66
+ * Use defineCategorySearchCategory to keep each category's own filter and result types.
67
+ */
68
+ export interface CategorySearchCategory {
69
+ /** Stable category identity. */
70
+ id: string;
71
+ /** User-facing category name. */
72
+ label: string;
73
+ /** Select the standard search field or a custom filter form. */
74
+ mode: 'search' | 'category';
75
+ /** Optional placeholder for a standard search field. */
76
+ placeholder?: string;
77
+ /** @internal Create an initial or reset draft. */
78
+ initialValue: () => unknown;
79
+ /** @internal Render the normalized category filter fields. */
80
+ renderFilters?: (context: CategorySearchFilterContext<unknown>) => ReactNode;
81
+ /** @internal Execute a search with the normalized submitted draft. */
82
+ onSearch: (value: unknown, context: CategorySearchRequestContext) => unknown | Promise<unknown>;
83
+ /** @internal Render completed results and their normalized submitted draft. */
84
+ renderResults: (context: {
85
+ result: unknown;
86
+ value: unknown;
87
+ selectResult: (text: string) => void;
88
+ }) => ReactNode;
89
+ /** @internal Return the number of matching results for the summary. */
90
+ getResultCount?: (result: unknown) => number;
91
+ }
92
+ export interface CategorySearchLabels {
93
+ /** Accessible category selector label. */
94
+ category: string;
95
+ /** Search submission button label. */
96
+ search: string;
97
+ /** Hidden label for the standard text search input. */
98
+ searchInput: string;
99
+ /** Clear the current category action label. */
100
+ clear: string;
101
+ /** Close the panel action label. */
102
+ close: string;
103
+ /** Category filter submission button label. */
104
+ filter: string;
105
+ /** Reset the current category filter action label. */
106
+ cancelFilter: string;
107
+ /** Action label for opening the filter fields. */
108
+ showFilters: string;
109
+ /** Action label for reopening remembered results. */
110
+ showResults: string;
111
+ /** Accessible results label and fallback announcement when no result count is available. */
112
+ results: string;
113
+ /** Status while a search is running. */
114
+ loading: string;
115
+ /** Message after a successful search with zero results. */
116
+ noResults: string;
117
+ /** Generic visible message after a failed search. */
118
+ searchError: string;
119
+ /**
120
+ * Notice when the filter object was replaced since the saved search was submitted.
121
+ * Returning fields to their earlier values does not remove it. Defaults to 'Filters edited since searching.'.
122
+ */
123
+ filtersChanged: string;
124
+ /** Format the number of matching results. */
125
+ resultCount: (count: number) => string;
126
+ }
127
+ export interface CategorySearchProps {
128
+ /** Optional stable DOM ID prefix; an ID is generated when omitted. */
129
+ id?: string;
130
+ /** Definitions with unique, stable IDs. Create these with defineCategorySearchCategory. */
131
+ categories: readonly CategorySearchCategory[];
132
+ /** Controlled selected category ID; use with onCategoryChange. */
133
+ categoryId?: string;
134
+ /** Initially selected ID. Defaults to the first category. */
135
+ defaultCategoryId?: string;
136
+ /** Called when the user selects another category. */
137
+ onCategoryChange?: (categoryId: string) => void;
138
+ /** Controlled panel visibility; use with onOpenChange. */
139
+ open?: boolean;
140
+ /**
141
+ * Initial non-modal panel visibility. Defaults to false.
142
+ * A text search also requires a non-empty input and a pending search, completed search, or error.
143
+ */
144
+ defaultOpen?: boolean;
145
+ /** Called when an interaction requests a visibility change. */
146
+ onOpenChange?: (open: boolean) => void;
147
+ /** Disable category selection, filter fields, and submission. Defaults to false. */
148
+ disabled?: boolean;
149
+ /** Size of the search field and buttons; also provided to renderFilters. Defaults to 'default'. */
150
+ size?: CategorySearchSize;
151
+ /** Override visible and accessible labels for localization. */
152
+ labels?: Partial<CategorySearchLabels>;
153
+ /**
154
+ * Text-results panel width. May exceed the search bar; constrained to the available viewport space.
155
+ * Defaults to '100%' of the whole search bar. Filter panels always match the bar excluding its category selector.
156
+ */
157
+ panelWidth?: CSSProperties['width'];
158
+ /** Maximum panel height; excess content scrolls. Defaults to 'min(32rem, 70dvh)'. */
159
+ maxPanelHeight?: CSSProperties['maxHeight'];
160
+ /** Additional CSS class applied to the outer component element. */
161
+ className?: string;
162
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){const a=e.getResultCount,s={id:e.id,label:e.label,getResultCount:a?r=>a(r):void 0};return e.mode==="search"?{...s,mode:"search",placeholder:e.placeholder,initialValue:()=>e.initialQuery??"",onSearch:(r,l)=>e.onSearch(r,l),renderResults:({result:r,value:l,selectResult:t})=>e.renderResults({result:r,query:l,selectResult:t})}:{...s,mode:"category",initialValue:e.initialFilters,renderFilters:({values:r,onChange:l,disabled:t,size:u})=>e.renderFilters({values:r,onChange:l,disabled:t,size:u}),onSearch:(r,l)=>e.onSearch(r,l),renderResults:({result:r,value:l})=>e.renderResults({result:r,filters:l})}}exports.defineCategorySearchCategory=c;
@@ -0,0 +1,7 @@
1
+ import { CategorySearchCategory, CategorySearchFilterDefinition, CategorySearchTextDefinition } from './category-search.types';
2
+ /**
3
+ * Gives text and filter categories a common internal format, while keeping each
4
+ * category's own input and result types checked at the application boundary.
5
+ */
6
+ export declare function defineCategorySearchCategory<Filters, Result>(definition: CategorySearchFilterDefinition<Filters, Result>): CategorySearchCategory;
7
+ export declare function defineCategorySearchCategory<Result>(definition: CategorySearchTextDefinition<Result>): CategorySearchCategory;
@@ -0,0 +1,25 @@
1
+ function c(e) {
2
+ const s = e.getResultCount, t = {
3
+ id: e.id,
4
+ label: e.label,
5
+ getResultCount: s ? (r) => s(r) : void 0
6
+ };
7
+ return e.mode === "search" ? {
8
+ ...t,
9
+ mode: "search",
10
+ placeholder: e.placeholder,
11
+ initialValue: () => e.initialQuery ?? "",
12
+ onSearch: (r, l) => e.onSearch(r, l),
13
+ renderResults: ({ result: r, value: l, selectResult: a }) => e.renderResults({ result: r, query: l, selectResult: a })
14
+ } : {
15
+ ...t,
16
+ mode: "category",
17
+ initialValue: e.initialFilters,
18
+ renderFilters: ({ values: r, onChange: l, disabled: a, size: u }) => e.renderFilters({ values: r, onChange: l, disabled: a, size: u }),
19
+ onSearch: (r, l) => e.onSearch(r, l),
20
+ renderResults: ({ result: r, value: l }) => e.renderResults({ result: r, filters: l })
21
+ };
22
+ }
23
+ export {
24
+ c as defineCategorySearchCategory
25
+ };
@@ -0,0 +1,3 @@
1
+ export * from './category-search';
2
+ export * from './category-search.types';
3
+ export { defineCategorySearchCategory } from './define-category-search-category';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react");function w(u){const[f,o]=i.useState(()=>new Map(u.map(t=>[t.id,{draft:t.initialValue(),status:"idle"}]))),s=i.useRef(new Map);i.useEffect(()=>{const t=s.current;return()=>{t.forEach(r=>r.abort()),t.clear()}},[]),i.useEffect(()=>{const t=new Set(u.map(r=>r.id));if(t.size!==u.length)throw new Error("CategorySearch category IDs must be unique.");s.current.forEach((r,e)=>{t.has(e)||(r.abort(),s.current.delete(e))}),o(r=>{const e=new Map(r);let n=!1;for(const a of u)e.has(a.id)||(e.set(a.id,{draft:a.initialValue(),status:"idle"}),n=!0);for(const a of r.keys())t.has(a)||(e.delete(a),n=!0);return n?e:r})},[u]);function c(t,r){o(e=>{const n=e.get(t);if(!n)return e;const a=new Map(e);return a.set(t,{...n,...r}),a})}function d(t,r){c(t,{draft:r})}function l(t){var r;(r=s.current.get(t))==null||r.abort(),s.current.delete(t),c(t,{status:"idle"})}function h(t){l(t.id),c(t.id,{draft:t.initialValue(),completedSearch:void 0,status:"idle"})}async function S(t,r){const e=t.id;l(e);const n=new AbortController;s.current.set(e,n),c(e,{status:"loading"});try{const a=await t.onSearch(r,{signal:n.signal});if(s.current.get(e)!==n)return;c(e,{completedSearch:{input:r,result:a},status:"idle"})}catch{if(s.current.get(e)!==n)return;c(e,{status:"error"})}finally{s.current.get(e)===n&&s.current.delete(e)}}return{states:f,changeDraft:d,search:S,clear:h,cancel:l}}exports.useCategorySearch=w;
@@ -0,0 +1,17 @@
1
+ import { CategorySearchCategory } from './category-search.types';
2
+ interface CategorySearchState {
3
+ draft: unknown;
4
+ completedSearch?: {
5
+ input: unknown;
6
+ result: unknown;
7
+ };
8
+ status: 'idle' | 'loading' | 'error';
9
+ }
10
+ export declare function useCategorySearch(categories: readonly CategorySearchCategory[]): {
11
+ states: ReadonlyMap<string, CategorySearchState>;
12
+ changeDraft: (categoryId: string, draft: unknown) => void;
13
+ search: (category: CategorySearchCategory, input: unknown) => Promise<void>;
14
+ clear: (category: CategorySearchCategory) => void;
15
+ cancel: (categoryId: string) => void;
16
+ };
17
+ export {};
@@ -0,0 +1,64 @@
1
+ import { useState as S, useRef as m, useEffect as o } from "react";
2
+ function b(u) {
3
+ const [f, l] = S(
4
+ () => new Map(u.map((t) => [t.id, { draft: t.initialValue(), status: "idle" }]))
5
+ ), s = m(/* @__PURE__ */ new Map());
6
+ o(() => {
7
+ const t = s.current;
8
+ return () => {
9
+ t.forEach((n) => n.abort()), t.clear();
10
+ };
11
+ }, []), o(() => {
12
+ const t = new Set(u.map((n) => n.id));
13
+ if (t.size !== u.length) throw new Error("CategorySearch category IDs must be unique.");
14
+ s.current.forEach((n, e) => {
15
+ t.has(e) || (n.abort(), s.current.delete(e));
16
+ }), l((n) => {
17
+ const e = new Map(n);
18
+ let r = !1;
19
+ for (const a of u)
20
+ e.has(a.id) || (e.set(a.id, { draft: a.initialValue(), status: "idle" }), r = !0);
21
+ for (const a of n.keys())
22
+ t.has(a) || (e.delete(a), r = !0);
23
+ return r ? e : n;
24
+ });
25
+ }, [u]);
26
+ function c(t, n) {
27
+ l((e) => {
28
+ const r = e.get(t);
29
+ if (!r) return e;
30
+ const a = new Map(e);
31
+ return a.set(t, { ...r, ...n }), a;
32
+ });
33
+ }
34
+ function d(t, n) {
35
+ c(t, { draft: n });
36
+ }
37
+ function i(t) {
38
+ var n;
39
+ (n = s.current.get(t)) == null || n.abort(), s.current.delete(t), c(t, { status: "idle" });
40
+ }
41
+ function h(t) {
42
+ i(t.id), c(t.id, { draft: t.initialValue(), completedSearch: void 0, status: "idle" });
43
+ }
44
+ async function w(t, n) {
45
+ const e = t.id;
46
+ i(e);
47
+ const r = new AbortController();
48
+ s.current.set(e, r), c(e, { status: "loading" });
49
+ try {
50
+ const a = await t.onSearch(n, { signal: r.signal });
51
+ if (s.current.get(e) !== r) return;
52
+ c(e, { completedSearch: { input: n, result: a }, status: "idle" });
53
+ } catch {
54
+ if (s.current.get(e) !== r) return;
55
+ c(e, { status: "error" });
56
+ } finally {
57
+ s.current.get(e) === r && s.current.delete(e);
58
+ }
59
+ }
60
+ return { states: f, changeDraft: d, search: w, clear: h, cancel: i };
61
+ }
62
+ export {
63
+ b as useCategorySearch
64
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),z=require("../../../../../external/classnames/index.cjs.js"),g=require("react"),A=require("../../../../tedi/components/form/feedback-text/feedback-text.cjs.js"),I=require("../../../../tedi/components/form/form-label/form-label.cjs.js"),O=require("../../../../tedi/components/tags/tag/tag.cjs.js"),D=require("../../button/button.cjs.js"),c=require("./file-upload.module.scss.cjs.js"),P=require("../../../../tedi/providers/label-provider/use-labels.cjs.js"),W=require("../../card/card.cjs.js"),Y=require("../../card/card-content/card-content.cjs.js"),G=require("../../../../tedi/components/layout/grid/row.cjs.js"),M=require("../../../../tedi/components/layout/grid/col.cjs.js"),J=({accept:a,maxSize:i},n)=>{if(!a&&!i)return;const s=[a&&`${n("file-upload.accept")} ${a.replaceAll(",",", ")}`,i&&`${n("file-upload.max-size")} ${i}MB`].filter(Boolean).join(". ");return s.length?{text:s}:void 0},K=(a,i)=>{const n=a.reduce((s,{type:r,file:p})=>(s[r].push(p.name),s),{extension:[],size:[]});return Object.entries(n).filter(([s,r])=>r.length).map(([s,r])=>{const p=r.map(y=>`'${y}'`).join(", ");return i(`file-upload.${s}-rejected`,p)}).join(". ")},Q=a=>{const{getLabel:i}=P.useLabels(),{id:n,name:s,accept:r,multiple:p,onChange:o,className:y,defaultFiles:N,onDelete:F,files:f,readOnly:b,disabled:m=!1,maxSize:h,helper:d=J({accept:r,maxSize:h},i),...$}=a,q=d?(d==null?void 0:d.id)??`${n}-helper`:void 0,[k,L]=g.useState(!1),[_,T]=g.useState(N||[]),[C,w]=g.useState(),U=z.default(c.default["file-upload"],{[c.default["file-upload-disabled"]]:m}),B=e=>{var x;if(!r)return!0;const l=(r==null?void 0:r.replace(/,/g,"").split("."))||[],u=(x=e.name.split(".").pop())==null?void 0:x.toLowerCase();return!!u&&l.includes(u)},v=g.useMemo(()=>f&&o?f:_,[f,_,o]),H=e=>{if(e.target.files){const l=[],u=[...Array.from(e.target.files)].filter(j=>B(j)?!0:(l.push({type:"extension",file:j}),!1)).filter(j=>!h||j.size<=h*1048576?!0:(l.push({type:"size",file:j}),!1)),x=[...v,...u];typeof f>"u"&&T(x),o==null||o(x),e.target.value="",l.length?w({type:"error",text:K(l,i)}):w(void 0)}},R=e=>{const l=[...v].filter(u=>u!==e);F&&F(e),typeof f>"u"&&T(l),o==null||o(l)},S=(e,l)=>t.jsx("li",{children:t.jsx(O.Tag,{color:"secondary",onClose:!e.isLoading&&!m&&!b?()=>R(e):void 0,isLoading:e.isLoading,children:e.name})},l),E=()=>t.jsx("ul",{className:c.default["file-upload__items"],children:v.map((e,l)=>S(e,l))});return t.jsxs("div",{children:[t.jsx("div",{onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),className:c.default["file-upload__label-wrapper"],children:t.jsx(I.FormLabel,{id:n,...$,renderWithoutLabel:b,className:c.default["file-upload__label"]})}),b?E():t.jsx(W.Card,{padding:.5,background:m?"bg-disabled":void 0,className:c.default["file-upload__card"],children:t.jsx(Y.CardContent,{children:t.jsxs(G.Row,{gutterY:2,children:[t.jsx(M.Col,{children:E()}),t.jsx(M.Col,{xs:12,md:"auto",align:"center",children:t.jsxs("div",{className:U,children:[t.jsx("input",{id:n,type:"file",name:s,accept:r,onChange:H,multiple:p,disabled:m}),t.jsx(D.Button,{visualType:"link",iconLeft:"file_upload","aria-describedby":q,isActive:k,disabled:m,onClick:()=>{var e;return(e=document.getElementById(n))==null?void 0:e.click()},children:i("file-upload.add")})]})})]})})}),(C||d)&&t.jsx(A.FeedbackText,{...C||d,id:q})]})};exports.FileUpload=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),S=require("../../../../../external/classnames/index.cjs.js"),j=require("react"),z=require("../../../../tedi/components/form/feedback-text/feedback-text.cjs.js"),A=require("../../../../tedi/components/form/form-label/form-label.cjs.js"),I=require("../../../../tedi/components/tags/tag/tag.cjs.js"),O=require("../../../../tedi/helpers/warn-deprecated/warn-deprecated.cjs.js"),P=require("../../button/button.cjs.js"),c=require("./file-upload.module.scss.cjs.js"),W=require("../../../../tedi/providers/label-provider/use-labels.cjs.js"),Y=require("../../card/card.cjs.js"),G=require("../../card/card-content/card-content.cjs.js"),J=require("../../../../tedi/components/layout/grid/row.cjs.js"),E=require("../../../../tedi/components/layout/grid/col.cjs.js"),K=({accept:a,maxSize:i},n)=>{if(!a&&!i)return;const s=[a&&`${n("file-upload.accept")} ${a.replaceAll(",",", ")}`,i&&`${n("file-upload.max-size")} ${i}MB`].filter(Boolean).join(". ");return s.length?{text:s}:void 0},Q=(a,i)=>{const n=a.reduce((s,{type:r,file:p})=>(s[r].push(p.name),s),{extension:[],size:[]});return Object.entries(n).filter(([s,r])=>r.length).map(([s,r])=>{const p=r.map(F=>`'${F}'`).join(", ");return i(`file-upload.${s}-rejected`,p)}).join(". ")},V=a=>{O.warnDeprecated("Community FileUpload","Use `FileUpload` from `@tedi-design-system/react/tedi` instead.");const{getLabel:i}=W.useLabels(),{id:n,name:s,accept:r,multiple:p,onChange:o,className:F,defaultFiles:M,onDelete:v,files:f,readOnly:b,disabled:m=!1,maxSize:h,helper:d=K({accept:r,maxSize:h},i),...N}=a,q=d?(d==null?void 0:d.id)??`${n}-helper`:void 0,[$,L]=j.useState(!1),[_,w]=j.useState(M||[]),[C,T]=j.useState(),k=S.default(c.default["file-upload"],{[c.default["file-upload-disabled"]]:m}),B=e=>{var x;if(!r)return!0;const l=(r==null?void 0:r.replace(/,/g,"").split("."))||[],u=(x=e.name.split(".").pop())==null?void 0:x.toLowerCase();return!!u&&l.includes(u)},y=j.useMemo(()=>f&&o?f:_,[f,_,o]),H=e=>{if(e.target.files){const l=[],u=[...Array.from(e.target.files)].filter(g=>B(g)?!0:(l.push({type:"extension",file:g}),!1)).filter(g=>!h||g.size<=h*1048576?!0:(l.push({type:"size",file:g}),!1)),x=[...y,...u];typeof f>"u"&&w(x),o==null||o(x),e.target.value="",l.length?T({type:"error",text:Q(l,i)}):T(void 0)}},D=e=>{const l=[...y].filter(u=>u!==e);v&&v(e),typeof f>"u"&&w(l),o==null||o(l)},R=(e,l)=>t.jsx("li",{children:t.jsx(I.Tag,{color:"secondary",onClose:!e.isLoading&&!m&&!b?()=>D(e):void 0,isLoading:e.isLoading,children:e.name})},l),U=()=>t.jsx("ul",{className:c.default["file-upload__items"],children:y.map((e,l)=>R(e,l))});return t.jsxs("div",{children:[t.jsx("div",{onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),className:c.default["file-upload__label-wrapper"],children:t.jsx(A.FormLabel,{id:n,...N,renderWithoutLabel:b,className:c.default["file-upload__label"]})}),b?U():t.jsx(Y.Card,{padding:.5,background:m?"bg-disabled":void 0,className:c.default["file-upload__card"],children:t.jsx(G.CardContent,{children:t.jsxs(J.Row,{gutterY:2,children:[t.jsx(E.Col,{children:U()}),t.jsx(E.Col,{xs:12,md:"auto",align:"center",children:t.jsxs("div",{className:k,children:[t.jsx("input",{id:n,type:"file",name:s,accept:r,onChange:H,multiple:p,disabled:m}),t.jsx(P.Button,{visualType:"link",iconLeft:"file_upload","aria-describedby":q,isActive:$,disabled:m,onClick:()=>{var e;return(e=document.getElementById(n))==null?void 0:e.click()},children:i("file-upload.add")})]})})]})})}),(C||d)&&t.jsx(z.FeedbackText,{...C||d,id:q})]})};exports.FileUpload=V;