@satellatickets/ui 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/NOTICE.md +9 -0
- package/README.md +84 -3
- package/dist/native/index.d.ts +91 -0
- package/dist/native/index.js +699 -0
- package/dist/web/index.d.ts +97 -0
- package/dist/web/index.js +626 -0
- package/dist/web/styles.css +553 -0
- package/package.json +89 -3
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
import { UIContext, buttonIconSize, createUIContextValue, iconSizePx, spinnerSizePx, textVariantStyles, useBrand, useButton, useColorScheme, useTheme, useTheme as useTheme$1 } from "@satellatickets/core";
|
|
2
|
+
import { Animated, Easing, Pressable, StyleSheet, Text as Text$1, View, useColorScheme as useColorScheme$1 } from "react-native";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Children, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import Svg, { Circle, Line, Path, Rect } from "react-native-svg";
|
|
6
|
+
//#region src/badge/Badge.native.tsx
|
|
7
|
+
const variantColors = {
|
|
8
|
+
success: (t) => t.color.feedback.success,
|
|
9
|
+
warning: (t) => t.color.feedback.warning,
|
|
10
|
+
danger: (t) => t.color.feedback.danger,
|
|
11
|
+
info: (t) => t.color.feedback.info
|
|
12
|
+
};
|
|
13
|
+
const styles$1 = StyleSheet.create({ base: {
|
|
14
|
+
flexDirection: "row",
|
|
15
|
+
alignItems: "center"
|
|
16
|
+
} });
|
|
17
|
+
function Badge({ variant = "info", style, testID, children }) {
|
|
18
|
+
const t = useTheme$1();
|
|
19
|
+
const colors = variantColors[variant](t);
|
|
20
|
+
const container = {
|
|
21
|
+
paddingVertical: t.space[1],
|
|
22
|
+
paddingHorizontal: t.space[2],
|
|
23
|
+
borderRadius: t.radius.full,
|
|
24
|
+
borderWidth: t.borderWidth.thin,
|
|
25
|
+
borderColor: colors.border,
|
|
26
|
+
backgroundColor: colors.bg
|
|
27
|
+
};
|
|
28
|
+
const label = {
|
|
29
|
+
flexShrink: 1,
|
|
30
|
+
fontSize: t.font.size.xs,
|
|
31
|
+
lineHeight: t.font.lineHeight.xs,
|
|
32
|
+
fontWeight: t.font.weight.medium,
|
|
33
|
+
color: colors.text
|
|
34
|
+
};
|
|
35
|
+
const family = t.font.family.sans;
|
|
36
|
+
if (family !== void 0) label.fontFamily = family;
|
|
37
|
+
return /* @__PURE__ */ jsx(View, {
|
|
38
|
+
testID,
|
|
39
|
+
style: [
|
|
40
|
+
styles$1.base,
|
|
41
|
+
container,
|
|
42
|
+
style
|
|
43
|
+
],
|
|
44
|
+
children: /* @__PURE__ */ jsx(Text$1, {
|
|
45
|
+
style: label,
|
|
46
|
+
children
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/box/Box.native.tsx
|
|
52
|
+
function Box({ padding, paddingX, paddingY, background, radius, borderColor, shadow, flex, style, testID, children }) {
|
|
53
|
+
const t = useTheme$1();
|
|
54
|
+
const computed = {};
|
|
55
|
+
if (padding !== void 0) computed.padding = t.space[padding];
|
|
56
|
+
if (paddingX !== void 0) computed.paddingHorizontal = t.space[paddingX];
|
|
57
|
+
if (paddingY !== void 0) computed.paddingVertical = t.space[paddingY];
|
|
58
|
+
if (background !== void 0) computed.backgroundColor = t.color.bg[background];
|
|
59
|
+
if (radius !== void 0) computed.borderRadius = t.radius[radius];
|
|
60
|
+
if (borderColor !== void 0) {
|
|
61
|
+
computed.borderWidth = t.borderWidth.thin;
|
|
62
|
+
computed.borderColor = t.color.border[borderColor];
|
|
63
|
+
}
|
|
64
|
+
if (shadow !== void 0) computed.boxShadow = t.shadow[shadow];
|
|
65
|
+
if (flex !== void 0) computed.flex = flex;
|
|
66
|
+
return /* @__PURE__ */ jsx(View, {
|
|
67
|
+
style: [computed, style],
|
|
68
|
+
testID,
|
|
69
|
+
children
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ../icons/src/icons.ts
|
|
74
|
+
const icons = {
|
|
75
|
+
"arrow-left": [{
|
|
76
|
+
"type": "path",
|
|
77
|
+
"d": "m12 19-7-7 7-7"
|
|
78
|
+
}, {
|
|
79
|
+
"type": "path",
|
|
80
|
+
"d": "M19 12H5"
|
|
81
|
+
}],
|
|
82
|
+
"arrow-right": [{
|
|
83
|
+
"type": "path",
|
|
84
|
+
"d": "M5 12h14"
|
|
85
|
+
}, {
|
|
86
|
+
"type": "path",
|
|
87
|
+
"d": "m12 5 7 7-7 7"
|
|
88
|
+
}],
|
|
89
|
+
"calendar": [
|
|
90
|
+
{
|
|
91
|
+
"type": "path",
|
|
92
|
+
"d": "M8 2v3"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"type": "path",
|
|
96
|
+
"d": "M16 2v3"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"type": "rect",
|
|
100
|
+
"x": 3,
|
|
101
|
+
"y": 3,
|
|
102
|
+
"width": 18,
|
|
103
|
+
"height": 18,
|
|
104
|
+
"rx": 2
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"type": "path",
|
|
108
|
+
"d": "M3 9h18"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"check": [{
|
|
112
|
+
"type": "path",
|
|
113
|
+
"d": "M20 6 9 17l-5-5"
|
|
114
|
+
}],
|
|
115
|
+
"chevron-down": [{
|
|
116
|
+
"type": "path",
|
|
117
|
+
"d": "m6 9 6 6 6-6"
|
|
118
|
+
}],
|
|
119
|
+
"chevron-left": [{
|
|
120
|
+
"type": "path",
|
|
121
|
+
"d": "m15 18-6-6 6-6"
|
|
122
|
+
}],
|
|
123
|
+
"chevron-right": [{
|
|
124
|
+
"type": "path",
|
|
125
|
+
"d": "m9 18 6-6-6-6"
|
|
126
|
+
}],
|
|
127
|
+
"chevron-up": [{
|
|
128
|
+
"type": "path",
|
|
129
|
+
"d": "m18 15-6-6-6 6"
|
|
130
|
+
}],
|
|
131
|
+
"circle-alert": [
|
|
132
|
+
{
|
|
133
|
+
"type": "circle",
|
|
134
|
+
"cx": 12,
|
|
135
|
+
"cy": 12,
|
|
136
|
+
"r": 10
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "line",
|
|
140
|
+
"x1": 12,
|
|
141
|
+
"y1": 8,
|
|
142
|
+
"x2": 12,
|
|
143
|
+
"y2": 12
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "line",
|
|
147
|
+
"x1": 12,
|
|
148
|
+
"y1": 16,
|
|
149
|
+
"x2": 12.01,
|
|
150
|
+
"y2": 16
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"circle-check": [{
|
|
154
|
+
"type": "circle",
|
|
155
|
+
"cx": 12,
|
|
156
|
+
"cy": 12,
|
|
157
|
+
"r": 10
|
|
158
|
+
}, {
|
|
159
|
+
"type": "path",
|
|
160
|
+
"d": "m16 9-5.5 5.5L8 12"
|
|
161
|
+
}],
|
|
162
|
+
"circle-x": [
|
|
163
|
+
{
|
|
164
|
+
"type": "circle",
|
|
165
|
+
"cx": 12,
|
|
166
|
+
"cy": 12,
|
|
167
|
+
"r": 10
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"type": "path",
|
|
171
|
+
"d": "m15 9-6 6"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"type": "path",
|
|
175
|
+
"d": "m9 9 6 6"
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"eye-off": [
|
|
179
|
+
{
|
|
180
|
+
"type": "path",
|
|
181
|
+
"d": "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"type": "path",
|
|
185
|
+
"d": "M14.084 14.158a3 3 0 0 1-4.242-4.242"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "path",
|
|
189
|
+
"d": "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "path",
|
|
193
|
+
"d": "m2 2 20 20"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"eye": [{
|
|
197
|
+
"type": "path",
|
|
198
|
+
"d": "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"
|
|
199
|
+
}, {
|
|
200
|
+
"type": "circle",
|
|
201
|
+
"cx": 12,
|
|
202
|
+
"cy": 12,
|
|
203
|
+
"r": 3
|
|
204
|
+
}],
|
|
205
|
+
"globe": [
|
|
206
|
+
{
|
|
207
|
+
"type": "circle",
|
|
208
|
+
"cx": 12,
|
|
209
|
+
"cy": 12,
|
|
210
|
+
"r": 10
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"type": "path",
|
|
214
|
+
"d": "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "path",
|
|
218
|
+
"d": "M2 12h20"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"info": [
|
|
222
|
+
{
|
|
223
|
+
"type": "circle",
|
|
224
|
+
"cx": 12,
|
|
225
|
+
"cy": 12,
|
|
226
|
+
"r": 10
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"type": "path",
|
|
230
|
+
"d": "M12 16v-4"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"type": "path",
|
|
234
|
+
"d": "M12 8h.01"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"loader-circle": [{
|
|
238
|
+
"type": "path",
|
|
239
|
+
"d": "M21 12a9 9 0 1 1-6.219-8.56"
|
|
240
|
+
}],
|
|
241
|
+
"map-pin": [{
|
|
242
|
+
"type": "path",
|
|
243
|
+
"d": "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"
|
|
244
|
+
}, {
|
|
245
|
+
"type": "circle",
|
|
246
|
+
"cx": 12,
|
|
247
|
+
"cy": 10,
|
|
248
|
+
"r": 3
|
|
249
|
+
}],
|
|
250
|
+
"menu": [
|
|
251
|
+
{
|
|
252
|
+
"type": "path",
|
|
253
|
+
"d": "M4 5h16"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"type": "path",
|
|
257
|
+
"d": "M4 12h16"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"type": "path",
|
|
261
|
+
"d": "M4 19h16"
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
"minus": [{
|
|
265
|
+
"type": "path",
|
|
266
|
+
"d": "M5 12h14"
|
|
267
|
+
}],
|
|
268
|
+
"plus": [{
|
|
269
|
+
"type": "path",
|
|
270
|
+
"d": "M5 12h14"
|
|
271
|
+
}, {
|
|
272
|
+
"type": "path",
|
|
273
|
+
"d": "M12 5v14"
|
|
274
|
+
}],
|
|
275
|
+
"search": [{
|
|
276
|
+
"type": "path",
|
|
277
|
+
"d": "m21 21-4.34-4.34"
|
|
278
|
+
}, {
|
|
279
|
+
"type": "circle",
|
|
280
|
+
"cx": 11,
|
|
281
|
+
"cy": 11,
|
|
282
|
+
"r": 8
|
|
283
|
+
}],
|
|
284
|
+
"settings": [{
|
|
285
|
+
"type": "path",
|
|
286
|
+
"d": "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"
|
|
287
|
+
}, {
|
|
288
|
+
"type": "circle",
|
|
289
|
+
"cx": 12,
|
|
290
|
+
"cy": 12,
|
|
291
|
+
"r": 3
|
|
292
|
+
}],
|
|
293
|
+
"ticket": [
|
|
294
|
+
{
|
|
295
|
+
"type": "path",
|
|
296
|
+
"d": "M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"type": "path",
|
|
300
|
+
"d": "M13 5v2"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"type": "path",
|
|
304
|
+
"d": "M13 17v2"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"type": "path",
|
|
308
|
+
"d": "M13 11v2"
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
"triangle-alert": [
|
|
312
|
+
{
|
|
313
|
+
"type": "path",
|
|
314
|
+
"d": "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"type": "path",
|
|
318
|
+
"d": "M12 9v4"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"type": "path",
|
|
322
|
+
"d": "M12 17h.01"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"user": [{
|
|
326
|
+
"type": "path",
|
|
327
|
+
"d": "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"
|
|
328
|
+
}, {
|
|
329
|
+
"type": "circle",
|
|
330
|
+
"cx": 12,
|
|
331
|
+
"cy": 7,
|
|
332
|
+
"r": 4
|
|
333
|
+
}],
|
|
334
|
+
"x": [{
|
|
335
|
+
"type": "path",
|
|
336
|
+
"d": "M18 6 6 18"
|
|
337
|
+
}, {
|
|
338
|
+
"type": "path",
|
|
339
|
+
"d": "m6 6 12 12"
|
|
340
|
+
}]
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/icon/Icon.native.tsx
|
|
344
|
+
function renderElement(element, index) {
|
|
345
|
+
switch (element.type) {
|
|
346
|
+
case "path": return /* @__PURE__ */ jsx(Path, { d: element.d }, index);
|
|
347
|
+
case "circle": return /* @__PURE__ */ jsx(Circle, {
|
|
348
|
+
cx: element.cx,
|
|
349
|
+
cy: element.cy,
|
|
350
|
+
r: element.r
|
|
351
|
+
}, index);
|
|
352
|
+
case "line": return /* @__PURE__ */ jsx(Line, {
|
|
353
|
+
x1: element.x1,
|
|
354
|
+
y1: element.y1,
|
|
355
|
+
x2: element.x2,
|
|
356
|
+
y2: element.y2
|
|
357
|
+
}, index);
|
|
358
|
+
case "rect": return /* @__PURE__ */ jsx(Rect, {
|
|
359
|
+
x: element.x,
|
|
360
|
+
y: element.y,
|
|
361
|
+
width: element.width,
|
|
362
|
+
height: element.height,
|
|
363
|
+
...element.rx === void 0 ? {} : { rx: element.rx }
|
|
364
|
+
}, index);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function Icon({ name, size = "md", color = "primary", label, style, testID }) {
|
|
368
|
+
const t = useTheme$1();
|
|
369
|
+
const px = iconSizePx[size];
|
|
370
|
+
const decorative = label === void 0;
|
|
371
|
+
const optional = {
|
|
372
|
+
...style === void 0 ? {} : { style },
|
|
373
|
+
...testID === void 0 ? {} : { testID },
|
|
374
|
+
...decorative ? {
|
|
375
|
+
accessibilityElementsHidden: true,
|
|
376
|
+
importantForAccessibility: "no-hide-descendants"
|
|
377
|
+
} : {
|
|
378
|
+
accessible: true,
|
|
379
|
+
accessibilityRole: "image",
|
|
380
|
+
accessibilityLabel: label
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
return /* @__PURE__ */ jsx(Svg, {
|
|
384
|
+
width: px,
|
|
385
|
+
height: px,
|
|
386
|
+
viewBox: `0 0 24 24`,
|
|
387
|
+
fill: "none",
|
|
388
|
+
stroke: t.color.text[color],
|
|
389
|
+
strokeWidth: 2,
|
|
390
|
+
strokeLinecap: "round",
|
|
391
|
+
strokeLinejoin: "round",
|
|
392
|
+
...optional,
|
|
393
|
+
children: icons[name].map(renderElement)
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/spinner/Spinner.native.tsx
|
|
398
|
+
/**
|
|
399
|
+
* Indicador de carga indeterminada. Versión mínima (ROADMAP Fase 3): el icono
|
|
400
|
+
* `loader-circle` girando con `Animated` y el driver nativo, sin dependencias extra.
|
|
401
|
+
* Con `label` es una barra de progreso indeterminada para los lectores de
|
|
402
|
+
* pantalla; sin él, es decorativo.
|
|
403
|
+
*/
|
|
404
|
+
function Spinner({ size = "md", color = "primary", label, style, testID }) {
|
|
405
|
+
const t = useTheme$1();
|
|
406
|
+
const [rotation] = useState(() => new Animated.Value(0));
|
|
407
|
+
const duration = t.duration.slow * 2;
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
const loop = Animated.loop(Animated.timing(rotation, {
|
|
410
|
+
toValue: 1,
|
|
411
|
+
duration,
|
|
412
|
+
easing: Easing.linear,
|
|
413
|
+
useNativeDriver: true
|
|
414
|
+
}));
|
|
415
|
+
loop.start();
|
|
416
|
+
return () => loop.stop();
|
|
417
|
+
}, [rotation, duration]);
|
|
418
|
+
const px = spinnerSizePx[size];
|
|
419
|
+
const rotate = rotation.interpolate({
|
|
420
|
+
inputRange: [0, 1],
|
|
421
|
+
outputRange: ["0deg", "360deg"]
|
|
422
|
+
});
|
|
423
|
+
const accessibility = label === void 0 ? {
|
|
424
|
+
accessibilityElementsHidden: true,
|
|
425
|
+
importantForAccessibility: "no-hide-descendants"
|
|
426
|
+
} : {
|
|
427
|
+
accessible: true,
|
|
428
|
+
accessibilityRole: "progressbar",
|
|
429
|
+
accessibilityLabel: label,
|
|
430
|
+
accessibilityState: { busy: true }
|
|
431
|
+
};
|
|
432
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
433
|
+
style: [{
|
|
434
|
+
width: px,
|
|
435
|
+
height: px,
|
|
436
|
+
transform: [{ rotate }]
|
|
437
|
+
}, style],
|
|
438
|
+
testID,
|
|
439
|
+
...accessibility,
|
|
440
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
441
|
+
name: "loader-circle",
|
|
442
|
+
size,
|
|
443
|
+
color
|
|
444
|
+
})
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/button/Button.native.tsx
|
|
449
|
+
const variantStyles = {
|
|
450
|
+
primary: (t) => ({
|
|
451
|
+
background: t.color.action.primary,
|
|
452
|
+
pressed: t.color.action.primaryActive,
|
|
453
|
+
disabled: t.color.action.disabled,
|
|
454
|
+
border: "transparent",
|
|
455
|
+
content: "onPrimary"
|
|
456
|
+
}),
|
|
457
|
+
secondary: (t) => ({
|
|
458
|
+
background: t.color.action.secondary,
|
|
459
|
+
pressed: t.color.action.secondaryActive,
|
|
460
|
+
disabled: t.color.action.disabled,
|
|
461
|
+
border: t.color.border.default,
|
|
462
|
+
content: "primary"
|
|
463
|
+
}),
|
|
464
|
+
ghost: (t) => ({
|
|
465
|
+
background: "transparent",
|
|
466
|
+
pressed: t.color.bg.muted,
|
|
467
|
+
disabled: "transparent",
|
|
468
|
+
border: "transparent",
|
|
469
|
+
content: "primary"
|
|
470
|
+
}),
|
|
471
|
+
danger: (t) => ({
|
|
472
|
+
background: t.color.action.danger,
|
|
473
|
+
pressed: t.color.action.dangerActive,
|
|
474
|
+
disabled: t.color.action.disabled,
|
|
475
|
+
border: "transparent",
|
|
476
|
+
content: "onDanger"
|
|
477
|
+
})
|
|
478
|
+
};
|
|
479
|
+
const sizeStyles = {
|
|
480
|
+
sm: (t) => ({
|
|
481
|
+
minHeight: t.size.control.sm,
|
|
482
|
+
paddingHorizontal: t.space[3],
|
|
483
|
+
paddingVertical: t.space[1],
|
|
484
|
+
fontSize: t.font.size.sm,
|
|
485
|
+
lineHeight: t.font.lineHeight.sm
|
|
486
|
+
}),
|
|
487
|
+
md: (t) => ({
|
|
488
|
+
minHeight: t.size.control.md,
|
|
489
|
+
paddingHorizontal: t.space[4],
|
|
490
|
+
paddingVertical: t.space[2],
|
|
491
|
+
fontSize: t.font.size.sm,
|
|
492
|
+
lineHeight: t.font.lineHeight.sm
|
|
493
|
+
}),
|
|
494
|
+
lg: (t) => ({
|
|
495
|
+
minHeight: t.size.control.lg,
|
|
496
|
+
paddingHorizontal: t.space[5],
|
|
497
|
+
paddingVertical: t.space[3],
|
|
498
|
+
fontSize: t.font.size.md,
|
|
499
|
+
lineHeight: t.font.lineHeight.md
|
|
500
|
+
})
|
|
501
|
+
};
|
|
502
|
+
const styles = StyleSheet.create({
|
|
503
|
+
base: {
|
|
504
|
+
flexDirection: "row",
|
|
505
|
+
alignItems: "center",
|
|
506
|
+
justifyContent: "center"
|
|
507
|
+
},
|
|
508
|
+
fullWidth: { width: "100%" },
|
|
509
|
+
content: {
|
|
510
|
+
flexDirection: "row",
|
|
511
|
+
alignItems: "center",
|
|
512
|
+
justifyContent: "center",
|
|
513
|
+
flexShrink: 1
|
|
514
|
+
},
|
|
515
|
+
hidden: { opacity: 0 },
|
|
516
|
+
spinner: {
|
|
517
|
+
position: "absolute",
|
|
518
|
+
top: 0,
|
|
519
|
+
right: 0,
|
|
520
|
+
bottom: 0,
|
|
521
|
+
left: 0,
|
|
522
|
+
alignItems: "center",
|
|
523
|
+
justifyContent: "center"
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
/** El texto como `children` se envuelve en `<Text>`; cualquier otro contenido se deja tal cual. */
|
|
527
|
+
function renderLabel(children, style) {
|
|
528
|
+
return Children.toArray(children).every((child) => typeof child === "string" || typeof child === "number") ? /* @__PURE__ */ jsx(Text$1, {
|
|
529
|
+
style,
|
|
530
|
+
children
|
|
531
|
+
}) : children;
|
|
532
|
+
}
|
|
533
|
+
function Button({ variant = "primary", size = "md", disabled = false, loading = false, iconStart, iconEnd, fullWidth = false, onPress, accessibilityLabel, style, testID, ref, children }) {
|
|
534
|
+
const t = useTheme$1();
|
|
535
|
+
const { interactive, press } = useButton({
|
|
536
|
+
disabled,
|
|
537
|
+
loading,
|
|
538
|
+
onPress
|
|
539
|
+
});
|
|
540
|
+
const [focused, setFocused] = useState(false);
|
|
541
|
+
const colors = variantStyles[variant](t);
|
|
542
|
+
const dimensions = sizeStyles[size](t);
|
|
543
|
+
const content = disabled ? "disabled" : colors.content;
|
|
544
|
+
const iconSize = buttonIconSize[size];
|
|
545
|
+
const container = {
|
|
546
|
+
minHeight: dimensions.minHeight,
|
|
547
|
+
paddingHorizontal: dimensions.paddingHorizontal,
|
|
548
|
+
paddingVertical: dimensions.paddingVertical,
|
|
549
|
+
borderRadius: t.radius.md,
|
|
550
|
+
borderWidth: t.borderWidth.thin,
|
|
551
|
+
borderColor: disabled ? "transparent" : colors.border
|
|
552
|
+
};
|
|
553
|
+
const focusRing = {
|
|
554
|
+
outlineStyle: "solid",
|
|
555
|
+
outlineColor: t.color.border.focus,
|
|
556
|
+
outlineWidth: t.borderWidth.thick,
|
|
557
|
+
outlineOffset: t.borderWidth.thick
|
|
558
|
+
};
|
|
559
|
+
const label = {
|
|
560
|
+
flexShrink: 1,
|
|
561
|
+
fontSize: dimensions.fontSize,
|
|
562
|
+
lineHeight: dimensions.lineHeight,
|
|
563
|
+
fontWeight: t.font.weight.medium,
|
|
564
|
+
color: t.color.text[content],
|
|
565
|
+
textAlign: "center"
|
|
566
|
+
};
|
|
567
|
+
const family = t.font.family.sans;
|
|
568
|
+
if (family !== void 0) label.fontFamily = family;
|
|
569
|
+
const hitSlop = Math.max(0, (t.size.control.md - dimensions.minHeight) / 2);
|
|
570
|
+
return /* @__PURE__ */ jsxs(Pressable, {
|
|
571
|
+
ref,
|
|
572
|
+
accessibilityRole: "button",
|
|
573
|
+
accessibilityLabel,
|
|
574
|
+
accessibilityState: {
|
|
575
|
+
disabled: !interactive,
|
|
576
|
+
busy: loading
|
|
577
|
+
},
|
|
578
|
+
disabled: !interactive,
|
|
579
|
+
hitSlop,
|
|
580
|
+
onPress: press,
|
|
581
|
+
onFocus: () => setFocused(true),
|
|
582
|
+
onBlur: () => setFocused(false),
|
|
583
|
+
testID,
|
|
584
|
+
style: ({ pressed }) => [
|
|
585
|
+
styles.base,
|
|
586
|
+
container,
|
|
587
|
+
{ backgroundColor: disabled ? colors.disabled : pressed ? colors.pressed : colors.background },
|
|
588
|
+
fullWidth && styles.fullWidth,
|
|
589
|
+
focused && focusRing,
|
|
590
|
+
style
|
|
591
|
+
],
|
|
592
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
593
|
+
style: [
|
|
594
|
+
styles.content,
|
|
595
|
+
{ gap: t.space[2] },
|
|
596
|
+
loading && styles.hidden
|
|
597
|
+
],
|
|
598
|
+
children: [
|
|
599
|
+
iconStart === void 0 ? null : /* @__PURE__ */ jsx(Icon, {
|
|
600
|
+
name: iconStart,
|
|
601
|
+
size: iconSize,
|
|
602
|
+
color: content
|
|
603
|
+
}),
|
|
604
|
+
renderLabel(children, label),
|
|
605
|
+
iconEnd === void 0 ? null : /* @__PURE__ */ jsx(Icon, {
|
|
606
|
+
name: iconEnd,
|
|
607
|
+
size: iconSize,
|
|
608
|
+
color: content
|
|
609
|
+
})
|
|
610
|
+
]
|
|
611
|
+
}), loading ? /* @__PURE__ */ jsx(View, {
|
|
612
|
+
style: styles.spinner,
|
|
613
|
+
children: /* @__PURE__ */ jsx(Spinner, {
|
|
614
|
+
size: iconSize,
|
|
615
|
+
color: content
|
|
616
|
+
})
|
|
617
|
+
}) : null]
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/stack/Stack.native.tsx
|
|
622
|
+
const alignItems = {
|
|
623
|
+
stretch: "stretch",
|
|
624
|
+
start: "flex-start",
|
|
625
|
+
center: "center",
|
|
626
|
+
end: "flex-end"
|
|
627
|
+
};
|
|
628
|
+
const justifyContent = {
|
|
629
|
+
start: "flex-start",
|
|
630
|
+
center: "center",
|
|
631
|
+
end: "flex-end",
|
|
632
|
+
between: "space-between",
|
|
633
|
+
around: "space-around"
|
|
634
|
+
};
|
|
635
|
+
function Stack({ direction = "column", gap, align = "stretch", justify = "start", wrap = false, style, ...boxProps }) {
|
|
636
|
+
const t = useTheme$1();
|
|
637
|
+
const layout = {
|
|
638
|
+
flexDirection: direction,
|
|
639
|
+
alignItems: alignItems[align],
|
|
640
|
+
justifyContent: justifyContent[justify],
|
|
641
|
+
flexWrap: wrap ? "wrap" : "nowrap"
|
|
642
|
+
};
|
|
643
|
+
if (gap !== void 0) layout.gap = t.space[gap];
|
|
644
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
645
|
+
...boxProps,
|
|
646
|
+
style: [layout, style]
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/text/Text.native.tsx
|
|
651
|
+
const textAlign = {
|
|
652
|
+
left: "left",
|
|
653
|
+
center: "center",
|
|
654
|
+
right: "right"
|
|
655
|
+
};
|
|
656
|
+
function Text({ variant = "body", color = "primary", align, truncate = false, numberOfLines, style, testID, children }) {
|
|
657
|
+
const t = useTheme$1();
|
|
658
|
+
const spec = textVariantStyles[variant];
|
|
659
|
+
const computed = {
|
|
660
|
+
fontSize: t.font.size[spec.size],
|
|
661
|
+
lineHeight: t.font.lineHeight[spec.size],
|
|
662
|
+
fontWeight: t.font.weight[spec.weight],
|
|
663
|
+
color: t.color.text[color]
|
|
664
|
+
};
|
|
665
|
+
const family = t.font.family[spec.family];
|
|
666
|
+
if (family !== void 0) computed.fontFamily = family;
|
|
667
|
+
if (align !== void 0) computed.textAlign = textAlign[align];
|
|
668
|
+
if (spec.uppercase) computed.textTransform = "uppercase";
|
|
669
|
+
if (spec.letterSpacing !== void 0) computed.letterSpacing = spec.letterSpacing;
|
|
670
|
+
return /* @__PURE__ */ jsx(Text$1, {
|
|
671
|
+
style: [computed, style],
|
|
672
|
+
numberOfLines: truncate ? 1 : numberOfLines,
|
|
673
|
+
ellipsizeMode: "tail",
|
|
674
|
+
accessibilityRole: spec.headingLevel === void 0 ? void 0 : "header",
|
|
675
|
+
"aria-level": spec.headingLevel,
|
|
676
|
+
testID,
|
|
677
|
+
children
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/ui-provider/UIProvider.native.tsx
|
|
682
|
+
/**
|
|
683
|
+
* Activa tema y marca para todo lo que envuelve (ADR-010). Entrega el tema
|
|
684
|
+
* resuelto por contexto; `system` sigue a `Appearance`.
|
|
685
|
+
*/
|
|
686
|
+
function UIProvider({ theme = "system", brand, children }) {
|
|
687
|
+
const system = useColorScheme$1() === "dark" ? "dark" : "light";
|
|
688
|
+
const value = useMemo(() => createUIContextValue(theme, system, brand), [
|
|
689
|
+
theme,
|
|
690
|
+
system,
|
|
691
|
+
brand
|
|
692
|
+
]);
|
|
693
|
+
return /* @__PURE__ */ jsx(UIContext.Provider, {
|
|
694
|
+
value,
|
|
695
|
+
children
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
//#endregion
|
|
699
|
+
export { Badge, Box, Button, Icon, Spinner, Stack, Text, UIProvider, useBrand, useColorScheme, useTheme };
|