@alixpartners/ui-components 2.5.1 → 2.5.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.
@@ -1,11 +1,11 @@
1
1
  import { jsxs as m, jsx as o, Fragment as re } from "react/jsx-runtime";
2
2
  import { c as T } from "../../clsx-OuTLNxxd.js";
3
- import { useState as b, useEffect as ce, useMemo as H } from "react";
4
- import J from "../Button/Button.js";
3
+ import { useState as F, useEffect as ce, useMemo as J } from "react";
4
+ import v from "../Button/Button.js";
5
5
  import W from "../Icon/Icon.js";
6
6
  import le from "../Tooltip/Tooltip.js";
7
7
  import { R as de, T as se, P as ie, C as _e } from "../../index-DZ4Gof57.js";
8
- import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker___SxV3q", pe = "Datepicker-module__label___uPuKe", De = "Datepicker-module__labelText___BAflA", me = "Datepicker-module__required___cAVa1", he = "Datepicker-module__labelTooltipIcon___n2IvH", ye = "Datepicker-module__inputWrapper___aKtHi", ge = "Datepicker-module__inputIcon___OUb8V", fe = "Datepicker-module__inputText___rwYA-", ke = "Datepicker-module__placeholder___UVl-W", Me = "Datepicker-module__error___C5WX8", Ne = "Datepicker-module__calendarContainer___Bjfa8", Se = "Datepicker-module__calendarHeader___a7I0V", Te = "Datepicker-module__calendarDivider___DRk4M", Ae = "Datepicker-module__headerActions___AP324", be = "Datepicker-module__headerAction___nyMJF", Fe = "Datepicker-module__headerActionIcon___J8RC-", Ye = "Datepicker-module__headerLabel___IPAo-", we = "Datepicker-module__calendarBody___yaLJA", Oe = "Datepicker-module__weekdays___noAbQ", Ee = "Datepicker-module__weekday___0hrfJ", Ie = "Datepicker-module__grid___lJEHW", Ce = "Datepicker-module__gridMonths___n1wAM", Re = "Datepicker-module__gridYears___cI0YR", ze = "Datepicker-module__day___3XU9S", ve = "Datepicker-module__date___G2cRK", xe = "Datepicker-module__month___VKvm3", Pe = "Datepicker-module__year___9OzXM", Ve = "Datepicker-module__daySelected___DkZ5T", Be = "Datepicker-module__dayOutside___CXb-b", Le = "Datepicker-module__dayTodayCurrent___ocAqU", $e = "Datepicker-module__dayTodayDot___ZyD-l", He = "Datepicker-module__calendarFooter___sLvNP", Je = "Datepicker-module__calendarFooterSpacer___3IXgI", We = "Datepicker-module__todayButton___zl9VO", Xe = "Datepicker-module__helperRow___IKmCq", Ue = "Datepicker-module__helpText___g7zEx", qe = "Datepicker-module__errorText___7o5Rs", Ke = "Datepicker-module__disabled___Hlnlo", e = {
8
+ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker___SxV3q", pe = "Datepicker-module__label___uPuKe", De = "Datepicker-module__labelText___BAflA", me = "Datepicker-module__required___cAVa1", he = "Datepicker-module__labelTooltipIcon___n2IvH", ye = "Datepicker-module__inputWrapper___aKtHi", ge = "Datepicker-module__inputIcon___OUb8V", fe = "Datepicker-module__inputText___rwYA-", ke = "Datepicker-module__placeholder___UVl-W", Me = "Datepicker-module__error___C5WX8", Ne = "Datepicker-module__calendarContainer___Bjfa8", Se = "Datepicker-module__calendarHeader___a7I0V", Te = "Datepicker-module__calendarDivider___DRk4M", Ae = "Datepicker-module__headerActions___AP324", Fe = "Datepicker-module__headerAction___nyMJF", Ye = "Datepicker-module__headerActionIcon___J8RC-", be = "Datepicker-module__headerLabel___IPAo-", we = "Datepicker-module__calendarBody___yaLJA", Oe = "Datepicker-module__weekdays___noAbQ", Ee = "Datepicker-module__weekday___0hrfJ", Ie = "Datepicker-module__grid___lJEHW", Ce = "Datepicker-module__gridMonths___n1wAM", Re = "Datepicker-module__gridYears___cI0YR", ze = "Datepicker-module__day___3XU9S", ve = "Datepicker-module__date___G2cRK", xe = "Datepicker-module__month___VKvm3", Pe = "Datepicker-module__year___9OzXM", Ve = "Datepicker-module__daySelected___DkZ5T", Le = "Datepicker-module__dayOutside___CXb-b", $e = "Datepicker-module__dayTodayCurrent___ocAqU", Be = "Datepicker-module__dayTodayDot___ZyD-l", He = "Datepicker-module__calendarFooter___sLvNP", Je = "Datepicker-module__calendarFooterSpacer___3IXgI", We = "Datepicker-module__helperRow___IKmCq", Xe = "Datepicker-module__helpText___g7zEx", Ue = "Datepicker-module__errorText___7o5Rs", qe = "Datepicker-module__disabled___Hlnlo", e = {
9
9
  datepicker: ue,
