tgui-core 1.7.6 → 1.8.1
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/common/collections.d.ts +7 -0
- package/dist/common/collections.js +7 -3
- package/dist/common/ui.js +67 -67
- package/dist/components/Input.js +39 -36
- package/dist/components/MenuBar.js +9 -9
- package/dist/components/TextArea.d.ts +2 -0
- package/dist/components/TextArea.js +82 -68
- package/package.json +1 -1
|
@@ -7,4 +7,11 @@ type Zip<T extends unknown[][]> = {
|
|
|
7
7
|
* the second elements of the given arrays, and so on.
|
|
8
8
|
*/
|
|
9
9
|
export declare function zip<T extends unknown[][]>(...arr: T): Zip<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Helper function for string compares with native sorts
|
|
12
|
+
* @param a first string to compare
|
|
13
|
+
* @param b second string to compare
|
|
14
|
+
* @returns -1 for a < b, 1 for a > b and 0 otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function stringCompare(a: string, b: string): 0 | 1 | -1;
|
|
10
17
|
export {};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
return Array(Math.max(...
|
|
1
|
+
function p(...n) {
|
|
2
|
+
return Array(Math.max(...n.map((t) => t.length))).fill(void 0).map((t, r) => n.map((i) => i[r]));
|
|
3
|
+
}
|
|
4
|
+
function a(n, t) {
|
|
5
|
+
return n < t ? -1 : n > t ? 1 : 0;
|
|
3
6
|
}
|
|
4
7
|
export {
|
|
5
|
-
|
|
8
|
+
a as stringCompare,
|
|
9
|
+
p as zip
|
|
6
10
|
};
|
package/dist/common/ui.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import { CSS_COLORS as u } from "./constants.js";
|
|
2
2
|
import { classes as y } from "./react.js";
|
|
3
|
-
const f = (
|
|
4
|
-
if (typeof
|
|
5
|
-
return
|
|
6
|
-
if (typeof
|
|
7
|
-
return `${
|
|
8
|
-
}, p = (
|
|
9
|
-
if (typeof
|
|
10
|
-
return f(
|
|
11
|
-
if (typeof
|
|
12
|
-
return f(
|
|
3
|
+
const f = (t) => {
|
|
4
|
+
if (typeof t == "string")
|
|
5
|
+
return t.endsWith("px") ? `${Number.parseFloat(t) / 12}rem` : t;
|
|
6
|
+
if (typeof t == "number")
|
|
7
|
+
return `${t}rem`;
|
|
8
|
+
}, p = (t) => {
|
|
9
|
+
if (typeof t == "string")
|
|
10
|
+
return f(t);
|
|
11
|
+
if (typeof t == "number")
|
|
12
|
+
return f(t * 0.5);
|
|
13
13
|
};
|
|
14
|
-
function w(
|
|
15
|
-
return !h(
|
|
14
|
+
function w(t) {
|
|
15
|
+
return !h(t);
|
|
16
16
|
}
|
|
17
|
-
function h(
|
|
18
|
-
return typeof
|
|
17
|
+
function h(t) {
|
|
18
|
+
return typeof t == "string" && u.includes(t);
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
(typeof i == "number" || typeof i == "string") && (t
|
|
22
|
-
}, n = (
|
|
23
|
-
(typeof e == "number" || typeof e == "string") && (i[
|
|
24
|
-
},
|
|
25
|
-
e && (i[
|
|
26
|
-
},
|
|
20
|
+
const l = (t) => (o, i) => {
|
|
21
|
+
(typeof i == "number" || typeof i == "string") && (o[t] = i);
|
|
22
|
+
}, n = (t, o) => (i, e) => {
|
|
23
|
+
(typeof e == "number" || typeof e == "string") && (i[t] = o(e));
|
|
24
|
+
}, s = (t, o) => (i, e) => {
|
|
25
|
+
e && (i[t] = o);
|
|
26
|
+
}, c = (t, o, i) => (e, r) => {
|
|
27
27
|
if (typeof r == "number" || typeof r == "string")
|
|
28
28
|
for (let m = 0; m < i.length; m++)
|
|
29
|
-
e[
|
|
30
|
-
}, a = (
|
|
31
|
-
w(i) && (t
|
|
29
|
+
e[t + i[m]] = o(r);
|
|
30
|
+
}, a = (t) => (o, i) => {
|
|
31
|
+
w(i) && (o[t] = i);
|
|
32
32
|
}, d = {
|
|
33
|
-
align:
|
|
33
|
+
align: l("textAlign"),
|
|
34
34
|
bottom: n("bottom", f),
|
|
35
|
-
fontFamily:
|
|
35
|
+
fontFamily: l("fontFamily"),
|
|
36
36
|
fontSize: n("fontSize", f),
|
|
37
|
-
fontWeight:
|
|
37
|
+
fontWeight: l("fontWeight"),
|
|
38
38
|
height: n("height", f),
|
|
39
39
|
left: n("left", f),
|
|
40
40
|
maxHeight: n("maxHeight", f),
|
|
41
41
|
maxWidth: n("maxWidth", f),
|
|
42
42
|
minHeight: n("minHeight", f),
|
|
43
43
|
minWidth: n("minWidth", f),
|
|
44
|
-
opacity:
|
|
45
|
-
overflow:
|
|
46
|
-
overflowX:
|
|
47
|
-
overflowY:
|
|
48
|
-
position:
|
|
44
|
+
opacity: l("opacity"),
|
|
45
|
+
overflow: l("overflow"),
|
|
46
|
+
overflowX: l("overflowX"),
|
|
47
|
+
overflowY: l("overflowY"),
|
|
48
|
+
position: l("position"),
|
|
49
49
|
right: n("right", f),
|
|
50
|
-
textAlign:
|
|
50
|
+
textAlign: l("textAlign"),
|
|
51
51
|
top: n("top", f),
|
|
52
|
-
verticalAlign:
|
|
52
|
+
verticalAlign: l("verticalAlign"),
|
|
53
53
|
width: n("width", f),
|
|
54
|
-
lineHeight: (
|
|
55
|
-
typeof
|
|
54
|
+
lineHeight: (t, o) => {
|
|
55
|
+
typeof o == "number" ? t.lineHeight = o : typeof o == "string" && (t.lineHeight = f(o));
|
|
56
56
|
},
|
|
57
57
|
// Margin
|
|
58
|
-
m:
|
|
58
|
+
m: c("margin", p, [
|
|
59
59
|
"Top",
|
|
60
60
|
"Bottom",
|
|
61
61
|
"Left",
|
|
@@ -65,10 +65,10 @@ const c = (o) => (t, i) => {
|
|
|
65
65
|
ml: n("marginLeft", p),
|
|
66
66
|
mr: n("marginRight", p),
|
|
67
67
|
mt: n("marginTop", p),
|
|
68
|
-
mx:
|
|
69
|
-
my:
|
|
68
|
+
mx: c("margin", p, ["left", "right"]),
|
|
69
|
+
my: c("margin", p, ["top", "bottom"]),
|
|
70
70
|
// Padding
|
|
71
|
-
p:
|
|
71
|
+
p: c("padding", p, [
|
|
72
72
|
"Top",
|
|
73
73
|
"Bottom",
|
|
74
74
|
"Left",
|
|
@@ -78,58 +78,58 @@ const c = (o) => (t, i) => {
|
|
|
78
78
|
pl: n("paddingLeft", p),
|
|
79
79
|
pr: n("paddingRight", p),
|
|
80
80
|
pt: n("paddingTop", p),
|
|
81
|
-
px:
|
|
82
|
-
py:
|
|
81
|
+
px: c("padding", p, ["left", "right"]),
|
|
82
|
+
py: c("padding", p, ["top", "bottom"]),
|
|
83
83
|
// Color props
|
|
84
84
|
color: a("color"),
|
|
85
85
|
textColor: a("color"),
|
|
86
86
|
backgroundColor: a("backgroundColor")
|
|
87
87
|
}, b = {
|
|
88
|
-
bold:
|
|
89
|
-
fillPositionedParent: (
|
|
90
|
-
|
|
88
|
+
bold: s("fontWeight", "bold"),
|
|
89
|
+
fillPositionedParent: (t, o) => {
|
|
90
|
+
o && (t.position = "absolute", t.top = 0, t.bottom = 0, t.left = 0, t.right = 0);
|
|
91
91
|
},
|
|
92
|
-
inline:
|
|
93
|
-
italic:
|
|
94
|
-
nowrap:
|
|
95
|
-
preserveWhitespace:
|
|
92
|
+
inline: s("display", "inline-block"),
|
|
93
|
+
italic: s("fontStyle", "italic"),
|
|
94
|
+
nowrap: s("whiteSpace", "nowrap"),
|
|
95
|
+
preserveWhitespace: s("whiteSpace", "pre-wrap")
|
|
96
96
|
};
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
for (const e in
|
|
97
|
+
function S(t) {
|
|
98
|
+
const o = {}, i = {};
|
|
99
|
+
for (const e in t) {
|
|
100
100
|
if (e === "style")
|
|
101
101
|
continue;
|
|
102
|
-
const r =
|
|
103
|
-
m ? m(i, r) :
|
|
102
|
+
const r = t[e], m = d[e] || b[e];
|
|
103
|
+
m ? m(i, r) : o[e] = r;
|
|
104
104
|
}
|
|
105
|
-
return
|
|
105
|
+
return o.style = { ...i, ...t.style }, o;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
const
|
|
107
|
+
function T(t) {
|
|
108
|
+
const o = t.textColor || t.color, { backgroundColor: i } = t;
|
|
109
109
|
return y([
|
|
110
|
-
h(
|
|
110
|
+
h(o) && `color-${o}`,
|
|
111
111
|
h(i) && `color-bg-${i}`
|
|
112
112
|
]);
|
|
113
113
|
}
|
|
114
|
-
function P(
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
const i =
|
|
114
|
+
function P(t) {
|
|
115
|
+
const o = {};
|
|
116
|
+
if (!t) return o;
|
|
117
|
+
const i = t.split(" ");
|
|
118
118
|
for (const e of i) {
|
|
119
119
|
const [r, m] = e.split("-");
|
|
120
120
|
if (r)
|
|
121
121
|
if (r in d) {
|
|
122
122
|
if (m === "") continue;
|
|
123
123
|
const g = Number(m);
|
|
124
|
-
!Number.isNaN(g) && Number.isFinite(g) ?
|
|
125
|
-
} else r in b ?
|
|
124
|
+
!Number.isNaN(g) && Number.isFinite(g) ? o[r] = g : o[r] = m;
|
|
125
|
+
} else r in b ? o[r] = !0 : console.warn(`Unknown prop ${r}`);
|
|
126
126
|
}
|
|
127
|
-
return
|
|
127
|
+
return o;
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
130
|
b as booleanStyleMap,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
T as computeBoxClassName,
|
|
132
|
+
S as computeBoxProps,
|
|
133
133
|
P as computeTwClass,
|
|
134
134
|
p as halfUnit,
|
|
135
135
|
d as stringStyleMap,
|
package/dist/components/Input.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { debounce as
|
|
6
|
-
import { Box as
|
|
1
|
+
import { jsxs as S, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as j, useEffect as m } from "react";
|
|
3
|
+
import { KEY as k, isEscape as v } from "../common/keys.js";
|
|
4
|
+
import { classes as w } from "../common/react.js";
|
|
5
|
+
import { debounce as B } from "../common/timer.js";
|
|
6
|
+
import { Box as F } from "./Box.js";
|
|
7
7
|
function d(r) {
|
|
8
8
|
return typeof r != "number" && typeof r != "string" ? "" : String(r);
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
10
|
+
const O = B((r) => r(), 250);
|
|
11
|
+
function z(r) {
|
|
12
12
|
const {
|
|
13
13
|
autoFocus: g,
|
|
14
14
|
autoSelect: l,
|
|
@@ -19,55 +19,58 @@ function C(r) {
|
|
|
19
19
|
maxLength: x,
|
|
20
20
|
monospace: y,
|
|
21
21
|
onChange: n,
|
|
22
|
-
onEnter:
|
|
22
|
+
onEnter: o,
|
|
23
23
|
onEscape: s,
|
|
24
|
-
onInput:
|
|
25
|
-
placeholder:
|
|
26
|
-
selfClear:
|
|
27
|
-
updateOnPropsChange:
|
|
28
|
-
value:
|
|
29
|
-
...
|
|
30
|
-
} = r,
|
|
31
|
-
function
|
|
24
|
+
onInput: a,
|
|
25
|
+
placeholder: E,
|
|
26
|
+
selfClear: N,
|
|
27
|
+
updateOnPropsChange: _,
|
|
28
|
+
value: c,
|
|
29
|
+
...A
|
|
30
|
+
} = r, i = j(null);
|
|
31
|
+
function D(t) {
|
|
32
32
|
var u;
|
|
33
|
-
if (!
|
|
33
|
+
if (!a) return;
|
|
34
34
|
const e = (u = t.currentTarget) == null ? void 0 : u.value;
|
|
35
|
-
b ?
|
|
35
|
+
b ? O(() => a(t, e)) : a(t, e);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
if (t.key ===
|
|
39
|
-
|
|
37
|
+
function K(t) {
|
|
38
|
+
if (t.key === k.Enter) {
|
|
39
|
+
o == null || o(t, t.currentTarget.value), N ? t.currentTarget.value = "" : (t.currentTarget.blur(), n == null || n(t, t.currentTarget.value));
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
v(t.key) && (s == null || s(t), t.currentTarget.value = d(c), t.currentTarget.blur());
|
|
43
43
|
}
|
|
44
44
|
function f(t) {
|
|
45
|
-
const e =
|
|
45
|
+
const e = i.current;
|
|
46
46
|
if (!e) return;
|
|
47
47
|
const u = d(t);
|
|
48
48
|
e.value !== u && (e.value = u);
|
|
49
49
|
}
|
|
50
50
|
return m(() => {
|
|
51
|
-
const t =
|
|
51
|
+
const t = i.current;
|
|
52
52
|
if (t) {
|
|
53
|
-
f(
|
|
53
|
+
f(c);
|
|
54
54
|
const e = g || l, u = document.activeElement === t;
|
|
55
55
|
e && !u && setTimeout(() => {
|
|
56
56
|
t.focus(), l && t.select();
|
|
57
57
|
}, 1);
|
|
58
58
|
}
|
|
59
59
|
}, []), m(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if (_) {
|
|
61
|
+
const t = i.current;
|
|
62
|
+
t && (document.activeElement === t || f(c));
|
|
63
|
+
}
|
|
64
|
+
}, [c]), /* @__PURE__ */ S(
|
|
65
|
+
F,
|
|
63
66
|
{
|
|
64
|
-
className:
|
|
67
|
+
className: w([
|
|
65
68
|
"Input",
|
|
66
69
|
h && "Input--fluid",
|
|
67
70
|
y && "Input--monospace",
|
|
68
71
|
I
|
|
69
72
|
]),
|
|
70
|
-
...
|
|
73
|
+
...A,
|
|
71
74
|
children: [
|
|
72
75
|
/* @__PURE__ */ p("div", { className: "Input__baseline", children: "." }),
|
|
73
76
|
/* @__PURE__ */ p(
|
|
@@ -77,10 +80,10 @@ function C(r) {
|
|
|
77
80
|
disabled: T,
|
|
78
81
|
maxLength: x,
|
|
79
82
|
onBlur: (t) => n == null ? void 0 : n(t, t.target.value),
|
|
80
|
-
onChange:
|
|
81
|
-
onKeyDown:
|
|
82
|
-
placeholder:
|
|
83
|
-
ref:
|
|
83
|
+
onChange: D,
|
|
84
|
+
onKeyDown: K,
|
|
85
|
+
placeholder: E,
|
|
86
|
+
ref: i
|
|
84
87
|
}
|
|
85
88
|
)
|
|
86
89
|
]
|
|
@@ -88,6 +91,6 @@ function C(r) {
|
|
|
88
91
|
);
|
|
89
92
|
}
|
|
90
93
|
export {
|
|
91
|
-
|
|
94
|
+
z as Input,
|
|
92
95
|
d as toInputValue
|
|
93
96
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
1
|
+
import { jsx as t, jsxs as f } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as B, useEffect as h } from "react";
|
|
3
|
-
import { classes as
|
|
3
|
+
import { classes as p } from "../common/react.js";
|
|
4
4
|
import { Box as l } from "./Box.js";
|
|
5
5
|
import { Icon as v } from "./Icon.js";
|
|
6
6
|
function k(n) {
|
|
@@ -34,12 +34,12 @@ function N(n) {
|
|
|
34
34
|
openWidth: s,
|
|
35
35
|
onOutsideClick: m,
|
|
36
36
|
...M
|
|
37
|
-
} = n,
|
|
38
|
-
return /* @__PURE__ */
|
|
37
|
+
} = n, _ = B(null);
|
|
38
|
+
return /* @__PURE__ */ f("div", { ref: _, children: [
|
|
39
39
|
/* @__PURE__ */ t(
|
|
40
40
|
l,
|
|
41
41
|
{
|
|
42
|
-
className:
|
|
42
|
+
className: p([
|
|
43
43
|
"MenuBar__MenuBarButton",
|
|
44
44
|
"MenuBar__font",
|
|
45
45
|
"MenuBar__hover",
|
|
@@ -55,7 +55,7 @@ function N(n) {
|
|
|
55
55
|
k,
|
|
56
56
|
{
|
|
57
57
|
width: s,
|
|
58
|
-
menuRef:
|
|
58
|
+
menuRef: _,
|
|
59
59
|
onOutsideClick: m,
|
|
60
60
|
children: e
|
|
61
61
|
}
|
|
@@ -99,10 +99,10 @@ function d(n) {
|
|
|
99
99
|
O.Dropdown = d;
|
|
100
100
|
function g(n) {
|
|
101
101
|
const { value: e, displayText: o, onClick: r, checked: a } = n;
|
|
102
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ f(
|
|
103
103
|
l,
|
|
104
104
|
{
|
|
105
|
-
className:
|
|
105
|
+
className: p([
|
|
106
106
|
"MenuBar__font",
|
|
107
107
|
"MenuBar__MenuItem",
|
|
108
108
|
"MenuBar__MenuItemToggle",
|
|
@@ -122,7 +122,7 @@ function C(n) {
|
|
|
122
122
|
return /* @__PURE__ */ t(
|
|
123
123
|
l,
|
|
124
124
|
{
|
|
125
|
-
className:
|
|
125
|
+
className: p([
|
|
126
126
|
"MenuBar__font",
|
|
127
127
|
"MenuBar__MenuItem",
|
|
128
128
|
"MenuBar__hover"
|
|
@@ -18,6 +18,8 @@ export declare const TextArea: import('react').ForwardRefExoticComponent<Partial
|
|
|
18
18
|
placeholder: string;
|
|
19
19
|
scrollbar: boolean;
|
|
20
20
|
selfClear: boolean;
|
|
21
|
+
/** Provides a Record with key: markupChar entries which can be used for ctrl + key combinations to surround a selected text with the markup character */
|
|
22
|
+
userMarkup: Record<string, string>;
|
|
21
23
|
value: string;
|
|
22
24
|
}> & Partial<{
|
|
23
25
|
as: string;
|
|
@@ -1,73 +1,87 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { KEY as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { Box as
|
|
6
|
-
import { toInputValue as
|
|
7
|
-
|
|
8
|
-
(
|
|
1
|
+
import { jsxs as I, jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as M, useRef as Y, useState as C, useImperativeHandle as H, useEffect as y } from "react";
|
|
3
|
+
import { KEY as A, isEscape as L } from "../common/keys.js";
|
|
4
|
+
import { classes as p } from "../common/react.js";
|
|
5
|
+
import { Box as U } from "./Box.js";
|
|
6
|
+
import { toInputValue as _ } from "./Input.js";
|
|
7
|
+
function q(u, s, l, t) {
|
|
8
|
+
return `${u.substring(0, l)}${s}${u.substring(l, t)}${s}${u.substring(t)}`;
|
|
9
|
+
}
|
|
10
|
+
const X = M(
|
|
11
|
+
(u, s) => {
|
|
9
12
|
const {
|
|
10
|
-
autoFocus:
|
|
11
|
-
autoSelect:
|
|
12
|
-
displayedValue:
|
|
13
|
-
dontUseTabForIndent:
|
|
14
|
-
maxLength:
|
|
15
|
-
noborder:
|
|
16
|
-
onChange:
|
|
17
|
-
onEnter:
|
|
18
|
-
onEscape:
|
|
19
|
-
onInput:
|
|
20
|
-
placeholder:
|
|
21
|
-
scrollbar:
|
|
22
|
-
selfClear:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
autoFocus: l,
|
|
14
|
+
autoSelect: t,
|
|
15
|
+
displayedValue: o,
|
|
16
|
+
dontUseTabForIndent: w,
|
|
17
|
+
maxLength: S,
|
|
18
|
+
noborder: $,
|
|
19
|
+
onChange: i,
|
|
20
|
+
onEnter: f,
|
|
21
|
+
onEscape: g,
|
|
22
|
+
onInput: d,
|
|
23
|
+
placeholder: k,
|
|
24
|
+
scrollbar: E,
|
|
25
|
+
selfClear: b,
|
|
26
|
+
userMarkup: m,
|
|
27
|
+
value: T,
|
|
28
|
+
...K
|
|
29
|
+
} = u, { className: D, fluid: N, nowrap: R, ...V } = K, a = Y(null), [j, B] = C(0);
|
|
30
|
+
function F(r) {
|
|
31
|
+
if (r.key === A.Enter) {
|
|
28
32
|
if (r.shiftKey) {
|
|
29
33
|
r.currentTarget.focus();
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
|
-
|
|
36
|
+
f == null || f(r, r.currentTarget.value), b && (r.currentTarget.value = ""), r.currentTarget.blur();
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
39
|
+
if (L(r.key)) {
|
|
40
|
+
g == null || g(r), b ? r.currentTarget.value = "" : (r.currentTarget.value = _(T), r.currentTarget.blur());
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
|
-
if (!
|
|
43
|
+
if (!w && r.key === A.Tab) {
|
|
40
44
|
r.preventDefault();
|
|
41
|
-
const { value:
|
|
42
|
-
r.currentTarget.value = `${
|
|
45
|
+
const { value: e, selectionStart: c, selectionEnd: n } = r.currentTarget;
|
|
46
|
+
r.currentTarget.value = `${e.substring(0, c)} ${e.substring(n)}`, r.currentTarget.selectionEnd = c + 1;
|
|
47
|
+
}
|
|
48
|
+
if (m && (r.ctrlKey || r.metaKey) && m[r.key]) {
|
|
49
|
+
r.preventDefault();
|
|
50
|
+
const { value: e, selectionStart: c, selectionEnd: n } = r.currentTarget, h = m[r.key];
|
|
51
|
+
r.currentTarget.value = q(
|
|
52
|
+
e,
|
|
53
|
+
h,
|
|
54
|
+
c,
|
|
55
|
+
n
|
|
56
|
+
), r.currentTarget.selectionEnd = n + h.length * 2;
|
|
43
57
|
}
|
|
44
58
|
}
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
() =>
|
|
48
|
-
),
|
|
49
|
-
if (!
|
|
50
|
-
const r =
|
|
51
|
-
r && (
|
|
52
|
-
r.focus(),
|
|
59
|
+
return H(
|
|
60
|
+
s,
|
|
61
|
+
() => a.current
|
|
62
|
+
), y(() => {
|
|
63
|
+
if (!l && !t) return;
|
|
64
|
+
const r = a.current;
|
|
65
|
+
r && (l || t) && setTimeout(() => {
|
|
66
|
+
r.focus(), t && r.select();
|
|
53
67
|
}, 1);
|
|
54
|
-
}, []),
|
|
55
|
-
const r =
|
|
68
|
+
}, []), y(() => {
|
|
69
|
+
const r = a.current;
|
|
56
70
|
if (!r) return;
|
|
57
|
-
const
|
|
58
|
-
r.value !==
|
|
59
|
-
}, [
|
|
60
|
-
|
|
71
|
+
const e = _(T);
|
|
72
|
+
r.value !== e && (r.value = e);
|
|
73
|
+
}, [T]), /* @__PURE__ */ I(
|
|
74
|
+
U,
|
|
61
75
|
{
|
|
62
|
-
className:
|
|
76
|
+
className: p([
|
|
63
77
|
"TextArea",
|
|
64
78
|
N && "TextArea--fluid",
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
$ && "TextArea--noborder",
|
|
80
|
+
D
|
|
67
81
|
]),
|
|
68
|
-
...
|
|
82
|
+
...V,
|
|
69
83
|
children: [
|
|
70
|
-
!!
|
|
84
|
+
!!o && /* @__PURE__ */ x(
|
|
71
85
|
"div",
|
|
72
86
|
{
|
|
73
87
|
style: {
|
|
@@ -76,40 +90,40 @@ const M = F(
|
|
|
76
90
|
position: "absolute",
|
|
77
91
|
width: "100%"
|
|
78
92
|
},
|
|
79
|
-
children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ x(
|
|
80
94
|
"div",
|
|
81
95
|
{
|
|
82
|
-
className:
|
|
96
|
+
className: p([
|
|
83
97
|
"TextArea__textarea",
|
|
84
98
|
"TextArea__textarea_custom"
|
|
85
99
|
]),
|
|
86
100
|
style: {
|
|
87
|
-
transform: `translateY(-${
|
|
101
|
+
transform: `translateY(-${j}px)`
|
|
88
102
|
},
|
|
89
|
-
children:
|
|
103
|
+
children: o
|
|
90
104
|
}
|
|
91
105
|
)
|
|
92
106
|
}
|
|
93
107
|
),
|
|
94
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ x(
|
|
95
109
|
"textarea",
|
|
96
110
|
{
|
|
97
|
-
className:
|
|
111
|
+
className: p([
|
|
98
112
|
"TextArea__textarea",
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
E && "TextArea__textarea--scrollable",
|
|
114
|
+
R && "TextArea__nowrap"
|
|
101
115
|
]),
|
|
102
|
-
maxLength:
|
|
103
|
-
onBlur: (r) =>
|
|
104
|
-
onChange: (r) =>
|
|
105
|
-
onKeyDown:
|
|
116
|
+
maxLength: S,
|
|
117
|
+
onBlur: (r) => i == null ? void 0 : i(r, r.target.value),
|
|
118
|
+
onChange: (r) => d == null ? void 0 : d(r, r.target.value),
|
|
119
|
+
onKeyDown: F,
|
|
106
120
|
onScroll: () => {
|
|
107
|
-
|
|
121
|
+
o && a.current && B(a.current.scrollTop);
|
|
108
122
|
},
|
|
109
|
-
placeholder:
|
|
110
|
-
ref:
|
|
123
|
+
placeholder: k,
|
|
124
|
+
ref: a,
|
|
111
125
|
style: {
|
|
112
|
-
color:
|
|
126
|
+
color: o ? "rgba(0, 0, 0, 0)" : "inherit"
|
|
113
127
|
}
|
|
114
128
|
}
|
|
115
129
|
)
|
|
@@ -119,5 +133,5 @@ const M = F(
|
|
|
119
133
|
}
|
|
120
134
|
);
|
|
121
135
|
export {
|
|
122
|
-
|
|
136
|
+
X as TextArea
|
|
123
137
|
};
|