@reportportal/ui-kit 0.0.1-alpha.100 → 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.
- package/dist/fieldNumber-1fa248f5.js +139 -0
- package/dist/fieldNumber.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/fieldNumber-c9113a7f.js +0 -135
|
@@ -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
|
+
};
|
package/dist/fieldNumber.js
CHANGED
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-
|
|
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,135 +0,0 @@
|
|
|
1
|
-
import { jsxs as d, 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, m = 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: N = "0",
|
|
39
|
-
disabled: t = !1,
|
|
40
|
-
onChange: o,
|
|
41
|
-
onFocus: C,
|
|
42
|
-
onBlur: G,
|
|
43
|
-
label: O,
|
|
44
|
-
postfix: c = "",
|
|
45
|
-
min: E = 0,
|
|
46
|
-
max: l = Number.MAX_SAFE_INTEGER,
|
|
47
|
-
title: f,
|
|
48
|
-
error: u,
|
|
49
|
-
id: h,
|
|
50
|
-
...Y
|
|
51
|
-
}) => {
|
|
52
|
-
const a = T(null), D = I(), L = (n) => {
|
|
53
|
-
let e = n.target.value.replace(/^0(?=\d+|^\d)/g, "");
|
|
54
|
-
if (e === "") {
|
|
55
|
-
o("");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
e = +e, e >= E && e <= l && o(e);
|
|
59
|
-
}, M = (n) => {
|
|
60
|
-
const { keyCode: e } = n;
|
|
61
|
-
k.includes(e) || (e < _.NUMBER_START_KEY_CODE || e > _.NUMBER_END_KEY_CODE || n.shiftKey) && n.preventDefault();
|
|
62
|
-
}, R = () => {
|
|
63
|
-
const n = +r - 1;
|
|
64
|
-
n >= E && n <= l && o(n);
|
|
65
|
-
}, U = () => {
|
|
66
|
-
const n = +r + 1;
|
|
67
|
-
n >= E && n <= l && o(n);
|
|
68
|
-
}, K = N + c, A = W(() => {
|
|
69
|
-
let n = (String(r) || K).length;
|
|
70
|
-
return c && !r && (n += 1), n > m ? `${m}ch` : `${n || w}ch`;
|
|
71
|
-
}, [K, c, r]), g = () => {
|
|
72
|
-
a && a.current && a.current.focus(), C && C();
|
|
73
|
-
};
|
|
74
|
-
return /* @__PURE__ */ d(v, { children: [
|
|
75
|
-
/* @__PURE__ */ d("div", { className: s("field-number", { disabled: t }), children: [
|
|
76
|
-
O && /* @__PURE__ */ i(S, { htmlFor: h ?? D, children: O }),
|
|
77
|
-
/* @__PURE__ */ d(
|
|
78
|
-
"div",
|
|
79
|
-
{
|
|
80
|
-
className: s("input-container", {
|
|
81
|
-
error: u,
|
|
82
|
-
disabled: t
|
|
83
|
-
}),
|
|
84
|
-
title: f,
|
|
85
|
-
children: [
|
|
86
|
-
/* @__PURE__ */ i(
|
|
87
|
-
p,
|
|
88
|
-
{
|
|
89
|
-
className: s("sign", "minus"),
|
|
90
|
-
disabled: t,
|
|
91
|
-
onClick: R,
|
|
92
|
-
children: /* @__PURE__ */ i(B, {})
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
/* @__PURE__ */ d("span", { className: s("input-field", { disabled: t }), onClick: g, children: [
|
|
96
|
-
/* @__PURE__ */ i(
|
|
97
|
-
"input",
|
|
98
|
-
{
|
|
99
|
-
id: h ?? D,
|
|
100
|
-
ref: a,
|
|
101
|
-
className: s("input"),
|
|
102
|
-
type: "number",
|
|
103
|
-
value: r,
|
|
104
|
-
placeholder: K,
|
|
105
|
-
disabled: t,
|
|
106
|
-
min: E,
|
|
107
|
-
max: l,
|
|
108
|
-
onKeyDown: t ? void 0 : M,
|
|
109
|
-
onChange: t ? void 0 : L,
|
|
110
|
-
onFocus: t ? void 0 : C,
|
|
111
|
-
style: { width: A },
|
|
112
|
-
...Y
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
!!c && (r === 0 || !!r) && /* @__PURE__ */ i("span", { children: c.slice(0, 1) })
|
|
116
|
-
] }),
|
|
117
|
-
/* @__PURE__ */ i(
|
|
118
|
-
p,
|
|
119
|
-
{
|
|
120
|
-
className: s("sign", "plus"),
|
|
121
|
-
disabled: t,
|
|
122
|
-
onClick: U,
|
|
123
|
-
children: /* @__PURE__ */ i(F, {})
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
] }),
|
|
130
|
-
u && /* @__PURE__ */ i("div", { className: s("additional-content"), children: /* @__PURE__ */ i("span", { className: s("error-text"), children: u }) })
|
|
131
|
-
] });
|
|
132
|
-
};
|
|
133
|
-
export {
|
|
134
|
-
Z as F
|
|
135
|
-
};
|