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

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.
@@ -145,6 +145,130 @@ function apply(fns, theme, colors) {
145
145
  return merged;
146
146
  }
147
147
 
148
+ // src/system/slot/children-to-string.ts
149
+ var _react = require('react');
150
+ function childrenToString(children) {
151
+ const text = stringify(children);
152
+ return text === null || text === "" ? null : text;
153
+ }
154
+ function stringify(node) {
155
+ if (node === null || node === void 0 || typeof node === "boolean") return "";
156
+ if (typeof node === "string") return node;
157
+ if (typeof node === "number") return String(node);
158
+ if (_react.isValidElement.call(void 0, node)) return null;
159
+ if (Array.isArray(node)) {
160
+ let text = "";
161
+ for (const child of node) {
162
+ const part = stringify(child);
163
+ if (part === null) return null;
164
+ text += part;
165
+ }
166
+ return text;
167
+ }
168
+ return null;
169
+ }
170
+
171
+ // src/system/slot/create-slot-context.ts
172
+
173
+ function createSlotContext(name) {
174
+ const Context = _react.createContext.call(void 0, null);
175
+ Context.displayName = `XAUI.${name}.Context`;
176
+ function useSlotContext() {
177
+ const value = _react.useContext.call(void 0, Context);
178
+ if (value === null) {
179
+ const error = new Error(
180
+ `XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
181
+ );
182
+ _optionalChain([Error, 'access', _4 => _4.captureStackTrace, 'optionalCall', _5 => _5(
183
+ error,
184
+ useSlotContext
185
+ )]);
186
+ throw error;
187
+ }
188
+ return value;
189
+ }
190
+ return [Context.Provider, useSlotContext];
191
+ }
192
+
193
+ // src/system/slot/merge-refs.ts
194
+ function mergeRefs(...refs) {
195
+ return (value) => {
196
+ for (const ref of refs) {
197
+ if (typeof ref === "function") ref(value);
198
+ else if (ref) ref.current = value;
199
+ }
200
+ };
201
+ }
202
+
203
+ // src/system/slot/merge-props.ts
204
+ var EVENT_HANDLER = /^on[A-Z]/;
205
+ function mergeProps(ours, theirs) {
206
+ const merged = { ...ours };
207
+ for (const key of Object.keys(theirs)) {
208
+ const ourValue = ours[key];
209
+ const theirValue = theirs[key];
210
+ if (EVENT_HANDLER.test(key)) {
211
+ merged[key] = composeHandlers(ourValue, theirValue);
212
+ } else if (key === "style") {
213
+ merged[key] = mergeStyles(ourValue, theirValue);
214
+ } else if (key === "ref") {
215
+ merged[key] = mergeRefs(
216
+ ourValue,
217
+ theirValue
218
+ );
219
+ } else {
220
+ merged[key] = theirValue;
221
+ }
222
+ }
223
+ return merged;
224
+ }
225
+ function composeHandlers(ours, theirs) {
226
+ if (typeof ours !== "function") return theirs;
227
+ if (typeof theirs !== "function") return ours;
228
+ return (...args) => {
229
+ ;
230
+ ours(...args);
231
+ return theirs(...args);
232
+ };
233
+ }
234
+ function mergeStyles(ours, theirs) {
235
+ if (typeof ours === "function" || typeof theirs === "function") {
236
+ return (state) => [
237
+ resolveStyle(ours, state),
238
+ resolveStyle(theirs, state)
239
+ ];
240
+ }
241
+ return [ours, theirs];
242
+ }
243
+ function resolveStyle(style, state) {
244
+ return typeof style === "function" ? style(state) : style;
245
+ }
246
+
247
+ // src/system/slot/slot.tsx
248
+
249
+ var Slot = _react.forwardRef.call(void 0, function Slot2({ children, ...ours }, ref) {
250
+ if (!_react.isValidElement.call(void 0, children)) {
251
+ throw new Error(
252
+ "XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
253
+ );
254
+ }
255
+ const child = children;
256
+ const merged = mergeProps(ours, child.props);
257
+ merged.ref = mergeRefs(ref, refOf(child));
258
+ return _react.cloneElement.call(void 0, child, merged);
259
+ });
260
+ Slot.displayName = "XAUI.Slot";
261
+ function refOf(element) {
262
+ const fromProps = element.props.ref;
263
+ const fromElement = element.ref;
264
+ return _nullishCoalesce(fromProps, () => ( fromElement));
265
+ }
266
+
267
+
268
+
269
+
270
+
271
+
148
272
 
149
273
 
150
- exports.createRecipe = createRecipe;
274
+ exports.createRecipe = createRecipe; exports.childrenToString = childrenToString; exports.createSlotContext = createSlotContext; exports.mergeRefs = mergeRefs; exports.mergeProps = mergeProps; exports.Slot = Slot;
@@ -145,6 +145,130 @@ function apply(fns, theme, colors) {
145
145
  return merged;
146
146
  }
147
147
 
148
+ // src/system/slot/children-to-string.ts
149
+ import { isValidElement } from "react";
150
+ function childrenToString(children) {
151
+ const text = stringify(children);
152
+ return text === null || text === "" ? null : text;
153
+ }
154
+ function stringify(node) {
155
+ if (node === null || node === void 0 || typeof node === "boolean") return "";
156
+ if (typeof node === "string") return node;
157
+ if (typeof node === "number") return String(node);
158
+ if (isValidElement(node)) return null;
159
+ if (Array.isArray(node)) {
160
+ let text = "";
161
+ for (const child of node) {
162
+ const part = stringify(child);
163
+ if (part === null) return null;
164
+ text += part;
165
+ }
166
+ return text;
167
+ }
168
+ return null;
169
+ }
170
+
171
+ // src/system/slot/create-slot-context.ts
172
+ import { createContext, useContext } from "react";
173
+ function createSlotContext(name) {
174
+ const Context = createContext(null);
175
+ Context.displayName = `XAUI.${name}.Context`;
176
+ function useSlotContext() {
177
+ const value = useContext(Context);
178
+ if (value === null) {
179
+ const error = new Error(
180
+ `XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
181
+ );
182
+ Error.captureStackTrace?.(
183
+ error,
184
+ useSlotContext
185
+ );
186
+ throw error;
187
+ }
188
+ return value;
189
+ }
190
+ return [Context.Provider, useSlotContext];
191
+ }
192
+
193
+ // src/system/slot/merge-refs.ts
194
+ function mergeRefs(...refs) {
195
+ return (value) => {
196
+ for (const ref of refs) {
197
+ if (typeof ref === "function") ref(value);
198
+ else if (ref) ref.current = value;
199
+ }
200
+ };
201
+ }
202
+
203
+ // src/system/slot/merge-props.ts
204
+ var EVENT_HANDLER = /^on[A-Z]/;
205
+ function mergeProps(ours, theirs) {
206
+ const merged = { ...ours };
207
+ for (const key of Object.keys(theirs)) {
208
+ const ourValue = ours[key];
209
+ const theirValue = theirs[key];
210
+ if (EVENT_HANDLER.test(key)) {
211
+ merged[key] = composeHandlers(ourValue, theirValue);
212
+ } else if (key === "style") {
213
+ merged[key] = mergeStyles(ourValue, theirValue);
214
+ } else if (key === "ref") {
215
+ merged[key] = mergeRefs(
216
+ ourValue,
217
+ theirValue
218
+ );
219
+ } else {
220
+ merged[key] = theirValue;
221
+ }
222
+ }
223
+ return merged;
224
+ }
225
+ function composeHandlers(ours, theirs) {
226
+ if (typeof ours !== "function") return theirs;
227
+ if (typeof theirs !== "function") return ours;
228
+ return (...args) => {
229
+ ;
230
+ ours(...args);
231
+ return theirs(...args);
232
+ };
233
+ }
234
+ function mergeStyles(ours, theirs) {
235
+ if (typeof ours === "function" || typeof theirs === "function") {
236
+ return (state) => [
237
+ resolveStyle(ours, state),
238
+ resolveStyle(theirs, state)
239
+ ];
240
+ }
241
+ return [ours, theirs];
242
+ }
243
+ function resolveStyle(style, state) {
244
+ return typeof style === "function" ? style(state) : style;
245
+ }
246
+
247
+ // src/system/slot/slot.tsx
248
+ import { cloneElement, forwardRef, isValidElement as isValidElement2 } from "react";
249
+ var Slot = forwardRef(function Slot2({ children, ...ours }, ref) {
250
+ if (!isValidElement2(children)) {
251
+ throw new Error(
252
+ "XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
253
+ );
254
+ }
255
+ const child = children;
256
+ const merged = mergeProps(ours, child.props);
257
+ merged.ref = mergeRefs(ref, refOf(child));
258
+ return cloneElement(child, merged);
259
+ });
260
+ Slot.displayName = "XAUI.Slot";
261
+ function refOf(element) {
262
+ const fromProps = element.props.ref;
263
+ const fromElement = element.ref;
264
+ return fromProps ?? fromElement;
265
+ }
266
+
148
267
  export {
149
- createRecipe
268
+ createRecipe,
269
+ childrenToString,
270
+ createSlotContext,
271
+ mergeRefs,
272
+ mergeProps,
273
+ Slot
150
274
  };
