@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.
@@ -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, ref, maxLength, mask, onAnimationStart, onAnimationEnd, ...base }: InputProps) => import("react/jsx-runtime").JSX.Element;
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 Q, useLayoutEffect as W, useCallback as R, useEffect as X } from "react";
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 Y, isDigit as Z, getFirstNotEnteredCharIndex as v, replaceCharByIndex as b, getNextChar as T, isSeparator as P, getPreviousChar as k, applyMask as tt } from "./input.utils.js";
5
- import { useControlInteraction as et } from "../../utils/hooks/use-control-interaction/use-control-interaction.hook.js";
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 nt = "_Input_gfvsr_1", rt = "_Placeholder_gfvsr_45", w = {
8
- Input: nt,
9
- Placeholder: rt
10
- }, lt = ({
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
- ref: U,
20
- maxLength: q,
19
+ maxLength: U,
21
20
  mask: n = "",
22
- onAnimationStart: z,
23
- onAnimationEnd: G,
21
+ onAnimationStart: q,
22
+ onAnimationEnd: z,
24
23
  // Base props
25
24
  ...s
26
25
  }) => {
27
- const { emitChange: C, handleFocus: S, handleBlur: E } = et({
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 = U || d(null), D = d(!1), a = d(null), N = d(!0), [r, I] = Q(y || n), i = (t) => {
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
- W(() => {
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
- }, H = R(() => {
48
- const t = o.current?.value || "", c = Y(r, t);
49
- if (!Z(c)) return;
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), O = b(p + B, e - 1, x), _ = T(p + B, e) || "";
53
- I(O), i(P(_, n) && _ ? e + 1 : e);
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]), J = R(
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 = k(r, e), m = T(r, e - 1), l = P(A, n), f = P(m, n), p = e - (l || f ? 2 : 1), x = tt(r, n, e - (f ? 2 : 1));
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
- X(() => {
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") && z?.(u), t.includes("autofill-end") && G?.(u);
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: J,
110
- onChange: H,
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: q,
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
- lt as Input
142
+ it as Input
144
143
  };
@@ -1,103 +1,106 @@
1
- import { jsxs as p, jsx as t } from "react/jsx-runtime";
2
- import { useRef as B } from "react";
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 C } from "../../../animations/fade-scale/fade-scale.component.js";
6
- import { FadeSlide as $ } from "../../../animations/fade-slide/fade-slide.component.js";
7
- import { Box as w } from "../../primitives/box/box.component.js";
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 j } from "../../primitives/error-message/error-message.component.js";
11
- import { Label as D } from "../../primitives/label/label.component.js";
12
- import { Input as O } from "../input/input.component.js";
13
- import '../../../assets/text-field-5nNgGQnX.css';const R = "_TextField_l5ui0_1", q = "_Content_l5ui0_10", y = "_Label_l5ui0_26", z = "_Idle_l5ui0_32", G = "_Active_l5ui0_37", H = "_Placeholder_l5ui0_42", J = "_PlaceholderText_l5ui0_49", K = "_ErrorMessage_l5ui0_57", Q = "_Input_l5ui0_61", U = "_MaskStart_l5ui0_65", e = {
14
- TextField: R,
15
- Content: q,
16
- Label: y,
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: U
24
- }, ne = ({
23
+ MaskStart: R
24
+ }, le = ({
25
25
  // Interactive props
26
- id: c,
27
- value: l = "",
26
+ id: l,
27
+ value: s = "",
28
28
  disabled: I = !1,
29
- state: a = "idle",
30
- onChange: F,
31
- onFocus: M,
32
- onBlur: P,
29
+ state: n = "idle",
30
+ onChange: j,
31
+ onFocus: F,
32
+ onBlur: M,
33
33
  // Text props
34
- mask: n,
35
- maxLength: T = -1,
36
- label: A = "",
37
- message: d = "",
38
- placeholder: u = "",
34
+ mask: c,
35
+ maxLength: P = -1,
36
+ label: T = "",
37
+ message: m = "",
38
+ placeholder: _ = "",
39
39
  // Base props
40
- ...m
40
+ ...p
41
41
  }) => {
42
- const { value: _, setTrue: S, setFalse: b } = x(!1), { value: r, setTrue: g, setFalse: E } = x(!1), f = B(null), s = r || !!l || _, N = !n && !!u && r && !l && !_, v = !!d && a === "error", L = (o) => {
43
- g(), M?.(o);
44
- }, k = (o) => {
45
- E(), P?.(o);
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__ */ p(
47
+ return /* @__PURE__ */ i(
48
48
  "div",
49
49
  {
50
- "data-testid": h(m, "data-testid", "text-field"),
51
- className: i(e.TextField, h(m, "className")),
50
+ "data-testid": h(p, "data-testid", "text-field"),
51
+ className: d(e.TextField, h(p, "className")),
52
52
  children: [
53
- /* @__PURE__ */ t(w, { state: a, focused: r, children: /* @__PURE__ */ p(
54
- "label",
55
- {
56
- htmlFor: c,
57
- className: e.Content,
58
- onPointerDown: (o) => {
59
- r && o.preventDefault(), f.current?.click();
60
- },
61
- children: [
62
- /* @__PURE__ */ t(
63
- D,
64
- {
65
- "data-testid": "text-label",
66
- text: A,
67
- position: s ? "active" : "idle",
68
- state: s ? a : "idle",
69
- className: i(e.Label, s ? e.Active : e.Idle)
70
- }
71
- ),
72
- /* @__PURE__ */ t(C, { name: "text-placeholder", condition: N, className: e.Placeholder, children: /* @__PURE__ */ t("span", { "data-testid": "text-placeholder", className: e.PlaceholderText, children: u }) }),
73
- /* @__PURE__ */ t(
74
- O,
75
- {
76
- "data-testid": "text-input",
77
- mask: n,
78
- maxLength: T,
79
- disabled: I,
80
- id: c,
81
- ref: f,
82
- value: l,
83
- className: i(e.Input, {
84
- [e.MaskStart]: n && l === "" && !s
85
- }),
86
- onAnimationStart: S,
87
- onAnimationEnd: b,
88
- onChange: F,
89
- onFocus: L,
90
- onBlur: k
91
- }
92
- )
93
- ]
94
- }
95
- ) }),
96
- /* @__PURE__ */ t($, { name: "text-message", direction: "ltr", condition: v, children: /* @__PURE__ */ t(j, { "data-testid": "text-error-message", text: d, className: e.ErrorMessage }) })
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
- ne as TextField
105
+ le as TextField
103
106
  };
@@ -1,33 +1,36 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import _ from "clsx";
3
- import { Content as a } from "../../../utils/content/content.component.js";
4
- import { baseProps as t } from "../../../utils/functions/functions.util.js";
5
- import '../../../assets/label-BKXQlPJi.css';const i = "_Label_85kr5_1", d = "_Idle_85kr5_7", m = "_Active_85kr5_12", n = "_Success_85kr5_21", e = {
6
- Label: i,
7
- Idle: d,
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: n
11
- }, v = ({
10
+ Success: p
11
+ }, L = ({
12
12
  // Label props
13
- text: o,
13
+ text: t,
14
14
  state: r = "idle",
15
15
  position: c = "idle",
16
16
  // Base props
17
17
  ...s
18
- }) => /* @__PURE__ */ l(
19
- a,
18
+ }) => /* @__PURE__ */ a(
19
+ _,
20
20
  {
21
- "data-testid": t(s, "data-testid", "label"),
22
- className: _(e.Label, t(s, "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
- children: o
28
+ onClick: (l) => {
29
+ l.stopPropagation();
30
+ },
31
+ children: t
29
32
  }
30
33
  );
31
34
  export {
32
- v as Label
35
+ L as Label
33
36
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arthurzakharov/ui-kit",
3
3
  "private": false,
4
- "version": "1.7.7",
4
+ "version": "1.7.8",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -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}