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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,274 @@
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
+ var _chunkM7P46XKIcjs = require('./chunk-M7P46XKI.cjs');
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 = _chunkM7P46XKIcjs.deriveTint.call(void 0, color, theme);
21
+ const colors = {};
22
+ for (const [role, token] of Object.entries(_nullishCoalesce(tokens, () => ( {})))) {
23
+ colors[role] = tint[tintSliceFor(token)];
24
+ }
25
+ return colors;
26
+ }
27
+
28
+ // src/system/recipe/style-cache.ts
29
+ var _reactnative = require('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(_nullishCoalesce(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] ? _optionalChain([states, 'optionalAccess', _ => _[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(_nullishCoalesce(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 _nullishCoalesce(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(_nullishCoalesce(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] = _nullishCoalesce(built[slot], () => ( {}));
92
+ const created = _reactnative.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}:${_nullishCoalesce(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 : _optionalChain([config, 'access', _2 => _2.variantTokens, 'optionalAccess', _3 => _3[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
+ // 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
+
273
+
274
+ exports.createRecipe = createRecipe; exports.childrenToString = childrenToString; exports.createSlotContext = createSlotContext; exports.mergeRefs = mergeRefs; exports.mergeProps = mergeProps; exports.Slot = Slot;
@@ -0,0 +1,100 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/colors.ts
2
+ var srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
3
+ var linearToSrgb = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
4
+ var clamp01 = (n) => Math.min(1, Math.max(0, n));
5
+ var HEX = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
6
+ function isHex(value) {
7
+ return HEX.test(value);
8
+ }
9
+ function hexToRgb(hex) {
10
+ if (!isHex(hex)) {
11
+ throw new Error(
12
+ `XAUI: "${hex}" is not a hex colour. Tokens that feed mix() and alpha() must be #rgb or #rrggbb \u2014 named colours and rgb()/rgba() values cannot be blended.`
13
+ );
14
+ }
15
+ const raw = hex.replace("#", "");
16
+ const full = raw.length === 3 ? raw.split("").map((c) => c + c).join("") : raw;
17
+ return [
18
+ parseInt(full.slice(0, 2), 16) / 255,
19
+ parseInt(full.slice(2, 4), 16) / 255,
20
+ parseInt(full.slice(4, 6), 16) / 255
21
+ ];
22
+ }
23
+ function rgbToHex([r, g, b]) {
24
+ const to = (n) => Math.round(clamp01(n) * 255).toString(16).padStart(2, "0");
25
+ return `#${to(r)}${to(g)}${to(b)}`;
26
+ }
27
+ function rgbToOklab([r, g, b]) {
28
+ const R = srgbToLinear(r);
29
+ const G = srgbToLinear(g);
30
+ const B = srgbToLinear(b);
31
+ const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B);
32
+ const m = Math.cbrt(0.2119034982 * R + 0.6806995451 * G + 0.1073969566 * B);
33
+ const s = Math.cbrt(0.0883024619 * R + 0.2817188376 * G + 0.6299787005 * B);
34
+ return [
35
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
36
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
37
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
38
+ ];
39
+ }
40
+ function oklabToRgb([L, a, b]) {
41
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
42
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
43
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
44
+ return [
45
+ clamp01(linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s)),
46
+ clamp01(linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s)),
47
+ clamp01(linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s))
48
+ ];
49
+ }
50
+ function mix(base, other, amount) {
51
+ const from = rgbToOklab(hexToRgb(base));
52
+ const to = rgbToOklab(hexToRgb(other));
53
+ return rgbToHex(
54
+ oklabToRgb([
55
+ from[0] + (to[0] - from[0]) * amount,
56
+ from[1] + (to[1] - from[1]) * amount,
57
+ from[2] + (to[2] - from[2]) * amount
58
+ ])
59
+ );
60
+ }
61
+ function alpha(hex, amount) {
62
+ const [r, g, b] = hexToRgb(hex).map((v) => Math.round(v * 255));
63
+ return `rgba(${r}, ${g}, ${b}, ${amount})`;
64
+ }
65
+ function lightnessOf(hex) {
66
+ return rgbToOklab(hexToRgb(hex))[0];
67
+ }
68
+ function contrastOn(hex, light, dark) {
69
+ return lightnessOf(hex) > 0.62 ? dark : light;
70
+ }
71
+
72
+ // src/theme/derive-tint.ts
73
+ var cache = /* @__PURE__ */ new Map();
74
+ function deriveTint(tint, theme) {
75
+ const key = `${theme.id}|${theme.mode}|${tint}`;
76
+ const hit = cache.get(key);
77
+ if (hit) return hit;
78
+ if (!isHex(tint)) {
79
+ throw new Error(
80
+ `XAUI: color="${tint}" must be a hex value (#rgb or #rrggbb). A tint's contrasted, soft and pressed slices are derived in OKLab, which cannot read rgba() or a named colour. Pass the hex here and put the transparency in \`style\`.`
81
+ );
82
+ }
83
+ const foreground = contrastOn(tint, theme.colors.snow, theme.colors.eclipse);
84
+ const derived = {
85
+ base: tint,
86
+ foreground,
87
+ soft: alpha(tint, 0.15),
88
+ softForeground: mix(tint, theme.colors.foreground, 0.2),
89
+ pressed: mix(tint, foreground, 0.1),
90
+ softPressed: alpha(tint, 0.2)
91
+ };
92
+ cache.set(key, derived);
93
+ return derived;
94
+ }
95
+
96
+
97
+
98
+
99
+
100
+ exports.mix = mix; exports.alpha = alpha; exports.deriveTint = deriveTint;
@@ -1,4 +1,9 @@
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; }// src/provider/xaui-provider.tsx
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 _chunkM7P46XKIcjs = require('./chunk-M7P46XKI.cjs');
5
+
6
+ // src/provider/xaui-provider.tsx
2
7
  var _reactnative = require('react-native');
