mimir-ui-kit 1.43.17 → 1.43.18
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.d.ts +8 -0
- package/dist/components/DatePicker/DatePicker.js +296 -185
- package/dist/components/DatePicker/DatePickerModal.d.ts +2 -1
- package/dist/components/DatePicker/DatePickerModal.js +62 -61
- package/dist/components/DatePicker/MonthPickerModal.d.ts +2 -1
- package/dist/components/DatePicker/MonthPickerModal.js +50 -49
- package/package.json +1 -1
@@ -25,6 +25,10 @@ export type TProps = {
|
|
25
25
|
* Значение типа модального окна календаря
|
26
26
|
*/
|
27
27
|
type?: 'days' | 'months' | 'years';
|
28
|
+
/**
|
29
|
+
* Формат отображения даты в инпуте
|
30
|
+
*/
|
31
|
+
dateFormat?: 'full' | 'month' | 'year';
|
28
32
|
/**
|
29
33
|
* Флаг отключения компонента
|
30
34
|
*/
|
@@ -99,6 +103,10 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
|
|
99
103
|
* Значение типа модального окна календаря
|
100
104
|
*/
|
101
105
|
type?: "days" | "months" | "years";
|
106
|
+
/**
|
107
|
+
* Формат отображения даты в инпуте
|
108
|
+
*/
|
109
|
+
dateFormat?: "full" | "month" | "year";
|
102
110
|
/**
|
103
111
|
* Флаг отключения компонента
|
104
112
|
*/
|
@@ -1,242 +1,353 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { c as
|
3
|
-
import { memo as
|
4
|
-
import { MAX_DAY as
|
5
|
-
import { DatePickerModal as
|
6
|
-
import { MonthPickerModal as
|
7
|
-
import { c as
|
8
|
-
import { formatDatePart as
|
1
|
+
import { jsxs as Z, jsx as D } from "react/jsx-runtime";
|
2
|
+
import { c as G } from "../../index-DIxK0V-G.js";
|
3
|
+
import { memo as dt, forwardRef as Dt, useState as b, useEffect as H } from "react";
|
4
|
+
import { months as $, MAX_DAY as wt, MAX_MONTH as kt, DATE_LENGTH as Nt } from "./constants.js";
|
5
|
+
import { DatePickerModal as ut } from "./DatePickerModal.js";
|
6
|
+
import { MonthPickerModal as ht } from "./MonthPickerModal.js";
|
7
|
+
import { c as y } from "../../styles.module-Cuqm31CO.js";
|
8
|
+
import { formatDatePart as z } from "./utils.js";
|
9
9
|
import { YearPickerModal as Mt } from "./YearPickerModal.js";
|
10
|
-
import { useClickOutside as
|
11
|
-
import { Icon as
|
12
|
-
import { formating as
|
13
|
-
import { I as
|
14
|
-
import { EInputStatus as
|
15
|
-
const
|
16
|
-
|
10
|
+
import { useClickOutside as gt } from "../../hooks/useClickOutside/useClickOutside.js";
|
11
|
+
import { Icon as C } from "../../icons/Icon.js";
|
12
|
+
import { formating as p } from "../../utils/index.js";
|
13
|
+
import { I as Tt } from "../../Input-BU_6U1CW.js";
|
14
|
+
import { EInputStatus as bt, EInputSize as R } from "../Input/constants.js";
|
15
|
+
const $t = dt(
|
16
|
+
Dt(
|
17
17
|
({
|
18
|
-
size:
|
19
|
-
value:
|
20
|
-
onChangeValue:
|
21
|
-
name:
|
22
|
-
before:
|
23
|
-
type:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
18
|
+
size: j,
|
19
|
+
value: k,
|
20
|
+
onChangeValue: a,
|
21
|
+
name: w,
|
22
|
+
before: h,
|
23
|
+
type: n = "days",
|
24
|
+
dateFormat: N = "full",
|
25
|
+
error: v,
|
26
|
+
onError: M,
|
27
|
+
onBlur: m,
|
28
|
+
validateImmediately: L,
|
29
|
+
variant: B,
|
30
|
+
disabled: _ = !1,
|
31
|
+
editable: A = !1,
|
32
|
+
openOnInput: W = !0,
|
33
|
+
sendIntermediateValues: V = !1,
|
34
|
+
disableFuture: q = !1,
|
35
|
+
disablePast: E = !1,
|
36
|
+
disabledDate: O,
|
37
|
+
validRange: o,
|
38
|
+
...S
|
39
|
+
}, tt) => {
|
40
|
+
const [Y, d] = b(!1), [U, l] = b(n), [f, g] = b(
|
41
|
+
() => k && !isNaN(new Date(k).getTime()) ? new Date(k) : void 0
|
42
|
+
), [I, X] = b(v), [et, P] = b(""), [st, T] = b();
|
43
|
+
S.status = !!I && bt.Error || S.status, H(() => {
|
44
|
+
X(v);
|
45
|
+
}, [v]), H(() => {
|
46
|
+
g(
|
47
|
+
k && !isNaN(new Date(k).getTime()) ? new Date(k) : void 0
|
47
48
|
);
|
48
|
-
}, [
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
}, [k]), H(() => {
|
50
|
+
if (f && typeof f != "string" && !isNaN(f == null ? void 0 : f.getTime())) {
|
51
|
+
let t = "";
|
52
|
+
switch (N) {
|
53
|
+
case "year": {
|
54
|
+
t = f.getFullYear().toString();
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
case "month": {
|
58
|
+
const s = $[f.getMonth()], e = f.getFullYear();
|
59
|
+
t = `${s} ${e}`;
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
case "full": {
|
63
|
+
t = p.Date(f, "dd/mm/yyyy");
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
default: {
|
67
|
+
t = p.Date(f, "dd/mm/yyyy");
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
P(t);
|
72
|
+
} else
|
73
|
+
P("");
|
74
|
+
}, [f, N]);
|
75
|
+
const J = k && new Date(k).getTime;
|
76
|
+
H(() => {
|
77
|
+
L && (J ? (X(!1), M == null || M({ name: w, active: !1 })) : (X(!0), M == null || M({ name: w, active: !0 })));
|
78
|
+
}, [L, w, J]), gt({
|
79
|
+
isActive: Y,
|
56
80
|
setActive: (t) => {
|
57
|
-
|
81
|
+
d(t), l(n), t || T(void 0);
|
58
82
|
},
|
59
|
-
className:
|
83
|
+
className: y["calendar-block"]
|
60
84
|
});
|
61
|
-
const
|
62
|
-
!
|
63
|
-
},
|
64
|
-
const
|
65
|
-
if (t.setHours(0, 0, 0, 0),
|
85
|
+
const rt = () => {
|
86
|
+
!_ && (W || !A) && d(!0);
|
87
|
+
}, K = (t) => {
|
88
|
+
const s = t.getTime();
|
89
|
+
if (t.setHours(0, 0, 0, 0), h && (typeof h == "string" ? new Date(h) : h).getTime() > s)
|
66
90
|
return !1;
|
67
|
-
if (W) {
|
68
|
-
const i = /* @__PURE__ */ new Date();
|
69
|
-
if (i.setHours(0, 0, 0, 0), t.getTime() > i.getTime()) return !1;
|
70
|
-
}
|
71
91
|
if (q) {
|
72
|
-
const
|
73
|
-
if (
|
92
|
+
const e = /* @__PURE__ */ new Date();
|
93
|
+
if (e.setHours(0, 0, 0, 0), t.getTime() > e.getTime()) return !1;
|
94
|
+
}
|
95
|
+
if (E) {
|
96
|
+
const e = /* @__PURE__ */ new Date();
|
97
|
+
if (e.setHours(0, 0, 0, 0), s < e.getTime()) return !1;
|
74
98
|
}
|
75
|
-
if (
|
76
|
-
if (
|
77
|
-
let
|
78
|
-
typeof
|
79
|
-
new Date(
|
80
|
-
typeof
|
81
|
-
] :
|
82
|
-
|
83
|
-
typeof
|
99
|
+
if (O && O(t)) return !1;
|
100
|
+
if (o) {
|
101
|
+
let e;
|
102
|
+
typeof o[0] == "string" ? e = [
|
103
|
+
new Date(o[0]),
|
104
|
+
typeof o[1] == "string" ? new Date(o[1]) : o[1]
|
105
|
+
] : e = [
|
106
|
+
o[0],
|
107
|
+
typeof o[1] == "string" ? new Date(o[1]) : o[1]
|
84
108
|
];
|
85
|
-
const [
|
86
|
-
if (
|
109
|
+
const [i, r] = e, c = new Date(i), u = new Date(r);
|
110
|
+
if (c.setHours(0, 0, 0, 0), u.setHours(23, 59, 59, 999), t < c || t > u) return !1;
|
87
111
|
}
|
88
112
|
return !0;
|
89
|
-
},
|
90
|
-
isNaN(t.getTime())
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
113
|
+
}, at = (t) => {
|
114
|
+
if (!isNaN(t.getTime())) {
|
115
|
+
g(t), T(void 0);
|
116
|
+
let e = "";
|
117
|
+
switch (N) {
|
118
|
+
case "year": {
|
119
|
+
e = t.getFullYear().toString();
|
120
|
+
break;
|
121
|
+
}
|
122
|
+
case "month": {
|
123
|
+
const i = $[t.getMonth()], r = t.getFullYear();
|
124
|
+
e = `${i} ${r}`;
|
125
|
+
break;
|
126
|
+
}
|
127
|
+
case "full": {
|
128
|
+
e = p.Date(t, "yyyy-mm-dd");
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
default: {
|
132
|
+
e = p.Date(t, "yyyy-mm-dd");
|
133
|
+
break;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
a == null || a({
|
137
|
+
value: e,
|
138
|
+
name: w
|
139
|
+
});
|
140
|
+
}
|
141
|
+
U === "years" && (n === "years" ? (d(!1), l(n)) : l("months")), U === "months" && (n === "months" ? (d(!1), l(n)) : l("days")), g(t);
|
142
|
+
let s = "";
|
143
|
+
switch (N) {
|
144
|
+
case "year": {
|
145
|
+
s = t.getFullYear().toString();
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
case "month": {
|
149
|
+
const e = $[t.getMonth()], i = t.getFullYear();
|
150
|
+
s = `${e} ${i}`;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
case "full": {
|
154
|
+
s = p.Date(t, "yyyy-mm-dd");
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
default: {
|
158
|
+
s = p.Date(t, "yyyy-mm-dd");
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
a == null || a({
|
163
|
+
value: s,
|
164
|
+
name: w
|
165
|
+
}), m == null || m(s);
|
166
|
+
}, ct = (t) => {
|
167
|
+
const s = f || /* @__PURE__ */ new Date(), e = s.getDate(), i = s.getMonth() + 1, r = new Date(t, i - 1, e);
|
168
|
+
if (r.getFullYear() === t && r.getMonth() === i - 1 && r.getDate() === e && K(r)) {
|
169
|
+
g(r), T(void 0);
|
170
|
+
let c = "";
|
171
|
+
switch (N) {
|
172
|
+
case "year": {
|
173
|
+
c = t.toString();
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
case "month": {
|
177
|
+
c = `${$[i - 1]} ${t}`;
|
178
|
+
break;
|
179
|
+
}
|
180
|
+
case "full": {
|
181
|
+
c = p.Date(r, "yyyy-mm-dd");
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
default: {
|
185
|
+
c = p.Date(r, "yyyy-mm-dd");
|
186
|
+
break;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (a == null || a({
|
190
|
+
value: c,
|
191
|
+
name: w
|
192
|
+
}), m == null || m(c), n === "years") {
|
193
|
+
d(!1), l(n);
|
105
194
|
return;
|
106
195
|
}
|
107
196
|
} else
|
108
|
-
|
109
|
-
|
110
|
-
},
|
111
|
-
const
|
112
|
-
if (
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
197
|
+
T(new Date(t, i - 1, 1));
|
198
|
+
n === "years" ? (d(!1), l(n)) : l("months");
|
199
|
+
}, it = (t, s) => {
|
200
|
+
const i = (f || /* @__PURE__ */ new Date()).getDate(), r = new Date(t, s - 1, i);
|
201
|
+
if (r.getFullYear() === t && r.getMonth() === s - 1 && r.getDate() === i && K(r)) {
|
202
|
+
g(r), T(void 0);
|
203
|
+
let c = "";
|
204
|
+
switch (N) {
|
205
|
+
case "year": {
|
206
|
+
c = t.toString();
|
207
|
+
break;
|
208
|
+
}
|
209
|
+
case "month": {
|
210
|
+
c = `${$[s - 1]} ${t}`;
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
case "full": {
|
214
|
+
c = p.Date(r, "yyyy-mm-dd");
|
215
|
+
break;
|
216
|
+
}
|
217
|
+
default: {
|
218
|
+
c = p.Date(r, "yyyy-mm-dd");
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
if (a == null || a({
|
223
|
+
value: c,
|
224
|
+
name: w
|
225
|
+
}), m == null || m(c), n === "months") {
|
226
|
+
d(!1), l(n);
|
118
227
|
return;
|
119
228
|
}
|
120
229
|
} else
|
121
|
-
|
122
|
-
|
123
|
-
},
|
124
|
-
if (
|
125
|
-
const
|
126
|
-
if (
|
127
|
-
|
230
|
+
T(new Date(t, s - 1, 1));
|
231
|
+
n === "months" ? (d(!1), l(n)) : l("days");
|
232
|
+
}, ot = (t) => {
|
233
|
+
if (A) {
|
234
|
+
const s = t.target.value.replace(/[^\d]/g, "");
|
235
|
+
if (s.length === 0)
|
236
|
+
P(""), a == null || a({ value: "", name: w }), m == null || m("");
|
128
237
|
else {
|
129
|
-
const [
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
],
|
134
|
-
if (
|
135
|
-
const
|
136
|
-
|
137
|
-
value:
|
138
|
-
name:
|
238
|
+
const [e, i, r] = [
|
239
|
+
z(s.substring(0, 2), wt),
|
240
|
+
z(s.substring(2, 4), kt),
|
241
|
+
s.substring(4, 8)
|
242
|
+
], c = [e, i, r].filter(Boolean).join("/");
|
243
|
+
if (P(c), V) {
|
244
|
+
const u = r ? `${r}-${i || "00"}-${e || "00"}` : [e, i, r].filter(Boolean).join("-");
|
245
|
+
a == null || a({
|
246
|
+
value: u,
|
247
|
+
name: w
|
139
248
|
});
|
140
249
|
}
|
141
|
-
if (
|
142
|
-
const
|
143
|
-
`${
|
250
|
+
if (c.length === Nt) {
|
251
|
+
const u = parseInt(r), x = /* @__PURE__ */ new Date(
|
252
|
+
`${u}-${i.padStart(2, "0")}-${e.padStart(2, "0")}`
|
144
253
|
);
|
145
|
-
isNaN(
|
146
|
-
value:
|
147
|
-
name:
|
148
|
-
}),
|
254
|
+
isNaN(x.getTime()) || (g(x), a == null || a({
|
255
|
+
value: p.Date(x, "yyyy-mm-dd"),
|
256
|
+
name: w
|
257
|
+
}), m == null || m(p.Date(x, "yyyy-mm-dd")));
|
149
258
|
}
|
150
259
|
}
|
151
260
|
}
|
152
|
-
},
|
153
|
-
let
|
154
|
-
if (
|
155
|
-
let t,
|
156
|
-
typeof
|
261
|
+
}, mt = G(y.wrapper, Y && y.active), ft = G(y.input, y.inputBorderControl);
|
262
|
+
let Q;
|
263
|
+
if (o) {
|
264
|
+
let t, s;
|
265
|
+
typeof o[0] == "string" ? t = new Date(o[0]) : t = o[0], typeof o[1] == "string" ? s = new Date(o[1]) : s = o[1], Q = [t, s];
|
157
266
|
}
|
158
|
-
const
|
159
|
-
onChangeValue:
|
160
|
-
date:
|
161
|
-
selectedDate:
|
162
|
-
before: typeof
|
163
|
-
onChangeType:
|
164
|
-
setIsActive:
|
165
|
-
disableFuture:
|
166
|
-
disablePast:
|
167
|
-
disabledDate:
|
168
|
-
validRange:
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
267
|
+
const F = {
|
268
|
+
onChangeValue: at,
|
269
|
+
date: st || f || /* @__PURE__ */ new Date(),
|
270
|
+
selectedDate: f,
|
271
|
+
before: typeof h == "string" ? new Date(h) : h,
|
272
|
+
onChangeType: l,
|
273
|
+
setIsActive: d,
|
274
|
+
disableFuture: q,
|
275
|
+
disablePast: E,
|
276
|
+
disabledDate: O,
|
277
|
+
validRange: Q,
|
278
|
+
dateFormat: N
|
279
|
+
}, nt = {
|
280
|
+
...F,
|
281
|
+
onChangeMonth: it,
|
282
|
+
dateFormat: N
|
283
|
+
}, lt = {
|
284
|
+
...F,
|
285
|
+
onChangeYear: ct
|
286
|
+
}, yt = (() => {
|
287
|
+
switch (U) {
|
177
288
|
case "months":
|
178
|
-
return () => /* @__PURE__ */
|
289
|
+
return () => /* @__PURE__ */ D(ht, { ...nt });
|
179
290
|
case "years":
|
180
|
-
return () => /* @__PURE__ */
|
291
|
+
return () => /* @__PURE__ */ D(Mt, { ...lt });
|
181
292
|
default:
|
182
|
-
return () => /* @__PURE__ */
|
293
|
+
return () => /* @__PURE__ */ D(ut, { ...F });
|
183
294
|
}
|
184
|
-
})(),
|
185
|
-
|
186
|
-
}, className:
|
187
|
-
|
295
|
+
})(), pt = ({ isActive: t }) => /* @__PURE__ */ D("button", { onClick: (e) => {
|
296
|
+
e.stopPropagation(), _ || d(!t);
|
297
|
+
}, className: y["icon-button"], children: t ? /* @__PURE__ */ D(
|
298
|
+
C,
|
188
299
|
{
|
189
|
-
iconName:
|
300
|
+
iconName: j === R.S ? "DropdownArrowUp16px" : "DropdownArrowUp24px"
|
190
301
|
}
|
191
|
-
) : /* @__PURE__ */
|
192
|
-
|
302
|
+
) : /* @__PURE__ */ D(
|
303
|
+
C,
|
193
304
|
{
|
194
|
-
iconName:
|
305
|
+
iconName: j === R.S ? "DropdownArrowBottom16px" : "DropdownArrowDown24px"
|
195
306
|
}
|
196
307
|
) });
|
197
|
-
return /* @__PURE__ */
|
198
|
-
/* @__PURE__ */
|
199
|
-
/* @__PURE__ */
|
308
|
+
return /* @__PURE__ */ Z("div", { className: y["input-field-group-datePicker"], children: [
|
309
|
+
/* @__PURE__ */ Z("div", { className: mt, "data-disabled": _, children: [
|
310
|
+
/* @__PURE__ */ D(
|
200
311
|
"div",
|
201
312
|
{
|
202
313
|
role: "button",
|
203
|
-
"data-status":
|
204
|
-
className:
|
205
|
-
[
|
314
|
+
"data-status": S.status,
|
315
|
+
className: G(y["date-wrapper"], {
|
316
|
+
[y.editable]: A
|
206
317
|
}),
|
207
|
-
onClick:
|
208
|
-
children: /* @__PURE__ */
|
209
|
-
|
318
|
+
onClick: rt,
|
319
|
+
children: /* @__PURE__ */ D(
|
320
|
+
Tt,
|
210
321
|
{
|
211
|
-
ref:
|
212
|
-
className:
|
213
|
-
wrapperClassName:
|
214
|
-
size:
|
322
|
+
ref: tt,
|
323
|
+
className: ft,
|
324
|
+
wrapperClassName: y["input-wrapper"],
|
325
|
+
size: j,
|
215
326
|
type: "text",
|
216
|
-
variant:
|
217
|
-
value:
|
218
|
-
onChange:
|
327
|
+
variant: B,
|
328
|
+
value: et,
|
329
|
+
onChange: ot,
|
219
330
|
rightAddon: {
|
220
331
|
addonType: "react-node",
|
221
|
-
addonContent: /* @__PURE__ */
|
332
|
+
addonContent: /* @__PURE__ */ D(pt, { isActive: Y })
|
222
333
|
},
|
223
|
-
rightSlotClassName:
|
334
|
+
rightSlotClassName: y["right-slot"],
|
224
335
|
onFocus: () => {
|
225
|
-
|
336
|
+
W && !A && d(!0);
|
226
337
|
},
|
227
|
-
...
|
338
|
+
...S
|
228
339
|
}
|
229
340
|
)
|
230
341
|
}
|
231
342
|
),
|
232
|
-
|
343
|
+
Y && /* @__PURE__ */ D(yt, {})
|
233
344
|
] }),
|
234
|
-
|
345
|
+
I && typeof I == "string" && /* @__PURE__ */ D("div", { className: y.textError, children: I })
|
235
346
|
] });
|
236
347
|
}
|
237
348
|
)
|
238
349
|
);
|
239
|
-
|
350
|
+
$t.displayName = "DatePicker";
|
240
351
|
export {
|
241
|
-
|
352
|
+
$t as DatePicker
|
242
353
|
};
|
@@ -9,6 +9,7 @@ type TProps = {
|
|
9
9
|
disablePast?: boolean;
|
10
10
|
disabledDate?: (date: Date) => boolean;
|
11
11
|
validRange?: [Date, Date];
|
12
|
+
dateFormat?: 'full' | 'month' | 'year';
|
12
13
|
};
|
13
|
-
export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange }: TProps) => import("react/jsx-runtime").JSX.Element;
|
14
|
+
export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange, dateFormat }: TProps) => import("react/jsx-runtime").JSX.Element;
|
14
15
|
export {};
|
@@ -1,103 +1,104 @@
|
|
1
1
|
import { jsxs as u, jsx as a } from "react/jsx-runtime";
|
2
|
-
import { c as
|
3
|
-
import { useState as
|
4
|
-
import { week as
|
5
|
-
import { useDatePickerPosition as
|
2
|
+
import { c as A } from "../../index-DIxK0V-G.js";
|
3
|
+
import { useState as U } from "react";
|
4
|
+
import { week as V, COUNT_WORK_DAYS as W } from "./constants.js";
|
5
|
+
import { useDatePickerPosition as E } from "./hooks.js";
|
6
6
|
import { c as n } from "../../styles.module-Cuqm31CO.js";
|
7
|
-
import { getUpdateDate as
|
8
|
-
import { Icon as
|
7
|
+
import { getUpdateDate as B } from "./utils.js";
|
8
|
+
import { Icon as K } from "../../icons/Icon.js";
|
9
9
|
import { formating as m } from "../../utils/index.js";
|
10
|
-
import { Button as
|
11
|
-
import { parseDate as
|
12
|
-
const
|
10
|
+
import { Button as H } from "../Button/Button.js";
|
11
|
+
import { parseDate as I } from "../../utils/formating/Date.js";
|
12
|
+
const mt = ({
|
13
13
|
date: i,
|
14
14
|
selectedDate: d,
|
15
|
-
onChangeValue:
|
16
|
-
setIsActive:
|
17
|
-
before:
|
15
|
+
onChangeValue: O,
|
16
|
+
setIsActive: S,
|
17
|
+
before: g,
|
18
18
|
onChangeType: D,
|
19
|
-
disableFuture:
|
20
|
-
disablePast:
|
21
|
-
disabledDate:
|
22
|
-
validRange: N
|
19
|
+
disableFuture: T = !1,
|
20
|
+
disablePast: _ = !1,
|
21
|
+
disabledDate: p,
|
22
|
+
validRange: N,
|
23
|
+
dateFormat: w
|
23
24
|
}) => {
|
24
|
-
var
|
25
|
+
var k;
|
25
26
|
i = isNaN(new Date(i).getTime()) ? /* @__PURE__ */ new Date() : i;
|
26
|
-
const l =
|
27
|
+
const l = I(i), f = d ? I(d) : l, y = {
|
27
28
|
y: f.getFullYear(),
|
28
29
|
d: f.getDate(),
|
29
30
|
m: f.getMonth() + 1
|
30
|
-
},
|
31
|
+
}, v = {
|
31
32
|
y: l.getFullYear(),
|
32
33
|
d: l.getDate(),
|
33
34
|
m: l.getMonth() + 1
|
34
|
-
}, [r, b] =
|
35
|
+
}, [r, b] = U({ y: v.y, m: v.m }), j = E([r]), C = (t) => {
|
35
36
|
let e = t.getDay();
|
36
37
|
return e === 0 && (e = 7), e - 1;
|
37
|
-
},
|
38
|
+
}, x = r.m - 1, c = new Date(r.y, x), h = [], M = (() => {
|
38
39
|
const t = new Date(c);
|
39
40
|
t.setDate(t.getDate() - 1);
|
40
41
|
const e = t.getDate(), o = [];
|
41
|
-
for (let s = 0; s <
|
42
|
+
for (let s = 0; s < C(c); s++)
|
42
43
|
o.push(e - s);
|
43
44
|
return o.reverse(), o;
|
44
45
|
})();
|
45
|
-
for (; c.getMonth() ===
|
46
|
-
|
47
|
-
const
|
48
|
-
const e = 42 - (
|
46
|
+
for (; c.getMonth() === x; )
|
47
|
+
h.push(c.getDate()), c.setDate(c.getDate() + 1);
|
48
|
+
const L = (() => {
|
49
|
+
const e = 42 - (M.length + h.length), o = [];
|
49
50
|
for (let s = 1; s <= e; s++)
|
50
51
|
o.push(s);
|
51
52
|
return o;
|
52
|
-
})(),
|
53
|
-
|
54
|
-
},
|
55
|
-
b(
|
56
|
-
},
|
57
|
-
b(
|
58
|
-
},
|
53
|
+
})(), Y = () => {
|
54
|
+
S(!1);
|
55
|
+
}, z = () => {
|
56
|
+
b(B(r.m + 1, r.y));
|
57
|
+
}, F = () => {
|
58
|
+
b(B(r.m - 1, r.y));
|
59
|
+
}, $ = (t) => {
|
59
60
|
const e = new Date(t);
|
60
|
-
if (e.setHours(0, 0, 0, 0),
|
61
|
+
if (e.setHours(0, 0, 0, 0), g && g.getTime() > t)
|
61
62
|
return !0;
|
62
|
-
if (
|
63
|
+
if (T) {
|
63
64
|
const o = /* @__PURE__ */ new Date();
|
64
65
|
if (o.setHours(0, 0, 0, 0), e.getTime() > o.getTime()) return !0;
|
65
66
|
}
|
66
|
-
if (
|
67
|
+
if (_) {
|
67
68
|
const o = /* @__PURE__ */ new Date();
|
68
69
|
if (o.setHours(0, 0, 0, 0), t < o.getTime()) return !0;
|
69
70
|
}
|
70
|
-
if (
|
71
|
+
if (p && p(e)) return !0;
|
71
72
|
if (N) {
|
72
|
-
const [o, s] = N,
|
73
|
-
if (o.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0),
|
73
|
+
const [o, s] = N, P = new Date(t);
|
74
|
+
if (o.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), P < o || P > s) return !0;
|
74
75
|
}
|
75
76
|
return !1;
|
76
|
-
},
|
77
|
-
|
77
|
+
}, G = (t) => {
|
78
|
+
$(
|
78
79
|
(/* @__PURE__ */ new Date(
|
79
80
|
`${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
|
80
81
|
)).getTime()
|
81
|
-
) || (
|
82
|
+
) || (O(
|
82
83
|
/* @__PURE__ */ new Date(
|
83
84
|
`${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
|
84
85
|
)
|
85
|
-
),
|
86
|
+
), Y());
|
86
87
|
};
|
87
88
|
return /* @__PURE__ */ u(
|
88
89
|
"div",
|
89
90
|
{
|
90
91
|
className: n["calendar-block"],
|
91
|
-
ref:
|
92
|
+
ref: j,
|
92
93
|
"data-testid": "calendar-modal",
|
93
94
|
children: [
|
94
95
|
/* @__PURE__ */ u("div", { className: n.h, children: [
|
95
96
|
/* @__PURE__ */ a(
|
96
|
-
|
97
|
+
H,
|
97
98
|
{
|
98
99
|
isIconButton: !0,
|
99
100
|
iconName: "DropdownArrowLeft16px",
|
100
|
-
onClick:
|
101
|
+
onClick: F,
|
101
102
|
variant: "secondary-gray",
|
102
103
|
size: "l"
|
103
104
|
}
|
@@ -107,46 +108,46 @@ const at = ({
|
|
107
108
|
{
|
108
109
|
type: "button",
|
109
110
|
className: n.d,
|
110
|
-
onClick: () => D == null ? void 0 : D("months"),
|
111
111
|
"data-testid": "month-year-button",
|
112
|
+
onClick: w === "month" ? void 0 : () => D == null ? void 0 : D("months"),
|
112
113
|
children: [
|
113
|
-
(
|
114
|
+
(k = m.Month(r.m)) == null ? void 0 : k.name,
|
114
115
|
"’",
|
115
116
|
r.y.toString().slice(-2),
|
116
|
-
/* @__PURE__ */ a(
|
117
|
+
w !== "month" && /* @__PURE__ */ a(K, { iconName: "DropdownArrowBottom16px" })
|
117
118
|
]
|
118
119
|
}
|
119
120
|
),
|
120
121
|
/* @__PURE__ */ a(
|
121
|
-
|
122
|
+
H,
|
122
123
|
{
|
123
124
|
isIconButton: !0,
|
124
125
|
iconName: "DropdownArrowRight16px",
|
125
|
-
onClick:
|
126
|
+
onClick: z,
|
126
127
|
variant: "secondary-gray",
|
127
128
|
size: "l"
|
128
129
|
}
|
129
130
|
)
|
130
131
|
] }),
|
131
132
|
/* @__PURE__ */ u("div", { className: n.b, children: [
|
132
|
-
|
133
|
+
V.map((t, e) => /* @__PURE__ */ a(
|
133
134
|
"div",
|
134
135
|
{
|
135
|
-
className:
|
136
|
-
[n.orange]: e >
|
136
|
+
className: A(n.m, {
|
137
|
+
[n.orange]: e > W
|
137
138
|
}),
|
138
139
|
children: t
|
139
140
|
},
|
140
141
|
`v${e}`
|
141
142
|
)),
|
142
|
-
|
143
|
-
|
143
|
+
M.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e)),
|
144
|
+
h.map((t, e) => /* @__PURE__ */ a(
|
144
145
|
"button",
|
145
146
|
{
|
146
147
|
type: "button",
|
147
|
-
onClick: () =>
|
148
|
-
className:
|
149
|
-
|
148
|
+
onClick: () => G(t),
|
149
|
+
className: A(
|
150
|
+
$(
|
150
151
|
(/* @__PURE__ */ new Date(
|
151
152
|
`${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
|
152
153
|
)).getTime()
|
@@ -159,12 +160,12 @@ const at = ({
|
|
159
160
|
},
|
160
161
|
e
|
161
162
|
)),
|
162
|
-
|
163
|
+
L.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e))
|
163
164
|
] })
|
164
165
|
]
|
165
166
|
}
|
166
167
|
);
|
167
168
|
};
|
168
169
|
export {
|
169
|
-
|
170
|
+
mt as DatePickerModal
|
170
171
|
};
|
@@ -9,6 +9,7 @@ type TProps = {
|
|
9
9
|
disablePast?: boolean;
|
10
10
|
disabledDate?: (date: Date) => boolean;
|
11
11
|
validRange?: [Date, Date];
|
12
|
+
dateFormat?: 'full' | 'month' | 'year';
|
12
13
|
};
|
13
|
-
export declare const MonthPickerModal: ({ date, selectedDate, onChangeValue, before, onChangeType, onChangeMonth, disableFuture, disablePast, disabledDate, validRange }: TProps) => import("react/jsx-runtime").JSX.Element;
|
14
|
+
export declare const MonthPickerModal: ({ date, selectedDate, onChangeValue, before, onChangeType, onChangeMonth, disableFuture, disablePast, disabledDate, validRange, dateFormat }: TProps) => import("react/jsx-runtime").JSX.Element;
|
14
15
|
export {};
|
@@ -1,66 +1,67 @@
|
|
1
1
|
import { jsxs as w, jsx as f } from "react/jsx-runtime";
|
2
|
-
import { c as
|
3
|
-
import { useState as
|
4
|
-
import { months as
|
5
|
-
import { useDatePickerPosition as
|
2
|
+
import { c as _ } from "../../index-DIxK0V-G.js";
|
3
|
+
import { useState as C } from "react";
|
4
|
+
import { months as L } from "./constants.js";
|
5
|
+
import { useDatePickerPosition as b } from "./hooks.js";
|
6
6
|
import { c } from "../../styles.module-Cuqm31CO.js";
|
7
|
-
import { Icon as
|
8
|
-
import { formating as
|
9
|
-
import { Button as
|
10
|
-
const
|
11
|
-
date:
|
7
|
+
import { Icon as q } from "../../icons/Icon.js";
|
8
|
+
import { formating as P } from "../../utils/index.js";
|
9
|
+
import { Button as A } from "../Button/Button.js";
|
10
|
+
const T = ({
|
11
|
+
date: F,
|
12
12
|
selectedDate: D,
|
13
|
-
onChangeValue:
|
13
|
+
onChangeValue: G,
|
14
14
|
before: m,
|
15
15
|
onChangeType: y,
|
16
16
|
onChangeMonth: g,
|
17
|
-
disableFuture:
|
18
|
-
disablePast:
|
17
|
+
disableFuture: I = !1,
|
18
|
+
disablePast: N = !1,
|
19
19
|
disabledDate: u,
|
20
|
-
validRange:
|
20
|
+
validRange: h,
|
21
|
+
dateFormat: M
|
21
22
|
}) => {
|
22
|
-
const
|
23
|
+
const O = b(), d = new Date(F), p = D ? new Date(D) : d, k = {
|
23
24
|
y: p.getFullYear(),
|
24
25
|
d: p.getDate(),
|
25
26
|
m: p.getMonth() + 1
|
26
|
-
},
|
27
|
+
}, x = {
|
27
28
|
y: d.getFullYear(),
|
28
29
|
d: d.getDate(),
|
29
30
|
m: d.getMonth() + 1
|
30
|
-
}, [t,
|
31
|
-
|
32
|
-
},
|
33
|
-
|
34
|
-
},
|
35
|
-
const i = /* @__PURE__ */ new Date(),
|
36
|
-
if (
|
37
|
-
const [
|
31
|
+
}, [t, Y] = C(x.y), S = () => {
|
32
|
+
Y(t + 1);
|
33
|
+
}, $ = () => {
|
34
|
+
Y(t - 1);
|
35
|
+
}, v = (e) => {
|
36
|
+
const i = /* @__PURE__ */ new Date(), r = i.getFullYear(), l = i.getMonth() + 1;
|
37
|
+
if (h) {
|
38
|
+
const [n, a] = h, o = new Date(t, e - 1, 1), s = new Date(t, e, 0);
|
38
39
|
o.setHours(0, 0, 0, 0), s.setHours(23, 59, 59, 999);
|
39
|
-
const
|
40
|
-
|
41
|
-
const
|
42
|
-
if (
|
40
|
+
const B = new Date(n), H = new Date(a);
|
41
|
+
B.setHours(0, 0, 0, 0), H.setHours(23, 59, 59, 999);
|
42
|
+
const z = s < B, R = o > H;
|
43
|
+
if (z || R)
|
43
44
|
return !0;
|
44
45
|
}
|
45
46
|
if (m) {
|
46
|
-
const
|
47
|
-
if (
|
47
|
+
const n = m.getFullYear(), a = m.getMonth() + 1;
|
48
|
+
if (n > t || n === t && a > e)
|
48
49
|
return !0;
|
49
50
|
}
|
50
|
-
if (
|
51
|
+
if (I && (t > r || t === r && e > l) || N && (t < r || t === r && e < l))
|
51
52
|
return !0;
|
52
53
|
if (u) {
|
53
|
-
const
|
54
|
+
const n = new Date(t, e, 0).getDate(), a = [1, Math.ceil(n / 2), n];
|
54
55
|
for (const o of a) {
|
55
56
|
const s = new Date(t, e - 1, o);
|
56
57
|
if (!u(s)) return !1;
|
57
58
|
}
|
58
|
-
for (let o = 2; o <
|
59
|
+
for (let o = 2; o < n; o += 3) {
|
59
60
|
if (a.includes(o)) continue;
|
60
61
|
const s = new Date(t, e - 1, o);
|
61
62
|
if (!u(s)) return !1;
|
62
63
|
}
|
63
|
-
for (let o = 1; o <=
|
64
|
+
for (let o = 1; o <= n; o++) {
|
64
65
|
if (a.includes(o) || (o - 2) % 3 === 0) continue;
|
65
66
|
const s = new Date(t, e - 1, o);
|
66
67
|
if (!u(s)) return !1;
|
@@ -68,21 +69,21 @@ const Z = ({
|
|
68
69
|
return !0;
|
69
70
|
}
|
70
71
|
return !1;
|
71
|
-
},
|
72
|
-
|
72
|
+
}, j = (e) => {
|
73
|
+
v(e) || (g ? g(t, e) : G(
|
73
74
|
/* @__PURE__ */ new Date(
|
74
|
-
`${t}-${
|
75
|
+
`${t}-${P.Number(2, e)}-${P.Number(2, x.d)}`
|
75
76
|
)
|
76
77
|
));
|
77
78
|
};
|
78
|
-
return /* @__PURE__ */ w("div", { className: c["calendar-block"], ref:
|
79
|
+
return /* @__PURE__ */ w("div", { className: c["calendar-block"], ref: O, children: [
|
79
80
|
/* @__PURE__ */ w("div", { className: c.h, children: [
|
80
81
|
/* @__PURE__ */ f(
|
81
|
-
|
82
|
+
A,
|
82
83
|
{
|
83
84
|
isIconButton: !0,
|
84
85
|
iconName: "DropdownArrowLeft16px",
|
85
|
-
onClick:
|
86
|
+
onClick: $,
|
86
87
|
variant: "secondary-gray",
|
87
88
|
size: "l"
|
88
89
|
}
|
@@ -91,36 +92,36 @@ const Z = ({
|
|
91
92
|
"button",
|
92
93
|
{
|
93
94
|
type: "button",
|
94
|
-
onClick: () => y == null ? void 0 : y("years"),
|
95
95
|
className: c.d,
|
96
96
|
"data-testid": "year-button",
|
97
|
+
onClick: M === "month" ? void 0 : () => y == null ? void 0 : y("years"),
|
97
98
|
children: [
|
98
99
|
t.toString(),
|
99
|
-
/* @__PURE__ */ f(
|
100
|
+
M !== "month" && /* @__PURE__ */ f(q, { iconName: "DropdownArrowBottom16px" })
|
100
101
|
]
|
101
102
|
}
|
102
103
|
),
|
103
104
|
/* @__PURE__ */ f(
|
104
|
-
|
105
|
+
A,
|
105
106
|
{
|
106
107
|
isIconButton: !0,
|
107
108
|
iconName: "DropdownArrowRight16px",
|
108
|
-
onClick:
|
109
|
+
onClick: S,
|
109
110
|
variant: "secondary-gray",
|
110
111
|
size: "l"
|
111
112
|
}
|
112
113
|
)
|
113
114
|
] }),
|
114
|
-
/* @__PURE__ */ f("div", { className: c.monthGrid, "data-testid": "month-picker", children:
|
115
|
-
const
|
115
|
+
/* @__PURE__ */ f("div", { className: c.monthGrid, "data-testid": "month-picker", children: L.map((e, i) => {
|
116
|
+
const r = i + 1, l = v(r);
|
116
117
|
return /* @__PURE__ */ f(
|
117
118
|
"button",
|
118
119
|
{
|
119
120
|
type: "button",
|
120
|
-
onClick: () =>
|
121
|
+
onClick: () => j(r),
|
121
122
|
disabled: l,
|
122
|
-
className:
|
123
|
-
[c.current]: D &&
|
123
|
+
className: _(l ? c.m : c.a, {
|
124
|
+
[c.current]: D && k.y === t && k.m === r
|
124
125
|
}),
|
125
126
|
children: e
|
126
127
|
},
|
@@ -130,5 +131,5 @@ const Z = ({
|
|
130
131
|
] });
|
131
132
|
};
|
132
133
|
export {
|
133
|
-
|
134
|
+
T as MonthPickerModal
|
134
135
|
};
|