@xaui/native 0.9.1-alpha.2 → 0.9.1-alpha.20

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