asma-ui-core 3.106.0 → 3.107.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.
@@ -1,4 +1,4 @@
1
- import { cn as _ } from "../../../helpers/cn.js";
1
+ import { cn as E } from "../../../helpers/cn.js";
2
2
  import { TOP_LAYER_PROPS as nt, TOP_LAYER_RESET_STYLE as at, getOpenModalDialogAncestor as it, shouldUsePopoverTopLayer as ct, useTopLayerRef as dt } from "../../../hooks/useTopLayer.hook.js";
3
3
  import { ChevronDownIcon as ut } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
4
  import { CloseIcon as pt } from "../../icons/close-icon/CloseIcon.js";
@@ -9,26 +9,26 @@ import { StyledCheckbox as de } from "../checkbox/base-ui/StyledCheckbox.js";
9
9
  import { LoadingIcon as bt } from "../../../table/shared-components/LoadingIcon.js";
10
10
  import U from "./StyledSelectAutocomplete.module.js";
11
11
  import { useEffect as ue, useMemo as V, useRef as pe, useState as D } from "react";
12
- import { jsx as s, jsxs as I } from "react/jsx-runtime";
13
- import { FloatingPortal as gt, autoUpdate as xt, flip as yt, offset as wt, shift as kt, size as vt, useDismiss as Dt, useFloating as It, useInteractions as Nt, useMergeRefs as fe, useRole as At } from "@floating-ui/react";
12
+ import { jsx as o, jsxs as I } from "react/jsx-runtime";
13
+ import { FloatingPortal as gt, autoUpdate as xt, flip as wt, offset as yt, shift as kt, size as vt, useDismiss as Dt, useFloating as It, useInteractions as Nt, useMergeRefs as fe, useRole as At } from "@floating-ui/react";
14
14
  var Ct = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), St = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
- function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, getOptionLabel: he, getOptionKey: C, isOptionEqualToValue: B, renderOption: T, renderValue: Y, filterOptions: O, loading: q, loadingText: be = "Loading…", noOptionsText: ge = "No options", disabled: S, readOnly: g, error: xe, helperText: ye, size: we = "small", rowSize: ke = "compact", disableClearable: ve, disableCloseOnSelect: De, popupIcon: Ie, autoHeight: Ne, multiple: Ae, allowSelectAll: M, selectAllLabel: Ce = "Select all", fullWidth: Se, classes: Me, inputValue: R, onInputChange: Re, open: G, onOpen: Pe, onClose: $e, className: Le, wrapperClassName: Ee, getOptionDisabled: _e, slotProps: J }) {
16
- const r = Ae === !0, c = he ?? Ct, P = (e, t) => B ? B(e, t) : e === t, [Oe, Fe] = D(!1), a = G ?? Oe, d = (e) => {
15
+ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, getOptionLabel: he, getOptionKey: C, isOptionEqualToValue: B, renderOption: T, renderValue: Y, filterOptions: O, loading: q, loadingText: be = "Loading…", noOptionsText: ge = "No options", disabled: S, readOnly: g, error: xe, helperText: we, size: ye = "small", rowSize: ke = "compact", disableClearable: ve, disableCloseOnSelect: De, popupIcon: Ie, autoHeight: Ne, multiple: Ae, allowSelectAll: M, selectAllLabel: Ce = "Select all", fullWidth: Se, classes: Me, inputValue: R, onInputChange: Re, open: G, onOpen: Pe, onClose: $e, className: _e, wrapperClassName: Le, getOptionDisabled: Ee, slotProps: J }) {
16
+ const s = Ae === !0, c = he ?? Ct, P = (e, t) => B ? B(e, t) : e === t, [Oe, Fe] = D(!1), a = G ?? Oe, d = (e) => {
17
17
  e && (g || S) || (G === void 0 && Fe(e), e ? Pe?.() : (x(null), $e?.()));
18
18
  }, [je, Q] = D(""), m = R ?? je, $ = (e, t, n) => {
19
19
  R === void 0 && Q(t), Re?.(e, t, n);
20
- }, [o, x] = D(null), X = `${l}-listbox`, Z = pe([]), K = pe(null), [ze, He] = D(null), [ee, We] = D(null), i = r ? Array.isArray(N) ? N : [] : [], y = r ? null : N ?? null, te = !r && y !== null ? c(y) : "";
20
+ }, [r, x] = D(null), X = `${l}-listbox`, Z = pe([]), K = pe(null), [ze, He] = D(null), [ee, We] = D(null), i = s ? Array.isArray(N) ? N : [] : [], w = s ? null : N ?? null, te = !s && w !== null ? c(w) : "";
21
21
  ue(() => {
22
- R !== void 0 || r || Q(te);
22
+ R !== void 0 || s || Q(te);
23
23
  }, [
24
24
  R,
25
- r,
25
+ s,
26
26
  te
27
27
  ]);
