@flare-engine/ui 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/README.md +32 -0
- package/dist/index.d.mts +350 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.js +760 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +715 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
// src/theme.ts
|
|
2
|
+
import { createContext, createElement, useContext } from "react";
|
|
3
|
+
var darkTheme = {
|
|
4
|
+
name: "dark",
|
|
5
|
+
colors: {
|
|
6
|
+
bg: "#0b0d10",
|
|
7
|
+
surface: "#14181d",
|
|
8
|
+
surfaceAlt: "#1d232b",
|
|
9
|
+
border: "#2a323c",
|
|
10
|
+
text: "#e7ecf1",
|
|
11
|
+
textMuted: "#8c96a3",
|
|
12
|
+
accent: "#4aa3ff",
|
|
13
|
+
accentText: "#0b0d10",
|
|
14
|
+
danger: "#ff5c5c",
|
|
15
|
+
success: "#5dd39e",
|
|
16
|
+
warning: "#f1c40f",
|
|
17
|
+
focus: "#ffd166"
|
|
18
|
+
},
|
|
19
|
+
spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },
|
|
20
|
+
typography: {
|
|
21
|
+
sizeXs: 10,
|
|
22
|
+
sizeSm: 12,
|
|
23
|
+
sizeMd: 14,
|
|
24
|
+
sizeLg: 18,
|
|
25
|
+
sizeXl: 24
|
|
26
|
+
},
|
|
27
|
+
radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 }
|
|
28
|
+
};
|
|
29
|
+
var lightTheme = {
|
|
30
|
+
name: "light",
|
|
31
|
+
colors: {
|
|
32
|
+
bg: "#f6f8fa",
|
|
33
|
+
surface: "#ffffff",
|
|
34
|
+
surfaceAlt: "#eef1f4",
|
|
35
|
+
border: "#d4dae0",
|
|
36
|
+
text: "#13181d",
|
|
37
|
+
textMuted: "#5b6670",
|
|
38
|
+
accent: "#0a66d0",
|
|
39
|
+
accentText: "#ffffff",
|
|
40
|
+
danger: "#d12e2e",
|
|
41
|
+
success: "#2f9d69",
|
|
42
|
+
warning: "#c79600",
|
|
43
|
+
focus: "#ff9500"
|
|
44
|
+
},
|
|
45
|
+
spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },
|
|
46
|
+
typography: {
|
|
47
|
+
sizeXs: 10,
|
|
48
|
+
sizeSm: 12,
|
|
49
|
+
sizeMd: 14,
|
|
50
|
+
sizeLg: 18,
|
|
51
|
+
sizeXl: 24
|
|
52
|
+
},
|
|
53
|
+
radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 }
|
|
54
|
+
};
|
|
55
|
+
var ThemeContext = createContext(darkTheme);
|
|
56
|
+
function ThemeProvider({ theme = darkTheme, children }) {
|
|
57
|
+
return createElement(ThemeContext.Provider, { value: theme }, children);
|
|
58
|
+
}
|
|
59
|
+
function useTheme() {
|
|
60
|
+
return useContext(ThemeContext);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/focus.ts
|
|
64
|
+
function createFocusManager() {
|
|
65
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
66
|
+
let seqCounter = 0;
|
|
67
|
+
let focusedId = null;
|
|
68
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
69
|
+
function notify() {
|
|
70
|
+
for (const l of listeners) l(focusedId);
|
|
71
|
+
}
|
|
72
|
+
function orderedIds() {
|
|
73
|
+
const entries = Array.from(nodes.values()).filter((e) => !e.disabled);
|
|
74
|
+
entries.sort((a, b) => {
|
|
75
|
+
if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;
|
|
76
|
+
return a.seq - b.seq;
|
|
77
|
+
});
|
|
78
|
+
return entries.map((e) => e.id);
|
|
79
|
+
}
|
|
80
|
+
function setFocused(next) {
|
|
81
|
+
if (next === focusedId) return;
|
|
82
|
+
const prev = focusedId;
|
|
83
|
+
focusedId = next;
|
|
84
|
+
if (prev !== null) nodes.get(prev)?.onBlur?.();
|
|
85
|
+
if (next !== null) nodes.get(next)?.onFocus?.();
|
|
86
|
+
notify();
|
|
87
|
+
}
|
|
88
|
+
function move(delta) {
|
|
89
|
+
const order = orderedIds();
|
|
90
|
+
if (order.length === 0) {
|
|
91
|
+
setFocused(null);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (focusedId === null) {
|
|
95
|
+
setFocused(delta === 1 ? order[0] ?? null : order[order.length - 1] ?? null);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const idx = order.indexOf(focusedId);
|
|
99
|
+
if (idx === -1) {
|
|
100
|
+
setFocused(order[0] ?? null);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const nextIdx = (idx + delta + order.length) % order.length;
|
|
104
|
+
setFocused(order[nextIdx] ?? null);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
register(node) {
|
|
108
|
+
const entry = { ...node, seq: seqCounter++ };
|
|
109
|
+
nodes.set(node.id, entry);
|
|
110
|
+
if (focusedId === null && !node.disabled) {
|
|
111
|
+
setFocused(node.id);
|
|
112
|
+
}
|
|
113
|
+
return () => {
|
|
114
|
+
this.unregister(node.id);
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
unregister(id) {
|
|
118
|
+
if (!nodes.has(id)) return;
|
|
119
|
+
nodes.delete(id);
|
|
120
|
+
if (focusedId === id) {
|
|
121
|
+
const order = orderedIds();
|
|
122
|
+
setFocused(order[0] ?? null);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
focus(id) {
|
|
126
|
+
const entry = nodes.get(id);
|
|
127
|
+
if (!entry || entry.disabled) return;
|
|
128
|
+
setFocused(id);
|
|
129
|
+
},
|
|
130
|
+
blur() {
|
|
131
|
+
setFocused(null);
|
|
132
|
+
},
|
|
133
|
+
next() {
|
|
134
|
+
move(1);
|
|
135
|
+
},
|
|
136
|
+
prev() {
|
|
137
|
+
move(-1);
|
|
138
|
+
},
|
|
139
|
+
activate() {
|
|
140
|
+
if (focusedId === null) return;
|
|
141
|
+
nodes.get(focusedId)?.onActivate?.();
|
|
142
|
+
},
|
|
143
|
+
getFocused() {
|
|
144
|
+
return focusedId;
|
|
145
|
+
},
|
|
146
|
+
getOrder() {
|
|
147
|
+
return orderedIds();
|
|
148
|
+
},
|
|
149
|
+
subscribe(listener) {
|
|
150
|
+
listeners.add(listener);
|
|
151
|
+
return () => {
|
|
152
|
+
listeners.delete(listener);
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/focus-context.ts
|
|
159
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
160
|
+
var FocusContext = createContext2(null);
|
|
161
|
+
function useFocusManager() {
|
|
162
|
+
return useContext2(FocusContext);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/focus-provider.tsx
|
|
166
|
+
import { createElement as createElement2, useEffect, useState } from "react";
|
|
167
|
+
function FocusProvider({ manager, children }) {
|
|
168
|
+
const [mgr] = useState(() => manager ?? createFocusManager());
|
|
169
|
+
const [, force] = useState(0);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
return mgr.subscribe(() => {
|
|
172
|
+
force((n) => n + 1);
|
|
173
|
+
});
|
|
174
|
+
}, [mgr]);
|
|
175
|
+
return createElement2(FocusContext.Provider, { value: mgr }, children);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/layout.ts
|
|
179
|
+
var ZERO_PAD = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
180
|
+
function resolvePadding(p) {
|
|
181
|
+
if (!p) return ZERO_PAD;
|
|
182
|
+
return {
|
|
183
|
+
top: p.top ?? 0,
|
|
184
|
+
right: p.right ?? 0,
|
|
185
|
+
bottom: p.bottom ?? 0,
|
|
186
|
+
left: p.left ?? 0
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function resolveLayout(container, children) {
|
|
190
|
+
const n = children.length;
|
|
191
|
+
if (n === 0) return [];
|
|
192
|
+
const pad = resolvePadding(container.padding);
|
|
193
|
+
const gap = container.gap ?? 0;
|
|
194
|
+
const isRow = container.direction === "row";
|
|
195
|
+
const mainSize = (isRow ? container.width : container.height) - (isRow ? pad.left + pad.right : pad.top + pad.bottom);
|
|
196
|
+
const crossSize = (isRow ? container.height : container.width) - (isRow ? pad.top + pad.bottom : pad.left + pad.right);
|
|
197
|
+
const mainStart = isRow ? pad.left : pad.top;
|
|
198
|
+
const crossStart = isRow ? pad.top : pad.left;
|
|
199
|
+
const justify = container.justifyContent ?? "start";
|
|
200
|
+
const align = container.alignItems ?? "stretch";
|
|
201
|
+
const totalGap = gap * Math.max(0, n - 1);
|
|
202
|
+
let totalBasis = 0;
|
|
203
|
+
let totalGrow = 0;
|
|
204
|
+
for (const c of children) {
|
|
205
|
+
totalBasis += c.basis ?? 0;
|
|
206
|
+
totalGrow += c.grow ?? 0;
|
|
207
|
+
}
|
|
208
|
+
const leftover = mainSize - totalBasis - totalGap;
|
|
209
|
+
const sizes = new Array(n);
|
|
210
|
+
for (let i = 0; i < n; i++) {
|
|
211
|
+
const c = children[i];
|
|
212
|
+
const base = c.basis ?? 0;
|
|
213
|
+
const growShare = totalGrow > 0 ? (c.grow ?? 0) / totalGrow * Math.max(0, leftover) : 0;
|
|
214
|
+
sizes[i] = Math.max(0, base + growShare);
|
|
215
|
+
}
|
|
216
|
+
const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;
|
|
217
|
+
const free = Math.max(0, mainSize - used);
|
|
218
|
+
let cursor = mainStart;
|
|
219
|
+
let spacing = gap;
|
|
220
|
+
switch (justify) {
|
|
221
|
+
case "start":
|
|
222
|
+
break;
|
|
223
|
+
case "end":
|
|
224
|
+
cursor = mainStart + free;
|
|
225
|
+
break;
|
|
226
|
+
case "center":
|
|
227
|
+
cursor = mainStart + free / 2;
|
|
228
|
+
break;
|
|
229
|
+
case "space-between":
|
|
230
|
+
if (n > 1) spacing = gap + free / (n - 1);
|
|
231
|
+
break;
|
|
232
|
+
case "space-around":
|
|
233
|
+
if (n > 0) {
|
|
234
|
+
const s = free / n;
|
|
235
|
+
cursor = mainStart + s / 2;
|
|
236
|
+
spacing = gap + s;
|
|
237
|
+
}
|
|
238
|
+
break;
|
|
239
|
+
case "space-evenly":
|
|
240
|
+
if (n >= 0) {
|
|
241
|
+
const s = free / (n + 1);
|
|
242
|
+
cursor = mainStart + s;
|
|
243
|
+
spacing = gap + s;
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
const out = new Array(n);
|
|
248
|
+
for (let i = 0; i < n; i++) {
|
|
249
|
+
const c = children[i];
|
|
250
|
+
const mainLen = sizes[i];
|
|
251
|
+
const crossLen = c.crossSize !== void 0 ? c.crossSize : align === "stretch" ? crossSize : 0;
|
|
252
|
+
let crossOffset;
|
|
253
|
+
switch (align) {
|
|
254
|
+
case "start":
|
|
255
|
+
crossOffset = 0;
|
|
256
|
+
break;
|
|
257
|
+
case "end":
|
|
258
|
+
crossOffset = crossSize - crossLen;
|
|
259
|
+
break;
|
|
260
|
+
case "center":
|
|
261
|
+
crossOffset = (crossSize - crossLen) / 2;
|
|
262
|
+
break;
|
|
263
|
+
case "stretch":
|
|
264
|
+
crossOffset = 0;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
const x = isRow ? cursor : crossStart + crossOffset;
|
|
268
|
+
const y = isRow ? crossStart + crossOffset : cursor;
|
|
269
|
+
const w = isRow ? mainLen : crossLen;
|
|
270
|
+
const h = isRow ? crossLen : mainLen;
|
|
271
|
+
out[i] = { x, y, width: w, height: h };
|
|
272
|
+
cursor += mainLen + spacing;
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/panel.tsx
|
|
278
|
+
import { View } from "react-native";
|
|
279
|
+
import { jsx } from "react/jsx-runtime";
|
|
280
|
+
function Panel({
|
|
281
|
+
children,
|
|
282
|
+
variant = "surface",
|
|
283
|
+
padding = "md",
|
|
284
|
+
radius = "md",
|
|
285
|
+
style
|
|
286
|
+
}) {
|
|
287
|
+
const theme = useTheme();
|
|
288
|
+
const bg = variant === "elevated" ? theme.colors.surfaceAlt : theme.colors.surface;
|
|
289
|
+
const pad = padding === "none" ? 0 : theme.spacing[padding];
|
|
290
|
+
const r = theme.radii[radius];
|
|
291
|
+
const base = {
|
|
292
|
+
backgroundColor: bg,
|
|
293
|
+
padding: pad,
|
|
294
|
+
borderRadius: r,
|
|
295
|
+
borderWidth: variant === "elevated" ? 1 : 0,
|
|
296
|
+
borderColor: theme.colors.border
|
|
297
|
+
};
|
|
298
|
+
return /* @__PURE__ */ jsx(View, { style: [base, style], children });
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/label.tsx
|
|
302
|
+
import { Text } from "react-native";
|
|
303
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
304
|
+
function Label({
|
|
305
|
+
children,
|
|
306
|
+
variant = "md",
|
|
307
|
+
tone = "default",
|
|
308
|
+
mono = false,
|
|
309
|
+
style
|
|
310
|
+
}) {
|
|
311
|
+
const theme = useTheme();
|
|
312
|
+
const sizeMap = {
|
|
313
|
+
xs: theme.typography.sizeXs,
|
|
314
|
+
sm: theme.typography.sizeSm,
|
|
315
|
+
md: theme.typography.sizeMd,
|
|
316
|
+
lg: theme.typography.sizeLg,
|
|
317
|
+
xl: theme.typography.sizeXl
|
|
318
|
+
};
|
|
319
|
+
const toneMap = {
|
|
320
|
+
default: theme.colors.text,
|
|
321
|
+
muted: theme.colors.textMuted,
|
|
322
|
+
accent: theme.colors.accent,
|
|
323
|
+
danger: theme.colors.danger,
|
|
324
|
+
success: theme.colors.success,
|
|
325
|
+
warning: theme.colors.warning
|
|
326
|
+
};
|
|
327
|
+
const base = {
|
|
328
|
+
color: toneMap[tone],
|
|
329
|
+
fontSize: sizeMap[variant],
|
|
330
|
+
fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ jsx2(Text, { style: [base, style], children });
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/button.tsx
|
|
336
|
+
import { useEffect as useEffect2, useId } from "react";
|
|
337
|
+
import { Pressable, StyleSheet, Text as Text2, View as View2 } from "react-native";
|
|
338
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
339
|
+
function Button({
|
|
340
|
+
label,
|
|
341
|
+
onPress,
|
|
342
|
+
variant = "primary",
|
|
343
|
+
disabled = false,
|
|
344
|
+
tabIndex = 0,
|
|
345
|
+
focusId,
|
|
346
|
+
style
|
|
347
|
+
}) {
|
|
348
|
+
const theme = useTheme();
|
|
349
|
+
const manager = useFocusManager();
|
|
350
|
+
const generated = useId();
|
|
351
|
+
const id = focusId ?? generated;
|
|
352
|
+
useEffect2(() => {
|
|
353
|
+
if (!manager) return;
|
|
354
|
+
return manager.register({
|
|
355
|
+
id,
|
|
356
|
+
tabIndex,
|
|
357
|
+
disabled,
|
|
358
|
+
onActivate: () => {
|
|
359
|
+
if (!disabled) onPress?.();
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}, [manager, id, tabIndex, disabled, onPress]);
|
|
363
|
+
const focused = manager?.getFocused() === id;
|
|
364
|
+
let bg = theme.colors.surface;
|
|
365
|
+
let fg = theme.colors.text;
|
|
366
|
+
let border = theme.colors.border;
|
|
367
|
+
switch (variant) {
|
|
368
|
+
case "primary":
|
|
369
|
+
bg = theme.colors.accent;
|
|
370
|
+
fg = theme.colors.accentText;
|
|
371
|
+
border = theme.colors.accent;
|
|
372
|
+
break;
|
|
373
|
+
case "secondary":
|
|
374
|
+
bg = theme.colors.surfaceAlt;
|
|
375
|
+
fg = theme.colors.text;
|
|
376
|
+
border = theme.colors.border;
|
|
377
|
+
break;
|
|
378
|
+
case "ghost":
|
|
379
|
+
bg = "transparent";
|
|
380
|
+
fg = theme.colors.text;
|
|
381
|
+
border = "transparent";
|
|
382
|
+
break;
|
|
383
|
+
case "danger":
|
|
384
|
+
bg = theme.colors.danger;
|
|
385
|
+
fg = theme.colors.accentText;
|
|
386
|
+
border = theme.colors.danger;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
const container = {
|
|
390
|
+
backgroundColor: bg,
|
|
391
|
+
borderColor: focused ? theme.colors.focus : border,
|
|
392
|
+
borderWidth: focused ? 2 : 1,
|
|
393
|
+
borderRadius: theme.radii.md,
|
|
394
|
+
paddingHorizontal: theme.spacing.md,
|
|
395
|
+
paddingVertical: theme.spacing.sm,
|
|
396
|
+
opacity: disabled ? 0.5 : 1
|
|
397
|
+
};
|
|
398
|
+
return /* @__PURE__ */ jsx3(
|
|
399
|
+
Pressable,
|
|
400
|
+
{
|
|
401
|
+
onPress: () => {
|
|
402
|
+
if (disabled) return;
|
|
403
|
+
manager?.focus(id);
|
|
404
|
+
onPress?.();
|
|
405
|
+
},
|
|
406
|
+
disabled,
|
|
407
|
+
accessibilityRole: "button",
|
|
408
|
+
accessibilityLabel: label,
|
|
409
|
+
accessibilityState: { disabled, selected: focused },
|
|
410
|
+
style: [styles.wrap, container, style],
|
|
411
|
+
children: /* @__PURE__ */ jsx3(View2, { children: /* @__PURE__ */ jsx3(Text2, { style: { color: fg, fontSize: theme.typography.sizeMd, textAlign: "center" }, children: label }) })
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
var styles = StyleSheet.create({
|
|
416
|
+
wrap: {
|
|
417
|
+
alignSelf: "stretch",
|
|
418
|
+
alignItems: "center",
|
|
419
|
+
justifyContent: "center"
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
// src/progress-bar.tsx
|
|
424
|
+
import { View as View3 } from "react-native";
|
|
425
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
426
|
+
function ProgressBar({
|
|
427
|
+
value,
|
|
428
|
+
height = 8,
|
|
429
|
+
trackColor,
|
|
430
|
+
fillColor,
|
|
431
|
+
style
|
|
432
|
+
}) {
|
|
433
|
+
const theme = useTheme();
|
|
434
|
+
const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));
|
|
435
|
+
const r = theme.radii.sm;
|
|
436
|
+
return /* @__PURE__ */ jsx4(
|
|
437
|
+
View3,
|
|
438
|
+
{
|
|
439
|
+
style: [
|
|
440
|
+
{
|
|
441
|
+
height,
|
|
442
|
+
borderRadius: r,
|
|
443
|
+
backgroundColor: trackColor ?? theme.colors.surfaceAlt,
|
|
444
|
+
overflow: "hidden"
|
|
445
|
+
},
|
|
446
|
+
style
|
|
447
|
+
],
|
|
448
|
+
children: /* @__PURE__ */ jsx4(
|
|
449
|
+
View3,
|
|
450
|
+
{
|
|
451
|
+
style: {
|
|
452
|
+
width: `${clamped * 100}%`,
|
|
453
|
+
height: "100%",
|
|
454
|
+
backgroundColor: fillColor ?? theme.colors.accent
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/hud-bar.tsx
|
|
463
|
+
import { View as View4 } from "react-native";
|
|
464
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
465
|
+
function HUDBar({
|
|
466
|
+
label,
|
|
467
|
+
value,
|
|
468
|
+
max,
|
|
469
|
+
kind = "custom",
|
|
470
|
+
showNumbers = true,
|
|
471
|
+
fillColor
|
|
472
|
+
}) {
|
|
473
|
+
const theme = useTheme();
|
|
474
|
+
const ratio = max <= 0 ? 0 : value / max;
|
|
475
|
+
let color = fillColor;
|
|
476
|
+
if (!color) {
|
|
477
|
+
switch (kind) {
|
|
478
|
+
case "hp":
|
|
479
|
+
color = theme.colors.danger;
|
|
480
|
+
break;
|
|
481
|
+
case "mp":
|
|
482
|
+
color = theme.colors.accent;
|
|
483
|
+
break;
|
|
484
|
+
case "xp":
|
|
485
|
+
color = theme.colors.success;
|
|
486
|
+
break;
|
|
487
|
+
default:
|
|
488
|
+
color = theme.colors.accent;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return /* @__PURE__ */ jsxs(View4, { children: [
|
|
492
|
+
/* @__PURE__ */ jsxs(
|
|
493
|
+
View4,
|
|
494
|
+
{
|
|
495
|
+
style: {
|
|
496
|
+
flexDirection: "row",
|
|
497
|
+
justifyContent: "space-between",
|
|
498
|
+
marginBottom: theme.spacing.xs
|
|
499
|
+
},
|
|
500
|
+
children: [
|
|
501
|
+
/* @__PURE__ */ jsx5(Label, { variant: "sm", tone: "muted", children: label }),
|
|
502
|
+
showNumbers && /* @__PURE__ */ jsx5(Label, { variant: "sm", tone: "muted", mono: true, children: `${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}` })
|
|
503
|
+
]
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
/* @__PURE__ */ jsx5(ProgressBar, { value: ratio, fillColor: color })
|
|
507
|
+
] });
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/list.tsx
|
|
511
|
+
import { Fragment } from "react";
|
|
512
|
+
import { View as View5 } from "react-native";
|
|
513
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
514
|
+
function List({ children, gap, direction = "column", style }) {
|
|
515
|
+
const theme = useTheme();
|
|
516
|
+
const g = gap ?? theme.spacing.sm;
|
|
517
|
+
const items = [];
|
|
518
|
+
let i = 0;
|
|
519
|
+
const flat = Array.isArray(children) ? children : [children];
|
|
520
|
+
for (const child of flat) {
|
|
521
|
+
if (child === null || child === void 0 || child === false) continue;
|
|
522
|
+
if (i > 0) {
|
|
523
|
+
const spacerStyle = direction === "row" ? { width: g } : { height: g };
|
|
524
|
+
items.push(/* @__PURE__ */ jsx6(View5, { style: spacerStyle }, `s-${i}`));
|
|
525
|
+
}
|
|
526
|
+
items.push(/* @__PURE__ */ jsx6(Fragment, { children: child }, `i-${i}`));
|
|
527
|
+
i++;
|
|
528
|
+
}
|
|
529
|
+
return /* @__PURE__ */ jsx6(View5, { style: [{ flexDirection: direction }, style], children: items });
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/modal.tsx
|
|
533
|
+
import { Pressable as Pressable2, View as View6 } from "react-native";
|
|
534
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
535
|
+
function Modal({
|
|
536
|
+
visible,
|
|
537
|
+
children,
|
|
538
|
+
onBackdropPress,
|
|
539
|
+
backdropOpacity = 0.6
|
|
540
|
+
}) {
|
|
541
|
+
if (!visible) return null;
|
|
542
|
+
return /* @__PURE__ */ jsxs2(
|
|
543
|
+
View6,
|
|
544
|
+
{
|
|
545
|
+
style: {
|
|
546
|
+
position: "absolute",
|
|
547
|
+
top: 0,
|
|
548
|
+
left: 0,
|
|
549
|
+
right: 0,
|
|
550
|
+
bottom: 0,
|
|
551
|
+
alignItems: "center",
|
|
552
|
+
justifyContent: "center"
|
|
553
|
+
},
|
|
554
|
+
pointerEvents: "box-none",
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ jsx7(
|
|
557
|
+
Pressable2,
|
|
558
|
+
{
|
|
559
|
+
onPress: onBackdropPress,
|
|
560
|
+
style: {
|
|
561
|
+
position: "absolute",
|
|
562
|
+
top: 0,
|
|
563
|
+
left: 0,
|
|
564
|
+
right: 0,
|
|
565
|
+
bottom: 0,
|
|
566
|
+
backgroundColor: `rgba(0,0,0,${backdropOpacity})`
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
/* @__PURE__ */ jsx7(Panel, { variant: "elevated", padding: "lg", style: { minWidth: 240, maxWidth: "80%" }, children })
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// src/dialogue-panel.tsx
|
|
577
|
+
import { Pressable as Pressable3, View as View7 } from "react-native";
|
|
578
|
+
import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
579
|
+
function DialoguePanel({
|
|
580
|
+
speaker,
|
|
581
|
+
text,
|
|
582
|
+
portrait,
|
|
583
|
+
choices,
|
|
584
|
+
onAdvance,
|
|
585
|
+
style
|
|
586
|
+
}) {
|
|
587
|
+
const theme = useTheme();
|
|
588
|
+
const body = /* @__PURE__ */ jsxs3(View7, { style: { flexDirection: "row", alignItems: "flex-start" }, children: [
|
|
589
|
+
portrait !== void 0 ? /* @__PURE__ */ jsx8(View7, { style: { marginRight: theme.spacing.md }, children: portrait }) : null,
|
|
590
|
+
/* @__PURE__ */ jsxs3(View7, { style: { flex: 1 }, children: [
|
|
591
|
+
/* @__PURE__ */ jsx8(Label, { variant: "sm", tone: "accent", style: { marginBottom: theme.spacing.xs }, children: speaker }),
|
|
592
|
+
/* @__PURE__ */ jsx8(Label, { variant: "md", children: text }),
|
|
593
|
+
choices && choices.length > 0 ? /* @__PURE__ */ jsx8(View7, { style: { marginTop: theme.spacing.md }, children: choices.map((c, i) => /* @__PURE__ */ jsx8(View7, { style: { marginTop: i === 0 ? 0 : theme.spacing.xs }, children: /* @__PURE__ */ jsx8(
|
|
594
|
+
Button,
|
|
595
|
+
{
|
|
596
|
+
label: c.label,
|
|
597
|
+
onPress: c.onPress,
|
|
598
|
+
disabled: c.disabled,
|
|
599
|
+
variant: "secondary"
|
|
600
|
+
}
|
|
601
|
+
) }, `${c.label}-${i}`)) }) : null
|
|
602
|
+
] })
|
|
603
|
+
] });
|
|
604
|
+
if (choices && choices.length > 0) {
|
|
605
|
+
return /* @__PURE__ */ jsx8(Panel, { variant: "elevated", padding: "md", style, children: body });
|
|
606
|
+
}
|
|
607
|
+
return /* @__PURE__ */ jsx8(Pressable3, { onPress: onAdvance, children: /* @__PURE__ */ jsx8(Panel, { variant: "elevated", padding: "md", style, children: body }) });
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// src/shop-panel.tsx
|
|
611
|
+
import { View as View8 } from "react-native";
|
|
612
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
613
|
+
function ShopPanel({
|
|
614
|
+
items,
|
|
615
|
+
isEntitled,
|
|
616
|
+
onPurchase,
|
|
617
|
+
ownedLabel = "Owned",
|
|
618
|
+
purchaseLabelFor,
|
|
619
|
+
style
|
|
620
|
+
}) {
|
|
621
|
+
const theme = useTheme();
|
|
622
|
+
return /* @__PURE__ */ jsx9(Panel, { variant: "elevated", padding: "md", style, children: items.map((item, i) => {
|
|
623
|
+
const owned = item.ownedKeys?.some((k) => isEntitled(k)) ?? false;
|
|
624
|
+
return /* @__PURE__ */ jsxs4(
|
|
625
|
+
View8,
|
|
626
|
+
{
|
|
627
|
+
style: {
|
|
628
|
+
marginTop: i === 0 ? 0 : theme.spacing.md,
|
|
629
|
+
paddingTop: i === 0 ? 0 : theme.spacing.md,
|
|
630
|
+
borderTopWidth: i === 0 ? 0 : 1,
|
|
631
|
+
borderTopColor: theme.colors.border
|
|
632
|
+
},
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ jsx9(Label, { variant: "md", children: item.title }),
|
|
635
|
+
item.description !== void 0 ? /* @__PURE__ */ jsx9(Label, { variant: "sm", tone: "muted", style: { marginTop: theme.spacing.xs }, children: item.description }) : null,
|
|
636
|
+
/* @__PURE__ */ jsx9(View8, { style: { marginTop: theme.spacing.sm }, children: owned ? /* @__PURE__ */ jsx9(Button, { label: ownedLabel, variant: "ghost", disabled: true }) : /* @__PURE__ */ jsx9(
|
|
637
|
+
Button,
|
|
638
|
+
{
|
|
639
|
+
label: purchaseLabelFor ? purchaseLabelFor(item) : item.priceDisplay,
|
|
640
|
+
variant: "primary",
|
|
641
|
+
disabled: item.disabled,
|
|
642
|
+
onPress: () => onPurchase(item.productId)
|
|
643
|
+
}
|
|
644
|
+
) })
|
|
645
|
+
]
|
|
646
|
+
},
|
|
647
|
+
item.productId
|
|
648
|
+
);
|
|
649
|
+
}) });
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/main-menu-kit.tsx
|
|
653
|
+
import { View as View9 } from "react-native";
|
|
654
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
655
|
+
function MainMenuKit({
|
|
656
|
+
title,
|
|
657
|
+
subtitle,
|
|
658
|
+
items,
|
|
659
|
+
footer,
|
|
660
|
+
style
|
|
661
|
+
}) {
|
|
662
|
+
const theme = useTheme();
|
|
663
|
+
return /* @__PURE__ */ jsxs5(
|
|
664
|
+
View9,
|
|
665
|
+
{
|
|
666
|
+
style: [
|
|
667
|
+
{
|
|
668
|
+
flex: 1,
|
|
669
|
+
alignItems: "center",
|
|
670
|
+
justifyContent: "center",
|
|
671
|
+
padding: theme.spacing.lg
|
|
672
|
+
},
|
|
673
|
+
style
|
|
674
|
+
],
|
|
675
|
+
children: [
|
|
676
|
+
/* @__PURE__ */ jsx10(Label, { variant: "xl", tone: "accent", style: { marginBottom: theme.spacing.xs }, children: title }),
|
|
677
|
+
subtitle !== void 0 ? /* @__PURE__ */ jsx10(Label, { variant: "sm", tone: "muted", style: { marginBottom: theme.spacing.lg }, children: subtitle }) : /* @__PURE__ */ jsx10(View9, { style: { height: theme.spacing.lg } }),
|
|
678
|
+
/* @__PURE__ */ jsx10(View9, { style: { alignSelf: "stretch", maxWidth: 320, width: "100%" }, children: items.map((item, i) => /* @__PURE__ */ jsx10(View9, { style: { marginTop: i === 0 ? 0 : theme.spacing.sm }, children: /* @__PURE__ */ jsx10(
|
|
679
|
+
Button,
|
|
680
|
+
{
|
|
681
|
+
label: item.label,
|
|
682
|
+
onPress: item.onPress,
|
|
683
|
+
variant: item.variant ?? "primary",
|
|
684
|
+
disabled: item.disabled,
|
|
685
|
+
focusId: item.id,
|
|
686
|
+
tabIndex: i
|
|
687
|
+
}
|
|
688
|
+
) }, item.id)) }),
|
|
689
|
+
footer !== void 0 ? /* @__PURE__ */ jsx10(View9, { style: { marginTop: theme.spacing.lg }, children: footer }) : null
|
|
690
|
+
]
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
export {
|
|
695
|
+
Button,
|
|
696
|
+
DialoguePanel,
|
|
697
|
+
FocusContext,
|
|
698
|
+
FocusProvider,
|
|
699
|
+
HUDBar,
|
|
700
|
+
Label,
|
|
701
|
+
List,
|
|
702
|
+
MainMenuKit,
|
|
703
|
+
Modal,
|
|
704
|
+
Panel,
|
|
705
|
+
ProgressBar,
|
|
706
|
+
ShopPanel,
|
|
707
|
+
ThemeProvider,
|
|
708
|
+
createFocusManager,
|
|
709
|
+
darkTheme,
|
|
710
|
+
lightTheme,
|
|
711
|
+
resolveLayout,
|
|
712
|
+
useFocusManager,
|
|
713
|
+
useTheme
|
|
714
|
+
};
|
|
715
|
+
//# sourceMappingURL=index.mjs.map
|