@xaui/native 0.9.1-alpha.18 → 0.9.1-alpha.19

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.
Files changed (49) hide show
  1. package/dist/{chunk-M2VYRHVS.cjs → chunk-2WMVDMFV.cjs} +2 -2
  2. package/dist/{chunk-MBLPPOSO.js → chunk-4EPS7UBO.js} +18 -17
  3. package/dist/{chunk-6N5JXRUZ.cjs → chunk-57SJ4LJF.cjs} +2 -20
  4. package/dist/{chunk-ODH5WAVM.cjs → chunk-6ARON3XT.cjs} +27 -26
  5. package/dist/{chunk-XJARE6SC.js → chunk-A3EGFI6T.js} +0 -18
  6. package/dist/{chunk-P5MKOLIW.cjs → chunk-A4VD4MHK.cjs} +73 -73
  7. package/dist/chunk-BFB6K4M7.cjs +31 -0
  8. package/dist/{chunk-BHAHJHAI.cjs → chunk-BHTFIZTQ.cjs} +34 -32
  9. package/dist/{chunk-5SU7FXWH.cjs → chunk-EVXZGNPA.cjs} +3 -148
  10. package/dist/{chunk-4K3LZS7M.js → chunk-EXX6ATAS.js} +2 -147
  11. package/dist/chunk-GGW42MY4.js +20 -0
  12. package/dist/chunk-MAYVGK6W.js +31 -0
  13. package/dist/chunk-MC7SY2QH.cjs +20 -0
  14. package/dist/{chunk-XQE5PXOD.js → chunk-MWXE7D4L.js} +4 -2
  15. package/dist/chunk-N7C4UNUL.js +150 -0
  16. package/dist/{chunk-6PZF4PI7.js → chunk-RMLFMRWL.js} +5 -3
  17. package/dist/{chunk-6VTBGBPP.cjs → chunk-UBA6AEY6.cjs} +10 -8
  18. package/dist/chunk-UVO4GFSW.cjs +150 -0
  19. package/dist/{chunk-VQPP6FCB.js → chunk-WXAME7KB.js} +76 -76
  20. package/dist/{chunk-L3AQNVRN.js → chunk-XHZBXYVU.js} +1 -1
  21. package/dist/components/button/index.cjs +7 -5
  22. package/dist/components/button/index.d.cts +3 -2
  23. package/dist/components/button/index.d.ts +3 -2
  24. package/dist/components/button/index.js +6 -4
  25. package/dist/components/typography/index.cjs +6 -4
  26. package/dist/components/typography/index.d.cts +2 -1
  27. package/dist/components/typography/index.d.ts +2 -1
  28. package/dist/components/typography/index.js +5 -3
  29. package/dist/components/view/index.cjs +10 -0
  30. package/dist/components/view/index.d.cts +77 -0
  31. package/dist/components/view/index.d.ts +77 -0
  32. package/dist/components/view/index.js +10 -0
  33. package/dist/{create-recipe-3_ElpCYt.d.cts → create-recipe-C0XXjuow.d.cts} +2 -30
  34. package/dist/{create-recipe-DImq1AZA.d.ts → create-recipe-CPXFo2rk.d.ts} +2 -30
  35. package/dist/index.cjs +19 -10
  36. package/dist/index.d.cts +4 -2
  37. package/dist/index.d.ts +4 -2
  38. package/dist/index.js +17 -8
  39. package/dist/{pressable-feedback.type-UwqIG6ES.d.ts → pressable-feedback.type-1K8YEOb8.d.cts} +1 -1
  40. package/dist/{pressable-feedback.type-lgW5wQx5.d.cts → pressable-feedback.type-BwkKLQlX.d.ts} +1 -1
  41. package/dist/style-props.type-B1BG5TCm.d.cts +31 -0
  42. package/dist/style-props.type-B1BG5TCm.d.ts +31 -0
  43. package/dist/system/index.cjs +8 -5
  44. package/dist/system/index.d.cts +5 -4
  45. package/dist/system/index.d.ts +5 -4
  46. package/dist/system/index.js +8 -5
  47. package/dist/theme/index.cjs +4 -3
  48. package/dist/theme/index.js +3 -2
  49. package/package.json +11 -1
