@semcore/bulk-textarea 1.1.0-prerelease.4 → 1.1.0
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/CHANGELOG.md +15 -3
- package/lib/cjs/BulkTextarea.js +9 -7
- package/lib/cjs/BulkTextarea.js.map +1 -1
- package/lib/cjs/BulkTextarea.types.js.map +1 -1
- package/lib/cjs/components/InputField/InputField.js +42 -28
- package/lib/cjs/components/InputField/InputField.js.map +1 -1
- package/lib/cjs/components/InputField/InputField.types.js.map +1 -1
- package/lib/cjs/components/InputField/inputField.shadow.css +1 -0
- package/lib/es6/BulkTextarea.js +9 -7
- package/lib/es6/BulkTextarea.js.map +1 -1
- package/lib/es6/BulkTextarea.types.js.map +1 -1
- package/lib/es6/components/InputField/InputField.js +42 -28
- package/lib/es6/components/InputField/InputField.js.map +1 -1
- package/lib/es6/components/InputField/InputField.types.js.map +1 -1
- package/lib/es6/components/InputField/inputField.shadow.css +1 -0
- package/lib/esm/BulkTextarea.mjs +212 -0
- package/lib/esm/components/ClearAll.mjs +16 -0
- package/lib/esm/components/Counter.mjs +18 -0
- package/lib/esm/components/ErrorsNavigation.mjs +43 -0
- package/lib/esm/components/InputField/InputField.mjs +625 -0
- package/lib/esm/index.mjs +4 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +33 -0
- package/lib/esm/translations/de.json.mjs +13 -0
- package/lib/esm/translations/en.json.mjs +13 -0
- package/lib/esm/translations/es.json.mjs +13 -0
- package/lib/esm/translations/fr.json.mjs +13 -0
- package/lib/esm/translations/it.json.mjs +13 -0
- package/lib/esm/translations/ja.json.mjs +13 -0
- package/lib/esm/translations/ko.json.mjs +13 -0
- package/lib/esm/translations/nl.json.mjs +13 -0
- package/lib/esm/translations/pl.json.mjs +13 -0
- package/lib/esm/translations/pt.json.mjs +13 -0
- package/lib/esm/translations/sv.json.mjs +13 -0
- package/lib/esm/translations/tr.json.mjs +13 -0
- package/lib/esm/translations/vi.json.mjs +13 -0
- package/lib/esm/translations/zh.json.mjs +13 -0
- package/lib/types/BulkTextarea.types.d.ts +1 -1
- package/lib/types/components/InputField/InputField.d.ts +1 -0
- package/lib/types/components/InputField/InputField.types.d.ts +4 -3
- package/package.json +16 -11
- package/vite.config.ts +25 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import O from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import V from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import d from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import q from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import H from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import i from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
import M, { assignProps as j, Component as G } from "@semcore/core";
|
|
8
|
+
import m from "react";
|
|
9
|
+
import { Box as J } from "@semcore/flex-box";
|
|
10
|
+
import { InputField as K } from "./components/InputField/InputField.mjs";
|
|
11
|
+
import { Counter as Q } from "./components/Counter.mjs";
|
|
12
|
+
import { ClearAll as U } from "./components/ClearAll.mjs";
|
|
13
|
+
import { ErrorsNavigation as W } from "./components/ErrorsNavigation.mjs";
|
|
14
|
+
import { localizedMessages as X } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
15
|
+
import Y from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
16
|
+
import Z from "@semcore/utils/lib/enhances/focusSourceEnhance";
|
|
17
|
+
import rr from "@semcore/utils/lib/uniqueID";
|
|
18
|
+
var E = /* @__PURE__ */ function(_) {
|
|
19
|
+
q(x, _);
|
|
20
|
+
var R = H(x);
|
|
21
|
+
function x() {
|
|
22
|
+
var r;
|
|
23
|
+
O(this, x);
|
|
24
|
+
for (var e = arguments.length, t = new Array(e), l = 0; l < e; l++)
|
|
25
|
+
t[l] = arguments[l];
|
|
26
|
+
return r = R.call.apply(R, [this].concat(t)), i(d(r), "inputFieldRef", /* @__PURE__ */ m.createRef()), i(d(r), "clearAllButtonRef", /* @__PURE__ */ m.createRef()), i(d(r), "nextButtonRef", /* @__PURE__ */ m.createRef()), i(d(r), "prevButtonRef", /* @__PURE__ */ m.createRef()), i(d(r), "counterRef", /* @__PURE__ */ m.createRef()), i(d(r), "state", {
|
|
27
|
+
linesCount: 0,
|
|
28
|
+
isEmptyText: !0,
|
|
29
|
+
errorIndex: -1,
|
|
30
|
+
highlightErrorIndex: !1
|
|
31
|
+
}), i(d(r), "handleChangeLinesCount", function(n) {
|
|
32
|
+
var s = !n;
|
|
33
|
+
r.setState({
|
|
34
|
+
linesCount: n,
|
|
35
|
+
isEmptyText: s
|
|
36
|
+
}), s && (r.handlers.showErrors(!1), r.handlers.errors([]), r.handlers.state("normal"));
|
|
37
|
+
}), i(d(r), "handleClickClearAll", function(n) {
|
|
38
|
+
var s;
|
|
39
|
+
r.handlers.showErrors(!1), r.handlers.errors([]), r.setState({
|
|
40
|
+
errorIndex: -1
|
|
41
|
+
}), r.handlers.value("", n), r.handlers.state("normal");
|
|
42
|
+
var a = (s = r.inputFieldRef.current) === null || s === void 0 ? void 0 : s.querySelector('[role="textbox"]');
|
|
43
|
+
a instanceof HTMLDivElement && a.focus();
|
|
44
|
+
}), i(d(r), "handleChangeErrorIndex", function(n) {
|
|
45
|
+
return function() {
|
|
46
|
+
var s = r.asProps.errors, a = s === void 0 ? [] : s, h = r.state.errorIndex, u = a.length - 1, o = h + n;
|
|
47
|
+
o < 0 ? o = n + u + 1 : o > u && (o = o - u - 1), a[o] ? (r.handlers.showErrors(!1), r.setState({
|
|
48
|
+
errorIndex: -1
|
|
49
|
+
}), setTimeout(function() {
|
|
50
|
+
r.handlers.showErrors(!0), r.setState({
|
|
51
|
+
errorIndex: o,
|
|
52
|
+
highlightErrorIndex: !0
|
|
53
|
+
});
|
|
54
|
+
})) : r.handleChangeErrorIndex(n < 0 ? n - 1 : n + 1)();
|
|
55
|
+
};
|
|
56
|
+
}), r;
|
|
57
|
+
}
|
|
58
|
+
return V(x, [{
|
|
59
|
+
key: "uncontrolledProps",
|
|
60
|
+
value: function() {
|
|
61
|
+
return {
|
|
62
|
+
value: null,
|
|
63
|
+
state: null,
|
|
64
|
+
showErrors: null,
|
|
65
|
+
errors: null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "counterId",
|
|
70
|
+
get: function() {
|
|
71
|
+
return "".concat(this.asProps.uid, "_counter");
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "getInputFieldProps",
|
|
75
|
+
value: function() {
|
|
76
|
+
var e = this, t = this.asProps, l = t.value, n = t.size, s = t.minRows, a = t.maxRows, h = t.lineValidation, u = t.placeholder, o = t.validateOn, C = t.onChange, B = t.linesDelimiters, b = t.maxLines, $ = t.disabled, k = t.readonly, L = t.pasteProps, S = t.lineProcessing, w = t.errors, c = w === void 0 ? [] : w, y = t.showErrors, g = this.state, T = g.errorIndex, z = g.prevError, A = g.linesCount, F = g.highlightErrorIndex;
|
|
77
|
+
return i({
|
|
78
|
+
value: l,
|
|
79
|
+
size: n,
|
|
80
|
+
state: y && (c == null ? void 0 : c.length) > 0 ? "invalid" : "normal",
|
|
81
|
+
disabled: $,
|
|
82
|
+
readonly: k,
|
|
83
|
+
minRows: s,
|
|
84
|
+
maxRows: a,
|
|
85
|
+
maxLines: b,
|
|
86
|
+
placeholder: u,
|
|
87
|
+
prevError: z,
|
|
88
|
+
pasteProps: L,
|
|
89
|
+
linesCount: A,
|
|
90
|
+
lineProcessing: S,
|
|
91
|
+
onChangeLinesCount: this.handleChangeLinesCount,
|
|
92
|
+
onChangeLineIndex: function() {
|
|
93
|
+
o != null && o.includes("blurLine") && e.handlers.showErrors(!0);
|
|
94
|
+
},
|
|
95
|
+
onBlur: function(f, p) {
|
|
96
|
+
o != null && o.includes("blur") && (e.asProps.focusSourceRef.current === "keyboard" || p instanceof FocusEvent && p.relatedTarget !== e.clearAllButtonRef.current) && e.handlers.showErrors(!0), e.asProps.showErrors === !1 && (o != null && o.includes("blur") || o != null && o.includes("blurLine")) && setTimeout(function() {
|
|
97
|
+
var v;
|
|
98
|
+
(v = e.nextButtonRef.current) === null || v === void 0 || v.focus();
|
|
99
|
+
}, 250), C == null || C(f, p);
|
|
100
|
+
},
|
|
101
|
+
showErrors: y,
|
|
102
|
+
validateOn: o,
|
|
103
|
+
lineValidation: h,
|
|
104
|
+
errors: c,
|
|
105
|
+
onErrorsChange: function(f) {
|
|
106
|
+
var p = f.length === 0 ? c[0] : void 0;
|
|
107
|
+
e.handlers.errors(f), e.setState({
|
|
108
|
+
prevError: p
|
|
109
|
+
}), setTimeout(function() {
|
|
110
|
+
var v = e.asProps, N = v.showErrors, P = v.errors;
|
|
111
|
+
if (N) {
|
|
112
|
+
var D = f.length === 0 ? "normal" : "invalid";
|
|
113
|
+
e.handlers.state(D);
|
|
114
|
+
}
|
|
115
|
+
(P == null ? void 0 : P.length) === 0 && (e.handlers.showErrors(!1), setTimeout(function() {
|
|
116
|
+
e.setState({
|
|
117
|
+
prevError: void 0
|
|
118
|
+
});
|
|
119
|
+
}, 150));
|
|
120
|
+
}, 10);
|
|
121
|
+
},
|
|
122
|
+
highlightErrorIndex: F,
|
|
123
|
+
errorIndex: T,
|
|
124
|
+
onErrorIndexChange: function(f) {
|
|
125
|
+
var p = c[T];
|
|
126
|
+
e.setState({
|
|
127
|
+
errorIndex: f,
|
|
128
|
+
prevError: p,
|
|
129
|
+
highlightErrorIndex: !1
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
linesDelimiters: B,
|
|
133
|
+
ref: this.inputFieldRef
|
|
134
|
+
}, "aria-describedby", this.counterId);
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "getCounterProps",
|
|
138
|
+
value: function() {
|
|
139
|
+
var e = this.asProps, t = e.maxLines, l = e.getI18nText, n = e.size, s = this.state, a = s.linesCount, h = s.isEmptyText, u = "";
|
|
140
|
+
return a === t ? u = "warning" : a > t && (u = "danger"), {
|
|
141
|
+
id: this.counterId,
|
|
142
|
+
ref: this.counterRef,
|
|
143
|
+
getI18nText: l,
|
|
144
|
+
theme: u,
|
|
145
|
+
linesCount: h ? 0 : a,
|
|
146
|
+
maxLines: t,
|
|
147
|
+
size: n
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "getClearAllProps",
|
|
152
|
+
value: function() {
|
|
153
|
+
var e = this.asProps, t = e.size, l = e.getI18nText, n = e.disabled, s = e.readonly;
|
|
154
|
+
return {
|
|
155
|
+
onClick: this.handleClickClearAll,
|
|
156
|
+
isHidden: this.state.isEmptyText,
|
|
157
|
+
size: t,
|
|
158
|
+
getI18nText: l,
|
|
159
|
+
ref: this.clearAllButtonRef,
|
|
160
|
+
disabled: n || s
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "getErrorsNavigationProps",
|
|
165
|
+
value: function() {
|
|
166
|
+
var e = this.asProps, t = e.size, l = e.getI18nText, n = e.disabled, s = e.readonly, a = e.errors, h = a === void 0 ? [] : a, u = e.showErrors, o = this.state.errorIndex;
|
|
167
|
+
return {
|
|
168
|
+
size: t,
|
|
169
|
+
getI18nText: l,
|
|
170
|
+
errorIndex: o,
|
|
171
|
+
onPrevError: this.handleChangeErrorIndex(-1),
|
|
172
|
+
onNextError: this.handleChangeErrorIndex(1),
|
|
173
|
+
errorsCount: h.map(Boolean).length,
|
|
174
|
+
showErrors: u,
|
|
175
|
+
disabled: n || s || !1,
|
|
176
|
+
nextButtonRef: this.nextButtonRef,
|
|
177
|
+
prevButtonRef: this.prevButtonRef
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "render",
|
|
182
|
+
value: function() {
|
|
183
|
+
var e = this.asProps;
|
|
184
|
+
return /* @__PURE__ */ m.createElement(J, j({
|
|
185
|
+
__excludeProps: ["onBlur", "value", "placeholder"]
|
|
186
|
+
}, e));
|
|
187
|
+
}
|
|
188
|
+
}]), x;
|
|
189
|
+
}(G);
|
|
190
|
+
i(E, "displayName", "BulkTextarea");
|
|
191
|
+
i(E, "defaultProps", {
|
|
192
|
+
defaultValue: "",
|
|
193
|
+
size: "m",
|
|
194
|
+
defaultState: "normal",
|
|
195
|
+
minRows: 2,
|
|
196
|
+
maxRows: 10,
|
|
197
|
+
maxLines: 100,
|
|
198
|
+
validateOn: "blur",
|
|
199
|
+
locale: "en",
|
|
200
|
+
defaultErrors: [],
|
|
201
|
+
defaultShowErrors: !1
|
|
202
|
+
});
|
|
203
|
+
i(E, "enhance", [Y(X), Z(), rr()]);
|
|
204
|
+
var gr = M(E, {
|
|
205
|
+
InputField: K,
|
|
206
|
+
Counter: Q,
|
|
207
|
+
ClearAll: U,
|
|
208
|
+
ErrorsNavigation: W
|
|
209
|
+
});
|
|
210
|
+
export {
|
|
211
|
+
gr as default
|
|
212
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import n from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { sstyled as m, assignProps as a } from "@semcore/core";
|
|
3
|
+
import l from "react";
|
|
4
|
+
import u from "@semcore/button";
|
|
5
|
+
import i from "@semcore/icon/Close/m";
|
|
6
|
+
function p(t) {
|
|
7
|
+
var r = arguments[0], e, o = u;
|
|
8
|
+
return !t.isHidden && (e = m(t.styles), /* @__PURE__ */ l.createElement(o, e.cn("SButton", n({}, a({
|
|
9
|
+
theme: "muted",
|
|
10
|
+
use: "tertiary",
|
|
11
|
+
addonLeft: i
|
|
12
|
+
}, r))), t.getI18nText("BulkTextarea.ClearAllButton.buttonText")));
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
p as ClearAll
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assignProps as i } from "@semcore/core";
|
|
2
|
+
import e from "react";
|
|
3
|
+
import { ScreenReaderOnly as a } from "@semcore/flex-box";
|
|
4
|
+
import u from "@semcore/counter";
|
|
5
|
+
function d(t) {
|
|
6
|
+
var l = arguments[0], r = t.theme, o = t.linesCount, m = t.maxLines, n = t.getI18nText;
|
|
7
|
+
return /* @__PURE__ */ e.createElement(u, i({
|
|
8
|
+
ml: 1,
|
|
9
|
+
theme: r
|
|
10
|
+
}, l), o, /* @__PURE__ */ e.createElement("span", {
|
|
11
|
+
"aria-hidden": "true"
|
|
12
|
+
}, "/", m), /* @__PURE__ */ e.createElement(a, null, n("BulkTextarea.Counter.ofAllowedRows:sr-message", {
|
|
13
|
+
rowsNumber: m
|
|
14
|
+
})), r === "warning" && /* @__PURE__ */ e.createElement(a, null, n("BulkTextarea.Counter.limitReached:sr-message")), r === "danger" && /* @__PURE__ */ e.createElement(a, null, n("BulkTextarea.Counter.limitExceeded:sr-message")));
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
d as Counter
|
|
18
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import i from "@semcore/button";
|
|
3
|
+
import { Flex as f } from "@semcore/flex-box";
|
|
4
|
+
import { Text as d } from "@semcore/typography";
|
|
5
|
+
import s from "@semcore/icon/ChevronUp/m";
|
|
6
|
+
import v from "@semcore/icon/ChevronDown/m";
|
|
7
|
+
function k(r) {
|
|
8
|
+
var n = r.errorIndex, o = r.errorsCount, l = r.onPrevError, m = r.onNextError, E = r.size, u = r.showErrors, t = r.getI18nText, a = r.disabled, x = r.nextButtonRef, c = r.prevButtonRef;
|
|
9
|
+
return /* @__PURE__ */ e.createElement(f, {
|
|
10
|
+
alignItems: "center"
|
|
11
|
+
}, o > 0 && u && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(i, {
|
|
12
|
+
onClick: m,
|
|
13
|
+
addonLeft: v,
|
|
14
|
+
use: "tertiary",
|
|
15
|
+
theme: "muted",
|
|
16
|
+
"aria-label": t("BulkTextarea.ErrorsNavigation.nextError:aria-label"),
|
|
17
|
+
hintPlacement: "bottom",
|
|
18
|
+
disabled: a,
|
|
19
|
+
ref: x
|
|
20
|
+
}), /* @__PURE__ */ e.createElement(i, {
|
|
21
|
+
onClick: l,
|
|
22
|
+
addonLeft: s,
|
|
23
|
+
use: "tertiary",
|
|
24
|
+
theme: "muted",
|
|
25
|
+
"aria-label": t("BulkTextarea.ErrorsNavigation.previousError:aria-label"),
|
|
26
|
+
hintPlacement: "bottom",
|
|
27
|
+
disabled: a,
|
|
28
|
+
ref: c
|
|
29
|
+
}), /* @__PURE__ */ e.createElement(d, {
|
|
30
|
+
size: E === "l" ? 300 : 200,
|
|
31
|
+
color: "text-critical",
|
|
32
|
+
ml: 1,
|
|
33
|
+
disabled: a
|
|
34
|
+
}, n === -1 ? t("BulkTextarea.ErrorsNavigation.totalErrors", {
|
|
35
|
+
errorsCount: o
|
|
36
|
+
}) : t("BulkTextarea.ErrorsNavigation.selectedError", {
|
|
37
|
+
errorIndex: n + 1,
|
|
38
|
+
errorsCount: o
|
|
39
|
+
}))));
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
k as ErrorsNavigation
|
|
43
|
+
};
|