@arthurzakharov/ui-kit 1.7.7 → 1.7.8
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/assets/text-field-CMQWxQpy.css +1 -0
- package/dist/controls/interactives/input/input.component.d.ts +1 -3
- package/dist/controls/interactives/input/input.component.js +26 -27
- package/dist/controls/interactives/text-field/text-field.component.js +82 -79
- package/dist/controls/primitives/label/label.component.js +19 -16
- package/package.json +1 -1
- package/dist/assets/text-field-5nNgGQnX.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._TextField_1jd9o_1{position:relative;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;justify-content:flex-start;gap:var(--rm-ui-padding-xxs)}._Content_1jd9o_11{box-sizing:border-box;position:relative;flex-grow:1;height:58px;padding:var(--rm-ui-padding-xs) var(--rm-ui-padding-sm) calc(var(--rm-ui-padding-xs) - 2px) var(--rm-ui-padding-sm);display:flex;flex-direction:row;justify-content:stretch;align-items:flex-end}._Content_1jd9o_11:hover{cursor:pointer}._Label_1jd9o_27{position:absolute;left:var(--rm-ui-padding-sm);transition:top var(--rm-ui-amimation-speed-primary) var(--rm-ui-amimation-cubic-primary)}._Label_1jd9o_27:hover{cursor:pointer}._Idle_1jd9o_37{top:50%;transform:translateY(-50%)}._Active_1jd9o_42{top:var(--rm-ui-padding-xs);transform:translateY(0)}._Placeholder_1jd9o_47{position:absolute;z-index:1;bottom:var(--rm-ui-padding-xs);left:var(--rm-ui-padding-sm)}._PlaceholderText_1jd9o_54{opacity:.75;font-weight:var(--rm-ui-font-weight-regular);font-size:var(--rm-ui-font-size-body);line-height:var(--rm-ui-line-height-body);color:var(--rm-ui-color-text-secondary)}._ErrorMessage_1jd9o_62{padding-left:var(--rm-ui-padding-sm)}._Input_1jd9o_66{flex-grow:1}._MaskStart_1jd9o_70{opacity:0}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
1
|
import { Interactive } from '../../utils';
|
|
3
2
|
import { Base } from '../../../utils/types';
|
|
4
3
|
export interface InputProps extends Base, Interactive<string> {
|
|
5
|
-
ref?: RefObject<HTMLInputElement>;
|
|
6
4
|
mask?: string;
|
|
7
5
|
maxLength?: number;
|
|
8
6
|
onAnimationStart?: (id: string) => void;
|
|
9
7
|
onAnimationEnd?: (id: string) => void;
|
|
10
8
|
}
|
|
11
|
-
export declare const Input: ({ id, value, disabled, onChange, onFocus, onBlur,
|
|
9
|
+
export declare const Input: ({ id, value, disabled, onChange, onFocus, onBlur, maxLength, mask, onAnimationStart, onAnimationEnd, ...base }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as M } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as d, useState as
|
|
2
|
+
import { useRef as d, useState as O, useLayoutEffect as Q, useCallback as R, useEffect as W } from "react";
|
|
3
3
|
import K from "clsx";
|
|
4
|
-
import { compareStrings as
|
|
5
|
-
import { useControlInteraction as
|
|
4
|
+
import { compareStrings as X, isDigit as Y, getFirstNotEnteredCharIndex as v, replaceCharByIndex as b, getNextChar as T, isSeparator as P, getPreviousChar as Z, applyMask as k } from "./input.utils.js";
|
|
5
|
+
import { useControlInteraction as tt } from "../../utils/hooks/use-control-interaction/use-control-interaction.hook.js";
|
|
6
6
|
import { baseProps as h } from "../../../utils/functions/functions.util.js";
|
|
7
|
-
import '../../../assets/input-D66hMzHc.css';const
|
|
8
|
-
Input:
|
|
9
|
-
Placeholder:
|
|
10
|
-
},
|
|
7
|
+
import '../../../assets/input-D66hMzHc.css';const et = "_Input_gfvsr_1", nt = "_Placeholder_gfvsr_45", w = {
|
|
8
|
+
Input: et,
|
|
9
|
+
Placeholder: nt
|
|
10
|
+
}, it = ({
|
|
11
11
|
// Interactive props
|
|
12
12
|
id: u,
|
|
13
13
|
value: y = "",
|
|
@@ -16,27 +16,26 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
16
16
|
onFocus: L,
|
|
17
17
|
onBlur: j,
|
|
18
18
|
// Input props
|
|
19
|
-
|
|
20
|
-
maxLength: q,
|
|
19
|
+
maxLength: U,
|
|
21
20
|
mask: n = "",
|
|
22
|
-
onAnimationStart:
|
|
23
|
-
onAnimationEnd:
|
|
21
|
+
onAnimationStart: q,
|
|
22
|
+
onAnimationEnd: z,
|
|
24
23
|
// Base props
|
|
25
24
|
...s
|
|
26
25
|
}) => {
|
|
27
|
-
const { emitChange: C, handleFocus: S, handleBlur: E } =
|
|
26
|
+
const { emitChange: C, handleFocus: S, handleBlur: E } = tt({
|
|
28
27
|
id: u,
|
|
29
28
|
disabled: g,
|
|
30
29
|
onChange: $,
|
|
31
30
|
onFocus: L,
|
|
32
31
|
onBlur: j
|
|
33
|
-
}), o =
|
|
32
|
+
}), o = d(null), D = d(!1), a = d(null), N = d(!0), [r, I] = O(y || n), i = (t) => {
|
|
34
33
|
const c = Math.max(0, t);
|
|
35
34
|
if (a.current = c, !o.current) return;
|
|
36
35
|
const e = Math.min(c, o.current.value.length);
|
|
37
36
|
o.current.setSelectionRange(e, e);
|
|
38
37
|
};
|
|
39
|
-
|
|
38
|
+
Q(() => {
|
|
40
39
|
if (!n || !o.current || a.current === null) return;
|
|
41
40
|
const t = Math.min(a.current, o.current.value.length);
|
|
42
41
|
o.current.setSelectionRange(t, t), a.current = null;
|
|
@@ -44,16 +43,16 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
44
43
|
const F = () => {
|
|
45
44
|
const t = o.current?.value || "", c = v(t, n);
|
|
46
45
|
c !== t.length && i(c);
|
|
47
|
-
},
|
|
48
|
-
const t = o.current?.value || "", c =
|
|
49
|
-
if (!
|
|
46
|
+
}, G = R(() => {
|
|
47
|
+
const t = o.current?.value || "", c = X(r, t);
|
|
48
|
+
if (!Y(c)) return;
|
|
50
49
|
const e = o.current?.selectionEnd || 0, m = v(t, n) === t.length, l = b(r, e - 1, c), f = v(l, n);
|
|
51
50
|
if (m) {
|
|
52
|
-
const p = t.slice(0, e - 1), x = t.slice(e - 1, e), B = t.slice(e),
|
|
53
|
-
I(
|
|
51
|
+
const p = t.slice(0, e - 1), x = t.slice(e - 1, e), B = t.slice(e), J = b(p + B, e - 1, x), _ = T(p + B, e) || "";
|
|
52
|
+
I(J), i(P(_, n) && _ ? e + 1 : e);
|
|
54
53
|
} else
|
|
55
54
|
I(l), i(f);
|
|
56
|
-
}, [r, n]),
|
|
55
|
+
}, [r, n]), H = R(
|
|
57
56
|
(t) => {
|
|
58
57
|
if ([
|
|
59
58
|
"Digit1",
|
|
@@ -74,14 +73,14 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
74
73
|
t.preventDefault();
|
|
75
74
|
const e = o.current?.selectionEnd || 0;
|
|
76
75
|
if (e) {
|
|
77
|
-
const A =
|
|
76
|
+
const A = Z(r, e), m = T(r, e - 1), l = P(A, n), f = P(m, n), p = e - (l || f ? 2 : 1), x = k(r, n, e - (f ? 2 : 1));
|
|
78
77
|
I(x), i(p);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
},
|
|
82
81
|
[r, n]
|
|
83
82
|
);
|
|
84
|
-
|
|
83
|
+
W(() => {
|
|
85
84
|
if (n) {
|
|
86
85
|
if (N.current) {
|
|
87
86
|
N.current = !1;
|
|
@@ -91,7 +90,7 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
91
90
|
}
|
|
92
91
|
}, [r, n, C]);
|
|
93
92
|
const V = (t) => {
|
|
94
|
-
t.includes("autofill-start") &&
|
|
93
|
+
t.includes("autofill-start") && q?.(u), t.includes("autofill-end") && z?.(u);
|
|
95
94
|
};
|
|
96
95
|
return n ? /* @__PURE__ */ M(
|
|
97
96
|
"input",
|
|
@@ -106,8 +105,8 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
106
105
|
value: r,
|
|
107
106
|
className: K(w.Input, h(s, "className"), { [w.Placeholder]: r === n }),
|
|
108
107
|
onAnimationStart: (t) => V(t.animationName),
|
|
109
|
-
onKeyDown:
|
|
110
|
-
onChange:
|
|
108
|
+
onKeyDown: H,
|
|
109
|
+
onChange: G,
|
|
111
110
|
onPointerDown: (t) => {
|
|
112
111
|
t.preventDefault(), D.current = !0, t.currentTarget.focus(), F();
|
|
113
112
|
},
|
|
@@ -126,7 +125,7 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
126
125
|
"data-testid": h(s, "data-testid", "input"),
|
|
127
126
|
"aria-label": `${u}-text-input`,
|
|
128
127
|
disabled: g,
|
|
129
|
-
maxLength:
|
|
128
|
+
maxLength: U,
|
|
130
129
|
type: "text",
|
|
131
130
|
id: u,
|
|
132
131
|
name: u,
|
|
@@ -140,5 +139,5 @@ import '../../../assets/input-D66hMzHc.css';const nt = "_Input_gfvsr_1", rt = "_
|
|
|
140
139
|
);
|
|
141
140
|
};
|
|
142
141
|
export {
|
|
143
|
-
|
|
142
|
+
it as Input
|
|
144
143
|
};
|
|
@@ -1,103 +1,106 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import i from "clsx";
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import d from "clsx";
|
|
4
3
|
import { useBoolean as x } from "usehooks-ts";
|
|
5
|
-
import { FadeScale as
|
|
6
|
-
import { FadeSlide as
|
|
7
|
-
import { Box as
|
|
4
|
+
import { FadeScale as k } from "../../../animations/fade-scale/fade-scale.component.js";
|
|
5
|
+
import { FadeSlide as B } from "../../../animations/fade-slide/fade-slide.component.js";
|
|
6
|
+
import { Box as C } from "../../primitives/box/box.component.js";
|
|
7
|
+
import "react";
|
|
8
8
|
import { baseProps as h } from "../../../utils/functions/functions.util.js";
|
|
9
9
|
import "lucide-react";
|
|
10
|
-
import { ErrorMessage as
|
|
11
|
-
import { Label as
|
|
12
|
-
import { Input as
|
|
13
|
-
import '../../../assets/text-field-
|
|
14
|
-
TextField:
|
|
15
|
-
Content:
|
|
16
|
-
Label:
|
|
10
|
+
import { ErrorMessage as $ } from "../../primitives/error-message/error-message.component.js";
|
|
11
|
+
import { Label as w } from "../../primitives/label/label.component.js";
|
|
12
|
+
import { Input as D } from "../input/input.component.js";
|
|
13
|
+
import '../../../assets/text-field-CMQWxQpy.css';const O = "_TextField_1jd9o_1", y = "_Content_1jd9o_11", q = "_Label_1jd9o_27", z = "_Idle_1jd9o_37", G = "_Active_1jd9o_42", H = "_Placeholder_1jd9o_47", J = "_PlaceholderText_1jd9o_54", K = "_ErrorMessage_1jd9o_62", Q = "_Input_1jd9o_66", R = "_MaskStart_1jd9o_70", e = {
|
|
14
|
+
TextField: O,
|
|
15
|
+
Content: y,
|
|
16
|
+
Label: q,
|
|
17
17
|
Idle: z,
|
|
18
18
|
Active: G,
|
|
19
19
|
Placeholder: H,
|
|
20
20
|
PlaceholderText: J,
|
|
21
21
|
ErrorMessage: K,
|
|
22
22
|
Input: Q,
|
|
23
|
-
MaskStart:
|
|
24
|
-
},
|
|
23
|
+
MaskStart: R
|
|
24
|
+
}, le = ({
|
|
25
25
|
// Interactive props
|
|
26
|
-
id:
|
|
27
|
-
value:
|
|
26
|
+
id: l,
|
|
27
|
+
value: s = "",
|
|
28
28
|
disabled: I = !1,
|
|
29
|
-
state:
|
|
30
|
-
onChange:
|
|
31
|
-
onFocus:
|
|
32
|
-
onBlur:
|
|
29
|
+
state: n = "idle",
|
|
30
|
+
onChange: j,
|
|
31
|
+
onFocus: F,
|
|
32
|
+
onBlur: M,
|
|
33
33
|
// Text props
|
|
34
|
-
mask:
|
|
35
|
-
maxLength:
|
|
36
|
-
label:
|
|
37
|
-
message:
|
|
38
|
-
placeholder:
|
|
34
|
+
mask: c,
|
|
35
|
+
maxLength: P = -1,
|
|
36
|
+
label: T = "",
|
|
37
|
+
message: m = "",
|
|
38
|
+
placeholder: _ = "",
|
|
39
39
|
// Base props
|
|
40
|
-
...
|
|
40
|
+
...p
|
|
41
41
|
}) => {
|
|
42
|
-
const { value:
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
42
|
+
const { value: u, setTrue: g, setFalse: A } = x(!1), { value: r, setTrue: S, setFalse: b } = x(!1), a = r || !!s || u, E = !c && !!_ && r && !s && !u, N = !!m && n === "error", v = (o) => {
|
|
43
|
+
S(), F?.(o);
|
|
44
|
+
}, L = (o) => {
|
|
45
|
+
b(), M?.(o);
|
|
46
46
|
};
|
|
47
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ i(
|
|
48
48
|
"div",
|
|
49
49
|
{
|
|
50
|
-
"data-testid": h(
|
|
51
|
-
className:
|
|
50
|
+
"data-testid": h(p, "data-testid", "text-field"),
|
|
51
|
+
className: d(e.TextField, h(p, "className")),
|
|
52
52
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
53
|
+
/* @__PURE__ */ i(C, { state: n, focused: r, children: [
|
|
54
|
+
/* @__PURE__ */ t(
|
|
55
|
+
w,
|
|
56
|
+
{
|
|
57
|
+
"data-testid": "text-label",
|
|
58
|
+
text: T,
|
|
59
|
+
position: a ? "active" : "idle",
|
|
60
|
+
state: a ? n : "idle",
|
|
61
|
+
className: d(e.Label, a ? e.Active : e.Idle)
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ i(
|
|
65
|
+
"label",
|
|
66
|
+
{
|
|
67
|
+
htmlFor: l,
|
|
68
|
+
className: e.Content,
|
|
69
|
+
onPointerDown: (o) => {
|
|
70
|
+
r && o.preventDefault();
|
|
71
|
+
const f = document.getElementById(l);
|
|
72
|
+
console.log("input", f), f?.click();
|
|
73
|
+
},
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ t(k, { name: "text-placeholder", condition: E, className: e.Placeholder, children: /* @__PURE__ */ t("span", { "data-testid": "text-placeholder", className: e.PlaceholderText, children: _ }) }),
|
|
76
|
+
/* @__PURE__ */ t(
|
|
77
|
+
D,
|
|
78
|
+
{
|
|
79
|
+
"data-testid": "text-input",
|
|
80
|
+
mask: c,
|
|
81
|
+
maxLength: P,
|
|
82
|
+
disabled: I,
|
|
83
|
+
id: l,
|
|
84
|
+
value: s,
|
|
85
|
+
className: d(e.Input, {
|
|
86
|
+
[e.MaskStart]: c && s === "" && !a
|
|
87
|
+
}),
|
|
88
|
+
onAnimationStart: g,
|
|
89
|
+
onAnimationEnd: A,
|
|
90
|
+
onChange: j,
|
|
91
|
+
onFocus: v,
|
|
92
|
+
onBlur: L
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ t(B, { name: "text-message", direction: "ltr", condition: N, children: /* @__PURE__ */ t($, { "data-testid": "text-error-message", text: m, className: e.ErrorMessage }) })
|
|
97
100
|
]
|
|
98
101
|
}
|
|
99
102
|
);
|
|
100
103
|
};
|
|
101
104
|
export {
|
|
102
|
-
|
|
105
|
+
le as TextField
|
|
103
106
|
};
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { Content as
|
|
4
|
-
import { baseProps as
|
|
5
|
-
import '../../../assets/label-BKXQlPJi.css';const
|
|
6
|
-
Label:
|
|
7
|
-
Idle:
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import i from "clsx";
|
|
3
|
+
import { Content as _ } from "../../../utils/content/content.component.js";
|
|
4
|
+
import { baseProps as o } from "../../../utils/functions/functions.util.js";
|
|
5
|
+
import '../../../assets/label-BKXQlPJi.css';const d = "_Label_85kr5_1", n = "_Idle_85kr5_7", m = "_Active_85kr5_12", p = "_Success_85kr5_21", e = {
|
|
6
|
+
Label: d,
|
|
7
|
+
Idle: n,
|
|
8
8
|
Active: m,
|
|
9
9
|
Error: "_Error_85kr5_17",
|
|
10
|
-
Success:
|
|
11
|
-
},
|
|
10
|
+
Success: p
|
|
11
|
+
}, L = ({
|
|
12
12
|
// Label props
|
|
13
|
-
text:
|
|
13
|
+
text: t,
|
|
14
14
|
state: r = "idle",
|
|
15
15
|
position: c = "idle",
|
|
16
16
|
// Base props
|
|
17
17
|
...s
|
|
18
|
-
}) => /* @__PURE__ */
|
|
19
|
-
|
|
18
|
+
}) => /* @__PURE__ */ a(
|
|
19
|
+
_,
|
|
20
20
|
{
|
|
21
|
-
"data-testid":
|
|
22
|
-
className:
|
|
21
|
+
"data-testid": o(s, "data-testid", "label"),
|
|
22
|
+
className: i(e.Label, o(s, "className"), {
|
|
23
23
|
[e.Idle]: c === "idle",
|
|
24
24
|
[e.Active]: c === "active",
|
|
25
25
|
[e.Error]: r === "error",
|
|
26
26
|
[e.Success]: r === "success"
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
onClick: (l) => {
|
|
29
|
+
l.stopPropagation();
|
|
30
|
+
},
|
|
31
|
+
children: t
|
|
29
32
|
}
|
|
30
33
|
);
|
|
31
34
|
export {
|
|
32
|
-
|
|
35
|
+
L as Label
|
|
33
36
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._TextField_l5ui0_1{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;justify-content:flex-start;gap:var(--rm-ui-padding-xxs)}._Content_l5ui0_10{box-sizing:border-box;position:relative;flex-grow:1;height:58px;padding:var(--rm-ui-padding-xs) var(--rm-ui-padding-sm) calc(var(--rm-ui-padding-xs) - 2px) var(--rm-ui-padding-sm);display:flex;flex-direction:row;justify-content:stretch;align-items:flex-end}._Content_l5ui0_10:hover{cursor:pointer}._Label_l5ui0_26{position:absolute;left:var(--rm-ui-padding-sm);transition:top var(--rm-ui-amimation-speed-primary) var(--rm-ui-amimation-cubic-primary)}._Idle_l5ui0_32{top:50%;transform:translateY(-50%)}._Active_l5ui0_37{top:var(--rm-ui-padding-xs);transform:translateY(0)}._Placeholder_l5ui0_42{position:absolute;z-index:1;bottom:var(--rm-ui-padding-xs);left:var(--rm-ui-padding-sm)}._PlaceholderText_l5ui0_49{opacity:.75;font-weight:var(--rm-ui-font-weight-regular);font-size:var(--rm-ui-font-size-body);line-height:var(--rm-ui-line-height-body);color:var(--rm-ui-color-text-secondary)}._ErrorMessage_l5ui0_57{padding-left:var(--rm-ui-padding-sm)}._Input_l5ui0_61{flex-grow:1}._MaskStart_l5ui0_65{opacity:0}
|