mimir-ui-kit 1.36.1 → 1.36.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ export type TProps = {
|
|
12
12
|
/**
|
13
13
|
* Функция обратного вызова при потере фокуса компонентом
|
14
14
|
*/
|
15
|
-
onBlur?: (e:
|
15
|
+
onBlur?: (e: string) => void;
|
16
16
|
/**
|
17
17
|
* Функция ограничения выбора даты (до какой даты выбор не доступен)
|
18
18
|
*/
|
@@ -43,7 +43,7 @@ export type TProps = {
|
|
43
43
|
editable?: boolean;
|
44
44
|
} & TInputProps;
|
45
45
|
export type TDatePickerValue = {
|
46
|
-
value?:
|
46
|
+
value?: string;
|
47
47
|
name?: string;
|
48
48
|
};
|
49
49
|
export type TDatePickerOnError = {
|
@@ -62,7 +62,7 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
|
|
62
62
|
/**
|
63
63
|
* Функция обратного вызова при потере фокуса компонентом
|
64
64
|
*/
|
65
|
-
onBlur?: (e:
|
65
|
+
onBlur?: (e: string) => void;
|
66
66
|
/**
|
67
67
|
* Функция ограничения выбора даты (до какой даты выбор не доступен)
|
68
68
|
*/
|
@@ -1,123 +1,123 @@
|
|
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
|
1
|
+
import { jsxs as Q, jsx as g } from "react/jsx-runtime";
|
2
|
+
import { c as v } from "../../index-DIxK0V-G.js";
|
3
|
+
import { memo as W, forwardRef as Z, useState as y, useEffect as w } from "react";
|
4
|
+
import { MAX_DAY as E, MAX_MONTH as B, DATE_LENGTH as V } from "./constants.js";
|
5
|
+
import { DatePickerModal as tt } from "./DatePickerModal.js";
|
6
|
+
import { MonthPickerModal as st } from "./MonthPickerModal.js";
|
7
7
|
import { c as a } from "../../styles.module-Chnn6DA-.js";
|
8
|
-
import { formatDatePart as
|
9
|
-
import { YearPickerModal as
|
10
|
-
import { useClickOutside as
|
11
|
-
import { formating as
|
8
|
+
import { formatDatePart as Y } from "./utils.js";
|
9
|
+
import { YearPickerModal as et } from "./YearPickerModal.js";
|
10
|
+
import { useClickOutside as it } from "../../hooks/useClickOutside/useClickOutside.js";
|
11
|
+
import { formating as d } from "../../utils/index.js";
|
12
12
|
import { I as at } from "../../Input-DlGNMuUD.js";
|
13
13
|
import { EInputStatus as rt } from "../Input/constants.js";
|
14
|
-
const
|
15
|
-
days:
|
16
|
-
months:
|
17
|
-
years:
|
18
|
-
},
|
19
|
-
|
14
|
+
const mt = {
|
15
|
+
days: tt,
|
16
|
+
months: st,
|
17
|
+
years: et
|
18
|
+
}, ot = W(
|
19
|
+
Z(
|
20
20
|
({
|
21
|
-
size:
|
21
|
+
size: $,
|
22
22
|
value: s,
|
23
23
|
onChangeValue: e,
|
24
24
|
name: r,
|
25
|
-
before:
|
26
|
-
type:
|
27
|
-
error:
|
28
|
-
onError:
|
29
|
-
onBlur:
|
30
|
-
validateImmediately:
|
31
|
-
variant:
|
32
|
-
disabled:
|
33
|
-
editable:
|
34
|
-
...
|
35
|
-
},
|
36
|
-
const [n, f] =
|
25
|
+
before: N,
|
26
|
+
type: m = "days",
|
27
|
+
error: T,
|
28
|
+
onError: o,
|
29
|
+
onBlur: c,
|
30
|
+
validateImmediately: x,
|
31
|
+
variant: H,
|
32
|
+
disabled: S = !1,
|
33
|
+
editable: _ = !1,
|
34
|
+
...L
|
35
|
+
}, R) => {
|
36
|
+
const [n, f] = y(!1), [A, p] = y(m), [i, D] = y(
|
37
37
|
() => s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
|
38
|
-
), [
|
39
|
-
|
40
|
-
|
41
|
-
}, [
|
42
|
-
|
38
|
+
), [k, M] = y(T), [X, P] = y("");
|
39
|
+
w(() => {
|
40
|
+
M(T);
|
41
|
+
}, [T]), w(() => {
|
42
|
+
D(
|
43
43
|
s && !isNaN(new Date(s).getTime()) ? new Date(s) : void 0
|
44
44
|
);
|
45
|
-
}, [s]),
|
46
|
-
i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ?
|
45
|
+
}, [s]), w(() => {
|
46
|
+
i && typeof i != "string" && !isNaN(i == null ? void 0 : i.getTime()) ? P(d.Date(i, "dd/mm/yyyy")) : P("");
|
47
47
|
}, [i]);
|
48
|
-
const
|
49
|
-
|
50
|
-
|
51
|
-
}, [
|
48
|
+
const b = s && new Date(s).getTime;
|
49
|
+
w(() => {
|
50
|
+
x && (b ? (M(!1), o == null || o({ name: r, active: !1 })) : (M(!0), o == null || o({ name: r, active: !0 })));
|
51
|
+
}, [x, r, b]), it({
|
52
52
|
isActive: n,
|
53
53
|
setActive: (t) => {
|
54
|
-
f(t), p(
|
54
|
+
f(t), p(m);
|
55
55
|
},
|
56
56
|
className: a["calendar-block"]
|
57
57
|
});
|
58
|
-
const
|
59
|
-
|
60
|
-
}, G = (t) => {
|
61
|
-
isNaN(t.getTime()) || (l(t), e == null || e({ value: t, name: r })), T === "years" && (o === "years" ? (f(!1), p(o)) : p("months")), T === "months" && (o === "months" ? (f(!1), p(o)) : p("days")), l(t), e == null || e({ value: t, name: r }), m == null || m(t);
|
58
|
+
const G = () => {
|
59
|
+
S || f(!0);
|
62
60
|
}, K = (t) => {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
61
|
+
isNaN(t.getTime()) || (D(t), e == null || e({ value: d.Date(t, "yyyy-mm-dd"), name: r })), A === "years" && (m === "years" ? (f(!1), p(m)) : p("months")), A === "months" && (m === "months" ? (f(!1), p(m)) : p("days")), D(t), e == null || e({ value: d.Date(t, "yyyy-mm-dd"), name: r }), c == null || c(d.Date(t, "yyyy-mm-dd"));
|
62
|
+
}, U = (t) => {
|
63
|
+
if (_) {
|
64
|
+
const I = t.target.value.replace(/[^\d]/g, ""), [h, u, O] = [
|
65
|
+
Y(I.substring(0, 2), E),
|
66
|
+
Y(I.substring(2, 4), B),
|
67
|
+
I.substring(4, 8)
|
68
|
+
], j = [h, u, O].filter(Boolean).join("/");
|
69
|
+
if (P(j), j.length === V) {
|
70
|
+
const J = parseInt(O), l = /* @__PURE__ */ new Date(
|
71
|
+
`${J}-${u.padStart(2, "0")}-${h.padStart(2, "0")}`
|
72
72
|
);
|
73
|
-
isNaN(
|
73
|
+
isNaN(l.getTime()) || (D(l), e == null || e({ value: d.Date(l, "yyyy-mm-dd"), name: r }), c == null || c(d.Date(l, "yyyy-mm-dd")));
|
74
74
|
}
|
75
75
|
}
|
76
|
-
},
|
77
|
-
onChangeValue:
|
76
|
+
}, q = v(a.wrapper, n && a.active), z = v(a.input, a.inputBorderControl), C = {
|
77
|
+
onChangeValue: K,
|
78
78
|
date: i || /* @__PURE__ */ new Date(),
|
79
|
-
before: typeof
|
79
|
+
before: typeof N == "string" ? new Date(N) : N,
|
80
80
|
onChangeType: p,
|
81
81
|
setIsActive: f
|
82
|
-
},
|
83
|
-
return /* @__PURE__ */
|
84
|
-
/* @__PURE__ */
|
82
|
+
}, F = mt[A];
|
83
|
+
return /* @__PURE__ */ Q("div", { className: q, "data-disabled": S, children: [
|
84
|
+
/* @__PURE__ */ g(
|
85
85
|
"div",
|
86
86
|
{
|
87
87
|
role: "button",
|
88
|
-
"data-error":
|
89
|
-
className:
|
90
|
-
[a.editable]:
|
88
|
+
"data-error": k,
|
89
|
+
className: v(a["date-wrapper"], {
|
90
|
+
[a.editable]: _
|
91
91
|
}),
|
92
|
-
onClick:
|
93
|
-
children: /* @__PURE__ */
|
92
|
+
onClick: G,
|
93
|
+
children: /* @__PURE__ */ g(
|
94
94
|
at,
|
95
95
|
{
|
96
|
-
ref:
|
97
|
-
className:
|
96
|
+
ref: R,
|
97
|
+
className: z,
|
98
98
|
wrapperClassName: a["input-wrapper"],
|
99
|
-
size:
|
99
|
+
size: $,
|
100
100
|
type: "text",
|
101
|
-
variant:
|
102
|
-
status:
|
103
|
-
value:
|
104
|
-
onChange:
|
101
|
+
variant: H,
|
102
|
+
status: k ? rt.Error : void 0,
|
103
|
+
value: X,
|
104
|
+
onChange: U,
|
105
105
|
rightAddon: {
|
106
106
|
addonType: "icon",
|
107
107
|
addonContent: n ? "DropdownArrowUp24px" : "DropdownArrowDown24px"
|
108
108
|
},
|
109
|
-
"data-error":
|
110
|
-
...
|
109
|
+
"data-error": k,
|
110
|
+
...L
|
111
111
|
}
|
112
112
|
)
|
113
113
|
}
|
114
114
|
),
|
115
|
-
n && /* @__PURE__ */
|
115
|
+
n && /* @__PURE__ */ g(F, { ...C })
|
116
116
|
] });
|
117
117
|
}
|
118
118
|
)
|
119
119
|
);
|
120
|
-
|
120
|
+
ot.displayName = "DatePicker";
|
121
121
|
export {
|
122
|
-
|
122
|
+
ot as DatePicker
|
123
123
|
};
|