tgui-core 1.3.2 → 1.4.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/ui.d.ts +113 -0
- package/dist/common/ui.js +137 -0
- package/dist/components/Box.d.ts +75 -63
- package/dist/components/Box.js +13 -127
- package/dist/components/Button.js +2 -1
- package/dist/components/ByondUi.js +1 -1
- package/dist/components/ColorBox.js +1 -1
- package/dist/components/Dropdown.js +1 -1
- package/dist/components/Flex.js +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/Icon.js +2 -2
- package/dist/components/Image.js +22 -21
- package/dist/components/ImageButton.js +1 -1
- package/dist/components/InfinitePlane.js +1 -1
- package/dist/components/Input.d.ts +6 -3
- package/dist/components/Input.js +60 -55
- package/dist/components/KeyListener.d.ts +2 -8
- package/dist/components/KeyListener.js +11 -19
- package/dist/components/Knob.js +1 -1
- package/dist/components/LabeledList.js +16 -15
- package/dist/components/Modal.js +1 -1
- package/dist/components/ProgressBar.js +1 -1
- package/dist/components/RoundGauge.d.ts +2 -1
- package/dist/components/RoundGauge.js +19 -18
- package/dist/components/Section.d.ts +43 -27
- package/dist/components/Section.js +64 -66
- package/dist/components/Slider.js +1 -1
- package/dist/components/Stack.js +1 -1
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/components/TextArea.d.ts +2 -1
- package/package.json +3 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BoxProps } from '../components/Box';
|
|
2
|
+
import { BooleanLike } from './react';
|
|
3
|
+
type UnitMapper = (value: unknown) => string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Coverts our rem-like spacing unit into a CSS unit.
|
|
6
|
+
*/
|
|
7
|
+
export declare const unit: UnitMapper;
|
|
8
|
+
/**
|
|
9
|
+
* Same as `unit`, but half the size for integers numbers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const halfUnit: UnitMapper;
|
|
12
|
+
export type StringStyleMap = {
|
|
13
|
+
/** Align text inside the box. */
|
|
14
|
+
align: string | BooleanLike;
|
|
15
|
+
/** A direct mapping to `position` CSS property. */
|
|
16
|
+
position: string | BooleanLike;
|
|
17
|
+
/** Vertical align property. */
|
|
18
|
+
verticalAlign: string | BooleanLike;
|
|
19
|
+
/** Sets background color. */
|
|
20
|
+
backgroundColor: string | BooleanLike;
|
|
21
|
+
/** Applies an atomic `color-<name>` class to the element. */
|
|
22
|
+
color: string | BooleanLike;
|
|
23
|
+
/** Opacity, from 0 to 1. */
|
|
24
|
+
opacity: string | BooleanLike;
|
|
25
|
+
/** Sets text color. */
|
|
26
|
+
textColor: string | BooleanLike;
|
|
27
|
+
/** Margin on all sides. */
|
|
28
|
+
m: string | BooleanLike;
|
|
29
|
+
/** Bottom margin. */
|
|
30
|
+
mb: string | BooleanLike;
|
|
31
|
+
/** Left margin. */
|
|
32
|
+
ml: string | BooleanLike;
|
|
33
|
+
/** Right margin. */
|
|
34
|
+
mr: string | BooleanLike;
|
|
35
|
+
/** Top margin. */
|
|
36
|
+
mt: string | BooleanLike;
|
|
37
|
+
/** Horizontal margin. */
|
|
38
|
+
mx: string | BooleanLike;
|
|
39
|
+
/** Vertical margin. */
|
|
40
|
+
my: string | BooleanLike;
|
|
41
|
+
/** Bottom margin. */
|
|
42
|
+
bottom: string | BooleanLike;
|
|
43
|
+
/** Left margin. */
|
|
44
|
+
left: string | BooleanLike;
|
|
45
|
+
/** Right margin. */
|
|
46
|
+
right: string | BooleanLike;
|
|
47
|
+
/** Top margin. */
|
|
48
|
+
top: string | BooleanLike;
|
|
49
|
+
/** Overflow property. */
|
|
50
|
+
overflow: string | BooleanLike;
|
|
51
|
+
/** Overflow-X property. */
|
|
52
|
+
overflowX: string | BooleanLike;
|
|
53
|
+
/** Overflow-Y property. */
|
|
54
|
+
overflowY: string | BooleanLike;
|
|
55
|
+
/** Padding on all sides. */
|
|
56
|
+
p: string | BooleanLike;
|
|
57
|
+
/** Bottom padding. */
|
|
58
|
+
pb: string | BooleanLike;
|
|
59
|
+
/** Left padding. */
|
|
60
|
+
pl: string | BooleanLike;
|
|
61
|
+
/** Right padding. */
|
|
62
|
+
pr: string | BooleanLike;
|
|
63
|
+
/** Top padding. */
|
|
64
|
+
pt: string | BooleanLike;
|
|
65
|
+
/** Horizontal padding. */
|
|
66
|
+
px: string | BooleanLike;
|
|
67
|
+
/** Vertical padding. */
|
|
68
|
+
py: string | BooleanLike;
|
|
69
|
+
/** Box height. */
|
|
70
|
+
height: string | BooleanLike;
|
|
71
|
+
/** Box maximum height. */
|
|
72
|
+
maxHeight: string | BooleanLike;
|
|
73
|
+
/** Box maximum width. */
|
|
74
|
+
maxWidth: string | BooleanLike;
|
|
75
|
+
/** Box minimum height. */
|
|
76
|
+
minHeight: string | BooleanLike;
|
|
77
|
+
/** Box minimum width. */
|
|
78
|
+
minWidth: string | BooleanLike;
|
|
79
|
+
/** Box width. */
|
|
80
|
+
width: string | BooleanLike;
|
|
81
|
+
/** Font family. */
|
|
82
|
+
fontFamily: string | BooleanLike;
|
|
83
|
+
/** Font size. */
|
|
84
|
+
fontSize: string | BooleanLike;
|
|
85
|
+
/** Font weight. */
|
|
86
|
+
fontWeight: string | BooleanLike;
|
|
87
|
+
/** Directly affects the height of text lines. Useful for adjusting button height. */
|
|
88
|
+
lineHeight: string | BooleanLike;
|
|
89
|
+
/** Align text inside the box. */
|
|
90
|
+
textAlign: string | BooleanLike;
|
|
91
|
+
};
|
|
92
|
+
export declare const stringStyleMap: Record<keyof StringStyleMap, any>;
|
|
93
|
+
export type BooleanStyleMap = {
|
|
94
|
+
/** Make text bold. */
|
|
95
|
+
bold: boolean;
|
|
96
|
+
/** Fill positioned parent. */
|
|
97
|
+
fillPositionedParent: boolean;
|
|
98
|
+
/** Forces the `Box` to appear as an `inline-block`. */
|
|
99
|
+
inline: boolean;
|
|
100
|
+
/** Make text italic. */
|
|
101
|
+
italic: boolean;
|
|
102
|
+
/** Stops text from wrapping. */
|
|
103
|
+
nowrap: boolean;
|
|
104
|
+
/** Preserves line-breaks and spacing in text. */
|
|
105
|
+
preserveWhitespace: boolean;
|
|
106
|
+
};
|
|
107
|
+
export declare const booleanStyleMap: Record<keyof BooleanStyleMap, any>;
|
|
108
|
+
export declare function computeBoxProps(props: any): Record<string, any>;
|
|
109
|
+
export declare function computeBoxClassName(props: BoxProps): string;
|
|
110
|
+
type StyleMap = StringStyleMap & BooleanStyleMap;
|
|
111
|
+
/** Super light implementation of tailwind-like class names. */
|
|
112
|
+
export declare function computeTwClass(input: string | undefined): StyleMap;
|
|
113
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { CSS_COLORS as u } from "./constants.js";
|
|
2
|
+
import { classes as y } from "./react.js";
|
|
3
|
+
const f = (o) => {
|
|
4
|
+
if (typeof o == "string")
|
|
5
|
+
return o.endsWith("px") ? `${Number.parseFloat(o) / 12}rem` : o;
|
|
6
|
+
if (typeof o == "number")
|
|
7
|
+
return `${o}rem`;
|
|
8
|
+
}, p = (o) => {
|
|
9
|
+
if (typeof o == "string")
|
|
10
|
+
return f(o);
|
|
11
|
+
if (typeof o == "number")
|
|
12
|
+
return f(o * 0.5);
|
|
13
|
+
};
|
|
14
|
+
function w(o) {
|
|
15
|
+
return !h(o);
|
|
16
|
+
}
|
|
17
|
+
function h(o) {
|
|
18
|
+
return typeof o == "string" && u.includes(o);
|
|
19
|
+
}
|
|
20
|
+
const c = (o) => (t, i) => {
|
|
21
|
+
(typeof i == "number" || typeof i == "string") && (t[o] = i);
|
|
22
|
+
}, n = (o, t) => (i, e) => {
|
|
23
|
+
(typeof e == "number" || typeof e == "string") && (i[o] = t(e));
|
|
24
|
+
}, l = (o, t) => (i, e) => {
|
|
25
|
+
e && (i[o] = t);
|
|
26
|
+
}, s = (o, t, i) => (e, r) => {
|
|
27
|
+
if (typeof r == "number" || typeof r == "string")
|
|
28
|
+
for (let m = 0; m < i.length; m++)
|
|
29
|
+
e[o + i[m]] = t(r);
|
|
30
|
+
}, a = (o) => (t, i) => {
|
|
31
|
+
w(i) && (t[o] = i);
|
|
32
|
+
}, d = {
|
|
33
|
+
align: c("textAlign"),
|
|
34
|
+
bottom: n("bottom", f),
|
|
35
|
+
fontFamily: c("fontFamily"),
|
|
36
|
+
fontSize: n("fontSize", f),
|
|
37
|
+
fontWeight: c("fontWeight"),
|
|
38
|
+
height: n("height", f),
|
|
39
|
+
left: n("left", f),
|
|
40
|
+
maxHeight: n("maxHeight", f),
|
|
41
|
+
maxWidth: n("maxWidth", f),
|
|
42
|
+
minHeight: n("minHeight", f),
|
|
43
|
+
minWidth: n("minWidth", f),
|
|
44
|
+
opacity: c("opacity"),
|
|
45
|
+
overflow: c("overflow"),
|
|
46
|
+
overflowX: c("overflowX"),
|
|
47
|
+
overflowY: c("overflowY"),
|
|
48
|
+
position: c("position"),
|
|
49
|
+
right: n("right", f),
|
|
50
|
+
textAlign: c("textAlign"),
|
|
51
|
+
top: n("top", f),
|
|
52
|
+
verticalAlign: c("verticalAlign"),
|
|
53
|
+
width: n("width", f),
|
|
54
|
+
lineHeight: (o, t) => {
|
|
55
|
+
typeof t == "number" ? o.lineHeight = t : typeof t == "string" && (o.lineHeight = f(t));
|
|
56
|
+
},
|
|
57
|
+
// Margin
|
|
58
|
+
m: s("margin", p, [
|
|
59
|
+
"Top",
|
|
60
|
+
"Bottom",
|
|
61
|
+
"Left",
|
|
62
|
+
"Right"
|
|
63
|
+
]),
|
|
64
|
+
mb: n("marginBottom", p),
|
|
65
|
+
ml: n("marginLeft", p),
|
|
66
|
+
mr: n("marginRight", p),
|
|
67
|
+
mt: n("marginTop", p),
|
|
68
|
+
mx: s("margin", p, ["Left", "Right"]),
|
|
69
|
+
my: s("margin", p, ["Top", "Bottom"]),
|
|
70
|
+
// Padding
|
|
71
|
+
p: s("padding", p, [
|
|
72
|
+
"Top",
|
|
73
|
+
"Bottom",
|
|
74
|
+
"Left",
|
|
75
|
+
"Right"
|
|
76
|
+
]),
|
|
77
|
+
pb: n("paddingBottom", p),
|
|
78
|
+
pl: n("paddingLeft", p),
|
|
79
|
+
pr: n("paddingRight", p),
|
|
80
|
+
pt: n("paddingTop", p),
|
|
81
|
+
px: s("padding", p, ["Left", "Right"]),
|
|
82
|
+
py: s("padding", p, ["Top", "Bottom"]),
|
|
83
|
+
// Color props
|
|
84
|
+
color: a("color"),
|
|
85
|
+
textColor: a("color"),
|
|
86
|
+
backgroundColor: a("backgroundColor")
|
|
87
|
+
}, b = {
|
|
88
|
+
bold: l("fontWeight", "bold"),
|
|
89
|
+
fillPositionedParent: (o, t) => {
|
|
90
|
+
t && (o.position = "absolute", o.top = 0, o.bottom = 0, o.left = 0, o.right = 0);
|
|
91
|
+
},
|
|
92
|
+
inline: l("display", "inline-block"),
|
|
93
|
+
italic: l("fontStyle", "italic"),
|
|
94
|
+
nowrap: l("whiteSpace", "nowrap"),
|
|
95
|
+
preserveWhitespace: l("whiteSpace", "pre-wrap")
|
|
96
|
+
};
|
|
97
|
+
function T(o) {
|
|
98
|
+
const t = {}, i = {};
|
|
99
|
+
for (const e in o) {
|
|
100
|
+
if (e === "style")
|
|
101
|
+
continue;
|
|
102
|
+
const r = o[e], m = d[e] || b[e];
|
|
103
|
+
m ? m(i, r) : t[e] = r;
|
|
104
|
+
}
|
|
105
|
+
return t.style = { ...i, ...o.style }, t;
|
|
106
|
+
}
|
|
107
|
+
function S(o) {
|
|
108
|
+
const t = o.textColor || o.color, { backgroundColor: i } = o;
|
|
109
|
+
return y([
|
|
110
|
+
h(t) && `color-${t}`,
|
|
111
|
+
h(i) && `color-bg-${i}`
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
function P(o) {
|
|
115
|
+
const t = {};
|
|
116
|
+
if (!o) return t;
|
|
117
|
+
const i = o.split(" ");
|
|
118
|
+
for (const e of i) {
|
|
119
|
+
const [r, m] = e.split("-");
|
|
120
|
+
if (r)
|
|
121
|
+
if (r in d) {
|
|
122
|
+
if (m === "") continue;
|
|
123
|
+
const g = Number(m);
|
|
124
|
+
!Number.isNaN(g) && Number.isFinite(g) ? t[r] = g : t[r] = m;
|
|
125
|
+
} else r in b ? t[r] = !0 : console.warn(`Unknown prop ${r}`);
|
|
126
|
+
}
|
|
127
|
+
return t;
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
b as booleanStyleMap,
|
|
131
|
+
S as computeBoxClassName,
|
|
132
|
+
T as computeBoxProps,
|
|
133
|
+
P as computeTwClass,
|
|
134
|
+
p as halfUnit,
|
|
135
|
+
d as stringStyleMap,
|
|
136
|
+
f as unit
|
|
137
|
+
};
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, KeyboardEventHandler, MouseEventHandler, ReactNode, UIEventHandler } from 'react';
|
|
2
2
|
import { BooleanLike } from '../common/react';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
export type EventHandlers = Partial<{
|
|
3
|
+
import { BooleanStyleMap, StringStyleMap } from '../common/ui';
|
|
4
|
+
type EventHandlers = {
|
|
6
5
|
onClick: MouseEventHandler<HTMLDivElement>;
|
|
7
6
|
onContextMenu: MouseEventHandler<HTMLDivElement>;
|
|
8
7
|
onDoubleClick: MouseEventHandler<HTMLDivElement>;
|
|
@@ -14,78 +13,91 @@ export type EventHandlers = Partial<{
|
|
|
14
13
|
onMouseOver: MouseEventHandler<HTMLDivElement>;
|
|
15
14
|
onMouseUp: MouseEventHandler<HTMLDivElement>;
|
|
16
15
|
onScroll: UIEventHandler<HTMLDivElement>;
|
|
17
|
-
}
|
|
18
|
-
|
|
16
|
+
};
|
|
17
|
+
type InternalProps = {
|
|
18
|
+
/** The component used for the root node. */
|
|
19
19
|
as: string;
|
|
20
|
+
/** The content of the component. */
|
|
20
21
|
children: ReactNode;
|
|
22
|
+
/** Class name to pass into the component. */
|
|
21
23
|
className: string | BooleanLike;
|
|
24
|
+
/** The unique id of the component. */
|
|
22
25
|
id: string;
|
|
26
|
+
/** The inline style of the component. */
|
|
23
27
|
style: CSSProperties;
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* ### tw
|
|
30
|
+
* A shorthand classname syntax based loosely on tailwind.
|
|
31
|
+
*
|
|
32
|
+
* This takes all Box style props with a dash separator for params, e.g.'mb-4' or the prop name alone e.g. 'bold'.
|
|
33
|
+
*
|
|
34
|
+
* It's compatible with regular Box props, even on the same component, but it will take precedence.
|
|
35
|
+
*
|
|
36
|
+
* ### Example:
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Box tw="mb-2 bold fontSize-16px">
|
|
39
|
+
* // Is equivalent to
|
|
40
|
+
* <Box mb={2} bold fontSize="16px">
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* ### Caveats:
|
|
44
|
+
* 1. You can't use this for custom props from other components.
|
|
45
|
+
*
|
|
46
|
+
* 2. There is no type info or safety for this method. Like the old days, it simply won't work if you use it incorrectly.
|
|
47
|
+
*
|
|
48
|
+
* 3. This should be a static string with minimal interpolation. If you need more logic, prefer the props approach.
|
|
49
|
+
*/
|
|
50
|
+
tw: string;
|
|
51
|
+
};
|
|
52
|
+
export type BoxProps = Partial<InternalProps & BooleanStyleMap & StringStyleMap & EventHandlers>;
|
|
25
53
|
type DangerDoNotUse = {
|
|
26
54
|
dangerouslySetInnerHTML?: {
|
|
27
55
|
__html: any;
|
|
28
56
|
};
|
|
29
57
|
};
|
|
30
58
|
/**
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
59
|
+
* # Box
|
|
60
|
+
*
|
|
61
|
+
* The Box component serves as a wrapper component for most of the CSS utility
|
|
62
|
+
* needs. It creates a new DOM element, a `<div>` by default that can be changed
|
|
63
|
+
* with the `as` property. Let's say you want to use a `<span>` instead:
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <Box as="span" m={1}>
|
|
68
|
+
* <Button />
|
|
69
|
+
* </Box>
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* This works great when the changes can be isolated to a new DOM element.
|
|
73
|
+
* For instance, you can change the margin this way.
|
|
74
|
+
*
|
|
75
|
+
* However, sometimes you have to target the underlying DOM element.
|
|
76
|
+
* For instance, you want to change the text color of the button. The Button
|
|
77
|
+
* component defines its own color. CSS inheritance doesn't help.
|
|
78
|
+
*
|
|
79
|
+
* To workaround this problem, the Box children accept a render props function.
|
|
80
|
+
* This way, `Button` can pull out the `className` generated by the `Box`.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <Box color="primary">{(props) => <Button {...props} />}</Box>
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* ## Box Units
|
|
88
|
+
*
|
|
89
|
+
* `Box` units, like width, height and margins can be defined in two ways:
|
|
90
|
+
*
|
|
91
|
+
* - By plain numbers
|
|
92
|
+
* - 1 unit equals `1rem` for width, height and positioning properties.
|
|
93
|
+
* - 1 unit equals `0.5rem` for margins and paddings.
|
|
94
|
+
* - By strings with proper CSS units
|
|
95
|
+
* - For example: `100px`, `2em`, `1rem`, `100%`, etc.
|
|
96
|
+
*
|
|
97
|
+
* If you need more precision, you can always use fractional numbers.
|
|
98
|
+
*
|
|
99
|
+
* Default font size (`1rem`) is equal to `12px`.
|
|
36
100
|
*/
|
|
37
|
-
export declare function halfUnit(value: unknown): string | undefined;
|
|
38
|
-
declare const stringStyleMap: {
|
|
39
|
-
readonly align: (style: any, value: any) => void;
|
|
40
|
-
readonly bottom: (style: any, value: any) => void;
|
|
41
|
-
readonly fontFamily: (style: any, value: any) => void;
|
|
42
|
-
readonly fontSize: (style: any, value: any) => void;
|
|
43
|
-
readonly fontWeight: (style: any, value: any) => void;
|
|
44
|
-
readonly height: (style: any, value: any) => void;
|
|
45
|
-
readonly left: (style: any, value: any) => void;
|
|
46
|
-
readonly maxHeight: (style: any, value: any) => void;
|
|
47
|
-
readonly maxWidth: (style: any, value: any) => void;
|
|
48
|
-
readonly minHeight: (style: any, value: any) => void;
|
|
49
|
-
readonly minWidth: (style: any, value: any) => void;
|
|
50
|
-
readonly opacity: (style: any, value: any) => void;
|
|
51
|
-
readonly overflow: (style: any, value: any) => void;
|
|
52
|
-
readonly overflowX: (style: any, value: any) => void;
|
|
53
|
-
readonly overflowY: (style: any, value: any) => void;
|
|
54
|
-
readonly position: (style: any, value: any) => void;
|
|
55
|
-
readonly right: (style: any, value: any) => void;
|
|
56
|
-
readonly textAlign: (style: any, value: any) => void;
|
|
57
|
-
readonly top: (style: any, value: any) => void;
|
|
58
|
-
readonly verticalAlign: (style: any, value: any) => void;
|
|
59
|
-
readonly width: (style: any, value: any) => void;
|
|
60
|
-
readonly lineHeight: (style: any, value: any) => void;
|
|
61
|
-
readonly m: (style: any, value: any) => void;
|
|
62
|
-
readonly mb: (style: any, value: any) => void;
|
|
63
|
-
readonly ml: (style: any, value: any) => void;
|
|
64
|
-
readonly mr: (style: any, value: any) => void;
|
|
65
|
-
readonly mt: (style: any, value: any) => void;
|
|
66
|
-
readonly mx: (style: any, value: any) => void;
|
|
67
|
-
readonly my: (style: any, value: any) => void;
|
|
68
|
-
readonly p: (style: any, value: any) => void;
|
|
69
|
-
readonly pb: (style: any, value: any) => void;
|
|
70
|
-
readonly pl: (style: any, value: any) => void;
|
|
71
|
-
readonly pr: (style: any, value: any) => void;
|
|
72
|
-
readonly pt: (style: any, value: any) => void;
|
|
73
|
-
readonly px: (style: any, value: any) => void;
|
|
74
|
-
readonly py: (style: any, value: any) => void;
|
|
75
|
-
readonly color: (style: any, value: any) => void;
|
|
76
|
-
readonly textColor: (style: any, value: any) => void;
|
|
77
|
-
readonly backgroundColor: (style: any, value: any) => void;
|
|
78
|
-
};
|
|
79
|
-
declare const booleanStyleMap: {
|
|
80
|
-
readonly bold: (style: any, value: any) => void;
|
|
81
|
-
readonly fillPositionedParent: (style: any, value: any) => void;
|
|
82
|
-
readonly inline: (style: any, value: any) => void;
|
|
83
|
-
readonly italic: (style: any, value: any) => void;
|
|
84
|
-
readonly nowrap: (style: any, value: any) => void;
|
|
85
|
-
readonly preserveWhitespace: (style: any, value: any) => void;
|
|
86
|
-
};
|
|
87
|
-
export declare function computeBoxProps(props: any): Record<string, any>;
|
|
88
|
-
export declare function computeBoxClassName(props: BoxProps): string;
|
|
89
101
|
export declare function Box(props: BoxProps & DangerDoNotUse): import('react').ReactElement<{
|
|
90
102
|
className: string;
|
|
91
103
|
}, string | import('react').JSXElementConstructor<any>>;
|
package/dist/components/Box.js
CHANGED
|
@@ -1,133 +1,19 @@
|
|
|
1
|
-
import { createElement as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function r(o) {
|
|
11
|
-
if (typeof o == "string")
|
|
12
|
-
return p(o);
|
|
13
|
-
if (typeof o == "number")
|
|
14
|
-
return p(o * 0.5);
|
|
15
|
-
}
|
|
16
|
-
function x(o) {
|
|
17
|
-
return !a(o);
|
|
18
|
-
}
|
|
19
|
-
function a(o) {
|
|
20
|
-
return typeof o == "string" && b.includes(o);
|
|
21
|
-
}
|
|
22
|
-
const m = (o) => (t, i) => {
|
|
23
|
-
(typeof i == "number" || typeof i == "string") && (t[o] = i);
|
|
24
|
-
}, n = (o, t) => (i, e) => {
|
|
25
|
-
(typeof e == "number" || typeof e == "string") && (i[o] = t(e));
|
|
26
|
-
}, l = (o, t) => (i, e) => {
|
|
27
|
-
e && (i[o] = t);
|
|
28
|
-
}, g = (o, t, i) => (e, f) => {
|
|
29
|
-
if (typeof f == "number" || typeof f == "string")
|
|
30
|
-
for (let c = 0; c < i.length; c++)
|
|
31
|
-
e[o + i[c]] = t(f);
|
|
32
|
-
}, s = (o) => (t, i) => {
|
|
33
|
-
x(i) && (t[o] = i);
|
|
34
|
-
}, C = {
|
|
35
|
-
align: m("textAlign"),
|
|
36
|
-
bottom: n("bottom", p),
|
|
37
|
-
fontFamily: m("fontFamily"),
|
|
38
|
-
fontSize: n("fontSize", p),
|
|
39
|
-
fontWeight: m("fontWeight"),
|
|
40
|
-
height: n("height", p),
|
|
41
|
-
left: n("left", p),
|
|
42
|
-
maxHeight: n("maxHeight", p),
|
|
43
|
-
maxWidth: n("maxWidth", p),
|
|
44
|
-
minHeight: n("minHeight", p),
|
|
45
|
-
minWidth: n("minWidth", p),
|
|
46
|
-
opacity: m("opacity"),
|
|
47
|
-
overflow: m("overflow"),
|
|
48
|
-
overflowX: m("overflowX"),
|
|
49
|
-
overflowY: m("overflowY"),
|
|
50
|
-
position: m("position"),
|
|
51
|
-
right: n("right", p),
|
|
52
|
-
textAlign: m("textAlign"),
|
|
53
|
-
top: n("top", p),
|
|
54
|
-
verticalAlign: m("verticalAlign"),
|
|
55
|
-
width: n("width", p),
|
|
56
|
-
lineHeight: (o, t) => {
|
|
57
|
-
typeof t == "number" ? o.lineHeight = t : typeof t == "string" && (o.lineHeight = p(t));
|
|
58
|
-
},
|
|
59
|
-
// Margin
|
|
60
|
-
m: g("margin", r, [
|
|
61
|
-
"Top",
|
|
62
|
-
"Bottom",
|
|
63
|
-
"Left",
|
|
64
|
-
"Right"
|
|
65
|
-
]),
|
|
66
|
-
mb: n("marginBottom", r),
|
|
67
|
-
ml: n("marginLeft", r),
|
|
68
|
-
mr: n("marginRight", r),
|
|
69
|
-
mt: n("marginTop", r),
|
|
70
|
-
mx: g("margin", r, ["Left", "Right"]),
|
|
71
|
-
my: g("margin", r, ["Top", "Bottom"]),
|
|
72
|
-
// Padding
|
|
73
|
-
p: g("padding", r, [
|
|
74
|
-
"Top",
|
|
75
|
-
"Bottom",
|
|
76
|
-
"Left",
|
|
77
|
-
"Right"
|
|
78
|
-
]),
|
|
79
|
-
pb: n("paddingBottom", r),
|
|
80
|
-
pl: n("paddingLeft", r),
|
|
81
|
-
pr: n("paddingRight", r),
|
|
82
|
-
pt: n("paddingTop", r),
|
|
83
|
-
px: g("padding", r, ["Left", "Right"]),
|
|
84
|
-
py: g("padding", r, ["Top", "Bottom"]),
|
|
85
|
-
// Color props
|
|
86
|
-
color: s("color"),
|
|
87
|
-
textColor: s("color"),
|
|
88
|
-
backgroundColor: s("backgroundColor")
|
|
89
|
-
}, w = {
|
|
90
|
-
bold: l("fontWeight", "bold"),
|
|
91
|
-
fillPositionedParent: (o, t) => {
|
|
92
|
-
t && (o.position = "absolute", o.top = 0, o.bottom = 0, o.left = 0, o.right = 0);
|
|
93
|
-
},
|
|
94
|
-
inline: l("display", "inline-block"),
|
|
95
|
-
italic: l("fontStyle", "italic"),
|
|
96
|
-
nowrap: l("whiteSpace", "nowrap"),
|
|
97
|
-
preserveWhitespace: l("whiteSpace", "pre-wrap")
|
|
98
|
-
};
|
|
99
|
-
function S(o) {
|
|
100
|
-
const t = {}, i = {};
|
|
101
|
-
for (const e of Object.keys(o)) {
|
|
102
|
-
if (e === "style")
|
|
103
|
-
continue;
|
|
104
|
-
const f = o[e], c = C[e] || w[e];
|
|
105
|
-
c ? c(i, f) : t[e] = f;
|
|
106
|
-
}
|
|
107
|
-
return t.style = { ...i, ...o.style }, t;
|
|
108
|
-
}
|
|
109
|
-
function d(o) {
|
|
110
|
-
const t = o.textColor || o.color, i = o.backgroundColor;
|
|
111
|
-
return u([
|
|
112
|
-
a(t) && `color-${t}`,
|
|
113
|
-
a(i) && `color-bg-${i}`
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
function W(o) {
|
|
117
|
-
const { as: t = "div", className: i, children: e, ...f } = o, c = i ? `${i} ${d(f)}` : d(f), h = S(f);
|
|
118
|
-
return y(
|
|
119
|
-
typeof t == "string" ? t : "div",
|
|
1
|
+
import { createElement as n } from "react";
|
|
2
|
+
import { computeBoxClassName as s, computeBoxProps as l, computeTwClass as u } from "../common/ui.js";
|
|
3
|
+
function x(t) {
|
|
4
|
+
const { as: m = "div", className: e, children: c, tw: r, ...o } = t, a = e ? `${e} ${s(o)}` : s(o), p = l({
|
|
5
|
+
...o,
|
|
6
|
+
...u(r)
|
|
7
|
+
});
|
|
8
|
+
return n(
|
|
9
|
+
m,
|
|
120
10
|
{
|
|
121
|
-
...
|
|
122
|
-
className:
|
|
11
|
+
...p,
|
|
12
|
+
className: a
|
|
123
13
|
},
|
|
124
|
-
|
|
14
|
+
c
|
|
125
15
|
);
|
|
126
16
|
}
|
|
127
17
|
export {
|
|
128
|
-
|
|
129
|
-
d as computeBoxClassName,
|
|
130
|
-
S as computeBoxProps,
|
|
131
|
-
r as halfUnit,
|
|
132
|
-
p as unit
|
|
18
|
+
x as Box
|
|
133
19
|
};
|
|
@@ -2,7 +2,8 @@ import { jsx as i, jsxs as _, Fragment as K } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState as A, createRef as V, useEffect as $, useRef as z } from "react";
|
|
3
3
|
import { KEY as D, isEscape as E } from "../common/keys.js";
|
|
4
4
|
import { classes as F } from "../common/react.js";
|
|
5
|
-
import { computeBoxClassName as j, computeBoxProps as q
|
|
5
|
+
import { computeBoxClassName as j, computeBoxProps as q } from "../common/ui.js";
|
|
6
|
+
import { Box as O } from "./Box.js";
|
|
6
7
|
import { Icon as S } from "./Icon.js";
|
|
7
8
|
import { Tooltip as v } from "./Tooltip.js";
|
|
8
9
|
function x(u) {
|
|
@@ -2,7 +2,7 @@ import { jsx as s } from "react/jsx-runtime";
|
|
|
2
2
|
import { Component as a, createRef as c } from "react";
|
|
3
3
|
import { shallowDiffers as r } from "../common/react.js";
|
|
4
4
|
import { debounce as m } from "../common/timer.js";
|
|
5
|
-
import { computeBoxProps as l } from "
|
|
5
|
+
import { computeBoxProps as l } from "../common/ui.js";
|
|
6
6
|
const o = [];
|
|
7
7
|
function h(t) {
|
|
8
8
|
const n = o.length;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { classes as c } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as s, computeBoxProps as m } from "
|
|
3
|
+
import { computeBoxClassName as s, computeBoxProps as m } from "../common/ui.js";
|
|
4
4
|
function d(r) {
|
|
5
5
|
const { content: l, children: a, className: e, ...o } = r;
|
|
6
6
|
return o.color = l ? null : "default", o.backgroundColor = r.color || "default", /* @__PURE__ */ t(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as l, jsxs as p, Fragment as W } from "react/jsx-runtime";
|
|
2
2
|
import { useState as F, useRef as L, useEffect as S } from "react";
|
|
3
3
|
import { classes as N } from "../common/react.js";
|
|
4
|
-
import { unit as $ } from "
|
|
4
|
+
import { unit as $ } from "../common/ui.js";
|
|
5
5
|
import { Button as D } from "./Button.js";
|
|
6
6
|
import { Icon as b } from "./Icon.js";
|
|
7
7
|
import { Popper as q } from "./Popper.js";
|
package/dist/components/Flex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { classes as r } from "../common/react.js";
|
|
3
|
-
import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "
|
|
3
|
+
import { computeBoxClassName as m, computeBoxProps as a, unit as f } from "../common/ui.js";
|
|
4
4
|
function p(e) {
|
|
5
5
|
return r([
|
|
6
6
|
"Flex",
|
|
@@ -15,7 +15,7 @@ type Props = {
|
|
|
15
15
|
spin: BooleanLike;
|
|
16
16
|
/** Custom CSS. */
|
|
17
17
|
style: CSSProperties;
|
|
18
|
-
}> & BoxProps
|
|
18
|
+
}> & Omit<BoxProps, 'children'>;
|
|
19
19
|
export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export declare namespace Icon {
|
|
21
21
|
var Stack: typeof IconStack;
|
package/dist/components/Icon.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { classes as l } from "../common/react.js";
|
|
3
|
-
import { computeBoxProps as p, computeBoxClassName as u } from "
|
|
3
|
+
import { computeBoxProps as p, computeBoxClassName as u } from "../common/ui.js";
|
|
4
4
|
const f = /-o$/;
|
|
5
5
|
function d(c) {
|
|
6
|
-
const { name: s, size: o, spin: a, className: N, rotation: r, ...e } = c, n = e.style || {};
|
|
6
|
+
const { name: s = "", size: o, spin: a, className: N, rotation: r, ...e } = c, n = e.style || {};
|
|
7
7
|
o && (n.fontSize = `${o * 100}%`), r && (n.transform = `rotate(${r}deg)`), e.style = n;
|
|
8
8
|
const x = p(e);
|
|
9
9
|
let t = "";
|