@alphakits/ui 2.5.13 → 2.5.14
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/calendar-input/component.js +21 -19
- package/dist/form/templates/base-form/index.d.ts +2 -2
- package/dist/masked-input/component.js +46 -35
- package/dist/modal/components/modals/modal.js +8 -8
- package/dist/select/components/field/component.js +11 -10
- package/dist/select/components/select-search/index.js +8 -7
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as c, jsxs as q } from "react/jsx-runtime";
|
|
2
2
|
import ye from "classnames";
|
|
3
|
-
import Re, { forwardRef as Te, useState as
|
|
3
|
+
import Re, { forwardRef as Te, useState as N, useEffect as z, useRef as d, useCallback as n } from "react";
|
|
4
4
|
import k from "react-merge-refs";
|
|
5
5
|
import { Calendar as ge } from "../calendar/component.js";
|
|
6
6
|
import { dateInLimits as we } from "../calendar/utils.js";
|
|
@@ -8,8 +8,8 @@ import { MaskedInput as De } from "../masked-input/component.js";
|
|
|
8
8
|
import { Popover as Ie } from "../popover/component.js";
|
|
9
9
|
import { formatDate as G } from "../utils/format-date/index.js";
|
|
10
10
|
import "../toast-notifier/component.js";
|
|
11
|
-
import
|
|
12
|
-
import { isCompleteDateInput as A, parseDateString as E, DATE_MASK as
|
|
11
|
+
import p from "./index.module.css.js";
|
|
12
|
+
import { isCompleteDateInput as A, parseDateString as E, DATE_MASK as Ce, SUPPORTS_INPUT_TYPE_DATE as Ne, NATIVE_DATE_FORMAT as ke } from "./utils.js";
|
|
13
13
|
const xe = Te(
|
|
14
14
|
({
|
|
15
15
|
block: J = !1,
|
|
@@ -35,15 +35,15 @@ const xe = Te(
|
|
|
35
35
|
readOnly: b,
|
|
36
36
|
...ne
|
|
37
37
|
}, j) => {
|
|
38
|
-
const oe = l && l.includes("-") ? l.split("-").reverse().join(".") : l, T = l === void 0, F =
|
|
38
|
+
const oe = l && l.includes("-") ? l.split("-").reverse().join(".") : l, T = l === void 0, F = Ne && K === "native", U = K === "input", re = S === "static" && !U, ae = S === "popover" && !F && !U, [i, a] = N(!1), [se, ce] = N(f), u = T ? se : oe ?? "", [g, w] = N(u);
|
|
39
39
|
z(() => {
|
|
40
|
-
w(
|
|
41
|
-
}, [
|
|
42
|
-
const D = g && A(g) ? g :
|
|
40
|
+
w(u);
|
|
41
|
+
}, [u]);
|
|
42
|
+
const D = g && A(g) ? g : u, I = D && A(D) ? E(D).getTime() : void 0, x = we(I, m, h), C = P || b, B = d(null), O = d(null), le = d(null), r = d(null), ie = n((e) => {
|
|
43
43
|
e.key === "Escape" && a(!1);
|
|
44
|
-
}, []),
|
|
44
|
+
}, []), ue = n(() => {
|
|
45
45
|
i || a(!0);
|
|
46
|
-
}, [i]),
|
|
46
|
+
}, [i]), pe = n(
|
|
47
47
|
(e) => {
|
|
48
48
|
a(!0), !i && e.target.tagName !== "INPUT" && r.current && r.current.focus();
|
|
49
49
|
},
|
|
@@ -121,13 +121,14 @@ const xe = Te(
|
|
|
121
121
|
"div",
|
|
122
122
|
{
|
|
123
123
|
ref: le,
|
|
124
|
-
className: ye(
|
|
125
|
-
[
|
|
124
|
+
className: ye(p.component, Q, {
|
|
125
|
+
[p.block]: J
|
|
126
126
|
}),
|
|
127
|
+
"data-modal-no-autofocus": !0,
|
|
127
128
|
tabIndex: -1,
|
|
128
|
-
onKeyDown:
|
|
129
|
-
onClick:
|
|
130
|
-
onFocus:
|
|
129
|
+
onKeyDown: C ? void 0 : ie,
|
|
130
|
+
onClick: C ? void 0 : ue,
|
|
131
|
+
onFocus: C ? void 0 : pe,
|
|
131
132
|
onBlur: de,
|
|
132
133
|
"data-test-id": Z,
|
|
133
134
|
children: [
|
|
@@ -138,22 +139,23 @@ const xe = Te(
|
|
|
138
139
|
ref: k([j, B]),
|
|
139
140
|
wrapperRef: k([te, O]),
|
|
140
141
|
className: X,
|
|
141
|
-
value:
|
|
142
|
+
value: u,
|
|
142
143
|
required: $,
|
|
143
144
|
defaultValue: f,
|
|
144
145
|
disabled: P,
|
|
145
146
|
readOnly: b,
|
|
146
|
-
mask:
|
|
147
|
+
mask: Ce,
|
|
147
148
|
rightAddons: /* @__PURE__ */ q(Re.Fragment, { children: [
|
|
148
|
-
/* @__PURE__ */ c("span", { className:
|
|
149
|
+
/* @__PURE__ */ c("span", { className: p.calendarIcon }),
|
|
149
150
|
F && /* @__PURE__ */ c(
|
|
150
151
|
"input",
|
|
151
152
|
{
|
|
152
153
|
type: "date",
|
|
153
154
|
ref: k([j, B]),
|
|
154
155
|
defaultValue: f,
|
|
156
|
+
autoComplete: "off",
|
|
155
157
|
onChange: he,
|
|
156
|
-
className:
|
|
158
|
+
className: p.nativeInput
|
|
157
159
|
}
|
|
158
160
|
)
|
|
159
161
|
] }),
|
|
@@ -170,7 +172,7 @@ const xe = Te(
|
|
|
170
172
|
{
|
|
171
173
|
open: i,
|
|
172
174
|
anchorElement: O.current,
|
|
173
|
-
popperClassName:
|
|
175
|
+
popperClassName: p.calendarContainer,
|
|
174
176
|
position: "bottom-start",
|
|
175
177
|
offset: [0, 8],
|
|
176
178
|
withTransition: !1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormikErrors, FormikProps, FormikValues } from 'formik';
|
|
2
|
-
import { default as React
|
|
2
|
+
import { default as React } from 'react';
|
|
3
3
|
import { TFunction } from '../../../modal';
|
|
4
4
|
export type Props<T extends FormikValues> = {
|
|
5
5
|
initialValues: T;
|
|
@@ -11,4 +11,4 @@ export type Props<T extends FormikValues> = {
|
|
|
11
11
|
save: (values: any) => any;
|
|
12
12
|
children: (props: FormikProps<FormikValues & T>) => React.ReactNode;
|
|
13
13
|
};
|
|
14
|
-
export declare function BaseForm<T extends FormikValues>({ loading, validate, customValidationFields, initialValues, enableReinitialize, save, children, t, }:
|
|
14
|
+
export declare function BaseForm<T extends FormikValues>({ loading, validate, customValidationFields, initialValues, enableReinitialize, save, children, t, }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { createTextMaskInputElement as
|
|
6
|
-
import { Input as
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx as M } from "react/jsx-runtime";
|
|
2
|
+
import w from "classnames";
|
|
3
|
+
import P, { useRef as l, useState as m, useCallback as c, useEffect as f } from "react";
|
|
4
|
+
import v from "react-merge-refs";
|
|
5
|
+
import { createTextMaskInputElement as A } from "text-mask-core";
|
|
6
|
+
import { Input as L } from "../input/component.js";
|
|
7
|
+
import T from "./index.module.css.js";
|
|
8
|
+
const V = " ", y = P.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
mask: i,
|
|
11
|
+
value: n,
|
|
12
|
+
defaultValue: s,
|
|
13
|
+
className: d,
|
|
14
|
+
onBeforeDisplay: p,
|
|
15
|
+
onChange: o,
|
|
16
|
+
onClear: u,
|
|
17
|
+
autoComplete: x = "off",
|
|
18
|
+
...C
|
|
19
|
+
}, R) => {
|
|
20
|
+
const r = l(null), a = l(null), [h, k] = m(n || s || ""), [E, H] = m(!0), t = c((e = "") => {
|
|
21
|
+
a.current && r.current && (a.current.update(e), k(r.current.value));
|
|
22
|
+
}, []), I = c(
|
|
13
23
|
(e) => {
|
|
14
|
-
t(e.target.value),
|
|
24
|
+
t(e.target.value), o && o(e, {
|
|
15
25
|
value: e.target.value
|
|
16
26
|
});
|
|
17
27
|
},
|
|
18
|
-
[
|
|
19
|
-
),
|
|
28
|
+
[o, t]
|
|
29
|
+
), g = c(
|
|
20
30
|
(e) => {
|
|
21
|
-
t(""),
|
|
31
|
+
t(""), u && u(e);
|
|
22
32
|
},
|
|
23
|
-
[
|
|
33
|
+
[u, t]
|
|
24
34
|
);
|
|
25
|
-
return
|
|
26
|
-
r.current && (a.current =
|
|
27
|
-
mask:
|
|
35
|
+
return f(() => {
|
|
36
|
+
r.current && (a.current = A({
|
|
37
|
+
mask: i,
|
|
28
38
|
inputElement: r.current,
|
|
29
|
-
pipe:
|
|
39
|
+
pipe: p,
|
|
30
40
|
guide: !1,
|
|
31
41
|
keepCharPositions: !1,
|
|
32
42
|
showMask: !1,
|
|
33
|
-
placeholderChar:
|
|
43
|
+
placeholderChar: V,
|
|
34
44
|
rawValue: "",
|
|
35
45
|
currentCaretPosition: 0,
|
|
36
46
|
previousConformedValue: ""
|
|
37
47
|
}));
|
|
38
|
-
}, [
|
|
48
|
+
}, [p, i]), f(() => {
|
|
39
49
|
t(n || s);
|
|
40
|
-
}, [n, t, s]),
|
|
41
|
-
|
|
42
|
-
}, []), /* @__PURE__ */
|
|
43
|
-
|
|
50
|
+
}, [n, t, s]), f(() => {
|
|
51
|
+
H(!1);
|
|
52
|
+
}, []), /* @__PURE__ */ M(
|
|
53
|
+
L,
|
|
44
54
|
{
|
|
45
|
-
...
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
...C,
|
|
56
|
+
autoComplete: x,
|
|
57
|
+
className: w(d, { [T.textHidden]: E }),
|
|
58
|
+
value: h,
|
|
59
|
+
onChange: I,
|
|
60
|
+
onClear: g,
|
|
61
|
+
ref: v([R, r])
|
|
51
62
|
}
|
|
52
63
|
);
|
|
53
64
|
}
|
|
54
65
|
);
|
|
55
66
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
y as MaskedInput,
|
|
68
|
+
V as PLACEHOLDER_CHAR
|
|
58
69
|
};
|
|
@@ -30,7 +30,7 @@ const T = {
|
|
|
30
30
|
const a = window.getComputedStyle(r);
|
|
31
31
|
return a.visibility === "hidden" || a.display === "none" ? !1 : r.offsetWidth > 0 || r.offsetHeight > 0 || r.getClientRects().length > 0;
|
|
32
32
|
}) : [], P = (t) => {
|
|
33
|
-
if (t.hasAttribute("data-modal-no-autofocus") || t.hasAttribute("aria-haspopup") || t.hasAttribute("aria-autocomplete")) return !0;
|
|
33
|
+
if (t.hasAttribute("data-modal-no-autofocus") || t.closest("[data-modal-no-autofocus]") || t.closest('[role="combobox"],[aria-haspopup]') || t.hasAttribute("aria-haspopup") || t.hasAttribute("aria-autocomplete")) return !0;
|
|
34
34
|
const n = t.getAttribute("role");
|
|
35
35
|
return !!(n === "combobox" || n === "listbox" || t.querySelector('[role="combobox"],[aria-haspopup],[aria-autocomplete]'));
|
|
36
36
|
}, _ = (t) => {
|
|
@@ -38,7 +38,7 @@ const T = {
|
|
|
38
38
|
const n = t.querySelector("[data-modal-autofocus]");
|
|
39
39
|
return n || F(t).find((d) => !P(d)) || t;
|
|
40
40
|
}, J = ({ modal: t, t: n, index: r, dirtyModals: a, closeModal: d, currentModalId: u }) => {
|
|
41
|
-
const R = D(t.props.size), [
|
|
41
|
+
const R = D(t.props.size), [b] = q(B), [m, h] = L(!1), c = w(null), x = w(null);
|
|
42
42
|
N(() => {
|
|
43
43
|
const o = requestAnimationFrame(() => h(!0));
|
|
44
44
|
return () => cancelAnimationFrame(o);
|
|
@@ -92,12 +92,12 @@ const T = {
|
|
|
92
92
|
e.preventDefault(), c.current && c.current.focus({ preventScroll: !0 });
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
const g = i[0], v = i[i.length - 1],
|
|
96
|
-
if (e.shiftKey && (
|
|
95
|
+
const g = i[0], v = i[i.length - 1], p = document.activeElement;
|
|
96
|
+
if (e.shiftKey && (p === g || !c.current?.contains(p))) {
|
|
97
97
|
e.preventDefault(), v.focus({ preventScroll: !0 });
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
!e.shiftKey && (
|
|
100
|
+
!e.shiftKey && (p === v || !c.current?.contains(p)) && (e.preventDefault(), g.focus({ preventScroll: !0 }));
|
|
101
101
|
};
|
|
102
102
|
return t.id === u && window?.addEventListener("keydown", o), () => {
|
|
103
103
|
window?.removeEventListener("keydown", o);
|
|
@@ -115,8 +115,8 @@ const T = {
|
|
|
115
115
|
{
|
|
116
116
|
ref: c,
|
|
117
117
|
className: C(s.right, s.content, {
|
|
118
|
-
[s.open]:
|
|
119
|
-
[s.bottomSheet]:
|
|
118
|
+
[s.open]: m,
|
|
119
|
+
[s.bottomSheet]: b
|
|
120
120
|
}),
|
|
121
121
|
style: {
|
|
122
122
|
zIndex: 9999999 + r,
|
|
@@ -125,7 +125,7 @@ const T = {
|
|
|
125
125
|
// схема — анимация ширины и right'а синхронны). На
|
|
126
126
|
// мобиле right=0 всегда, а появление контролируется
|
|
127
127
|
// CSS (.bottomSheet.open → top: 0).
|
|
128
|
-
right:
|
|
128
|
+
right: b || m ? 0 : R
|
|
129
129
|
},
|
|
130
130
|
role: "dialog",
|
|
131
131
|
"aria-modal": "true",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import w from "classnames";
|
|
3
3
|
import d, { useState as E, useRef as L, useCallback as f } from "react";
|
|
4
4
|
import { FormControl as O } from "../../../form-control/component.js";
|
|
@@ -16,7 +16,7 @@ const P = ({
|
|
|
16
16
|
placeholder: l,
|
|
17
17
|
selectedMultiple: N = [],
|
|
18
18
|
selected: v,
|
|
19
|
-
rightAddons:
|
|
19
|
+
rightAddons: a,
|
|
20
20
|
valueRenderer: j = q,
|
|
21
21
|
Arrow: t,
|
|
22
22
|
innerProps: k,
|
|
@@ -24,17 +24,18 @@ const P = ({
|
|
|
24
24
|
fieldClassName: B,
|
|
25
25
|
...C
|
|
26
26
|
}) => {
|
|
27
|
-
const [R,
|
|
28
|
-
return /* @__PURE__ */
|
|
27
|
+
const [R, r] = E(!1), i = L(null), [y] = W(i, "keyboard"), S = f(() => r(!0), []), V = f(() => r(!1), []), m = j({ selected: v, selectedMultiple: N }), o = !!m, g = !!n && (o || !l);
|
|
28
|
+
return /* @__PURE__ */ s(
|
|
29
29
|
"div",
|
|
30
30
|
{
|
|
31
31
|
className: e.component,
|
|
32
32
|
ref: i,
|
|
33
33
|
onFocus: S,
|
|
34
34
|
onBlur: V,
|
|
35
|
-
children: /* @__PURE__ */
|
|
35
|
+
children: /* @__PURE__ */ s(
|
|
36
36
|
O,
|
|
37
37
|
{
|
|
38
|
+
"data-modal-no-autofocus": !0,
|
|
38
39
|
fieldClassName: w(e.field, B, {
|
|
39
40
|
[e.disabled]: c,
|
|
40
41
|
[e.focusVisible]: y
|
|
@@ -43,12 +44,12 @@ const P = ({
|
|
|
43
44
|
size: p,
|
|
44
45
|
focused: h || R,
|
|
45
46
|
disabled: c,
|
|
46
|
-
filled:
|
|
47
|
+
filled: o,
|
|
47
48
|
label: g && n,
|
|
48
49
|
error: F,
|
|
49
50
|
hint: b,
|
|
50
|
-
rightAddons: (t ||
|
|
51
|
-
|
|
51
|
+
rightAddons: (t || a) && /* @__PURE__ */ u(d.Fragment, { children: [
|
|
52
|
+
a,
|
|
52
53
|
t ? d.cloneElement(
|
|
53
54
|
t,
|
|
54
55
|
{ className: e.arrow }
|
|
@@ -58,8 +59,8 @@ const P = ({
|
|
|
58
59
|
...C,
|
|
59
60
|
...k,
|
|
60
61
|
children: /* @__PURE__ */ u("div", { className: e.contentWrapper, children: [
|
|
61
|
-
l && !
|
|
62
|
-
|
|
62
|
+
l && !o && /* @__PURE__ */ s("span", { className: e.placeholder, children: l }),
|
|
63
|
+
o && /* @__PURE__ */ s("div", { className: e.value, children: m })
|
|
63
64
|
] })
|
|
64
65
|
}
|
|
65
66
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as k, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import v from "@alphakits/icons/dist/SearchS";
|
|
3
|
-
import f, { useState as
|
|
3
|
+
import f, { useState as x, useRef as P, useCallback as p, useMemo as b } from "react";
|
|
4
4
|
import "../../../toast-notifier/component.js";
|
|
5
5
|
import { useClickOutside as j } from "../../../hooks/useClickOutside/index.js";
|
|
6
6
|
import { safeStringify as F } from "../../../utils/safe-stringify.js";
|
|
@@ -19,6 +19,7 @@ const B = f.forwardRef(
|
|
|
19
19
|
leftAddons: /* @__PURE__ */ s(v, {}),
|
|
20
20
|
inputMode: "search",
|
|
21
21
|
enterKeyHint: "search",
|
|
22
|
+
autoComplete: "off",
|
|
22
23
|
autoFocus: !0,
|
|
23
24
|
...e,
|
|
24
25
|
fieldClassName: A.innerInput,
|
|
@@ -36,8 +37,8 @@ const B = f.forwardRef(
|
|
|
36
37
|
selected: i = "",
|
|
37
38
|
...c
|
|
38
39
|
}) => {
|
|
39
|
-
const [L, a] =
|
|
40
|
-
(
|
|
40
|
+
const [L, a] = x(e), [m, d] = x(""), h = P(null), C = p(
|
|
41
|
+
(S, { value: l }) => {
|
|
41
42
|
d(l);
|
|
42
43
|
try {
|
|
43
44
|
if (!l) return a(e);
|
|
@@ -56,8 +57,8 @@ const B = f.forwardRef(
|
|
|
56
57
|
), t = p(() => {
|
|
57
58
|
d(""), a(e);
|
|
58
59
|
}, [e]), O = p(
|
|
59
|
-
(
|
|
60
|
-
n?.(
|
|
60
|
+
(S) => {
|
|
61
|
+
n?.(S), t();
|
|
61
62
|
},
|
|
62
63
|
[n, t]
|
|
63
64
|
);
|
|
@@ -66,14 +67,14 @@ const B = f.forwardRef(
|
|
|
66
67
|
() => ({
|
|
67
68
|
ref: h,
|
|
68
69
|
inputProps: {
|
|
69
|
-
onChange:
|
|
70
|
+
onChange: C,
|
|
70
71
|
value: m,
|
|
71
72
|
type: o,
|
|
72
73
|
clear: !0,
|
|
73
74
|
onClear: t
|
|
74
75
|
}
|
|
75
76
|
}),
|
|
76
|
-
[
|
|
77
|
+
[C, m, o, t]
|
|
77
78
|
);
|
|
78
79
|
return /* @__PURE__ */ s(
|
|
79
80
|
M,
|