3
8
 
4
9
  // src/utils/stable-hash.ts
@@ -18,103 +23,41 @@ function stableHash(value) {
18
23
  return hash.toString(36);
19
24
  }
20
25
 
21
- // src/utils/colors.ts
22
- var srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
23
- var linearToSrgb = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
24
- var clamp01 = (n) => Math.min(1, Math.max(0, n));
25
- var HEX = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
26
- function hexToRgb(hex) {
27
- if (!HEX.test(hex)) {
28
- throw new Error(
29
- `XAUI: "${hex}" is not a hex colour. Tokens that feed mix() and alpha() must be #rgb or #rrggbb \u2014 named colours and rgb()/rgba() values cannot be blended.`
30
- );
31
- }
32
- const raw = hex.replace("#", "");
33
- const full = raw.length === 3 ? raw.split("").map((c) => c + c).join("") : raw;
34
- return [
35
- parseInt(full.slice(0, 2), 16) / 255,
36
- parseInt(full.slice(2, 4), 16) / 255,
37
- parseInt(full.slice(4, 6), 16) / 255
38
- ];
39
- }
40
- function rgbToHex([r, g, b]) {
41
- const to = (n) => Math.round(clamp01(n) * 255).toString(16).padStart(2, "0");
42
- return `#${to(r)}${to(g)}${to(b)}`;
43
- }
44
- function rgbToOklab([r, g, b]) {
45
- const R = srgbToLinear(r);
46
- const G = srgbToLinear(g);
47
- const B = srgbToLinear(b);
48
- const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B);
49
- const m = Math.cbrt(0.2119034982 * R + 0.6806995451 * G + 0.1073969566 * B);
50
- const s = Math.cbrt(0.0883024619 * R + 0.2817188376 * G + 0.6299787005 * B);
51
- return [
52
- 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
53
- 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
54
- 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
55
- ];
56
- }
57
- function oklabToRgb([L, a, b]) {
58
- const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
59
- const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
60
- const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
61
- return [
62
- clamp01(linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s)),
63
- clamp01(linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s)),
64
- clamp01(linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s))
65
- ];
66
- }
67
- function mix(base, other, amount) {
68
- const from = rgbToOklab(hexToRgb(base));
69
- const to = rgbToOklab(hexToRgb(other));
70
- return rgbToHex(
71
- oklabToRgb([
72
- from[0] + (to[0] - from[0]) * amount,
73
- from[1] + (to[1] - from[1]) * amount,
74
- from[2] + (to[2] - from[2]) * amount
75
- ])
76
- );
77
- }
78
- function alpha(hex, amount) {
79
- const [r, g, b] = hexToRgb(hex).map((v) => Math.round(v * 255));
80
- return `rgba(${r}, ${g}, ${b}, ${amount})`;
81
- }
82
-
83
26
  // src/theme/derive-colors.ts
