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