28
- const F = (e) => r ? i.some((t) => P(e, t)) : y !== null && P(e, y), L = (e) => _e?.(e) ?? St(e), le = V(() => {
28
+ const F = (e) => s ? i.some((t) => P(e, t)) : w !== null && P(e, w), _ = (e) => Ee?.(e) ?? St(e), le = V(() => {
29
29
  const e = [...b];
30
30
  if (O) return O(e, { inputValue: m });
31
- const t = !r && y !== null ? c(y).toLowerCase() : null;
31
+ const t = !s && w !== null ? c(w).toLowerCase() : null;
32
32
  if (!m || m.toLowerCase() === t) return e;
33
33
  const n = m.toLowerCase();
34
34
  return e.filter((p) => c(p).toLowerCase().includes(n));
@@ -37,61 +37,61 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
37
37
  m,
38
38
  O,
39
39
  N
40
- ]), u = V(() => le.slice(0, 100), [le]), re = u.flatMap((e, t) => L(e) ? [] : [t]), j = M && r ? [-1, ...re] : re, oe = u.map((e, t) => t), h = M && r ? [-1, ...oe] : oe, k = u.findIndex(F);
40
+ ]), u = V(() => le.slice(0, 100), [le]), se = u.flatMap((e, t) => _(e) ? [] : [t]), j = M && s ? [-1, ...se] : se, re = u.map((e, t) => t), h = M && s ? [-1, ...re] : re, k = u.findIndex(F);
41
41
  ue(() => {
42
42
  if (!a) return;
43
- const e = o ?? k;
43
+ const e = r ?? k;
44
44
  if (e < 0) return;
45
45
  const t = requestAnimationFrame(() => Z.current[e]?.scrollIntoView({ block: "nearest" }));
46
46
  return () => cancelAnimationFrame(t);
47
47
  }, [
48
- o,
48
+ r,
49
49
  a,
50
50
  ee,
51
51
  k
52
52
  ]);