10
10
  label: pe,
11
11
  labelText: De,
@@ -20,9 +20,9 @@ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker__
20
20
  calendarHeader: Se,
21
21
  calendarDivider: Te,
22
22
  headerActions: Ae,
23
- headerAction: be,
24
- headerActionIcon: Fe,
25
- headerLabel: Ye,
23
+ headerAction: Fe,
24
+ headerActionIcon: Ye,
25
+ headerLabel: be,
26
26
  calendarBody: we,
27
27
  weekdays: Oe,
28
28
  weekday: Ee,
@@ -34,17 +34,16 @@ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker__
34
34
  month: xe,
35
35
  year: Pe,
36
36
  daySelected: Ve,
37
- dayOutside: Be,
38
- dayTodayCurrent: Le,
39
- dayTodayDot: $e,
37
+ dayOutside: Le,
38
+ dayTodayCurrent: $e,
39
+ dayTodayDot: Be,
40
40
  calendarFooter: He,
41
41
  calendarFooterSpacer: Je,
42
- todayButton: We,
43
- helperRow: Xe,
44
- helpText: Ue,
45
- errorText: qe,
46
- disabled: Ke
47
- }, Ge = 7, je = 6, Ze = Ge * je, g = 12, Qe = 1, et = 1, q = 1, I = 1, tt = 1, at = 1, f = 1, nt = 6, ot = "Label", rt = "Today", ct = "ap-icon-date", lt = "ap-icon-info", dt = "ap-icon-expand-more", st = "ap-icon-expand-less", it = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], v = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], _t = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], ut = (t) => {
42
+ helperRow: We,
43
+ helpText: Xe,
44
+ errorText: Ue,
45
+ disabled: qe
46
+ }, Ke = 7, Ge = 6, je = Ke * Ge, g = 12, Ze = 1, Qe = 1, q = 1, I = 1, et = 1, tt = 1, f = 1, at = 6, nt = "Label", ot = "Today", rt = "ap-icon-date", ct = "ap-icon-info", lt = "ap-icon-expand-more", dt = "ap-icon-expand-less", st = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], x = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], it = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], _t = (t) => {
48
47
  if (t instanceof Date)
49
48
  return Number.isNaN(t.getTime()) ? null : t;
50
49
  if (typeof t == "string" || typeof t == "number") {
@@ -53,14 +52,14 @@ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker__
53
52
  }
54
53
  return null;
55
54
  }, i = (t) => {
56
- const a = ut(t);
55
+ const a = _t(t);
57
56
  return a ? new Date(a.getFullYear(), a.getMonth(), a.getDate()) : null;
58
- }, X = (t, a) => t.getFullYear() === a.getFullYear() && t.getMonth() === a.getMonth() && t.getDate() === a.getDate(), U = (t) => String(t).padStart(2, "0"), pt = (t, a) => {
57
+ }, X = (t, a) => t.getFullYear() === a.getFullYear() && t.getMonth() === a.getMonth() && t.getDate() === a.getDate(), U = (t) => String(t).padStart(2, "0"), ut = (t, a) => {
59
58
  const _ = U(t.getMonth() + 1), r = U(t.getDate()), s = t.getFullYear();
60
- return a === "Mon DD, YYYY" ? `${v[t.getMonth()]} ${r}, ${s}` : a === "YYYY/MM/DD" ? `${s}/${_}/${r}` : `${_}/${r}/${s}`;
61
- }, Dt = (t, a) => {
59
+ return a === "Mon DD, YYYY" ? `${x[t.getMonth()]} ${r}, ${s}` : a === "YYYY/MM/DD" ? `${s}/${_}/${r}` : `${_}/${r}/${s}`;
60
+ }, pt = (t, a) => {
62
61
  const r = new Date(t, a, f).getDay(), s = new Date(t, a + I, 0).getDate(), D = new Date(t, a, 0).getDate(), c = [];
63
- for (let l = r - Qe; l >= 0; l -= 1)
62
+ for (let l = r - Ze; l >= 0; l -= 1)
64
63
  c.push({
65
64
  date: new Date(t, a - q, D - l),
66
65
  inCurrentMonth: !1
@@ -70,8 +69,8 @@ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker__
70
69
  date: new Date(t, a, l),
71
70
  inCurrentMonth: !0
72
71
  });
73
- for (; c.length < Ze; ) {
74
- const l = c.length - (r + s) + et;
72
+ for (; c.length < je; ) {
73
+ const l = c.length - (r + s) + Qe;
75
74
  c.push({
76
75
  date: new Date(t, a + I, l),
77
76
  inCurrentMonth: !1
@@ -79,7 +78,7 @@ import '../../assets/Datepicker.css';const ue = "Datepicker-module__datepicker__
79
78
  }
80
79
  return c;
81
80
  };
82
- function mt({
81
+ function Dt({
83
82
  day: t,
84
83
  selectedDate: a,
85
84
  currentMonth: _,
@@ -89,13 +88,13 @@ function mt({
89
88
  }) {
90
89
  const c = i(t.date);
91
90
  if (!c) return null;
92
- const l = r ? i(r) : null, k = s ? i(s) : null, u = !!(l && c < l || k && c > k), h = i(a), M = h ? X(c, h) : !1, y = i(/* @__PURE__ */ new Date()), F = y ? X(c, y) : !1;
93
- return /* @__PURE__ */ m("button", { type: "button", className: T(e.day, e.date, !t.inCurrentMonth && e.dayOutside, t.date.getMonth() !== _ && e.dayOutside, u && e.dayOutside, F && !M && e.dayTodayCurrent, M && e.daySelected), onClick: () => D(c), disabled: u, children: [
91
+ const l = r ? i(r) : null, k = s ? i(s) : null, u = !!(l && c < l || k && c > k), h = i(a), M = h ? X(c, h) : !1, y = i(/* @__PURE__ */ new Date()), Y = y ? X(c, y) : !1;
92
+ return /* @__PURE__ */ m("button", { type: "button", className: T(e.day, e.date, !t.inCurrentMonth && e.dayOutside, t.date.getMonth() !== _ && e.dayOutside, u && e.dayOutside, Y && !M && e.dayTodayCurrent, M && e.daySelected), onClick: () => D(c), disabled: u, children: [
94
93
  t.date.getDate(),
95
- F && !M && /* @__PURE__ */ o("span", { className: e.dayTodayDot })
94
+ Y && !M && /* @__PURE__ */ o("span", { className: e.dayTodayDot })
96
95
  ] });
97
96
  }
98
- function ht({
97
+ function mt({
99
98
  monthIndex: t,
100
99
  activeMonth: a,
101
100
  year: _,
@@ -104,9 +103,9 @@ function ht({
104
103
  onSelect: D
105
104
  }) {
106
105
  const c = r ? i(r) : null, l = s ? i(s) : null, k = new Date(_, t, f), u = new Date(_, t + I, 0), h = !!(c && u < c || l && k > l);
107
- return /* @__PURE__ */ o("button", { type: "button", className: T(e.day, e.month, h && e.dayOutside, t === a && e.daySelected), onClick: () => D(t), disabled: h, children: v[t] });
106
+ return /* @__PURE__ */ o("button", { type: "button", className: T(e.day, e.month, h && e.dayOutside, t === a && e.daySelected), onClick: () => D(t), disabled: h, children: x[t] });
108
107
  }
109
- function yt({
108
+ function ht({
110
109
  year: t,
111
110
  activeYear: a,
112
111
  minDate: _,
@@ -116,9 +115,9 @@ function yt({
116
115
  const D = _ ? i(_) : null, c = r ? i(r) : null, l = new Date(t, 0, f), k = new Date(t, 11, 31), u = !!(D && k < D || c && l > c);
117
116
  return /* @__PURE__ */ o("button", { type: "button", className: T(e.day, e.year, u && e.dayOutside, t === a && e.daySelected), onClick: () => s(t), disabled: u, children: t });
118
117
  }
119
- function At({
118
+ function Tt({
120
119
  className: t,
121
- label: a = ot,
120
+ label: a = nt,
122
121
  placeholder: _ = "",
123
122
  value: r,
124
123
  defaultValue: s = /* @__PURE__ */ new Date(),
@@ -130,18 +129,18 @@ function At({
130
129
  maxDate: h,
131
130
  onChange: M,
132
131
  labelTooltip: y,
133
- dateFormat: F = "MM/DD/YYYY"
132
+ dateFormat: Y = "MM/DD/YYYY"
134
133
  }) {
135
- const C = r !== void 0 && !!M, R = i(r), z = i(s), x = i(/* @__PURE__ */ new Date()) ?? /* @__PURE__ */ new Date(), [K, P] = b(!1), [Y, V] = b(() => r === null ? null : R ?? z), [p, S] = b("date"), [d, N] = b(() => r === null ? x : R || z || x), [w, O] = b(Math.floor(d.getFullYear() / g) * g);
134
+ const C = r !== void 0 && !!M, R = i(r), z = i(s), P = i(/* @__PURE__ */ new Date()) ?? /* @__PURE__ */ new Date(), [K, V] = F(!1), [b, L] = F(() => r === null ? null : R ?? z), [p, S] = F("date"), [d, N] = F(() => r === null ? P : R || z || P), [w, O] = F(Math.floor(d.getFullYear() / g) * g);
136
135
  ce(() => {
137
136
  if (!C) return;
138
137
  const n = i(r);
139
- V(n), n && (N(n), O(Math.floor(n.getFullYear() / g) * g));
138
+ L(n), n && (N(n), O(Math.floor(n.getFullYear() / g) * g));
140
139
  }, [C, r]);
141
- const G = Y ? pt(Y, F) : _, E = i(/* @__PURE__ */ new Date()) ?? /* @__PURE__ */ new Date(), B = u ? i(u) : null, L = h ? i(h) : null, j = !!(B && E < B || L && E > L), Z = H(() => Dt(d.getFullYear(), d.getMonth()), [d]), Q = H(() => Array.from({
140
+ const G = b ? ut(b, Y) : _, E = i(/* @__PURE__ */ new Date()) ?? /* @__PURE__ */ new Date(), $ = u ? i(u) : null, B = h ? i(h) : null, j = !!($ && E < $ || B && E > B), Z = J(() => pt(d.getFullYear(), d.getMonth()), [d]), Q = J(() => Array.from({
142
141
  length: g
143
142
  }, (n, A) => w + A), [w]), ee = (n) => {
144
- C || V(n), M == null || M(n);
143
+ C || L(n), M == null || M(n);
145
144
  }, te = () => {
146
145
  if (p === "date") {
147
146
  S("month");
@@ -157,7 +156,7 @@ function At({
157
156
  return;
158
157
  }
159
158
  if (p === "month") {
160
- N(new Date(d.getFullYear() - tt, d.getMonth(), f));
159
+ N(new Date(d.getFullYear() - et, d.getMonth(), f));
161
160
  return;
162
161
  }
163
162
  O((n) => n - g);
@@ -167,56 +166,56 @@ function At({
167
166
  return;
168
167
  }
169
168
  if (p === "month") {
170
- N(new Date(d.getFullYear() + at, d.getMonth(), f));
169
+ N(new Date(d.getFullYear() + tt, d.getMonth(), f));
171
170
  return;
172
171
  }
173
172
  O((n) => n + g);
174
- }, $ = (n) => {
175
- ee(n), N(n), P(!1), S("date");
173
+ }, H = (n) => {
174
+ ee(n), N(n), V(!1), S("date");
176
175
  };
177
176
  return /* @__PURE__ */ m("div", { className: T(e.datepicker, t, D && e.disabled), children: [
178
177
  a && /* @__PURE__ */ m("label", { className: e.label, children: [
179
178
  /* @__PURE__ */ o("span", { className: e.labelText, children: a }),
180
179
  c && /* @__PURE__ */ o("span", { className: e.required, children: "*" }),
181
- y && /* @__PURE__ */ o(le, { content: y.content, size: y.size, theme: y.theme, tipSide: y.tipSide, tipAlignment: y.tipAlignment, startVisible: y.startVisible, children: /* @__PURE__ */ o(W, { icon: lt, className: e.labelTooltipIcon }) })
180
+ y && /* @__PURE__ */ o(le, { content: y.content, size: y.size, theme: y.theme, tipSide: y.tipSide, tipAlignment: y.tipAlignment, startVisible: y.startVisible, children: /* @__PURE__ */ o(W, { icon: ct, className: e.labelTooltipIcon }) })
182
181
  ] }),
183
182
  /* @__PURE__ */ m(de, { open: K, onOpenChange: (n) => {
184
- D || (P(n), n || S("date"));
183
+ D || (V(n), n || S("date"));
185
184
  }, children: [
186
185
  /* @__PURE__ */ m(se, { className: T(e.inputWrapper, l && e.error), disabled: D, children: [
187
- /* @__PURE__ */ o(W, { icon: ct, className: e.inputIcon }),
188
- /* @__PURE__ */ o("span", { className: T(e.inputText, !Y && e.placeholder), children: G })
186
+ /* @__PURE__ */ o(W, { icon: rt, className: e.inputIcon }),
187
+ /* @__PURE__ */ o("span", { className: T(e.inputText, !b && e.placeholder), children: G })
189
188
  ] }),
190
- /* @__PURE__ */ o(ie, { children: /* @__PURE__ */ m(_e, { side: "bottom", align: "start", sideOffset: nt, className: e.calendarContainer, children: [
189
+ /* @__PURE__ */ o(ie, { children: /* @__PURE__ */ m(_e, { side: "bottom", align: "start", sideOffset: at, className: e.calendarContainer, children: [
191
190
  /* @__PURE__ */ m("div", { className: e.calendarHeader, children: [
192
191
  /* @__PURE__ */ m("button", { type: "button", className: e.headerLabel, onClick: te, disabled: p === "year", children: [
193
- p === "date" && `${_t[d.getMonth()]} ${d.getFullYear()}`,
192
+ p === "date" && `${it[d.getMonth()]} ${d.getFullYear()}`,
194
193
  p === "month" && `${d.getFullYear()}`,
195
194
  p === "year" && `${w} - ${w + g - 1}`
196
195
  ] }),
197
196
  /* @__PURE__ */ m("div", { className: e.headerActions, children: [
198
- /* @__PURE__ */ o(J, { size: "md", type: "tertiary", className: e.headerAction, icon: st, iconClassName: e.headerActionIcon, onClick: ae }),
199
- /* @__PURE__ */ o(J, { size: "md", type: "tertiary", className: e.headerAction, icon: dt, iconClassName: e.headerActionIcon, onClick: ne })
197
+ /* @__PURE__ */ o(v, { size: "md", type: "tertiary", className: e.headerAction, icon: dt, iconClassName: e.headerActionIcon, onClick: ae }),
198
+ /* @__PURE__ */ o(v, { size: "md", type: "tertiary", className: e.headerAction, icon: lt, iconClassName: e.headerActionIcon, onClick: ne })
200
199
  ] })
201
200
  ] }),
202
201
  /* @__PURE__ */ o("div", { className: e.calendarDivider }),
203
202
  /* @__PURE__ */ m("div", { className: e.calendarBody, children: [
204
203
  p === "date" && /* @__PURE__ */ m(re, { children: [
205
- /* @__PURE__ */ o("div", { className: e.weekdays, children: it.map((n) => /* @__PURE__ */ o("span", { className: e.weekday, children: n }, n)) }),
206
- /* @__PURE__ */ o("div", { className: e.grid, children: Z.map((n) => /* @__PURE__ */ o(mt, { day: n, selectedDate: Y, currentMonth: d.getMonth(), minDate: u, maxDate: h, onSelect: $ }, n.date.toISOString())) })
204
+ /* @__PURE__ */ o("div", { className: e.weekdays, children: st.map((n) => /* @__PURE__ */ o("span", { className: e.weekday, children: n }, n)) }),
205
+ /* @__PURE__ */ o("div", { className: e.grid, children: Z.map((n) => /* @__PURE__ */ o(Dt, { day: n, selectedDate: b, currentMonth: d.getMonth(), minDate: u, maxDate: h, onSelect: H }, n.date.toISOString())) })
207
206
  ] }),
208
- p === "month" && /* @__PURE__ */ o("div", { className: e.gridMonths, children: v.map((n, A) => /* @__PURE__ */ o(ht, { monthIndex: A, activeMonth: d.getMonth(), year: d.getFullYear(), minDate: u, maxDate: h, onSelect: (oe) => {
207
+ p === "month" && /* @__PURE__ */ o("div", { className: e.gridMonths, children: x.map((n, A) => /* @__PURE__ */ o(mt, { monthIndex: A, activeMonth: d.getMonth(), year: d.getFullYear(), minDate: u, maxDate: h, onSelect: (oe) => {
209
208
  N(new Date(d.getFullYear(), oe, f)), S("date");
210
209
  } }, n)) }),
211
- p === "year" && /* @__PURE__ */ o("div", { className: e.gridYears, children: Q.map((n) => /* @__PURE__ */ o(yt, { year: n, activeYear: d.getFullYear(), minDate: u, maxDate: h, onSelect: (A) => {
210
+ p === "year" && /* @__PURE__ */ o("div", { className: e.gridYears, children: Q.map((n) => /* @__PURE__ */ o(ht, { year: n, activeYear: d.getFullYear(), minDate: u, maxDate: h, onSelect: (A) => {
212
211
  N(new Date(A, d.getMonth(), f)), S("month");
213
212
  } }, n)) })
214
213
  ] }),
215
214
  /* @__PURE__ */ m("div", { className: e.calendarFooter, children: [
216
215
  /* @__PURE__ */ o("div", { className: e.calendarFooterSpacer }),
217
- /* @__PURE__ */ o("button", { type: "button", className: e.todayButton, disabled: j, onClick: () => {
218
- $(E), O(Math.floor(E.getFullYear() / g) * g);
219
- }, children: rt })
216
+ /* @__PURE__ */ o(v, { type: "secondary", size: "md", variant: "default", disabled: j, onClick: () => {
217
+ H(E), O(Math.floor(E.getFullYear() / g) * g);
218
+ }, children: ot })
220
219
  ] })
221
220
  ] }) })
222
221
  ] }),
@@ -224,5 +223,5 @@ function At({
224
223
  ] });
225
224
  }
226
225
  export {
227
- At as default
226
+ Tt as default
228
227
  };
@@ -41,6 +41,7 @@ type DragAndDropProps = {
41
41
  errorMessage?: string;
42
42
  fileExtensionsAllowed: string[];
43
43
  maxSize?: number;
44
+ constraintsText?: string;
44
45
  maxFiles?: number;
45
46
  value?: File | File[];
46
47
  onUpload?: (files: UploadFile[]) => void;
@@ -88,11 +89,12 @@ type DragAndDropProps = {
88
89
  * @param {boolean} [props.required] - Whether the field is required; shows an asterisk
89
90
  * @param {string[]} props.fileExtensionsAllowed - Allowed file extensions (e.g. ['pdf','png'])
90
91
  * @param {number} [props.maxSize] - Maximum file size in MB; default no limit
92
+ * @param {string} [props.constraintsText] - Full constraints line; when set, replaces default and `texts.constraints`
91
93
  * @param {number} [props.maxFiles] - Maximum number of files when type is 'multiple'
92
94
  * @param {File | File[]} [props.value] - Controlled value for the component; accepts a single File or array of Files
93
95
  * @param {(files: UploadFile[]) => void} [props.onUpload] - Callback fired with validated files upon selection or drop
94
96
  * @param {boolean} [props.queueFiles] - When true, newly selected files are appended to the existing list
95
97
  * @returns {JSX.Element} The rendered DragAndDrop component
96
98
  */
97
- export default function DragAndDrop({ label, type, disabled, required, errorMessage, fileExtensionsAllowed, maxSize, maxFiles, value, onUpload, onRemoveFile, queueFiles, className, maxSizeErrorMessage, fileExtensionInvalidErrorMessage, texts, fileIcon, errorIcon, deleteIcon, browseButtonIcon, renderFileItem, fileSizeFormatter, browseButtonProps, validator, errors: externalErrors, ...props }: DragAndDropProps): import("react/jsx-runtime").JSX.Element;
99
+ export default function DragAndDrop({ label, type, disabled, required, errorMessage, fileExtensionsAllowed, maxSize, constraintsText, maxFiles, value, onUpload, onRemoveFile, queueFiles, className, maxSizeErrorMessage, fileExtensionInvalidErrorMessage, texts, fileIcon, errorIcon, deleteIcon, browseButtonIcon, renderFileItem, fileSizeFormatter, browseButtonProps, validator, errors: externalErrors, ...props }: DragAndDropProps): import("react/jsx-runtime").JSX.Element;
98
100
  export {};
@@ -30,32 +30,33 @@ import '../../assets/DragAndDrop.css';const br = "DragAndDrop-module__disabled__
30
30
  function Pr({
31
31
  label: u,
32
32
  type: o = "single",
33
- disabled: y,
33
+ disabled: P,
34
34
  required: ar,
35
35
  errorMessage: b,
36
36
  fileExtensionsAllowed: c,
37
37
  maxSize: p = Number.POSITIVE_INFINITY,
38
+ constraintsText: B,
38
39
  maxFiles: l = Number.POSITIVE_INFINITY,
39
40
  value: D,
40
41
  onUpload: m,
41
42
  onRemoveFile: I,
42
- queueFiles: P,
43
+ queueFiles: V,
43
44
  className: nr,
44
- maxSizeErrorMessage: T,
45
- fileExtensionInvalidErrorMessage: v,
45
+ maxSizeErrorMessage: v,
46
+ fileExtensionInvalidErrorMessage: T,
46
47
  texts: a,
47
48
  fileIcon: dr = "ap-icon-document",
48
49
  errorIcon: or = "ap-icon-alert",
49
50
  deleteIcon: ir = "ap-icon-delete",
50
51
  browseButtonIcon: sr,
51
- renderFileItem: V,
52
- fileSizeFormatter: B,
52
+ renderFileItem: j,
53
+ fileSizeFormatter: S,
53
54
  browseButtonProps: tr,
54
- validator: S,
55
+ validator: w,
55
56
  errors: L,
56
57
  ...lr
57
58
  }) {
58
- const j = Cr(), Y = Or(null), [C, G] = U([]), [X, w] = U(!1), h = D !== void 0, Z = c.join(", "), H = p ? `up to ${p}MB` : "", cr = c.map((r) => `.${r.replace(/^\./, "")}`).join(","), M = g((r, e) => {
59
+ const Y = Cr(), G = Or(null), [C, X] = U([]), [Z, E] = U(!1), h = D !== void 0, F = c.join(", "), cr = c.map((r) => `.${r.replace(/^\./, "")}`).join(","), H = g((r, e) => {
59
60
  if (!r) return r || "";
60
61
  if (a != null && a.errors && e) {
61
62
  if (e === "SIZE_TOO_LARGE" && a.errors.sizeTooLarge)
@@ -64,16 +65,23 @@ function Pr({
64
65
  return typeof a.errors.invalidExtension == "function" ? a.errors.invalidExtension(c) : a.errors.invalidExtension;
65
66
  }
66
67
  return r;
67
- }, [a, p, c]), _r = g(() => a != null && a.browse ? typeof a.browse == "function" ? a.browse(o) : a.browse : o === "single" ? "Browse file" : "Browse files", [a, o]), gr = g(() => a != null && a.drag ? typeof a.drag == "function" ? a.drag(o) : a.drag : o === "single" ? "or drag your file" : "or drag multiple files", [a, o]), pr = g(() => a != null && a.constraints ? a.constraints({
68
- extensions: c,
69
- maxSize: p,
70
- type: o
71
- }) : `${Z} ${o === "single" ? "file" : "files"} ${H}`, [a, c, Z, p, H, o]), mr = () => {
68
+ }, [a, p, c]), _r = g(() => a != null && a.browse ? typeof a.browse == "function" ? a.browse(o) : a.browse : o === "single" ? "Browse file" : "Browse files", [a, o]), gr = g(() => a != null && a.drag ? typeof a.drag == "function" ? a.drag(o) : a.drag : o === "single" ? "or drag your file" : "or drag multiple files", [a, o]), pr = g(() => {
69
+ if (B !== void 0)
70
+ return B;
71
+ if (a != null && a.constraints)
72
+ return a.constraints({
73
+ extensions: c,
74
+ maxSize: p,
75
+ type: o
76
+ });
77
+ const r = p ? `up to ${p}MB` : "";
78
+ return `${F} ${o === "single" ? "file" : "files"} ${r}`;
79
+ }, [B, a, c, F, p, o]), mr = () => {
72
80
  var r;
73
- N || (r = Y.current) == null || r.click();
74
- }, E = A(() => new Set(c.map((r) => r.toLowerCase().replace(/^\./, ""))), [c]), W = g((r, e) => {
75
- const s = e.maxSize ? e.maxSize * 1024 * 1024 : Number.POSITIVE_INFINITY, i = e.fileExtensionsAllowed.join(", "), f = (T == null ? void 0 : T.replace(/\{maxSize\}/g, String(e.maxSize))) ?? Er(e.maxSize), Ir = (v == null ? void 0 : v.replace(/\{fileExtensionsAllowed\}/g, i)) ?? $r(i), Tr = r.size <= s, K = r.name.toLowerCase(), vr = K.includes(".") ? K.split(".").pop() ?? "" : "", Lr = E.size === 0 || E.has(vr);
76
- return Tr ? Lr ? {
81
+ N || (r = G.current) == null || r.click();
82
+ }, $ = A(() => new Set(c.map((r) => r.toLowerCase().replace(/^\./, ""))), [c]), M = g((r, e) => {
83
+ const s = e.maxSize ? e.maxSize * 1024 * 1024 : Number.POSITIVE_INFINITY, i = e.fileExtensionsAllowed.join(", "), f = (v == null ? void 0 : v.replace(/\{maxSize\}/g, String(e.maxSize))) ?? Er(e.maxSize), Ir = (T == null ? void 0 : T.replace(/\{fileExtensionsAllowed\}/g, i)) ?? $r(i), vr = r.size <= s, K = r.name.toLowerCase(), Tr = K.includes(".") ? K.split(".").pop() ?? "" : "", Lr = $.size === 0 || $.has(Tr);
84
+ return vr ? Lr ? {
77
85
  file: r
78
86
  } : {
79
87
  file: r,
@@ -84,16 +92,16 @@ function Pr({
84
92
  error: f,
85
93
  errorCode: "SIZE_TOO_LARGE"
86
94
  };
87
- }, [E, T, v]), $ = A(() => ({
95
+ }, [$, v, T]), k = A(() => ({
88
96
  maxSize: p,
89
97
  fileExtensionsAllowed: c,
90
98
  type: o,
91
99
  maxFiles: l
92
100
  }), [p, c, o, l]), O = g((r) => {
93
101
  let e;
94
- S ? e = r.map((i) => S(i, $)) : e = r.map((i) => W(i, $));
102
+ w ? e = r.map((i) => w(i, k)) : e = r.map((i) => M(i, k));
95
103
  let s = e.map((i) => {
96
- const f = i.error ? M(i.error, i.errorCode) : void 0;
104
+ const f = i.error ? H(i.error, i.errorCode) : void 0;
97
105
  return {
98
106
  file: i.file,
99
107
  // Don't merge external errors here - that happens in files useMemo
@@ -104,7 +112,7 @@ function Pr({
104
112
  ...i,
105
113
  error: i.error ?? `Maximum ${l} file${l === 1 ? "" : "s"} allowed.`
106
114
  })), s);
107
- }, [o, l, S, $, M, W]), n = A(() => {
115
+ }, [o, l, w, k, H, M]), n = A(() => {
108
116
  let r;
109
117
  if (h) {
110
118
  const e = Array.isArray(D) ? D : D ? [D] : [];
@@ -116,45 +124,45 @@ function Pr({
116
124
  // Validator errors take precedence over external errors
117
125
  error: e.error ?? (L == null ? void 0 : L[e.file.name])
118
126
  }));
119
- }, [h, D, O, C, L]), fr = g((r) => B ? B(r) : (r / 1024).toFixed(2) + " KB", [B]), N = A(() => y || (n == null ? void 0 : n.length) >= l || o === "single" && (n == null ? void 0 : n.length) > 0, [y, n, l, o]), F = !!b, Q = g((r) => {
127
+ }, [h, D, O, C, L]), fr = g((r) => S ? S(r) : (r / 1024).toFixed(2) + " KB", [S]), N = A(() => P || (n == null ? void 0 : n.length) >= l || o === "single" && (n == null ? void 0 : n.length) > 0, [P, n, l, o]), W = !!b, Q = g((r) => {
120
128
  const e = O(r);
121
129
  if (h)
122
130
  m == null || m(e);
123
131
  else {
124
- const s = P ? [...C, ...e] : e;
125
- G(s), m == null || m(s);
132
+ const s = V ? [...C, ...e] : e;
133
+ X(s), m == null || m(s);
126
134
  }
127
- }, [O, h, P, C, m]), ur = (r) => {
135
+ }, [O, h, V, C, m]), ur = (r) => {
128
136
  if (!r.target.files) return;
129
137
  const e = Array.from(r.target.files);
130
138
  Q(e), r.target.value = "";
131
- }, k = g((r) => {
139
+ }, z = g((r) => {
132
140
  if (!(n != null && n.length) || r < 0 || r >= n.length) return;
133
141
  const e = n[r], s = n.filter((i, f) => f !== r);
134
- h || G(s), I == null || I(e.file, s);
135
- }, [h, n, I]), J = A(() => new Map(n.map((r, e) => [e, () => k(e)])), [n, k]), {
136
- onDragOver: z,
137
- onDragLeave: R,
138
- onDrop: q,
142
+ h || X(s), I == null || I(e.file, s);
143
+ }, [h, n, I]), J = A(() => new Map(n.map((r, e) => [e, () => z(e)])), [n, z]), {
144
+ onDragOver: R,
145
+ onDragLeave: q,
146
+ onDrop: y,
139
147
  ...Dr
140
148
  } = lr, hr = (r) => {
141
- N || (r.preventDefault(), X || w(!0), z == null || z(r));
149
+ N || (r.preventDefault(), Z || E(!0), R == null || R(r));
142
150
  }, Nr = (r) => {
143
- r.preventDefault(), w(!1), R == null || R(r);
151
+ r.preventDefault(), E(!1), q == null || q(r);
144
152
  }, Ar = (r) => {
145
153
  if (N) return;
146
154
  r.preventDefault();
147
155
  const e = Array.from(r.dataTransfer.files);
148
- Q(e), r.dataTransfer.clearData(), w(!1), q == null || q(r);
156
+ Q(e), r.dataTransfer.clearData(), E(!1), y == null || y(r);
149
157
  };
150
158
  return /* @__PURE__ */ _("div", { className: rr(d["drag-and-drop-container"], N && d.disabled, nr), ...Dr, children: [
151
- u && /* @__PURE__ */ _("label", { htmlFor: j, children: [
159
+ u && /* @__PURE__ */ _("label", { htmlFor: Y, children: [
152
160
  u,
153
161
  ar && /* @__PURE__ */ t("span", { "aria-hidden": "true", className: d.required, children: "*" })
154
162
  ] }),
155
- /* @__PURE__ */ _("div", { className: rr(d["drag-and-drop-space"], X && d.active, F && d.error), onDragOver: hr, onDragLeave: Nr, onDrop: Ar, children: [
163
+ /* @__PURE__ */ _("div", { className: rr(d["drag-and-drop-space"], Z && d.active, W && d.error), onDragOver: hr, onDragLeave: Nr, onDrop: Ar, children: [
156
164
  /* @__PURE__ */ t(x, { type: "secondary", variant: "default", size: "sm", ...tr, disabled: N, onClick: mr, icon: sr, children: _r() }),
157
- /* @__PURE__ */ t("input", { id: j, ref: Y, type: "file", style: {
165
+ /* @__PURE__ */ t("input", { id: Y, ref: G, type: "file", style: {
158
166
  display: "none"
159
167
  }, multiple: o === "multiple", accept: cr, onChange: ur }),
160
168
  /* @__PURE__ */ _("div", { className: d["drag-and-drop-space-text"], children: [
@@ -165,8 +173,8 @@ function Pr({
165
173
  ] })
166
174
  ] })
167
175
  ] }),
168
- F && /* @__PURE__ */ t("span", { title: b, className: d["error-message"], children: b }),
169
- (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ t("ul", { className: d["drag-and-drop-files-list"], children: n == null ? void 0 : n.map((r, e) => V ? /* @__PURE__ */ t("li", { children: V(r, e, J.get(e) ?? (() => k(e))) }, e) : /* @__PURE__ */ t("li", { className: d["drag-and-drop-files-list-item"], children: /* @__PURE__ */ _("div", { className: d["drag-and-drop-files-list-item-content"], children: [
176
+ W && /* @__PURE__ */ t("span", { title: b, className: d["error-message"], children: b }),
177
+ (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ t("ul", { className: d["drag-and-drop-files-list"], children: n == null ? void 0 : n.map((r, e) => j ? /* @__PURE__ */ t("li", { children: j(r, e, J.get(e) ?? (() => z(e))) }, e) : /* @__PURE__ */ t("li", { className: d["drag-and-drop-files-list-item"], children: /* @__PURE__ */ _("div", { className: d["drag-and-drop-files-list-item-content"], children: [
170
178
  /* @__PURE__ */ t("span", { className: d["drag-and-drop-files-list-item-icon-container"], children: /* @__PURE__ */ t(er, { icon: dr, className: d["drag-and-drop-files-list-item-icon"] }) }),
171
179
  /* @__PURE__ */ _("div", { className: d["drag-and-drop-files-list-item-content-data"], children: [
172
180
  /* @__PURE__ */ _("div", { className: d["drag-and-drop-files-list-item-text"], children: [