package/dist/index.cjs CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkKFCORXWWcjs = require('./chunk-KFCORXWW.cjs');
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkB755PRVJcjs = require('./chunk-B755PRVJ.cjs');
4
9
 
5
10
 
6
11
 
@@ -37,4 +42,9 @@ var _chunkM7P46XKIcjs = require('./chunk-M7P46XKI.cjs');
37
42
 
38
43
 
39
44
 
40
- exports.ThemeContext = _chunkNHPQQQ7Pcjs.ThemeContext; exports.XAUIProvider = _chunkNHPQQQ7Pcjs.XAUIProvider; exports.buildRadius = _chunkNHPQQQ7Pcjs.buildRadius; exports.buildShadows = _chunkNHPQQQ7Pcjs.buildShadows; exports.createRecipe = _chunkKFCORXWWcjs.createRecipe; exports.createTheme = _chunkNHPQQQ7Pcjs.createTheme; exports.defaultTheme = _chunkNHPQQQ7Pcjs.defaultTheme; exports.deriveColors = _chunkNHPQQQ7Pcjs.deriveColors; exports.deriveTint = _chunkM7P46XKIcjs.deriveTint; exports.palette = _chunkNHPQQQ7Pcjs.palette; exports.primitives = _chunkNHPQQQ7Pcjs.primitives; exports.sourceKeys = _chunkNHPQQQ7Pcjs.sourceKeys; exports.tokens = _chunkNHPQQQ7Pcjs.tokens; exports.useColorMode = _chunkNHPQQQ7Pcjs.useColorMode; exports.useThemeColor = _chunkNHPQQQ7Pcjs.useThemeColor; exports.useXAUITheme = _chunkNHPQQQ7Pcjs.useXAUITheme;
45
+
46
+
47
+
48
+
49
+
50
+ exports.Slot = _chunkB755PRVJcjs.Slot; exports.ThemeContext = _chunkNHPQQQ7Pcjs.ThemeContext; exports.XAUIProvider = _chunkNHPQQQ7Pcjs.XAUIProvider; exports.buildRadius = _chunkNHPQQQ7Pcjs.buildRadius; exports.buildShadows = _chunkNHPQQQ7Pcjs.buildShadows; exports.childrenToString = _chunkB755PRVJcjs.childrenToString; exports.createRecipe = _chunkB755PRVJcjs.createRecipe; exports.createSlotContext = _chunkB755PRVJcjs.createSlotContext; exports.createTheme = _chunkNHPQQQ7Pcjs.createTheme; exports.defaultTheme = _chunkNHPQQQ7Pcjs.defaultTheme; exports.deriveColors = _chunkNHPQQQ7Pcjs.deriveColors; exports.deriveTint = _chunkM7P46XKIcjs.deriveTint; exports.mergeProps = _chunkB755PRVJcjs.mergeProps; exports.mergeRefs = _chunkB755PRVJcjs.mergeRefs; exports.palette = _chunkNHPQQQ7Pcjs.palette; exports.primitives = _chunkNHPQQQ7Pcjs.primitives; exports.sourceKeys = _chunkNHPQQQ7Pcjs.sourceKeys; exports.tokens = _chunkNHPQQQ7Pcjs.tokens; exports.useColorMode = _chunkNHPQQQ7Pcjs.useColorMode; exports.useThemeColor = _chunkNHPQQQ7Pcjs.useThemeColor; exports.useXAUITheme = _chunkNHPQQQ7Pcjs.useXAUITheme;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { Axes, CompoundVariant, Recipe, RecipeConfig, ResolveArgs, ResolvedSelection, ResolvedStyles, Selection, SlotStyle, SlotStyles, StateName, States, StyleFn, TintArgs, VariantColors, VariantRole, VariantTokens, createRecipe } from './system/index.cjs';
1
+ export { AsChildProps, Axes, CompoundVariant, MergeableProps, PossibleRef, Recipe, RecipeConfig, ResolveArgs, ResolvedSelection, ResolvedStyles, Selection, Slot, SlotProps, SlotStyle, SlotStyles, StateName, States, StyleFn, TintArgs, VariantColors, VariantRole, VariantTokens, childrenToString, createRecipe, createSlotContext, mergeProps, mergeRefs } from './system/index.cjs';
2
2
  export { ColorModePreference, PaletteFamily, PaletteShade, ThemeContext, XAUIProvider, XAUIProviderProps, XAUITint, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, deriveTint, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme } from './theme/index.cjs';
