@xaui/native 0.9.1-alpha.2 → 0.9.1-alpha.21
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-4NE3SLTM.cjs +695 -0
- package/dist/{chunk-M7P46XKI.cjs → chunk-57SJ4LJF.cjs} +33 -3
- package/dist/chunk-5LC6KVL3.cjs +68 -0
- package/dist/{chunk-RBNCR5KB.js → chunk-A3EGFI6T.js} +31 -1
- package/dist/chunk-APCBIHLR.cjs +507 -0
- package/dist/chunk-BPBY7ON7.cjs +451 -0
- package/dist/chunk-EVXZGNPA.cjs +303 -0
- package/dist/chunk-EXX6ATAS.js +303 -0
- package/dist/chunk-GGW42MY4.js +20 -0
- package/dist/chunk-IBRVMLUF.js +668 -0
- package/dist/chunk-ISVUXVFL.js +471 -0
- package/dist/chunk-JL27KVRT.js +68 -0
- package/dist/chunk-JXLRHKCQ.js +143 -0
- package/dist/chunk-MC7SY2QH.cjs +20 -0
- package/dist/{chunk-RCP3SD26.js → chunk-N7C4UNUL.js} +2 -126
- package/dist/chunk-RMLFMRWL.js +102 -0
- package/dist/chunk-RRRGLRRP.cjs +28 -0
- package/dist/chunk-SGHP76GU.js +28 -0
- package/dist/{chunk-PBVPOX7D.js → chunk-TUJBDS5M.js} +30 -63
- package/dist/chunk-UBA6AEY6.cjs +102 -0
- package/dist/{chunk-NHPQQQ7P.cjs → chunk-UL263KGM.cjs} +56 -89
- package/dist/{chunk-B755PRVJ.cjs → chunk-UVO4GFSW.cjs} +3 -127
- package/dist/chunk-XHZBXYVU.js +62 -0
- package/dist/chunk-YRCUALUQ.js +451 -0
- package/dist/components/button/index.cjs +17 -0
- package/dist/components/button/index.d.cts +659 -0
- package/dist/components/button/index.d.ts +659 -0
- package/dist/components/button/index.js +17 -0
- package/dist/components/card/index.cjs +20 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +20 -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-CC3NNCqF.d.ts +94 -0
- package/dist/create-recipe-CPBFg7ym.d.cts +94 -0
- package/dist/icon.type-BkcEPJbK.d.ts +73 -0
- package/dist/icon.type-Cs1tMX0W.d.cts +73 -0
- package/dist/index.cjs +167 -5
- package/dist/index.d.cts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +171 -9
- package/dist/pressable-feedback.type-DsvWZXWC.d.ts +127 -0
- package/dist/pressable-feedback.type-wfeiJz5m.d.cts +127 -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 +66 -3
- package/dist/system/index.d.cts +301 -75
- package/dist/system/index.d.ts +301 -75
- package/dist/system/index.js +68 -5
- package/dist/theme/index.cjs +4 -3
- package/dist/theme/index.d.cts +27 -15
- package/dist/theme/index.d.ts +27 -15
- 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 +74 -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,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/hooks/use-press-state.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
function usePressState(handlers = {}) {
|
|
4
|
+
const [isPressed, setIsPressed] = _react.useState.call(void 0, false);
|
|
5
|
+
const latest = _react.useRef.call(void 0, handlers);
|
|
6
|
+
latest.current = handlers;
|
|
7
|
+
const onPressIn = _react.useCallback.call(void 0, (event) => {
|
|
8
|
+
setIsPressed(true);
|
|
9
|
+
_optionalChain([latest, 'access', _ => _.current, 'access', _2 => _2.onPressIn, 'optionalCall', _3 => _3(event)]);
|
|
10
|
+
}, []);
|
|
11
|
+
const onPressOut = _react.useCallback.call(void 0, (event) => {
|
|
12
|
+
setIsPressed(false);
|
|
13
|
+
_optionalChain([latest, 'access', _4 => _4.current, 'access', _5 => _5.onPressOut, 'optionalCall', _6 => _6(event)]);
|
|
14
|
+
}, []);
|
|
15
|
+
const press = _react.useRef.call(void 0, { onPressIn, onPressOut }).current;
|
|
16
|
+
return [isPressed, press];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/utils/warn-dev.ts
|
|
20
|
+
function warnDev(message) {
|
|
21
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
22
|
+
console.warn(`XAUI: ${message}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.usePressState = usePressState; exports.warnDev = warnDev;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/hooks/use-press-state.ts
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
function usePressState(handlers = {}) {
|
|
4
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
5
|
+
const latest = useRef(handlers);
|
|
6
|
+
latest.current = handlers;
|
|
7
|
+
const onPressIn = useCallback((event) => {
|
|
8
|
+
setIsPressed(true);
|
|
9
|
+
latest.current.onPressIn?.(event);
|
|
10
|
+
}, []);
|
|
11
|
+
const onPressOut = useCallback((event) => {
|
|
12
|
+
setIsPressed(false);
|
|
13
|
+
latest.current.onPressOut?.(event);
|
|
14
|
+
}, []);
|
|
15
|
+
const press = useRef({ onPressIn, onPressOut }).current;
|
|
16
|
+
return [isPressed, press];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/utils/warn-dev.ts
|
|
20
|
+
function warnDev(message) {
|
|
21
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
22
|
+
console.warn(`XAUI: ${message}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
usePressState,
|
|
27
|
+
warnDev
|
|
28
|
+
};
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ThemeContext,
|
|
2
3
|
alpha,
|
|
3
4
|
mix
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-A3EGFI6T.js";
|
|
6
|
+
import {
|
|
7
|
+
stableHash
|
|
8
|
+
} from "./chunk-GGW42MY4.js";
|
|
5
9
|
|
|
6
10
|
// src/provider/xaui-provider.tsx
|
|
7
11
|
import { useColorScheme } from "react-native";
|
|
8
12
|
|
|
9
|
-
// src/utils/stable-hash.ts
|
|
10
|
-
function canonical(value) {
|
|
11
|
-
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
12
|
-
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
13
|
-
const entries = Object.entries(value).filter(([, v]) => typeof v !== "function").sort(([a], [b]) => a < b ? -1 : 1).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`);
|
|
14
|
-
return `{${entries.join(",")}}`;
|
|
15
|
-
}
|
|
16
|
-
function stableHash(value) {
|
|
17
|
-
const input = canonical(value);
|
|
18
|
-
let hash = 2166136261;
|
|
19
|
-
for (let i = 0; i < input.length; i++) {
|
|
20
|
-
hash ^= input.charCodeAt(i);
|
|
21
|
-
hash = Math.imul(hash, 16777619) >>> 0;
|
|
22
|
-
}
|
|
23
|
-
return hash.toString(36);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
13
|
// src/theme/derive-colors.ts
|
|
27
14
|
function deriveColors(s) {
|
|
28
15
|
return {
|
|
29
|
-
accentPressed: mix(s.accent, s.
|
|
30
|
-
successPressed: mix(s.success, s.
|
|
31
|
-
warningPressed: mix(s.warning, s.
|
|
32
|
-
dangerPressed: mix(s.danger, s.
|
|
16
|
+
accentPressed: mix(s.accent, s.foreground, 0.1),
|
|
17
|
+
successPressed: mix(s.success, s.foreground, 0.1),
|
|
18
|
+
warningPressed: mix(s.warning, s.foreground, 0.1),
|
|
19
|
+
dangerPressed: mix(s.danger, s.foreground, 0.1),
|
|
33
20
|
defaultPressed: mix(s.default, s.defaultForeground, 0.04),
|
|
34
21
|
surfacePressed: mix(s.surface, s.surfaceForeground, 0.08),
|
|
35
22
|
defaultSoft: alpha(s.default, 0.5),
|
|
@@ -62,6 +49,7 @@ function deriveColors(s) {
|
|
|
62
49
|
}
|
|
63
50
|
|
|
64
51
|
// src/theme/scales.ts
|
|
52
|
+
import { Platform } from "react-native";
|
|
65
53
|
var SPACING_UNIT = 4;
|
|
66
54
|
var RADIUS_BASE = 12;
|
|
67
55
|
function buildRadius(base) {
|
|
@@ -113,7 +101,10 @@ var fontWeights = {
|
|
|
113
101
|
var fontFamilies = {
|
|
114
102
|
body: "System",
|
|
115
103
|
heading: "System",
|
|
116
|
-
|
|
104
|
+
// `'monospace'` is an Android family name, not a generic one: iOS does not resolve it and
|
|
105
|
+
// silently falls back to the system face, so code set with it is not monospaced there.
|
|
106
|
+
// Menlo is the face iOS ships, and it is what HeroUI Native selects for the same reason.
|
|
107
|
+
mono: Platform.OS === "ios" ? "Menlo" : "monospace"
|
|
117
108
|
};
|
|
118
109
|
var borderWidth = { default: 1, field: 1 };
|
|
119
110
|
var opacity = { disabled: 0.5 };
|
|
@@ -170,7 +161,7 @@ var tokens = {
|
|
|
170
161
|
foreground: "#18181b",
|
|
171
162
|
surface: "#ffffff",
|
|
172
163
|
surfaceForeground: "#18181b",
|
|
173
|
-
surfaceSecondary: "#
|
|
164
|
+
surfaceSecondary: "#ececee",
|
|
174
165
|
surfaceSecondaryForeground: "#18181b",
|
|
175
166
|
surfaceTertiary: "#e4e4e7",
|
|
176
167
|
surfaceTertiaryForeground: "#18181b",
|
|
@@ -178,7 +169,7 @@ var tokens = {
|
|
|
178
169
|
overlayForeground: "#18181b",
|
|
179
170
|
backdrop: "rgba(0, 0, 0, 0.2)",
|
|
180
171
|
muted: "#71717a",
|
|
181
|
-
default: "#
|
|
172
|
+
default: "#e4e4e7",
|
|
182
173
|
defaultForeground: "#18181b",
|
|
183
174
|
accent: "#9333ea",
|
|
184
175
|
accentForeground: "#faf5ff",
|
|
@@ -198,15 +189,15 @@ var tokens = {
|
|
|
198
189
|
separator: "#d4d4d8",
|
|
199
190
|
focus: "#9333ea",
|
|
200
191
|
link: "#18181b",
|
|
201
|
-
accentPressed: "#
|
|
202
|
-
successPressed: "#
|
|
203
|
-
warningPressed: "#
|
|
204
|
-
dangerPressed: "#
|
|
205
|
-
defaultPressed: "#
|
|
192
|
+
accentPressed: "#8533d3",
|
|
193
|
+
successPressed: "#1b753a",
|
|
194
|
+
warningPressed: "#a34d13",
|
|
195
|
+
dangerPressed: "#c72927",
|
|
196
|
+
defaultPressed: "#dbdbde",
|
|
206
197
|
surfacePressed: "#eaeaea",
|
|
207
|
-
defaultSoft: "rgba(
|
|
198
|
+
defaultSoft: "rgba(228, 228, 231, 0.5)",
|
|
208
199
|
defaultSoftForeground: "#18181b",
|
|
209
|
-
defaultSoftPressed: "rgba(
|
|
200
|
+
defaultSoftPressed: "rgba(228, 228, 231, 0.6)",
|
|
210
201
|
accentSoft: "rgba(147, 51, 234, 0.15)",
|
|
211
202
|
accentSoftForeground: "#7833bc",
|
|
212
203
|
accentSoftPressed: "rgba(147, 51, 234, 0.2)",
|
|
@@ -268,10 +259,10 @@ var tokens = {
|
|
|
268
259
|
separator: "#52525b",
|
|
269
260
|
focus: "#c084fc",
|
|
270
261
|
link: "#fafafa",
|
|
271
|
-
accentPressed: "#
|
|
272
|
-
successPressed: "#
|
|
273
|
-
warningPressed: "#
|
|
274
|
-
dangerPressed: "#
|
|
262
|
+
accentPressed: "#c691fd",
|
|
263
|
+
successPressed: "#64e18d",
|
|
264
|
+
warningPressed: "#fbc54b",
|
|
265
|
+
dangerPressed: "#fa807e",
|
|
275
266
|
defaultPressed: "#2e2e31",
|
|
276
267
|
surfacePressed: "#27272a",
|
|
277
268
|
defaultSoft: "rgba(39, 39, 42, 0.5)",
|
|
@@ -385,11 +376,8 @@ function createTheme(config = {}) {
|
|
|
385
376
|
}
|
|
386
377
|
var defaultTheme = createTheme();
|
|
387
378
|
|
|
388
|
-
// src/theme/theme-context.ts
|
|
389
|
-
import { createContext } from "react";
|
|
390
|
-
var ThemeContext = createContext(null);
|
|
391
|
-
|
|
392
379
|
// src/provider/xaui-provider.tsx
|
|
380
|
+
import { jsx } from "react/jsx-runtime";
|
|
393
381
|
function XAUIProvider({
|
|
394
382
|
children,
|
|
395
383
|
theme = defaultTheme,
|
|
@@ -397,7 +385,7 @@ function XAUIProvider({
|
|
|
397
385
|
}) {
|
|
398
386
|
const scheme = useColorScheme();
|
|
399
387
|
const resolved = colorMode === "system" ? scheme === "dark" ? "dark" : "light" : colorMode;
|
|
400
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: theme[resolved], children });
|
|
401
389
|
}
|
|
402
390
|
|
|
403
391
|
// src/theme/palette.ts
|
|
@@ -699,23 +687,6 @@ var primitives = {
|
|
|
699
687
|
eclipse: "#18181b"
|
|
700
688
|
};
|
|
701
689
|
|
|
702
|
-
// src/theme/theme-hooks.ts
|
|
703
|
-
import { useContext } from "react";
|
|
704
|
-
function useXAUITheme() {
|
|
705
|
-
const theme = useContext(ThemeContext);
|
|
706
|
-
if (theme === null) {
|
|
707
|
-
throw new Error("XAUI: useXAUITheme must be used within <XAUIProvider>.");
|
|
708
|
-
}
|
|
709
|
-
return theme;
|
|
710
|
-
}
|
|
711
|
-
function useColorMode() {
|
|
712
|
-
return useXAUITheme().mode;
|
|
713
|
-
}
|
|
714
|
-
function useThemeColor(token) {
|
|
715
|
-
const { colors } = useXAUITheme();
|
|
716
|
-
return Array.isArray(token) ? token.map((key) => colors[key]) : colors[token];
|
|
717
|
-
}
|
|
718
|
-
|
|
719
690
|
export {
|
|
720
691
|
deriveColors,
|
|
721
692
|
buildRadius,
|
|
@@ -724,11 +695,7 @@ export {
|
|
|
724
695
|
sourceKeys,
|
|
725
696
|
createTheme,
|
|
726
697
|
defaultTheme,
|
|
727
|
-
ThemeContext,
|
|
728
698
|
XAUIProvider,
|
|
729
699
|
palette,
|
|
730
|
-
primitives
|
|
731
|
-
useXAUITheme,
|
|
732
|
-
useColorMode,
|
|
733
|
-
useThemeColor
|
|
700
|
+
primitives
|
|
734
701
|
};
|
|
@@ -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;
|