@xaui/native 0.9.1-alpha.16 → 0.9.1-alpha.18
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-4K3LZS7M.js +448 -0
- package/dist/chunk-5SU7FXWH.cjs +448 -0
- package/dist/chunk-6PZF4PI7.js +100 -0
- package/dist/chunk-6VTBGBPP.cjs +100 -0
- package/dist/{chunk-KCUT47FY.cjs → chunk-BHAHJHAI.cjs} +5 -1
- package/dist/{chunk-UOJBK5Z4.js → chunk-L3AQNVRN.js} +1 -1
- package/dist/{chunk-BAACHVM4.cjs → chunk-M2VYRHVS.cjs} +2 -2
- package/dist/{chunk-E3756MJC.js → chunk-MBLPPOSO.js} +16 -15
- package/dist/{chunk-NLFE3CRM.cjs → chunk-ODH5WAVM.cjs} +24 -23
- package/dist/{chunk-PUER6Y4M.cjs → chunk-P5MKOLIW.cjs} +110 -409
- package/dist/chunk-VQPP6FCB.js +728 -0
- package/dist/{chunk-EHHSY2KB.js → chunk-XQE5PXOD.js} +5 -1
- package/dist/components/button/index.cjs +4 -3
- package/dist/components/button/index.d.cts +179 -178
- package/dist/components/button/index.d.ts +179 -178
- package/dist/components/button/index.js +3 -2
- package/dist/components/typography/index.cjs +12 -0
- package/dist/components/typography/index.d.cts +115 -0
- package/dist/components/typography/index.d.ts +115 -0
- package/dist/components/typography/index.js +12 -0
- package/dist/create-recipe-3_ElpCYt.d.cts +117 -0
- package/dist/create-recipe-DImq1AZA.d.ts +117 -0
- package/dist/index.cjs +17 -7
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +21 -11
- package/dist/pressable-feedback.type-UwqIG6ES.d.ts +195 -0
- package/dist/pressable-feedback.type-lgW5wQx5.d.cts +195 -0
- package/dist/system/index.cjs +5 -3
- package/dist/system/index.d.cts +10 -4
- package/dist/system/index.d.ts +10 -4
- package/dist/system/index.js +11 -9
- package/dist/theme/index.cjs +2 -2
- package/dist/theme/index.d.cts +2 -2
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.js +1 -1
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +11 -1
- package/dist/chunk-64L44HEI.js +0 -1021
- package/dist/create-recipe-BcUu9b2I.d.cts +0 -280
- package/dist/create-recipe-DD9W6m9b.d.ts +0 -280
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
|
+
var _chunk6N5JXRUZcjs = require('./chunk-6N5JXRUZ.cjs');
|
|
5
|
+
|
|
6
|
+
// src/system/style-props/use-style-props.ts
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
|
|
9
|
+
// src/utils/style-props.ts
|
|
10
|
+
var STYLE_PROP_KEYS = [
|
|
11
|
+
// Flex and layout
|
|
12
|
+
"alignContent",
|
|
13
|
+
"alignItems",
|
|
14
|
+
"alignSelf",
|
|
15
|
+
"aspectRatio",
|
|
16
|
+
"boxSizing",
|
|
17
|
+
"columnGap",
|
|
18
|
+
"direction",
|
|
19
|
+
"display",
|
|
20
|
+
"flex",
|
|
21
|
+
"flexBasis",
|
|
22
|
+
"flexDirection",
|
|
23
|
+
"flexGrow",
|
|
24
|
+
"flexShrink",
|
|
25
|
+
"flexWrap",
|
|
26
|
+
"gap",
|
|
27
|
+
"justifyContent",
|
|
28
|
+
"overflow",
|
|
29
|
+
"rowGap",
|
|
30
|
+
// Position
|
|
31
|
+
"bottom",
|
|
32
|
+
"end",
|
|
33
|
+
"inset",
|
|
34
|
+
"insetBlock",
|
|
35
|
+
"insetBlockEnd",
|
|
36
|
+
"insetBlockStart",
|
|
37
|
+
"insetInline",
|
|
38
|
+
"insetInlineEnd",
|
|
39
|
+
"insetInlineStart",
|
|
40
|
+
"position",
|
|
41
|
+
"start",
|
|
42
|
+
"top",
|
|
43
|
+
"zIndex",
|
|
44
|
+
// Margin
|
|
45
|
+
"margin",
|
|
46
|
+
"marginBlock",
|
|
47
|
+
"marginBlockEnd",
|
|
48
|
+
"marginBlockStart",
|
|
49
|
+
"marginBottom",
|
|
50
|
+
"marginEnd",
|
|
51
|
+
"marginHorizontal",
|
|
52
|
+
"marginInline",
|
|
53
|
+
"marginInlineEnd",
|
|
54
|
+
"marginInlineStart",
|
|
55
|
+
"marginStart",
|
|
56
|
+
"marginTop",
|
|
57
|
+
"marginVertical",
|
|
58
|
+
// Padding
|
|
59
|
+
"padding",
|
|
60
|
+
"paddingBlock",
|
|
61
|
+
"paddingBlockEnd",
|
|
62
|
+
"paddingBlockStart",
|
|
63
|
+
"paddingBottom",
|
|
64
|
+
"paddingEnd",
|
|
65
|
+
"paddingHorizontal",
|
|
66
|
+
"paddingInline",
|
|
67
|
+
"paddingInlineEnd",
|
|
68
|
+
"paddingInlineStart",
|
|
69
|
+
"paddingStart",
|
|
70
|
+
"paddingTop",
|
|
71
|
+
"paddingVertical",
|
|
72
|
+
// Size
|
|
73
|
+
"height",
|
|
74
|
+
"maxHeight",
|
|
75
|
+
"maxWidth",
|
|
76
|
+
"minHeight",
|
|
77
|
+
"minWidth",
|
|
78
|
+
"width",
|
|
79
|
+
// Border
|
|
80
|
+
"borderBlockColor",
|
|
81
|
+
"borderBlockEndColor",
|
|
82
|
+
"borderBlockStartColor",
|
|
83
|
+
"borderBottomColor",
|
|
84
|
+
"borderBottomEndRadius",
|
|
85
|
+
"borderBottomStartRadius",
|
|
86
|
+
"borderBottomWidth",
|
|
87
|
+
"borderColor",
|
|
88
|
+
"borderCurve",
|
|
89
|
+
"borderEndColor",
|
|
90
|
+
"borderEndEndRadius",
|
|
91
|
+
"borderEndStartRadius",
|
|
92
|
+
"borderEndWidth",
|
|
93
|
+
"borderRadius",
|
|
94
|
+
"borderStartColor",
|
|
95
|
+
"borderStartEndRadius",
|
|
96
|
+
"borderStartStartRadius",
|
|
97
|
+
"borderStartWidth",
|
|
98
|
+
"borderStyle",
|
|
99
|
+
"borderTopColor",
|
|
100
|
+
"borderTopEndRadius",
|
|
101
|
+
"borderTopStartRadius",
|
|
102
|
+
"borderTopWidth",
|
|
103
|
+
"borderWidth",
|
|
104
|
+
// Fill, shadow, and the rest of a box's paint
|
|
105
|
+
"backfaceVisibility",
|
|
106
|
+
"backgroundColor",
|
|
107
|
+
"boxShadow",
|
|
108
|
+
"cursor",
|
|
109
|
+
"elevation",
|
|
110
|
+
"experimental_backgroundImage",
|
|
111
|
+
"filter",
|
|
112
|
+
"isolation",
|
|
113
|
+
"mixBlendMode",
|
|
114
|
+
"opacity",
|
|
115
|
+
"outlineColor",
|
|
116
|
+
"outlineOffset",
|
|
117
|
+
"outlineStyle",
|
|
118
|
+
"outlineWidth",
|
|
119
|
+
"shadowColor",
|
|
120
|
+
"shadowOffset",
|
|
121
|
+
"shadowOpacity",
|
|
122
|
+
"shadowRadius",
|
|
123
|
+
// Transform
|
|
124
|
+
"rotation",
|
|
125
|
+
"scaleX",
|
|
126
|
+
"scaleY",
|
|
127
|
+
"transform",
|
|
128
|
+
"transformMatrix",
|
|
129
|
+
"transformOrigin",
|
|
130
|
+
"translateX",
|
|
131
|
+
"translateY",
|
|
132
|
+
// Text — a text slot only
|
|
133
|
+
"color",
|
|
134
|
+
"fontFamily",
|
|
135
|
+
"fontSize",
|
|
136
|
+
"fontStyle",
|
|
137
|
+
"fontVariant",
|
|
138
|
+
"fontWeight",
|
|
139
|
+
"includeFontPadding",
|
|
140
|
+
"letterSpacing",
|
|
141
|
+
"lineHeight",
|
|
142
|
+
"textAlign",
|
|
143
|
+
"textAlignVertical",
|
|
144
|
+
"textDecorationColor",
|
|
145
|
+
"textDecorationLine",
|
|
146
|
+
"textDecorationStyle",
|
|
147
|
+
"textShadowColor",
|
|
148
|
+
"textShadowOffset",
|
|
149
|
+
"textShadowRadius",
|
|
150
|
+
"textTransform",
|
|
151
|
+
"userSelect",
|
|
152
|
+
"verticalAlign",
|
|
153
|
+
"writingDirection",
|
|
154
|
+
// Image — an image slot only
|
|
155
|
+
"objectFit",
|
|
156
|
+
"overlayColor",
|
|
157
|
+
"resizeMode",
|
|
158
|
+
"tintColor"
|
|
159
|
+
];
|
|
160
|
+
var STYLE_PROP_KEY_SET = new Set(STYLE_PROP_KEYS);
|
|
161
|
+
function splitStyleProps(props) {
|
|
162
|
+
const styleProps = {};
|
|
163
|
+
const rest = {};
|
|
164
|
+
for (const [key, value] of Object.entries(props)) {
|
|
165
|
+
if (STYLE_PROP_KEY_SET.has(key)) styleProps[key] = value;
|
|
166
|
+
else rest[key] = value;
|
|
167
|
+
}
|
|
168
|
+
return [styleProps, rest];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/system/style-props/use-style-props.ts
|
|
172
|
+
function useStyleProps(props) {
|
|
173
|
+
const [styleProps, rest] = splitStyleProps(props);
|
|
174
|
+
const key = _chunk6N5JXRUZcjs.stableHash.call(void 0, styleProps);
|
|
175
|
+
return [_react.useMemo.call(void 0, () => styleProps, [key]), rest];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/system/slot/children-to-string.ts
|
|
179
|
+
|
|
180
|
+
function childrenToString(children) {
|
|
181
|
+
const text = stringify(children);
|
|
182
|
+
return text === null || text === "" ? null : text;
|
|
183
|
+
}
|
|
184
|
+
function stringify(node) {
|
|
185
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
186
|
+
if (typeof node === "string") return node;
|
|
187
|
+
if (typeof node === "number") return String(node);
|
|
188
|
+
if (_react.isValidElement.call(void 0, node)) return null;
|
|
189
|
+
if (Array.isArray(node)) {
|
|
190
|
+
let text = "";
|
|
191
|
+
for (const child of node) {
|
|
192
|
+
const part = stringify(child);
|
|
193
|
+
if (part === null) return null;
|
|
194
|
+
text += part;
|
|
195
|
+
}
|
|
196
|
+
return text;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/system/slot/create-slot-context.ts
|
|
202
|
+
|
|
203
|
+
function createSlotContext(name) {
|
|
204
|
+
const Context = _react.createContext.call(void 0, null);
|
|
205
|
+
Context.displayName = `XAUI.${name}.Context`;
|
|
206
|
+
function useSlotContext() {
|
|
207
|
+
const value = _react.useContext.call(void 0, Context);
|
|
208
|
+
if (value === null) {
|
|
209
|
+
const error = new Error(
|
|
210
|
+
`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.`
|
|
211
|
+
);
|
|
212
|
+
_optionalChain([Error, 'access', _ => _.captureStackTrace, 'optionalCall', _2 => _2(
|
|
213
|
+
error,
|
|
214
|
+
useSlotContext
|
|
215
|
+
)]);
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
return [Context.Provider, useSlotContext];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/system/slot/merge-refs.ts
|
|
224
|
+
function mergeRefs(...refs) {
|
|
225
|
+
return (value) => {
|
|
226
|
+
for (const ref of refs) {
|
|
227
|
+
if (typeof ref === "function") ref(value);
|
|
228
|
+
else if (ref) ref.current = value;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/system/slot/merge-props.ts
|
|
234
|
+
var EVENT_HANDLER = /^on[A-Z]/;
|
|
235
|
+
function mergeProps(ours, theirs) {
|
|
236
|
+
const merged = { ...ours };
|
|
237
|
+
for (const key of Object.keys(theirs)) {
|
|
238
|
+
const ourValue = ours[key];
|
|
239
|
+
const theirValue = theirs[key];
|
|
240
|
+
if (EVENT_HANDLER.test(key)) {
|
|
241
|
+
merged[key] = composeHandlers(ourValue, theirValue);
|
|
242
|
+
} else if (key === "style") {
|
|
243
|
+
merged[key] = mergeStyles(ourValue, theirValue);
|
|
244
|
+
} else if (key === "ref") {
|
|
245
|
+
merged[key] = mergeRefs(
|
|
246
|
+
ourValue,
|
|
247
|
+
theirValue
|
|
248
|
+
);
|
|
249
|
+
} else {
|
|
250
|
+
merged[key] = theirValue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return merged;
|
|
254
|
+
}
|
|
255
|
+
function composeHandlers(ours, theirs) {
|
|
256
|
+
if (typeof ours !== "function") return theirs;
|
|
257
|
+
if (typeof theirs !== "function") return ours;
|
|
258
|
+
return (...args) => {
|
|
259
|
+
;
|
|
260
|
+
ours(...args);
|
|
261
|
+
return theirs(...args);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function mergeStyles(ours, theirs) {
|
|
265
|
+
if (typeof ours === "function" || typeof theirs === "function") {
|
|
266
|
+
return (state) => [
|
|
267
|
+
resolveStyle(ours, state),
|
|
268
|
+
resolveStyle(theirs, state)
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
return [ours, theirs];
|
|
272
|
+
}
|
|
273
|
+
function resolveStyle(style, state) {
|
|
274
|
+
return typeof style === "function" ? style(state) : style;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/system/slot/slot.tsx
|
|
278
|
+
|
|
279
|
+
var Slot = _react.forwardRef.call(void 0, function Slot2({ children, ...ours }, ref) {
|
|
280
|
+
if (!_react.isValidElement.call(void 0, children)) {
|
|
281
|
+
throw new Error(
|
|
282
|
+
"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."
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
const child = children;
|
|
286
|
+
const merged = mergeProps(ours, child.props);
|
|
287
|
+
merged.ref = mergeRefs(ref, refOf(child));
|
|
288
|
+
return _react.cloneElement.call(void 0, child, merged);
|
|
289
|
+
});
|
|
290
|
+
Slot.displayName = "XAUI.Slot";
|
|
291
|
+
function refOf(element) {
|
|
292
|
+
const fromProps = element.props.ref;
|
|
293
|
+
const fromElement = element.ref;
|
|
294
|
+
return _nullishCoalesce(fromProps, () => ( fromElement));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/system/recipe/resolve-tint.ts
|
|
298
|
+
var TINT_SLICE_BY_SUFFIX = [
|
|
299
|
+
[/SoftForeground$/, "softForeground"],
|
|
300
|
+
[/SoftPressed$/, "softPressed"],
|
|
301
|
+
[/Soft$/, "soft"],
|
|
302
|
+
[/Foreground$/, "foreground"],
|
|
303
|
+
[/Pressed$/, "pressed"]
|
|
304
|
+
];
|
|
305
|
+
function tintSliceFor(token) {
|
|
306
|
+
for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
|
|
307
|
+
if (suffix.test(token)) return slice;
|
|
308
|
+
}
|
|
309
|
+
return "base";
|
|
310
|
+
}
|
|
311
|
+
function resolveTint(tokens, color, theme) {
|
|
312
|
+
const tint = _chunk6N5JXRUZcjs.deriveTint.call(void 0, color, theme);
|
|
313
|
+
const colors = {};
|
|
314
|
+
for (const [role, token] of Object.entries(_nullishCoalesce(tokens, () => ( {})))) {
|
|
315
|
+
colors[role] = tint[tintSliceFor(token)];
|
|
316
|
+
}
|
|
317
|
+
return colors;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/system/recipe/style-cache.ts
|
|
321
|
+
var _reactnative = require('react-native');
|
|
322
|
+
|
|
323
|
+
// src/system/recipe/variant-map.ts
|
|
324
|
+
var STATE_ORDER = ["focused", "pressed", "disabled"];
|
|
325
|
+
function resolveSelection(defaultVariants, selection) {
|
|
326
|
+
const resolved = { ...defaultVariants };
|
|
327
|
+
for (const [axis, value] of Object.entries(_nullishCoalesce(selection, () => ( {})))) {
|
|
328
|
+
if (value !== void 0) resolved[axis] = value;
|
|
329
|
+
}
|
|
330
|
+
return resolved;
|
|
331
|
+
}
|
|
332
|
+
function resolveVariantColors(tokens, theme) {
|
|
333
|
+
const colors = {};
|
|
334
|
+
for (const [role, token] of entriesOf(tokens)) {
|
|
335
|
+
const value = theme.colors[token];
|
|
336
|
+
if (value === void 0) {
|
|
337
|
+
throw new Error(
|
|
338
|
+
`XAUI: the recipe names "${token}" for its "${role}" role, but the theme has no such colour token. Check the spelling against XAUIColors.`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
colors[role] = value;
|
|
342
|
+
}
|
|
343
|
+
return colors;
|
|
344
|
+
}
|
|
345
|
+
function activeStateFns(states, active) {
|
|
346
|
+
const fns = [];
|
|
347
|
+
for (const state of STATE_ORDER) {
|
|
348
|
+
const fn = active[state] ? _optionalChain([states, 'optionalAccess', _3 => _3[state]]) : void 0;
|
|
349
|
+
if (fn) fns.push(fn);
|
|
350
|
+
}
|
|
351
|
+
return fns;
|
|
352
|
+
}
|
|
353
|
+
function collectStyleFns(config, selection, states) {
|
|
354
|
+
const fns = [];
|
|
355
|
+
if (config.base) fns.push(config.base);
|
|
356
|
+
if (config.paint) fns.push(config.paint);
|
|
357
|
+
for (const [axis, values] of Object.entries(_nullishCoalesce(config.variants, () => ( {})))) {
|
|
358
|
+
const value = selection[axis];
|
|
359
|
+
const fn = value === void 0 ? void 0 : values[value];
|
|
360
|
+
if (fn) fns.push(fn);
|
|
361
|
+
}
|
|
362
|
+
for (const compound of _nullishCoalesce(config.compoundVariants, () => ( []))) {
|
|
363
|
+
if (appliesTo(compound.when, selection)) fns.push(compound.style);
|
|
364
|
+
}
|
|
365
|
+
return [...fns, ...activeStateFns(config.states, states)];
|
|
366
|
+
}
|
|
367
|
+
function appliesTo(when, selection) {
|
|
368
|
+
return Object.entries(when).every(([axis, value]) => selection[axis] === value);
|
|
369
|
+
}
|
|
370
|
+
function entriesOf(tokens) {
|
|
371
|
+
return Object.entries(_nullishCoalesce(tokens, () => ( {})));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/system/recipe/style-cache.ts
|
|
375
|
+
function createStyleCache(slots) {
|
|
376
|
+
const entries = /* @__PURE__ */ new Map();
|
|
377
|
+
return {
|
|
378
|
+
read(key, build) {
|
|
379
|
+
const hit = entries.get(key);
|
|
380
|
+
if (hit) return hit;
|
|
381
|
+
const built = build();
|
|
382
|
+
const complete = {};
|
|
383
|
+
for (const slot of slots) complete[slot] = _nullishCoalesce(built[slot], () => ( {}));
|
|
384
|
+
const created = _reactnative.StyleSheet.create(complete);
|
|
385
|
+
entries.set(key, created);
|
|
386
|
+
return created;
|
|
387
|
+
},
|
|
388
|
+
get size() {
|
|
389
|
+
return entries.size;
|
|
390
|
+
},
|
|
391
|
+
clear() {
|
|
392
|
+
entries.clear();
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function cacheKey(theme, selection, states) {
|
|
397
|
+
const axes = Object.keys(selection).sort().map((axis) => `${axis}:${_nullishCoalesce(selection[axis], () => ( "-"))}`).join("|");
|
|
398
|
+
const active = STATE_ORDER.filter((state) => states[state]).join(",");
|
|
399
|
+
return `${theme.id}|${theme.mode}|${axes}|${active}`;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// src/system/recipe/create-recipe.ts
|
|
403
|
+
function createRecipe(config) {
|
|
404
|
+
const cache = createStyleCache(config.slots);
|
|
405
|
+
const tokensFor = (variant) => variant === void 0 ? void 0 : _optionalChain([config, 'access', _4 => _4.variantTokens, 'optionalAccess', _5 => _5[variant]]);
|
|
406
|
+
return {
|
|
407
|
+
slots: config.slots,
|
|
408
|
+
resolve({ theme, selection, states = {} }) {
|
|
409
|
+
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
410
|
+
return cache.read(cacheKey(theme, resolved, states), () => {
|
|
411
|
+
const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
|
|
412
|
+
return apply(collectStyleFns(config, resolved, states), theme, colors);
|
|
413
|
+
});
|
|
414
|
+
},
|
|
415
|
+
tint({ theme, color, selection, states = {} }) {
|
|
416
|
+
if (!config.paint) return {};
|
|
417
|
+
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
418
|
+
const tokens = tokensFor(resolved.variant);
|
|
419
|
+
if (!tokens) return {};
|
|
420
|
+
const colors = resolveTint(tokens, color, theme);
|
|
421
|
+
const fns = [config.paint, ...activeStateFns(config.states, states)];
|
|
422
|
+
return apply(fns, theme, colors);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function apply(fns, theme, colors) {
|
|
427
|
+
const merged = {};
|
|
428
|
+
for (const fn of fns) {
|
|
429
|
+
const produced = fn(theme, colors);
|
|
430
|
+
for (const slot of Object.keys(produced)) {
|
|
431
|
+
const style = produced[slot];
|
|
432
|
+
if (!style) continue;
|
|
433
|
+
const previous = merged[slot];
|
|
434
|
+
merged[slot] = previous ? { ...previous, ...style } : style;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return merged;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
exports.useStyleProps = useStyleProps; exports.childrenToString = childrenToString; exports.createSlotContext = createSlotContext; exports.mergeRefs = mergeRefs; exports.mergeProps = mergeProps; exports.Slot = Slot; exports.createRecipe = createRecipe;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Slot,
|
|
3
|
+
createRecipe,
|
|
4
|
+
useStyleProps
|
|
5
|
+
} from "./chunk-4K3LZS7M.js";
|
|
6
|
+
import {
|
|
7
|
+
useXAUITheme
|
|
8
|
+
} from "./chunk-XJARE6SC.js";
|
|
9
|
+
|
|
10
|
+
// src/components/typography/typography.tsx
|
|
11
|
+
import { forwardRef } from "react";
|
|
12
|
+
import { Text } from "react-native";
|
|
13
|
+
|
|
14
|
+
// src/components/typography/typography.recipe.ts
|
|
15
|
+
var SLOTS = ["root"];
|
|
16
|
+
var VARIANT_TOKENS = {
|
|
17
|
+
h1: { fg: "foreground" },
|
|
18
|
+
h2: { fg: "foreground" },
|
|
19
|
+
h3: { fg: "foreground" },
|
|
20
|
+
h4: { fg: "foreground" },
|
|
21
|
+
h5: { fg: "foreground" },
|
|
22
|
+
h6: { fg: "foreground" },
|
|
23
|
+
body: { fg: "foreground" },
|
|
24
|
+
"body-sm": { fg: "foreground" },
|
|
25
|
+
"body-xs": { fg: "foreground" },
|
|
26
|
+
code: { fg: "foreground" }
|
|
27
|
+
};
|
|
28
|
+
var ROLES = {
|
|
29
|
+
h1: { step: "4xl", weight: "bold", family: "heading", letterSpacing: -0.5 },
|
|
30
|
+
h2: { step: "3xl", weight: "bold", family: "heading", letterSpacing: -0.4 },
|
|
31
|
+
h3: { step: "2xl", weight: "bold", family: "heading", letterSpacing: -0.3 },
|
|
32
|
+
h4: { step: "xl", weight: "semibold", family: "heading" },
|
|
33
|
+
h5: { step: "lg", weight: "semibold", family: "heading" },
|
|
34
|
+
h6: { step: "md", weight: "semibold", family: "heading" },
|
|
35
|
+
body: { step: "md", weight: "regular", family: "body" },
|
|
36
|
+
"body-sm": { step: "sm", weight: "regular", family: "body" },
|
|
37
|
+
"body-xs": { step: "xs", weight: "regular", family: "body" },
|
|
38
|
+
code: { step: "sm", weight: "regular", family: "mono", chip: true }
|
|
39
|
+
};
|
|
40
|
+
function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
41
|
+
return (theme) => ({
|
|
42
|
+
root: {
|
|
43
|
+
fontSize: theme.fontSizes[step],
|
|
44
|
+
lineHeight: theme.lineHeights[step],
|
|
45
|
+
fontWeight: theme.fontWeights[weight],
|
|
46
|
+
fontFamily: theme.fontFamilies[family],
|
|
47
|
+
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
48
|
+
...chip === void 0 ? {} : {
|
|
49
|
+
alignSelf: "flex-start",
|
|
50
|
+
backgroundColor: theme.colors.default,
|
|
51
|
+
paddingHorizontal: theme.spacing(1.5),
|
|
52
|
+
paddingVertical: theme.spacing(0.5),
|
|
53
|
+
borderRadius: theme.radius.md
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
var ROLE_AXIS = Object.fromEntries(
|
|
59
|
+
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
60
|
+
);
|
|
61
|
+
var typographyRecipe = createRecipe({
|
|
62
|
+
slots: SLOTS,
|
|
63
|
+
variantTokens: VARIANT_TOKENS,
|
|
64
|
+
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
65
|
+
// where it also stays inside the cache key instead of being recomputed with the tint.
|
|
66
|
+
paint: (_theme, colors) => ({ root: { color: colors.fg } }),
|
|
67
|
+
variants: { variant: ROLE_AXIS },
|
|
68
|
+
defaultVariants: { variant: "body" }
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/components/typography/typography.tsx
|
|
72
|
+
import { jsx } from "react/jsx-runtime";
|
|
73
|
+
var Typography = forwardRef(function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
74
|
+
const theme = useXAUITheme();
|
|
75
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
76
|
+
const selection = { variant };
|
|
77
|
+
const styles = typographyRecipe.resolve({ theme, selection });
|
|
78
|
+
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
79
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
80
|
+
const Root = asChild ? Slot : Text;
|
|
81
|
+
return /* @__PURE__ */ jsx(Root, { ref, style: rootStyle, ...rest, children });
|
|
82
|
+
});
|
|
83
|
+
Typography.displayName = "XAUI.Typography";
|
|
84
|
+
|
|
85
|
+
// src/components/typography/text-span.tsx
|
|
86
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
87
|
+
import { Text as Text2 } from "react-native";
|
|
88
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
89
|
+
var TextSpan = forwardRef2(function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
90
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
91
|
+
const Root = asChild ? Slot : Text2;
|
|
92
|
+
return /* @__PURE__ */ jsx2(Root, { ref, style: [styleProps, style], ...rest, children });
|
|
93
|
+
});
|
|
94
|
+
TextSpan.displayName = "XAUI.TextSpan";
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
typographyRecipe,
|
|
98
|
+
Typography,
|
|
99
|
+
TextSpan
|
|
100
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
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; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk5SU7FXWHcjs = require('./chunk-5SU7FXWH.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk6N5JXRUZcjs = require('./chunk-6N5JXRUZ.cjs');
|
|
9
|
+
|
|
10
|
+
// src/components/typography/typography.tsx
|
|
11
|
+
var _react = require('react');
|
|
12
|
+
var _reactnative = require('react-native');
|
|
13
|
+
|
|
14
|
+
// src/components/typography/typography.recipe.ts
|
|
15
|
+
var SLOTS = ["root"];
|
|
16
|
+
var VARIANT_TOKENS = {
|
|
17
|
+
h1: { fg: "foreground" },
|
|
18
|
+
h2: { fg: "foreground" },
|
|
19
|
+
h3: { fg: "foreground" },
|
|
20
|
+
h4: { fg: "foreground" },
|
|
21
|
+
h5: { fg: "foreground" },
|
|
22
|
+
h6: { fg: "foreground" },
|
|
23
|
+
body: { fg: "foreground" },
|
|
24
|
+
"body-sm": { fg: "foreground" },
|
|
25
|
+
"body-xs": { fg: "foreground" },
|
|
26
|
+
code: { fg: "foreground" }
|
|
27
|
+
};
|
|
28
|
+
var ROLES = {
|
|
29
|
+
h1: { step: "4xl", weight: "bold", family: "heading", letterSpacing: -0.5 },
|
|
30
|
+
h2: { step: "3xl", weight: "bold", family: "heading", letterSpacing: -0.4 },
|
|
31
|
+
h3: { step: "2xl", weight: "bold", family: "heading", letterSpacing: -0.3 },
|
|
32
|
+
h4: { step: "xl", weight: "semibold", family: "heading" },
|
|
33
|
+
h5: { step: "lg", weight: "semibold", family: "heading" },
|
|
34
|
+
h6: { step: "md", weight: "semibold", family: "heading" },
|
|
35
|
+
body: { step: "md", weight: "regular", family: "body" },
|
|
36
|
+
"body-sm": { step: "sm", weight: "regular", family: "body" },
|
|
37
|
+
"body-xs": { step: "xs", weight: "regular", family: "body" },
|
|
38
|
+
code: { step: "sm", weight: "regular", family: "mono", chip: true }
|
|
39
|
+
};
|
|
40
|
+
function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
41
|
+
return (theme) => ({
|
|
42
|
+
root: {
|
|
43
|
+
fontSize: theme.fontSizes[step],
|
|
44
|
+
lineHeight: theme.lineHeights[step],
|
|
45
|
+
fontWeight: theme.fontWeights[weight],
|
|
46
|
+
fontFamily: theme.fontFamilies[family],
|
|
47
|
+
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
48
|
+
...chip === void 0 ? {} : {
|
|
49
|
+
alignSelf: "flex-start",
|
|
50
|
+
backgroundColor: theme.colors.default,
|
|
51
|
+
paddingHorizontal: theme.spacing(1.5),
|
|
52
|
+
paddingVertical: theme.spacing(0.5),
|
|
53
|
+
borderRadius: theme.radius.md
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
var ROLE_AXIS = Object.fromEntries(
|
|
59
|
+
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
60
|
+
);
|
|
61
|
+
var typographyRecipe = _chunk5SU7FXWHcjs.createRecipe.call(void 0, {
|
|
62
|
+
slots: SLOTS,
|
|
63
|
+
variantTokens: VARIANT_TOKENS,
|
|
64
|
+
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
65
|
+
// where it also stays inside the cache key instead of being recomputed with the tint.
|
|
66
|
+
paint: (_theme, colors) => ({ root: { color: colors.fg } }),
|
|
67
|
+
variants: { variant: ROLE_AXIS },
|
|
68
|
+
defaultVariants: { variant: "body" }
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// src/components/typography/typography.tsx
|
|
72
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
73
|
+
var Typography = _react.forwardRef.call(void 0, function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
74
|
+
const theme = _chunk6N5JXRUZcjs.useXAUITheme.call(void 0, );
|
|
75
|
+
const [styleProps, rest] = _chunk5SU7FXWHcjs.useStyleProps.call(void 0, props);
|
|
76
|
+
const selection = { variant };
|
|
77
|
+
const styles = typographyRecipe.resolve({ theme, selection });
|
|
78
|
+
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
79
|
+
const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _ => _.root]), styleProps, style];
|
|
80
|
+
const Root = asChild ? _chunk5SU7FXWHcjs.Slot : _reactnative.Text;
|
|
81
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: rootStyle, ...rest, children });
|
|
82
|
+
});
|
|
83
|
+
Typography.displayName = "XAUI.Typography";
|
|
84
|
+
|
|
85
|
+
// src/components/typography/text-span.tsx
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var TextSpan = _react.forwardRef.call(void 0, function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
90
|
+
const [styleProps, rest] = _chunk5SU7FXWHcjs.useStyleProps.call(void 0, props);
|
|
91
|
+
const Root = asChild ? _chunk5SU7FXWHcjs.Slot : _reactnative.Text;
|
|
92
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [styleProps, style], ...rest, children });
|
|
93
|
+
});
|
|
94
|
+
TextSpan.displayName = "XAUI.TextSpan";
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
exports.typographyRecipe = typographyRecipe; exports.Typography = Typography; exports.TextSpan = TextSpan;
|
|
@@ -47,6 +47,7 @@ function deriveColors(s) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// src/theme/scales.ts
|
|
50
|
+
|
|
50
51
|
var SPACING_UNIT = 4;
|
|
51
52
|
var RADIUS_BASE = 12;
|
|
52
53
|
function buildRadius(base) {
|
|
@@ -98,7 +99,10 @@ var fontWeights = {
|
|
|
98
99
|
var fontFamilies = {
|
|
99
100
|
body: "System",
|
|
100
101
|
heading: "System",
|
|
101
|
-
|
|
102
|
+
// `'monospace'` is an Android family name, not a generic one: iOS does not resolve it and
|
|
103
|
+
// silently falls back to the system face, so code set with it is not monospaced there.
|
|
104
|
+
// Menlo is the face iOS ships, and it is what HeroUI Native selects for the same reason.
|
|
105
|
+
mono: _reactnative.Platform.OS === "ios" ? "Menlo" : "monospace"
|
|
102
106
|
};
|
|
103
107
|
var borderWidth = { default: 1, field: 1 };
|
|
104
108
|
var opacity = { disabled: 0.5 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5SU7FXWHcjs = require('./chunk-5SU7FXWH.cjs');
|
|
4
4
|
|
|
5
5
|
// src/system/portal/portal.tsx
|
|
6
6
|
var _react = require('react');
|
|
@@ -31,7 +31,7 @@ var styles = _reactnative.StyleSheet.create({
|
|
|
31
31
|
container: { flex: 1 }
|
|
32
32
|
});
|
|
33
33
|
function PortalHost({ children, ...props }) {
|
|
34
|
-
const [styleProps] =
|
|
34
|
+
const [styleProps] = _chunk5SU7FXWHcjs.useStyleProps.call(void 0, props);
|
|
35
35
|
const [portals, setPortals] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
|
|
36
36
|
const addPortal = _react.useCallback.call(void 0, (key, element) => {
|
|
37
37
|
setPortals((current) => new Map(current).set(key, element));
|