tgui-core 1.2.0 → 1.3.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/README.md +3 -3
- package/dist/common/color.js +31 -30
- package/dist/common/events.js +5 -5
- package/dist/common/format.js +27 -27
- package/dist/common/hotkeys.d.ts +0 -1
- package/dist/common/hotkeys.js +2 -2
- package/dist/common/math.d.ts +4 -0
- package/dist/common/math.js +29 -25
- package/dist/common/random.js +14 -13
- package/dist/common/react.js +1 -1
- package/dist/common/string.js +9 -9
- package/dist/common/type-utils.d.ts +1 -1
- package/dist/components/AnimatedNumber.d.ts +6 -6
- package/dist/components/AnimatedNumber.js +14 -17
- package/dist/components/Autofocus.d.ts +0 -1
- package/dist/components/Blink.d.ts +0 -1
- package/dist/components/BlockQuote.d.ts +0 -1
- package/dist/components/BlockQuote.js +4 -7
- package/dist/components/Box.d.ts +0 -1
- package/dist/components/Box.js +4 -4
- package/dist/components/Button.d.ts +0 -1
- package/dist/components/Button.js +173 -211
- package/dist/components/ByondUi.js +3 -3
- package/dist/components/Chart.d.ts +0 -1
- package/dist/components/Chart.js +25 -22
- package/dist/components/Collapsible.d.ts +0 -1
- package/dist/components/ColorBox.d.ts +0 -1
- package/dist/components/ColorBox.js +7 -14
- package/dist/components/Dialog.js +31 -40
- package/dist/components/Dimmer.d.ts +0 -1
- package/dist/components/Dimmer.js +6 -9
- package/dist/components/Divider.js +10 -14
- package/dist/components/DmIcon.d.ts +0 -1
- package/dist/components/DraggableControl.js +57 -49
- package/dist/components/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown.js +73 -67
- package/dist/components/FitText.d.ts +0 -1
- package/dist/components/Flex.d.ts +1 -1
- package/dist/components/Flex.js +39 -41
- package/dist/components/Icon.d.ts +0 -1
- package/dist/components/Icon.js +27 -34
- package/dist/components/Image.d.ts +0 -1
- package/dist/components/Image.js +7 -6
- package/dist/components/ImageButton.d.ts +0 -1
- package/dist/components/ImageButton.js +84 -171
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +0 -1
- package/dist/components/Input.js +57 -64
- package/dist/components/KeyListener.d.ts +0 -1
- package/dist/components/Knob.d.ts +0 -1
- package/dist/components/Knob.js +91 -117
- package/dist/components/LabeledControls.d.ts +0 -1
- package/dist/components/LabeledList.d.ts +0 -1
- package/dist/components/LabeledList.js +48 -55
- package/dist/components/MenuBar.d.ts +0 -1
- package/dist/components/MenuBar.js +93 -102
- package/dist/components/Modal.d.ts +0 -1
- package/dist/components/Modal.js +11 -18
- package/dist/components/NoticeBox.d.ts +0 -1
- package/dist/components/NoticeBox.js +16 -43
- package/dist/components/NumberInput.d.ts +0 -2
- package/dist/components/NumberInput.js +99 -107
- package/dist/components/Popper.d.ts +0 -1
- package/dist/components/ProgressBar.d.ts +0 -1
- package/dist/components/ProgressBar.js +22 -27
- package/dist/components/RestrictedInput.js +64 -58
- package/dist/components/RoundGauge.d.ts +0 -1
- package/dist/components/RoundGauge.js +70 -104
- package/dist/components/Section.d.ts +1 -2
- package/dist/components/Section.js +50 -51
- package/dist/components/Slider.d.ts +0 -1
- package/dist/components/Slider.js +72 -80
- package/dist/components/Stack.d.ts +0 -1
- package/dist/components/Stack.js +37 -47
- package/dist/components/StyleableSection.d.ts +0 -1
- package/dist/components/StyleableSection.js +11 -11
- package/dist/components/Table.d.ts +0 -1
- package/dist/components/Table.js +38 -47
- package/dist/components/Tabs.d.ts +0 -1
- package/dist/components/Tabs.js +43 -75
- package/dist/components/TextArea.d.ts +0 -1
- package/dist/components/TextArea.js +74 -69
- package/dist/components/TimeDisplay.d.ts +7 -6
- package/dist/components/TimeDisplay.js +17 -17
- package/dist/components/Tooltip.d.ts +1 -2
- package/dist/components/Tooltip.js +8 -10
- package/dist/components/TrackOutsideClicks.d.ts +0 -1
- package/dist/components/VirtualList.d.ts +0 -1
- package/package.json +11 -25
- package/dist/ProgressBar.module-Jzqlebbx.js +0 -29
- package/dist/Section.module-qhQWhlUX.js +0 -18
- package/dist/assets/BlockQuote.css +0 -1
- package/dist/assets/Button.css +0 -1
- package/dist/assets/ColorBox.css +0 -1
- package/dist/assets/Dialog.css +0 -1
- package/dist/assets/Dimmer.css +0 -1
- package/dist/assets/Divider.css +0 -1
- package/dist/assets/Flex.css +0 -1
- package/dist/assets/Icon.css +0 -6
- package/dist/assets/ImageButton.css +0 -5
- package/dist/assets/Input.css +0 -1
- package/dist/assets/Knob.css +0 -1
- package/dist/assets/LabeledList.css +0 -1
- package/dist/assets/MenuBar.css +0 -1
- package/dist/assets/Modal.css +0 -1
- package/dist/assets/NoticeBox.css +0 -1
- package/dist/assets/NumberInput.css +0 -1
- package/dist/assets/ProgressBar.css +0 -1
- package/dist/assets/RoundGauge.css +0 -1
- package/dist/assets/Section.css +0 -1
- package/dist/assets/Slider.css +0 -1
- package/dist/assets/Stack.css +0 -1
- package/dist/assets/Table.css +0 -1
- package/dist/assets/Tabs.css +0 -1
- package/dist/assets/TextArea.css +0 -1
- package/dist/assets/Tooltip.css +0 -1
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Button as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
button: f
|
|
12
|
-
};
|
|
13
|
-
function h(n) {
|
|
14
|
-
const { title: e, onClose: i, children: r, width: l, height: _ } = n;
|
|
15
|
-
return /* @__PURE__ */ t("div", { className: o.dialog, children: /* @__PURE__ */ c(s, { className: o.content, width: l || "370px", height: _, children: [
|
|
16
|
-
/* @__PURE__ */ c("div", { className: o.header, children: [
|
|
17
|
-
/* @__PURE__ */ t("div", { className: o.title, children: e }),
|
|
18
|
-
/* @__PURE__ */ t(s, { mr: 2, children: /* @__PURE__ */ t(
|
|
19
|
-
a,
|
|
1
|
+
import { jsx as o, jsxs as e } from "react/jsx-runtime";
|
|
2
|
+
import { Box as r } from "./Box.js";
|
|
3
|
+
import { Button as s } from "./Button.js";
|
|
4
|
+
function d(i) {
|
|
5
|
+
const { title: n, onClose: t, children: c, width: l, height: h } = i;
|
|
6
|
+
return /* @__PURE__ */ o("div", { className: "Dialog", children: /* @__PURE__ */ e(r, { className: "Dialog__content", width: l || "370px", height: h, children: [
|
|
7
|
+
/* @__PURE__ */ e("div", { className: "Dialog__header", children: [
|
|
8
|
+
/* @__PURE__ */ o("div", { className: "Dialog__title", children: n }),
|
|
9
|
+
/* @__PURE__ */ o(r, { mr: 2, children: /* @__PURE__ */ o(
|
|
10
|
+
s,
|
|
20
11
|
{
|
|
21
12
|
mr: "-3px",
|
|
22
13
|
width: "26px",
|
|
@@ -26,42 +17,42 @@ function h(n) {
|
|
|
26
17
|
icon: "window-close-o",
|
|
27
18
|
tooltip: "Close",
|
|
28
19
|
tooltipPosition: "bottom-start",
|
|
29
|
-
onClick:
|
|
20
|
+
onClick: t
|
|
30
21
|
}
|
|
31
22
|
) })
|
|
32
23
|
] }),
|
|
33
|
-
|
|
24
|
+
c
|
|
34
25
|
] }) });
|
|
35
26
|
}
|
|
36
|
-
function
|
|
37
|
-
const { onClick:
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
-
|
|
27
|
+
function a(i) {
|
|
28
|
+
const { onClick: n, children: t } = i;
|
|
29
|
+
return /* @__PURE__ */ o(
|
|
30
|
+
s,
|
|
40
31
|
{
|
|
41
|
-
onClick:
|
|
42
|
-
className:
|
|
32
|
+
onClick: n,
|
|
33
|
+
className: "Dialog__button",
|
|
43
34
|
verticalAlignContent: "middle",
|
|
44
|
-
children:
|
|
35
|
+
children: t
|
|
45
36
|
}
|
|
46
37
|
);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
|
-
function
|
|
50
|
-
const { documentName:
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
39
|
+
d.Button = a;
|
|
40
|
+
function p(i) {
|
|
41
|
+
const { documentName: n, onSave: t, onDiscard: c, onClose: l } = i;
|
|
42
|
+
return /* @__PURE__ */ e(d, { title: "Notepad", onClose: l, children: [
|
|
43
|
+
/* @__PURE__ */ e("div", { className: "Dialog__body", children: [
|
|
53
44
|
"Do you want to save changes to ",
|
|
54
|
-
|
|
45
|
+
n,
|
|
55
46
|
"?"
|
|
56
47
|
] }),
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ e("div", { className: "Dialog__footer", children: [
|
|
49
|
+
/* @__PURE__ */ o(a, { onClick: t, children: "Save" }),
|
|
50
|
+
/* @__PURE__ */ o(a, { onClick: c, children: "Don't Save" }),
|
|
51
|
+
/* @__PURE__ */ o(a, { onClick: l, children: "Cancel" })
|
|
61
52
|
] })
|
|
62
53
|
] });
|
|
63
54
|
}
|
|
64
55
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
d as Dialog,
|
|
57
|
+
p as UnsavedChangesDialog
|
|
67
58
|
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { classes as o } from "../common/react.js";
|
|
3
|
-
import { Box as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
function _(r) {
|
|
8
|
-
const { className: e, children: s, ...i } = r;
|
|
9
|
-
return /* @__PURE__ */ m(t, { className: o([n.dimmer, e]), ...i, children: /* @__PURE__ */ m("div", { className: "Dimmer__inner", children: s }) });
|
|
3
|
+
import { Box as c } from "./Box.js";
|
|
4
|
+
function l(m) {
|
|
5
|
+
const { className: e, children: s, ...i } = m;
|
|
6
|
+
return /* @__PURE__ */ r(c, { className: o(["Dimmer", e]), ...i, children: /* @__PURE__ */ r("div", { className: "Dimmer__inner", children: s }) });
|
|
10
7
|
}
|
|
11
8
|
export {
|
|
12
|
-
|
|
9
|
+
l as Dimmer
|
|
13
10
|
};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { classes as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
vertical: s
|
|
7
|
-
};
|
|
8
|
-
function l(t) {
|
|
9
|
-
const { hidden: o, vertical: n } = t;
|
|
10
|
-
return /* @__PURE__ */ r(
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { classes as o } from "../common/react.js";
|
|
3
|
+
function n(i) {
|
|
4
|
+
const { hidden: r, vertical: e } = i;
|
|
5
|
+
return /* @__PURE__ */ d(
|
|
11
6
|
"div",
|
|
12
7
|
{
|
|
13
|
-
className:
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
className: o([
|
|
9
|
+
"Divider",
|
|
10
|
+
r && "Divider--hidden",
|
|
11
|
+
e ? "Divider--vertical" : "Divider--horizontal"
|
|
16
12
|
])
|
|
17
13
|
}
|
|
18
14
|
);
|
|
19
15
|
}
|
|
20
16
|
export {
|
|
21
|
-
|
|
17
|
+
n as Divider
|
|
22
18
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as T, Fragment as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { jsxs as T, Fragment as I, jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { Component as x, createRef as y } from "react";
|
|
3
|
+
import { clamp as c } from "../common/math.js";
|
|
4
4
|
import { AnimatedNumber as M } from "./AnimatedNumber.js";
|
|
5
5
|
const R = 400;
|
|
6
|
-
function
|
|
6
|
+
function N(v, u) {
|
|
7
7
|
return v.screenX * u[0] + v.screenY * u[1];
|
|
8
8
|
}
|
|
9
|
-
class C extends
|
|
9
|
+
class C extends x {
|
|
10
10
|
constructor(u) {
|
|
11
|
-
super(u), this.inputRef =
|
|
11
|
+
super(u), this.inputRef = y(), this.state = {
|
|
12
12
|
value: u.value,
|
|
13
13
|
dragging: !1,
|
|
14
14
|
editing: !1,
|
|
@@ -28,7 +28,7 @@ class C extends b {
|
|
|
28
28
|
const { value: i, dragMatrix: l } = this.props, { editing: s } = this.state;
|
|
29
29
|
s || (document.body.style["pointer-events"] = "none", this.ref = e.target, this.setState({
|
|
30
30
|
dragging: !1,
|
|
31
|
-
origin:
|
|
31
|
+
origin: N(e, l),
|
|
32
32
|
value: i,
|
|
33
33
|
internalValue: i
|
|
34
34
|
}), this.timer = setTimeout(() => {
|
|
@@ -36,26 +36,26 @@ class C extends b {
|
|
|
36
36
|
dragging: !0
|
|
37
37
|
});
|
|
38
38
|
}, 250), this.dragInterval = setInterval(() => {
|
|
39
|
-
const { dragging: o, value: g } = this.state, { onDrag:
|
|
40
|
-
o &&
|
|
39
|
+
const { dragging: o, value: g } = this.state, { onDrag: r } = this.props;
|
|
40
|
+
o && r && r(e, g);
|
|
41
41
|
}, this.props.updateRate || R), document.addEventListener("mousemove", this.handleDragMove), document.addEventListener("mouseup", this.handleDragEnd));
|
|
42
42
|
}, this.handleDragMove = (e) => {
|
|
43
43
|
const { minValue: i, maxValue: l, step: s, stepPixelSize: o, dragMatrix: g } = this.props;
|
|
44
|
-
this.setState((
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
44
|
+
this.setState((r) => {
|
|
45
|
+
const a = { ...r }, p = N(e, g) - a.origin;
|
|
46
|
+
if (r.dragging) {
|
|
47
47
|
const h = Number.isFinite(i) ? i % s : 0;
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
a.internalValue = c(
|
|
49
|
+
a.internalValue + p * s / o,
|
|
50
50
|
i - s,
|
|
51
51
|
l + s
|
|
52
|
-
),
|
|
53
|
-
|
|
52
|
+
), a.value = c(
|
|
53
|
+
a.internalValue - a.internalValue % s + h,
|
|
54
54
|
i,
|
|
55
55
|
l
|
|
56
|
-
),
|
|
57
|
-
} else Math.abs(p) > 4 && (
|
|
58
|
-
return
|
|
56
|
+
), a.origin = N(e, g);
|
|
57
|
+
} else Math.abs(p) > 4 && (a.dragging = !0);
|
|
58
|
+
return a;
|
|
59
59
|
});
|
|
60
60
|
}, this.handleDragEnd = (e) => {
|
|
61
61
|
const { onChange: i, onDrag: l } = this.props, { dragging: s, value: o, internalValue: g } = this.state;
|
|
@@ -66,9 +66,9 @@ class C extends b {
|
|
|
66
66
|
}), document.removeEventListener("mousemove", this.handleDragMove), document.removeEventListener("mouseup", this.handleDragEnd), s)
|
|
67
67
|
this.suppressFlicker(), i && i(e, o), l && l(e, o);
|
|
68
68
|
else if (this.inputRef) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const r = this.inputRef.current;
|
|
70
|
+
r.value = g, setTimeout(() => {
|
|
71
|
+
r.focus(), r.select();
|
|
72
72
|
}, 10);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
@@ -83,39 +83,43 @@ class C extends b {
|
|
|
83
83
|
animated: s,
|
|
84
84
|
value: o,
|
|
85
85
|
unit: g,
|
|
86
|
-
minValue:
|
|
87
|
-
maxValue:
|
|
86
|
+
minValue: r,
|
|
87
|
+
maxValue: a,
|
|
88
88
|
unclamped: p,
|
|
89
89
|
format: h,
|
|
90
|
-
onChange:
|
|
91
|
-
onDrag:
|
|
92
|
-
children:
|
|
90
|
+
onChange: m,
|
|
91
|
+
onDrag: f,
|
|
92
|
+
children: S,
|
|
93
93
|
// Input props
|
|
94
|
-
height:
|
|
95
|
-
lineHeight:
|
|
96
|
-
fontSize:
|
|
94
|
+
height: V,
|
|
95
|
+
lineHeight: D,
|
|
96
|
+
fontSize: b
|
|
97
97
|
} = this.props;
|
|
98
98
|
let d = o;
|
|
99
99
|
(u || l) && (d = i);
|
|
100
|
-
const
|
|
100
|
+
const k = /* @__PURE__ */ T(I, { children: [
|
|
101
101
|
s && !u && !l ? /* @__PURE__ */ F(M, { value: d, format: h }) : h ? h(d) : d,
|
|
102
|
-
g ?
|
|
103
|
-
] }),
|
|
102
|
+
g ? ` ${g}` : ""
|
|
103
|
+
] }), E = /* @__PURE__ */ F(
|
|
104
104
|
"input",
|
|
105
105
|
{
|
|
106
106
|
ref: this.inputRef,
|
|
107
107
|
className: "NumberInput__input",
|
|
108
108
|
style: {
|
|
109
109
|
display: e ? void 0 : "none",
|
|
110
|
-
height:
|
|
111
|
-
lineHeight:
|
|
112
|
-
fontsize:
|
|
110
|
+
height: V,
|
|
111
|
+
lineHeight: D,
|
|
112
|
+
fontsize: b
|
|
113
113
|
},
|
|
114
|
-
onBlur: (
|
|
114
|
+
onBlur: (n) => {
|
|
115
115
|
if (!e)
|
|
116
116
|
return;
|
|
117
117
|
let t;
|
|
118
|
-
if (p ? t = parseFloat(
|
|
118
|
+
if (p ? t = Number.parseFloat(n.target.value) : t = c(
|
|
119
|
+
Number.parseFloat(n.target.value),
|
|
120
|
+
r,
|
|
121
|
+
a
|
|
122
|
+
), Number.isNaN(t)) {
|
|
119
123
|
this.setState({
|
|
120
124
|
editing: !1
|
|
121
125
|
});
|
|
@@ -124,12 +128,16 @@ class C extends b {
|
|
|
124
128
|
this.setState({
|
|
125
129
|
editing: !1,
|
|
126
130
|
value: t
|
|
127
|
-
}), this.suppressFlicker(),
|
|
131
|
+
}), this.suppressFlicker(), m && m(n, t), f && f(n, t);
|
|
128
132
|
},
|
|
129
|
-
onKeyDown: (
|
|
130
|
-
if (
|
|
133
|
+
onKeyDown: (n) => {
|
|
134
|
+
if (n.keyCode === 13) {
|
|
131
135
|
let t;
|
|
132
|
-
if (p ? t = parseFloat(
|
|
136
|
+
if (p ? t = Number.parseFloat(n.target.value) : t = c(
|
|
137
|
+
Number.parseFloat(n.target.value),
|
|
138
|
+
r,
|
|
139
|
+
a
|
|
140
|
+
), Number.isNaN(t)) {
|
|
133
141
|
this.setState({
|
|
134
142
|
editing: !1
|
|
135
143
|
});
|
|
@@ -138,10 +146,10 @@ class C extends b {
|
|
|
138
146
|
this.setState({
|
|
139
147
|
editing: !1,
|
|
140
148
|
value: t
|
|
141
|
-
}), this.suppressFlicker(),
|
|
149
|
+
}), this.suppressFlicker(), m && m(n, t), f && f(n, t);
|
|
142
150
|
return;
|
|
143
151
|
}
|
|
144
|
-
if (
|
|
152
|
+
if (n.keyCode === 27) {
|
|
145
153
|
this.setState({
|
|
146
154
|
editing: !1
|
|
147
155
|
});
|
|
@@ -150,20 +158,20 @@ class C extends b {
|
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
160
|
);
|
|
153
|
-
return
|
|
161
|
+
return S({
|
|
154
162
|
dragging: u,
|
|
155
163
|
editing: e,
|
|
156
164
|
value: o,
|
|
157
165
|
displayValue: d,
|
|
158
|
-
displayElement:
|
|
159
|
-
inputElement:
|
|
166
|
+
displayElement: k,
|
|
167
|
+
inputElement: E,
|
|
160
168
|
handleDragStart: this.handleDragStart
|
|
161
169
|
});
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
C.defaultProps = {
|
|
165
|
-
minValue:
|
|
166
|
-
maxValue:
|
|
173
|
+
minValue: Number.NEGATIVE_INFINITY,
|
|
174
|
+
maxValue: Number.POSITIVE_INFINITY,
|
|
167
175
|
step: 1,
|
|
168
176
|
stepPixelSize: 1,
|
|
169
177
|
suppressFlicker: 50,
|
|
@@ -1,141 +1,147 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as F, useRef as L, useEffect as
|
|
3
|
-
import { classes as
|
|
4
|
-
import { unit as
|
|
1
|
+
import { jsx as l, jsxs as p, Fragment as W } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useRef as L, useEffect as S } from "react";
|
|
3
|
+
import { classes as N } from "../common/react.js";
|
|
4
|
+
import { unit as $ } from "./Box.js";
|
|
5
5
|
import { Button as D } from "./Button.js";
|
|
6
6
|
import { Icon as b } from "./Icon.js";
|
|
7
|
-
import { Popper as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
return typeof
|
|
7
|
+
import { Popper as q } from "./Popper.js";
|
|
8
|
+
const z = -1;
|
|
9
|
+
function h(u) {
|
|
10
|
+
return typeof u == "string" ? u : u.value;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function X(u) {
|
|
13
13
|
const {
|
|
14
|
-
autoScroll:
|
|
14
|
+
autoScroll: v = !0,
|
|
15
15
|
buttons: I,
|
|
16
16
|
className: O,
|
|
17
17
|
clipSelectedText: k = !0,
|
|
18
18
|
color: B = "default",
|
|
19
|
-
disabled:
|
|
20
|
-
displayText:
|
|
19
|
+
disabled: d,
|
|
20
|
+
displayText: E,
|
|
21
21
|
icon: x,
|
|
22
22
|
iconRotation: T,
|
|
23
23
|
iconSpin: j,
|
|
24
|
-
menuWidth:
|
|
25
|
-
noChevron:
|
|
26
|
-
onClick:
|
|
27
|
-
onSelected:
|
|
28
|
-
options:
|
|
29
|
-
over:
|
|
30
|
-
placeholder:
|
|
31
|
-
selected:
|
|
24
|
+
menuWidth: C = "15rem",
|
|
25
|
+
noChevron: R,
|
|
26
|
+
onClick: a,
|
|
27
|
+
onSelected: o,
|
|
28
|
+
options: c = [],
|
|
29
|
+
over: y,
|
|
30
|
+
placeholder: K = "Select...",
|
|
31
|
+
selected: m,
|
|
32
32
|
width: P = "15rem"
|
|
33
|
-
} =
|
|
34
|
-
function
|
|
35
|
-
var
|
|
36
|
-
let
|
|
37
|
-
e <
|
|
38
|
-
const n = (
|
|
33
|
+
} = u, [r, f] = F(!1), V = y ? !r : r, w = L(null), i = c.findIndex((e) => h(e) === m) || 0;
|
|
34
|
+
function g(e) {
|
|
35
|
+
var t;
|
|
36
|
+
let s = e;
|
|
37
|
+
e < i ? s = e < 2 ? 0 : e - 2 : s = e > c.length - 3 ? c.length - 1 : e - 2;
|
|
38
|
+
const n = (t = w.current) == null ? void 0 : t.children[s];
|
|
39
39
|
n == null || n.scrollIntoView({ block: "nearest" });
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (
|
|
41
|
+
function _(e) {
|
|
42
|
+
if (c.length < 1 || d)
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
|
|
44
|
+
const s = 0, n = c.length - 1;
|
|
45
|
+
let t;
|
|
46
|
+
i < 0 ? t = e === "next" ? n : s : e === "next" ? t = i === n ? s : i + 1 : t = i === s ? n : i - 1, r && v && g(t), o == null || o(h(c[t]));
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return S(() => {
|
|
49
49
|
var e;
|
|
50
|
-
|
|
51
|
-
}, [
|
|
52
|
-
|
|
50
|
+
r && (v && i !== z && g(i), (e = w.current) == null || e.focus());
|
|
51
|
+
}, [r]), /* @__PURE__ */ l(
|
|
52
|
+
q,
|
|
53
53
|
{
|
|
54
|
-
isOpen:
|
|
55
|
-
onClickOutside: () =>
|
|
56
|
-
placement:
|
|
57
|
-
content: /* @__PURE__ */
|
|
54
|
+
isOpen: r,
|
|
55
|
+
onClickOutside: () => f(!1),
|
|
56
|
+
placement: y ? "top-start" : "bottom-start",
|
|
57
|
+
content: /* @__PURE__ */ p(
|
|
58
58
|
"div",
|
|
59
59
|
{
|
|
60
60
|
className: "Layout Dropdown__menu",
|
|
61
|
-
style: { minWidth:
|
|
62
|
-
ref:
|
|
61
|
+
style: { minWidth: C },
|
|
62
|
+
ref: w,
|
|
63
63
|
children: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const n =
|
|
67
|
-
return /* @__PURE__ */
|
|
64
|
+
c.length === 0 && /* @__PURE__ */ l("div", { className: "Dropdown__menuentry", children: "No options" }),
|
|
65
|
+
c.map((e, s) => {
|
|
66
|
+
const n = h(e);
|
|
67
|
+
return /* @__PURE__ */ l(
|
|
68
68
|
"div",
|
|
69
69
|
{
|
|
70
|
-
className:
|
|
70
|
+
className: N([
|
|
71
71
|
"Dropdown__menuentry",
|
|
72
|
-
|
|
72
|
+
m === n && "selected"
|
|
73
73
|
]),
|
|
74
74
|
onClick: () => {
|
|
75
|
-
|
|
75
|
+
f(!1), o == null || o(n);
|
|
76
|
+
},
|
|
77
|
+
onKeyDown: (t) => {
|
|
78
|
+
t.key === "Enter" && (f(!1), o == null || o(n));
|
|
76
79
|
},
|
|
77
80
|
children: typeof e == "string" ? e : e.displayText
|
|
78
81
|
},
|
|
79
|
-
|
|
82
|
+
s
|
|
80
83
|
);
|
|
81
84
|
})
|
|
82
85
|
]
|
|
83
86
|
}
|
|
84
87
|
),
|
|
85
|
-
children: /* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
88
|
+
children: /* @__PURE__ */ p("div", { className: "Dropdown", style: { width: $(P) }, children: [
|
|
89
|
+
/* @__PURE__ */ p(
|
|
87
90
|
"div",
|
|
88
91
|
{
|
|
89
|
-
className:
|
|
92
|
+
className: N([
|
|
90
93
|
"Dropdown__control",
|
|
91
94
|
"Button",
|
|
92
95
|
"Button--dropdown",
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
`Button--color--${B}`,
|
|
97
|
+
d && "Button--disabled",
|
|
95
98
|
O
|
|
96
99
|
]),
|
|
97
100
|
onClick: (e) => {
|
|
98
|
-
|
|
101
|
+
d && !r || (f(!r), a == null || a(e));
|
|
102
|
+
},
|
|
103
|
+
onKeyDown: (e) => {
|
|
104
|
+
e.key === "Enter" && !d && (f(!r), a == null || a(e));
|
|
99
105
|
},
|
|
100
106
|
children: [
|
|
101
|
-
x && /* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
107
|
+
x && /* @__PURE__ */ l(b, { mr: 1, name: x, rotation: T, spin: j }),
|
|
108
|
+
/* @__PURE__ */ l(
|
|
103
109
|
"span",
|
|
104
110
|
{
|
|
105
111
|
className: "Dropdown__selected-text",
|
|
106
112
|
style: {
|
|
107
113
|
overflow: k ? "hidden" : "visible"
|
|
108
114
|
},
|
|
109
|
-
children:
|
|
115
|
+
children: E || m && h(m) || K
|
|
110
116
|
}
|
|
111
117
|
),
|
|
112
|
-
!
|
|
118
|
+
!R && /* @__PURE__ */ l("span", { className: "Dropdown__arrow-button", children: /* @__PURE__ */ l(b, { name: V ? "chevron-up" : "chevron-down" }) })
|
|
113
119
|
]
|
|
114
120
|
}
|
|
115
121
|
),
|
|
116
|
-
I && /* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
122
|
+
I && /* @__PURE__ */ p(W, { children: [
|
|
123
|
+
/* @__PURE__ */ l(
|
|
118
124
|
D,
|
|
119
125
|
{
|
|
120
|
-
disabled:
|
|
126
|
+
disabled: d,
|
|
121
127
|
height: 1.8,
|
|
122
128
|
icon: "chevron-left",
|
|
123
129
|
onClick: () => {
|
|
124
|
-
|
|
130
|
+
_(
|
|
125
131
|
"previous"
|
|
126
132
|
/* Previous */
|
|
127
133
|
);
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
),
|
|
131
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ l(
|
|
132
138
|
D,
|
|
133
139
|
{
|
|
134
|
-
disabled:
|
|
140
|
+
disabled: d,
|
|
135
141
|
height: 1.8,
|
|
136
142
|
icon: "chevron-right",
|
|
137
143
|
onClick: () => {
|
|
138
|
-
|
|
144
|
+
_(
|
|
139
145
|
"next"
|
|
140
146
|
/* Next */
|
|
141
147
|
);
|
|
@@ -148,5 +154,5 @@ function Y(d) {
|
|
|
148
154
|
);
|
|
149
155
|
}
|
|
150
156
|
export {
|
|
151
|
-
|
|
157
|
+
X as Dropdown
|
|
152
158
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BoxProps } from './Box';
|
|
2
|
-
|
|
3
2
|
export type FlexProps = Partial<{
|
|
4
3
|
/**
|
|
5
4
|
* Default alignment of all children.
|
|
@@ -60,6 +59,7 @@ export declare function Flex(props: any): import("react/jsx-runtime").JSX.Elemen
|
|
|
60
59
|
export declare namespace Flex {
|
|
61
60
|
var Item: typeof FlexItem;
|
|
62
61
|
}
|
|
62
|
+
export declare const computeFlexItemClassName: (props: FlexItemProps) => string;
|
|
63
63
|
export type FlexItemProps = Partial<{
|
|
64
64
|
/** This allows the default alignment (or the one specified by align-items) to be overridden for individual flex items. */
|
|
65
65
|
align: string | boolean;
|