@number10/jsx-components 5.0.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/LICENSE +667 -0
- package/README.md +43 -0
- package/dist/Accordion.cjs +1 -0
- package/dist/Accordion.d.ts +43 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +71 -0
- package/dist/Accordion.test.d.ts +2 -0
- package/dist/Accordion.test.d.ts.map +1 -0
- package/dist/ActivityIndicator.cjs +1 -0
- package/dist/ActivityIndicator.d.ts +21 -0
- package/dist/ActivityIndicator.d.ts.map +1 -0
- package/dist/ActivityIndicator.js +133 -0
- package/dist/AlertDialog.cjs +1 -0
- package/dist/AlertDialog.d.ts +53 -0
- package/dist/AlertDialog.d.ts.map +1 -0
- package/dist/AlertDialog.js +76 -0
- package/dist/Badge.cjs +1 -0
- package/dist/Badge.d.ts +96 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +238 -0
- package/dist/Badge.test.d.ts +2 -0
- package/dist/Badge.test.d.ts.map +1 -0
- package/dist/BottomSheet.cjs +1 -0
- package/dist/BottomSheet.d.ts +72 -0
- package/dist/BottomSheet.d.ts.map +1 -0
- package/dist/BottomSheet.js +132 -0
- package/dist/Button.cjs +1 -0
- package/dist/Button.d.ts +61 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +251 -0
- package/dist/Checkbox.cjs +1 -0
- package/dist/Checkbox.d.ts +40 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +84 -0
- package/dist/Checkbox.test.d.ts +2 -0
- package/dist/Checkbox.test.d.ts.map +1 -0
- package/dist/ColorPicker.cjs +1 -0
- package/dist/ColorPicker.d.ts +48 -0
- package/dist/ColorPicker.d.ts.map +1 -0
- package/dist/ColorPicker.js +256 -0
- package/dist/DebugPanel.cjs +1 -0
- package/dist/DebugPanel.d.ts +63 -0
- package/dist/DebugPanel.d.ts.map +1 -0
- package/dist/DebugPanel.js +116 -0
- package/dist/Dialog.cjs +1 -0
- package/dist/Dialog.d.ts +59 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +142 -0
- package/dist/Divider.cjs +1 -0
- package/dist/Divider.d.ts +19 -0
- package/dist/Divider.d.ts.map +1 -0
- package/dist/Divider.js +15 -0
- package/dist/Divider.test.d.ts +2 -0
- package/dist/Divider.test.d.ts.map +1 -0
- package/dist/Dropdown.cjs +1 -0
- package/dist/Dropdown.d.ts +35 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +222 -0
- package/dist/Icon.cjs +1 -0
- package/dist/Icon.d.ts +71 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Icon.js +57 -0
- package/dist/Icon.test.d.ts +2 -0
- package/dist/Icon.test.d.ts.map +1 -0
- package/dist/Image.cjs +1 -0
- package/dist/Image.d.ts +10 -0
- package/dist/Image.d.ts.map +1 -0
- package/dist/Image.js +18 -0
- package/dist/Joystick.cjs +1 -0
- package/dist/Joystick.d.ts +32 -0
- package/dist/Joystick.d.ts.map +1 -0
- package/dist/Joystick.js +185 -0
- package/dist/ListBox.cjs +1 -0
- package/dist/ListBox.d.ts +67 -0
- package/dist/ListBox.d.ts.map +1 -0
- package/dist/ListBox.js +104 -0
- package/dist/ListBox.test.d.ts +2 -0
- package/dist/ListBox.test.d.ts.map +1 -0
- package/dist/MenuButton.cjs +1 -0
- package/dist/MenuButton.d.ts +33 -0
- package/dist/MenuButton.d.ts.map +1 -0
- package/dist/MenuButton.js +63 -0
- package/dist/Modal.cjs +1 -0
- package/dist/Modal.d.ts +27 -0
- package/dist/Modal.d.ts.map +1 -0
- package/dist/Modal.js +174 -0
- package/dist/Modal.test.d.ts +2 -0
- package/dist/Modal.test.d.ts.map +1 -0
- package/dist/NineSlice.cjs +1 -0
- package/dist/NineSlice.d.ts +40 -0
- package/dist/NineSlice.d.ts.map +1 -0
- package/dist/NineSlice.js +314 -0
- package/dist/NineSlice.props.test.d.ts +2 -0
- package/dist/NineSlice.props.test.d.ts.map +1 -0
- package/dist/NineSlice.test.d.ts +2 -0
- package/dist/NineSlice.test.d.ts.map +1 -0
- package/dist/NineSliceButton.cjs +1 -0
- package/dist/NineSliceButton.d.ts +94 -0
- package/dist/NineSliceButton.d.ts.map +1 -0
- package/dist/NineSliceButton.js +61 -0
- package/dist/NineSliceButton.test.d.ts +2 -0
- package/dist/NineSliceButton.test.d.ts.map +1 -0
- package/dist/NumberInput.cjs +1 -0
- package/dist/NumberInput.d.ts +90 -0
- package/dist/NumberInput.d.ts.map +1 -0
- package/dist/NumberInput.js +222 -0
- package/dist/NumberInput.test.d.ts +2 -0
- package/dist/NumberInput.test.d.ts.map +1 -0
- package/dist/PalettePicker.cjs +1 -0
- package/dist/PalettePicker.d.ts +49 -0
- package/dist/PalettePicker.d.ts.map +1 -0
- package/dist/PalettePicker.js +152 -0
- package/dist/PalettePicker.test.d.ts +2 -0
- package/dist/PalettePicker.test.d.ts.map +1 -0
- package/dist/Popover.cjs +1 -0
- package/dist/Popover.d.ts +95 -0
- package/dist/Popover.d.ts.map +1 -0
- package/dist/Popover.js +267 -0
- package/dist/Portal.cjs +1 -0
- package/dist/Portal.d.ts +30 -0
- package/dist/Portal.d.ts.map +1 -0
- package/dist/Portal.js +64 -0
- package/dist/Portal.test.d.ts +2 -0
- package/dist/Portal.test.d.ts.map +1 -0
- package/dist/ProgressBar.cjs +1 -0
- package/dist/ProgressBar.d.ts +61 -0
- package/dist/ProgressBar.d.ts.map +1 -0
- package/dist/ProgressBar.js +80 -0
- package/dist/ProgressBar.test.d.ts +2 -0
- package/dist/ProgressBar.test.d.ts.map +1 -0
- package/dist/ProgressView.cjs +1 -0
- package/dist/ProgressView.d.ts +37 -0
- package/dist/ProgressView.d.ts.map +1 -0
- package/dist/ProgressView.js +71 -0
- package/dist/RadioButton.cjs +1 -0
- package/dist/RadioButton.d.ts +21 -0
- package/dist/RadioButton.d.ts.map +1 -0
- package/dist/RadioButton.js +53 -0
- package/dist/RadioGroup.cjs +1 -0
- package/dist/RadioGroup.d.ts +26 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +32 -0
- package/dist/RatingBar.cjs +1 -0
- package/dist/RatingBar.d.ts +24 -0
- package/dist/RatingBar.d.ts.map +1 -0
- package/dist/RatingBar.js +84 -0
- package/dist/ScrollSlider.cjs +1 -0
- package/dist/ScrollSlider.d.ts +48 -0
- package/dist/ScrollSlider.d.ts.map +1 -0
- package/dist/ScrollSlider.js +93 -0
- package/dist/ScrollView.cjs +1 -0
- package/dist/ScrollView.d.ts +121 -0
- package/dist/ScrollView.d.ts.map +1 -0
- package/dist/ScrollView.js +541 -0
- package/dist/ScrollView.test.d.ts +2 -0
- package/dist/ScrollView.test.d.ts.map +1 -0
- package/dist/SegmentedControl.cjs +1 -0
- package/dist/SegmentedControl.d.ts +50 -0
- package/dist/SegmentedControl.d.ts.map +1 -0
- package/dist/SegmentedControl.js +201 -0
- package/dist/SegmentedControl.test.d.ts +2 -0
- package/dist/SegmentedControl.test.d.ts.map +1 -0
- package/dist/Sidebar.cjs +1 -0
- package/dist/Sidebar.d.ts +36 -0
- package/dist/Sidebar.d.ts.map +1 -0
- package/dist/Sidebar.js +122 -0
- package/dist/Slider.cjs +1 -0
- package/dist/Slider.d.ts +80 -0
- package/dist/Slider.d.ts.map +1 -0
- package/dist/Slider.js +233 -0
- package/dist/Tabs.cjs +1 -0
- package/dist/Tabs.d.ts +23 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +101 -0
- package/dist/TextInput.cjs +17 -0
- package/dist/TextInput.d.ts +82 -0
- package/dist/TextInput.d.ts.map +1 -0
- package/dist/TextInput.js +441 -0
- package/dist/Toast.cjs +1 -0
- package/dist/Toast.d.ts +66 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +188 -0
- package/dist/Toast.test.d.ts +2 -0
- package/dist/Toast.test.d.ts.map +1 -0
- package/dist/Toggle.cjs +1 -0
- package/dist/Toggle.d.ts +14 -0
- package/dist/Toggle.d.ts.map +1 -0
- package/dist/Toggle.js +135 -0
- package/dist/Toolbar.cjs +1 -0
- package/dist/Toolbar.d.ts +129 -0
- package/dist/Toolbar.d.ts.map +1 -0
- package/dist/Toolbar.js +159 -0
- package/dist/Toolbar.test.d.ts +2 -0
- package/dist/Toolbar.test.d.ts.map +1 -0
- package/dist/TransformOriginView.cjs +1 -0
- package/dist/TransformOriginView.d.ts +8 -0
- package/dist/TransformOriginView.d.ts.map +1 -0
- package/dist/TransformOriginView.js +38 -0
- package/dist/WheelPicker.cjs +1 -0
- package/dist/WheelPicker.d.ts +58 -0
- package/dist/WheelPicker.d.ts.map +1 -0
- package/dist/WheelPicker.js +167 -0
- package/dist/WrapText.cjs +1 -0
- package/dist/WrapText.d.ts +83 -0
- package/dist/WrapText.d.ts.map +1 -0
- package/dist/WrapText.js +93 -0
- package/dist/WrapText.test.d.ts +2 -0
- package/dist/WrapText.test.d.ts.map +1 -0
- package/dist/contrast-slot-map.d.ts +33 -0
- package/dist/contrast-slot-map.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/primitives/Image.cjs +1 -0
- package/dist/primitives/Image.d.ts +11 -0
- package/dist/primitives/Image.d.ts.map +1 -0
- package/dist/primitives/Image.js +7 -0
- package/dist/primitives/Sprite.cjs +1 -0
- package/dist/primitives/Sprite.d.ts +11 -0
- package/dist/primitives/Sprite.d.ts.map +1 -0
- package/dist/primitives/Sprite.js +7 -0
- package/dist/primitives/Text.cjs +1 -0
- package/dist/primitives/Text.d.ts +14 -0
- package/dist/primitives/Text.d.ts.map +1 -0
- package/dist/primitives/Text.js +15 -0
- package/dist/primitives/VectorDrawContent.cjs +1 -0
- package/dist/primitives/VectorDrawContent.d.ts +3 -0
- package/dist/primitives/VectorDrawContent.d.ts.map +1 -0
- package/dist/primitives/VectorDrawContent.js +7 -0
- package/dist/primitives/View.cjs +1 -0
- package/dist/primitives/View.d.ts +13 -0
- package/dist/primitives/View.d.ts.map +1 -0
- package/dist/primitives/View.js +7 -0
- package/dist/primitives/index.d.ts +13 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/primitives.test.d.ts +2 -0
- package/dist/primitives/primitives.test.d.ts.map +1 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.ts +2 -0
- package/dist/primitives.js +6 -0
- package/dist/theme-defaults.cjs +1 -0
- package/dist/theme-defaults.d.ts +12 -0
- package/dist/theme-defaults.d.ts.map +1 -0
- package/dist/theme-defaults.js +1288 -0
- package/dist/theme-defaults.test.d.ts +2 -0
- package/dist/theme-defaults.test.d.ts.map +1 -0
- package/dist/theme-types.cjs +0 -0
- package/dist/theme-types.d.ts +708 -0
- package/dist/theme-types.d.ts.map +1 -0
- package/dist/theme-types.js +0 -0
- package/dist/useOverlayPresence.cjs +1 -0
- package/dist/useOverlayPresence.d.ts +24 -0
- package/dist/useOverlayPresence.d.ts.map +1 -0
- package/dist/useOverlayPresence.js +19 -0
- package/package.json +83 -0
package/dist/Badge.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Text as e } from "./primitives/Text.js";
|
|
2
|
+
import { View as t } from "./primitives/View.js";
|
|
3
|
+
import "./primitives.js";
|
|
4
|
+
import { resolveComponentTheme as n, useTheme as r } from "@number10/jsx-core";
|
|
5
|
+
import { jsx as i, jsxs as a } from "@number10/jsx-core/jsx-runtime";
|
|
6
|
+
//#region src/Badge.tsx
|
|
7
|
+
var o = {
|
|
8
|
+
neutral: {
|
|
9
|
+
backgroundColor: 4674921,
|
|
10
|
+
softBackgroundColor: 1976635,
|
|
11
|
+
borderColor: 6583435,
|
|
12
|
+
textColor: "#ffffff",
|
|
13
|
+
outlineTextColor: "#cbd5e1"
|
|
14
|
+
},
|
|
15
|
+
primary: {
|
|
16
|
+
backgroundColor: 2450411,
|
|
17
|
+
softBackgroundColor: 1981066,
|
|
18
|
+
borderColor: 6333946,
|
|
19
|
+
textColor: "#ffffff",
|
|
20
|
+
outlineTextColor: "#93c5fd"
|
|
21
|
+
},
|
|
22
|
+
success: {
|
|
23
|
+
backgroundColor: 1483594,
|
|
24
|
+
softBackgroundColor: 1332013,
|
|
25
|
+
borderColor: 4906624,
|
|
26
|
+
textColor: "#ffffff",
|
|
27
|
+
outlineTextColor: "#86efac"
|
|
28
|
+
},
|
|
29
|
+
warning: {
|
|
30
|
+
backgroundColor: 16096779,
|
|
31
|
+
softBackgroundColor: 7877903,
|
|
32
|
+
borderColor: 16498468,
|
|
33
|
+
textColor: "#111827",
|
|
34
|
+
outlineTextColor: "#fde68a"
|
|
35
|
+
},
|
|
36
|
+
danger: {
|
|
37
|
+
backgroundColor: 14427686,
|
|
38
|
+
softBackgroundColor: 8330525,
|
|
39
|
+
borderColor: 16281969,
|
|
40
|
+
textColor: "#ffffff",
|
|
41
|
+
outlineTextColor: "#fecaca"
|
|
42
|
+
},
|
|
43
|
+
info: {
|
|
44
|
+
backgroundColor: 561586,
|
|
45
|
+
softBackgroundColor: 1461859,
|
|
46
|
+
borderColor: 2282478,
|
|
47
|
+
textColor: "#ffffff",
|
|
48
|
+
outlineTextColor: "#a5f3fc"
|
|
49
|
+
}
|
|
50
|
+
}, s = {
|
|
51
|
+
small: {
|
|
52
|
+
height: 22,
|
|
53
|
+
padding: {
|
|
54
|
+
left: 8,
|
|
55
|
+
right: 8,
|
|
56
|
+
top: 3,
|
|
57
|
+
bottom: 3
|
|
58
|
+
},
|
|
59
|
+
fontSize: 12,
|
|
60
|
+
cornerRadius: 11,
|
|
61
|
+
gap: 5,
|
|
62
|
+
dotSize: 8
|
|
63
|
+
},
|
|
64
|
+
medium: {
|
|
65
|
+
height: 26,
|
|
66
|
+
padding: {
|
|
67
|
+
left: 10,
|
|
68
|
+
right: 10,
|
|
69
|
+
top: 4,
|
|
70
|
+
bottom: 4
|
|
71
|
+
},
|
|
72
|
+
fontSize: 14,
|
|
73
|
+
cornerRadius: 13,
|
|
74
|
+
gap: 6,
|
|
75
|
+
dotSize: 10
|
|
76
|
+
},
|
|
77
|
+
large: {
|
|
78
|
+
height: 32,
|
|
79
|
+
padding: {
|
|
80
|
+
left: 13,
|
|
81
|
+
right: 13,
|
|
82
|
+
top: 5,
|
|
83
|
+
bottom: 5
|
|
84
|
+
},
|
|
85
|
+
fontSize: 18,
|
|
86
|
+
cornerRadius: 16,
|
|
87
|
+
gap: 8,
|
|
88
|
+
dotSize: 12
|
|
89
|
+
}
|
|
90
|
+
}, c = new Set([
|
|
91
|
+
"View",
|
|
92
|
+
"Text",
|
|
93
|
+
"Image",
|
|
94
|
+
"Sprite",
|
|
95
|
+
"Badge",
|
|
96
|
+
"Tag",
|
|
97
|
+
"Icon"
|
|
98
|
+
]);
|
|
99
|
+
function l({ count: e, maxCount: t = 99 }) {
|
|
100
|
+
if (!Number.isFinite(e)) return "0";
|
|
101
|
+
let n = Math.max(0, Math.floor(e ?? 0)), r = Math.max(0, Math.floor(t));
|
|
102
|
+
return n > r ? `${r}+` : `${n}`;
|
|
103
|
+
}
|
|
104
|
+
function u(e, t) {
|
|
105
|
+
let n = o[e];
|
|
106
|
+
return t === "outline" ? {
|
|
107
|
+
bg: 0,
|
|
108
|
+
bgAlpha: 0,
|
|
109
|
+
border: n.borderColor,
|
|
110
|
+
borderW: 1,
|
|
111
|
+
textColor: n.outlineTextColor
|
|
112
|
+
} : t === "soft" ? {
|
|
113
|
+
bg: n.softBackgroundColor,
|
|
114
|
+
bgAlpha: 1,
|
|
115
|
+
border: n.borderColor,
|
|
116
|
+
borderW: 1,
|
|
117
|
+
textColor: n.outlineTextColor
|
|
118
|
+
} : {
|
|
119
|
+
bg: n.backgroundColor,
|
|
120
|
+
bgAlpha: 1,
|
|
121
|
+
border: n.borderColor,
|
|
122
|
+
borderW: 0,
|
|
123
|
+
textColor: n.textColor
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function d(e) {
|
|
127
|
+
return s[e];
|
|
128
|
+
}
|
|
129
|
+
function f(a) {
|
|
130
|
+
let { children: o, label: s, count: f, maxCount: p, dot: m = !1, tone: h, variant: g, size: _, style: v, disabled: y = !1, disabledAlpha: b, theme: x, width: S, height: C, ...w } = a, T = r(), { props: E } = n({
|
|
131
|
+
componentName: "Badge",
|
|
132
|
+
localTheme: x ?? T,
|
|
133
|
+
explicitProps: {
|
|
134
|
+
tone: h,
|
|
135
|
+
variant: g,
|
|
136
|
+
size: _
|
|
137
|
+
},
|
|
138
|
+
knownComponents: c
|
|
139
|
+
}), D = h ?? E.tone ?? "neutral", O = g ?? E.variant ?? "solid", k = d(_ ?? E.size ?? "medium"), A = u(D, O), j = b ?? E.disabledAlpha ?? .5, M = p ?? E.maxCount ?? 99, N = f === void 0 ? s === void 0 ? "" : `${s}` : l({
|
|
140
|
+
count: f,
|
|
141
|
+
maxCount: M
|
|
142
|
+
}), P = {
|
|
143
|
+
color: A.textColor,
|
|
144
|
+
fontSize: k.fontSize
|
|
145
|
+
};
|
|
146
|
+
if (m) {
|
|
147
|
+
let e = k.dotSize;
|
|
148
|
+
return /* @__PURE__ */ i(t, {
|
|
149
|
+
width: S ?? e,
|
|
150
|
+
height: C ?? e,
|
|
151
|
+
backgroundColor: A.bg,
|
|
152
|
+
backgroundAlpha: A.bgAlpha,
|
|
153
|
+
borderColor: A.border,
|
|
154
|
+
borderWidth: A.borderW,
|
|
155
|
+
cornerRadius: e / 2,
|
|
156
|
+
...y ? { alpha: j } : {},
|
|
157
|
+
...w
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return /* @__PURE__ */ i(t, {
|
|
161
|
+
width: S ?? "auto",
|
|
162
|
+
height: C ?? k.height,
|
|
163
|
+
direction: "row",
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
justifyContent: "center",
|
|
166
|
+
gap: k.gap,
|
|
167
|
+
padding: k.padding,
|
|
168
|
+
backgroundColor: A.bg,
|
|
169
|
+
backgroundAlpha: A.bgAlpha,
|
|
170
|
+
borderColor: A.border,
|
|
171
|
+
borderWidth: A.borderW,
|
|
172
|
+
cornerRadius: k.cornerRadius,
|
|
173
|
+
...y ? { alpha: j } : {},
|
|
174
|
+
...w,
|
|
175
|
+
children: o ?? (N ? /* @__PURE__ */ i(e, {
|
|
176
|
+
text: N,
|
|
177
|
+
style: {
|
|
178
|
+
...P,
|
|
179
|
+
...v
|
|
180
|
+
}
|
|
181
|
+
}) : null)
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function p(e) {
|
|
185
|
+
return e.count === void 0 ? e.label === void 0 ? "" : `${e.label}` : l(e);
|
|
186
|
+
}
|
|
187
|
+
function m(o) {
|
|
188
|
+
let { selected: s = !1, onRemove: l, closeLabel: f = "×", tone: p, variant: m, size: h, style: g, theme: _, children: v, label: y, disabled: b = !1, disabledAlpha: x, ...S } = o, C = r(), { props: w } = n({
|
|
189
|
+
componentName: "Tag",
|
|
190
|
+
localTheme: _ ?? C,
|
|
191
|
+
knownComponents: c
|
|
192
|
+
}), T = p ?? w.tone ?? (s ? "primary" : "neutral"), E = m ?? w.variant ?? (s ? "solid" : "soft"), D = d(h ?? w.size ?? "medium"), O = u(T, E), k = x ?? w.disabledAlpha ?? .5, A = y === void 0 ? "" : `${y}`, j = {
|
|
193
|
+
color: O.textColor,
|
|
194
|
+
fontSize: D.fontSize,
|
|
195
|
+
...g
|
|
196
|
+
};
|
|
197
|
+
return /* @__PURE__ */ a(t, {
|
|
198
|
+
width: "auto",
|
|
199
|
+
height: D.height,
|
|
200
|
+
direction: "row",
|
|
201
|
+
alignItems: "center",
|
|
202
|
+
justifyContent: "center",
|
|
203
|
+
gap: D.gap,
|
|
204
|
+
padding: D.padding,
|
|
205
|
+
backgroundColor: O.bg,
|
|
206
|
+
backgroundAlpha: O.bgAlpha,
|
|
207
|
+
borderColor: O.border,
|
|
208
|
+
borderWidth: O.borderW,
|
|
209
|
+
cornerRadius: D.cornerRadius,
|
|
210
|
+
...b ? { alpha: k } : {},
|
|
211
|
+
...S,
|
|
212
|
+
children: [
|
|
213
|
+
y ? /* @__PURE__ */ i(e, {
|
|
214
|
+
text: A,
|
|
215
|
+
style: j
|
|
216
|
+
}) : null,
|
|
217
|
+
v,
|
|
218
|
+
l ? /* @__PURE__ */ i(t, {
|
|
219
|
+
width: 16,
|
|
220
|
+
height: 16,
|
|
221
|
+
justifyContent: "center",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
cornerRadius: 16 / 2,
|
|
224
|
+
enableGestures: !0,
|
|
225
|
+
onTouch: () => l(),
|
|
226
|
+
children: /* @__PURE__ */ i(e, {
|
|
227
|
+
text: f,
|
|
228
|
+
style: {
|
|
229
|
+
...j,
|
|
230
|
+
fontSize: 16 * .7
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}) : null
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { f as Badge, m as Tag, l as formatBadgeCount, p as getBadgeText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.test.d.ts","sourceRoot":"","sources":["../src/Badge.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./primitives/View.cjs`);require(`./primitives.cjs`);const t=require(`./Portal.cjs`);let n=require(`@number10/jsx-core`),r=require(`@number10/jsx-core/jsx-runtime`);var i=1100;function a(a){let{open:o,defaultOpen:s=!1,onOpenChange:c,children:l,height:u=.5,dismissThreshold:d,showHandle:f=!0,depth:p=i,closeOnBackdrop:m=!1,backdropAlpha:h,handleAreaHeight:g=32,renderHandle:_,theme:v}=a,y=(0,n.useTheme)(),b=v?(0,n.mergeThemes)(y??{},v):y,{props:x,nestedTheme:S}=(0,n.resolveComponentTheme)({componentName:`BottomSheet`,globalTheme:(0,n.getGlobalThemeDefaults)(),localTheme:b,knownComponents:n.KNOWN_COMPONENTS}),C=o!==void 0,[w,T]=(0,n.useState)(s),E=C?!!o:w,D=(0,n.useViewportSize)(),O=D.height,k=D.width,A=Math.round(O*Math.min(1,Math.max(.1,u))),j=Math.max(0,A-g),M=d??x.dismissThreshold,[N,P]=(0,n.useState)(0),F=(0,n.useRef)(0),I=(0,n.useRef)(0),L=(0,n.useRef)(j),[R,z]=(0,n.useState)(!1),B=e=>{C||T(e),c?.(e)};E&&!R&&z(!0);let V=e=>{e.stopPropagation();let t=e.state;if(t){if(t===`start`)F.current=0,I.current=0,L.current=Math.max(0,A-e.localY),P(0);else if(t===`move`){let t=e.dy??0;F.current=Math.max(0,F.current+t);let n=Math.min(F.current,j);I.current=F.current,P(n)}else if(t===`end`){let t=e.dy??0;F.current=Math.max(0,F.current+t),F.current>(M??L.current/2)&&B(!1),F.current=0,I.current=0,P(0)}}};if(!R&&!E)return null;let H=E||N>0,U=x.panelCornerRadius??16,W=x.handleWidth??36,G=x.handleHeight??5,K=x.handleColor??6583435,q=x.handleCornerRadius??2,J=x.handleAreaColor,Y=x.backdropColor??0,X=x.backdropAlpha,Z=x.backgroundColor,Q=x.backgroundAlpha,$=x.borderColor,ee=x.borderWidth,te=E?O-A+N:O-A;return(0,r.jsxs)(t.Portal,{depth:p,blockEvents:!1,children:[(0,r.jsx)(e.View,{width:k,height:O,backgroundColor:Y,backgroundAlpha:h??X??.5,enableGestures:!0,visible:E&&m,onTouch:e=>{e.stopPropagation(),B(!1)}}),(0,r.jsxs)(e.View,{width:k,height:A,y:te,backgroundColor:Z,backgroundAlpha:Q??1,borderColor:$,borderWidth:ee,cornerRadius:U,direction:`column`,enableGestures:!0,visible:H,onTouch:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),theme:S,children:[f?(0,r.jsx)(e.View,{width:k,height:g,alignItems:`center`,justifyContent:`center`,backgroundColor:J,enableGestures:!0,onTouch:e=>e.stopPropagation(),onTouchMove:V,children:_?typeof _==`function`?_({width:W,height:G,color:K,cornerRadius:q}):_:(0,r.jsx)(e.View,{width:W,height:G,backgroundColor:K,cornerRadius:q})}):null,(0,r.jsx)(e.View,{flex:1,width:`fill`,overflow:`hidden`,theme:S,children:l})]})]})}var o={Bar:t=>(0,r.jsx)(e.View,{width:t.width,height:t.height,backgroundColor:t.color,cornerRadius:t.cornerRadius}),Pill:t=>(0,r.jsx)(e.View,{width:t.width*2,height:t.height*3,backgroundColor:t.color,cornerRadius:t.height*1.5}),Grip:t=>(0,r.jsxs)(e.View,{gap:t.height,children:[(0,r.jsx)(e.View,{width:t.width*2,height:t.height,backgroundColor:t.color,cornerRadius:t.cornerRadius}),(0,r.jsx)(e.View,{width:t.width*2,height:t.height,backgroundColor:t.color,cornerRadius:t.cornerRadius}),(0,r.jsx)(e.View,{width:t.width*2,height:t.height,backgroundColor:t.color,cornerRadius:t.cornerRadius})]})};exports.BottomSheet=a,exports.BottomSheetDepth=i,exports.BottomSheetHandle=o;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ChildrenType, VNodeLike } from '@number10/jsx-core';
|
|
2
|
+
import { PortableComponentPartialTheme } from './theme-types';
|
|
3
|
+
/** The default portal depth for BottomSheet — can be overridden via props. */
|
|
4
|
+
export declare const BottomSheetDepth = 1100;
|
|
5
|
+
export interface BottomSheetLabels {
|
|
6
|
+
close?: string;
|
|
7
|
+
handle?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Props passed to renderHandle function for custom handle rendering. */
|
|
10
|
+
export interface HandleRenderProps {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
color: number;
|
|
14
|
+
cornerRadius: number;
|
|
15
|
+
}
|
|
16
|
+
export interface BottomSheetProps {
|
|
17
|
+
/** Unique key for VDOM identification. */
|
|
18
|
+
key?: string | number | undefined;
|
|
19
|
+
/** Controlled open state. */
|
|
20
|
+
open?: boolean;
|
|
21
|
+
/** Initial open state for uncontrolled usage. */
|
|
22
|
+
defaultOpen?: boolean;
|
|
23
|
+
/** Called when open state changes. */
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
/** Sheet content. */
|
|
26
|
+
children?: ChildrenType;
|
|
27
|
+
/** Height as fraction of viewport (0–1). Default 0.5. */
|
|
28
|
+
height?: number;
|
|
29
|
+
/** Drag distance in pixels to trigger dismiss. Default is half the available drag distance. */
|
|
30
|
+
dismissThreshold?: number;
|
|
31
|
+
/** Show drag handle. Default true. */
|
|
32
|
+
showHandle?: boolean;
|
|
33
|
+
/** Portal depth. */
|
|
34
|
+
depth?: number;
|
|
35
|
+
/** Whether tapping the backdrop closes the sheet. Default false. */
|
|
36
|
+
closeOnBackdrop?: boolean;
|
|
37
|
+
/** Backdrop alpha when closeOnBackdrop is active. Default 0.5. */
|
|
38
|
+
backdropAlpha?: number;
|
|
39
|
+
/** Height of the drag-handle touch area in px. Also used as max-drag cap. Default 32. */
|
|
40
|
+
handleAreaHeight?: number;
|
|
41
|
+
/** Custom handle renderer. Receives themed dimensions. Falls back to default bar. */
|
|
42
|
+
renderHandle?: VNodeLike | ((props: HandleRenderProps) => VNodeLike);
|
|
43
|
+
/** Theme overrides. */
|
|
44
|
+
theme?: PortableComponentPartialTheme<'BottomSheet'>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* BottomSheet — slide-up panel with backdrop and drag-to-dismiss.
|
|
48
|
+
*
|
|
49
|
+
* Portal lifecycle: once opened, the Portal stays mounted to avoid
|
|
50
|
+
* duplicate backdrop issues from mount/unmount races in the VDOM.
|
|
51
|
+
* Visibility is controlled via conditional children, not by returning null.
|
|
52
|
+
*/
|
|
53
|
+
export declare function BottomSheet(props: BottomSheetProps): VNodeLike;
|
|
54
|
+
/**
|
|
55
|
+
* Pre-built handle renderers for use with {@link BottomSheetProps.renderHandle}.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <BottomSheet renderHandle={BottomSheetHandle.Bar} />
|
|
60
|
+
* <BottomSheet renderHandle={BottomSheetHandle.Pill} />
|
|
61
|
+
* <BottomSheet renderHandle={(h) => <View width={h.width} height={h.height} backgroundColor={0xff0000} cornerRadius={4} />} />
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const BottomSheetHandle: {
|
|
65
|
+
/** Default bar — uses themed width, height, color, cornerRadius. */
|
|
66
|
+
Bar: (props: HandleRenderProps) => VNodeLike;
|
|
67
|
+
/** Pill variant — cornerRadius for a fully rounded look. */
|
|
68
|
+
Pill: (props: HandleRenderProps) => VNodeLike;
|
|
69
|
+
/** Gripper variant */
|
|
70
|
+
Grip: (props: HandleRenderProps) => VNodeLike;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=BottomSheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BottomSheet.d.ts","sourceRoot":"","sources":["../src/BottomSheet.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAoC,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,KAAK,EAAoB,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAkBpF,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,iDAAiD;IACjD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,sCAAsC;IACtC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,qBAAqB;IACrB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+FAA+F;IAC/F,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qFAAqF;IACrF,YAAY,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,CAAA;IACpE,uBAAuB;IACvB,KAAK,CAAC,EAAE,6BAA6B,CAAC,aAAa,CAAC,CAAA;CACrD;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA4L9D;AAMD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;IAC5B,oEAAoE;iBACvD,iBAAiB,KAAG,SAAS;IAQ1C,4DAA4D;kBAC9C,iBAAiB,KAAG,SAAS;IAQ3C,sBAAsB;kBACR,iBAAiB,KAAG,SAAS;CAsB5C,CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { View as e } from "./primitives/View.js";
|
|
2
|
+
import "./primitives.js";
|
|
3
|
+
import { Portal as t } from "./Portal.js";
|
|
4
|
+
import { KNOWN_COMPONENTS as n, getGlobalThemeDefaults as r, mergeThemes as i, resolveComponentTheme as a, useRef as o, useState as s, useTheme as c, useViewportSize as ee } from "@number10/jsx-core";
|
|
5
|
+
import { jsx as l, jsxs as u } from "@number10/jsx-core/jsx-runtime";
|
|
6
|
+
//#region src/BottomSheet.tsx
|
|
7
|
+
var d = 1100;
|
|
8
|
+
function f(f) {
|
|
9
|
+
let { open: p, defaultOpen: m = !1, onOpenChange: h, children: g, height: _ = .5, dismissThreshold: te, showHandle: v = !0, depth: y = d, closeOnBackdrop: b = !1, backdropAlpha: x, handleAreaHeight: S = 32, renderHandle: C, theme: w } = f, T = c(), E = w ? i(T ?? {}, w) : T, { props: D, nestedTheme: O } = a({
|
|
10
|
+
componentName: "BottomSheet",
|
|
11
|
+
globalTheme: r(),
|
|
12
|
+
localTheme: E,
|
|
13
|
+
knownComponents: n
|
|
14
|
+
}), k = p !== void 0, [A, j] = s(m), M = k ? !!p : A, N = ee(), P = N.height, F = N.width, I = Math.round(P * Math.min(1, Math.max(.1, _))), L = Math.max(0, I - S), R = te ?? D.dismissThreshold, [z, B] = s(0), V = o(0), H = o(0), U = o(L), [W, G] = s(!1), K = (e) => {
|
|
15
|
+
k || j(e), h?.(e);
|
|
16
|
+
};
|
|
17
|
+
M && !W && G(!0);
|
|
18
|
+
let q = (e) => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
let t = e.state;
|
|
21
|
+
if (t) {
|
|
22
|
+
if (t === "start") V.current = 0, H.current = 0, U.current = Math.max(0, I - e.localY), B(0);
|
|
23
|
+
else if (t === "move") {
|
|
24
|
+
let t = e.dy ?? 0;
|
|
25
|
+
V.current = Math.max(0, V.current + t);
|
|
26
|
+
let n = Math.min(V.current, L);
|
|
27
|
+
H.current = V.current, B(n);
|
|
28
|
+
} else if (t === "end") {
|
|
29
|
+
let t = e.dy ?? 0;
|
|
30
|
+
V.current = Math.max(0, V.current + t), V.current > (R ?? U.current / 2) && K(!1), V.current = 0, H.current = 0, B(0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (!W && !M) return null;
|
|
35
|
+
let J = M || z > 0, Y = D.panelCornerRadius ?? 16, X = D.handleWidth ?? 36, Z = D.handleHeight ?? 5, Q = D.handleColor ?? 6583435, $ = D.handleCornerRadius ?? 2, ne = D.handleAreaColor, re = D.backdropColor ?? 0, ie = D.backdropAlpha, ae = D.backgroundColor, oe = D.backgroundAlpha, se = D.borderColor, ce = D.borderWidth, le = M ? P - I + z : P - I;
|
|
36
|
+
return /* @__PURE__ */ u(t, {
|
|
37
|
+
depth: y,
|
|
38
|
+
blockEvents: !1,
|
|
39
|
+
children: [/* @__PURE__ */ l(e, {
|
|
40
|
+
width: F,
|
|
41
|
+
height: P,
|
|
42
|
+
backgroundColor: re,
|
|
43
|
+
backgroundAlpha: x ?? ie ?? .5,
|
|
44
|
+
enableGestures: !0,
|
|
45
|
+
visible: M && b,
|
|
46
|
+
onTouch: (e) => {
|
|
47
|
+
e.stopPropagation(), K(!1);
|
|
48
|
+
}
|
|
49
|
+
}), /* @__PURE__ */ u(e, {
|
|
50
|
+
width: F,
|
|
51
|
+
height: I,
|
|
52
|
+
y: le,
|
|
53
|
+
backgroundColor: ae,
|
|
54
|
+
backgroundAlpha: oe ?? 1,
|
|
55
|
+
borderColor: se,
|
|
56
|
+
borderWidth: ce,
|
|
57
|
+
cornerRadius: Y,
|
|
58
|
+
direction: "column",
|
|
59
|
+
enableGestures: !0,
|
|
60
|
+
visible: J,
|
|
61
|
+
onTouch: (e) => e.stopPropagation(),
|
|
62
|
+
onTouchMove: (e) => e.stopPropagation(),
|
|
63
|
+
theme: O,
|
|
64
|
+
children: [v ? /* @__PURE__ */ l(e, {
|
|
65
|
+
width: F,
|
|
66
|
+
height: S,
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
backgroundColor: ne,
|
|
70
|
+
enableGestures: !0,
|
|
71
|
+
onTouch: (e) => e.stopPropagation(),
|
|
72
|
+
onTouchMove: q,
|
|
73
|
+
children: C ? typeof C == "function" ? C({
|
|
74
|
+
width: X,
|
|
75
|
+
height: Z,
|
|
76
|
+
color: Q,
|
|
77
|
+
cornerRadius: $
|
|
78
|
+
}) : C : /* @__PURE__ */ l(e, {
|
|
79
|
+
width: X,
|
|
80
|
+
height: Z,
|
|
81
|
+
backgroundColor: Q,
|
|
82
|
+
cornerRadius: $
|
|
83
|
+
})
|
|
84
|
+
}) : null, /* @__PURE__ */ l(e, {
|
|
85
|
+
flex: 1,
|
|
86
|
+
width: "fill",
|
|
87
|
+
overflow: "hidden",
|
|
88
|
+
theme: O,
|
|
89
|
+
children: g
|
|
90
|
+
})]
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
var p = {
|
|
95
|
+
Bar: (t) => /* @__PURE__ */ l(e, {
|
|
96
|
+
width: t.width,
|
|
97
|
+
height: t.height,
|
|
98
|
+
backgroundColor: t.color,
|
|
99
|
+
cornerRadius: t.cornerRadius
|
|
100
|
+
}),
|
|
101
|
+
Pill: (t) => /* @__PURE__ */ l(e, {
|
|
102
|
+
width: t.width * 2,
|
|
103
|
+
height: t.height * 3,
|
|
104
|
+
backgroundColor: t.color,
|
|
105
|
+
cornerRadius: t.height * 1.5
|
|
106
|
+
}),
|
|
107
|
+
Grip: (t) => /* @__PURE__ */ u(e, {
|
|
108
|
+
gap: t.height,
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ l(e, {
|
|
111
|
+
width: t.width * 2,
|
|
112
|
+
height: t.height,
|
|
113
|
+
backgroundColor: t.color,
|
|
114
|
+
cornerRadius: t.cornerRadius
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ l(e, {
|
|
117
|
+
width: t.width * 2,
|
|
118
|
+
height: t.height,
|
|
119
|
+
backgroundColor: t.color,
|
|
120
|
+
cornerRadius: t.cornerRadius
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ l(e, {
|
|
123
|
+
width: t.width * 2,
|
|
124
|
+
height: t.height,
|
|
125
|
+
backgroundColor: t.color,
|
|
126
|
+
cornerRadius: t.cornerRadius
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { f as BottomSheet, d as BottomSheetDepth, p as BottomSheetHandle };
|
package/dist/Button.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./primitives/Text.cjs`),t=require(`./primitives/View.cjs`);require(`./primitives.cjs`);let n=require(`@number10/jsx-core`),r=require(`@number10/jsx-core/jsx-runtime`);function i(){let e=(0,n.getPresetWithMode)(`oceanBlue`,`light`).colors,t=e.primary.dark.toNumber(),r=e.text.lightest.toNumber(),i=e.surface.lightest.toNumber(),a=e.text.dark.toNumber(),o=e.surface.medium.toNumber(),s=e.text.light.toNumber(),c=e.primary.light.toNumber(),l=e.text.light.toNumber(),u=e.error.dark.toNumber(),d=e.text.lightest.toNumber(),f={medium:{fontSize:`16px`,fontFamily:`Arial`,fontStyle:`bold`}};return{variant:`primary`,size:`medium`,disabledColor:o,disabledTextColor:`#`+new n.HexColor(s.toString(16).padStart(6,`0`)).toString(),disabledIconTint:s,disabledAlpha:.48,height:40,backgroundColor:t,backgroundAlpha:1,borderColor:e.primary.darkest.toNumber(),borderWidth:1,cornerRadius:8,gap:8,padding:{top:8,bottom:8,left:16,right:16},justifyContent:`center`,alignItems:`center`,effect:`press`,effectConfig:{intensity:.94,time:140},iconSize:18,textStyle:{...f.medium,color:`#${r.toString(16).padStart(6,`0`)}`},Text:{style:{...f.medium,color:`#${r.toString(16).padStart(6,`0`)}`}},Icon:{size:18,tint:r},primary:{backgroundColor:t,borderColor:e.primary.darkest.toNumber(),textStyle:{color:`#${r.toString(16).padStart(6,`0`)}`,fontStyle:`bold`},Icon:{tint:r}},secondary:{backgroundColor:i,backgroundAlpha:.92,borderColor:e.border.light.toNumber(),borderWidth:1,textStyle:{color:`#${a.toString(16).padStart(6,`0`)}`,fontStyle:`bold`},Icon:{tint:a}},outline:{backgroundColor:e.primary.dark.toNumber(),backgroundAlpha:.08,borderColor:c,borderWidth:2,textStyle:{color:`#${c.toString(16).padStart(6,`0`)}`,fontStyle:`bold`},Icon:{tint:c}},ghost:{backgroundColor:e.surface.light.toNumber(),backgroundAlpha:.18,borderColor:e.border.medium.toNumber(),borderAlpha:.35,borderWidth:1,textStyle:{color:`#${l.toString(16).padStart(6,`0`)}`,fontStyle:`bold`},Icon:{tint:l}},danger:{backgroundColor:u,borderColor:e.error.darkest.toNumber(),textStyle:{color:`#${d.toString(16).padStart(6,`0`)}`,fontStyle:`bold`},Icon:{tint:d}},small:{height:32,padding:{top:6,bottom:6,left:12,right:12},cornerRadius:6,gap:6,iconSize:15,textStyle:{fontSize:`12px`},Icon:{size:15}},medium:{height:40,padding:{top:8,bottom:8,left:16,right:16},cornerRadius:8,gap:8,iconSize:18,Icon:{size:18}},large:{height:48,padding:{top:10,bottom:10,left:20,right:20},cornerRadius:10,gap:10,iconSize:22,textStyle:{fontSize:`18px`},Icon:{size:22}}}}(0,n.registerComponentDefaultsIfMissing)(`Button`,i());function a(e,t){return t?{...e,...t,textStyle:e.textStyle||t.textStyle?{...e.textStyle??{},...t.textStyle??{}}:void 0,Text:e.Text||t.Text?{...e.Text??{},...t.Text??{},style:e.Text?.style||t.Text?.style?{...e.Text?.style??{},...t.Text?.style??{}}:void 0}:void 0,Icon:e.Icon||t.Icon?{...e.Icon??{},...t.Icon??{}}:void 0}:e}function o(e,t,n){if(!n)return;let r=e[t],i=e[n];return{...r?.[n]??{},...i??{}}}function s(e){let t=e.Text??{},n=e.Icon??{},r=e.textStyle||t.style?{...t.style??{},...e.textStyle??{}}:void 0;return{Text:r?{...t,style:r}:t,Icon:{...n,...e.iconSize===void 0?{}:{size:e.iconSize}}}}function c(i){let{children:c,label:l,text:u,onClick:d,disabled:f=!1,variant:p,size:m,width:h,height:g,textStyle:_,iconSize:v,disabledAlpha:y,alpha:b,theme:x,onTouch:S,effect:C,effectConfig:w,...T}=i,E=(0,n.useTheme)(),D=x?(0,n.mergeThemes)(E??{},x):E,{props:O,nestedTheme:k}=(0,n.resolveComponentTheme)({componentName:`Button`,globalTheme:(0,n.getGlobalThemeDefaults)(),localTheme:D,explicitProps:T,knownComponents:n.KNOWN_COMPONENTS}),A=(0,n.useRef)(null),j=p??O.variant??`primary`,M=m??O.size??`medium`,N=a(a({...O},o(O,`variants`,j)),o(O,`sizes`,M)),P=N.textStyle||_?{...N.textStyle??{},..._??{}}:void 0,F=v??N.iconSize,I=y??N.disabledAlpha??.5,L=N.disabledTextColor??O.disabledTextColor??P?.color,R=N.disabledIconTint??O.disabledIconTint??N.iconTint,z=f&&L?{...P??{},color:L}:P,B={...z?{textStyle:z}:{},...F===void 0?{}:{iconSize:F},...f&&R!==void 0?{Icon:{...N.Icon??{},tint:R}}:{}},V=f?{...N,backgroundColor:N.disabledColor??O.disabledColor??N.backgroundColor,backgroundAlpha:I,...b===void 0?{}:{alpha:b},...B}:{...N,...b===void 0?{}:{alpha:b},...B},H=f?void 0:e=>{let t=(0,n.resolveEffect)({effect:C,effectConfig:w},V);(0,n.applyEffect)(A.current,t.effect,t.effectConfig),S?.(e),d?.()},U=l??u,W=c??(U===void 0?null:(0,r.jsx)(e.Text,{text:`${U}`,...z?{style:z}:{}})),G=(0,n.mergeThemes)(k,s(V)),{disabledColor:ee,disabledTextColor:te,disabledIconTint:K,disabledAlpha:q,effect:J,effectConfig:Y,textStyle:X,iconSize:Z,variant:ne,size:re,variants:ie,sizes:ae,Text:oe,Icon:Q,primary:se,secondary:ce,outline:le,ghost:ue,danger:de,small:fe,medium:pe,large:me,iconTint:he,...$}=V;return(0,r.jsx)(t.View,{ref:A,direction:`row`,alignItems:`center`,justifyContent:`center`,enableGestures:!0,...H?{onTouch:H}:{},theme:G,...$,width:h,height:g,...T,children:W})}exports.Button=c;
|
package/dist/Button.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ChildrenType, EffectConfig, EffectName, GestureEventData, PortableTextStyle, SizeValue, TooltipCallback, VNodeLike } from '@number10/jsx-core';
|
|
2
|
+
import { IconTheme, PortableComponentPartialTheme } from './theme-types';
|
|
3
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
|
|
4
|
+
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
5
|
+
interface ButtonVariantTheme {
|
|
6
|
+
backgroundColor?: number | undefined;
|
|
7
|
+
backgroundAlpha?: number | undefined;
|
|
8
|
+
borderColor?: number | undefined;
|
|
9
|
+
borderWidth?: number | undefined;
|
|
10
|
+
cornerRadius?: number | undefined;
|
|
11
|
+
textStyle?: PortableTextStyle | undefined;
|
|
12
|
+
iconSize?: number | undefined;
|
|
13
|
+
iconTint?: number | undefined;
|
|
14
|
+
disabledColor?: number | undefined;
|
|
15
|
+
disabledTextColor?: string | undefined;
|
|
16
|
+
disabledIconTint?: number | undefined;
|
|
17
|
+
disabledAlpha?: number | undefined;
|
|
18
|
+
effect?: EffectName | undefined;
|
|
19
|
+
effectConfig?: EffectConfig | undefined;
|
|
20
|
+
/** Nested Text theme */
|
|
21
|
+
Text?: Partial<PortableTextStyle> | undefined;
|
|
22
|
+
/** Nested Icon theme */
|
|
23
|
+
Icon?: Partial<IconTheme> | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface ButtonTheme extends ButtonVariantTheme {
|
|
26
|
+
variant?: ButtonVariant | undefined;
|
|
27
|
+
size?: ButtonSize | undefined;
|
|
28
|
+
variants?: Partial<Record<ButtonVariant, ButtonVariantTheme>> | undefined;
|
|
29
|
+
sizes?: Partial<Record<ButtonSize, ButtonVariantTheme>> | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface ButtonProps {
|
|
32
|
+
children?: ChildrenType | undefined;
|
|
33
|
+
key?: string | number | undefined;
|
|
34
|
+
label?: string | number | undefined;
|
|
35
|
+
text?: string | number | undefined;
|
|
36
|
+
onClick?: (() => void) | undefined;
|
|
37
|
+
disabled?: boolean | undefined;
|
|
38
|
+
variant?: ButtonVariant | undefined;
|
|
39
|
+
size?: ButtonSize | undefined;
|
|
40
|
+
textStyle?: PortableTextStyle | undefined;
|
|
41
|
+
iconSize?: number | undefined;
|
|
42
|
+
disabledAlpha?: number | undefined;
|
|
43
|
+
width?: SizeValue | undefined;
|
|
44
|
+
height?: SizeValue | undefined;
|
|
45
|
+
maxWidth?: SizeValue | undefined;
|
|
46
|
+
maxHeight?: SizeValue | undefined;
|
|
47
|
+
cornerRadius?: number | undefined;
|
|
48
|
+
padding?: SizeValue | number | undefined;
|
|
49
|
+
theme?: PortableComponentPartialTheme<'Button'> | undefined;
|
|
50
|
+
onTouch?: ((data: GestureEventData) => void) | undefined;
|
|
51
|
+
onLongPress?: (() => void) | undefined;
|
|
52
|
+
onTouchMove?: ((data: GestureEventData) => void) | undefined;
|
|
53
|
+
longPressDuration?: number | undefined;
|
|
54
|
+
onTooltip?: TooltipCallback | undefined;
|
|
55
|
+
effect?: EffectName | undefined;
|
|
56
|
+
effectConfig?: EffectConfig | undefined;
|
|
57
|
+
alpha?: number | undefined;
|
|
58
|
+
}
|
|
59
|
+
export declare function Button(props: ButtonProps): VNodeLike;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"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"}
|