@xaui/native 0.9.1-alpha.1 → 0.9.1-alpha.10

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.
@@ -0,0 +1,353 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+ var _chunk7D262JCJcjs = require('./chunk-7D262JCJ.cjs');
8
+
9
+
10
+ var _chunk3QBT3Q65cjs = require('./chunk-3QBT3Q65.cjs');
11
+
12
+ // src/components/button/button.context.ts
13
+ var [ButtonProvider, useButton] = _chunk7D262JCJcjs.createSlotContext.call(void 0, "Button");
14
+
15
+ // src/components/button/button-icon.tsx
16
+ var _jsxruntime = require('react/jsx-runtime');
17
+ function ButtonIcon({ size, color, ...rest }) {
18
+ const { icon } = useButton();
19
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk7D262JCJcjs.Icon, { size: _nullishCoalesce(size, () => ( icon.size)), color: _nullishCoalesce(color, () => ( icon.color)), ...rest });
20
+ }
21
+ ButtonIcon.displayName = "XAUI.Button.Icon";
22
+
23
+ // src/components/button/button-label.tsx
24
+ var _react = require('react');
25
+ var _reactnative = require('react-native');
26
+
27
+ var ButtonLabel = _react.forwardRef.call(void 0, function ButtonLabel2({ children, style, numberOfLines = 1, ...rest }, ref) {
28
+ const { labelStyle } = useButton();
29
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
30
+ _reactnative.Text,
31
+ {
32
+ ref,
33
+ numberOfLines,
34
+ style: [labelStyle, style],
35
+ ...rest,
36
+ children
37
+ }
38
+ );
39
+ });
40
+ ButtonLabel.displayName = "XAUI.Button.Label";
41
+
42
+ // src/components/button/button-spinner.tsx
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+ var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
53
+
54
+ var ROTATION_DURATION = 800;
55
+ function ButtonSpinner({ style, animation = true }) {
56
+ const { spinnerStyle } = useButton();
57
+ if (!animation) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: [spinnerStyle, style] });
58
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SpinningRing, { style: [spinnerStyle, style] });
59
+ }
60
+ ButtonSpinner.displayName = "XAUI.Button.Spinner";
61
+ function SpinningRing({ style }) {
62
+ const angle = _reactnativereanimated.useSharedValue.call(void 0, 0);
63
+ _react.useEffect.call(void 0, () => {
64
+ angle.value = _reactnativereanimated.withRepeat.call(void 0,
65
+ _reactnativereanimated.withTiming.call(void 0, 360, { duration: ROTATION_DURATION, easing: _reactnativereanimated.Easing.linear }),
66
+ -1,
67
+ false
68
+ );
69
+ return () => _reactnativereanimated.cancelAnimation.call(void 0, angle);
70
+ }, [angle]);
71
+ const animatedStyle = _reactnativereanimated.useAnimatedStyle.call(void 0,
72
+ () => ({ transform: [{ rotate: `${angle.value}deg` }] }),
73
+ [angle]
74
+ );
75
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, { style: [style, animatedStyle] });
76
+ }
77
+
78
+ // src/components/button/button.tsx
79
+
80
+
81
+
82
+ // src/hooks/use-press-state.ts
83
+
84
+ function usePressState(handlers = {}) {
85
+ const [isPressed, setIsPressed] = _react.useState.call(void 0, false);
86
+ const latest = _react.useRef.call(void 0, handlers);
87
+ latest.current = handlers;
88
+ const onPressIn = _react.useCallback.call(void 0, (event) => {
89
+ setIsPressed(true);
90
+ _optionalChain([latest, 'access', _ => _.current, 'access', _2 => _2.onPressIn, 'optionalCall', _3 => _3(event)]);
91
+ }, []);
92
+ const onPressOut = _react.useCallback.call(void 0, (event) => {
93
+ setIsPressed(false);
94
+ _optionalChain([latest, 'access', _4 => _4.current, 'access', _5 => _5.onPressOut, 'optionalCall', _6 => _6(event)]);
95
+ }, []);
96
+ const press = _react.useRef.call(void 0, { onPressIn, onPressOut }).current;
97
+ return [isPressed, press];
98
+ }
99
+
100
+ // src/utils/warn-dev.ts
101
+ function warnDev(message) {
102
+ if (typeof __DEV__ !== "undefined" && !__DEV__) return;
103
+ console.warn(`XAUI: ${message}`);
104
+ }
105
+
106
+ // src/components/button/button.recipe.ts
107
+ var SLOTS = ["root", "label", "icon", "spinner"];
108
+ var VARIANT_TOKENS = {
109
+ primary: { bg: "accent", bgPressed: "accentPressed", fg: "accentForeground" },
110
+ secondary: { bg: "default", bgPressed: "defaultPressed", fg: "defaultForeground" },
111
+ tertiary: {
112
+ border: "border",
113
+ bgPressed: "defaultSoftPressed",
114
+ fg: "foreground"
115
+ },
116
+ ghost: { bgPressed: "defaultSoftPressed", fg: "foreground" },
117
+ success: { bg: "success", bgPressed: "successPressed", fg: "successForeground" },
118
+ "success-soft": {
119
+ bg: "successSoft",
120
+ bgPressed: "successSoftPressed",
121
+ fg: "successSoftForeground"
122
+ },
123
+ warning: { bg: "warning", bgPressed: "warningPressed", fg: "warningForeground" },
124
+ "warning-soft": {
125
+ bg: "warningSoft",
126
+ bgPressed: "warningSoftPressed",
127
+ fg: "warningSoftForeground"
128
+ },
129
+ danger: { bg: "danger", bgPressed: "dangerPressed", fg: "dangerForeground" },
130
+ "danger-soft": {
131
+ bg: "dangerSoft",
132
+ bgPressed: "dangerSoftPressed",
133
+ fg: "dangerSoftForeground"
134
+ }
135
+ };
136
+ function ring(theme, size) {
137
+ return {
138
+ width: size,
139
+ height: size,
140
+ borderRadius: size / 2,
141
+ borderWidth: theme.borderWidth.default * 2,
142
+ borderTopColor: "transparent"
143
+ };
144
+ }
145
+ function sizeAxis(step) {
146
+ const { size, padding, gap, glyph, radius } = step;
147
+ return (theme) => ({
148
+ root: {
149
+ height: theme.controlHeights[size],
150
+ paddingHorizontal: theme.spacing(padding),
151
+ gap: theme.spacing(gap),
152
+ borderRadius: theme.radius[radius]
153
+ },
154
+ label: {
155
+ fontSize: theme.fontSizes[size],
156
+ lineHeight: theme.lineHeights[size]
157
+ },
158
+ icon: { fontSize: theme.fontSizes[glyph] },
159
+ spinner: ring(theme, theme.fontSizes[glyph])
160
+ });
161
+ }
162
+ var buttonRecipe = _chunk7D262JCJcjs.createRecipe.call(void 0, {
163
+ slots: SLOTS,
164
+ base: (theme) => ({
165
+ root: {
166
+ flexDirection: "row",
167
+ alignItems: "center",
168
+ justifyContent: "center",
169
+ borderWidth: 0,
170
+ // iOS's squircle. Free on Android, and it is what makes a large radius read as a
171
+ // shape rather than as two arcs meeting a straight edge.
172
+ borderCurve: "continuous"
173
+ },
174
+ label: {
175
+ fontFamily: theme.fontFamilies.body,
176
+ fontWeight: theme.fontWeights.medium
177
+ }
178
+ }),
179
+ variantTokens: VARIANT_TOKENS,
180
+ /**
181
+ * Where the variant's colours land, for every variant at once. The border width follows
182
+ * the *presence* of the border role rather than a per-variant flag — `tertiary` is the
183
+ * only variant that names one, and that fact is already in the table above.
184
+ */
185
+ paint: (theme, colors) => ({
186
+ root: {
187
+ backgroundColor: colors.bg,
188
+ borderColor: colors.border,
189
+ borderWidth: colors.border ? theme.borderWidth.default : 0
190
+ },
191
+ label: { color: colors.fg },
192
+ icon: { color: colors.fg },
193
+ spinner: { borderColor: colors.fg }
194
+ }),
195
+ /**
196
+ * Declaration order is application order: `radius` overrides the radius `size` set, and
197
+ * `isIconOnly` overrides its padding. Both are axes rather than a static sheet merged
198
+ * at the call site, so they stay inside the cache key and a press still allocates
199
+ * nothing.
200
+ */
201
+ variants: {
202
+ size: {
203
+ xs: sizeAxis({ size: "xs", padding: 3, gap: 1, glyph: "sm", radius: "3xl" }),
204
+ sm: sizeAxis({
205
+ size: "sm",
206
+ padding: 3.5,
207
+ gap: 1.5,
208
+ glyph: "md",
209
+ radius: "3xl"
210
+ }),
211
+ md: sizeAxis({ size: "md", padding: 4, gap: 2, glyph: "lg", radius: "3xl" }),
212
+ lg: sizeAxis({ size: "lg", padding: 5, gap: 2.5, glyph: "xl", radius: "4xl" })
213
+ },
214
+ radius: {
215
+ xs: (t) => ({ root: { borderRadius: t.radius.xs } }),
216
+ sm: (t) => ({ root: { borderRadius: t.radius.sm } }),
217
+ md: (t) => ({ root: { borderRadius: t.radius.md } }),
218
+ lg: (t) => ({ root: { borderRadius: t.radius.lg } }),
219
+ xl: (t) => ({ root: { borderRadius: t.radius.xl } }),
220
+ "2xl": (t) => ({ root: { borderRadius: t.radius["2xl"] } }),
221
+ "3xl": (t) => ({ root: { borderRadius: t.radius["3xl"] } }),
222
+ "4xl": (t) => ({ root: { borderRadius: t.radius["4xl"] } }),
223
+ field: (t) => ({ root: { borderRadius: t.radius.field } }),
224
+ full: (t) => ({ root: { borderRadius: t.radius.full } })
225
+ },
226
+ // A square on a fixed height. No width is computed, and none needs to be.
227
+ isIconOnly: {
228
+ true: () => ({ root: { paddingHorizontal: 0, aspectRatio: 1 } })
229
+ }
230
+ },
231
+ /**
232
+ * The pressed colour lives here rather than in a `PressableFeedback.Highlight`, because
233
+ * a control picks one treatment or the other — both, and a pressed button darkens
234
+ * twice. This one is the variant's own `…Pressed` token, so the press reads as the
235
+ * button's colour going down rather than as a neutral film over it, and a tinted button
236
+ * presses through the same OKLab formula as a token one.
237
+ */
238
+ states: {
239
+ pressed: (_theme, colors) => ({ root: { backgroundColor: colors.bgPressed } }),
240
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
241
+ },
242
+ defaultVariants: { variant: "primary", size: "md" }
243
+ });
244
+
245
+ // src/components/button/button.utils.ts
246
+
247
+ function containsElementOfType(children, type) {
248
+ return _react.Children.toArray(children).some(
249
+ (child) => _react.isValidElement.call(void 0, child) && child.type === type
250
+ );
251
+ }
252
+
253
+ // src/components/button/button.tsx
254
+
255
+ var ButtonRoot = _react.forwardRef.call(void 0, function Button({
256
+ children,
257
+ variant,
258
+ size,
259
+ radius,
260
+ color,
261
+ isDisabled = false,
262
+ isLoading = false,
263
+ isIconOnly = false,
264
+ asChild = false,
265
+ // `scale` and not `scale-highlight`: the recipe's `pressed` state already paints the
266
+ // variant's own pressed colour, and a neutral wash on top would darken it twice.
267
+ feedbackVariant = "scale",
268
+ accessibilityRole = "button",
269
+ accessibilityState,
270
+ style,
271
+ onPressIn,
272
+ onPressOut,
273
+ ...rest
274
+ }, ref) {
275
+ const theme = _chunk3QBT3Q65cjs.useXAUITheme.call(void 0, );
276
+ const [isPressed, press] = usePressState({ onPressIn, onPressOut });
277
+ const selection = {
278
+ variant,
279
+ size,
280
+ radius,
281
+ isIconOnly: isIconOnly ? "true" : void 0
282
+ };
283
+ const states = { pressed: isPressed, disabled: isDisabled || isLoading };
284
+ const styles = buttonRecipe.resolve({ theme, selection, states });
285
+ const tint = color ? buttonRecipe.tint({ theme, color, selection, states }) : void 0;
286
+ const context = _react.useMemo.call(void 0, () => {
287
+ const icon = _reactnative.StyleSheet.flatten([styles.icon, _optionalChain([tint, 'optionalAccess', _7 => _7.icon])]);
288
+ return {
289
+ labelStyle: tint ? [styles.label, tint.label] : styles.label,
290
+ spinnerStyle: tint ? [styles.spinner, tint.spinner] : styles.spinner,
291
+ icon: {
292
+ size: icon.fontSize,
293
+ // `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
294
+ // hand to a third-party component expecting a string.
295
+ color: typeof icon.color === "string" ? icon.color : void 0
296
+ },
297
+ isDisabled,
298
+ isLoading
299
+ };
300
+ }, [styles, tint, isDisabled, isLoading]);
301
+ const rootStyle = [
302
+ styles.root,
303
+ _optionalChain([tint, 'optionalAccess', _8 => _8.root]),
304
+ typeof style === "function" ? style({ pressed: isPressed }) : style
305
+ ];
306
+ const text = _chunk7D262JCJcjs.childrenToString.call(void 0, children);
307
+ const showSpinner = isLoading && !containsElementOfType(children, ButtonSpinner);
308
+ if (isIconOnly && !rest.accessibilityLabel && !rest["aria-label"]) {
309
+ warnDev(
310
+ "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."
311
+ );
312
+ }
313
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ButtonProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
314
+ _chunk7D262JCJcjs.PressableFeedback,
315
+ {
316
+ ref,
317
+ isPressed,
318
+ isDisabled: isDisabled || isLoading,
319
+ asChild,
320
+ feedbackVariant,
321
+ accessibilityRole,
322
+ accessibilityState: {
323
+ disabled: isDisabled,
324
+ busy: isLoading,
325
+ ...accessibilityState
326
+ },
327
+ ...rest,
328
+ style: rootStyle,
329
+ onPressIn: press.onPressIn,
330
+ onPressOut: press.onPressOut,
331
+ children: asChild ? children : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
332
+ showSpinner ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ButtonSpinner, {}) : null,
333
+ text !== null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ButtonLabel, { children: text }) : children
334
+ ] })
335
+ }
336
+ ) });
337
+ });
338
+ ButtonRoot.displayName = "XAUI.Button.Root";
339
+
340
+ // src/components/button/index.ts
341
+ var Button2 = Object.assign(ButtonRoot, {
342
+ Label: ButtonLabel,
343
+ Icon: ButtonIcon,
344
+ Spinner: ButtonSpinner
345
+ });
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+ exports.useButton = useButton; exports.usePressState = usePressState; exports.warnDev = warnDev; exports.buttonRecipe = buttonRecipe; exports.Button = Button2;
@@ -0,0 +1,57 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/system/portal/portal.tsx
2
+ var _react = require('react');
3
+
4
+ // src/system/portal/portal-context.ts
5
+
6
+ var PortalContext = _react.createContext.call(void 0, null);
7
+
8
+ // src/system/portal/portal.tsx
9
+ function Portal({ children }) {
10
+ const context = _react.useContext.call(void 0, PortalContext);
11
+ const key = _react.useId.call(void 0, );
12
+ _react.useLayoutEffect.call(void 0, () => {
13
+ _optionalChain([context, 'optionalAccess', _ => _.addPortal, 'call', _2 => _2(key, children)]);
14
+ }, [children, context, key]);
15
+ _react.useLayoutEffect.call(void 0, () => {
16
+ return () => _optionalChain([context, 'optionalAccess', _3 => _3.removePortal, 'call', _4 => _4(key)]);
17
+ }, [context, key]);
18
+ return null;
19
+ }
20
+ Portal.displayName = "XAUI.Portal";
21
+
22
+ // src/system/portal/portal-host.tsx
23
+
24
+ var _reactnative = require('react-native');
25
+ var _jsxruntime = require('react/jsx-runtime');
26
+ var styles = _reactnative.StyleSheet.create({
27
+ container: { flex: 1 }
28
+ });
29
+ function PortalHost({ children }) {
30
+ const [portals, setPortals] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
31
+ const addPortal = _react.useCallback.call(void 0, (key, element) => {
32
+ setPortals((current) => new Map(current).set(key, element));
33
+ }, []);
34
+ const removePortal = _react.useCallback.call(void 0, (key) => {
35
+ setPortals((current) => {
36
+ if (!current.has(key)) return current;
37
+ const next = new Map(current);
38
+ next.delete(key);
39
+ return next;
40
+ });
41
+ }, []);
42
+ const methods = _react.useMemo.call(void 0,
43
+ () => ({ addPortal, removePortal }),
44
+ [addPortal, removePortal]
45
+ );
46
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PortalContext.Provider, { value: methods, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactnative.View, { style: styles.container, children: [
47
+ children,
48
+ Array.from(portals, ([key, element]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: element }, key))
49
+ ] }) });
50
+ }
51
+ PortalHost.displayName = "XAUI.PortalHost";
52
+
53
+
54
+
55
+
56
+
57
+ exports.PortalContext = PortalContext; exports.Portal = Portal; exports.PortalHost = PortalHost;
@@ -1,3 +1,24 @@
1
+ // src/theme/theme-context.ts
2
+ import { createContext } from "react";
3
+ var ThemeContext = createContext(null);
4
+
5
+ // src/theme/theme-hooks.ts
6
+ import { useContext } from "react";
7
+ function useXAUITheme() {
8
+ const theme = useContext(ThemeContext);
9
+ if (theme === null) {
10
+ throw new Error("XAUI: useXAUITheme must be used within <XAUIProvider>.");
11
+ }
12
+ return theme;
13
+ }
14
+ function useColorMode() {
15
+ return useXAUITheme().mode;
16
+ }
17
+ function useThemeColor(token) {
18
+ const { colors } = useXAUITheme();
19
+ return Array.isArray(token) ? token.map((key) => colors[key]) : colors[token];
20
+ }
21
+
1
22
  // src/utils/colors.ts
