@xaui/native 0.9.1-alpha.1 → 0.9.1-alpha.3
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-PBVPOX7D.js → chunk-2KXQATVL.js} +3 -27
- package/dist/{chunk-M7P46XKI.cjs → chunk-3QBT3Q65.cjs} +27 -2
- package/dist/{chunk-NHPQQQ7P.cjs → chunk-AW63PTQ4.cjs} +33 -57
- package/dist/chunk-QAMNNTGM.js +637 -0
- package/dist/chunk-V63JO65F.cjs +637 -0
- package/dist/{chunk-RBNCR5KB.js → chunk-X2K2FX3W.js} +25 -0
- package/dist/index.cjs +36 -4
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +40 -8
- package/dist/system/index.cjs +35 -3
- package/dist/system/index.d.cts +273 -3
- package/dist/system/index.d.ts +273 -3
- package/dist/system/index.js +36 -4
- package/dist/theme/index.cjs +3 -3
- package/dist/theme/index.d.cts +3 -2
- package/dist/theme/index.d.ts +3 -2
- package/dist/theme/index.js +6 -6
- package/dist/{theme.type-B3ODSLbB.d.cts → theme.type-C9bFJKFm.d.cts} +7 -1
- package/dist/{theme.type-B3ODSLbB.d.ts → theme.type-C9bFJKFm.d.ts} +7 -1
- package/package.json +1 -1
- package/dist/chunk-KFCORXWW.cjs +0 -150
- package/dist/chunk-N357EQCZ.js +0 -150
package/dist/chunk-N357EQCZ.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deriveTint
|
|
3
|
-
} from "./chunk-RBNCR5KB.js";
|
|
4
|
-
|
|
5
|
-
// src/system/recipe/resolve-tint.ts
|
|
6
|
-
var TINT_SLICE_BY_SUFFIX = [
|
|
7
|
-
[/SoftForeground$/, "softForeground"],
|
|
8
|
-
[/SoftPressed$/, "softPressed"],
|
|
9
|
-
[/Soft$/, "soft"],
|
|
10
|
-
[/Foreground$/, "foreground"],
|
|
11
|
-
[/Pressed$/, "pressed"]
|
|
12
|
-
];
|
|
13
|
-
function tintSliceFor(token) {
|
|
14
|
-
for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
|
|
15
|
-
if (suffix.test(token)) return slice;
|
|
16
|
-
}
|
|
17
|
-
return "base";
|
|
18
|
-
}
|
|
19
|
-
function resolveTint(tokens, color, theme) {
|
|
20
|
-
const tint = deriveTint(color, theme);
|
|
21
|
-
const colors = {};
|
|
22
|
-
for (const [role, token] of Object.entries(tokens ?? {})) {
|
|
23
|
-
colors[role] = tint[tintSliceFor(token)];
|
|
24
|
-
}
|
|
25
|
-
return colors;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/system/recipe/style-cache.ts
|
|
29
|
-
import { StyleSheet } from "react-native";
|
|
30
|
-
|
|
31
|
-
// src/system/recipe/variant-map.ts
|
|
32
|
-
var STATE_ORDER = ["focused", "pressed", "disabled"];
|
|
33
|
-
function resolveSelection(defaultVariants, selection) {
|
|
34
|
-
const resolved = { ...defaultVariants };
|
|
35
|
-
for (const [axis, value] of Object.entries(selection ?? {})) {
|
|
36
|
-
if (value !== void 0) resolved[axis] = value;
|
|
37
|
-
}
|
|
38
|
-
return resolved;
|
|
39
|
-
}
|
|
40
|
-
function resolveVariantColors(tokens, theme) {
|
|
41
|
-
const colors = {};
|
|
42
|
-
for (const [role, token] of entriesOf(tokens)) {
|
|
43
|
-
const value = theme.colors[token];
|
|
44
|
-
if (value === void 0) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`XAUI: the recipe names "${token}" for its "${role}" role, but the theme has no such colour token. Check the spelling against XAUIColors.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
colors[role] = value;
|
|
50
|
-
}
|
|
51
|
-
return colors;
|
|
52
|
-
}
|
|
53
|
-
function activeStateFns(states, active) {
|
|
54
|
-
const fns = [];
|
|
55
|
-
for (const state of STATE_ORDER) {
|
|
56
|
-
const fn = active[state] ? states?.[state] : void 0;
|
|
57
|
-
if (fn) fns.push(fn);
|
|
58
|
-
}
|
|
59
|
-
return fns;
|
|
60
|
-
}
|
|
61
|
-
function collectStyleFns(config, selection, states) {
|
|
62
|
-
const fns = [];
|
|
63
|
-
if (config.base) fns.push(config.base);
|
|
64
|
-
if (config.paint) fns.push(config.paint);
|
|
65
|
-
for (const [axis, values] of Object.entries(config.variants ?? {})) {
|
|
66
|
-
const value = selection[axis];
|
|
67
|
-
const fn = value === void 0 ? void 0 : values[value];
|
|
68
|
-
if (fn) fns.push(fn);
|
|
69
|
-
}
|
|
70
|
-
for (const compound of config.compoundVariants ?? []) {
|
|
71
|
-
if (appliesTo(compound.when, selection)) fns.push(compound.style);
|
|
72
|
-
}
|
|
73
|
-
return [...fns, ...activeStateFns(config.states, states)];
|
|
74
|
-
}
|
|
75
|
-
function appliesTo(when, selection) {
|
|
76
|
-
return Object.entries(when).every(([axis, value]) => selection[axis] === value);
|
|
77
|
-
}
|
|
78
|
-
function entriesOf(tokens) {
|
|
79
|
-
return Object.entries(tokens ?? {});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/system/recipe/style-cache.ts
|
|
83
|
-
function createStyleCache(slots) {
|
|
84
|
-
const entries = /* @__PURE__ */ new Map();
|
|
85
|
-
return {
|
|
86
|
-
read(key, build) {
|
|
87
|
-
const hit = entries.get(key);
|
|
88
|
-
if (hit) return hit;
|
|
89
|
-
const built = build();
|
|
90
|
-
const complete = {};
|
|
91
|
-
for (const slot of slots) complete[slot] = built[slot] ?? {};
|
|
92
|
-
const created = StyleSheet.create(complete);
|
|
93
|
-
entries.set(key, created);
|
|
94
|
-
return created;
|
|
95
|
-
},
|
|
96
|
-
get size() {
|
|
97
|
-
return entries.size;
|
|
98
|
-
},
|
|
99
|
-
clear() {
|
|
100
|
-
entries.clear();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function cacheKey(theme, selection, states) {
|
|
105
|
-
const axes = Object.keys(selection).sort().map((axis) => `${axis}:${selection[axis] ?? "-"}`).join("|");
|
|
106
|
-
const active = STATE_ORDER.filter((state) => states[state]).join(",");
|
|
107
|
-
return `${theme.id}|${theme.mode}|${axes}|${active}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/system/recipe/create-recipe.ts
|
|
111
|
-
function createRecipe(config) {
|
|
112
|
-
const cache = createStyleCache(config.slots);
|
|
113
|
-
const tokensFor = (variant) => variant === void 0 ? void 0 : config.variantTokens?.[variant];
|
|
114
|
-
return {
|
|
115
|
-
slots: config.slots,
|
|
116
|
-
resolve({ theme, selection, states = {} }) {
|
|
117
|
-
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
118
|
-
return cache.read(cacheKey(theme, resolved, states), () => {
|
|
119
|
-
const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
|
|
120
|
-
return apply(collectStyleFns(config, resolved, states), theme, colors);
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
tint({ theme, color, selection, states = {} }) {
|
|
124
|
-
if (!config.paint) return {};
|
|
125
|
-
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
126
|
-
const tokens = tokensFor(resolved.variant);
|
|
127
|
-
if (!tokens) return {};
|
|
128
|
-
const colors = resolveTint(tokens, color, theme);
|
|
129
|
-
const fns = [config.paint, ...activeStateFns(config.states, states)];
|
|
130
|
-
return apply(fns, theme, colors);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function apply(fns, theme, colors) {
|
|
135
|
-
const merged = {};
|
|
136
|
-
for (const fn of fns) {
|
|
137
|
-
const produced = fn(theme, colors);
|
|
138
|
-
for (const slot of Object.keys(produced)) {
|
|
139
|
-
const style = produced[slot];
|
|
140
|
-
if (!style) continue;
|
|
141
|
-
const previous = merged[slot];
|
|
142
|
-
merged[slot] = previous ? { ...previous, ...style } : style;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return merged;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export {
|
|
149
|
-
createRecipe
|
|
150
|
-
};
|