@reportportal/ui-kit 0.0.1-alpha.247 → 0.0.1-alpha.248

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,24 @@
1
+ import { useState as d, useCallback as r, useEffect as k } from "react";
2
+ const n = (e) => {
3
+ var i, o, s;
4
+ return ((i = e == null ? void 0 : e.getModifierState) == null ? void 0 : i.call(e, "CapsLock")) ?? ((s = (o = e == null ? void 0 : e.nativeEvent) == null ? void 0 : o.getModifierState) == null ? void 0 : s.call(o, "CapsLock")) ?? !1;
5
+ }, u = () => {
6
+ const [e, i] = d(!1), o = r((s) => {
7
+ i(n(s));
8
+ }, []);
9
+ return k(() => {
10
+ const s = (t) => {
11
+ i(n(t));
12
+ }, a = (t) => {
13
+ t.key === "CapsLock" && i(n(t));
14
+ }, c = () => {
15
+ document.visibilityState === "visible" && i(!1);
16
+ };
17
+ return window.addEventListener("keydown", s), window.addEventListener("keyup", a), document.addEventListener("visibilitychange", c), () => {
18
+ window.removeEventListener("keydown", s), window.removeEventListener("keyup", a), document.removeEventListener("visibilitychange", c);
19
+ };
20
+ }, []), { capsLockOn: e, syncFromMouseEvent: o };
21
+ };
22
+ export {
23
+ u
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.247",
3
+ "version": "0.0.1-alpha.248",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,189 +0,0 @@
1
- import { jsx as t, jsxs as s, Fragment as E } from "react/jsx-runtime";
2
- import { forwardRef as M, useRef as tt, useId as nt, useState as b } from "react";
3
- import { c as ot } from "./bind-06a7ff84.js";
4
- import { S as et } from "./clear-53660571.js";
5
- import { b as ct, a as st, S as rt } from "./capslockIcon-b100b9d6.js";
6
- import { B as at } from "./baseIconButton-251479f7.js";
7
- import { S as it } from "./spinLoader-c4a53718.js";
8
- import { M as lt } from "./maxValueDisplay-9be01a75.js";
9
- import { FieldLabel as pt } from "./fieldLabel.js";
10
- import "react-dnd";
11
- import "react-dnd-html5-backend";
12
- import { u as _t } from "./useCapsLock-65753959.js";
13
- import { Tooltip as dt } from "./tooltip.js";
14
- const mt = "_collapsed_1vr19_11", ft = "_field_1vr19_23", ut = "_placeholder_1vr19_48", ht = "_disabled_1vr19_51", vt = "_error_1vr19_54", xt = "_touched_1vr19_54", wt = "_input_1vr19_73", Nt = "_icon_1vr19_1", kt = "_text_1vr19_207", yt = {
15
- "icon-container": "_icon-container_1vr19_1",
16
- "icon-container-additional": "_icon-container-additional_1vr19_1",
17
- "icon-container-end": "_icon-container-end_1vr19_1",
18
- "icon-container-start": "_icon-container-start_1vr19_1",
19
- collapsed: mt,
20
- field: ft,
21
- "default-width": "_default-width_1vr19_35",
22
- placeholder: ut,
23
- disabled: ht,
24
- error: vt,
25
- touched: xt,
26
- "max-length-display": "_max-length-display_1vr19_61",
27
- "input-container": "_input-container_1vr19_73",
28
- "type-password": "_type-password_1vr19_77",
29
- input: wt,
30
- "with-caps-lock": "_with-caps-lock_1vr19_81",
31
- "caps-lock-tooltip-wrapper": "_caps-lock-tooltip-wrapper_1vr19_84",
32
- "caps-lock-tooltip-content": "_caps-lock-tooltip-content_1vr19_96",
33
- "caps-lock-icon": "_caps-lock-icon_1vr19_107",
34
- "eye-icon": "_eye-icon_1vr19_117",
35
- icon: Nt,
36
- "start-icon": "_start-icon_1vr19_163",
37
- "clear-icon": "_clear-icon_1vr19_164",
38
- "additional-content": "_additional-content_1vr19_200",
39
- text: kt,
40
- "error-text": "_error-text_1vr19_227",
41
- "help-text": "_help-text_1vr19_231"
42
- }, n = ot.bind(yt), Dt = M(
43
- ({
44
- value: e = "",
45
- className: B,
46
- classNameHelpText: V,
47
- error: a,
48
- placeholder: u,
49
- disabled: c = !1,
50
- onChange: I,
51
- touched: h = !1,
52
- title: L,
53
- label: i,
54
- helpText: l,
55
- defaultWidth: P = !0,
56
- startIcon: v,
57
- endIcon: x,
58
- clearable: R = !1,
59
- onClear: w,
60
- isRequired: N = !1,
61
- hasDoubleMessage: j = !1,
62
- type: r = "text",
63
- displayError: D = !0,
64
- collapsible: H = !1,
65
- loading: O = !1,
66
- maxLengthDisplay: T,
67
- capsLockMessage: p,
68
- onFocus: $ = () => {
69
- },
70
- onBlur: z = () => {
71
- },
72
- onMouseDown: _,
73
- ...A
74
- }, G) => {
75
- const J = tt(null), d = G || J, k = nt(), [m, y] = b(!1), [g, K] = b(!1), { capsLockOn: Q, syncFromMouseEvent: U } = _t(), C = !!p && m && Q && e.length >= 1 && !c, W = (o) => {
76
- y(!0), $(o);
77
- }, X = (o) => {
78
- y(!1), z(o);
79
- }, Y = () => {
80
- var o;
81
- w && (w(e), (o = d.current) == null || o.focus());
82
- }, F = D && a && h, S = /* @__PURE__ */ t("span", { className: n("text", "help-text", V), children: l }), Z = () => r !== "password" ? r : g ? "text" : "password", q = () => {
83
- K((o) => !o);
84
- };
85
- return /* @__PURE__ */ s(E, { children: [
86
- i && /* @__PURE__ */ t(pt, { isRequired: N, htmlFor: k, children: i }),
87
- /* @__PURE__ */ s(
88
- "div",
89
- {
90
- className: n("field", B, {
91
- error: a,
92
- touched: h,
93
- disabled: c,
94
- "default-width": P,
95
- collapsed: H && !m && !e
96
- }),
97
- title: L,
98
- children: [
99
- O ? /* @__PURE__ */ t(it, {}) : v && /* @__PURE__ */ t(
100
- "span",
101
- {
102
- className: n("icon-container-start"),
103
- onClick: () => {
104
- var f;
105
- (f = d.current) == null || f.focus();
106
- },
107
- children: /* @__PURE__ */ t("span", { className: n("icon", { "start-icon": !m }), children: v })
108
- }
109
- ),
110
- /* @__PURE__ */ s(
111
- "span",
112
- {
113
- className: n("input-container", `type-${r}`, { "with-caps-lock": C }),
114
- children: [
115
- /* @__PURE__ */ t(
116
- "input",
117
- {
118
- ref: d,
119
- type: Z(),
120
- className: n("input"),
121
- value: e,
122
- disabled: c,
123
- id: k,
124
- onChange: I,
125
- onFocus: W,
126
- onBlur: X,
127
- onMouseDown: (o) => {
128
- p && U(o.nativeEvent), _ == null || _(o);
129
- },
130
- ...A
131
- }
132
- ),
133
- C && /* @__PURE__ */ t(
134
- dt,
135
- {
136
- content: p,
137
- wrapperClassName: n("caps-lock-tooltip-wrapper"),
138
- contentClassName: n("caps-lock-tooltip-content"),
139
- children: /* @__PURE__ */ t("span", { className: n("caps-lock-icon"), children: /* @__PURE__ */ t(ct, {}) })
140
- }
141
- ),
142
- r === "password" && e && /* @__PURE__ */ t(
143
- at,
144
- {
145
- className: n("eye-icon"),
146
- onClick: q,
147
- onPointerDown: (o) => o.preventDefault(),
148
- children: g ? /* @__PURE__ */ t(st, {}) : /* @__PURE__ */ t(rt, {})
149
- }
150
- ),
151
- u && !e && /* @__PURE__ */ s("span", { className: n("placeholder"), children: [
152
- u,
153
- N && !i && /* @__PURE__ */ t("span", { className: n("asterisk") })
154
- ] })
155
- ]
156
- }
157
- ),
158
- /* @__PURE__ */ t(
159
- lt,
160
- {
161
- className: n("max-length-display"),
162
- value: e.length,
163
- maxValue: T
164
- }
165
- ),
166
- R && e.length > 0 && /* @__PURE__ */ t("span", { className: n("icon-container-end"), children: /* @__PURE__ */ t(
167
- "button",
168
- {
169
- type: "button",
170
- className: n("clear-icon", { disabled: c }),
171
- onClick: Y,
172
- onMouseDown: (o) => o.preventDefault(),
173
- children: /* @__PURE__ */ t(et, {})
174
- }
175
- ) }),
176
- x && /* @__PURE__ */ t("span", { className: n("icon-container-end"), children: /* @__PURE__ */ t("span", { className: n("icon"), children: x }) })
177
- ]
178
- }
179
- ),
180
- (F || l) && /* @__PURE__ */ t("div", { className: n("additional-content", { disabled: c }), children: F ? /* @__PURE__ */ s(E, { children: [
181
- /* @__PURE__ */ t("span", { className: n("text", "error-text"), children: a }),
182
- j && S
183
- ] }) : l && S })
184
- ] });
185
- }
186
- );
187
- export {
188
- Dt as F
189
- };
@@ -1,21 +0,0 @@
1
- import { useState as c, useCallback as d, useEffect as r } from "react";
2
- const u = () => {
3
- const [s, e] = c(!1), a = d((t) => {
4
- e(t.getModifierState("CapsLock"));
5
- }, []);
6
- return r(() => {
7
- const t = (n) => {
8
- e(n.getModifierState("CapsLock"));
9
- }, i = (n) => {
10
- n.key === "CapsLock" && e(n.getModifierState("CapsLock"));
11
- }, o = () => {
12
- document.visibilityState === "visible" && e(!1);
13
- };
14
- return window.addEventListener("keydown", t), window.addEventListener("keyup", i), document.addEventListener("visibilitychange", o), () => {
15
- window.removeEventListener("keydown", t), window.removeEventListener("keyup", i), document.removeEventListener("visibilitychange", o);
16
- };
17
- }, []), { capsLockOn: s, syncFromMouseEvent: a };
18
- };
19
- export {
20
- u
21
- };