@@ -0,0 +1,150 @@
1
+ import {
2
+ deriveTint
3
+ } from "./chunk-A3EGFI6T.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
+ };
@@ -1,11 +1,13 @@
1
+ import {
2
+ createRecipe
3
+ } from "./chunk-N7C4UNUL.js";
1
4
  import {
2
5
  Slot,
3
- createRecipe,
4
6
  useStyleProps
5
- } from "./chunk-4K3LZS7M.js";
7
+ } from "./chunk-EXX6ATAS.js";
6
8
  import {
7
9
  useXAUITheme
8
- } from "./chunk-XJARE6SC.js";
10
+ } from "./chunk-A3EGFI6T.js";
9
11
 
10
12
  // src/components/typography/typography.tsx
11
13
  import { forwardRef } from "react";
@@ -1,11 +1,13 @@
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 _chunkUVO4GFSWcjs = require('./chunk-UVO4GFSW.cjs');
3
4
 
4
5
 
5
- var _chunk5SU7FXWHcjs = require('./chunk-5SU7FXWH.cjs');
6
6
 
7
+ var _chunkEVXZGNPAcjs = require('./chunk-EVXZGNPA.cjs');
7
8
 
8
- var _chunk6N5JXRUZcjs = require('./chunk-6N5JXRUZ.cjs');
9
+
10
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
9
11
 
10
12
  // src/components/typography/typography.tsx
11
13
  var _react = require('react');
@@ -58,7 +60,7 @@ function metricsOf({ step, weight, family, letterSpacing, chip }) {
58
60
  var ROLE_AXIS = Object.fromEntries(
59
61
  Object.entries(ROLES).map(([name, spec]) => [name, metricsOf(spec)])
60
62
  );
61
- var typographyRecipe = _chunk5SU7FXWHcjs.createRecipe.call(void 0, {
63
+ var typographyRecipe = _chunkUVO4GFSWcjs.createRecipe.call(void 0, {
62
64
  slots: SLOTS,
63
65
  variantTokens: VARIANT_TOKENS,
64
66
  // Ink only. The chip's fill is a token, not a role, so it belongs to the metrics above —
@@ -71,13 +73,13 @@ var typographyRecipe = _chunk5SU7FXWHcjs.createRecipe.call(void 0, {
71
73
  // src/components/typography/typography.tsx
72
74
  var _jsxruntime = require('react/jsx-runtime');
73
75
  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 theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
77
+ const [styleProps, rest] = _chunkEVXZGNPAcjs.useStyleProps.call(void 0, props);
76
78
  const selection = { variant };
77
79
  const styles = typographyRecipe.resolve({ theme, selection });
78
80
  const tint = color ? typographyRecipe.tint({ theme, color, selection }) : void 0;
79
81
  const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _ => _.root]), styleProps, style];
80
- const Root = asChild ? _chunk5SU7FXWHcjs.Slot : _reactnative.Text;
82
+ const Root = asChild ? _chunkEVXZGNPAcjs.Slot : _reactnative.Text;
81
83
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: rootStyle, ...rest, children });
82
84
  });
83
85
  Typography.displayName = "XAUI.Typography";
@@ -87,8 +89,8 @@ Typography.displayName = "XAUI.Typography";
87
89
 
88
90
 
89
91
  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
+ const [styleProps, rest] = _chunkEVXZGNPAcjs.useStyleProps.call(void 0, props);
93
+ const Root = asChild ? _chunkEVXZGNPAcjs.Slot : _reactnative.Text;
92
94
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Root, { ref, style: [styleProps, style], ...rest, children });
93
95
  });
94
96
  TextSpan.displayName = "XAUI.TextSpan";
@@ -0,0 +1,150 @@
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 _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.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 = _chunk57SJ4LJFcjs.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
+
149
+
150
+ exports.createRecipe = createRecipe;