2
23
  var srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
3
24
  var linearToSrgb = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
@@ -94,6 +115,10 @@ function deriveTint(tint, theme) {
94
115
  }
95
116
 
96
117
  export {
118
+ ThemeContext,
119
+ useXAUITheme,
120
+ useColorMode,
121
+ useThemeColor,
97
122
  mix,
98
123
  alpha,
99
124
  deriveTint
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkERCOAOO6cjs = require('../../chunk-ERCOAOO6.cjs');
6
+ require('../../chunk-7D262JCJ.cjs');
7
+ require('../../chunk-3QBT3Q65.cjs');
8
+
9
+
10
+
11
+
12
+ exports.Button = _chunkERCOAOO6cjs.Button; exports.buttonRecipe = _chunkERCOAOO6cjs.buttonRecipe; exports.useButton = _chunkERCOAOO6cjs.useButton;
@@ -0,0 +1,192 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import * as react_native from 'react-native';
4
+ import { StyleProp, TextStyle, ViewStyle, TextProps, PressableStateCallbackType } from 'react-native';
5
+ import { a as IconContextValue, b as IconProps, P as PressableFeedbackProps, f as Recipe, n as SlotStyles } from '../../create-recipe-BjSP0zL_.cjs';
6
+ import { S as Size, R as RadiusKey, g as XAUITheme } from '../../theme.type-C9bFJKFm.cjs';
7
+ import 'react-native-reanimated';
8
+
9
+ type ButtonSlot = 'root' | 'label' | 'icon' | 'spinner';
10
+ /**
11
+ * The ten sanctioned appearances (R7). Emphasis and intention are one flat union, which
12
+ * is why there is no `themeColor` beside it: `primary` … `ghost` are the emphasis levels,
13
+ * and each intention carries its own `-soft` low-emphasis level rather than one of them
14
+ * being special-cased.
15
+ */
16
+ type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'ghost' | 'success' | 'success-soft' | 'warning' | 'warning-soft' | 'danger' | 'danger-soft';
17
+ type ButtonSize = Size;
18
+ type ButtonProps = Omit<PressableFeedbackProps, 'isPressed' | 'isDisabled' | 'style' | 'children'> & {
19
+ variant?: ButtonVariant;
20
+ /** Height, padding, gap, radius and type. Never width. */
21
+ size?: ButtonSize;
22
+ /** Overrides the radius `size` chose. Unset, a button is the shape its size implies. */
23
+ radius?: RadiusKey;
24
+ /**
25
+ * A raw tint (`'#7c3aed'`), never a token (R7). Where it lands follows the variant: the
26
+ * background of a `primary`, the label of a `ghost`, the border and label of a
27
+ * `tertiary`. Its contrasted, soft and pressed slices are derived in OKLab, so it
28
+ * behaves exactly like `accent` — which is also why it must be a hex value.
29
+ */
30
+ color?: string;
31
+ isDisabled?: boolean;
32
+ /** Presses through as disabled, and inserts a `Button.Spinner` if none is composed. */
33
+ isLoading?: boolean;
34
+ /** Drops the horizontal padding and squares the button on its fixed height. */
35
+ isIconOnly?: boolean;
36
+ /** R9 — `Pressable`'s function form as much as an object or an array. */
37
+ style?: StyleProp<ViewStyle> | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>);
38
+ children?: ReactNode;
39
+ };
40
+ type ButtonLabelProps = TextProps & {
41
+ children?: ReactNode;
42
+ };
43
+ /**
44
+ * `Icon`'s three forms, plus the `style` every slot carries (R2). `size` and `color`
45
+ * default to what the root resolved; passing either wins over it.
46
+ */
47
+ type ButtonIconProps = IconProps;
48
+ type ButtonSpinnerProps = {
49
+ style?: StyleProp<ViewStyle>;
50
+ /** `false` stops the rotation. The ring stays, so the button does not change size. */
51
+ animation?: boolean;
52
+ };
53
+ /**
54
+ * R5 — resolved styles, not props for a slot to resolve a second time. Each entry is the
55
+ * cached `StyleSheet` reference with the uncached tint pass layered over it, so a slot
56
+ * merges its own `style` on top and does no work of its own.
57
+ */
58
+ type ButtonContextValue = {
59
+ labelStyle: StyleProp<TextStyle>;
60
+ spinnerStyle: StyleProp<ViewStyle>;
61
+ /**
62
+ * Values, not a style: `Icon` hands `size` and `color` to a third-party component, so
63
+ * the root flattens its icon slot once here rather than in every icon it contains.
64
+ */
65
+ icon: IconContextValue;
66
+ isDisabled: boolean;
67
+ isLoading: boolean;
68
+ };
69
+
70
+ /**
71
+ * An icon that takes the button's size and colour without being told either:
72
+ *
73
+ * ```tsx
74
+ * <Button variant="danger">
75
+ * <Button.Icon as={TrashIcon} />
76
+ * <Button.Label>Supprimer</Button.Label>
77
+ * </Button>
78
+ * ```
79
+ *
80
+ * The values come from the root, which resolved them once; an explicit `size` or `color`
81
+ * still wins, which is what `Icon` promises everywhere else in the library.
82
+ */
83
+ declare function ButtonIcon({ size, color, ...rest }: ButtonIconProps): react.JSX.Element;
84
+ declare namespace ButtonIcon {
85
+ var displayName: string;
86
+ }
87
+
88
+ /**
89
+ * The busy indicator. `isLoading` inserts one when none is composed, so
90
+ * `<Button isLoading>Envoi…</Button>` works; composing it explicitly is how you put it
91
+ * after the label instead of before it.
92
+ *
93
+ * A ring rather than RN's `ActivityIndicator`: the recipe owns its diameter and its
94
+ * colour like every other measurement, which is what makes it follow the button's `size`
95
+ * and its variant with nothing to pass. P3 extracts it into the standalone `Spinner`, and
96
+ * this slot becomes its call site.
97
+ */
98
+ declare function ButtonSpinner({ style, animation }: ButtonSpinnerProps): react.JSX.Element;
99
+ declare namespace ButtonSpinner {
100
+ var displayName: string;
101
+ }
102
+
103
+ declare const useButton: () => ButtonContextValue;
104
+
105
+ declare const buttonRecipe: Recipe<"label" | "root" | "icon" | "spinner", ButtonVariant, {
106
+ readonly size: {
107
+ readonly xs: (theme: XAUITheme) => SlotStyles<ButtonSlot>;
108
+ readonly sm: (theme: XAUITheme) => SlotStyles<ButtonSlot>;
109
+ readonly md: (theme: XAUITheme) => SlotStyles<ButtonSlot>;
110
+ readonly lg: (theme: XAUITheme) => SlotStyles<ButtonSlot>;
111
+ };
112
+ readonly radius: {
113
+ readonly xs: (t: XAUITheme) => {
114
+ root: {
115
+ borderRadius: number;
116
+ };
117
+ };
118
+ readonly sm: (t: XAUITheme) => {
119
+ root: {
120
+ borderRadius: number;
121
+ };
122
+ };
123
+ readonly md: (t: XAUITheme) => {
124
+ root: {
125
+ borderRadius: number;
126
+ };
127
+ };
128
+ readonly lg: (t: XAUITheme) => {
129
+ root: {
130
+ borderRadius: number;
131
+ };
132
+ };
133
+ readonly xl: (t: XAUITheme) => {
134
+ root: {
135
+ borderRadius: number;
136
+ };
137
+ };
138
+ readonly '2xl': (t: XAUITheme) => {
139
+ root: {
140
+ borderRadius: number;
141
+ };
142
+ };
143
+ readonly '3xl': (t: XAUITheme) => {
144
+ root: {
145
+ borderRadius: number;
146
+ };
147
+ };
148
+ readonly '4xl': (t: XAUITheme) => {
149
+ root: {
150
+ borderRadius: number;
151
+ };
152
+ };
153
+ readonly field: (t: XAUITheme) => {
154
+ root: {
155
+ borderRadius: number;
156
+ };
157
+ };
158
+ readonly full: (t: XAUITheme) => {
159
+ root: {
160
+ borderRadius: number;
161
+ };
162
+ };
163
+ };
164
+ readonly isIconOnly: {
165
+ readonly true: () => {
166
+ root: {
167
+ paddingHorizontal: number;
168
+ aspectRatio: number;
169
+ };
170
+ };
171
+ };
172
+ }>;
173
+
174
+ declare const Button: react.ForwardRefExoticComponent<Omit<PressableFeedbackProps, "children" | "style" | "isPressed" | "isDisabled"> & {
175
+ variant?: ButtonVariant;
176
+ size?: ButtonSize;
177
+ radius?: RadiusKey;
178
+ color?: string;
179
+ isDisabled?: boolean;
180
+ isLoading?: boolean;
181
+ isIconOnly?: boolean;
182
+ style?: react_native.StyleProp<react_native.ViewStyle> | ((state: react_native.PressableStateCallbackType) => react_native.StyleProp<react_native.ViewStyle>);
183
+ children?: react.ReactNode;
184
+ } & react.RefAttributes<react_native.View>> & {
185
+ Label: react.ForwardRefExoticComponent<react_native.TextProps & {
186
+ children?: react.ReactNode;
187
+ } & react.RefAttributes<react_native.Text>>;
188
+ Icon: typeof ButtonIcon;
189
+ Spinner: typeof ButtonSpinner;
190
+ };
191
+
192
+ export { Button, type ButtonContextValue, type ButtonIconProps, type ButtonLabelProps, type ButtonProps, type ButtonSize, type ButtonSlot, type ButtonSpinnerProps, type ButtonVariant, buttonRecipe, useButton };