asma-ui-core 3.20.0 → 3.20.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,138 +1,139 @@
1
- import { getValue as N } from "../helpers.js";
2
- import { StyledInputField as X } from "../../../shared-components/StyledInputField.js";
3
- import { cn as Z } from "../../../helpers/cn.js";
4
- import { DatePickerButton as _ } from "./DatePickerButton.js";
5
- import { useDatePickerMask as $ } from "../hooks/useDatePickerMask.js";
6
- import { useDatePickerValidation as ee } from "../hooks/useDatePickerValidation.js";
7
- import { HelperTextWithTooltip as te } from "./HelperTextWithTooltip.js";
8
- import { useEffect as P, useState as w } from "react";
9
- import { jsx as a, jsxs as y } from "react/jsx-runtime";
10
- import { isValid as ae, parse as le } from "date-fns";
11
- var he = (F) => {
12
- const { onClick: B, inputClassName: I, dateFormat: f, selected: l, error: S, helperText: Y, errorText: E, onInputChange: C, hideCalendar: O, locale: t, disabledDays: o, label: W, title: b, readOnly: e, disallowPast: r, disallowFuture: i, validateOnCalendarClose: T, onValidatedOnce: V, hideDefaultHelperText: j, required: s, minDate: n, ...h } = F, { validationError: R, handleValidation: d, errHelperText: q, clearValidation: H } = ee(), { maskRef: z } = $(), x = l ? N(l, f) : "", [m, M] = w(x), [k, v] = w(!1), A = t?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", G = j ? void 0 : A, u = !!(R || S), J = u ? E ?? q : Y ?? G, D = k ? m : x;
13
- P(() => {
14
- if (!l) {
15
- H();
1
+ import { getValue as x } from "../helpers.js";
2
+ import { StyledInputField as G } from "../../../shared-components/StyledInputField.js";
3
+ import { cn as J } from "../../../helpers/cn.js";
4
+ import { DatePickerButton as K } from "./DatePickerButton.js";
5
+ import { useDatePickerMask as L } from "../hooks/useDatePickerMask.js";
6
+ import { useDatePickerValidation as Q } from "../hooks/useDatePickerValidation.js";
7
+ import { HelperTextWithTooltip as U } from "./HelperTextWithTooltip.js";
8
+ import { useEffect as v, useState as X } from "react";
9
+ import { jsx as o, jsxs as D } from "react/jsx-runtime";
10
+ import { isValid as Z, parse as _ } from "date-fns";
11
+ var ce = (k) => {
12
+ const { onClick: N, inputClassName: P, dateFormat: l, selected: t, error: V, helperText: w, errorText: F, onInputChange: g, hideCalendar: B, locale: r, disabledDays: i, label: S, title: y, readOnly: e, disallowPast: s, disallowFuture: d, validateOnCalendarClose: C, onValidatedOnce: b, hideDefaultHelperText: Y, required: n, minDate: c, ...f } = k, { validationError: E, handleValidation: p, errHelperText: I, clearValidation: T } = Q(), { maskRef: O } = L(), [a, H] = X(t ? x(t, l) : ""), W = r?.code?.startsWith("nb") ? "DD/MM/ÅÅÅÅ" : "DD/MM/YYYY", j = Y ? void 0 : W, m = !!(E || V), R = m ? F ?? I : w ?? j;
13
+ v(() => {
14
+ H(t ? x(t, l) : "");
15
+ }, [t, l]), v(() => {
16
+ if (!t) {
17
+ T();
16
18
  return;
17
19
  }
18
- d({
19
- value: N(l, f),
20
- disabledDays: o,
21
- localeCode: t?.code,
22
- disallowPast: r,
23
- disallowFuture: i,
24
- required: s,
25
- minDate: n
20
+ p({
21
+ value: x(t, l),
22
+ disabledDays: i,
23
+ localeCode: r?.code,
24
+ disallowPast: s,
25
+ disallowFuture: d,
26
+ required: n,
27
+ minDate: c
26
28
  });
27
29
  }, [
30
+ t,
28
31
  l,
29
- f,
30
- o,
31
- t?.code,
32
- r,
33
32
  i,
33
+ r?.code,
34
34
  s,
35
- n,
36
35
  d,
37
- H
36
+ n,
37
+ c,
38
+ p,
39
+ T
38
40
  ]);
39
- const K = D.replace(/\D/g, "").length > 0, L = (c) => {
40
- const p = c.target.value, U = p.replace(/\D/g, "");
41
- v(!0), M(U.length ? p : "");
41
+ const q = a.replace(/\D/g, "").length > 0, z = (u) => {
42
+ const M = u.target.value;
43
+ H(M.replace(/\D/g, "").length ? M : "");
42
44
  };
43
- P(() => {
44
- T && (d({
45
- value: m,
46
- disabledDays: o,
47
- localeCode: t?.code,
48
- disallowPast: r,
49
- disallowFuture: i,
50
- required: s,
51
- minDate: n
52
- }), V?.());
45
+ v(() => {
46
+ C && (p({
47
+ value: a,
48
+ disabledDays: i,
49
+ localeCode: r?.code,
50
+ disallowPast: s,
51
+ disallowFuture: d,
52
+ required: n,
53
+ minDate: c
54
+ }), b?.());
53
55
  }, [
54
- T,
55
- m,
56
- o,
57
- t?.code,
58
- r,
56
+ C,
57
+ a,
59
58
  i,
59
+ r?.code,
60
60
  s,
61
+ d,
61
62
  n,
62
- V,
63
- d
63
+ c,
64
+ b,
65
+ p
64
66
  ]);
65
- const Q = () => {
66
- const c = k ? m : x;
67
- if (d({
68
- value: c,
69
- disabledDays: o,
70
- localeCode: t?.code,
71
- disallowPast: r,
72
- disallowFuture: i,
73
- required: s,
74
- minDate: n
67
+ const A = () => {
68
+ if (p({
69
+ value: a,
70
+ disabledDays: i,
71
+ localeCode: r?.code,
72
+ disallowPast: s,
73
+ disallowFuture: d,
74
+ required: n,
75
+ minDate: c
75
76
  })) return;
76
- if (!c.replace(/\D/g, "").length) {
77
- v(!1), M(""), C?.(void 0);
77
+ if (!a.replace(/\D/g, "").length) {
78
+ g?.(void 0);
78
79
  return;
79
80
  }
80
- const p = le(c, "dd/MM/yyyy", /* @__PURE__ */ new Date());
81
- v(!1), C?.(ae(p) ? p : void 0);
82
- }, g = e ? 120 : 160;
83
- return /* @__PURE__ */ y("div", {
81
+ const u = _(a, "dd/MM/yyyy", /* @__PURE__ */ new Date());
82
+ g?.(Z(u) ? u : void 0);
83
+ }, h = e ? 120 : 160;
84
+ return /* @__PURE__ */ D("div", {
84
85
  className: "cursor-default",
85
- children: [b && /* @__PURE__ */ a("div", {
86
+ children: [y && /* @__PURE__ */ o("div", {
86
87
  className: "pb-1 font-roboto font-semibold text-delta-800",
87
- children: b
88
- }), /* @__PURE__ */ y("div", {
88
+ children: y
89
+ }), /* @__PURE__ */ D("div", {
89
90
  className: "flex gap-1",
90
91
  style: { height: e ? 40 : 75 },
91
- children: [/* @__PURE__ */ y("div", {
92
- style: { width: g },
93
- children: [/* @__PURE__ */ a("div", {
92
+ children: [/* @__PURE__ */ D("div", {
93
+ style: { width: h },
94
+ children: [/* @__PURE__ */ o("div", {
94
95
  className: "relative",
95
- children: /* @__PURE__ */ a(X, {
96
- ...h,
97
- label: W,
96
+ children: /* @__PURE__ */ o(G, {
97
+ ...f,
98
+ label: S,
98
99
  readOnly: e,
99
- "data-testid": h.dataTest,
100
+ "data-testid": f.dataTest,
100
101
  autoComplete: "off",
101
- inputRef: e ? void 0 : z,
102
- placeholder: !e && !K ? " / / " : void 0,
102
+ inputRef: e ? void 0 : O,
103
+ placeholder: !e && !q ? " / / " : void 0,
103
104
  size: "small",
104
- value: e ? D.replaceAll("/", ".") : D,
105
- className: I,
106
- style: { width: g },
107
- error: u,
108
- onBlur: e ? void 0 : Q,
105
+ value: e ? a.replaceAll("/", ".") : a,
106
+ className: P,
107
+ style: { width: h },
108
+ error: m,
109
+ onBlur: e ? void 0 : A,
109
110
  helperText: null,
110
111
  FormHelperTextProps: { sx: { m: 0 } },
111
112
  inputProps: { ...e ? {} : {
112
113
  inputMode: "numeric",
113
114
  style: { fontFamily: "monospace" }
114
115
  } },
115
- onChange: L
116
+ onChange: z
116
117
  })
117
- }), !e && /* @__PURE__ */ a("div", {
118
- className: Z("pt-1 text-[14px]", u ? "text-error-500" : "text-delta-600"),
118
+ }), !e && /* @__PURE__ */ o("div", {
119
+ className: J("pt-1 text-[14px]", m ? "text-error-500" : "text-delta-600"),
119
120
  style: {
120
- maxWidth: g,
121
+ maxWidth: h,
121
122
  maxHeight: 34,
122
123
  lineHeight: "16px"
123
124
  },
124
- children: /* @__PURE__ */ a(te, {
125
- text: J,
126
- hasError: u
125
+ children: /* @__PURE__ */ o(U, {
126
+ text: R,
127
+ hasError: m
127
128
  })
128
129
  })]
129
- }), !O && !e && /* @__PURE__ */ a(_, {
130
- onClick: B,
131
- disabled: !!h.disabled
130
+ }), !B && !e && /* @__PURE__ */ o(K, {
131
+ onClick: N,
132
+ disabled: !!f.disabled
132
133
  })]
133
134
  })]
134
135
  });
135
136
  };
136
137
  export {
137
- he as BaseDatePickerInput
138
+ ce as BaseDatePickerInput
138
139
  };
@@ -1,32 +1,31 @@
1
- var _ = "_months_4o44h_5", a = "_month_4o44h_5", o = "_caption_4o44h_18", e = "_caption_label_4o44h_22", d = "_nav_4o44h_31", r = "_nav_button_4o44h_35", n = "_nav_button_previous_4o44h_41", t = "_nav_button_next_4o44h_45", h = "_head_row_4o44h_49", v = "_head_cell_4o44h_64", l = "_row_4o44h_73", i = "_cell_4o44h_85", c = "_has_4o44h_88", s = "_first_4o44h_91", y = "_last_4o44h_94", u = "_day_4o44h_98", b = "_day_today_4o44h_109", p = "_day_selected_4o44h_115", m = "_day_outside_4o44h_130", f = "_day_range_middle_4o44h_133", w = "_day_disabled_4o44h_141", k = "_day_hidden_4o44h_145", g = "_weeknumber_4o44h_149", x = "_caption_end_4o44h_153", C = {
2
- "styled-calendar-day-picker": "_styled-calendar-day-picker_4o44h_1",
1
+ var _ = "_months_fief3_12", e = "_month_fief3_12", a = "_caption_fief3_25", f = "_caption_label_fief3_29", d = "_nav_fief3_34", i = "_nav_button_fief3_38", r = "_nav_button_previous_fief3_44", n = "_nav_button_next_fief3_48", t = "_head_row_fief3_52", v = "_head_cell_fief3_56", l = "_row_fief3_65", o = "_cell_fief3_69", s = "_has_fief3_72", y = "_first_fief3_75", c = "_last_fief3_78", u = "_day_fief3_82", b = "_day_today_fief3_93", h = "_day_selected_fief3_99", p = "_day_outside_fief3_120", m = "_day_range_middle_fief3_126", w = "_day_disabled_fief3_134", k = "_day_hidden_fief3_142", g = "_weeknumber_fief3_146", x = "_caption_end_fief3_158", C = {
2
+ "styled-calendar-day-picker": "_styled-calendar-day-picker_fief3_1",
3
3
  months: _,
4
- month: a,
5
- caption: o,
6
- caption_label: e,
7
- "custom-caption": "_custom-caption_4o44h_27",
4
+ month: e,
5
+ caption: a,
6
+ caption_label: f,
8
7
  nav: d,
9
- nav_button: r,
10
- nav_button_previous: n,
11
- nav_button_next: t,
12
- head_row: h,
13
- "locale-nb": "_locale-nb_4o44h_60",
8
+ nav_button: i,
9
+ nav_button_previous: r,
10
+ nav_button_next: n,
11
+ head_row: t,
14
12
  head_cell: v,
15
13
  row: l,
16
- cell: i,
17
- has: c,
18
- first: s,
19
- last: y,
14
+ cell: o,
15
+ has: s,
16
+ first: y,
17
+ last: c,
20
18
  day: u,
21
- "focus-visible": "_focus-visible_4o44h_104",
19
+ "focus-visible": "_focus-visible_fief3_88",
22
20
  day_today: b,
23
- day_selected: p,
24
- "rdp-day_range_end": "_rdp-day_range_end_4o44h_118",
25
- day_outside: m,
26
- day_range_middle: f,
21
+ day_selected: h,
22
+ "rdp-day_range_end": "_rdp-day_range_end_fief3_120",
23
+ day_outside: p,
24
+ day_range_middle: m,
27
25
  day_disabled: w,
28
26
  day_hidden: k,
29
27
  weeknumber: g,
28
+ "weeknumber-header": "_weeknumber-header_fief3_150",
30
29
  caption_end: x
31
30
  };
32
31
  export {
@@ -1,12 +1,11 @@
1
- import { StyledButton as i } from "../../../shared-components/button/StyledButton.js";
2
- import { CloseIcon as l } from "../../../shared-components/CloseIcon.js";
3
- import s from "./StyledCalendarPicker.module.js";
4
- import { jsx as e, jsxs as d } from "react/jsx-runtime";
5
- function x(o) {
6
- const { onClose: n, children: a, calendarMonth: c, displayIndex: m, ...t } = o;
7
- return /* @__PURE__ */ d("div", {
1
+ import { StyledButton as s } from "../../../shared-components/button/StyledButton.js";
2
+ import { CloseIcon as r } from "../../../shared-components/CloseIcon.js";
3
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
4
+ function y(n) {
5
+ const { onClose: o, children: a, calendarMonth: c, displayIndex: d, ...t } = n;
6
+ return /* @__PURE__ */ l("div", {
8
7
  ...t,
9
- className: s["custom-caption"],
8
+ className: "rdp-custom-caption capitalize",
10
9
  style: {
11
10
  ...t.style,
12
11
  display: "flex",
@@ -14,11 +13,11 @@ function x(o) {
14
13
  alignItems: "center",
15
14
  marginLeft: "10px"
16
15
  },
17
- children: [a, /* @__PURE__ */ e(i, {
16
+ children: [a, /* @__PURE__ */ e(s, {
18
17
  dataTest: "close-button",
19
18
  variant: "textGray",
20
- onClick: (r) => n?.(r, "backdropClick"),
21
- startIcon: /* @__PURE__ */ e(l, {
19
+ onClick: (i) => o?.(i, "backdropClick"),
20
+ startIcon: /* @__PURE__ */ e(r, {
22
21
  height: 20,
23
22
  width: 20
24
23
  })
@@ -26,5 +25,5 @@ function x(o) {
26
25
  });
27
26
  }
28
27
  export {
29
- x as CustomCaption
28
+ y as CustomCaption
30
29
  };
@@ -1,52 +1,70 @@
1
- import { StyledCalendarPickerFooter as p } from "./StyledCalendarPickerFooter.js";
2
- import e from "./StyledCalendarPicker.module.js";
1
+ import { StyledCalendarPickerFooter as C } from "./StyledCalendarPickerFooter.js";
3
2
  import { CustomCaption as O } from "./StyledCalendarPickerCaption.js";
4
- import { StyledCalendarPickerSelectMonth as Y } from "./StyledCalendarPickerSelectMonth.js";
5
- import { StyledCalendarPickerSelectYear as F } from "./StyledCalendarPickerSelectYear.js";
6
- import { buildDisabled as x } from "../helpers.js";
7
- import { useState as N } from "react";
3
+ import { StyledCalendarPickerSelectMonth as x } from "./StyledCalendarPickerSelectMonth.js";
4
+ import { StyledCalendarPickerSelectYear as N } from "./StyledCalendarPickerSelectYear.js";
5
+ import e from "./StyledCalendarPicker.module.js";
6
+ import { buildDisabled as Y } from "../helpers.js";
7
+ import { useState as F } from "react";
8
8
  import "@mui/material";
9
- import { jsx as r } from "react/jsx-runtime";
10
- import { DayPicker as q } from "react-day-picker";
11
- import { endOfMonth as R, startOfToday as T } from "date-fns";
12
- import { enGB as W } from "date-fns/locale";
13
- var U = ({ datePickerProps: t, popoverProps: y }) => {
14
- const { showOutsideDays: h = !0, locale: i = W, numberOfMonths: f, disabledDays: w, onClear: b, title: $, ...D } = t, { onClose: m } = y, [c, u] = N((t.mode === "range" ? t.selected?.from : t.selected) ?? /* @__PURE__ */ new Date()), _ = i.code === "nb", S = (f ?? 1) < 2, g = x(w, "disallowPast" in t ? t.disallowPast : void 0, "disallowFuture" in t ? t.disallowFuture : void 0, T()), v = (n) => {
9
+ import { jsx as i } from "react/jsx-runtime";
10
+ import { DayPicker as W } from "react-day-picker";
11
+ import { endOfMonth as q, startOfToday as R } from "date-fns";
12
+ import { enGB as T } from "date-fns/locale";
13
+ var Q = ({ datePickerProps: t, popoverProps: y }) => {
14
+ const { showOutsideDays: h = !0, locale: s = T, numberOfMonths: b, disabledDays: w, onClear: f, title: j, ...g } = t, { onClose: m } = y, [_, c] = F((t.mode === "range" ? t.selected?.from : t.selected) ?? /* @__PURE__ */ new Date()), u = s.code === "nb", v = (b ?? 1) < 2, D = Y(w, "disallowPast" in t ? t.disallowPast : void 0, "disallowFuture" in t ? t.disallowFuture : void 0, R()), S = (n) => {
15
15
  if (!t.selected || !t.onSelect) return;
16
16
  const o = /* @__PURE__ */ new Date(), a = {};
17
17
  if (t.mode === "range") {
18
- const d = t.onSelect;
19
- d(void 0, o, a, n);
18
+ const l = t.onSelect;
19
+ l(void 0, o, a, n);
20
20
  return;
21
21
  }
22
- const l = t.onSelect;
23
- l(void 0, o, a, n);
22
+ const d = t.onSelect;
23
+ d(void 0, o, a, n);
24
24
  };
25
- return /* @__PURE__ */ r(q, {
26
- ...D,
27
- disabled: g,
28
- month: c,
25
+ return /* @__PURE__ */ i(W, {
26
+ ...g,
27
+ disabled: D,
28
+ month: _,
29
29
  onMonthChange: (n) => {
30
- if (u(n), !!t.onSelect && (!t.mode || t.mode === "single")) {
30
+ if (c(n), !!t.onSelect && (!t.mode || t.mode === "single")) {
31
31
  const o = t.selected;
32
32
  if (o instanceof Date) {
33
- const a = n.getFullYear(), l = n.getMonth(), d = o.getDate(), M = R(new Date(a, l, 1)).getDate(), C = Math.min(d, M), s = new Date(o);
34
- s.setFullYear(a, l, C), t.onSelect(s, s, {}, {});
33
+ const a = n.getFullYear(), d = n.getMonth(), l = o.getDate(), p = q(new Date(a, d, 1)).getDate(), M = Math.min(l, p), r = new Date(o);
34
+ r.setFullYear(a, d, M), t.onSelect(r, r, {}, {});
35
35
  }
36
36
  }
37
37
  },
38
38
  captionLayout: "dropdown",
39
+ hideNavigation: !0,
39
40
  weekStartsOn: 1,
40
- locale: i,
41
+ locale: s,
41
42
  startMonth: new Date(t.fromYear ?? 1900, 0),
42
43
  endMonth: new Date(t.toYear ?? 2100, 11),
43
44
  "data-test": "calendar-picker",
44
45
  showWeekNumber: !0,
45
46
  showOutsideDays: h,
46
47
  fixedWeeks: !0,
47
- className: `${e["styled-calendar-day-picker"]} ${_ ? e["locale-nb"] : ""}`,
48
+ formatters: { formatWeekNumberHeader: () => u ? "U" : "W" },
49
+ className: e["styled-calendar-day-picker"],
48
50
  classNames: {
49
51
  months: e.months,
52
+ month_caption: e.caption,
53
+ weekdays: e.head_row,
54
+ weekday: e.head_cell,
55
+ week: e.row,
56
+ day: e.cell,
57
+ day_button: e.day,
58
+ week_number: e.weeknumber,
59
+ week_number_header: e["weeknumber-header"],
60
+ selected: e.day_selected,
61
+ today: e.day_today,
62
+ outside: e.day_outside,
63
+ disabled: e.day_disabled,
64
+ range_middle: e.day_range_middle,
65
+ hidden: e.day_hidden,
66
+ button_previous: e.nav_button_previous,
67
+ button_next: e.nav_button_next,
50
68
  weeknumber: e.weeknumber,
51
69
  month: e.month,
52
70
  caption: e.caption,
@@ -59,35 +77,34 @@ var U = ({ datePickerProps: t, popoverProps: y }) => {
59
77
  head_cell: e.head_cell,
60
78
  row: e.row,
61
79
  cell: e.cell,
62
- day: e.day,
63
80
  day_today: e.day_today,
64
81
  day_selected: e.day_selected,
65
82
  day_outside: e.day_outside,
66
83
  day_disabled: e.day_disabled,
67
84
  day_range_middle: e.day_range_middle,
68
85
  day_hidden: e.day_hidden,
69
- caption_end: S ? "" : e.caption_end
86
+ caption_end: v ? "" : e.caption_end
70
87
  },
71
88
  components: {
72
- MonthCaption: (n) => /* @__PURE__ */ r(O, {
89
+ MonthCaption: (n) => /* @__PURE__ */ i(O, {
73
90
  ...n,
74
91
  onClose: m
75
92
  }),
76
- MonthsDropdown: Y,
77
- YearsDropdown: F
93
+ MonthsDropdown: x,
94
+ YearsDropdown: N
78
95
  },
79
- footer: /* @__PURE__ */ r(p, {
96
+ footer: /* @__PURE__ */ i(C, {
80
97
  onClose: m,
81
- isNb: _,
98
+ isNb: u,
82
99
  selected: t.selected,
83
- removeSelection: v,
100
+ removeSelection: S,
84
101
  required: t?.required,
85
- setMonth: u,
86
- month: c,
87
- onClear: b
102
+ setMonth: c,
103
+ month: _,
104
+ onClear: f
88
105
  })
89
106
  });
90
107
  };
91
108
  export {
92
- U as StyledDayPicker
109
+ Q as StyledDayPicker
93
110
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.20.0",
6
+ "version": "3.20.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",