mimir-ui-kit 1.37.1 → 1.37.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,149 +1,154 @@
1
- import { jsxs as B, jsx as r } from "react/jsx-runtime";
2
- import { c as v } from "../../index-DIxK0V-G.js";
3
- import { memo as V, forwardRef as tt, useState as y, useEffect as I } from "react";
4
- import { MAX_DAY as st, MAX_MONTH as et, DATE_LENGTH as ot } from "./constants.js";
5
- import { DatePickerModal as it } from "./DatePickerModal.js";
6
- import { MonthPickerModal as at } from "./MonthPickerModal.js";
1
+ import { jsxs as B, jsx as m } from "react/jsx-runtime";
2
+ import { c as b } from "../../index-DIxK0V-G.js";
3
+ import { memo as V, forwardRef as tt, useState as w, useEffect as T } from "react";
4
+ import { MAX_DAY as st, MAX_MONTH as et, DATE_LENGTH as it } from "./constants.js";
5
+ import { DatePickerModal as ot } from "./DatePickerModal.js";
6
+ import { MonthPickerModal as rt } from "./MonthPickerModal.js";
7
7
  import { c as o } from "../../styles.module-B3xL6-zc.js";
8
- import { formatDatePart as $ } from "./utils.js";
9
- import { YearPickerModal as rt } from "./YearPickerModal.js";
8
+ import { formatDatePart as L } from "./utils.js";
9
+ import { YearPickerModal as at } from "./YearPickerModal.js";
10
10
  import { useClickOutside as ct } from "../../hooks/useClickOutside/useClickOutside.js";
11
- import { Icon as H } from "../../icons/Icon.js";
12
- import { formating as f } from "../../utils/index.js";
11
+ import { Icon as R } from "../../icons/Icon.js";
12
+ import { formating as y } from "../../utils/index.js";
13
13
  import { I as mt } from "../../Input-BYrIS5GU.js";
