@xaui/native 0.9.1-alpha.3 → 0.9.1-alpha.30
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-27ZRTZEE.js +293 -0
- package/dist/chunk-3FV4COTM.js +68 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4XPLPQLM.cjs +147 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5GO7MAVY.cjs +74 -0
- package/dist/chunk-5RQ7AZPN.cjs +455 -0
- package/dist/chunk-5Z4P6WHR.cjs +525 -0
- package/dist/chunk-6RVCGLKZ.js +661 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7SEZGVTY.js +62 -0
- package/dist/chunk-7XKQJQF2.cjs +70 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-A5OCK3C2.js +525 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BFMTUMTU.js +669 -0
- package/dist/chunk-BVJQ3UPZ.js +62 -0
- package/dist/chunk-DFME724B.js +147 -0
- package/dist/chunk-E2CWBQTV.js +119 -0
- package/dist/chunk-E4TS6632.cjs +314 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FMZQW35T.js +431 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7K652GC.js +145 -0
- package/dist/chunk-GGW42MY4.js +20 -0
- package/dist/chunk-GI24YJPE.js +314 -0
- package/dist/chunk-GLGU2WFL.cjs +190 -0
- package/dist/chunk-GPVNCJ3Z.cjs +696 -0
- package/dist/chunk-GVQOD3VW.js +74 -0
- package/dist/chunk-KOC3KQIT.js +124 -0
- package/dist/chunk-KPWZLUES.cjs +124 -0
- package/dist/chunk-KWCHSIMI.cjs +293 -0
- package/dist/chunk-MC7SY2QH.cjs +20 -0
- package/dist/chunk-N527BTY4.cjs +366 -0
- package/dist/chunk-NBFWWQFW.cjs +346 -0
- package/dist/chunk-NYRXUGVL.js +104 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-OHEHPQLC.cjs} +72 -72
- package/dist/chunk-Q3WFY5N3.js +366 -0
- package/dist/chunk-QGN2BBJO.cjs +104 -0
- package/dist/chunk-TGZZ3RZU.cjs +86 -0
- package/dist/{chunk-2KXQATVL.js → chunk-TZG3DERP.js} +46 -46
- package/dist/chunk-UBQLKIZC.cjs +431 -0
- package/dist/chunk-URSKA2VR.js +190 -0
- package/dist/chunk-V4WDMM6Z.js +86 -0
- package/dist/chunk-VJEER76X.js +455 -0
- package/dist/chunk-VZBWYWEI.cjs +736 -0
- package/dist/chunk-WR7YLDVV.cjs +68 -0
- package/dist/chunk-X4HQ4H2V.js +701 -0
- package/dist/chunk-XFSW3ZNI.cjs +145 -0
- package/dist/chunk-XQFAUDR2.cjs +62 -0
- package/dist/chunk-YKL6XHM6.js +346 -0
- package/dist/chunk-ZP2E2H2G.cjs +119 -0
- package/dist/chunk-ZSLNGBDS.cjs +700 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/button/index.cjs +21 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +21 -0
- package/dist/components/card/index.cjs +22 -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 +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/input/index.cjs +25 -0
- package/dist/components/input/index.d.cts +205 -0
- package/dist/components/input/index.d.ts +205 -0
- package/dist/components/input/index.js +25 -0
- package/dist/components/input-group/index.cjs +27 -0
- package/dist/components/input-group/index.d.cts +270 -0
- package/dist/components/input-group/index.d.ts +270 -0
- package/dist/components/input-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/spinner/index.cjs +16 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +16 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/typography/index.cjs +15 -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 +15 -0
- package/dist/components/view/index.cjs +17 -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 +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +246 -4
- package/dist/index.d.cts +109 -4
- package/dist/index.d.ts +109 -4
- package/dist/index.js +266 -24
- package/dist/input.type-BUMDlzL9.d.cts +167 -0
- package/dist/input.type-D2qgi03E.d.ts +167 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +60 -3
- package/dist/system/index.d.cts +347 -181
- package/dist/system/index.d.ts +347 -181
- package/dist/system/index.js +71 -14
- package/dist/theme/index.cjs +4 -3
- package/dist/theme/index.d.cts +34 -23
- package/dist/theme/index.d.ts +34 -23
- package/dist/theme/index.js +3 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +174 -18
- package/dist/chunk-QAMNNTGM.js +0 -637
- package/dist/chunk-V63JO65F.cjs +0 -637
|
@@ -0,0 +1,174 @@
|
|
|
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
|
+
// src/system/recipe/radius-axis.ts
|
|
149
|
+
function radiusAxis(...slots) {
|
|
150
|
+
const axis = {};
|
|
151
|
+
for (const key of RADIUS_KEYS) {
|
|
152
|
+
axis[key] = (theme) => Object.fromEntries(
|
|
153
|
+
slots.map((slot) => [slot, { borderRadius: theme.radius[key] }])
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return axis;
|
|
157
|
+
}
|
|
158
|
+
var RADIUS_KEYS = [
|
|
159
|
+
"xs",
|
|
160
|
+
"sm",
|
|
161
|
+
"md",
|
|
162
|
+
"lg",
|
|
163
|
+
"xl",
|
|
164
|
+
"2xl",
|
|
165
|
+
"3xl",
|
|
166
|
+
"4xl",
|
|
167
|
+
"field",
|
|
168
|
+
"full"
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
exports.createRecipe = createRecipe; exports.radiusAxis = radiusAxis;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Slot
|
|
3
|
+
} from "./chunk-E2CWBQTV.js";
|
|
4
|
+
import {
|
|
5
|
+
useStyleProps
|
|
6
|
+
} from "./chunk-URSKA2VR.js";
|
|
7
|
+
|
|
8
|
+
// src/components/view/grid.tsx
|
|
9
|
+
import { Children, forwardRef, useMemo, useState } from "react";
|
|
10
|
+
import { View } from "react-native";
|
|
11
|
+
|
|
12
|
+
// src/components/view/grid.context.ts
|
|
13
|
+
import { createContext, useContext } from "react";
|
|
14
|
+
var GridContext = createContext(null);
|
|
15
|
+
var GridProvider = GridContext.Provider;
|
|
16
|
+
function useGrid() {
|
|
17
|
+
const value = useContext(GridContext);
|
|
18
|
+
if (value === null) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"XAUI: Grid.Item must be rendered inside a Grid \u2014 it spans that grid\u2019s columns, and outside one there is nothing to span."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function spanWidth({ cellWidth, columns, gap }, span) {
|
|
26
|
+
const clamped = Math.min(Math.max(Math.floor(span), 1), columns);
|
|
27
|
+
if (cellWidth === void 0) return `${100 / columns * clamped}%`;
|
|
28
|
+
return cellWidth * clamped + gap * (clamped - 1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/components/view/grid.tsx
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
var GridRoot = forwardRef(function Grid({ children, columns = 2, gap = 0, style, onLayout, ...props }, ref) {
|
|
34
|
+
const [width, setWidth] = useState();
|
|
35
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
36
|
+
const safeColumns = Math.max(Math.floor(columns), 1);
|
|
37
|
+
const cellWidth = width === void 0 ? void 0 : (width - gap * (safeColumns - 1)) / safeColumns;
|
|
38
|
+
const context = useMemo(
|
|
39
|
+
() => ({ cellWidth, columns: safeColumns, gap }),
|
|
40
|
+
[cellWidth, safeColumns, gap]
|
|
41
|
+
);
|
|
42
|
+
const handleLayout = (event) => {
|
|
43
|
+
const next = event.nativeEvent.layout.width;
|
|
44
|
+
if (next > 0 && next !== width) setWidth(next);
|
|
45
|
+
onLayout?.(event);
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ jsx(GridProvider, { value: context, children: /* @__PURE__ */ jsx(
|
|
48
|
+
View,
|
|
49
|
+
{
|
|
50
|
+
ref,
|
|
51
|
+
onLayout: handleLayout,
|
|
52
|
+
style: [
|
|
53
|
+
{ flexDirection: "row", flexWrap: "wrap", rowGap: gap, columnGap: gap },
|
|
54
|
+
styleProps,
|
|
55
|
+
style
|
|
56
|
+
],
|
|
57
|
+
...rest,
|
|
58
|
+
children: Children.map(
|
|
59
|
+
children,
|
|
60
|
+
(child) => isGridItem(child) ? child : /* @__PURE__ */ jsx(View, { style: { width: spanWidth(context, 1) }, children: child })
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
) });
|
|
64
|
+
});
|
|
65
|
+
GridRoot.displayName = "XAUI.Grid";
|
|
66
|
+
function isGridItem(child) {
|
|
67
|
+
if (child === null || typeof child !== "object") return false;
|
|
68
|
+
const type = child.type;
|
|
69
|
+
return type?.displayName === "XAUI.Grid.Item";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/components/view/grid-item.tsx
|
|
73
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
74
|
+
import { View as View2 } from "react-native";
|
|
75
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
76
|
+
var GridItem = forwardRef2(function GridItem2({ children, span = 1, style, ...props }, ref) {
|
|
77
|
+
const grid = useGrid();
|
|
78
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
79
|
+
return /* @__PURE__ */ jsx2(
|
|
80
|
+
View2,
|
|
81
|
+
{
|
|
82
|
+
ref,
|
|
83
|
+
style: [{ width: spanWidth(grid, span) }, styleProps, style],
|
|
84
|
+
...rest,
|
|
85
|
+
children
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
GridItem.displayName = "XAUI.Grid.Item";
|
|
90
|
+
|
|
91
|
+
// src/components/view/stack.tsx
|
|
92
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
93
|
+
import { View as View3 } from "react-native";
|
|
94
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
95
|
+
var StackRoot = forwardRef3(function Stack({ children, asChild = false, style, ...props }, ref) {
|
|
96
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
97
|
+
const Root = asChild ? Slot : View3;
|
|
98
|
+
return /* @__PURE__ */ jsx3(Root, { ref, style: [{ position: "relative" }, styleProps, style], ...rest, children });
|
|
99
|
+
});
|
|
100
|
+
StackRoot.displayName = "XAUI.Stack";
|
|
101
|
+
|
|
102
|
+
// src/components/view/stack-item.tsx
|
|
103
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
104
|
+
import { View as View4 } from "react-native";
|
|
105
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
106
|
+
var StackItem = forwardRef4(function StackItem2({ children, asChild = false, style, ...props }, ref) {
|
|
107
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
108
|
+
const Root = asChild ? Slot : View4;
|
|
109
|
+
return /* @__PURE__ */ jsx4(Root, { ref, style: [{ position: "absolute" }, styleProps, style], ...rest, children });
|
|
110
|
+
});
|
|
111
|
+
StackItem.displayName = "XAUI.Stack.Item";
|
|
112
|
+
|
|
113
|
+
// src/components/view/row.tsx
|
|
114
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
115
|
+
import { View as View5 } from "react-native";
|
|
116
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
117
|
+
var Row = forwardRef5(function Row2({ children, asChild = false, style, ...props }, ref) {
|
|
118
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
119
|
+
const Root = asChild ? Slot : View5;
|
|
120
|
+
return /* @__PURE__ */ jsx5(Root, { ref, style: [{ flexDirection: "row" }, styleProps, style], ...rest, children });
|
|
121
|
+
});
|
|
122
|
+
Row.displayName = "XAUI.Row";
|
|
123
|
+
|
|
124
|
+
// src/components/view/column.tsx
|
|
125
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
126
|
+
import { View as View6 } from "react-native";
|
|
127
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
128
|
+
var Column = forwardRef6(function Column2({ children, asChild = false, style, ...props }, ref) {
|
|
129
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
130
|
+
const Root = asChild ? Slot : View6;
|
|
131
|
+
return /* @__PURE__ */ jsx6(Root, { ref, style: [{ flexDirection: "column" }, styleProps, style], ...rest, children });
|
|
132
|
+
});
|
|
133
|
+
Column.displayName = "XAUI.Column";
|
|
134
|
+
|
|
135
|
+
// src/components/view/index.ts
|
|
136
|
+
var Stack2 = Object.assign(StackRoot, { Item: StackItem });
|
|
137
|
+
var Grid2 = Object.assign(GridRoot, { Item: GridItem });
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
useGrid,
|
|
141
|
+
Row,
|
|
142
|
+
Column,
|
|
143
|
+
Stack2 as Stack,
|
|
144
|
+
Grid2 as Grid
|
|
145
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/utils/stable-hash.ts
|
|
2
|
+
function canonical(value) {
|
|
3
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
4
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
5
|
+
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)}`);
|
|
6
|
+
return `{${entries.join(",")}}`;
|
|
7
|
+
}
|
|
8
|
+
function stableHash(value) {
|
|
9
|
+
const input = canonical(value);
|
|
10
|
+
let hash = 2166136261;
|
|
11
|
+
for (let i = 0; i < input.length; i++) {
|
|
12
|
+
hash ^= input.charCodeAt(i);
|
|
13
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
14
|
+
}
|
|
15
|
+
return hash.toString(36);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
stableHash
|
|
20
|
+
};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useRotation
|
|
3
|
+
} from "./chunk-BVJQ3UPZ.js";
|
|
4
|
+
import {
|
|
5
|
+
PressableFeedback
|
|
6
|
+
} from "./chunk-BFMTUMTU.js";
|
|
7
|
+
import {
|
|
8
|
+
usePressState
|
|
9
|
+
} from "./chunk-423RQBOX.js";
|
|
10
|
+
import {
|
|
11
|
+
Icon
|
|
12
|
+
} from "./chunk-3FV4COTM.js";
|
|
13
|
+
import {
|
|
14
|
+
warnDev
|
|
15
|
+
} from "./chunk-EGLLDKN6.js";
|
|
16
|
+
import {
|
|
17
|
+
createRecipe,
|
|
18
|
+
radiusAxis
|
|
19
|
+
} from "./chunk-4GTAZM2C.js";
|
|
20
|
+
import {
|
|
21
|
+
useXAUITheme
|
|
22
|
+
} from "./chunk-A3EGFI6T.js";
|
|
23
|
+
import {
|
|
24
|
+
childrenToString,
|
|
25
|
+
createSlotContext
|
|
26
|
+
} from "./chunk-E2CWBQTV.js";
|
|
27
|
+
import {
|
|
28
|
+
useStyleProps
|
|
29
|
+
} from "./chunk-URSKA2VR.js";
|
|
30
|
+
|
|
31
|
+
// src/components/button/button.context.ts
|
|
32
|
+
var [ButtonProvider, useButton] = createSlotContext("Button");
|
|
33
|
+
|
|
34
|
+
// src/components/button/button-icon.tsx
|
|
35
|
+
import { jsx } from "react/jsx-runtime";
|
|
36
|
+
function ButtonIcon({ size, color, ...rest }) {
|
|
37
|
+
const { icon } = useButton();
|
|
38
|
+
return /* @__PURE__ */ jsx(Icon, { size: size ?? icon.size, color: color ?? icon.color, ...rest });
|
|
39
|
+
}
|
|
40
|
+
ButtonIcon.displayName = "XAUI.Button.Icon";
|
|
41
|
+
|
|
42
|
+
// src/components/button/button-label.tsx
|
|
43
|
+
import { forwardRef } from "react";
|
|
44
|
+
import { Text } from "react-native";
|
|
45
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
46
|
+
var ButtonLabel = forwardRef(function ButtonLabel2({ children, style, numberOfLines = 1, ...props }, ref) {
|
|
47
|
+
const { labelStyle } = useButton();
|
|
48
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
49
|
+
return /* @__PURE__ */ jsx2(
|
|
50
|
+
Text,
|
|
51
|
+
{
|
|
52
|
+
ref,
|
|
53
|
+
numberOfLines,
|
|
54
|
+
style: [labelStyle, styleProps, style],
|
|
55
|
+
...rest,
|
|
56
|
+
children
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
ButtonLabel.displayName = "XAUI.Button.Label";
|
|
61
|
+
|
|
62
|
+
// src/components/button/button-spinner.tsx
|
|
63
|
+
import { View } from "react-native";
|
|
64
|
+
import Animated from "react-native-reanimated";
|
|
65
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
66
|
+
function ButtonSpinner({
|
|
67
|
+
style,
|
|
68
|
+
animation = true,
|
|
69
|
+
...props
|
|
70
|
+
}) {
|
|
71
|
+
const { spinnerStyle } = useButton();
|
|
72
|
+
const [styleProps] = useStyleProps(props);
|
|
73
|
+
const ringStyle = [spinnerStyle, styleProps, style];
|
|
74
|
+
if (!animation) return /* @__PURE__ */ jsx3(View, { style: ringStyle });
|
|
75
|
+
return /* @__PURE__ */ jsx3(SpinningRing, { style: ringStyle });
|
|
76
|
+
}
|
|
77
|
+
ButtonSpinner.displayName = "XAUI.Button.Spinner";
|
|
78
|
+
function SpinningRing({ style }) {
|
|
79
|
+
const rotation = useRotation();
|
|
80
|
+
return /* @__PURE__ */ jsx3(Animated.View, { style: [style, rotation] });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/components/button/button.tsx
|
|
84
|
+
import { forwardRef as forwardRef2, useMemo } from "react";
|
|
85
|
+
import { StyleSheet } from "react-native";
|
|
86
|
+
|
|
87
|
+
// src/components/button/button.recipe.ts
|
|
88
|
+
var SLOTS = ["root", "label", "icon", "spinner"];
|
|
89
|
+
var VARIANT_TOKENS = {
|
|
90
|
+
primary: { bg: "accent", bgPressed: "accentPressed", fg: "accentForeground" },
|
|
91
|
+
// The accent's soft slice, not a second neutral: `secondary` is to `primary` what
|
|
92
|
+
// `danger-soft` is to `danger`, and it reads as the same family at lower emphasis.
|
|
93
|
+
secondary: {
|
|
94
|
+
bg: "accentSoft",
|
|
95
|
+
bgPressed: "accentSoftPressed",
|
|
96
|
+
fg: "accentSoftForeground"
|
|
97
|
+
},
|
|
98
|
+
default: { bg: "default", bgPressed: "defaultPressed", fg: "defaultForeground" },
|
|
99
|
+
tertiary: {
|
|
100
|
+
border: "border",
|
|
101
|
+
bgPressed: "defaultSoftPressed",
|
|
102
|
+
fg: "foreground"
|
|
103
|
+
},
|
|
104
|
+
ghost: { bgPressed: "defaultSoftPressed", fg: "foreground" },
|
|
105
|
+
danger: { bg: "danger", bgPressed: "dangerPressed", fg: "dangerForeground" },
|
|
106
|
+
"danger-soft": {
|
|
107
|
+
bg: "dangerSoft",
|
|
108
|
+
bgPressed: "dangerSoftPressed",
|
|
109
|
+
fg: "dangerSoftForeground"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function ring(theme, size) {
|
|
113
|
+
return {
|
|
114
|
+
width: size,
|
|
115
|
+
height: size,
|
|
116
|
+
borderRadius: size / 2,
|
|
117
|
+
borderWidth: theme.borderWidth.default * 2,
|
|
118
|
+
borderTopColor: "transparent"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function sizeAxis(step) {
|
|
122
|
+
const { size, padding, gap, glyph, radius } = step;
|
|
123
|
+
return (theme) => ({
|
|
124
|
+
root: {
|
|
125
|
+
height: theme.controlHeights[size],
|
|
126
|
+
paddingHorizontal: theme.spacing(padding),
|
|
127
|
+
gap: theme.spacing(gap),
|
|
128
|
+
borderRadius: theme.radius[radius]
|
|
129
|
+
},
|
|
130
|
+
label: {
|
|
131
|
+
fontSize: theme.fontSizes[size],
|
|
132
|
+
lineHeight: theme.lineHeights[size]
|
|
133
|
+
},
|
|
134
|
+
icon: { fontSize: theme.fontSizes[glyph] },
|
|
135
|
+
spinner: ring(theme, theme.fontSizes[glyph])
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
var buttonRecipe = createRecipe({
|
|
139
|
+
slots: SLOTS,
|
|
140
|
+
base: (theme) => ({
|
|
141
|
+
root: {
|
|
142
|
+
flexDirection: "row",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center",
|
|
145
|
+
borderWidth: 0,
|
|
146
|
+
// iOS's squircle. Free on Android, and it is what makes a large radius read as a
|
|
147
|
+
// shape rather than as two arcs meeting a straight edge.
|
|
148
|
+
borderCurve: "continuous"
|
|
149
|
+
},
|
|
150
|
+
label: {
|
|
151
|
+
fontFamily: theme.fontFamilies.body,
|
|
152
|
+
fontWeight: theme.fontWeights.medium
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
variantTokens: VARIANT_TOKENS,
|
|
156
|
+
/**
|
|
157
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
158
|
+
* the *presence* of the border role rather than a per-variant flag — `tertiary` is the
|
|
159
|
+
* only variant that names one, and that fact is already in the table above.
|
|
160
|
+
*/
|
|
161
|
+
paint: (theme, colors) => ({
|
|
162
|
+
root: {
|
|
163
|
+
backgroundColor: colors.bg,
|
|
164
|
+
borderColor: colors.border,
|
|
165
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
166
|
+
},
|
|
167
|
+
label: { color: colors.fg },
|
|
168
|
+
icon: { color: colors.fg },
|
|
169
|
+
spinner: { borderColor: colors.fg }
|
|
170
|
+
}),
|
|
171
|
+
/**
|
|
172
|
+
* Declaration order is application order: `radius` overrides the radius `size` set, and
|
|
173
|
+
* `isIconOnly` overrides its padding. Both are axes rather than a static sheet merged
|
|
174
|
+
* at the call site, so they stay inside the cache key and a press still allocates
|
|
175
|
+
* nothing.
|
|
176
|
+
*/
|
|
177
|
+
variants: {
|
|
178
|
+
size: {
|
|
179
|
+
xs: sizeAxis({ size: "xs", padding: 3, gap: 1, glyph: "sm", radius: "3xl" }),
|
|
180
|
+
sm: sizeAxis({
|
|
181
|
+
size: "sm",
|
|
182
|
+
padding: 3.5,
|
|
183
|
+
gap: 1.5,
|
|
184
|
+
glyph: "md",
|
|
185
|
+
radius: "3xl"
|
|
186
|
+
}),
|
|
187
|
+
md: sizeAxis({ size: "md", padding: 4, gap: 2, glyph: "lg", radius: "3xl" }),
|
|
188
|
+
lg: sizeAxis({ size: "lg", padding: 5, gap: 2.5, glyph: "xl", radius: "4xl" })
|
|
189
|
+
},
|
|
190
|
+
radius: radiusAxis("root"),
|
|
191
|
+
// A square on a fixed height. No width is computed, and none needs to be.
|
|
192
|
+
isIconOnly: {
|
|
193
|
+
true: () => ({ root: { paddingHorizontal: 0, aspectRatio: 1 } })
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* The pressed colour lives here rather than in a `PressableFeedback.Highlight`, because
|
|
198
|
+
* a control picks one treatment or the other — both, and a pressed button darkens
|
|
199
|
+
* twice. This one is the variant's own `…Pressed` token, so the press reads as the
|
|
200
|
+
* button's colour going down rather than as a neutral film over it, and a tinted button
|
|
201
|
+
* presses through the same OKLab formula as a token one.
|
|
202
|
+
*/
|
|
203
|
+
states: {
|
|
204
|
+
pressed: (_theme, colors) => ({ root: { backgroundColor: colors.bgPressed } }),
|
|
205
|
+
disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
|
|
206
|
+
},
|
|
207
|
+
defaultVariants: { variant: "primary", size: "md" }
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// src/components/button/button.utils.ts
|
|
211
|
+
import { Children, isValidElement } from "react";
|
|
212
|
+
function containsElementOfType(children, type) {
|
|
213
|
+
return Children.toArray(children).some(
|
|
214
|
+
(child) => isValidElement(child) && child.type === type
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/components/button/button.tsx
|
|
219
|
+
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
220
|
+
var ButtonRoot = forwardRef2(function Button({
|
|
221
|
+
children,
|
|
222
|
+
variant,
|
|
223
|
+
size,
|
|
224
|
+
radius,
|
|
225
|
+
color,
|
|
226
|
+
isDisabled = false,
|
|
227
|
+
isLoading = false,
|
|
228
|
+
isIconOnly = false,
|
|
229
|
+
asChild = false,
|
|
230
|
+
accessibilityRole = "button",
|
|
231
|
+
accessibilityState,
|
|
232
|
+
style,
|
|
233
|
+
onPressIn,
|
|
234
|
+
onPressOut,
|
|
235
|
+
...props
|
|
236
|
+
}, ref) {
|
|
237
|
+
const theme = useXAUITheme();
|
|
238
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
239
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
240
|
+
const selection = {
|
|
241
|
+
variant,
|
|
242
|
+
size,
|
|
243
|
+
radius,
|
|
244
|
+
isIconOnly: isIconOnly ? "true" : void 0
|
|
245
|
+
};
|
|
246
|
+
const states = { pressed: isPressed, disabled: isDisabled || isLoading };
|
|
247
|
+
const styles = buttonRecipe.resolve({ theme, selection, states });
|
|
248
|
+
const tint = color ? buttonRecipe.tint({ theme, color, selection, states }) : void 0;
|
|
249
|
+
const context = useMemo(() => {
|
|
250
|
+
const icon = StyleSheet.flatten([styles.icon, tint?.icon]);
|
|
251
|
+
return {
|
|
252
|
+
labelStyle: tint ? [styles.label, tint.label] : styles.label,
|
|
253
|
+
spinnerStyle: tint ? [styles.spinner, tint.spinner] : styles.spinner,
|
|
254
|
+
icon: {
|
|
255
|
+
size: icon.fontSize,
|
|
256
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
257
|
+
// hand to a third-party component expecting a string.
|
|
258
|
+
color: typeof icon.color === "string" ? icon.color : void 0
|
|
259
|
+
},
|
|
260
|
+
isDisabled,
|
|
261
|
+
isLoading
|
|
262
|
+
};
|
|
263
|
+
}, [styles, tint, isDisabled, isLoading]);
|
|
264
|
+
const rootStyle = [
|
|
265
|
+
styles.root,
|
|
266
|
+
tint?.root,
|
|
267
|
+
styleProps,
|
|
268
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
269
|
+
];
|
|
270
|
+
const text = childrenToString(children);
|
|
271
|
+
const showSpinner = isLoading && !containsElementOfType(children, ButtonSpinner);
|
|
272
|
+
if (isIconOnly && !rest.accessibilityLabel && !rest["aria-label"]) {
|
|
273
|
+
warnDev(
|
|
274
|
+
"Button: an icon-only button needs an `accessibilityLabel` \u2014 there is no text for a screen reader to read, so it announces as an unlabelled button."
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return /* @__PURE__ */ jsx4(ButtonProvider, { value: context, children: /* @__PURE__ */ jsx4(
|
|
278
|
+
PressableFeedback,
|
|
279
|
+
{
|
|
280
|
+
ref,
|
|
281
|
+
isPressed,
|
|
282
|
+
isDisabled: isDisabled || isLoading,
|
|
283
|
+
asChild,
|
|
284
|
+
accessibilityRole,
|
|
285
|
+
accessibilityState: {
|
|
286
|
+
disabled: isDisabled,
|
|
287
|
+
busy: isLoading,
|
|
288
|
+
...accessibilityState
|
|
289
|
+
},
|
|
290
|
+
...rest,
|
|
291
|
+
style: rootStyle,
|
|
292
|
+
onPressIn: press.onPressIn,
|
|
293
|
+
onPressOut: press.onPressOut,
|
|
294
|
+
children: asChild ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
|
+
showSpinner ? /* @__PURE__ */ jsx4(ButtonSpinner, {}) : null,
|
|
296
|
+
text !== null ? /* @__PURE__ */ jsx4(ButtonLabel, { children: text }) : children
|
|
297
|
+
] })
|
|
298
|
+
}
|
|
299
|
+
) });
|
|
300
|
+
});
|
|
301
|
+
ButtonRoot.displayName = "XAUI.Button.Root";
|
|
302
|
+
|
|
303
|
+
// src/components/button/index.ts
|
|
304
|
+
var Button2 = Object.assign(ButtonRoot, {
|
|
305
|
+
Label: ButtonLabel,
|
|
306
|
+
Icon: ButtonIcon,
|
|
307
|
+
Spinner: ButtonSpinner
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
export {
|
|
311
|
+
useButton,
|
|
312
|
+
buttonRecipe,
|
|
313
|
+
Button2 as Button
|
|
314
|
+
};
|