@reportportal/ui-kit 0.0.1-alpha.101 → 0.0.1-alpha.102

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,139 @@
1
+ import { jsxs as a, Fragment as y, jsx as r } from "react/jsx-runtime";
2
+ import { useRef as B, useId as F, useMemo as S } from "react";
3
+ import { c as w } from "./bind-06a7ff84.js";
4
+ import { K as _ } from "./keyCodes-f63c0e11.js";
5
+ import { B as p } from "./baseIconButton-251479f7.js";
6
+ import { S as V, a as k } from "./plus-0929dda4.js";
7
+ import { FieldLabel as H } from "./fieldLabel.js";
8
+ const P = 5, N = 16, j = [
9
+ _.TAB_KEY_CODE,
10
+ _.BACKSPACE_KEY_CODE,
11
+ _.ARROW_LEFT_KEY_CODE,
12
+ _.ARROW_UP_KEY_CODE,
13
+ _.ARROW_RIGHT_KEY_CODE,
14
+ _.ARROW_DOWN_KEY_CODE,
15
+ _.DELETE_KEY_CODE,
16
+ _.NUM_LOCK_0_KEY_CODE,
17
+ _.NUM_LOCK_1_KEY_CODE,
18
+ _.NUM_LOCK_2_KEY_CODE,
19
+ _.NUM_LOCK_3_KEY_CODE,
20
+ _.NUM_LOCK_4_KEY_CODE,
21
+ _.NUM_LOCK_5_KEY_CODE,
22
+ _.NUM_LOCK_6_KEY_CODE,
23
+ _.NUM_LOCK_7_KEY_CODE,
24
+ _.NUM_LOCK_8_KEY_CODE,
25
+ _.NUM_LOCK_9_KEY_CODE
26
+ ], z = "_sign_3v3h5_7", G = "_error_3v3h5_22", X = "_disabled_3v3h5_27", $ = "_input_3v3h5_12", b = {
27
+ "field-number": "_field-number_3v3h5_1",
28
+ sign: z,
29
+ "input-container": "_input-container_3v3h5_12",
30
+ error: G,
31
+ disabled: X,
32
+ "input-field": "_input-field_3v3h5_38",
33
+ input: $,
34
+ "additional-content": "_additional-content_3v3h5_84",
35
+ "error-text": "_error-text_3v3h5_88"
36
+ }, c = w.bind(b), en = ({
37
+ value: i = "",
38
+ placeholder: Y = "0",
39
+ disabled: t = !1,
40
+ onChange: s,
41
+ onFocus: d,
42
+ onBlur: O,
43
+ label: h,
44
+ postfix: o = "",
45
+ min: l = 0,
46
+ max: E = Number.MAX_SAFE_INTEGER,
47
+ title: L,
48
+ error: C,
49
+ id: D,
50
+ ...M
51
+ }) => {
52
+ const u = B(null), f = F(), R = (n) => n < l ? l : n > E ? E : n, U = (n) => {
53
+ let e = n.target.value.replace(/^0(?=\d+|^\d)/g, "");
54
+ if (e === "") {
55
+ s("");
56
+ return;
57
+ }
58
+ e = +e, s(e);
59
+ }, A = (n) => {
60
+ const e = +n.currentTarget.value, m = R(e);
61
+ m !== e && s(m), O && O(n);
62
+ }, g = (n) => {
63
+ const { keyCode: e } = n;
64
+ j.includes(e) || (e < _.NUMBER_START_KEY_CODE || e > _.NUMBER_END_KEY_CODE || n.shiftKey) && n.preventDefault();
65
+ }, T = () => {
66
+ const n = +i - 1;
67
+ n >= l && n <= E && s(n);
68
+ }, v = () => {
69
+ const n = +i + 1;
70
+ n >= l && n <= E && s(n);
71
+ }, K = Y + o, I = S(() => {
72
+ let n = (String(i) || K).length;
73
+ return o && !i && (n += 1), n > N ? `${N}ch` : `${n || P}ch`;
74
+ }, [K, o, i]), W = () => {
75
+ u && u.current && u.current.focus(), d && d();
76
+ };
77
+ return /* @__PURE__ */ a(y, { children: [
78
+ /* @__PURE__ */ a("div", { className: c("field-number", { disabled: t }), children: [
79
+ h && /* @__PURE__ */ r(H, { htmlFor: D ?? f, children: h }),
80
+ /* @__PURE__ */ a(
81
+ "div",
82
+ {
83
+ className: c("input-container", {
84
+ error: C,
85
+ disabled: t
86
+ }),
87
+ title: L,
88
+ children: [
89
+ /* @__PURE__ */ r(
90
+ p,
91
+ {
92
+ className: c("sign", "minus"),
93
+ disabled: t,
94
+ onClick: T,
95
+ children: /* @__PURE__ */ r(V, {})
96
+ }
97
+ ),
98
+ /* @__PURE__ */ a("span", { className: c("input-field", { disabled: t }), onClick: W, children: [
99
+ /* @__PURE__ */ r(
100
+ "input",
101
+ {
102
+ id: D ?? f,
103
+ ref: u,
104
+ className: c("input"),
105
+ type: "number",
106
+ value: i,
107
+ placeholder: K,
108
+ disabled: t,
109
+ min: l,
110
+ max: E,
111
+ onKeyDown: t ? void 0 : g,
112
+ onChange: t ? void 0 : U,
113
+ onFocus: t ? void 0 : d,
114
+ onBlur: t ? void 0 : A,
115
+ style: { width: I },
116
+ ...M
117
+ }
118
+ ),
119
+ !!o && (i === 0 || !!i) && /* @__PURE__ */ r("span", { children: o.slice(0, 1) })
120
+ ] }),
121
+ /* @__PURE__ */ r(
122
+ p,
123
+ {
124
+ className: c("sign", "plus"),
125
+ disabled: t,
126
+ onClick: v,
127
+ children: /* @__PURE__ */ r(k, {})
128
+ }
129
+ )
130
+ ]
131
+ }
132
+ )
133
+ ] }),
134
+ C && /* @__PURE__ */ r("div", { className: c("additional-content"), children: /* @__PURE__ */ r("span", { className: c("error-text"), children: C }) })
135
+ ] });
136
+ };
137
+ export {
138
+ en as F
139
+ };
@@ -1,4 +1,4 @@
1
- import { F as m } from "./fieldNumber-4a22c986.js";
1
+ import { F as m } from "./fieldNumber-1fa248f5.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
4
  import "./bind-06a7ff84.js";
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { D as M } from "./datePicker-efa4e2d6.js";
8
8
  import "react-datepicker";
