@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.
- package/dist/chunk-2WMVDMFV.cjs +62 -0
- package/dist/chunk-33QILJJH.cjs +143 -0
- package/dist/chunk-4EPS7UBO.js +496 -0
- package/dist/{chunk-M7P46XKI.cjs → chunk-57SJ4LJF.cjs} +33 -3
- package/dist/chunk-6ARON3XT.cjs +534 -0
- package/dist/{chunk-RBNCR5KB.js → chunk-A3EGFI6T.js} +31 -1
- package/dist/chunk-A4VD4MHK.cjs +757 -0
- package/dist/{chunk-NHPQQQ7P.cjs → chunk-BHTFIZTQ.cjs} +55 -88
- package/dist/chunk-EVXZGNPA.cjs +303 -0
- package/dist/chunk-EXX6ATAS.js +303 -0
- package/dist/chunk-GGW42MY4.js +20 -0
- package/dist/chunk-JXLRHKCQ.js +143 -0
- package/dist/chunk-MC7SY2QH.cjs +20 -0
- package/dist/{chunk-PBVPOX7D.js → chunk-MWXE7D4L.js} +29 -62
- package/dist/{chunk-RCP3SD26.js → chunk-N7C4UNUL.js} +2 -126
- package/dist/chunk-RMLFMRWL.js +102 -0
- package/dist/chunk-UBA6AEY6.cjs +102 -0
- package/dist/{chunk-B755PRVJ.cjs → chunk-UVO4GFSW.cjs} +3 -127
- package/dist/chunk-WXAME7KB.js +728 -0
- package/dist/chunk-XHZBXYVU.js +62 -0
- package/dist/components/button/index.cjs +15 -0
- package/dist/components/button/index.d.cts +658 -0
- package/dist/components/button/index.d.ts +658 -0
- package/dist/components/button/index.js +15 -0
- package/dist/components/typography/index.cjs +14 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +14 -0
- package/dist/components/view/index.cjs +16 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +16 -0
- package/dist/create-recipe-C0XXjuow.d.cts +89 -0
- package/dist/create-recipe-CPXFo2rk.d.ts +89 -0
- package/dist/index.cjs +151 -5
- package/dist/index.d.cts +77 -4
- package/dist/index.d.ts +77 -4
- package/dist/index.js +155 -9
- package/dist/pressable-feedback.type-1K8YEOb8.d.cts +195 -0
- package/dist/pressable-feedback.type-BwkKLQlX.d.ts +195 -0
- package/dist/style-props.type-B1BG5TCm.d.cts +31 -0
- package/dist/style-props.type-B1BG5TCm.d.ts +31 -0
- package/dist/system/index.cjs +64 -3
- package/dist/system/index.d.cts +299 -75
- package/dist/system/index.d.ts +299 -75
- package/dist/system/index.js +66 -5
- package/dist/theme/index.cjs +4 -3
- package/dist/theme/index.d.cts +26 -14
- package/dist/theme/index.d.ts +26 -14
- package/dist/theme/index.js +7 -6
- package/dist/{theme.type-B3ODSLbB.d.cts → theme.type-C2gNHpEx.d.cts} +8 -2
- package/dist/{theme.type-B3ODSLbB.d.ts → theme.type-C2gNHpEx.d.ts} +8 -2
- package/package.json +64 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deriveTint
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-A3EGFI6T.js";
|
|
4
4
|
|
|
5
5
|
// src/system/recipe/resolve-tint.ts
|
|
6
6
|
var TINT_SLICE_BY_SUFFIX = [
|
|
@@ -145,130 +145,6 @@ 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
|
-
|
|
267
148
|
export {
|
|
268
|
-
createRecipe
|
|
269
|
-
childrenToString,
|
|
270
|
-
createSlotContext,
|
|
271
|
-
mergeRefs,
|
|
272
|
-
mergeProps,
|
|
273
|
-
Slot
|
|
149
|
+
createRecipe
|
|
274
150
|
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRecipe
|
|
3
|
+
} from "./chunk-N7C4UNUL.js";
|
|
4
|
+
import {
|
|
5
|
+
Slot,
|
|
6
|
+
useStyleProps
|
|
7
|
+
} from "./chunk-EXX6ATAS.js";
|
|
8
|
+
import {
|
|
9
|
+
useXAUITheme
|
|
10
|
+
} from "./chunk-A3EGFI6T.js";
|
|
11
|
+
|
|
12
|
+
// src/components/typography/typography.tsx
|
|
13
|
+
import { forwardRef } from "react";
|
|
14
|
+
import { Text } from "react-native";
|
|
15
|
+
|
|
16
|
+
// src/components/typography/typography.recipe.ts
|
|
17
|
+
var SLOTS = ["root"];
|
|
18
|
+
var VARIANT_TOKENS = {
|
|
19
|
+
h1: { fg: "foreground" },
|
|
20
|
+
h2: { fg: "foreground" },
|
|
21
|
+
h3: { fg: "foreground" },
|
|
22
|
+
h4: { fg: "foreground" },
|
|
23
|
+
h5: { fg: "foreground" },
|
|
24
|
+
h6: { fg: "foreground" },
|
|
25
|
+
body: { fg: "foreground" },
|
|
26
|
+
"body-sm": { fg: "foreground" },
|
|
27
|
+
"body-xs": { fg: "foreground" },
|
|
28
|
+
code: { fg: "foreground" }
|
|
29
|
+
};
|
|
30
|
+
var ROLES = {
|
|
31
|
+
h1: { step: "4xl", weight: "bold", family: "heading", letterSpacing: -0.5 },
|
|
32
|
+
h2: { step: "3xl", weight: "bold", family: "heading", letterSpacing: -0.4 },
|
|
33
|
+
h3: { step: "2xl", weight: "bold", family: "heading", letterSpacing: -0.3 },
|
|
34
|
+
h4: { step: "xl", weight: "semibold", family: "heading" },
|
|
35
|
+
h5: { step: "lg", weight: "semibold", family: "heading" },
|
|
36
|
+
h6: { step: "md", weight: "semibold", family: "heading" },
|
|
37
|
+
body: { step: "md", weight: "regular", family: "body" },
|
|
38
|
+
"body-sm": { step: "sm", weight: "regular", family: "body" },
|
|
39
|
+
"body-xs": { step: "xs", weight: "regular", family: "body" },
|
|
40
|
+
code: { step: "sm", weight: "regular", family: "mono", chip: true }
|
|
41
|
+
};
|
|
42
|
+
function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
43
|
+
return (theme) => ({
|
|
44
|
+
root: {
|
|
45
|
+
fontSize: theme.fontSizes[step],
|
|
46
|
+
lineHeight: theme.lineHeights[step],
|
|
47
|
+
fontWeight: theme.fontWeights[weight],
|
|
48
|
+
fontFamily: theme.fontFamilies[family],
|
|
49
|
+
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
50
|
+
...chip === void 0 ? {} : {
|
|
51
|
+
alignSelf: "flex-start",
|
|
52
|
+
backgroundColor: theme.colors.default,
|
|
53
|
+
paddingHorizontal: theme.spacing(1.5),
|
|
54
|
+
paddingVertical: theme.spacing(0.5),
|
|
55
|
+
borderRadius: theme.radius.md
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var ROLE_AXIS = Object.fromEntries(
|
|
61
|
+
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
62
|
+
);
|
|
63
|
+
var typographyRecipe = createRecipe({
|
|
64
|
+
slots: SLOTS,
|
|
65
|
+
variantTokens: VARIANT_TOKENS,
|
|
66
|
+
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
67
|
+
// where it also stays inside the cache key instead of being recomputed with the tint.
|
|
68
|
+
paint: (_theme, colors) => ({ root: { color: colors.fg } }),
|
|
69
|
+
variants: { variant: ROLE_AXIS },
|
|
70
|
+
defaultVariants: { variant: "body" }
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/components/typography/typography.tsx
|
|
74
|
+
import { jsx } from "react/jsx-runtime";
|
|
75
|
+
var Typography = forwardRef(function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
76
|
+
const theme = useXAUITheme();
|
|
77
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
78
|
+
const selection = { variant };
|
|
79
|
+
const styles = typographyRecipe.resolve({ theme, selection });
|
|
80
|
+
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
81
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
82
|
+
const Root = asChild ? Slot : Text;
|
|
83
|
+
return /* @__PURE__ */ jsx(Root, { ref, style: rootStyle, ...rest, children });
|
|
84
|
+
});
|
|
85
|
+
Typography.displayName = "XAUI.Typography";
|
|
86
|
+
|
|
87
|
+
// src/components/typography/text-span.tsx
|
|
88
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
89
|
+
import { Text as Text2 } from "react-native";
|
|
90
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
91
|
+
var TextSpan = forwardRef2(function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
92
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
93
|
+
const Root = asChild ? Slot : Text2;
|
|
94
|
+
return /* @__PURE__ */ jsx2(Root, { ref, style: [styleProps, style], ...rest, children });
|
|
95
|
+
});
|
|
96
|
+
TextSpan.displayName = "XAUI.TextSpan";
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
typographyRecipe,
|
|
100
|
+
Typography,
|
|
101
|
+
TextSpan
|
|
102
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
var _chunkUVO4GFSWcjs = require('./chunk-UVO4GFSW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkEVXZGNPAcjs = require('./chunk-EVXZGNPA.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
11
|
+
|
|
12
|
+
// src/components/typography/typography.tsx
|
|
13
|
+
var _react = require('react');
|
|
14
|
+
var _reactnative = require('react-native');
|
|
15
|
+
|
|
16
|
+
// src/components/typography/typography.recipe.ts
|
|
17
|
+
var SLOTS = ["root"];
|
|
18
|
+
var VARIANT_TOKENS = {
|
|
19
|
+
h1: { fg: "foreground" },
|
|
20
|
+
h2: { fg: "foreground" },
|
|
21
|
+
h3: { fg: "foreground" },
|
|
22
|
+
h4: { fg: "foreground" },
|
|
23
|
+
h5: { fg: "foreground" },
|
|
24
|
+
h6: { fg: "foreground" },
|
|
25
|
+
body: { fg: "foreground" },
|
|
26
|
+
"body-sm": { fg: "foreground" },
|
|
27
|
+
"body-xs": { fg: "foreground" },
|
|
28
|
+
code: { fg: "foreground" }
|
|
29
|
+
};
|
|
30
|
+
var ROLES = {
|
|
31
|
+
h1: { step: "4xl", weight: "bold", family: "heading", letterSpacing: -0.5 },
|
|
32
|
+
h2: { step: "3xl", weight: "bold", family: "heading", letterSpacing: -0.4 },
|
|
33
|
+
h3: { step: "2xl", weight: "bold", family: "heading", letterSpacing: -0.3 },
|
|
34
|
+
h4: { step: "xl", weight: "semibold", family: "heading" },
|
|
35
|
+
h5: { step: "lg", weight: "semibold", family: "heading" },
|
|
36
|
+
h6: { step: "md", weight: "semibold", family: "heading" },
|
|
37
|
+
body: { step: "md", weight: "regular", family: "body" },
|
|
38
|
+
"body-sm": { step: "sm", weight: "regular", family: "body" },
|
|
39
|
+
"body-xs": { step: "xs", weight: "regular", family: "body" },
|
|
40
|
+
code: { step: "sm", weight: "regular", family: "mono", chip: true }
|
|
41
|
+
};
|
|
42
|
+
function metricsOf({ step, weight, family, letterSpacing, chip }) {
|
|
43
|
+
return (theme) => ({
|
|
44
|
+
root: {
|
|
45
|
+
fontSize: theme.fontSizes[step],
|
|
46
|
+
lineHeight: theme.lineHeights[step],
|
|
47
|
+
fontWeight: theme.fontWeights[weight],
|
|
48
|
+
fontFamily: theme.fontFamilies[family],
|
|
49
|
+
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
50
|
+
...chip === void 0 ? {} : {
|
|
51
|
+
alignSelf: "flex-start",
|
|
52
|
+
backgroundColor: theme.colors.default,
|
|
53
|
+
paddingHorizontal: theme.spacing(1.5),
|
|
54
|
+
paddingVertical: theme.spacing(0.5),
|
|
55
|
+
borderRadius: theme.radius.md
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var ROLE_AXIS = Object.fromEntries(
|
|
61
|
+
Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
|
|
62
|
+
);
|
|
63
|
+
var typographyRecipe = _chunkUVO4GFSWcjs.createRecipe.call(void 0, {
|
|
64
|
+
slots: SLOTS,
|
|
65
|
+
variantTokens: VARIANT_TOKENS,
|
|
66
|
+
// Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
|
|
67
|
+
// where it also stays inside the cache key instead of being recomputed with the tint.
|
|
68
|
+
paint: (_theme, colors) => ({ root: { color: colors.fg } }),
|
|
69
|
+
variants: { variant: ROLE_AXIS },
|
|
70
|
+
defaultVariants: { variant: "body" }
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/components/typography/typography.tsx
|
|
74
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
75
|
+
var Typography = _react.forwardRef.call(void 0, function Typography2({ children, variant, color, asChild = false, style, ...props }, ref) {
|
|
76
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
77
|
+
const [styleProps, rest] = _chunkEVXZGNPAcjs.useStyleProps.call(void 0, props);
|
|
78
|
+
const selection = { variant };
|
|
79
|
+
const styles = typographyRecipe.resolve({ theme, selection });
|
|
80
|
+
const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
|
|
81
|
+
const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _ => _.root]), styleProps, style];
|
|
82
|
+
const Root = asChild ? _chunkEVXZGNPAcjs.Slot : _reactnative.Text;
|
|
83
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: rootStyle, ...rest, children });
|
|
84
|
+
});
|
|
85
|
+
Typography.displayName = "XAUI.Typography";
|
|
86
|
+
|
|
87
|
+
// src/components/typography/text-span.tsx
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var TextSpan = _react.forwardRef.call(void 0, function TextSpan2({ children, asChild = false, style, ...props }, ref) {
|
|
92
|
+
const [styleProps, rest] = _chunkEVXZGNPAcjs.useStyleProps.call(void 0, props);
|
|
93
|
+
const Root = asChild ? _chunkEVXZGNPAcjs.Slot : _reactnative.Text;
|
|
94
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [styleProps, style], ...rest, children });
|
|
95
|
+
});
|
|
96
|
+
TextSpan.displayName = "XAUI.TextSpan";
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
exports.typographyRecipe = typographyRecipe; exports.Typography = Typography; exports.TextSpan = TextSpan;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
4
4
|
|
|
5
5
|
// src/system/recipe/resolve-tint.ts
|
|
6
6
|
var TINT_SLICE_BY_SUFFIX = [
|
|
@@ -17,7 +17,7 @@ function tintSliceFor(token) {
|
|
|
17
17
|
return "base";
|
|
18
18
|
}
|
|
19
19
|
function resolveTint(tokens, color, theme) {
|
|
20
|
-
const tint =
|
|
20
|
+
const tint = _chunk57SJ4LJFcjs.deriveTint.call(void 0, color, theme);
|
|
21
21
|
const colors = {};
|
|
22
22
|
for (const [role, token] of Object.entries(_nullishCoalesce(tokens, () => ( {})))) {
|
|
23
23
|
colors[role] = tint[tintSliceFor(token)];
|
|
@@ -145,130 +145,6 @@ 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
|
-
|
|
272
148
|
|
|
273
149
|
|
|
274
|
-
exports.createRecipe = createRecipe;
|
|
150
|
+
exports.createRecipe = createRecipe;
|