14
- import { EInputStatus as pt, EInputSize as L } from "../Input/constants.js";
14
+ import { EInputStatus as pt, EInputSize as U } from "../Input/constants.js";
15
15
  const dt = {
16
- days: it,
17
- months: at,
18
- years: rt
19
- }, nt = V(
16
+ days: ot,
17
+ months: rt,
18
+ years: at
19
+ }, ft = V(
20
20
  tt(
21
21
  ({
22
- size: T,
23
- value: s,
24
- onChangeValue: e,
25
- name: c,
26
- before: P,
27
- type: m = "days",
28
- error: M,
29
- onError: p,
30
- onBlur: d,
31
- validateImmediately: _,
32
- variant: R,
33
- disabled: u = !1,
34
- editable: l = !1,
35
- openOnInput: b = !0,
36
- ...U
37
- }, X) => {
38
- const [w, a] = y(!1), [g, n] = y(m), [i, D] = y(
39
- () => s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
40
- ), [x, S] = y(M), [F, h] = y("");
41
- I(() => {
42
- S(M);
43
- }, [M]), I(() => {
44
- D(
45
- s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
22
+ size: P,
23
+ value: e,
24
+ onChangeValue: s,
25
+ name: a,
26
+ before: M,
27
+ type: p = "days",
28
+ error: v,
29
+ onError: d,
30
+ onBlur: i,
31
+ validateImmediately: h,
32
+ variant: X,
33
+ disabled: x = !1,
34
+ editable: D = !1,
35
+ openOnInput: j = !0,
36
+ ...u
37
+ }, F) => {
38
+ const [N, c] = w(!1), [S, f] = w(p), [r, l] = w(
39
+ () => e && !isNaN(new Date(e).getTime()) ? new Date(e) : void 0
40
+ ), [_, g] = w(v), [G, k] = w("");
41
+ T(() => {
42
+ g(v);
43
+ }, [v]), T(() => {
44
+ l(
45
+ e && !isNaN(new Date(e).getTime()) ? new Date(e) : void 0
46
46
  );
47
- }, [s]), I(() => {
48
- i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ? h(f.Date(i, "dd/mm/yyyy")) : h("");
49
- }, [i]);
50
- const j = s && new Date(s).getTime;
51
- I(() => {
52
- _ && (j ? (S(!1), p == null || p({ name: c, active: !1 })) : (S(!0), p == null || p({ name: c, active: !0 })));
53
- }, [_, c, j]), ct({
54
- isActive: w,
47
+ }, [e]), T(() => {
48
+ r && typeof r != "string" && !isNaN(r == null ? void 0 : r.getTime()) ? k(y.Date(r, "dd/mm/yyyy")) : k("");
49
+ }, [r]);
50
+ const O = e && new Date(e).getTime;
51
+ T(() => {
52
+ h && (O ? (g(!1), d == null || d({ name: a, active: !1 })) : (g(!0), d == null || d({ name: a, active: !0 })));
53
+ }, [h, a, O]), ct({
54
+ isActive: N,
55
55
  setActive: (t) => {
56
- a(t), n(m);
56
+ c(t), f(p);
57
57
  },
58
58
  className: o["calendar-block"]
59
59
  });
60
- const G = () => {
61
- !u && (b || !l) && a(!0);
62
- }, K = (t) => {
63
- isNaN(t.getTime()) || (D(t), e == null || e({
64
- value: f.Date(t, "yyyy-mm-dd"),
65
- name: c
66
- })), g === "years" && (m === "years" ? (a(!1), n(m)) : n("months")), g === "months" && (m === "months" ? (a(!1), n(m)) : n("days")), D(t), e == null || e({
67
- value: f.Date(t, "yyyy-mm-dd"),
68
- name: c
69
- }), d == null || d(f.Date(t, "yyyy-mm-dd"));
60
+ const K = () => {
61
+ !x && (j || !D) && c(!0);
70
62
  }, W = (t) => {
71
- if (l) {
72
- const N = t.target.value.replace(/[^\d]/g, ""), [k, C, O] = [
73
- $(N.substring(0, 2), st),
74
- $(N.substring(2, 4), et),
75
- N.substring(4, 8)
76
- ], Y = [k, C, O].filter(Boolean).join("/");
77
- if (h(Y), Y.length === ot) {
78
- const z = parseInt(O), A = /* @__PURE__ */ new Date(
79
- `${z}-${C.padStart(2, "0")}-${k.padStart(2, "0")}`
80
- );
81
- isNaN(A.getTime()) || (D(A), e == null || e({
82
- value: f.Date(A, "yyyy-mm-dd"),
83
- name: c
84
- }), d == null || d(f.Date(A, "yyyy-mm-dd")));
63
+ isNaN(t.getTime()) || (l(t), s == null || s({
64
+ value: y.Date(t, "yyyy-mm-dd"),
65
+ name: a
66
+ })), S === "years" && (p === "years" ? (c(!1), f(p)) : f("months")), S === "months" && (p === "months" ? (c(!1), f(p)) : f("days")), l(t), s == null || s({
67
+ value: y.Date(t, "yyyy-mm-dd"),
68
+ name: a
69
+ }), i == null || i(y.Date(t, "yyyy-mm-dd"));
70
+ }, q = (t) => {
71
+ if (D) {
72
+ const n = t.target.value.replace(/[^\d]/g, "");
73
+ if (n.length === 0)
74
+ k(""), s == null || s({ value: "", name: a }), i == null || i("");
75
+ else {
76
+ const [A, Y, $] = [
77
+ L(n.substring(0, 2), st),
78
+ L(n.substring(2, 4), et),
79
+ n.substring(4, 8)
80
+ ], H = [A, Y, $].filter(Boolean).join("/");
81
+ if (k(H), H.length === it) {
82
+ const C = parseInt($), I = /* @__PURE__ */ new Date(
83
+ `${C}-${Y.padStart(2, "0")}-${A.padStart(2, "0")}`
84
+ );
85
+ isNaN(I.getTime()) || (l(I), s == null || s({
86
+ value: y.Date(I, "yyyy-mm-dd"),
87
+ name: a
88
+ }), i == null || i(y.Date(I, "yyyy-mm-dd")));
89
+ }
85
90
  }
86
91
  }
87
- }, q = v(o.wrapper, w && o.active), E = v(o.input, o.inputBorderControl), J = {
88
- onChangeValue: K,
89
- date: i || /* @__PURE__ */ new Date(),
90
- before: typeof P == "string" ? new Date(P) : P,
91
- onChangeType: n,
92
- setIsActive: a
93
- }, Q = dt[g], Z = ({ isActive: t }) => /* @__PURE__ */ r("button", { onClick: (k) => {
94
- k.stopPropagation(), u || a(!t);
95
- }, className: o["icon-button"], children: t ? /* @__PURE__ */ r(
96
- H,
92
+ }, E = b(o.wrapper, N && o.active), J = b(o.input, o.inputBorderControl), Q = {
93
+ onChangeValue: W,
94
+ date: r || /* @__PURE__ */ new Date(),
95
+ before: typeof M == "string" ? new Date(M) : M,
96
+ onChangeType: f,
97
+ setIsActive: c
98
+ }, Z = dt[S], z = ({ isActive: t }) => /* @__PURE__ */ m("button", { onClick: (A) => {
99
+ A.stopPropagation(), x || c(!t);
100
+ }, className: o["icon-button"], children: t ? /* @__PURE__ */ m(
101
+ R,
97
102
  {
98
- iconName: T === L.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
103
+ iconName: P === U.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
99
104
  }
100
- ) : /* @__PURE__ */ r(
101
- H,
105
+ ) : /* @__PURE__ */ m(
106
+ R,
102
107
  {
103
- iconName: T === L.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
108
+ iconName: P === U.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
104
109
  }
105
110
  ) });
106
- return /* @__PURE__ */ B("div", { className: q, "data-disabled": u, children: [
107
- /* @__PURE__ */ r(
111
+ return /* @__PURE__ */ B("div", { className: E, "data-disabled": x, children: [
112
+ /* @__PURE__ */ m(
108
113
  "div",
109
114
  {
110
115
  role: "button",
111
- "data-error": x,
112
- className: v(o["date-wrapper"], {
113
- [o.editable]: l
116
+ "data-error": _,
117
+ className: b(o["date-wrapper"], {
118
+ [o.editable]: D
114
119
  }),
115
- onClick: G,
116
- children: /* @__PURE__ */ r(
120
+ onClick: K,
121
+ children: /* @__PURE__ */ m(
117
122
  mt,
118
123
  {
119
- ref: X,
120
- className: E,
124
+ ref: F,
125
+ className: J,
121
126
  wrapperClassName: o["input-wrapper"],
122
- size: T,
127
+ size: P,
123
128
  type: "text",
124
- variant: R,
125
- status: x ? pt.Error : void 0,
126
- value: F,
127
- onChange: W,
129
+ variant: X,
130
+ status: _ ? pt.Error : void 0,
131
+ value: G,
132
+ onChange: q,
128
133
  rightAddon: {
129
134
  addonType: "react-node",
130
- addonContent: /* @__PURE__ */ r(Z, { isActive: w })
135
+ addonContent: /* @__PURE__ */ m(z, { isActive: N })
131
136
  },
132
137
  onFocus: () => {
133
- b && !l && a(!0);
138
+ j && !D && c(!0);
134
139
  },
135
- "data-error": x,
136
- ...U
140
+ "data-error": _,
141
+ ...u
137
142
  }
138
143
  )
139
144
  }
140
145
  ),
141
- w && /* @__PURE__ */ r(Q, { ...J })
146
+ N && /* @__PURE__ */ m(Z, { ...Q })
142
147
  ] });
143
148
  }
144
149
  )
145
150
  );
146
- nt.displayName = "DatePicker";
151
+ ft.displayName = "DatePicker";
147
152
  export {
148
- nt as DatePicker
153
+ ft as DatePicker
149
154
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.37.1",
4
+ "version": "1.37.2",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {