tgui-core 2.0.4 → 2.0.6
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/README.md +1 -1
- package/dist/components/Knob.d.ts +0 -6
- package/dist/components/Knob.js +49 -51
- package/dist/components/ProgressBar.d.ts +2 -0
- package/dist/components/ProgressBar.js +12 -11
- package/dist/components/Section.d.ts +30 -44
- package/dist/components/Section.js +63 -64
- package/dist/components/Slider.d.ts +0 -6
- package/dist/components/Slider.js +37 -39
- package/dist/components/Stack.d.ts +1 -1
- package/dist/components/Stack.js +17 -16
- package/dist/components/TextArea.d.ts +14 -28
- package/dist/components/TextArea.js +118 -131
- package/package.json +1 -1
- package/styles/components/ProgressBar.scss +2 -0
- package/styles/components/TextArea.scss +7 -0
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ Contributions are welcome. Please open an issue or a pull request. I am availabl
|
|
|
66
66
|
|
|
67
67
|
To automagically release a new version of the tgui-core package, simply create a [new release](https://github.com/tgstation/tgui-core/releases/new) with the tag set to the new version you want to publish. Set the tag to be the commit you want to base the version off of (likely the latest, being the default).
|
|
68
68
|
|
|
69
|
-
The release workflow will take care of setting the `package.json` version, building,
|
|
69
|
+
The release workflow will take care of setting the `package.json` version, building, and publishing to npm.
|
|
70
70
|
|
|
71
71
|
### Development
|
|
72
72
|
|
|
@@ -42,12 +42,6 @@ type Props = {
|
|
|
42
42
|
step: number;
|
|
43
43
|
/** Screen distance mouse needs to travel to adjust value by one `step`. */
|
|
44
44
|
stepPixelSize: number;
|
|
45
|
-
/**
|
|
46
|
-
* A number in milliseconds, for which the input will hold off from updating
|
|
47
|
-
* while events propagate through the backend. Default is about 250ms,
|
|
48
|
-
* increase it if you still see flickering.
|
|
49
|
-
*/
|
|
50
|
-
suppressFlicker: number;
|
|
51
45
|
/** Whether to clamp the value to the range. */
|
|
52
46
|
unclamped: boolean;
|
|
53
47
|
/** Unit to display to the right of value. */
|
package/dist/components/Knob.js
CHANGED
|
@@ -1,79 +1,77 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { keyOfMatchingRange as
|
|
3
|
-
import { classes as
|
|
4
|
-
import { computeBoxProps as
|
|
5
|
-
import { DraggableControl as
|
|
6
|
-
function
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { keyOfMatchingRange as F, scale as c } from "../common/math.js";
|
|
3
|
+
import { classes as S } from "../common/react.js";
|
|
4
|
+
import { computeBoxProps as $, computeBoxClassName as j } from "../common/ui.js";
|
|
5
|
+
import { DraggableControl as E } from "./DraggableControl.js";
|
|
6
|
+
function A(m) {
|
|
7
7
|
const {
|
|
8
8
|
// Draggable props (passthrough)
|
|
9
9
|
animated: d,
|
|
10
|
-
format:
|
|
10
|
+
format: g,
|
|
11
11
|
maxValue: a,
|
|
12
|
-
minValue:
|
|
13
|
-
onChange:
|
|
14
|
-
onDrag:
|
|
12
|
+
minValue: o,
|
|
13
|
+
onChange: p,
|
|
14
|
+
onDrag: u,
|
|
15
15
|
step: _,
|
|
16
16
|
stepPixelSize: b,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
unit: x,
|
|
17
|
+
unclamped: f,
|
|
18
|
+
unit: h,
|
|
20
19
|
value: r,
|
|
21
20
|
// Own props
|
|
22
|
-
bipolar:
|
|
23
|
-
className:
|
|
24
|
-
color:
|
|
25
|
-
fillValue:
|
|
26
|
-
ranges:
|
|
27
|
-
size:
|
|
28
|
-
style:
|
|
29
|
-
...
|
|
21
|
+
bipolar: n,
|
|
22
|
+
className: x,
|
|
23
|
+
color: K,
|
|
24
|
+
fillValue: i,
|
|
25
|
+
ranges: v = {},
|
|
26
|
+
size: N = 1,
|
|
27
|
+
style: y,
|
|
28
|
+
...s
|
|
30
29
|
} = m;
|
|
31
30
|
return /* @__PURE__ */ e(
|
|
32
|
-
|
|
31
|
+
E,
|
|
33
32
|
{
|
|
34
33
|
dragMatrix: [0, -1],
|
|
35
34
|
animated: d,
|
|
36
|
-
format:
|
|
35
|
+
format: g,
|
|
37
36
|
maxValue: a,
|
|
38
|
-
minValue:
|
|
39
|
-
onChange:
|
|
40
|
-
onDrag:
|
|
37
|
+
minValue: o,
|
|
38
|
+
onChange: p,
|
|
39
|
+
onDrag: u,
|
|
41
40
|
step: _,
|
|
42
41
|
stepPixelSize: b,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
unit: x,
|
|
42
|
+
unclamped: f,
|
|
43
|
+
unit: h,
|
|
46
44
|
value: r,
|
|
47
|
-
children: (
|
|
45
|
+
children: (V) => {
|
|
48
46
|
const {
|
|
49
47
|
displayElement: D,
|
|
50
48
|
displayValue: t,
|
|
51
49
|
dragging: M,
|
|
52
|
-
handleDragStart:
|
|
53
|
-
inputElement:
|
|
54
|
-
} =
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
handleDragStart: k,
|
|
51
|
+
inputElement: B
|
|
52
|
+
} = V, P = c(
|
|
53
|
+
i ?? t,
|
|
54
|
+
o,
|
|
57
55
|
a
|
|
58
|
-
),
|
|
59
|
-
return /* @__PURE__ */
|
|
56
|
+
), C = c(t, o, a), w = K || F(i ?? r, v) || "default", z = Math.min((C - 0.5) * 270, 225);
|
|
57
|
+
return /* @__PURE__ */ l(
|
|
60
58
|
"div",
|
|
61
59
|
{
|
|
62
|
-
className:
|
|
60
|
+
className: S([
|
|
63
61
|
"Knob",
|
|
64
62
|
`Knob--color--${w}`,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
n && "Knob--bipolar",
|
|
64
|
+
x,
|
|
65
|
+
j(s)
|
|
68
66
|
]),
|
|
69
|
-
|
|
67
|
+
...$({
|
|
70
68
|
style: {
|
|
71
|
-
fontSize: `${
|
|
72
|
-
...
|
|
69
|
+
fontSize: `${N}em`,
|
|
70
|
+
...y
|
|
73
71
|
},
|
|
74
|
-
...
|
|
72
|
+
...s
|
|
75
73
|
}),
|
|
76
|
-
onMouseDown:
|
|
74
|
+
onMouseDown: k,
|
|
77
75
|
children: [
|
|
78
76
|
/* @__PURE__ */ e("div", { className: "Knob__circle", children: /* @__PURE__ */ e(
|
|
79
77
|
"div",
|
|
@@ -86,7 +84,7 @@ function G(m) {
|
|
|
86
84
|
}
|
|
87
85
|
) }),
|
|
88
86
|
M && /* @__PURE__ */ e("div", { className: "Knob__popupValue", children: D }),
|
|
89
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ l(
|
|
90
88
|
"svg",
|
|
91
89
|
{
|
|
92
90
|
className: "Knob__ring Knob__ringTrackPivot",
|
|
@@ -97,7 +95,7 @@ function G(m) {
|
|
|
97
95
|
]
|
|
98
96
|
}
|
|
99
97
|
),
|
|
100
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ l(
|
|
101
99
|
"svg",
|
|
102
100
|
{
|
|
103
101
|
className: "Knob__ring Knob__ringFillPivot",
|
|
@@ -110,7 +108,7 @@ function G(m) {
|
|
|
110
108
|
className: "Knob__ringFill",
|
|
111
109
|
style: {
|
|
112
110
|
strokeDashoffset: Math.max(
|
|
113
|
-
((
|
|
111
|
+
((n ? 2.75 : 2) - P * 1.5) * Math.PI * 50,
|
|
114
112
|
0
|
|
115
113
|
)
|
|
116
114
|
},
|
|
@@ -122,7 +120,7 @@ function G(m) {
|
|
|
122
120
|
]
|
|
123
121
|
}
|
|
124
122
|
),
|
|
125
|
-
|
|
123
|
+
B
|
|
126
124
|
]
|
|
127
125
|
}
|
|
128
126
|
);
|
|
@@ -131,5 +129,5 @@ function G(m) {
|
|
|
131
129
|
);
|
|
132
130
|
}
|
|
133
131
|
export {
|
|
134
|
-
|
|
132
|
+
A as Knob
|
|
135
133
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { CSS_COLORS as
|
|
3
|
-
import { keyOfMatchingRange as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { computeBoxProps as
|
|
6
|
-
function
|
|
1
|
+
import { jsxs as C, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { CSS_COLORS as P } from "../common/constants.js";
|
|
3
|
+
import { keyOfMatchingRange as h, toFixed as x, clamp01 as _, scale as v } from "../common/math.js";
|
|
4
|
+
import { classes as y } from "../common/react.js";
|
|
5
|
+
import { computeBoxProps as N, computeBoxClassName as S } from "../common/ui.js";
|
|
6
|
+
function k(n) {
|
|
7
7
|
const {
|
|
8
8
|
className: m,
|
|
9
9
|
value: o,
|
|
@@ -11,12 +11,13 @@ function j(n) {
|
|
|
11
11
|
maxValue: f = 1,
|
|
12
12
|
color: u,
|
|
13
13
|
ranges: p = {},
|
|
14
|
+
empty: g,
|
|
14
15
|
children: r,
|
|
15
16
|
...l
|
|
16
|
-
} = n,
|
|
17
|
-
width: `${
|
|
17
|
+
} = n, t = v(o, d, f), B = r !== void 0, s = u || h(o, p) || "default", e = N(l), a = ["ProgressBar", m, S(l)], c = {
|
|
18
|
+
width: `${_(t) * 100}%`
|
|
18
19
|
};
|
|
19
|
-
return
|
|
20
|
+
return P.includes(s) || s === "default" ? a.push(`ProgressBar--color--${s}`) : (e.style = { ...e.style, borderColor: s }, c.backgroundColor = s), /* @__PURE__ */ C("div", { className: y(a), ...e, children: [
|
|
20
21
|
/* @__PURE__ */ i(
|
|
21
22
|
"div",
|
|
22
23
|
{
|
|
@@ -24,9 +25,9 @@ function j(n) {
|
|
|
24
25
|
style: c
|
|
25
26
|
}
|
|
26
27
|
),
|
|
27
|
-
/* @__PURE__ */ i("div", { className: "ProgressBar__content", children:
|
|
28
|
+
/* @__PURE__ */ i("div", { className: "ProgressBar__content", children: B ? r : !g && `${x(t * 100)}%` })
|
|
28
29
|
] });
|
|
29
30
|
}
|
|
30
31
|
export {
|
|
31
|
-
|
|
32
|
+
k as ProgressBar
|
|
32
33
|
};
|
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { BoxProps } from './Box';
|
|
3
|
+
type Props = Partial<{
|
|
4
|
+
/** Buttons to render aside the section title. */
|
|
5
|
+
buttons: ReactNode;
|
|
6
|
+
/** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
|
|
7
|
+
container_id: string;
|
|
8
|
+
/** If true, fills all available vertical space. */
|
|
9
|
+
fill: boolean;
|
|
10
|
+
/** If true, removes all section padding. */
|
|
11
|
+
fitted: boolean;
|
|
12
|
+
/** If true, fills the area without forcing height to 100% */
|
|
13
|
+
flexGrow: boolean;
|
|
14
|
+
/** If true, removes the section top padding */
|
|
15
|
+
noTopPadding: boolean;
|
|
16
|
+
/** @member Callback function for the `scroll` event */
|
|
17
|
+
onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
18
|
+
/** Ref to the section element. */
|
|
19
|
+
ref: RefObject<HTMLDivElement | null>;
|
|
20
|
+
/** Shows or hides the scrollbar. */
|
|
21
|
+
scrollable: boolean;
|
|
22
|
+
/** Shows or hides the horizontal scrollbar. */
|
|
23
|
+
scrollableHorizontal: boolean;
|
|
24
|
+
/** If true, filly the area except for -3rem */
|
|
25
|
+
stretchContents: boolean;
|
|
26
|
+
/** Title of the section. */
|
|
27
|
+
title: ReactNode;
|
|
28
|
+
}> & BoxProps;
|
|
2
29
|
/**
|
|
3
30
|
* ## Section
|
|
4
31
|
* Section is a surface that displays content and actions on a single topic.
|
|
@@ -26,46 +53,5 @@ import { ReactNode } from 'react';
|
|
|
26
53
|
* </Section>
|
|
27
54
|
* ```
|
|
28
55
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
|
|
31
|
-
buttons: ReactNode;
|
|
32
|
-
/** id to assosiate with the parent div element used by this section, for uses with procs like getElementByID */
|
|
33
|
-
container_id: string;
|
|
34
|
-
/** If true, fills all available vertical space. */
|
|
35
|
-
fill: boolean;
|
|
36
|
-
/** If true, removes all section padding. */
|
|
37
|
-
fitted: boolean;
|
|
38
|
-
/** If true, fills the area without forcing height to 100% */
|
|
39
|
-
flexGrow: boolean;
|
|
40
|
-
/** If true, removes the section top padding */
|
|
41
|
-
noTopPadding: boolean;
|
|
42
|
-
/** @member Callback function for the `scroll` event */
|
|
43
|
-
onScroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
44
|
-
/** Shows or hides the scrollbar. */
|
|
45
|
-
scrollable: boolean;
|
|
46
|
-
/** Shows or hides the horizontal scrollbar. */
|
|
47
|
-
scrollableHorizontal: boolean;
|
|
48
|
-
/** If true, filly the area except for -3rem */
|
|
49
|
-
stretchContents: boolean;
|
|
50
|
-
/** Title of the section. */
|
|
51
|
-
title: ReactNode;
|
|
52
|
-
}> & Partial<{
|
|
53
|
-
as: string;
|
|
54
|
-
children: ReactNode;
|
|
55
|
-
className: string | import('../common/react').BooleanLike;
|
|
56
|
-
id: string;
|
|
57
|
-
style: import('react').CSSProperties;
|
|
58
|
-
tw: string;
|
|
59
|
-
} & import('../common/ui').BooleanStyleMap & import('../common/ui').StringStyleMap & {
|
|
60
|
-
onClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
61
|
-
onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
|
|
62
|
-
onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
63
|
-
onKeyDown: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
64
|
-
onKeyUp: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
65
|
-
onMouseDown: import('react').MouseEventHandler<HTMLDivElement>;
|
|
66
|
-
onMouseLeave: import('react').MouseEventHandler<HTMLDivElement>;
|
|
67
|
-
onMouseMove: import('react').MouseEventHandler<HTMLDivElement>;
|
|
68
|
-
onMouseOver: import('react').MouseEventHandler<HTMLDivElement>;
|
|
69
|
-
onMouseUp: import('react').MouseEventHandler<HTMLDivElement>;
|
|
70
|
-
onScroll: import('react').UIEventHandler<HTMLDivElement>;
|
|
71
|
-
}> & import('react').RefAttributes<HTMLDivElement>>;
|
|
56
|
+
export declare function Section(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export {};
|
|
@@ -1,66 +1,65 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { addScrollableNode as
|
|
4
|
-
import { canRender as
|
|
5
|
-
import { computeBoxProps as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as T, useEffect as C } from "react";
|
|
3
|
+
import { addScrollableNode as P, removeScrollableNode as g } from "../common/events.js";
|
|
4
|
+
import { canRender as a, classes as d } from "../common/react.js";
|
|
5
|
+
import { computeBoxProps as j, computeBoxClassName as z } from "../common/ui.js";
|
|
6
|
+
function k(m) {
|
|
7
|
+
const {
|
|
8
|
+
buttons: c,
|
|
9
|
+
children: S,
|
|
10
|
+
className: f,
|
|
11
|
+
container_id: u = "",
|
|
12
|
+
fill: _,
|
|
13
|
+
fitted: p,
|
|
14
|
+
flexGrow: N,
|
|
15
|
+
noTopPadding: h,
|
|
16
|
+
onScroll: b,
|
|
17
|
+
ref: o,
|
|
18
|
+
scrollable: n,
|
|
19
|
+
scrollableHorizontal: i,
|
|
20
|
+
stretchContents: x,
|
|
21
|
+
title: l,
|
|
22
|
+
...r
|
|
23
|
+
} = m, t = T((o == null ? void 0 : o.current) ?? null), v = a(l) || a(c);
|
|
24
|
+
return C(() => (t != null && t.current && (n || i) && P(t.current), () => {
|
|
25
|
+
t != null && t.current && g(t.current);
|
|
26
|
+
}), []), /* @__PURE__ */ s(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
id: u,
|
|
30
|
+
className: d([
|
|
31
|
+
"Section",
|
|
32
|
+
_ && "Section--fill",
|
|
33
|
+
p && "Section--fitted",
|
|
34
|
+
n && "Section--scrollable",
|
|
35
|
+
i && "Section--scrollableHorizontal",
|
|
36
|
+
N && "Section--flex",
|
|
37
|
+
f,
|
|
38
|
+
z(r)
|
|
39
|
+
]),
|
|
40
|
+
...j(r),
|
|
41
|
+
children: [
|
|
42
|
+
v && /* @__PURE__ */ s("div", { className: "Section__title", children: [
|
|
43
|
+
/* @__PURE__ */ e("span", { className: "Section__titleText", children: l }),
|
|
44
|
+
/* @__PURE__ */ e("div", { className: "Section__buttons", children: c })
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ e("div", { className: "Section__rest", children: /* @__PURE__ */ e(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: d([
|
|
50
|
+
"Section__content",
|
|
51
|
+
x && "Section__content--stretchContents",
|
|
52
|
+
h && "Section__content--noTopPadding"
|
|
53
|
+
]),
|
|
54
|
+
onScroll: b,
|
|
55
|
+
ref: t,
|
|
56
|
+
children: S
|
|
57
|
+
}
|
|
58
|
+
) })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
64
63
|
export {
|
|
65
|
-
|
|
64
|
+
k as Section
|
|
66
65
|
};
|
|
@@ -42,12 +42,6 @@ type Props = {
|
|
|
42
42
|
* while dragging. Use higher for larger sliders. Default is 1.
|
|
43
43
|
*/
|
|
44
44
|
stepPixelSize: number;
|
|
45
|
-
/**
|
|
46
|
-
* A number in milliseconds, for which the input will hold off from updating
|
|
47
|
-
* while events propagate through the backend. Default is about 250ms,
|
|
48
|
-
* increase it if you still see flickering.
|
|
49
|
-
*/
|
|
50
|
-
suppressFlicker: number;
|
|
51
45
|
/** Unit to display to the right of value. */
|
|
52
46
|
unit: string;
|
|
53
47
|
}> & BoxProps & PropsWithChildren;
|
|
@@ -1,69 +1,67 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { keyOfMatchingRange as
|
|
1
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { keyOfMatchingRange as F, clamp01 as s, scale as p } from "../common/math.js";
|
|
3
3
|
import { classes as g } from "../common/react.js";
|
|
4
4
|
import { computeBoxProps as O, computeBoxClassName as b } from "../common/ui.js";
|
|
5
|
-
import { DraggableControl as
|
|
6
|
-
function
|
|
5
|
+
import { DraggableControl as k } from "./DraggableControl.js";
|
|
6
|
+
function H(f) {
|
|
7
7
|
const {
|
|
8
8
|
// Draggable props (passthrough)
|
|
9
9
|
animated: _,
|
|
10
10
|
format: h,
|
|
11
|
-
maxValue:
|
|
12
|
-
minValue:
|
|
11
|
+
maxValue: l,
|
|
12
|
+
minValue: r,
|
|
13
13
|
onChange: v,
|
|
14
14
|
onDrag: N,
|
|
15
15
|
step: x,
|
|
16
16
|
stepPixelSize: y,
|
|
17
|
-
|
|
18
|
-
unit: P,
|
|
17
|
+
unit: B,
|
|
19
18
|
value: i,
|
|
20
19
|
// Own props
|
|
21
|
-
className:
|
|
22
|
-
fillValue:
|
|
23
|
-
color:
|
|
24
|
-
ranges:
|
|
20
|
+
className: P,
|
|
21
|
+
fillValue: a,
|
|
22
|
+
color: S,
|
|
23
|
+
ranges: V = {},
|
|
25
24
|
children: o,
|
|
26
25
|
...t
|
|
27
|
-
} = f,
|
|
26
|
+
} = f, C = o !== void 0;
|
|
28
27
|
return /* @__PURE__ */ e(
|
|
29
|
-
|
|
28
|
+
k,
|
|
30
29
|
{
|
|
31
30
|
dragMatrix: [1, 0],
|
|
32
31
|
animated: _,
|
|
33
32
|
format: h,
|
|
34
|
-
maxValue:
|
|
35
|
-
minValue:
|
|
33
|
+
maxValue: l,
|
|
34
|
+
minValue: r,
|
|
36
35
|
onChange: v,
|
|
37
36
|
onDrag: N,
|
|
38
37
|
step: x,
|
|
39
38
|
stepPixelSize: y,
|
|
40
|
-
|
|
41
|
-
unit: P,
|
|
39
|
+
unit: B,
|
|
42
40
|
value: i,
|
|
43
|
-
children: (
|
|
41
|
+
children: (D) => {
|
|
44
42
|
const {
|
|
45
43
|
displayElement: n,
|
|
46
44
|
displayValue: c,
|
|
47
|
-
dragging:
|
|
48
|
-
handleDragStart:
|
|
49
|
-
inputElement:
|
|
50
|
-
} =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
), m =
|
|
55
|
-
return /* @__PURE__ */
|
|
45
|
+
dragging: w,
|
|
46
|
+
handleDragStart: M,
|
|
47
|
+
inputElement: $
|
|
48
|
+
} = D, j = a != null, d = p(
|
|
49
|
+
a ?? c,
|
|
50
|
+
r,
|
|
51
|
+
l
|
|
52
|
+
), m = p(c, r, l), E = S || F(a ?? i, V) || "default";
|
|
53
|
+
return /* @__PURE__ */ u(
|
|
56
54
|
"div",
|
|
57
55
|
{
|
|
58
56
|
className: g([
|
|
59
57
|
"Slider",
|
|
60
58
|
"ProgressBar",
|
|
61
|
-
`ProgressBar--color--${
|
|
62
|
-
|
|
59
|
+
`ProgressBar--color--${E}`,
|
|
60
|
+
P,
|
|
63
61
|
b(t)
|
|
64
62
|
]),
|
|
65
63
|
...O(t),
|
|
66
|
-
onMouseDown:
|
|
64
|
+
onMouseDown: M,
|
|
67
65
|
children: [
|
|
68
66
|
/* @__PURE__ */ e(
|
|
69
67
|
"div",
|
|
@@ -73,7 +71,7 @@ function I(f) {
|
|
|
73
71
|
j && "ProgressBar__fill--animated"
|
|
74
72
|
]),
|
|
75
73
|
style: {
|
|
76
|
-
width: `${
|
|
74
|
+
width: `${s(d) * 100}%`,
|
|
77
75
|
opacity: 0.4
|
|
78
76
|
}
|
|
79
77
|
}
|
|
@@ -83,26 +81,26 @@ function I(f) {
|
|
|
83
81
|
{
|
|
84
82
|
className: "ProgressBar__fill",
|
|
85
83
|
style: {
|
|
86
|
-
width: `${
|
|
84
|
+
width: `${s(Math.min(d, m)) * 100}%`
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ u(
|
|
91
89
|
"div",
|
|
92
90
|
{
|
|
93
91
|
className: "Slider__cursorOffset",
|
|
94
92
|
style: {
|
|
95
|
-
width: `${
|
|
93
|
+
width: `${s(m) * 100}%`
|
|
96
94
|
},
|
|
97
95
|
children: [
|
|
98
96
|
/* @__PURE__ */ e("div", { className: "Slider__cursor" }),
|
|
99
97
|
/* @__PURE__ */ e("div", { className: "Slider__pointer" }),
|
|
100
|
-
|
|
98
|
+
w && /* @__PURE__ */ e("div", { className: "Slider__popupValue", children: n })
|
|
101
99
|
]
|
|
102
100
|
}
|
|
103
101
|
),
|
|
104
|
-
/* @__PURE__ */ e("div", { className: "ProgressBar__content", children:
|
|
105
|
-
|
|
102
|
+
/* @__PURE__ */ e("div", { className: "ProgressBar__content", children: C ? o : n }),
|
|
103
|
+
$
|
|
106
104
|
]
|
|
107
105
|
}
|
|
108
106
|
);
|
|
@@ -111,5 +109,5 @@ function I(f) {
|
|
|
111
109
|
);
|
|
112
110
|
}
|
|
113
111
|
export {
|
|
114
|
-
|
|
112
|
+
H as Slider
|
|
115
113
|
};
|
|
@@ -67,7 +67,7 @@ export declare namespace Stack {
|
|
|
67
67
|
var Divider: typeof StackDivider;
|
|
68
68
|
}
|
|
69
69
|
type StackItemProps = FlexItemProps & Partial<{
|
|
70
|
-
innerRef: RefObject<HTMLDivElement>;
|
|
70
|
+
innerRef: RefObject<HTMLDivElement | null>;
|
|
71
71
|
}>;
|
|
72
72
|
declare function StackItem(props: StackItemProps): import("react/jsx-runtime").JSX.Element;
|
|
73
73
|
type StackDividerProps = FlexItemProps & Partial<{
|
package/dist/components/Stack.js
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useRef as S } from "react";
|
|
3
|
+
import { classes as s } from "../common/react.js";
|
|
3
4
|
import { computeBoxClassName as o } from "../common/ui.js";
|
|
4
5
|
import { computeFlexProps as k, computeFlexClassName as v, computeFlexItemProps as m } from "./Flex.js";
|
|
5
|
-
function
|
|
6
|
-
const { className: c, vertical: e, fill: t, reverse:
|
|
6
|
+
function l(r) {
|
|
7
|
+
const { className: c, vertical: e, fill: t, reverse: a, zebra: n, ...d } = r, u = e ? "column" : "row", f = a ? "-reverse" : "";
|
|
7
8
|
return /* @__PURE__ */ i(
|
|
8
9
|
"div",
|
|
9
10
|
{
|
|
10
|
-
className:
|
|
11
|
+
className: s([
|
|
11
12
|
"Stack",
|
|
12
13
|
t && "Stack--fill",
|
|
13
14
|
e ? "Stack--vertical" : "Stack--horizontal",
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
n && "Stack--zebra",
|
|
16
|
+
a && `Stack--reverse${e ? "--vertical" : ""}`,
|
|
16
17
|
c,
|
|
17
18
|
v(r)
|
|
18
19
|
]),
|
|
19
20
|
...k({
|
|
20
|
-
direction: `${
|
|
21
|
+
direction: `${u}${f}`,
|
|
21
22
|
...d
|
|
22
23
|
})
|
|
23
24
|
}
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
const { className: c, innerRef: e, ...t } = r;
|
|
27
|
+
function p(r) {
|
|
28
|
+
const { className: c, innerRef: e, ...t } = r, a = S((e == null ? void 0 : e.current) ?? null);
|
|
28
29
|
return /* @__PURE__ */ i(
|
|
29
30
|
"div",
|
|
30
31
|
{
|
|
31
|
-
className:
|
|
32
|
-
ref:
|
|
32
|
+
className: s(["Stack__item", c, o(t)]),
|
|
33
|
+
ref: a,
|
|
33
34
|
...m(t)
|
|
34
35
|
}
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
function
|
|
38
|
+
l.Item = p;
|
|
39
|
+
function x(r) {
|
|
39
40
|
const { className: c, hidden: e, ...t } = r;
|
|
40
41
|
return /* @__PURE__ */ i(
|
|
41
42
|
"div",
|
|
42
43
|
{
|
|
43
|
-
className:
|
|
44
|
+
className: s([
|
|
44
45
|
"Stack__item",
|
|
45
46
|
"Stack__divider",
|
|
46
47
|
e && "Stack__divider--hidden",
|
|
@@ -51,7 +52,7 @@ function p(r) {
|
|
|
51
52
|
}
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
l.Divider = x;
|
|
55
56
|
export {
|
|
56
|
-
|
|
57
|
+
l as Stack
|
|
57
58
|
};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { SyntheticEvent } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* An input for larger amounts of text. Use this when you want inputs larger
|
|
6
|
-
* than one row.
|
|
7
|
-
*/
|
|
8
|
-
export declare const TextArea: import('react').ForwardRefExoticComponent<Partial<{
|
|
1
|
+
import { RefObject, SyntheticEvent } from 'react';
|
|
2
|
+
import { BoxProps } from './Box';
|
|
3
|
+
type Props = Partial<{
|
|
9
4
|
/** Automatically focus the textarea on mount */
|
|
10
5
|
autoFocus: boolean;
|
|
11
6
|
/** Selects all text on mount */
|
|
@@ -30,6 +25,8 @@ export declare const TextArea: import('react').ForwardRefExoticComponent<Partial
|
|
|
30
25
|
onInput: (event: SyntheticEvent<HTMLTextAreaElement>, value: string) => void;
|
|
31
26
|
/** Dummy text inside the textarea when it's empty */
|
|
32
27
|
placeholder: string;
|
|
28
|
+
/** Ref to the textarea element. */
|
|
29
|
+
ref: RefObject<HTMLTextAreaElement | null>;
|
|
33
30
|
/** Whether the textarea is scrollable when it has more content than height */
|
|
34
31
|
scrollbar: boolean;
|
|
35
32
|
/** Clears the textarea when the enter key is pressed */
|
|
@@ -38,23 +35,12 @@ export declare const TextArea: import('react').ForwardRefExoticComponent<Partial
|
|
|
38
35
|
userMarkup: Record<string, string>;
|
|
39
36
|
/** The value of the textarea */
|
|
40
37
|
value: string;
|
|
41
|
-
}> &
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
onContextMenu: import('react').MouseEventHandler<HTMLDivElement>;
|
|
51
|
-
onDoubleClick: import('react').MouseEventHandler<HTMLDivElement>;
|
|
52
|
-
onKeyDown: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
53
|
-
onKeyUp: import('react').KeyboardEventHandler<HTMLDivElement>;
|
|
54
|
-
onMouseDown: import('react').MouseEventHandler<HTMLDivElement>;
|
|
55
|
-
onMouseLeave: import('react').MouseEventHandler<HTMLDivElement>;
|
|
56
|
-
onMouseMove: import('react').MouseEventHandler<HTMLDivElement>;
|
|
57
|
-
onMouseOver: import('react').MouseEventHandler<HTMLDivElement>;
|
|
58
|
-
onMouseUp: import('react').MouseEventHandler<HTMLDivElement>;
|
|
59
|
-
onScroll: import('react').UIEventHandler<HTMLDivElement>;
|
|
60
|
-
}> & import('react').RefAttributes<HTMLTextAreaElement>>;
|
|
38
|
+
}> & BoxProps;
|
|
39
|
+
/**
|
|
40
|
+
* ## Textarea
|
|
41
|
+
*
|
|
42
|
+
* An input for larger amounts of text. Use this when you want inputs larger
|
|
43
|
+
* than one row.
|
|
44
|
+
*/
|
|
45
|
+
export declare function TextArea(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export {};
|
|
@@ -1,139 +1,126 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { KEY as A, isEscape as
|
|
4
|
-
import { classes as
|
|
5
|
-
import { Box as
|
|
6
|
-
import { toInputValue as
|
|
7
|
-
function
|
|
8
|
-
return `${
|
|
1
|
+
import { jsxs as M, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as R, useState as Y, useEffect as y } from "react";
|
|
3
|
+
import { KEY as A, isEscape as I } from "../common/keys.js";
|
|
4
|
+
import { classes as p } from "../common/react.js";
|
|
5
|
+
import { Box as L } from "./Box.js";
|
|
6
|
+
import { toInputValue as h } from "./Input.js";
|
|
7
|
+
function U(a, s, l, e) {
|
|
8
|
+
return `${a.substring(0, l)}${s}${a.substring(l, e)}${s}${a.substring(e)}`;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
f == null || f(r, r.currentTarget.value), b && (r.currentTarget.value = ""), r.currentTarget.blur();
|
|
10
|
+
function Q(a) {
|
|
11
|
+
const {
|
|
12
|
+
autoFocus: s,
|
|
13
|
+
autoSelect: l,
|
|
14
|
+
displayedValue: e,
|
|
15
|
+
dontUseTabForIndent: k,
|
|
16
|
+
maxLength: S,
|
|
17
|
+
noborder: $,
|
|
18
|
+
onChange: n,
|
|
19
|
+
onEnter: i,
|
|
20
|
+
onEscape: f,
|
|
21
|
+
onInput: g,
|
|
22
|
+
placeholder: E,
|
|
23
|
+
ref: m,
|
|
24
|
+
scrollbar: K,
|
|
25
|
+
selfClear: b,
|
|
26
|
+
userMarkup: T,
|
|
27
|
+
value: x,
|
|
28
|
+
...w
|
|
29
|
+
} = a, { className: N, fluid: D, nowrap: C, ...V } = w, u = R((m == null ? void 0 : m.current) ?? null), [j, B] = Y(0);
|
|
30
|
+
function F(r) {
|
|
31
|
+
if (r.key === A.Enter) {
|
|
32
|
+
if (r.shiftKey) {
|
|
33
|
+
r.currentTarget.focus();
|
|
37
34
|
return;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!k && r.key === A.Tab) {
|
|
44
|
-
r.preventDefault();
|
|
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;
|
|
57
|
-
}
|
|
36
|
+
i == null || i(r, r.currentTarget.value), b && (r.currentTarget.value = ""), r.currentTarget.blur();
|
|
37
|
+
return;
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
if (I(r.key)) {
|
|
40
|
+
f == null || f(r), b ? r.currentTarget.value = "" : (r.currentTarget.value = h(x), r.currentTarget.blur());
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!k && r.key === A.Tab) {
|
|
44
|
+
r.preventDefault();
|
|
45
|
+
const { value: t, selectionStart: o, selectionEnd: c } = r.currentTarget;
|
|
46
|
+
r.currentTarget.value = `${t.substring(0, o)} ${t.substring(c)}`, r.currentTarget.selectionEnd = o + 1;
|
|
47
|
+
}
|
|
48
|
+
if (T && (r.ctrlKey || r.metaKey) && T[r.key]) {
|
|
49
|
+
r.preventDefault();
|
|
50
|
+
const { value: t, selectionStart: o, selectionEnd: c } = r.currentTarget, _ = T[r.key];
|
|
51
|
+
r.currentTarget.value = U(
|
|
52
|
+
t,
|
|
53
|
+
_,
|
|
54
|
+
o,
|
|
55
|
+
c
|
|
56
|
+
), r.currentTarget.selectionEnd = c + _.length * 2;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return y(() => {
|
|
60
|
+
if (s || l) {
|
|
61
|
+
const r = u.current;
|
|
62
|
+
r && setTimeout(() => {
|
|
63
|
+
r.focus(), l && r.select();
|
|
67
64
|
}, 1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onKeyDown: B,
|
|
121
|
-
onScroll: () => {
|
|
122
|
-
s && a.current && j(a.current.scrollTop);
|
|
123
|
-
},
|
|
124
|
-
placeholder: $,
|
|
125
|
-
ref: a,
|
|
126
|
-
spellCheck: !1,
|
|
127
|
-
style: {
|
|
128
|
-
color: s ? "rgba(0, 0, 0, 0)" : "inherit"
|
|
129
|
-
}
|
|
65
|
+
}
|
|
66
|
+
}, []), y(() => {
|
|
67
|
+
const r = u.current;
|
|
68
|
+
if (r) {
|
|
69
|
+
const t = h(x);
|
|
70
|
+
r.value !== t && (r.value = t);
|
|
71
|
+
}
|
|
72
|
+
}, [x]), /* @__PURE__ */ M(
|
|
73
|
+
L,
|
|
74
|
+
{
|
|
75
|
+
className: p([
|
|
76
|
+
"TextArea",
|
|
77
|
+
D && "TextArea--fluid",
|
|
78
|
+
$ && "TextArea--noborder",
|
|
79
|
+
N
|
|
80
|
+
]),
|
|
81
|
+
...V,
|
|
82
|
+
children: [
|
|
83
|
+
!!e && /* @__PURE__ */ d("div", { className: "TextArea__value-container", children: /* @__PURE__ */ d(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: p([
|
|
87
|
+
"TextArea__textarea",
|
|
88
|
+
"TextArea__textarea_custom"
|
|
89
|
+
]),
|
|
90
|
+
style: {
|
|
91
|
+
transform: `translateY(-${j}px)`
|
|
92
|
+
},
|
|
93
|
+
children: e
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
/* @__PURE__ */ d(
|
|
97
|
+
"textarea",
|
|
98
|
+
{
|
|
99
|
+
autoComplete: "off",
|
|
100
|
+
className: p([
|
|
101
|
+
"TextArea__textarea",
|
|
102
|
+
K && "TextArea__textarea--scrollable",
|
|
103
|
+
C && "TextArea__nowrap"
|
|
104
|
+
]),
|
|
105
|
+
maxLength: S,
|
|
106
|
+
onBlur: (r) => n == null ? void 0 : n(r, r.target.value),
|
|
107
|
+
onChange: (r) => g == null ? void 0 : g(r, r.target.value),
|
|
108
|
+
onKeyDown: F,
|
|
109
|
+
onScroll: () => {
|
|
110
|
+
e && u.current && B(u.current.scrollTop);
|
|
111
|
+
},
|
|
112
|
+
placeholder: E,
|
|
113
|
+
ref: u,
|
|
114
|
+
spellCheck: !1,
|
|
115
|
+
style: {
|
|
116
|
+
color: e ? "rgba(0, 0, 0, 0)" : "inherit"
|
|
130
117
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
137
124
|
export {
|
|
138
|
-
|
|
125
|
+
Q as TextArea
|
|
139
126
|
};
|
package/package.json
CHANGED
|
@@ -11,6 +11,8 @@ $border-radius: 0 !default;
|
|
|
11
11
|
display: inline-block;
|
|
12
12
|
position: relative;
|
|
13
13
|
width: 100%;
|
|
14
|
+
min-height: 1.667em;
|
|
15
|
+
align-content: center;
|
|
14
16
|
padding: 0 var(--space-m);
|
|
15
17
|
border-width: var(--border-thickness-tiny) !important;
|
|
16
18
|
border-style: solid !important;
|