3
3
  export { C as ColorMode, F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, X as XAUIColors, b as XAUIDerivedColors, c as XAUIPrimitiveColors, d as XAUIRadius, e as XAUIShadow, f as XAUISourceColors, g as XAUITheme, h as XAUIThemeConfig, i as XAUIThemeSet } from './theme.type-B3ODSLbB.cjs';
4
4
  import 'react-native';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Axes, CompoundVariant, Recipe, RecipeConfig, ResolveArgs, ResolvedSelection, ResolvedStyles, Selection, SlotStyle, SlotStyles, StateName, States, StyleFn, TintArgs, VariantColors, VariantRole, VariantTokens, createRecipe } from './system/index.js';
1
+ export { AsChildProps, Axes, CompoundVariant, MergeableProps, PossibleRef, Recipe, RecipeConfig, ResolveArgs, ResolvedSelection, ResolvedStyles, Selection, Slot, SlotProps, SlotStyle, SlotStyles, StateName, States, StyleFn, TintArgs, VariantColors, VariantRole, VariantTokens, childrenToString, createRecipe, createSlotContext, mergeProps, mergeRefs } from './system/index.js';
2
2
  export { ColorModePreference, PaletteFamily, PaletteShade, ThemeContext, XAUIProvider, XAUIProviderProps, XAUITint, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, deriveTint, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme } from './theme/index.js';