53
- const { refs: E, floatingStyles: Ue, context: se } = It({
53
+ const { refs: L, floatingStyles: Ue, context: oe } = It({
54
54
  open: a,
55
55
  onOpenChange: d,
56
56
  placement: "bottom-start",
57
57
  strategy: "fixed",
58
58
  whileElementsMounted: xt,
59
59
  middleware: [
60
- wt(0),
61
- yt({ padding: 8 }),
60
+ yt(0),
61
+ wt({ padding: 8 }),
62
62
  kt({ padding: 8 }),
63
63
  vt({ apply({ rects: e, availableHeight: t }) {
64
64
  He(e.reference.width), We(Ne ? t - 8 : Math.min(t - 8, 320));
65
65
  } })
66
66
  ]
67
- }), { getReferenceProps: Ve, getFloatingProps: Be, getItemProps: Te } = Nt([Dt(se), At(se, { role: "listbox" })]), Ye = fe([E.setReference]), ne = V(() => a ? it(E.reference.current) : void 0, [a, E]), z = ct(ne), qe = fe([dt(E.setFloating, z)]), Ge = (e) => j.includes(k) ? k : j[e === 1 ? 0 : j.length - 1] ?? null, Je = (e) => {
67
+ }), { getReferenceProps: Ve, getFloatingProps: Be, getItemProps: Te } = Nt([Dt(oe), At(oe, { role: "listbox" })]), Ye = fe([L.setReference]), ne = V(() => a ? it(L.reference.current) : void 0, [a, L]), z = ct(ne), qe = fe([dt(L.setFloating, z)]), Ge = (e) => j.includes(k) ? k : j[e === 1 ? 0 : j.length - 1] ?? null, Je = (e) => {
68
68
  h.length !== 0 && x((t) => {
69
69
  const n = h.indexOf(t ?? k);
70
70
  return n === -1 ? h[e === 1 ? 0 : h.length - 1] ?? null : h[Math.min(Math.max(n + e, 0), h.length - 1)] ?? null;
71
71
  });
72
- }, v = (e, t, n = !r || !De) => {
73
- if (r) {
74
- const p = i.some((f) => P(t, f)), w = p ? i.filter((f) => !P(t, f)) : [...i, t];
75
- A?.(e, w, p ? "removeOption" : "selectOption", { option: t }), $(e, "", "reset"), n && d(!1);
72
+ }, v = (e, t, n = !s || !De) => {
73
+ if (s) {
74
+ const p = i.some((f) => P(t, f)), y = p ? i.filter((f) => !P(t, f)) : [...i, t];
75
+ A?.(e, y, p ? "removeOption" : "selectOption", { option: t }), $(e, "", "reset"), n && d(!1);
76
76
  } else
77
77
  A?.(e, t, "selectOption", { option: t }), $(e, c(t), "reset"), n && d(!1);
78
78
  }, ae = (e) => {
79
- A?.(e, r ? [] : null, "clear", void 0), $(e, "", "clear");
79
+ A?.(e, s ? [] : null, "clear", void 0), $(e, "", "clear");
80
80
  }, H = (e) => {
81
81
  const t = b.length > 0 && i.length === b.length;
82
82
  A?.(e, t ? [] : b, t ? "clear" : "selectOption", void 0);
83
83
  }, Qe = (e) => {
84
84
  if (e.key === "Backspace" && m === "" && ie) {
85
85
  const t = i[i.length - 1];
86
- r ? t !== void 0 && v(e, t, !1) : ae(e);
86
+ s ? t !== void 0 && v(e, t, !1) : ae(e);
87
87
  } else if (e.key === "Enter" && !a)
88
88
  e.preventDefault(), d(!0);
89
- else if (e.key === "Enter" && o === -1)
89
+ else if (e.key === "Enter" && r === -1)
90
90
  e.preventDefault(), H(e);
91
- else if (e.key === "Enter" && o != null && u[o] != null) {
91
+ else if (e.key === "Enter" && r != null && u[r] != null) {
92
92
  e.preventDefault();
93
- const t = u[o];
94
- L(t) || v(e, t, !0);
93
+ const t = u[r];
94
+ _(t) || v(e, t, !0);
95
95
  } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
96
96
  if (e.preventDefault(), !a) {
97
97
  x(Ge(e.key === "ArrowDown" ? 1 : -1)), d(!0);
@@ -100,19 +100,19 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
100
100
  Je(e.key === "ArrowDown" ? 1 : -1);
101
101
  } else if (e.key === "Home" || e.key === "End")
102
102
  e.preventDefault(), x(h[e.key === "Home" ? 0 : h.length - 1] ?? null);
103
- else if (e.key === " " && o === -1)
103
+ else if (e.key === " " && r === -1)
104
104
  e.preventDefault(), H(e);
105
- else if (e.key === " " && o != null && u[o] != null) {
105
+ else if (e.key === " " && r != null && u[r] != null) {
106
106
  e.preventDefault();
107
- const t = u[o];
108
- L(t) || v(e, t, !1);
107
+ const t = u[r];
108
+ _(t) || v(e, t, !1);
109
109
  } else e.key === "Escape" && a ? (e.preventDefault(), e.stopPropagation(), d(!1)) : e.key === "Tab" && d(!1);
110
- }, ie = !ve && !g && !S && (r ? i.length > 0 : y !== null);
110
+ }, ie = !ve && !g && !S && (s ? i.length > 0 : w !== null);
111
111
  let ce;
112
- a && o != null && (o === -1 || u[o] !== void 0) && (ce = o === -1 ? `${l}-select-all` : `${l}-option-${o}`);
112
+ a && r != null && (r === -1 || u[r] !== void 0) && (ce = r === -1 ? `${l}-select-all` : `${l}-option-${r}`);
113
113
  const Xe = (e) => {
114
114
  e.preventDefault(), !(S || g) && (K.current?.focus(), d(!a));
115
- }, Ze = r ? Y ? Y(i, ({ index: e }) => ({ "data-index": e })) : i.map((e, t) => /* @__PURE__ */ s(ht, {
115
+ }, Ze = s ? Y ? Y(i, ({ index: e }) => ({ "data-index": e })) : i.map((e, t) => /* @__PURE__ */ o(ht, {
116
116
  dataTest: `selected-chip-${c(e)}`,
117
117
  label: c(e),
118
118
  readOnly: g,
@@ -121,12 +121,12 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
121
121
  }, C ? C(e) : `${c(e)}-${t}`)) : void 0, Ke = /* @__PURE__ */ I("span", {
122
122
  className: "flex items-center gap-1",
123
123
  children: [
124
- q && /* @__PURE__ */ s(bt, {
124
+ q && /* @__PURE__ */ o(bt, {
125
125
  width: 20,
126
126
  height: 20,
127
127
  className: "animate-spin"
128
128
  }),
129
- ie && /* @__PURE__ */ s("button", {
129
+ ie && /* @__PURE__ */ o("button", {
130
130
  type: "button",
131
131
  tabIndex: -1,
132
132
  "aria-label": "Clear",
@@ -134,13 +134,13 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
134
134
  className: "invisible flex min-h-6 min-w-6 cursor-pointer items-center justify-center rounded-full border-0 bg-delta-50 group-focus-within:visible",
135
135
  onMouseDown: (e) => e.preventDefault(),
136
136
  onClick: ae,
137
- children: /* @__PURE__ */ s(pt, {
137
+ children: /* @__PURE__ */ o(pt, {
138
138
  width: 20,
139
139
  height: 20,
140
140
  className: "text-delta-700"
141
141
  })
142
142
  }),
143
- g ? null : /* @__PURE__ */ s("button", {
143
+ g ? null : /* @__PURE__ */ o("button", {
144
144
  type: "button",
145
145
  tabIndex: -1,
146
146
  "aria-label": "Toggle options",
@@ -149,23 +149,23 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
149
149
  className: "flex cursor-pointer items-center border-0 bg-transparent",
150
150
  onMouseDown: (e) => e.preventDefault(),
151
151
  onClick: Xe,
152
- children: Ie ?? (r ? /* @__PURE__ */ s(mt, {
152
+ children: Ie ?? (s ? /* @__PURE__ */ o(mt, {
153
153
  width: 24,
154
154
  height: 24,
155
155
  className: "text-delta-700"
156
- }) : /* @__PURE__ */ s(ut, {
156
+ }) : /* @__PURE__ */ o(ut, {
157
157
  width: 24,
158
158
  height: 24,
159
- className: _(U["select-custom-icon"], a && U["select-custom-icon-open"], "text-delta-700")
159
+ className: E(U["select-custom-icon"], a && U["select-custom-icon-open"], "text-delta-700")
160
160
  }))
161
161
  })
162
162
  ]
163
163
  }), et = {
164
164
  disabled: S,
165
- size: we,
165
+ size: ye,
166
166
  fullWidth: !0,
167
167
  error: xe,
168
- helperText: ye,
168
+ helperText: we,
169
169
  value: m,
170
170
  onChange: (e) => {
171
171
  x(null), $(e, e.target.value, "input"), a || d(!0);
@@ -190,38 +190,38 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
190
190
  endAdornment: Ke
191
191
  }
192
192
  }
193
- }, tt = _("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-800", ke === "regular" ? "min-h-12" : "min-h-10", "aria-selected:bg-gama-50 hover:bg-delta-50", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300"), lt = (e, t, n) => {
194
- const { key: p, ...w } = e;
193
+ }, tt = E("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-2 text-base text-delta-800", ke === "regular" ? "min-h-12" : "min-h-10", "aria-selected:bg-gama-50 hover:bg-delta-50", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300"), lt = (e, t, n) => {
194
+ const { key: p, ...y } = e;
195
195
  return /* @__PURE__ */ I("li", {
196
- ...w,
196
+ ...y,
197
197
  children: [
198
- e["data-active"] !== void 0 && /* @__PURE__ */ s("span", {
198
+ e["data-active"] !== void 0 && /* @__PURE__ */ o("span", {
199
199
  "aria-hidden": "true",
200
200
  className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
201
201
  }),
202
- r ? /* @__PURE__ */ s(de, {
202
+ s ? /* @__PURE__ */ o(de, {
203
203
  dataTest: `${l}-${c(t)}-checkbox`,
204
204
  checked: n.selected,
205
205
  size: "medium",
206
206
  checkboxClassName: "!h-4 !w-4",
207
207
  hideWrapper: !0,
208
208
  decorative: !0
209
- }) : /* @__PURE__ */ s("span", {
209
+ }) : /* @__PURE__ */ o("span", {
210
210
  className: "w-5",
211
- children: n.selected && /* @__PURE__ */ s(ft, {
211
+ children: n.selected && /* @__PURE__ */ o(ft, {
212
212
  width: 20,
213
213
  height: 20,
214
214
  className: "text-gama-500"
215
215
  })
216
216
  }),
217
- /* @__PURE__ */ s("span", {
217
+ /* @__PURE__ */ o("span", {
218
218
  className: "line-clamp-2 min-w-0 flex-1 break-words",
219
219
  children: c(t)
220
220
  })
221
221
  ]
222
222
  }, p);
223
- }, rt = (e, t) => {
224
- const n = L(e), p = {
223
+ }, st = (e, t) => {
224
+ const n = _(e), p = {
225
225
  ...Te({
226
226
  onMouseDown: (f) => f.preventDefault(),
227
227
  onClick: (f) => {
@@ -237,18 +237,18 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
237
237
  id: `${l}-option-${t}`,
238
238
  "aria-selected": F(e),
239
239
  "aria-disabled": n || void 0,
240
- "data-active": o === t ? "" : void 0,
240
+ "data-active": r === t ? "" : void 0,
241
241
  className: tt
242
- }, w = {
242
+ }, y = {
243
243
  selected: F(e),
244
244
  index: t,
245
245
  inputValue: m
246
246
  };
247
- return T ? T(p, e, w) : lt(p, e, w);
248
- }, ot = !!(M && r), W = b.length > 0 && i.length === b.length, st = i.length > 0 && !W;
247
+ return T ? T(p, e, y) : lt(p, e, y);
248
+ }, rt = !!(M && s), W = b.length > 0 && i.length === b.length, ot = i.length > 0 && !W;
249
249
  return /* @__PURE__ */ I("div", {
250
- className: _(U.styledSelectAutocompleteWrapper, !Se && "w-auto", Ee, Le),
251
- children: [me(et), a && /* @__PURE__ */ s(gt, {
250
+ className: E(U.styledSelectAutocompleteWrapper, !Se && "w-auto", Le, _e),
251
+ children: [me(et), a && /* @__PURE__ */ o(gt, {
252
252
  root: ne,
253
253
  children: /* @__PURE__ */ I("ul", {
254
254
  ref: qe,
@@ -264,46 +264,46 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
264
264
  ...Be(),
265
265
  id: X,
266
266
  role: "listbox",
267
- "aria-multiselectable": r ? !0 : void 0,
268
- className: _("z-[1300] m-0 list-none overflow-auto rounded border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", ot && "py-0", "[&>li:not(:last-child)]:border-0 [&>li:not(:last-child)]:border-b", "[&>li:not(:last-child)]:border-solid [&>li:not(:last-child)]:border-delta-200", Me?.listbox, J?.popper?.className),
269
- children: [M && r && /* @__PURE__ */ I("li", {
267
+ "aria-multiselectable": s ? !0 : void 0,
268
+ className: E("z-[1300] m-0 list-none overflow-auto rounded border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", rt && "py-0", "[&>li:not(:last-child)]:shadow-[inset_0_-1px_0_var(--colors-delta-200)]", Me?.listbox, J?.popper?.className),
269
+ children: [M && s && /* @__PURE__ */ I("li", {
270
270
  id: `${l}-select-all`,
271
271
  role: "option",
272
272
  "aria-selected": W,
273
- "data-active": o === -1 ? "" : void 0,
273
+ "data-active": r === -1 ? "" : void 0,
274
274
  tabIndex: -1,
275
275
  onMouseDown: (e) => e.preventDefault(),
276
276
  onClick: H,
277
277
  onMouseMove: () => x(null),
278
- className: "relative flex h-8 cursor-pointer items-center gap-x-3 border-0 border-b border-solid border-delta-200 bg-[var(--colors-gray-10)] px-3 text-xs font-semibold uppercase tracking-[0.2px] text-delta-600 hover:bg-delta-50",
278
+ className: "relative box-border flex h-8 cursor-pointer items-center gap-x-3 bg-[var(--colors-gray-10)] px-3 text-xs font-semibold uppercase tracking-[0.2px] text-delta-600 hover:bg-delta-50",
279
279
  children: [
280
- o === -1 && /* @__PURE__ */ s("span", {
280
+ r === -1 && /* @__PURE__ */ o("span", {
281
281
  "aria-hidden": "true",
282
282
  className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
283
283
  }),
284
- /* @__PURE__ */ s(de, {
284
+ /* @__PURE__ */ o(de, {
285
285
  dataTest: `${l}-select-all`,
286
286
  checked: W,
287
- indeterminate: st,
287
+ indeterminate: ot,
288
288
  size: "medium",
289
289
  checkboxClassName: "!h-4 !w-4",
290
290
  hideWrapper: !0,
291
291
  decorative: !0
292
292
  }),
293
- /* @__PURE__ */ s("span", {
293
+ /* @__PURE__ */ o("span", {
294
294
  className: "flex-1 truncate",
295
295
  children: Ce
296
296
  })
297
297
  ]
298
- }), q ? /* @__PURE__ */ s("li", {
298
+ }), q ? /* @__PURE__ */ o("li", {
299
299
  role: "presentation",
300
300
  className: "px-3 py-2 text-sm text-delta-600",
301
301
  children: be
302
- }) : u.length === 0 ? /* @__PURE__ */ s("li", {
302
+ }) : u.length === 0 ? /* @__PURE__ */ o("li", {
303
303
  role: "presentation",
304
304
  className: "px-3 py-2 text-sm text-delta-600",
305
305
  children: ge
306
- }) : u.map(rt)]
306
+ }) : u.map(st)]
307
307
  })
308
308
  })]
309
309
  });
@@ -1,29 +1,30 @@
1
- import { StyledInputField as G } from "../../../../components/inputs/input-field/StyledInputField.js";
2
- import { getValue as f } from "../helpers.js";
3
- import { DatePickerButton as J } from "./DatePickerButton.js";
4
- import { DATE_INPUT_FONT_FAMILY as K } from "../../../../helpers/inputMask.js";
5
- import { useDatePickerMask as Q } from "../hooks/useDatePickerMask.js";
6
- import { defaultDatePickerValidationMessages as X, useDatePickerValidation as Z } from "../hooks/useDatePickerValidation.js";
7
- import { useEffect as b, useState as k } from "react";
8
- import { jsx as m, jsxs as N } from "react/jsx-runtime";
9
- import { isValid as $, parse as ee } from "date-fns";
10
- var ce = (V) => {
11
- const { onClick: F, inputClassName: w, dateFormat: r, selected: e, error: I, helperText: H, errorText: Y, onInputChange: h, hideCalendar: B, locale: o, disabledDays: l, label: E, title: v, readOnly: t, disallowPast: i, disallowFuture: s, validateOnCalendarClose: D, onValidatedOnce: g, hideDefaultHelperText: O, required: d, minDate: n, ...u } = V, { validationError: A, handleValidation: c, errHelperText: R, clearValidation: x } = Z(X), { maskRef: S } = Q(), [a, y] = k(e ? f(e, r) : ""), [C, _] = k({
1
+ import { StyledInputField as K } from "../../../../components/inputs/input-field/StyledInputField.js";
2
+ import { getValue as h } from "../helpers.js";
3
+ import { DatePickerButton as Q } from "./DatePickerButton.js";
4
+ import { getTitleLabelling as X } from "../../../helpers/getTitleLabelling.js";
5
+ import { DATE_INPUT_FONT_FAMILY as Z } from "../../../../helpers/inputMask.js";
6
+ import { useDatePickerMask as $ } from "../hooks/useDatePickerMask.js";
7
+ import { defaultDatePickerValidationMessages as ee, useDatePickerValidation as te } from "../hooks/useDatePickerValidation.js";
8
+ import { useEffect as I, useId as ae, useState as N } from "react";
9
+ import { jsx as p, jsxs as V } from "react/jsx-runtime";
10
+ import { isValid as re, parse as oe } from "date-fns";
11
+ var he = (F) => {
12
+ const { onClick: w, inputClassName: H, dateFormat: r, selected: e, error: Y, helperText: A, errorText: B, onInputChange: v, hideCalendar: E, locale: o, disabledDays: l, label: g, title: u, inputAriaProps: O, readOnly: t, disallowPast: i, disallowFuture: s, validateOnCalendarClose: D, onValidatedOnce: x, hideDefaultHelperText: L, required: d, minDate: n, ...f } = F, { validationError: R, handleValidation: c, errHelperText: S, clearValidation: y } = te(ee), { maskRef: _ } = $(), T = ae(), [a, C] = N(e ? h(e, r) : ""), [P, j] = N({
12
13
  selected: e,
13
14
  dateFormat: r
14
15
  });
15
- (e !== C.selected || r !== C.dateFormat) && (_({
16
+ (e !== P.selected || r !== P.dateFormat) && (j({
16
17
  selected: e,
17
18
  dateFormat: r
18
- }), y(e ? f(e, r) : ""));
19
- const j = o?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", L = O ? void 0 : j, T = !!(A || I), q = T ? Y ?? R : H ?? L;
20
- b(() => {
19
+ }), C(e ? h(e, r) : ""));
20
+ const q = o?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", z = L ? void 0 : q, M = !!(R || Y), U = M ? B ?? S : A ?? z;
21
+ I(() => {
21
22
  if (!e) {
22
- x();
23
+ y();
23
24
  return;
24
25
  }
25
26
  c({
26
- value: f(e, r),
27
+ value: h(e, r),
27
28
  disabledDays: l,
28
29
  localeCode: o?.code,
29
30
  disallowPast: i,
@@ -41,13 +42,13 @@ var ce = (V) => {
41
42
  d,
42
43
  n,
43
44
  c,
44
- x
45
+ y
45
46
  ]);
46
- const z = /\d/.test(a), U = (p) => {
47
- const P = p.target.value;
48
- y(P.replace(/\D/g, "").length ? P : "");
47
+ const W = /\d/.test(a), G = (m) => {
48
+ const k = m.target.value;
49
+ C(k.replace(/\D/g, "").length ? k : "");
49
50
  };
50
- b(() => {
51
+ I(() => {
51
52
  D && (c({
52
53
  value: a,
53
54
  disabledDays: l,
@@ -56,7 +57,7 @@ var ce = (V) => {
56
57
  disallowFuture: s,
57
58
  required: d,
58
59
  minDate: n
59
- }), g?.());
60
+ }), x?.());
60
61
  }, [
61
62
  D,
62
63
  a,
@@ -66,10 +67,10 @@ var ce = (V) => {
66
67
  s,
67
68
  d,
68
69
  n,
69
- g,
70
+ x,
70
71
  c
71
72
  ]);
72
- const W = () => {
73
+ const J = () => {
73
74
  if (c({
74
75
  value: a,
75
76
  disabledDays: l,
@@ -80,61 +81,70 @@ var ce = (V) => {
80
81
  minDate: n
81
82
  })) return;
82
83
  if (!a.replace(/\D/g, "").length) {
83
- h?.(void 0);
84
+ v?.(void 0);
84
85
  return;
85
86
  }
86
- const p = ee(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
87
- h?.($(p) ? p : void 0);
88
- }, M = t ? 120 : 156;
89
- return /* @__PURE__ */ N("div", {
87
+ const m = oe(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
88
+ v?.(re(m) ? m : void 0);
89
+ }, b = t ? 120 : 156;
90
+ return /* @__PURE__ */ V("div", {
90
91
  className: "cursor-default",
91
- children: [v && /* @__PURE__ */ m("div", {
92
+ children: [u && /* @__PURE__ */ p("div", {
93
+ id: T,
92
94
  className: "pb-1 font-roboto font-semibold text-delta-800",
93
- children: v
94
- }), /* @__PURE__ */ N("div", {
95
+ children: u
96
+ }), /* @__PURE__ */ V("div", {
95
97
  className: "flex gap-1",
96
98
  style: { height: t ? 40 : 75 },
97
- children: [/* @__PURE__ */ m("div", {
98
- style: { width: M },
99
- children: /* @__PURE__ */ m("div", {
99
+ children: [/* @__PURE__ */ p("div", {
100
+ style: { width: b },
101
+ children: /* @__PURE__ */ p("div", {
100
102
  className: "relative",
101
- children: /* @__PURE__ */ m(G, {
102
- ...u,
103
- label: E,
103
+ children: /* @__PURE__ */ p(K, {
104
+ ...f,
105
+ label: g,
104
106
  readOnly: t,
105
- "data-testid": u.dataTest,
107
+ "data-testid": f.dataTest,
106
108
  autoComplete: "off",
107
- inputRef: t ? void 0 : S,
108
- placeholder: !t && !z ? " / / " : void 0,
109
+ inputRef: t ? void 0 : _,
110
+ placeholder: !t && !W ? " / / " : void 0,
109
111
  size: "small",
110
112
  value: t ? a.replaceAll("/", ".") : a,
111
- className: w,
112
- style: { width: M },
113
- error: T,
114
- onBlur: t ? void 0 : W,
115
- helperText: q,
113
+ className: H,
114
+ style: { width: b },
115
+ error: M,
116
+ onBlur: t ? void 0 : J,
117
+ helperText: U,
116
118
  slotProps: {
117
119
  formHelperText: { sx: {
118
120
  marginTop: "4px",
119
121
  marginLeft: 0,
120
122
  marginRight: 0
121
123
  } },
122
- htmlInput: { ...t ? {} : {
123
- inputMode: "numeric",
124
- style: { fontFamily: K }
125
- } }
124
+ htmlInput: {
125
+ ...X({
126
+ title: u,
127
+ titleId: T,
128
+ label: g,
129
+ inputAriaProps: O
130
+ }),
131
+ ...t ? {} : {
132
+ inputMode: "numeric",
133
+ style: { fontFamily: Z }
134
+ }
135
+ }
126
136
  },
127
- onChange: U
137
+ onChange: G
128
138
  })
129
139
  })
130
- }), !B && !t && /* @__PURE__ */ m(J, {
131
- onClick: F,
132
- disabled: !!u.disabled,
140
+ }), !E && !t && /* @__PURE__ */ p(Q, {
141
+ onClick: w,
142
+ disabled: !!f.disabled,
133
143
  localeCode: o?.code
134
144
  })]
135
145
  })]
136
146
  });
137
147
  };
138
148
  export {
139
- ce as BaseDatePickerInput
149
+ he as BaseDatePickerInput
140
150
  };
@@ -1,18 +1,18 @@
1
- import { BaseDatePickerInput as k } from "./BaseDatePickerInput.js";
2
- import { jsx as v } from "react/jsx-runtime";
3
- var F = ({ datePickerProps: e, onClick: a }) => {
4
- const { inputClassName: r, disabled: t, helperText: l, label: d, error: n, locale: i, hideCalendar: o, dateFormat: s, disabledDays: p, dataTest: u, readOnly: m, errorText: c, disallowFuture: C, disallowPast: h, required: x, minDate: D, validateOnCalendarClose: b, onValidatedOnce: I, onInputChange: T, selected: f, title: g, hideDefaultHelperText: O } = e;
5
- return /* @__PURE__ */ v(k, {
1
+ import { BaseDatePickerInput as v } from "./BaseDatePickerInput.js";
2
+ import { jsx as w } from "react/jsx-runtime";
3
+ var j = ({ datePickerProps: e, onClick: a }) => {
4
+ const { inputClassName: r, disabled: t, helperText: l, label: d, error: i, locale: n, hideCalendar: o, dateFormat: s, disabledDays: p, dataTest: u, readOnly: m, errorText: c, disallowFuture: C, disallowPast: h, required: x, minDate: D, validateOnCalendarClose: b, onValidatedOnce: I, onInputChange: P, selected: T, title: f, hideDefaultHelperText: g, inputAriaProps: O } = e;
5
+ return /* @__PURE__ */ w(v, {
6
6
  dataTest: u,
7
7
  inputClassName: r,
8
8
  readOnly: m,
9
9
  disabled: !!t,
10
10
  helperText: l,
11
11
  onClick: a,
12
- onInputChange: (P) => T?.(P),
13
- selected: f,
14
- error: !!n,
15
- locale: i,
12
+ onInputChange: (k) => P?.(k),
13
+ selected: T,
14
+ error: !!i,
15
+ locale: n,
16
16
  hideCalendar: o,
17
17
  dateFormat: s,
18
18
  disabledDays: p,
@@ -24,10 +24,11 @@ var F = ({ datePickerProps: e, onClick: a }) => {
24
24
  minDate: D,
25
25
  validateOnCalendarClose: b,
26
26
  onValidatedOnce: I,
27
- title: g,
28
- hideDefaultHelperText: O
27
+ title: f,
28
+ hideDefaultHelperText: g,
29
+ inputAriaProps: O
29
30
  });
30
31
  };
31
32
  export {
32
- F as DatePickerInputSingle
33
+ j as DatePickerInputSingle
33
34
  };