84
27
  function deriveColors(s) {
85
28
  return {
86
- accentPressed: mix(s.accent, s.accentForeground, 0.1),
87
- successPressed: mix(s.success, s.successForeground, 0.1),
88
- warningPressed: mix(s.warning, s.warningForeground, 0.1),
89
- dangerPressed: mix(s.danger, s.dangerForeground, 0.1),
90
- defaultPressed: mix(s.default, s.defaultForeground, 0.04),
91
- surfacePressed: mix(s.surface, s.surfaceForeground, 0.08),
92
- defaultSoft: alpha(s.default, 0.5),
29
+ accentPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.accent, s.accentForeground, 0.1),
30
+ successPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.success, s.successForeground, 0.1),
31
+ warningPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.warning, s.warningForeground, 0.1),
32
+ dangerPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.danger, s.dangerForeground, 0.1),
33
+ defaultPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.default, s.defaultForeground, 0.04),
34
+ surfacePressed: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.08),
35
+ defaultSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.default, 0.5),
93
36
  defaultSoftForeground: s.defaultForeground,
94
- defaultSoftPressed: alpha(s.default, 0.6),
95
- accentSoft: alpha(s.accent, 0.15),
96
- accentSoftForeground: mix(s.accent, s.foreground, 0.2),
97
- accentSoftPressed: alpha(s.accent, 0.2),
98
- successSoft: alpha(s.success, 0.15),
99
- successSoftForeground: mix(s.success, s.foreground, 0.3),
100
- successSoftPressed: alpha(s.success, 0.2),
101
- warningSoft: alpha(s.warning, 0.15),
102
- warningSoftForeground: mix(s.warning, s.foreground, 0.35),
103
- warningSoftPressed: alpha(s.warning, 0.2),
104
- dangerSoft: alpha(s.danger, 0.15),
105
- dangerSoftForeground: mix(s.danger, s.foreground, 0.2),
106
- dangerSoftPressed: alpha(s.danger, 0.2),
107
- backgroundSecondary: mix(s.background, s.foreground, 0.04),
108
- backgroundTertiary: mix(s.background, s.foreground, 0.08),
37
+ defaultSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.default, 0.6),
38
+ accentSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.accent, 0.15),
39
+ accentSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.accent, s.foreground, 0.2),
40
+ accentSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.accent, 0.2),
41
+ successSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.success, 0.15),
42
+ successSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.success, s.foreground, 0.3),
43
+ successSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.success, 0.2),
44
+ warningSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.warning, 0.15),
45
+ warningSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.warning, s.foreground, 0.35),
46
+ warningSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.warning, 0.2),
47
+ dangerSoft: _chunkM7P46XKIcjs.alpha.call(void 0, s.danger, 0.15),
48
+ dangerSoftForeground: _chunkM7P46XKIcjs.mix.call(void 0, s.danger, s.foreground, 0.2),
49
+ dangerSoftPressed: _chunkM7P46XKIcjs.alpha.call(void 0, s.danger, 0.2),
50
+ backgroundSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.background, s.foreground, 0.04),
51
+ backgroundTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.background, s.foreground, 0.08),
109
52
  backgroundInverse: s.foreground,
