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