9
9
  import { D as w } from "./dropdown-ec754bbe.js";
10
10
  import { FieldLabel as k } from "./fieldLabel.js";
11
- import { F as R } from "./fieldNumber-4a22c986.js";
11
+ import { F as R } from "./fieldNumber-1fa248f5.js";
12
12
  import { F as H } from "./fieldText-ba8a917c.js";
13
13
  import { F as N } from "./fieldTextFlex-8afaab31.js";
14
14
  import { FileDropArea as z, MIME_TYPES as W } from "./fileDropArea.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.101",
3
+ "version": "0.0.1-alpha.102",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,131 +0,0 @@
1
- import { jsxs as a, Fragment as v, jsx as i } from "react/jsx-runtime";
2
- import { useRef as T, useId as I, useMemo as W } from "react";
3
- import { c as y } from "./bind-06a7ff84.js";
4
- import { K as _ } from "./keyCodes-f63c0e11.js";
5
- import { B as p } from "./baseIconButton-251479f7.js";
6
- import { S as B, a as F } from "./plus-0929dda4.js";
7
- import { FieldLabel as S } from "./fieldLabel.js";
8
- const w = 5, N = 16, k = [
9
- _.TAB_KEY_CODE,
10
- _.BACKSPACE_KEY_CODE,
11
- _.ARROW_LEFT_KEY_CODE,
12
- _.ARROW_UP_KEY_CODE,
13
- _.ARROW_RIGHT_KEY_CODE,
14
- _.ARROW_DOWN_KEY_CODE,
15
- _.DELETE_KEY_CODE,
16
- _.NUM_LOCK_0_KEY_CODE,
17
- _.NUM_LOCK_1_KEY_CODE,
18
- _.NUM_LOCK_2_KEY_CODE,
19
- _.NUM_LOCK_3_KEY_CODE,
20
- _.NUM_LOCK_4_KEY_CODE,
21
- _.NUM_LOCK_5_KEY_CODE,
22
- _.NUM_LOCK_6_KEY_CODE,
23
- _.NUM_LOCK_7_KEY_CODE,
24
- _.NUM_LOCK_8_KEY_CODE,
25
- _.NUM_LOCK_9_KEY_CODE
26
- ], H = "_sign_3v3h5_7", V = "_error_3v3h5_22", P = "_disabled_3v3h5_27", b = "_input_3v3h5_12", j = {
27
- "field-number": "_field-number_3v3h5_1",
28
- sign: H,
29
- "input-container": "_input-container_3v3h5_12",
30
- error: V,
31
- disabled: P,
32
- "input-field": "_input-field_3v3h5_38",
33
- input: b,
34
- "additional-content": "_additional-content_3v3h5_84",
35
- "error-text": "_error-text_3v3h5_88"
36
- }, s = y.bind(j), Z = ({
37
- value: r = "",
38
- placeholder: m = "0",
39
- disabled: t = !1,
40
- onChange: C,
41
- onFocus: d,
42
- onBlur: G,
43
- label: O,
44
- postfix: o = "",
45
- min: c = 0,
46
- max: E = Number.MAX_SAFE_INTEGER,
47
- title: f,
48
- error: u,
49
- id: h,
50
- ...Y
51
- }) => {
52
- const l = T(null), D = I(), L = (n) => {
53
- let e = n.target.value.replace(/^0(?=\d+|^\d)/g, "");
54
- e = +e, e = e < c ? c : e, e >= c && e <= E && C(e);
55
- }, M = (n) => {
56
- const { keyCode: e } = n;
57
- k.includes(e) || (e < _.NUMBER_START_KEY_CODE || e > _.NUMBER_END_KEY_CODE || n.shiftKey) && n.preventDefault();
58
- }, R = () => {
59
- const n = +r - 1;
60
- n >= c && n <= E && C(n);
61
- }, U = () => {
62
- const n = +r + 1;
63
- n >= c && n <= E && C(n);
64
- }, K = m + o, A = W(() => {
65
- let n = (String(r) || K).length;
66
- return o && !r && (n += 1), n > N ? `${N}ch` : `${n || w}ch`;
67
- }, [K, o, r]), g = () => {
68
- l && l.current && l.current.focus(), d && d();
69
- };
70
- return /* @__PURE__ */ a(v, { children: [
71
- /* @__PURE__ */ a("div", { className: s("field-number", { disabled: t }), children: [
72
- O && /* @__PURE__ */ i(S, { htmlFor: h ?? D, children: O }),
73
- /* @__PURE__ */ a(
74
- "div",
75
- {
76
- className: s("input-container", {
77
- error: u,
78
- disabled: t
79
- }),
80
- title: f,
81
- children: [
82
- /* @__PURE__ */ i(
83
- p,
84
- {
85
- className: s("sign", "minus"),
86
- disabled: t,
87
- onClick: R,
88
- children: /* @__PURE__ */ i(B, {})
89
- }
90
- ),
91
- /* @__PURE__ */ a("span", { className: s("input-field", { disabled: t }), onClick: g, children: [
92
- /* @__PURE__ */ i(
93
- "input",
94
- {
95
- id: h ?? D,
96
- ref: l,
97
- className: s("input"),
98
- type: "number",
99
- value: r,
100
- placeholder: K,
101
- disabled: t,
102
- min: c,
103
- max: E,
104
- onKeyDown: t ? void 0 : M,
105
- onChange: t ? void 0 : L,
106
- onFocus: t ? void 0 : d,
107
- style: { width: A },
108
- ...Y
109
- }
110
- ),
111
- !!o && (r === 0 || !!r) && /* @__PURE__ */ i("span", { children: o.slice(0, 1) })
112
- ] }),
113
- /* @__PURE__ */ i(
114
- p,
115
- {
116
- className: s("sign", "plus"),
117
- disabled: t,
118
- onClick: U,
119
- children: /* @__PURE__ */ i(F, {})
120
- }
121
- )
122
- ]
123
- }
124
- )
125
- ] }),
126
- u && /* @__PURE__ */ i("div", { className: s("additional-content"), children: /* @__PURE__ */ i("span", { className: s("error-text"), children: u }) })
127
- ] });
128
- };
129
- export {
130
- Z as F
131
- };