tgui-core 2.0.6 → 2.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/dist/common/collections.d.ts +1 -1
- package/dist/common/collections.js +1 -10
- package/dist/common/color.js +1 -70
- package/dist/common/constants.js +1 -329
- package/dist/common/events.js +1 -147
- package/dist/common/exhaustive.js +1 -6
- package/dist/common/format.js +1 -117
- package/dist/common/fp.js +1 -9
- package/dist/common/hotkeys.d.ts +1 -1
- package/dist/common/hotkeys.js +1 -112
- package/dist/common/http.js +1 -10
- package/dist/common/keycodes.js +1 -88
- package/dist/common/keys.js +1 -32
- package/dist/common/math.js +1 -45
- package/dist/common/random.js +1 -21
- package/dist/common/react.js +1 -30
- package/dist/common/string.js +1 -88
- package/dist/common/timer.js +1 -28
- package/dist/common/type-utils.js +1 -25
- package/dist/common/ui.d.ts +2 -2
- package/dist/common/ui.js +1 -141
- package/dist/common/uuid.js +1 -10
- package/dist/common/vector.js +1 -48
- package/dist/components/AnimatedNumber.d.ts +1 -1
- package/dist/components/AnimatedNumber.js +1 -73
- package/dist/components/Autofocus.d.ts +1 -1
- package/dist/components/Autofocus.js +1 -17
- package/dist/components/Blink.d.ts +1 -1
- package/dist/components/Blink.js +1 -56
- package/dist/components/BlockQuote.d.ts +1 -1
- package/dist/components/BlockQuote.js +1 -10
- package/dist/components/Box.d.ts +5 -5
- package/dist/components/Box.js +1 -19
- package/dist/components/Button.d.ts +4 -4
- package/dist/components/Button.js +1 -258
- package/dist/components/ByondUi.d.ts +1 -1
- package/dist/components/ByondUi.js +1 -61
- package/dist/components/Chart.d.ts +1 -1
- package/dist/components/Chart.js +1 -80
- package/dist/components/Collapsible.d.ts +2 -2
- package/dist/components/Collapsible.js +1 -36
- package/dist/components/ColorBox.d.ts +2 -2
- package/dist/components/ColorBox.js +1 -17
- package/dist/components/Dialog.d.ts +1 -1
- package/dist/components/Dialog.js +1 -42
- package/dist/components/Dimmer.d.ts +1 -1
- package/dist/components/Dimmer.js +1 -10
- package/dist/components/Divider.js +1 -18
- package/dist/components/DmIcon.d.ts +3 -3
- package/dist/components/DmIcon.js +1 -23
- package/dist/components/DraggableControl.d.ts +2 -2
- package/dist/components/DraggableControl.js +1 -111
- package/dist/components/Dropdown.d.ts +2 -2
- package/dist/components/Dropdown.js +1 -165
- package/dist/components/FitText.d.ts +2 -2
- package/dist/components/FitText.js +1 -63
- package/dist/components/Flex.d.ts +1 -1
- package/dist/components/Flex.js +1 -70
- package/dist/components/Floating.d.ts +3 -3
- package/dist/components/Floating.js +1 -2235
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Icon.js +1 -45
- package/dist/components/Image.d.ts +1 -1
- package/dist/components/Image.js +1 -38
- package/dist/components/ImageButton.d.ts +10 -5
- package/dist/components/ImageButton.js +1 -154
- package/dist/components/InfinitePlane.d.ts +2 -2
- package/dist/components/InfinitePlane.js +1 -133
- package/dist/components/Input.d.ts +2 -2
- package/dist/components/Input.js +1 -96
- package/dist/components/KeyListener.d.ts +1 -1
- package/dist/components/KeyListener.js +1 -15
- package/dist/components/Knob.d.ts +2 -2
- package/dist/components/Knob.js +1 -133
- package/dist/components/LabeledControls.d.ts +1 -1
- package/dist/components/LabeledControls.js +1 -39
- package/dist/components/LabeledList.d.ts +2 -2
- package/dist/components/LabeledList.js +1 -89
- package/dist/components/MenuBar.d.ts +32 -0
- package/dist/components/MenuBar.js +1 -133
- package/dist/components/Modal.d.ts +2 -2
- package/dist/components/Modal.js +1 -22
- package/dist/components/NoticeBox.d.ts +1 -1
- package/dist/components/NoticeBox.js +1 -23
- package/dist/components/NumberInput.d.ts +9 -19
- package/dist/components/NumberInput.js +1 -213
- package/dist/components/Popper.d.ts +8 -9
- package/dist/components/Popper.js +1 -1082
- package/dist/components/ProgressBar.d.ts +2 -2
- package/dist/components/ProgressBar.js +1 -33
- package/dist/components/RestrictedInput.d.ts +29 -0
- package/dist/components/RestrictedInput.js +1 -161
- package/dist/components/RoundGauge.d.ts +2 -2
- package/dist/components/RoundGauge.js +1 -114
- package/dist/components/Section.d.ts +2 -2
- package/dist/components/Section.js +1 -65
- package/dist/components/Slider.d.ts +2 -2
- package/dist/components/Slider.js +1 -113
- package/dist/components/Stack.d.ts +2 -2
- package/dist/components/Stack.js +1 -58
- package/dist/components/StyleableSection.d.ts +1 -1
- package/dist/components/StyleableSection.js +1 -16
- package/dist/components/Table.d.ts +1 -1
- package/dist/components/Table.js +1 -57
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tabs.js +1 -65
- package/dist/components/TextArea.d.ts +2 -2
- package/dist/components/TextArea.js +1 -126
- package/dist/components/TimeDisplay.js +1 -25
- package/dist/components/Tooltip.d.ts +2 -2
- package/dist/components/Tooltip.js +1 -18
- package/dist/components/TrackOutsideClicks.d.ts +2 -2
- package/dist/components/TrackOutsideClicks.js +1 -24
- package/dist/components/VirtualList.d.ts +1 -1
- package/dist/components/VirtualList.js +1 -34
- package/dist/components/index.js +1 -96
- package/license.txt +1 -1
- package/package.json +11 -17
- package/styles/components/Button.scss +1 -1
- package/dist/components/FakeTerminal.js +0 -38
|
@@ -1,111 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as F, useRef as i, useEffect as J } from "react";
|
|
3
|
-
import { KEY as Q, isEscape as W } from "../common/keys.js";
|
|
4
|
-
import { clamp as b } from "../common/math.js";
|
|
5
|
-
import { AnimatedNumber as Z } from "./AnimatedNumber.js";
|
|
6
|
-
const C = 400, x = -1;
|
|
7
|
-
function A(n, m) {
|
|
8
|
-
return n.screenX * m[0] + n.screenY * m[1];
|
|
9
|
-
}
|
|
10
|
-
function ie(n) {
|
|
11
|
-
const {
|
|
12
|
-
// Our props
|
|
13
|
-
animated: m,
|
|
14
|
-
children: L,
|
|
15
|
-
dragMatrix: S = [1, 0],
|
|
16
|
-
format: g,
|
|
17
|
-
maxValue: N = Number.POSITIVE_INFINITY,
|
|
18
|
-
minValue: o = Number.NEGATIVE_INFINITY,
|
|
19
|
-
onChange: a,
|
|
20
|
-
onDrag: l,
|
|
21
|
-
step: s = 1,
|
|
22
|
-
stepPixelSize: O = 1,
|
|
23
|
-
unclamped: Y,
|
|
24
|
-
unit: V,
|
|
25
|
-
updateRate: k = C,
|
|
26
|
-
// Box props
|
|
27
|
-
fontSize: K,
|
|
28
|
-
height: P,
|
|
29
|
-
lineHeight: U
|
|
30
|
-
} = n, [ee, I] = F(n.value), [d, v] = F(!1), r = i(!1), u = i(n.value), c = i(0), E = i(x), y = i(null), T = i(null), p = i(null);
|
|
31
|
-
J(() => {
|
|
32
|
-
n.value !== u.current && (u.current = n.value, I(n.value));
|
|
33
|
-
}, [n.value]);
|
|
34
|
-
function j(e) {
|
|
35
|
-
d || (document.body.style["pointer-events"] = "none", E.current = A(e.nativeEvent, S), c.current = n.value, r.current = !0, document.addEventListener("mouseup", _), p.current = setTimeout(() => {
|
|
36
|
-
w(e.nativeEvent);
|
|
37
|
-
}, 100));
|
|
38
|
-
}
|
|
39
|
-
function w(e) {
|
|
40
|
-
if (r.current)
|
|
41
|
-
document.addEventListener("mousemove", h), T.current = setInterval(() => {
|
|
42
|
-
r.current && (l == null || l(e, n.value));
|
|
43
|
-
}, k);
|
|
44
|
-
else if (v(!0), y.current) {
|
|
45
|
-
const t = y.current;
|
|
46
|
-
t.value = c.current.toString(), setTimeout(() => {
|
|
47
|
-
t.focus(), t.select();
|
|
48
|
-
}, 10);
|
|
49
|
-
}
|
|
50
|
-
p.current && clearTimeout(p.current);
|
|
51
|
-
}
|
|
52
|
-
function h(e) {
|
|
53
|
-
const t = A(e, S), H = t - E.current, X = Number.isFinite(o) ? o % s : 0;
|
|
54
|
-
c.current = b(
|
|
55
|
-
c.current + H * s / O,
|
|
56
|
-
o - s,
|
|
57
|
-
N + s
|
|
58
|
-
);
|
|
59
|
-
const R = b(
|
|
60
|
-
c.current - c.current % s + X,
|
|
61
|
-
o,
|
|
62
|
-
N
|
|
63
|
-
);
|
|
64
|
-
u.current = R, I(R), E.current = t;
|
|
65
|
-
}
|
|
66
|
-
function _(e) {
|
|
67
|
-
document.body.style["pointer-events"] = "auto", T.current && clearInterval(T.current), E.current = x, document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", _), r.current && (a == null || a(e, u.current), l == null || l(e, u.current), r.current = !1);
|
|
68
|
-
}
|
|
69
|
-
function z(e) {
|
|
70
|
-
(e.key === Q.Enter || W(e.key)) && v(!1);
|
|
71
|
-
}
|
|
72
|
-
function B(e) {
|
|
73
|
-
let t = Number.parseFloat(e.currentTarget.value);
|
|
74
|
-
if (Y || (t = b(t, o, N)), Number.isNaN(t)) {
|
|
75
|
-
v(!1);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
c.current = t, u.current = t, I(t), a == null || a(e.nativeEvent, t), d && v(!1);
|
|
79
|
-
}
|
|
80
|
-
let f = n.value;
|
|
81
|
-
r.current && (f = u.current);
|
|
82
|
-
const G = /* @__PURE__ */ $(q, { children: [
|
|
83
|
-
m && !r.current ? /* @__PURE__ */ D(Z, { value: f, format: g }) : g ? g(f) : f,
|
|
84
|
-
V ? ` ${V}` : ""
|
|
85
|
-
] }), M = /* @__PURE__ */ D(
|
|
86
|
-
"input",
|
|
87
|
-
{
|
|
88
|
-
ref: y,
|
|
89
|
-
className: "NumberInput__input",
|
|
90
|
-
style: {
|
|
91
|
-
display: d ? void 0 : "none",
|
|
92
|
-
height: P,
|
|
93
|
-
lineHeight: U,
|
|
94
|
-
fontSize: K
|
|
95
|
-
},
|
|
96
|
-
onBlur: B,
|
|
97
|
-
onKeyDown: z
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
return L({
|
|
101
|
-
displayElement: G,
|
|
102
|
-
displayValue: f,
|
|
103
|
-
dragging: r.current,
|
|
104
|
-
editing: d,
|
|
105
|
-
handleDragStart: j,
|
|
106
|
-
inputElement: M
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
export {
|
|
110
|
-
ie as DraggableControl
|
|
111
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as r from"react";import*as t from"../common/keys.js";import*as n from"../common/math.js";import*as u from"./AnimatedNumber.js";function c(e,r){return e.screenX*r[0]+e.screenY*r[1]}function o(o){let{animated:a,children:s,dragMatrix:m=[1,0],format:i,maxValue:l=Number.POSITIVE_INFINITY,minValue:v=Number.NEGATIVE_INFINITY,onChange:f,onDrag:d,step:p=1,stepPixelSize:N=1,unclamped:E,unit:I,updateRate:b=400,fontSize:g,height:y,lineHeight:T}=o,[j,R]=(0,r.useState)(o.value),[h,S]=(0,r.useState)(!1),x=(0,r.useRef)(!1),F=(0,r.useRef)(o.value),L=(0,r.useRef)(0),Y=(0,r.useRef)(-1),_=(0,r.useRef)(null),k=(0,r.useRef)(null),A=(0,r.useRef)(null);function D(e){let r=c(e,m),t=r-Y.current,u=Number.isFinite(v)?v%p:0;L.current=(0,n.clamp)(L.current+t*p/N,v-p,l+p);let o=(0,n.clamp)(L.current-L.current%p+u,v,l);F.current=o,R(o),Y.current=r}function K(e){document.body.style["pointer-events"]="auto",k.current&&clearInterval(k.current),Y.current=-1,document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",K),x.current&&(f?.(e,F.current),d?.(e,F.current),x.current=!1)}(0,r.useEffect)(()=>{o.value!==F.current&&(F.current=o.value,R(o.value))},[o.value]);let V=o.value;x.current&&(V=F.current);let w=(0,e.jsxs)(e.Fragment,{children:[a&&!x.current?(0,e.jsx)(u.AnimatedNumber,{value:V,format:i}):i?i(V):V,I?` ${I}`:""]}),z=(0,e.jsx)("input",{ref:_,className:"NumberInput__input",style:{display:h?void 0:"none",height:y,lineHeight:T,fontSize:g},onBlur:function(e){let r=Number.parseFloat(e.currentTarget.value);if(E||(r=(0,n.clamp)(r,v,l)),Number.isNaN(r))return void S(!1);L.current=r,F.current=r,R(r),f?.(e.nativeEvent,r),h&&S(!1)},onKeyDown:function(e){(e.key===t.KEY.Enter||(0,t.isEscape)(e.key))&&S(!1)}});return s({displayElement:w,displayValue:V,dragging:x.current,editing:h,handleDragStart:function(e){h||(document.body.style["pointer-events"]="none",Y.current=c(e.nativeEvent,m),L.current=o.value,x.current=!0,document.addEventListener("mouseup",K),A.current=setTimeout(()=>{var r=e.nativeEvent;if(x.current)document.addEventListener("mousemove",D),k.current=setInterval(()=>{x.current&&d?.(r,o.value)},b);else if(S(!0),_.current){let e=_.current;e.value=L.current.toString(),setTimeout(()=>{e.focus(),e.select()},10)}A.current&&clearTimeout(A.current)},100))},inputElement:z})}export{o as DraggableControl};
|
|
@@ -1,165 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as S, useRef as V } from "react";
|
|
3
|
-
import { KEY as O } from "../common/keys.js";
|
|
4
|
-
import { classes as D } from "../common/react.js";
|
|
5
|
-
import { unit as C } from "../common/ui.js";
|
|
6
|
-
import { Button as E } from "./Button.js";
|
|
7
|
-
import { Floating as Y } from "./Floating.js";
|
|
8
|
-
import { Icon as T } from "./Icon.js";
|
|
9
|
-
const q = -1;
|
|
10
|
-
function f(d) {
|
|
11
|
-
return typeof d == "string" ? d : d.value;
|
|
12
|
-
}
|
|
13
|
-
function X(d) {
|
|
14
|
-
const {
|
|
15
|
-
autoScroll: v = !0,
|
|
16
|
-
buttons: k,
|
|
17
|
-
className: B,
|
|
18
|
-
color: K = "default",
|
|
19
|
-
disabled: i,
|
|
20
|
-
displayText: R,
|
|
21
|
-
icon: x,
|
|
22
|
-
iconRotation: j,
|
|
23
|
-
iconSpin: A,
|
|
24
|
-
iconOnly: h,
|
|
25
|
-
menuWidth: _,
|
|
26
|
-
noChevron: F,
|
|
27
|
-
onClick: a,
|
|
28
|
-
onSelected: t,
|
|
29
|
-
options: l = [],
|
|
30
|
-
over: y,
|
|
31
|
-
placeholder: W = "Select...",
|
|
32
|
-
selected: m,
|
|
33
|
-
width: $ = 15
|
|
34
|
-
} = d, [p, P] = S(!1), N = V(null), s = l.findIndex((e) => f(e) === m) || 0;
|
|
35
|
-
function g(e) {
|
|
36
|
-
let n = e;
|
|
37
|
-
e < s ? n = e < 2 ? 0 : e - 2 : n = e > l.length - 3 ? l.length - 1 : e - 2;
|
|
38
|
-
const o = N.current, c = o == null ? void 0 : o.children[n];
|
|
39
|
-
o && c && (o.scrollTop = c.offsetTop);
|
|
40
|
-
}
|
|
41
|
-
function b(e) {
|
|
42
|
-
if (l.length < 1 || i)
|
|
43
|
-
return;
|
|
44
|
-
const n = 0, o = l.length - 1;
|
|
45
|
-
let c;
|
|
46
|
-
s < 0 ? c = e === "next" ? o : n : e === "next" ? c = s === o ? n : s + 1 : c = s === n ? o : s - 1, p && v && g(c), t == null || t(f(l[c]));
|
|
47
|
-
}
|
|
48
|
-
let w = y ? "top" : "bottom";
|
|
49
|
-
return h && (w = `${w}-start`), /* @__PURE__ */ u("div", { className: "Dropdown", children: [
|
|
50
|
-
/* @__PURE__ */ r(
|
|
51
|
-
Y,
|
|
52
|
-
{
|
|
53
|
-
allowedOutsideClasses: ".Dropdown__button",
|
|
54
|
-
closeAfterInteract: !0,
|
|
55
|
-
contentAutoWidth: !_,
|
|
56
|
-
contentClasses: "Dropdown__menu--wrapper",
|
|
57
|
-
contentStyles: { width: _ ? C(_) : void 0 },
|
|
58
|
-
disabled: i,
|
|
59
|
-
onOpenChange: P,
|
|
60
|
-
placement: w,
|
|
61
|
-
content: /* @__PURE__ */ r("div", { ref: N, className: "Dropdown__menu", children: l.length === 0 ? /* @__PURE__ */ r("div", { className: "Dropdown__menu--entry", children: "No options" }) : l.map((e) => {
|
|
62
|
-
const n = f(e);
|
|
63
|
-
return /* @__PURE__ */ r(
|
|
64
|
-
"div",
|
|
65
|
-
{
|
|
66
|
-
className: D([
|
|
67
|
-
"Dropdown__menu--entry",
|
|
68
|
-
m === n && "selected"
|
|
69
|
-
]),
|
|
70
|
-
onClick: () => {
|
|
71
|
-
t == null || t(n);
|
|
72
|
-
},
|
|
73
|
-
onKeyDown: (o) => {
|
|
74
|
-
o.key === O.Enter && (t == null || t(n));
|
|
75
|
-
},
|
|
76
|
-
children: typeof e == "string" ? e : e.displayText
|
|
77
|
-
},
|
|
78
|
-
n
|
|
79
|
-
);
|
|
80
|
-
}) }),
|
|
81
|
-
onMounted: () => {
|
|
82
|
-
p && v && s !== q && g(s);
|
|
83
|
-
},
|
|
84
|
-
children: /* @__PURE__ */ u(
|
|
85
|
-
"div",
|
|
86
|
-
{
|
|
87
|
-
className: D([
|
|
88
|
-
"Dropdown__control",
|
|
89
|
-
`Button--color--${K}`,
|
|
90
|
-
i && "Button--disabled",
|
|
91
|
-
h && "Dropdown__control--icon-only",
|
|
92
|
-
B
|
|
93
|
-
]),
|
|
94
|
-
style: { width: C($) },
|
|
95
|
-
onClick: (e) => {
|
|
96
|
-
i && !p || a == null || a(e);
|
|
97
|
-
},
|
|
98
|
-
onKeyDown: (e) => {
|
|
99
|
-
e.key === O.Enter && !i && (a == null || a(e));
|
|
100
|
-
},
|
|
101
|
-
children: [
|
|
102
|
-
x && /* @__PURE__ */ r(
|
|
103
|
-
T,
|
|
104
|
-
{
|
|
105
|
-
className: "Dropdown__icon",
|
|
106
|
-
name: x,
|
|
107
|
-
rotation: j,
|
|
108
|
-
spin: A
|
|
109
|
-
}
|
|
110
|
-
),
|
|
111
|
-
!h && /* @__PURE__ */ u(I, { children: [
|
|
112
|
-
/* @__PURE__ */ r("span", { className: "Dropdown__selected-text", children: R || m && f(m) || W }),
|
|
113
|
-
!F && /* @__PURE__ */ r(
|
|
114
|
-
T,
|
|
115
|
-
{
|
|
116
|
-
className: D([
|
|
117
|
-
"Dropdown__icon",
|
|
118
|
-
"Dropdown__icon--arrow",
|
|
119
|
-
y && "over",
|
|
120
|
-
p && "open"
|
|
121
|
-
]),
|
|
122
|
-
name: "chevron-down"
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
] })
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
),
|
|
131
|
-
k && /* @__PURE__ */ u(I, { children: [
|
|
132
|
-
/* @__PURE__ */ r(
|
|
133
|
-
E,
|
|
134
|
-
{
|
|
135
|
-
className: "Dropdown__button",
|
|
136
|
-
disabled: i,
|
|
137
|
-
icon: "chevron-left",
|
|
138
|
-
onClick: () => {
|
|
139
|
-
b(
|
|
140
|
-
"previous"
|
|
141
|
-
/* Previous */
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
),
|
|
146
|
-
/* @__PURE__ */ r(
|
|
147
|
-
E,
|
|
148
|
-
{
|
|
149
|
-
className: "Dropdown__button",
|
|
150
|
-
disabled: i,
|
|
151
|
-
icon: "chevron-right",
|
|
152
|
-
onClick: () => {
|
|
153
|
-
b(
|
|
154
|
-
"next"
|
|
155
|
-
/* Next */
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
)
|
|
160
|
-
] })
|
|
161
|
-
] });
|
|
162
|
-
}
|
|
163
|
-
export {
|
|
164
|
-
X as Dropdown
|
|
165
|
-
};
|
|
1
|
+
import*as o from"react/jsx-runtime";import*as n from"react";import*as e from"../common/keys.js";import*as t from"../common/react.js";import*as s from"../common/ui.js";import*as r from"./Button.js";import*as l from"./Floating.js";import*as c from"./Icon.js";function i(o){return"string"==typeof o?o:o.value}function a(a){let{autoScroll:d=!0,buttons:m,className:p,color:u="default",disabled:_,displayText:f,icon:h,iconRotation:w,iconSpin:x,iconOnly:j,menuWidth:D,noChevron:g,onClick:y,onSelected:v,options:N=[],over:b,placeholder:k="Select...",selected:C,width:B=15}=a,[I,E]=(0,n.useState)(!1),F=(0,n.useRef)(null),K=N.findIndex(o=>i(o)===C)||0;function S(o){let n=o;n=o<K?o<2?0:o-2:o>N.length-3?N.length-1:o-2;let e=F.current,t=e?.children[n];e&&t&&(e.scrollTop=t.offsetTop)}function T(o){let n;if(N.length<1||_)return;let e=N.length-1;n=K<0?"next"===o?e:0:"next"===o?K===e?0:K+1:0===K?e:K-1,I&&d&&S(n),v?.(i(N[n]))}let A=b?"top":"bottom";return j&&(A=`${A}-start`),(0,o.jsxs)("div",{className:"Dropdown",children:[(0,o.jsx)(l.Floating,{allowedOutsideClasses:".Dropdown__button",closeAfterInteract:!0,contentAutoWidth:!D,contentClasses:"Dropdown__menu--wrapper",contentStyles:{width:D?(0,s.unit)(D):void 0},disabled:_,onOpenChange:E,placement:A,content:(0,o.jsx)("div",{ref:F,className:"Dropdown__menu",children:0===N.length?(0,o.jsx)("div",{className:"Dropdown__menu--entry",children:"No options"}):N.map(n=>{let s=i(n);return(0,o.jsx)("div",{className:(0,t.classes)(["Dropdown__menu--entry",C===s&&"selected"]),onClick:()=>{v?.(s)},onKeyDown:o=>{o.key===e.KEY.Enter&&v?.(s)},children:"string"==typeof n?n:n.displayText},s)})}),onMounted:()=>{I&&d&&-1!==K&&S(K)},children:(0,o.jsxs)("div",{className:(0,t.classes)(["Dropdown__control",`Button--color--${u}`,_&&"Button--disabled",j&&"Dropdown__control--icon-only",p]),style:{width:(0,s.unit)(B)},onClick:o=>{(!_||I)&&y?.(o)},onKeyDown:o=>{o.key!==e.KEY.Enter||_||y?.(o)},children:[h&&(0,o.jsx)(c.Icon,{className:"Dropdown__icon",name:h,rotation:w,spin:x}),!j&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"Dropdown__selected-text",children:f||C&&i(C)||k}),!g&&(0,o.jsx)(c.Icon,{className:(0,t.classes)(["Dropdown__icon","Dropdown__icon--arrow",b&&"over",I&&"open"]),name:"chevron-down"})]})]})}),m&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r.Button,{className:"Dropdown__button",disabled:_,icon:"chevron-left",onClick:()=>{T("previous")}}),(0,o.jsx)(r.Button,{className:"Dropdown__button",disabled:_,icon:"chevron-right",onClick:()=>{T("next")}})]})]})}export{a as Dropdown};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, HTMLAttributes, PropsWithChildren } from 'react';
|
|
1
|
+
import { Component, type HTMLAttributes, type PropsWithChildren } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
acceptableDifference?: number;
|
|
4
4
|
maxFontSize: number;
|
|
@@ -9,7 +9,7 @@ type State = {
|
|
|
9
9
|
fontSize: number;
|
|
10
10
|
};
|
|
11
11
|
export declare class FitText extends Component<Props, State> {
|
|
12
|
-
ref: import(
|
|
12
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
13
13
|
state: State;
|
|
14
14
|
constructor(props: Props);
|
|
15
15
|
componentDidUpdate(prevProps: any): void;
|
|
@@ -1,63 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var c = (i, t, e) => t in i ? d(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
-
var o = (i, t, e) => c(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
-
import { Component as l, createRef as m } from "react";
|
|
6
|
-
const z = 5;
|
|
7
|
-
class S extends l {
|
|
8
|
-
constructor(e) {
|
|
9
|
-
super(e);
|
|
10
|
-
o(this, "ref", m());
|
|
11
|
-
o(this, "state", {
|
|
12
|
-
fontSize: 0
|
|
13
|
-
});
|
|
14
|
-
this.resize = this.resize.bind(this), window.addEventListener("resize", this.resize);
|
|
15
|
-
}
|
|
16
|
-
componentDidUpdate(e) {
|
|
17
|
-
e.children !== this.props.children && this.resize();
|
|
18
|
-
}
|
|
19
|
-
componentWillUnmount() {
|
|
20
|
-
window.removeEventListener("resize", this.resize);
|
|
21
|
-
}
|
|
22
|
-
resize() {
|
|
23
|
-
const e = this.ref.current;
|
|
24
|
-
if (!e)
|
|
25
|
-
return;
|
|
26
|
-
const f = this.props.maxWidth;
|
|
27
|
-
let s = 0, r = this.props.maxFontSize;
|
|
28
|
-
for (let p = 0; p < 10; p++) {
|
|
29
|
-
const n = Math.round((s + r) / 2);
|
|
30
|
-
e.style.fontSize = `${n}px`;
|
|
31
|
-
const h = e.offsetWidth - f;
|
|
32
|
-
if (h > 0)
|
|
33
|
-
r = n;
|
|
34
|
-
else if (h < (this.props.acceptableDifference ?? z))
|
|
35
|
-
s = n;
|
|
36
|
-
else
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
this.setState({
|
|
40
|
-
fontSize: Math.round((s + r) / 2)
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
componentDidMount() {
|
|
44
|
-
this.resize();
|
|
45
|
-
}
|
|
46
|
-
render() {
|
|
47
|
-
var e;
|
|
48
|
-
return /* @__PURE__ */ a(
|
|
49
|
-
"span",
|
|
50
|
-
{
|
|
51
|
-
ref: this.ref,
|
|
52
|
-
style: {
|
|
53
|
-
fontSize: `${this.state.fontSize}px`,
|
|
54
|
-
...typeof ((e = this.props.native) == null ? void 0 : e.style) == "object" ? this.props.native.style : {}
|
|
55
|
-
},
|
|
56
|
-
children: this.props.children
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
S as FitText
|
|
63
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";class i extends t.Component{ref=(0,t.createRef)();state={fontSize:0};constructor(e){super(e),this.resize=this.resize.bind(this),window.addEventListener("resize",this.resize)}componentDidUpdate(e){e.children!==this.props.children&&this.resize()}componentWillUnmount(){window.removeEventListener("resize",this.resize)}resize(){let e=this.ref.current;if(!e)return;let t=this.props.maxWidth,i=0,s=this.props.maxFontSize;for(let r=0;r<10;r++){let r=Math.round((i+s)/2);e.style.fontSize=`${r}px`;let n=e.offsetWidth-t;if(n>0)s=r;else if(n<(this.props.acceptableDifference??5))i=r;else break}this.setState({fontSize:Math.round((i+s)/2)})}componentDidMount(){this.resize()}render(){return(0,e.jsx)("span",{ref:this.ref,style:{fontSize:`${this.state.fontSize}px`,..."object"==typeof this.props.native?.style?this.props.native.style:{}},children:this.props.children})}}export{i as FitText};
|
package/dist/components/Flex.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { classes as r } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "../common/ui.js";
|
|
4
|
-
function p(e) {
|
|
5
|
-
return r([
|
|
6
|
-
"Flex",
|
|
7
|
-
e.inlineFlex && "Flex--inline",
|
|
8
|
-
m(e)
|
|
9
|
-
]);
|
|
10
|
-
}
|
|
11
|
-
function d(e) {
|
|
12
|
-
const { direction: s, wrap: t, align: i, justify: n, ...o } = e;
|
|
13
|
-
return a({
|
|
14
|
-
style: {
|
|
15
|
-
...o.style,
|
|
16
|
-
flexDirection: s,
|
|
17
|
-
flexWrap: t === !0 ? "wrap" : t,
|
|
18
|
-
alignItems: i,
|
|
19
|
-
justifyContent: n
|
|
20
|
-
},
|
|
21
|
-
...o
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function F(e) {
|
|
25
|
-
const { className: s, ...t } = e;
|
|
26
|
-
return /* @__PURE__ */ l(
|
|
27
|
-
"div",
|
|
28
|
-
{
|
|
29
|
-
className: r([s, p(t)]),
|
|
30
|
-
...d(t)
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const N = (e) => r(["Flex__item", m(e)]);
|
|
35
|
-
function v(e) {
|
|
36
|
-
const { style: s, grow: t, order: i, shrink: n, basis: o, align: c, ...u } = e, x = o ?? // IE11: Set basis to specified width if it's known, which fixes certain
|
|
37
|
-
// bugs when rendering tables inside the flex.
|
|
38
|
-
e.width ?? // If grow is used, basis should be set to 0 to be consistent with
|
|
39
|
-
// flex css shorthand `flex: 1`.
|
|
40
|
-
(t !== void 0 ? 0 : void 0);
|
|
41
|
-
return a({
|
|
42
|
-
style: {
|
|
43
|
-
...s,
|
|
44
|
-
flexGrow: t !== void 0 && Number(t),
|
|
45
|
-
flexShrink: n !== void 0 && Number(n),
|
|
46
|
-
flexBasis: f(x),
|
|
47
|
-
order: i,
|
|
48
|
-
alignSelf: c
|
|
49
|
-
},
|
|
50
|
-
...u
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function y(e) {
|
|
54
|
-
const { className: s, ...t } = e;
|
|
55
|
-
return /* @__PURE__ */ l(
|
|
56
|
-
"div",
|
|
57
|
-
{
|
|
58
|
-
className: r([s, N(e)]),
|
|
59
|
-
...v(t)
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
F.Item = y;
|
|
64
|
-
export {
|
|
65
|
-
F as Flex,
|
|
66
|
-
p as computeFlexClassName,
|
|
67
|
-
N as computeFlexItemClassName,
|
|
68
|
-
v as computeFlexItemProps,
|
|
69
|
-
d as computeFlexProps
|
|
70
|
-
};
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"../common/react.js";import*as s from"../common/ui.js";function o(e){return(0,t.classes)(["Flex",e.inlineFlex&&"Flex--inline",(0,s.computeBoxClassName)(e)])}function l(e){let{direction:t,wrap:o,align:l,justify:r,...m}=e;return(0,s.computeBoxProps)({style:{...m.style,flexDirection:t,flexWrap:!0===o?"wrap":o,alignItems:l,justifyContent:r},...m})}function r(s){let{className:r,...m}=s;return(0,e.jsx)("div",{className:(0,t.classes)([r,o(m)]),...l(m)})}let m=e=>(0,t.classes)(["Flex__item",(0,s.computeBoxClassName)(e)]);function i(e){let{style:t,grow:o,order:l,shrink:r,basis:m,align:i,...n}=e,a=m??e.width??(void 0!==o?0:void 0);return(0,s.computeBoxProps)({style:{...t,flexGrow:void 0!==o&&Number(o),flexShrink:void 0!==r&&Number(r),flexBasis:(0,s.unit)(a),order:l,alignSelf:i},...n})}r.Item=function(s){let{className:o,...l}=s;return(0,e.jsx)("div",{className:(0,t.classes)([o,m(s)]),...i(l)})};export{r as Flex,o as computeFlexClassName,m as computeFlexItemClassName,i as computeFlexItemProps,l as computeFlexProps};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Placement } from '@floating-ui/react';
|
|
2
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { BooleanLike } from '../common/react';
|
|
1
|
+
import { type Placement } from '@floating-ui/react';
|
|
2
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
3
|
+
import { type BooleanLike } from '../common/react';
|
|
4
4
|
type Props = {
|
|
5
5
|
/** Interacting with this element will open the floating element. */
|
|
6
6
|
children: ReactNode;
|