110
- borderSecondary: mix(s.surface, s.surfaceForeground, 0.22),
111
- borderTertiary: mix(s.surface, s.surfaceForeground, 0.34),
112
- separatorSecondary: mix(s.surface, s.surfaceForeground, 0.15),
113
- separatorTertiary: mix(s.surface, s.surfaceForeground, 0.19),
114
- fieldPressed: mix(s.fieldBackground, s.fieldForeground, 0.1),
53
+ borderSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.22),
54
+ borderTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.34),
55
+ separatorSecondary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.15),
56
+ separatorTertiary: _chunkM7P46XKIcjs.mix.call(void 0, s.surface, s.surfaceForeground, 0.19),
57
+ fieldPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBackground, s.fieldForeground, 0.1),
115
58
  fieldFocus: s.fieldBackground,
116
- fieldBorderPressed: mix(s.fieldBorder, s.fieldForeground, 0.12),
117
- fieldBorderFocus: mix(s.fieldBorder, s.fieldForeground, 0.26)
59
+ fieldBorderPressed: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.12),
60
+ fieldBorderFocus: _chunkM7P46XKIcjs.mix.call(void 0, s.fieldBorder, s.fieldForeground, 0.26)
118
61
  };
119
62
  }
120
63
 
@@ -1,3 +1,8 @@
1
+ import {
2
+ alpha,
3
+ mix
4
+ } from "./chunk-RBNCR5KB.js";
5
+
1
6
  // src/provider/xaui-provider.tsx
2
7
  import { useColorScheme } from "react-native";
3
8
 
@@ -18,68 +23,6 @@ function stableHash(value) {
18
23
  return hash.toString(36);
19
24
  }
20
25
 
21
- // src/utils/colors.ts
22
- var srgbToLinear = (c) => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
23
- var linearToSrgb = (c) => c <= 31308e-7 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
24
- var clamp01 = (n) => Math.min(1, Math.max(0, n));
25
- var HEX = /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
26
- function hexToRgb(hex) {
27
- if (!HEX.test(hex)) {
28
- throw new Error(
29
- `XAUI: "${hex}" is not a hex colour. Tokens that feed mix() and alpha() must be #rgb or #rrggbb \u2014 named colours and rgb()/rgba() values cannot be blended.`
30
- );
31
- }
32
- const raw = hex.replace("#", "");
33
- const full = raw.length === 3 ? raw.split("").map((c) => c + c).join("") : raw;
34
- return [
35
- parseInt(full.slice(0, 2), 16) / 255,
36
- parseInt(full.slice(2, 4), 16) / 255,
37
- parseInt(full.slice(4, 6), 16) / 255
38
- ];
39
- }
40
- function rgbToHex([r, g, b]) {
41
- const to = (n) => Math.round(clamp01(n) * 255).toString(16).padStart(2, "0");
42
- return `#${to(r)}${to(g)}${to(b)}`;
43
- }
44
- function rgbToOklab([r, g, b]) {
45
- const R = srgbToLinear(r);
46
- const G = srgbToLinear(g);
47
- const B = srgbToLinear(b);
48
- const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B);
49
- const m = Math.cbrt(0.2119034982 * R + 0.6806995451 * G + 0.1073969566 * B);
50
- const s = Math.cbrt(0.0883024619 * R + 0.2817188376 * G + 0.6299787005 * B);
51
- return [
52
- 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
53
- 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
54
- 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
55
- ];
56
- }
57
- function oklabToRgb([L, a, b]) {
58
- const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
59
- const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
60
- const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
61
- return [
62
- clamp01(linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s)),
63
- clamp01(linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s)),
64
- clamp01(linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s))
65
- ];
66
- }
67
- function mix(base, other, amount) {
68
- const from = rgbToOklab(hexToRgb(base));
69
- const to = rgbToOklab(hexToRgb(other));
70
- return rgbToHex(
71
- oklabToRgb([
72
- from[0] + (to[0] - from[0]) * amount,
73
- from[1] + (to[1] - from[1]) * amount,
74
- from[2] + (to[2] - from[2]) * amount
75
- ])
76
- );
77
- }
78
- function alpha(hex, amount) {
79
- const [r, g, b] = hexToRgb(hex).map((v) => Math.round(v * 255));
80
- return `rgba(${r}, ${g}, ${b}, ${amount})`;
81
- }
82
-
83
26
  // src/theme/derive-colors.ts
84
27
  function deriveColors(s) {
85
28
  return {