3
3
  export { C as ColorMode, F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, X as XAUIColors, b as XAUIDerivedColors, c as XAUIPrimitiveColors, d as XAUIRadius, e as XAUIShadow, f as XAUISourceColors, g as XAUITheme, h as XAUIThemeConfig, i as XAUIThemeSet } from './theme.type-B3ODSLbB.js';
4
4
  import 'react-native';
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import {
2
- createRecipe
3
- } from "./chunk-N357EQCZ.js";
2
+ Slot,
3
+ childrenToString,
4
+ createRecipe,
5
+ createSlotContext,
6
+ mergeProps,
7
+ mergeRefs
8
+ } from "./chunk-RCP3SD26.js";
4
9
  import {
5
10
  ThemeContext,
6
11
  XAUIProvider,
@@ -21,15 +26,20 @@ import {
21
26
  deriveTint
22
27
  } from "./chunk-RBNCR5KB.js";
23
28
  export {
29
+ Slot,
24
30
  ThemeContext,
25
31
  XAUIProvider,
26
32
  buildRadius,
27
33
  buildShadows,
34
+ childrenToString,
28
35
  createRecipe,
36
+ createSlotContext,
29
37
  createTheme,
30
38
  defaultTheme,
31
39
  deriveColors,
32
40
  deriveTint,
41
+ mergeProps,
42
+ mergeRefs,
33
43
  palette,
34
44
  primitives,
35
45
  sourceKeys,
@@ -1,7 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkKFCORXWWcjs = require('../chunk-KFCORXWW.cjs');
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkB755PRVJcjs = require('../chunk-B755PRVJ.cjs');
4
9
  require('../chunk-M7P46XKI.cjs');
5
10
 
6
11
 
7
- exports.createRecipe = _chunkKFCORXWWcjs.createRecipe;
12
+
13
+
14
+
15
+
16
+
17
+ exports.Slot = _chunkB755PRVJcjs.Slot; exports.childrenToString = _chunkB755PRVJcjs.childrenToString; exports.createRecipe = _chunkB755PRVJcjs.createRecipe; exports.createSlotContext = _chunkB755PRVJcjs.createSlotContext; exports.mergeProps = _chunkB755PRVJcjs.mergeProps; exports.mergeRefs = _chunkB755PRVJcjs.mergeRefs;
@@ -1,5 +1,7 @@
1
1
  import { g as XAUITheme, X as XAUIColors } from '../theme.type-B3ODSLbB.cjs';
2
2
  import { ViewStyle, TextStyle } from 'react-native';
3
+ import * as react from 'react';
4
+ import { ReactNode, Provider, Ref, RefCallback } from 'react';
3
5
 
4
6
  /**
5
7
  * A slot is a view or a text node, and a recipe writes one object per slot, so the two
@@ -80,4 +82,93 @@ type Recipe<Slot extends string, Variant extends string, A extends Axes<Slot>> =
80
82
  */
81
83
  declare function createRecipe<Slot extends string, Variant extends string, const A extends Axes<Slot>>(config: RecipeConfig<Slot, Variant, A>): Recipe<Slot, Variant, A>;
82
84
 
83
- export { type Axes, type CompoundVariant, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedSelection, type ResolvedStyles, type Selection, type SlotStyle, type SlotStyles, type StateName, type States, type StyleFn, type TintArgs, type VariantColors, type VariantRole, type VariantTokens, createRecipe };
85
+ /**
86
+ * R3: the string a root should wrap in its default text slot, or `null` when it should
87
+ * render its children as they are.
88
+ *
89
+ * The whole tree is stringified recursively rather than the first child inspected. That
90
+ * is what makes `<Button>{count} items</Button>` work — children there are the array
91
+ * `[3, ' items']`, and an `isValidElement` check on the first entry would call it an
92
+ * element-free tree only by accident, while a check for "is the first child a string"
93
+ * would miss it outright.
94
+ *
95
+ * `null` for an empty result as much as for a tree containing an element: in both cases
96
+ * there is nothing to wrap, and a root's fallback — render the children — is right for
97
+ * both. It also keeps `<Button>{false}</Button>` from mounting an empty text node.
98
+ */
99
+ declare function childrenToString(children: ReactNode): string | null;
100
+
101
+ /**
102
+ * A context a slot cannot read by accident. Every compound gets one, and it carries
103
+ * **resolved** values — style references the root already computed, not tokens for the
104
+ * slot to resolve again (R5).
105
+ *
106
+ * ```ts
107
+ * const [ButtonProvider, useButton] = createSlotContext<ButtonContext>('Button')
108
+ * ```
109
+ *
110
+ * The tuple is what lets each compound name its own hook, which R10 requires it to
111
+ * export. `name` gives both halves of the error, so there is one place to spell it.
112
+ */
113
+ declare function createSlotContext<T>(name: string): readonly [Provider<T | null>, () => T];
114
+
115
+ /** Anything React accepts as a ref, plus the absence of one. */
116
+ type PossibleRef<T> = Ref<T> | undefined;
117
+ /**
118
+ * The props `mergeProps` knows how to combine. Deliberately loose: it merges whatever a
119
+ * root hands to whatever child it was given, and neither side is knowable from here.
120
+ */
121
+ type MergeableProps = Record<string, unknown>;
122
+ type AsChildProps = {
123
+ /**
124
+ * Merge this component's props into its single child instead of rendering an element
125
+ * of its own — a navigation `Link` as a `Button`, a bespoke trigger as a `Select`.
126
+ */
127
+ asChild?: boolean;
128
+ };
129
+
130
+ /**
131
+ * Merges a root's own props into the child it renders through `asChild` (R12). Four
132
+ * rules, and the child wins wherever they do not apply — it is the more specific intent:
133
+ *
134
+ * - **Event handlers compose.** Both run, ours first: the component's own behaviour (the
135
+ * press state that drives its styles) happens before the child's side effect (the
136
+ * navigation). Replacing one with the other is the bug this exists to prevent.
137
+ * - **Styles stack**, ours under the child's, so the child can override.
138
+ * - **`ref`s merge** through `mergeRefs`. React 19 passes `ref` as an ordinary prop, so
139
+ * it arrives here rather than beside the props, and dropping it would sever the root's
140
+ * handle on the node.
141
+ * - **Everything else: the child's value wins**, and ours fills in what it left unset.
142
+ */
143
+ declare function mergeProps(ours: MergeableProps, theirs: MergeableProps): MergeableProps;
144
+
145
+ /**
146
+ * One callback that feeds several refs — what lets a root keep its own handle on a node
147
+ * while still honouring the ref its caller passed (R9), and what `asChild` needs to
148
+ * forward a ref into the child it merges into (R12).
149
+ *
150
+ * It returns nothing on purpose. React 19 reads a ref callback's return value as a
151
+ * cleanup function while React 18 ignores it, and this package supports both; letting
152
+ * a merged cleanup through would behave differently on each. React calls every ref with
153
+ * `null` on unmount anyway, which this forwards.
154
+ */
155
+ declare function mergeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T>;
156
+
157
+ type SlotProps = MergeableProps & {
158
+ children?: ReactNode;
159
+ };
160
+ /**
161
+ * The render branch behind `asChild` (R12). A root picks it instead of its own element:
162
+ *
163
+ * ```tsx
164
+ * const Root = asChild ? Slot : Pressable
165
+ * return <Root ref={ref} {...rootProps}>{children}</Root>
166
+ * ```
167
+ *
168
+ * One line per root, which is the point — forty-seven roots each hand-rolling a
169
+ * `cloneElement` and a ref merge would drift, and R12 has to hold uniformly from the
170
+ * first component or the ref signature of the whole core changes later.
171
+ */
172
+ declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
173
+
174
+ export { type AsChildProps, type Axes, type CompoundVariant, type MergeableProps, type PossibleRef, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedSelection, type ResolvedStyles, type Selection, Slot, type SlotProps, type SlotStyle, type SlotStyles, type StateName, type States, type StyleFn, type TintArgs, type VariantColors, type VariantRole, type VariantTokens, childrenToString, createRecipe, createSlotContext, mergeProps, mergeRefs };
@@ -1,5 +1,7 @@
1
1
  import { g as XAUITheme, X as XAUIColors } from '../theme.type-B3ODSLbB.js';
2
2
  import { ViewStyle, TextStyle } from 'react-native';
3
+ import * as react from 'react';
4
+ import { ReactNode, Provider, Ref, RefCallback } from 'react';
3
5
 
4
6
  /**
5
7
  * A slot is a view or a text node, and a recipe writes one object per slot, so the two
@@ -80,4 +82,93 @@ type Recipe<Slot extends string, Variant extends string, A extends Axes<Slot>> =
80
82
  */
81
83
  declare function createRecipe<Slot extends string, Variant extends string, const A extends Axes<Slot>>(config: RecipeConfig<Slot, Variant, A>): Recipe<Slot, Variant, A>;
82
84
 
83
- export { type Axes, type CompoundVariant, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedSelection, type ResolvedStyles, type Selection, type SlotStyle, type SlotStyles, type StateName, type States, type StyleFn, type TintArgs, type VariantColors, type VariantRole, type VariantTokens, createRecipe };
85
+ /**
86
+ * R3: the string a root should wrap in its default text slot, or `null` when it should
87
+ * render its children as they are.
88
+ *
89
+ * The whole tree is stringified recursively rather than the first child inspected. That
90
+ * is what makes `<Button>{count} items</Button>` work — children there are the array
91
+ * `[3, ' items']`, and an `isValidElement` check on the first entry would call it an
92
+ * element-free tree only by accident, while a check for "is the first child a string"
93
+ * would miss it outright.
94
+ *
95
+ * `null` for an empty result as much as for a tree containing an element: in both cases
96
+ * there is nothing to wrap, and a root's fallback — render the children — is right for
97
+ * both. It also keeps `<Button>{false}</Button>` from mounting an empty text node.
98
+ */
99
+ declare function childrenToString(children: ReactNode): string | null;
100
+
101
+ /**
102
+ * A context a slot cannot read by accident. Every compound gets one, and it carries
103
+ * **resolved** values — style references the root already computed, not tokens for the
104
+ * slot to resolve again (R5).
105
+ *
106
+ * ```ts
107
+ * const [ButtonProvider, useButton] = createSlotContext<ButtonContext>('Button')
108
+ * ```
109
+ *
110
+ * The tuple is what lets each compound name its own hook, which R10 requires it to
111
+ * export. `name` gives both halves of the error, so there is one place to spell it.
112
+ */
113
+ declare function createSlotContext<T>(name: string): readonly [Provider<T | null>, () => T];
114
+
115
+ /** Anything React accepts as a ref, plus the absence of one. */
116
+ type PossibleRef<T> = Ref<T> | undefined;
117
+ /**
118
+ * The props `mergeProps` knows how to combine. Deliberately loose: it merges whatever a
119
+ * root hands to whatever child it was given, and neither side is knowable from here.
120
+ */
121
+ type MergeableProps = Record<string, unknown>;
122
+ type AsChildProps = {
123
+ /**
124
+ * Merge this component's props into its single child instead of rendering an element
125
+ * of its own — a navigation `Link` as a `Button`, a bespoke trigger as a `Select`.
126
+ */
127
+ asChild?: boolean;
128
+ };
129
+
130
+ /**
131
+ * Merges a root's own props into the child it renders through `asChild` (R12). Four
132
+ * rules, and the child wins wherever they do not apply — it is the more specific intent:
133
+ *
134
+ * - **Event handlers compose.** Both run, ours first: the component's own behaviour (the
135
+ * press state that drives its styles) happens before the child's side effect (the
136
+ * navigation). Replacing one with the other is the bug this exists to prevent.
137
+ * - **Styles stack**, ours under the child's, so the child can override.
138
+ * - **`ref`s merge** through `mergeRefs`. React 19 passes `ref` as an ordinary prop, so
139
+ * it arrives here rather than beside the props, and dropping it would sever the root's
140
+ * handle on the node.
141
+ * - **Everything else: the child's value wins**, and ours fills in what it left unset.
142
+ */
143
+ declare function mergeProps(ours: MergeableProps, theirs: MergeableProps): MergeableProps;
144
+
145
+ /**
146
+ * One callback that feeds several refs — what lets a root keep its own handle on a node
147
+ * while still honouring the ref its caller passed (R9), and what `asChild` needs to
148
+ * forward a ref into the child it merges into (R12).
149
+ *
150
+ * It returns nothing on purpose. React 19 reads a ref callback's return value as a
151
+ * cleanup function while React 18 ignores it, and this package supports both; letting
152
+ * a merged cleanup through would behave differently on each. React calls every ref with
153
+ * `null` on unmount anyway, which this forwards.
154
+ */
155
+ declare function mergeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T>;
156
+
157
+ type SlotProps = MergeableProps & {
158
+ children?: ReactNode;
159
+ };
160
+ /**
161
+ * The render branch behind `asChild` (R12). A root picks it instead of its own element:
162
+ *
163
+ * ```tsx
164
+ * const Root = asChild ? Slot : Pressable
165
+ * return <Root ref={ref} {...rootProps}>{children}</Root>
166
+ * ```
167
+ *
168
+ * One line per root, which is the point — forty-seven roots each hand-rolling a
169
+ * `cloneElement` and a ref merge would drift, and R12 has to hold uniformly from the
170
+ * first component or the ref signature of the whole core changes later.
171
+ */
172
+ declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
173
+
174
+ export { type AsChildProps, type Axes, type CompoundVariant, type MergeableProps, type PossibleRef, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedSelection, type ResolvedStyles, type Selection, Slot, type SlotProps, type SlotStyle, type SlotStyles, type StateName, type States, type StyleFn, type TintArgs, type VariantColors, type VariantRole, type VariantTokens, childrenToString, createRecipe, createSlotContext, mergeProps, mergeRefs };
@@ -1,7 +1,17 @@
1
1
  import {
2
- createRecipe
3
- } from "../chunk-N357EQCZ.js";
2
+ Slot,
3
+ childrenToString,
4
+ createRecipe,
5
+ createSlotContext,
6
+ mergeProps,
7
+ mergeRefs
8
+ } from "../chunk-RCP3SD26.js";
4
9
  import "../chunk-RBNCR5KB.js";
5
10
  export {
6
- createRecipe
11
+ Slot,
12
+ childrenToString,
13
+ createRecipe,
14
+ createSlotContext,
15
+ mergeProps,
16
+ mergeRefs
7
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/native",
3
- "version": "0.9.1-alpha.1",
3
+ "version": "0.9.1-alpha.2",
4
4
  "description": "Composition-first React Native UI components with native animations powered by Reanimated",
5
5
  "keywords": [
6
6
  "react-native",