mimir-ui-kit 1.37.1 → 1.37.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.
- package/dist/components/DatePicker/DatePicker.js +112 -107
- package/package.json +1 -1
|
@@ -1,149 +1,154 @@
|
|
|
1
|
-
import { jsxs as B, jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { memo as V, forwardRef as tt, useState as
|
|
4
|
-
import { MAX_DAY as st, MAX_MONTH as et, DATE_LENGTH as
|
|
5
|
-
import { DatePickerModal as
|
|
6
|
-
import { MonthPickerModal as
|
|
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
|
|
9
|
-
import { YearPickerModal as
|
|
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
|
|
12
|
-
import { formating as
|
|
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
|
|
14
|
+
import { EInputStatus as pt, EInputSize as U } from "../Input/constants.js";
|
|
15
15
|
const dt = {
|
|
16
|
-
days:
|
|
17
|
-
months:
|
|
18
|
-
years:
|
|
19
|
-
},
|
|
16
|
+
days: ot,
|
|
17
|
+
months: rt,
|
|
18
|
+
years: at
|
|
19
|
+
}, ft = V(
|
|
20
20
|
tt(
|
|
21
21
|
({
|
|
22
|
-
size:
|
|
23
|
-
value:
|
|
24
|
-
onChangeValue:
|
|
25
|
-
name:
|
|
26
|
-
before:
|
|
27
|
-
type:
|
|
28
|
-
error:
|
|
29
|
-
onError:
|
|
30
|
-
onBlur:
|
|
31
|
-
validateImmediately:
|
|
32
|
-
variant:
|
|
33
|
-
disabled:
|
|
34
|
-
editable:
|
|
35
|
-
openOnInput:
|
|
36
|
-
...
|
|
37
|
-
},
|
|
38
|
-
const [
|
|
39
|
-
() =>
|
|
40
|
-
), [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}, [
|
|
48
|
-
|
|
49
|
-
}, [
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
isActive:
|
|
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
|
-
|
|
56
|
+
c(t), f(p);
|
|
57
57
|
},
|
|
58
58
|
className: o["calendar-block"]
|
|
59
59
|
});
|
|
60
|
-
const
|
|
61
|
-
!
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
},
|
|
88
|
-
onChangeValue:
|
|
89
|
-
date:
|
|
90
|
-
before: typeof
|
|
91
|
-
onChangeType:
|
|
92
|
-
setIsActive:
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
}, className: o["icon-button"], children: t ? /* @__PURE__ */
|
|
96
|
-
|
|
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:
|
|
103
|
+
iconName: P === U.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
|
|
99
104
|
}
|
|
100
|
-
) : /* @__PURE__ */
|
|
101
|
-
|
|
105
|
+
) : /* @__PURE__ */ m(
|
|
106
|
+
R,
|
|
102
107
|
{
|
|
103
|
-
iconName:
|
|
108
|
+
iconName: P === U.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
|
|
104
109
|
}
|
|
105
110
|
) });
|
|
106
|
-
return /* @__PURE__ */ B("div", { className:
|
|
107
|
-
/* @__PURE__ */
|
|
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":
|
|
112
|
-
className:
|
|
113
|
-
[o.editable]:
|
|
116
|
+
"data-error": _,
|
|
117
|
+
className: b(o["date-wrapper"], {
|
|
118
|
+
[o.editable]: D
|
|
114
119
|
}),
|
|
115
|
-
onClick:
|
|
116
|
-
children: /* @__PURE__ */
|
|
120
|
+
onClick: K,
|
|
121
|
+
children: /* @__PURE__ */ m(
|
|
117
122
|
mt,
|
|
118
123
|
{
|
|
119
|
-
ref:
|
|
120
|
-
className:
|
|
124
|
+
ref: F,
|
|
125
|
+
className: J,
|
|
121
126
|
wrapperClassName: o["input-wrapper"],
|
|
122
|
-
size:
|
|
127
|
+
size: P,
|
|
123
128
|
type: "text",
|
|
124
|
-
variant:
|
|
125
|
-
status:
|
|
126
|
-
value:
|
|
127
|
-
onChange:
|
|
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__ */
|
|
135
|
+
addonContent: /* @__PURE__ */ m(z, { isActive: N })
|
|
131
136
|
},
|
|
132
137
|
onFocus: () => {
|
|
133
|
-
|
|
138
|
+
j && !D && c(!0);
|
|
134
139
|
},
|
|
135
|
-
"data-error":
|
|
136
|
-
...
|
|
140
|
+
"data-error": _,
|
|
141
|
+
...u
|
|
137
142
|
}
|
|
138
143
|
)
|
|
139
144
|
}
|
|
140
145
|
),
|
|
141
|
-
|
|
146
|
+
N && /* @__PURE__ */ m(Z, { ...Q })
|
|
142
147
|
] });
|
|
143
148
|
}
|
|
144
149
|
)
|
|
145
150
|
);
|
|
146
|
-
|
|
151
|
+
ft.displayName = "DatePicker";
|
|
147
152
|
export {
|
|
148
|
-
|
|
153
|
+
ft as DatePicker
|
|
149
154
|
};
|