@xaui/native 0.9.1-alpha.10 → 0.9.1-alpha.12
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/{chunk-7XGOXTGT.js → chunk-5TKZV7IC.js} +3 -19
- package/dist/chunk-CTULMYVI.cjs +545 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-EMXBFHIP.js} +20 -0
- package/dist/{chunk-2FEDC7U5.cjs → chunk-ESOOMXV4.cjs} +33 -49
- package/dist/{chunk-3QBT3Q65.cjs → chunk-FDUI4IAM.cjs} +22 -2
- package/dist/chunk-GZIOB63O.cjs +1044 -0
- package/dist/chunk-KLHHV4RU.js +1010 -0
- package/dist/chunk-SKVKAJ5Y.js +507 -0
- package/dist/components/button/index.cjs +4 -4
- package/dist/components/button/index.d.cts +147 -8
- package/dist/components/button/index.d.ts +147 -8
- package/dist/components/button/index.js +3 -3
- package/dist/{create-recipe-Dn9kj5Rs.d.ts → create-recipe-3OPwcC6P.d.ts} +81 -21
- package/dist/{create-recipe-BjSP0zL_.d.cts → create-recipe-oiLAlJ4u.d.cts} +81 -21
- package/dist/index.cjs +28 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -12
- package/dist/system/index.cjs +24 -4
- package/dist/system/index.d.cts +159 -31
- package/dist/system/index.d.ts +159 -31
- package/dist/system/index.js +31 -11
- package/dist/theme/index.cjs +3 -3
- package/dist/theme/index.js +2 -2
- package/package.json +8 -8
- package/dist/chunk-66OVPWF4.js +0 -716
- package/dist/chunk-7D262JCJ.cjs +0 -716
- package/dist/chunk-EQGTD5F6.js +0 -353
- package/dist/chunk-ERCOAOO6.cjs +0 -353
- /package/dist/{chunk-LMUPNKPH.cjs → chunk-2FOEFUPM.cjs} +0 -0
- /package/dist/{chunk-3TIDEII6.js → chunk-TO6DAGFB.js} +0 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { Icon, PressableFeedback, childrenToString, createRecipe, createSlotContext, useStyleProps } from "./chunk-KLHHV4RU.js";
|
|
2
|
+
import { useXAUITheme } from "./chunk-EMXBFHIP.js";
|
|
3
|
+
|
|
4
|
+
// src/components/button/button.context.ts
|
|
5
|
+
var [ButtonProvider, useButton] = createSlotContext("Button");
|
|
6
|
+
|
|
7
|
+
// src/components/button/button-icon.tsx
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function ButtonIcon({
|
|
10
|
+
size,
|
|
11
|
+
color,
|
|
12
|
+
...rest
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
icon
|
|
16
|
+
} = useButton();
|
|
17
|
+
return /* @__PURE__ */jsx(Icon, {
|
|
18
|
+
size: size ?? icon.size,
|
|
19
|
+
color: color ?? icon.color,
|
|
20
|
+
...rest
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
ButtonIcon.displayName = "XAUI.Button.Icon";
|
|
24
|
+
|
|
25
|
+
// src/components/button/button-label.tsx
|
|
26
|
+
import { forwardRef } from "react";
|
|
27
|
+
import { Text } from "react-native";
|
|
28
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
29
|
+
var ButtonLabel = forwardRef(function ButtonLabel2({
|
|
30
|
+
children,
|
|
31
|
+
style,
|
|
32
|
+
numberOfLines = 1,
|
|
33
|
+
...props
|
|
34
|
+
}, ref) {
|
|
35
|
+
const {
|
|
36
|
+
labelStyle
|
|
37
|
+
} = useButton();
|
|
38
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
39
|
+
return /* @__PURE__ */jsx2(Text, {
|
|
40
|
+
ref,
|
|
41
|
+
numberOfLines,
|
|
42
|
+
style: [labelStyle, styleProps, style],
|
|
43
|
+
...rest,
|
|
44
|
+
children
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
ButtonLabel.displayName = "XAUI.Button.Label";
|
|
48
|
+
|
|
49
|
+
// src/components/button/button-spinner.tsx
|
|
50
|
+
import { useEffect } from "react";
|
|
51
|
+
import { View } from "react-native";
|
|
52
|
+
import Animated, { Easing, cancelAnimation, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from "react-native-reanimated";
|
|
53
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
54
|
+
var ROTATION_DURATION = 800;
|
|
55
|
+
function ButtonSpinner({
|
|
56
|
+
style,
|
|
57
|
+
animation = true,
|
|
58
|
+
...props
|
|
59
|
+
}) {
|
|
60
|
+
const {
|
|
61
|
+
spinnerStyle
|
|
62
|
+
} = useButton();
|
|
63
|
+
const [styleProps] = useStyleProps(props);
|
|
64
|
+
const ringStyle = [spinnerStyle, styleProps, style];
|
|
65
|
+
if (!animation) return /* @__PURE__ */jsx3(View, {
|
|
66
|
+
style: ringStyle
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */jsx3(SpinningRing, {
|
|
69
|
+
style: ringStyle
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
ButtonSpinner.displayName = "XAUI.Button.Spinner";
|
|
73
|
+
const _worklet_17512781929349_init_data = {
|
|
74
|
+
code: "function chunkSKVKAJ5YJs1(){const{angle}=this.__closure;return{transform:[{rotate:angle.value+\"deg\"}]};}",
|
|
75
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-SKVKAJ5Y.js",
|
|
76
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkSKVKAJ5YJs1\",\"angle\",\"__closure\",\"transform\",\"rotate\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-SKVKAJ5Y.js\"],\"mappings\":\"AA0EyC,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,OAAAC,SAAA,CAE3C,MAAO,CAAEC,SAAS,CAAE,CAAC,CAAEC,MAAM,CAAKH,KAAK,CAACI,KAAK,MAAM,CAAC,CAAE,CAAC,CACzD\",\"ignoreList\":[]}"
|
|
77
|
+
};
|
|
78
|
+
function SpinningRing({
|
|
79
|
+
style
|
|
80
|
+
}) {
|
|
81
|
+
const angle = useSharedValue(0);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
angle.value = withRepeat(withTiming(360, {
|
|
84
|
+
duration: ROTATION_DURATION,
|
|
85
|
+
easing: Easing.linear
|
|
86
|
+
}), -1, false);
|
|
87
|
+
return () => cancelAnimation(angle);
|
|
88
|
+
}, [angle]);
|
|
89
|
+
const animatedStyle = useAnimatedStyle(function chunkSKVKAJ5YJs1Factory({
|
|
90
|
+
_worklet_17512781929349_init_data,
|
|
91
|
+
angle
|
|
92
|
+
}) {
|
|
93
|
+
const _e = [new global.Error(), -2, -27];
|
|
94
|
+
const chunkSKVKAJ5YJs1 = function () {
|
|
95
|
+
return {
|
|
96
|
+
transform: [{
|
|
97
|
+
rotate: `${angle.value}deg`
|
|
98
|
+
}]
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
chunkSKVKAJ5YJs1.__closure = {
|
|
102
|
+
angle
|
|
103
|
+
};
|
|
104
|
+
chunkSKVKAJ5YJs1.__workletHash = 17512781929349;
|
|
105
|
+
chunkSKVKAJ5YJs1.__pluginVersion = "0.7.4";
|
|
106
|
+
chunkSKVKAJ5YJs1.__initData = _worklet_17512781929349_init_data;
|
|
107
|
+
chunkSKVKAJ5YJs1.__stackDetails = _e;
|
|
108
|
+
return chunkSKVKAJ5YJs1;
|
|
109
|
+
}({
|
|
110
|
+
_worklet_17512781929349_init_data,
|
|
111
|
+
angle
|
|
112
|
+
}), [angle]);
|
|
113
|
+
return /* @__PURE__ */jsx3(Animated.View, {
|
|
114
|
+
style: [style, animatedStyle]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/components/button/button.tsx
|
|
119
|
+
import { forwardRef as forwardRef2, useMemo } from "react";
|
|
120
|
+
import { StyleSheet } from "react-native";
|
|
121
|
+
|
|
122
|
+
// src/hooks/use-press-state.ts
|
|
123
|
+
import { useCallback, useRef, useState } from "react";
|
|
124
|
+
function usePressState(handlers = {}) {
|
|
125
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
126
|
+
const latest = useRef(handlers);
|
|
127
|
+
latest.current = handlers;
|
|
128
|
+
const onPressIn = useCallback(event => {
|
|
129
|
+
setIsPressed(true);
|
|
130
|
+
latest.current.onPressIn?.(event);
|
|
131
|
+
}, []);
|
|
132
|
+
const onPressOut = useCallback(event => {
|
|
133
|
+
setIsPressed(false);
|
|
134
|
+
latest.current.onPressOut?.(event);
|
|
135
|
+
}, []);
|
|
136
|
+
const press = useRef({
|
|
137
|
+
onPressIn,
|
|
138
|
+
onPressOut
|
|
139
|
+
}).current;
|
|
140
|
+
return [isPressed, press];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/utils/warn-dev.ts
|
|
144
|
+
function warnDev(message) {
|
|
145
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
146
|
+
console.warn(`XAUI: ${message}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/components/button/button.recipe.ts
|
|
150
|
+
var SLOTS = ["root", "label", "icon", "spinner"];
|
|
151
|
+
var VARIANT_TOKENS = {
|
|
152
|
+
primary: {
|
|
153
|
+
bg: "accent",
|
|
154
|
+
bgPressed: "accentPressed",
|
|
155
|
+
fg: "accentForeground"
|
|
156
|
+
},
|
|
157
|
+
secondary: {
|
|
158
|
+
bg: "default",
|
|
159
|
+
bgPressed: "defaultPressed",
|
|
160
|
+
fg: "defaultForeground"
|
|
161
|
+
},
|
|
162
|
+
tertiary: {
|
|
163
|
+
border: "border",
|
|
164
|
+
bgPressed: "defaultSoftPressed",
|
|
165
|
+
fg: "foreground"
|
|
166
|
+
},
|
|
167
|
+
ghost: {
|
|
168
|
+
bgPressed: "defaultSoftPressed",
|
|
169
|
+
fg: "foreground"
|
|
170
|
+
},
|
|
171
|
+
success: {
|
|
172
|
+
bg: "success",
|
|
173
|
+
bgPressed: "successPressed",
|
|
174
|
+
fg: "successForeground"
|
|
175
|
+
},
|
|
176
|
+
"success-soft": {
|
|
177
|
+
bg: "successSoft",
|
|
178
|
+
bgPressed: "successSoftPressed",
|
|
179
|
+
fg: "successSoftForeground"
|
|
180
|
+
},
|
|
181
|
+
warning: {
|
|
182
|
+
bg: "warning",
|
|
183
|
+
bgPressed: "warningPressed",
|
|
184
|
+
fg: "warningForeground"
|
|
185
|
+
},
|
|
186
|
+
"warning-soft": {
|
|
187
|
+
bg: "warningSoft",
|
|
188
|
+
bgPressed: "warningSoftPressed",
|
|
189
|
+
fg: "warningSoftForeground"
|
|
190
|
+
},
|
|
191
|
+
danger: {
|
|
192
|
+
bg: "danger",
|
|
193
|
+
bgPressed: "dangerPressed",
|
|
194
|
+
fg: "dangerForeground"
|
|
195
|
+
},
|
|
196
|
+
"danger-soft": {
|
|
197
|
+
bg: "dangerSoft",
|
|
198
|
+
bgPressed: "dangerSoftPressed",
|
|
199
|
+
fg: "dangerSoftForeground"
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
function ring(theme, size) {
|
|
203
|
+
return {
|
|
204
|
+
width: size,
|
|
205
|
+
height: size,
|
|
206
|
+
borderRadius: size / 2,
|
|
207
|
+
borderWidth: theme.borderWidth.default * 2,
|
|
208
|
+
borderTopColor: "transparent"
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function sizeAxis(step) {
|
|
212
|
+
const {
|
|
213
|
+
size,
|
|
214
|
+
padding,
|
|
215
|
+
gap,
|
|
216
|
+
glyph,
|
|
217
|
+
radius
|
|
218
|
+
} = step;
|
|
219
|
+
return theme => ({
|
|
220
|
+
root: {
|
|
221
|
+
height: theme.controlHeights[size],
|
|
222
|
+
paddingHorizontal: theme.spacing(padding),
|
|
223
|
+
gap: theme.spacing(gap),
|
|
224
|
+
borderRadius: theme.radius[radius]
|
|
225
|
+
},
|
|
226
|
+
label: {
|
|
227
|
+
fontSize: theme.fontSizes[size],
|
|
228
|
+
lineHeight: theme.lineHeights[size]
|
|
229
|
+
},
|
|
230
|
+
icon: {
|
|
231
|
+
fontSize: theme.fontSizes[glyph]
|
|
232
|
+
},
|
|
233
|
+
spinner: ring(theme, theme.fontSizes[glyph])
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
var buttonRecipe = createRecipe({
|
|
237
|
+
slots: SLOTS,
|
|
238
|
+
base: theme => ({
|
|
239
|
+
root: {
|
|
240
|
+
flexDirection: "row",
|
|
241
|
+
alignItems: "center",
|
|
242
|
+
justifyContent: "center",
|
|
243
|
+
borderWidth: 0,
|
|
244
|
+
// iOS's squircle. Free on Android, and it is what makes a large radius read as a
|
|
245
|
+
// shape rather than as two arcs meeting a straight edge.
|
|
246
|
+
borderCurve: "continuous"
|
|
247
|
+
},
|
|
248
|
+
label: {
|
|
249
|
+
fontFamily: theme.fontFamilies.body,
|
|
250
|
+
fontWeight: theme.fontWeights.medium
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
variantTokens: VARIANT_TOKENS,
|
|
254
|
+
/**
|
|
255
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
256
|
+
* the *presence* of the border role rather than a per-variant flag — `tertiary` is the
|
|
257
|
+
* only variant that names one, and that fact is already in the table above.
|
|
258
|
+
*/
|
|
259
|
+
paint: (theme, colors) => ({
|
|
260
|
+
root: {
|
|
261
|
+
backgroundColor: colors.bg,
|
|
262
|
+
borderColor: colors.border,
|
|
263
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
264
|
+
},
|
|
265
|
+
label: {
|
|
266
|
+
color: colors.fg
|
|
267
|
+
},
|
|
268
|
+
icon: {
|
|
269
|
+
color: colors.fg
|
|
270
|
+
},
|
|
271
|
+
spinner: {
|
|
272
|
+
borderColor: colors.fg
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
/**
|
|
276
|
+
* Declaration order is application order: `radius` overrides the radius `size` set, and
|
|
277
|
+
* `isIconOnly` overrides its padding. Both are axes rather than a static sheet merged
|
|
278
|
+
* at the call site, so they stay inside the cache key and a press still allocates
|
|
279
|
+
* nothing.
|
|
280
|
+
*/
|
|
281
|
+
variants: {
|
|
282
|
+
size: {
|
|
283
|
+
xs: sizeAxis({
|
|
284
|
+
size: "xs",
|
|
285
|
+
padding: 3,
|
|
286
|
+
gap: 1,
|
|
287
|
+
glyph: "sm",
|
|
288
|
+
radius: "3xl"
|
|
289
|
+
}),
|
|
290
|
+
sm: sizeAxis({
|
|
291
|
+
size: "sm",
|
|
292
|
+
padding: 3.5,
|
|
293
|
+
gap: 1.5,
|
|
294
|
+
glyph: "md",
|
|
295
|
+
radius: "3xl"
|
|
296
|
+
}),
|
|
297
|
+
md: sizeAxis({
|
|
298
|
+
size: "md",
|
|
299
|
+
padding: 4,
|
|
300
|
+
gap: 2,
|
|
301
|
+
glyph: "lg",
|
|
302
|
+
radius: "3xl"
|
|
303
|
+
}),
|
|
304
|
+
lg: sizeAxis({
|
|
305
|
+
size: "lg",
|
|
306
|
+
padding: 5,
|
|
307
|
+
gap: 2.5,
|
|
308
|
+
glyph: "xl",
|
|
309
|
+
radius: "4xl"
|
|
310
|
+
})
|
|
311
|
+
},
|
|
312
|
+
radius: {
|
|
313
|
+
xs: t => ({
|
|
314
|
+
root: {
|
|
315
|
+
borderRadius: t.radius.xs
|
|
316
|
+
}
|
|
317
|
+
}),
|
|
318
|
+
sm: t => ({
|
|
319
|
+
root: {
|
|
320
|
+
borderRadius: t.radius.sm
|
|
321
|
+
}
|
|
322
|
+
}),
|
|
323
|
+
md: t => ({
|
|
324
|
+
root: {
|
|
325
|
+
borderRadius: t.radius.md
|
|
326
|
+
}
|
|
327
|
+
}),
|
|
328
|
+
lg: t => ({
|
|
329
|
+
root: {
|
|
330
|
+
borderRadius: t.radius.lg
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
xl: t => ({
|
|
334
|
+
root: {
|
|
335
|
+
borderRadius: t.radius.xl
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
"2xl": t => ({
|
|
339
|
+
root: {
|
|
340
|
+
borderRadius: t.radius["2xl"]
|
|
341
|
+
}
|
|
342
|
+
}),
|
|
343
|
+
"3xl": t => ({
|
|
344
|
+
root: {
|
|
345
|
+
borderRadius: t.radius["3xl"]
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
348
|
+
"4xl": t => ({
|
|
349
|
+
root: {
|
|
350
|
+
borderRadius: t.radius["4xl"]
|
|
351
|
+
}
|
|
352
|
+
}),
|
|
353
|
+
field: t => ({
|
|
354
|
+
root: {
|
|
355
|
+
borderRadius: t.radius.field
|
|
356
|
+
}
|
|
357
|
+
}),
|
|
358
|
+
full: t => ({
|
|
359
|
+
root: {
|
|
360
|
+
borderRadius: t.radius.full
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
},
|
|
364
|
+
// A square on a fixed height. No width is computed, and none needs to be.
|
|
365
|
+
isIconOnly: {
|
|
366
|
+
true: () => ({
|
|
367
|
+
root: {
|
|
368
|
+
paddingHorizontal: 0,
|
|
369
|
+
aspectRatio: 1
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
/**
|
|
375
|
+
* The pressed colour lives here rather than in a `PressableFeedback.Highlight`, because
|
|
376
|
+
* a control picks one treatment or the other — both, and a pressed button darkens
|
|
377
|
+
* twice. This one is the variant's own `…Pressed` token, so the press reads as the
|
|
378
|
+
* button's colour going down rather than as a neutral film over it, and a tinted button
|
|
379
|
+
* presses through the same OKLab formula as a token one.
|
|
380
|
+
*/
|
|
381
|
+
states: {
|
|
382
|
+
pressed: (_theme, colors) => ({
|
|
383
|
+
root: {
|
|
384
|
+
backgroundColor: colors.bgPressed
|
|
385
|
+
}
|
|
386
|
+
}),
|
|
387
|
+
disabled: theme => ({
|
|
388
|
+
root: {
|
|
389
|
+
opacity: theme.opacity.disabled
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
},
|
|
393
|
+
defaultVariants: {
|
|
394
|
+
variant: "primary",
|
|
395
|
+
size: "md"
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// src/components/button/button.utils.ts
|
|
400
|
+
import { Children, isValidElement } from "react";
|
|
401
|
+
function containsElementOfType(children, type) {
|
|
402
|
+
return Children.toArray(children).some(child => isValidElement(child) && child.type === type);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/components/button/button.tsx
|
|
406
|
+
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
407
|
+
var ButtonRoot = forwardRef2(function Button({
|
|
408
|
+
children,
|
|
409
|
+
variant,
|
|
410
|
+
size,
|
|
411
|
+
radius,
|
|
412
|
+
color,
|
|
413
|
+
isDisabled = false,
|
|
414
|
+
isLoading = false,
|
|
415
|
+
isIconOnly = false,
|
|
416
|
+
asChild = false,
|
|
417
|
+
accessibilityRole = "button",
|
|
418
|
+
accessibilityState,
|
|
419
|
+
style,
|
|
420
|
+
onPressIn,
|
|
421
|
+
onPressOut,
|
|
422
|
+
...props
|
|
423
|
+
}, ref) {
|
|
424
|
+
const theme = useXAUITheme();
|
|
425
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
426
|
+
const [isPressed, press] = usePressState({
|
|
427
|
+
onPressIn,
|
|
428
|
+
onPressOut
|
|
429
|
+
});
|
|
430
|
+
const selection = {
|
|
431
|
+
variant,
|
|
432
|
+
size,
|
|
433
|
+
radius,
|
|
434
|
+
isIconOnly: isIconOnly ? "true" : void 0
|
|
435
|
+
};
|
|
436
|
+
const states = {
|
|
437
|
+
pressed: isPressed,
|
|
438
|
+
disabled: isDisabled || isLoading
|
|
439
|
+
};
|
|
440
|
+
const styles = buttonRecipe.resolve({
|
|
441
|
+
theme,
|
|
442
|
+
selection,
|
|
443
|
+
states
|
|
444
|
+
});
|
|
445
|
+
const tint = color ? buttonRecipe.tint({
|
|
446
|
+
theme,
|
|
447
|
+
color,
|
|
448
|
+
selection,
|
|
449
|
+
states
|
|
450
|
+
}) : void 0;
|
|
451
|
+
const context = useMemo(() => {
|
|
452
|
+
const icon = StyleSheet.flatten([styles.icon, tint?.icon]);
|
|
453
|
+
return {
|
|
454
|
+
labelStyle: tint ? [styles.label, tint.label] : styles.label,
|
|
455
|
+
spinnerStyle: tint ? [styles.spinner, tint.spinner] : styles.spinner,
|
|
456
|
+
icon: {
|
|
457
|
+
size: icon.fontSize,
|
|
458
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
459
|
+
// hand to a third-party component expecting a string.
|
|
460
|
+
color: typeof icon.color === "string" ? icon.color : void 0
|
|
461
|
+
},
|
|
462
|
+
isDisabled,
|
|
463
|
+
isLoading
|
|
464
|
+
};
|
|
465
|
+
}, [styles, tint, isDisabled, isLoading]);
|
|
466
|
+
const rootStyle = [styles.root, tint?.root, styleProps, typeof style === "function" ? style({
|
|
467
|
+
pressed: isPressed
|
|
468
|
+
}) : style];
|
|
469
|
+
const text = childrenToString(children);
|
|
470
|
+
const showSpinner = isLoading && !containsElementOfType(children, ButtonSpinner);
|
|
471
|
+
if (isIconOnly && !rest.accessibilityLabel && !rest["aria-label"]) {
|
|
472
|
+
warnDev("Button: an icon-only button needs an `accessibilityLabel` \u2014 there is no text for a screen reader to read, so it announces as an unlabelled button.");
|
|
473
|
+
}
|
|
474
|
+
return /* @__PURE__ */jsx4(ButtonProvider, {
|
|
475
|
+
value: context,
|
|
476
|
+
children: /* @__PURE__ */jsx4(PressableFeedback, {
|
|
477
|
+
ref,
|
|
478
|
+
isPressed,
|
|
479
|
+
isDisabled: isDisabled || isLoading,
|
|
480
|
+
asChild,
|
|
481
|
+
accessibilityRole,
|
|
482
|
+
accessibilityState: {
|
|
483
|
+
disabled: isDisabled,
|
|
484
|
+
busy: isLoading,
|
|
485
|
+
...accessibilityState
|
|
486
|
+
},
|
|
487
|
+
...rest,
|
|
488
|
+
style: rootStyle,
|
|
489
|
+
onPressIn: press.onPressIn,
|
|
490
|
+
onPressOut: press.onPressOut,
|
|
491
|
+
children: asChild ? children : /* @__PURE__ */jsxs(Fragment, {
|
|
492
|
+
children: [showSpinner ? /* @__PURE__ */jsx4(ButtonSpinner, {}) : null, text !== null ? /* @__PURE__ */jsx4(ButtonLabel, {
|
|
493
|
+
children: text
|
|
494
|
+
}) : children]
|
|
495
|
+
})
|
|
496
|
+
})
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
ButtonRoot.displayName = "XAUI.Button.Root";
|
|
500
|
+
|
|
501
|
+
// src/components/button/index.ts
|
|
502
|
+
var Button2 = Object.assign(ButtonRoot, {
|
|
503
|
+
Label: ButtonLabel,
|
|
504
|
+
Icon: ButtonIcon,
|
|
505
|
+
Spinner: ButtonSpinner
|
|
506
|
+
});
|
|
507
|
+
export { useButton, usePressState, warnDev, buttonRecipe, Button2 as Button };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../../chunk-
|
|
7
|
-
require('../../chunk-
|
|
5
|
+
var _chunkCTULMYVIcjs = require('../../chunk-CTULMYVI.cjs');
|
|
6
|
+
require('../../chunk-GZIOB63O.cjs');
|
|
7
|
+
require('../../chunk-FDUI4IAM.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.Button =
|
|
12
|
+
exports.Button = _chunkCTULMYVIcjs.Button; exports.buttonRecipe = _chunkCTULMYVIcjs.buttonRecipe; exports.useButton = _chunkCTULMYVIcjs.useButton;
|