@flare-engine/ui 0.2.1 → 0.3.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/dist/index.js CHANGED
@@ -1,760 +1,807 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- Button: () => Button,
24
- DialoguePanel: () => DialoguePanel,
25
- FocusContext: () => FocusContext,
26
- FocusProvider: () => FocusProvider,
27
- HUDBar: () => HUDBar,
28
- Label: () => Label,
29
- List: () => List,
30
- MainMenuKit: () => MainMenuKit,
31
- Modal: () => Modal,
32
- Panel: () => Panel,
33
- ProgressBar: () => ProgressBar,
34
- ShopPanel: () => ShopPanel,
35
- ThemeProvider: () => ThemeProvider,
36
- createFocusManager: () => createFocusManager,
37
- darkTheme: () => darkTheme,
38
- lightTheme: () => lightTheme,
39
- resolveLayout: () => resolveLayout,
40
- useFocusManager: () => useFocusManager,
41
- useTheme: () => useTheme
42
- });
43
- module.exports = __toCommonJS(index_exports);
44
-
45
- // src/theme.ts
46
- var import_react = require("react");
47
- var darkTheme = {
48
- name: "dark",
49
- colors: {
50
- bg: "#0b0d10",
51
- surface: "#14181d",
52
- surfaceAlt: "#1d232b",
53
- border: "#2a323c",
54
- text: "#e7ecf1",
55
- textMuted: "#8c96a3",
56
- accent: "#4aa3ff",
57
- accentText: "#0b0d10",
58
- danger: "#ff5c5c",
59
- success: "#5dd39e",
60
- warning: "#f1c40f",
61
- focus: "#ffd166"
62
- },
63
- spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },
64
- typography: {
65
- sizeXs: 10,
66
- sizeSm: 12,
67
- sizeMd: 14,
68
- sizeLg: 18,
69
- sizeXl: 24
70
- },
71
- radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let react = require("react");
3
+ let react_native = require("react-native");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ //#region src/focus-context.ts
6
+ const FocusContext = (0, react.createContext)(null);
7
+ function useFocusManager() {
8
+ const ctx = (0, react.useContext)(FocusContext);
9
+ return ctx ? ctx.manager : null;
10
+ }
11
+ function useFocusedId() {
12
+ const ctx = (0, react.useContext)(FocusContext);
13
+ return ctx ? ctx.focusedId : null;
14
+ }
15
+ //#endregion
16
+ //#region src/theme.ts
17
+ const darkTheme = {
18
+ name: "dark",
19
+ colors: {
20
+ bg: "#0b0d10",
21
+ surface: "#14181d",
22
+ surfaceAlt: "#1d232b",
23
+ border: "#2a323c",
24
+ text: "#e7ecf1",
25
+ textMuted: "#8c96a3",
26
+ accent: "#4aa3ff",
27
+ accentText: "#0b0d10",
28
+ danger: "#ff5c5c",
29
+ success: "#5dd39e",
30
+ warning: "#f1c40f",
31
+ focus: "#ffd166"
32
+ },
33
+ spacing: {
34
+ xs: 4,
35
+ sm: 8,
36
+ md: 12,
37
+ lg: 20,
38
+ xl: 32
39
+ },
40
+ typography: {
41
+ sizeXs: 10,
42
+ sizeSm: 12,
43
+ sizeMd: 14,
44
+ sizeLg: 18,
45
+ sizeXl: 24
46
+ },
47
+ radii: {
48
+ none: 0,
49
+ sm: 4,
50
+ md: 8,
51
+ lg: 16,
52
+ pill: 9999
53
+ }
72
54
  };
73
- var lightTheme = {
74
- name: "light",
75
- colors: {
76
- bg: "#f6f8fa",
77
- surface: "#ffffff",
78
- surfaceAlt: "#eef1f4",
79
- border: "#d4dae0",
80
- text: "#13181d",
81
- textMuted: "#5b6670",
82
- accent: "#0a66d0",
83
- accentText: "#ffffff",
84
- danger: "#d12e2e",
85
- success: "#2f9d69",
86
- warning: "#c79600",
87
- focus: "#ff9500"
88
- },
89
- spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },
90
- typography: {
91
- sizeXs: 10,
92
- sizeSm: 12,
93
- sizeMd: 14,
94
- sizeLg: 18,
95
- sizeXl: 24
96
- },
97
- radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 }
55
+ const lightTheme = {
56
+ name: "light",
57
+ colors: {
58
+ bg: "#f6f8fa",
59
+ surface: "#ffffff",
60
+ surfaceAlt: "#eef1f4",
61
+ border: "#d4dae0",
62
+ text: "#13181d",
63
+ textMuted: "#5b6670",
64
+ accent: "#0a66d0",
65
+ accentText: "#ffffff",
66
+ danger: "#d12e2e",
67
+ success: "#2f9d69",
68
+ warning: "#c79600",
69
+ focus: "#ff9500"
70
+ },
71
+ spacing: {
72
+ xs: 4,
73
+ sm: 8,
74
+ md: 12,
75
+ lg: 20,
76
+ xl: 32
77
+ },
78
+ typography: {
79
+ sizeXs: 10,
80
+ sizeSm: 12,
81
+ sizeMd: 14,
82
+ sizeLg: 18,
83
+ sizeXl: 24
84
+ },
85
+ radii: {
86
+ none: 0,
87
+ sm: 4,
88
+ md: 8,
89
+ lg: 16,
90
+ pill: 9999
91
+ }
98
92
  };
99
- var ThemeContext = (0, import_react.createContext)(darkTheme);
93
+ const ThemeContext = (0, react.createContext)(darkTheme);
100
94
  function ThemeProvider({ theme = darkTheme, children }) {
101
- return (0, import_react.createElement)(ThemeContext.Provider, { value: theme }, children);
95
+ return (0, react.createElement)(ThemeContext.Provider, { value: theme }, children);
102
96
  }
103
97
  function useTheme() {
104
- return (0, import_react.useContext)(ThemeContext);
98
+ return (0, react.useContext)(ThemeContext);
105
99
  }
106
-
107
- // src/focus.ts
108
- function createFocusManager() {
109
- const nodes = /* @__PURE__ */ new Map();
110
- let seqCounter = 0;
111
- let focusedId = null;
112
- const listeners = /* @__PURE__ */ new Set();
113
- function notify() {
114
- for (const l of listeners) l(focusedId);
115
- }
116
- function orderedIds() {
117
- const entries = Array.from(nodes.values()).filter((e) => !e.disabled);
118
- entries.sort((a, b) => {
119
- if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;
120
- return a.seq - b.seq;
121
- });
122
- return entries.map((e) => e.id);
123
- }
124
- function setFocused(next) {
125
- if (next === focusedId) return;
126
- const prev = focusedId;
127
- focusedId = next;
128
- if (prev !== null) nodes.get(prev)?.onBlur?.();
129
- if (next !== null) nodes.get(next)?.onFocus?.();
130
- notify();
131
- }
132
- function move(delta) {
133
- const order = orderedIds();
134
- if (order.length === 0) {
135
- setFocused(null);
136
- return;
137
- }
138
- if (focusedId === null) {
139
- setFocused(delta === 1 ? order[0] ?? null : order[order.length - 1] ?? null);
140
- return;
141
- }
142
- const idx = order.indexOf(focusedId);
143
- if (idx === -1) {
144
- setFocused(order[0] ?? null);
145
- return;
146
- }
147
- const nextIdx = (idx + delta + order.length) % order.length;
148
- setFocused(order[nextIdx] ?? null);
149
- }
150
- return {
151
- register(node) {
152
- const entry = { ...node, seq: seqCounter++ };
153
- nodes.set(node.id, entry);
154
- if (focusedId === null && !node.disabled) {
155
- setFocused(node.id);
156
- }
157
- return () => {
158
- this.unregister(node.id);
159
- };
160
- },
161
- unregister(id) {
162
- if (!nodes.has(id)) return;
163
- nodes.delete(id);
164
- if (focusedId === id) {
165
- const order = orderedIds();
166
- setFocused(order[0] ?? null);
167
- }
168
- },
169
- focus(id) {
170
- const entry = nodes.get(id);
171
- if (!entry || entry.disabled) return;
172
- setFocused(id);
173
- },
174
- blur() {
175
- setFocused(null);
176
- },
177
- next() {
178
- move(1);
179
- },
180
- prev() {
181
- move(-1);
182
- },
183
- activate() {
184
- if (focusedId === null) return;
185
- nodes.get(focusedId)?.onActivate?.();
186
- },
187
- getFocused() {
188
- return focusedId;
189
- },
190
- getOrder() {
191
- return orderedIds();
192
- },
193
- subscribe(listener) {
194
- listeners.add(listener);
195
- return () => {
196
- listeners.delete(listener);
197
- };
198
- }
199
- };
100
+ //#endregion
101
+ //#region src/button.tsx
102
+ function Button({ label, onPress, variant = "primary", disabled = false, tabIndex = 0, focusId, style }) {
103
+ const theme = useTheme();
104
+ const manager = useFocusManager();
105
+ const focusedId = useFocusedId();
106
+ const generated = (0, react.useId)();
107
+ const id = focusId ?? generated;
108
+ (0, react.useEffect)(() => {
109
+ if (!manager) return;
110
+ return manager.register({
111
+ id,
112
+ tabIndex,
113
+ disabled,
114
+ onActivate: () => {
115
+ if (!disabled) onPress?.();
116
+ }
117
+ });
118
+ }, [
119
+ manager,
120
+ id,
121
+ tabIndex,
122
+ disabled,
123
+ onPress
124
+ ]);
125
+ const focused = focusedId === id;
126
+ let bg = theme.colors.surface;
127
+ let fg = theme.colors.text;
128
+ let border = theme.colors.border;
129
+ switch (variant) {
130
+ case "primary":
131
+ bg = theme.colors.accent;
132
+ fg = theme.colors.accentText;
133
+ border = theme.colors.accent;
134
+ break;
135
+ case "secondary":
136
+ bg = theme.colors.surfaceAlt;
137
+ fg = theme.colors.text;
138
+ border = theme.colors.border;
139
+ break;
140
+ case "ghost":
141
+ bg = "transparent";
142
+ fg = theme.colors.text;
143
+ border = "transparent";
144
+ break;
145
+ case "danger":
146
+ bg = theme.colors.danger;
147
+ fg = theme.colors.accentText;
148
+ border = theme.colors.danger;
149
+ break;
150
+ }
151
+ const container = {
152
+ backgroundColor: bg,
153
+ borderColor: focused ? theme.colors.focus : border,
154
+ borderWidth: focused ? 2 : 1,
155
+ borderRadius: theme.radii.md,
156
+ paddingHorizontal: theme.spacing.md,
157
+ paddingVertical: theme.spacing.sm,
158
+ opacity: disabled ? .5 : 1
159
+ };
160
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
161
+ onPress: () => {
162
+ if (disabled) return;
163
+ manager?.focus(id);
164
+ onPress?.();
165
+ },
166
+ disabled,
167
+ accessibilityRole: "button",
168
+ accessibilityLabel: label,
169
+ accessibilityState: {
170
+ disabled,
171
+ selected: focused
172
+ },
173
+ style: [
174
+ styles.wrap,
175
+ container,
176
+ style
177
+ ],
178
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
179
+ style: {
180
+ color: fg,
181
+ fontSize: theme.typography.sizeMd,
182
+ textAlign: "center"
183
+ },
184
+ children: label
185
+ }) })
186
+ });
200
187
  }
201
-
202
- // src/focus-context.ts
203
- var import_react2 = require("react");
204
- var FocusContext = (0, import_react2.createContext)(null);
205
- function useFocusManager() {
206
- return (0, import_react2.useContext)(FocusContext);
188
+ const styles = react_native.StyleSheet.create({ wrap: {
189
+ alignSelf: "stretch",
190
+ alignItems: "center",
191
+ justifyContent: "center"
192
+ } });
193
+ //#endregion
194
+ //#region src/label.tsx
195
+ function Label({ children, variant = "md", tone = "default", mono = false, style }) {
196
+ const theme = useTheme();
197
+ const sizeMap = {
198
+ xs: theme.typography.sizeXs,
199
+ sm: theme.typography.sizeSm,
200
+ md: theme.typography.sizeMd,
201
+ lg: theme.typography.sizeLg,
202
+ xl: theme.typography.sizeXl
203
+ };
204
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
205
+ style: [{
206
+ color: {
207
+ default: theme.colors.text,
208
+ muted: theme.colors.textMuted,
209
+ accent: theme.colors.accent,
210
+ danger: theme.colors.danger,
211
+ success: theme.colors.success,
212
+ warning: theme.colors.warning
213
+ }[tone],
214
+ fontSize: sizeMap[variant],
215
+ fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily
216
+ }, style],
217
+ children
218
+ });
207
219
  }
208
-
209
- // src/focus-provider.tsx
210
- var import_react3 = require("react");
211
- function FocusProvider({ manager, children }) {
212
- const [mgr] = (0, import_react3.useState)(() => manager ?? createFocusManager());
213
- const [, force] = (0, import_react3.useState)(0);
214
- (0, import_react3.useEffect)(() => {
215
- return mgr.subscribe(() => {
216
- force((n) => n + 1);
217
- });
218
- }, [mgr]);
219
- return (0, import_react3.createElement)(FocusContext.Provider, { value: mgr }, children);
220
+ //#endregion
221
+ //#region src/panel.tsx
222
+ function Panel({ children, variant = "surface", padding = "md", radius = "md", style }) {
223
+ const theme = useTheme();
224
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
225
+ style: [{
226
+ backgroundColor: variant === "elevated" ? theme.colors.surfaceAlt : theme.colors.surface,
227
+ padding: padding === "none" ? 0 : theme.spacing[padding],
228
+ borderRadius: theme.radii[radius],
229
+ borderWidth: variant === "elevated" ? 1 : 0,
230
+ borderColor: theme.colors.border
231
+ }, style],
232
+ children
233
+ });
220
234
  }
221
-
222
- // src/layout.ts
223
- var ZERO_PAD = { top: 0, right: 0, bottom: 0, left: 0 };
224
- function resolvePadding(p) {
225
- if (!p) return ZERO_PAD;
226
- return {
227
- top: p.top ?? 0,
228
- right: p.right ?? 0,
229
- bottom: p.bottom ?? 0,
230
- left: p.left ?? 0
231
- };
235
+ //#endregion
236
+ //#region src/dialogue-panel.tsx
237
+ /**
238
+ * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`
239
+ * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your
240
+ * portrait resolver → `portrait` here.
241
+ *
242
+ * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.
243
+ */
244
+ function DialoguePanel({ speaker, text, portrait, choices, onAdvance, style }) {
245
+ const theme = useTheme();
246
+ const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
247
+ style: {
248
+ flexDirection: "row",
249
+ alignItems: "flex-start"
250
+ },
251
+ children: [portrait !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
252
+ style: { marginRight: theme.spacing.md },
253
+ children: portrait
254
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
255
+ style: { flex: 1 },
256
+ children: [
257
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
258
+ variant: "sm",
259
+ tone: "accent",
260
+ style: { marginBottom: theme.spacing.xs },
261
+ children: speaker
262
+ }),
263
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
264
+ variant: "md",
265
+ children: text
266
+ }),
267
+ choices && choices.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
268
+ style: { marginTop: theme.spacing.md },
269
+ children: choices.map((c, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
270
+ style: { marginTop: i === 0 ? 0 : theme.spacing.xs },
271
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
272
+ label: c.label,
273
+ onPress: c.onPress,
274
+ disabled: c.disabled,
275
+ variant: "secondary"
276
+ })
277
+ }, `${c.label}-${i}`))
278
+ }) : null
279
+ ]
280
+ })]
281
+ });
282
+ if (choices && choices.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
283
+ variant: "elevated",
284
+ padding: "md",
285
+ style,
286
+ children: body
287
+ });
288
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
289
+ onPress: onAdvance,
290
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
291
+ variant: "elevated",
292
+ padding: "md",
293
+ style,
294
+ children: body
295
+ })
296
+ });
232
297
  }
233
- function resolveLayout(container, children) {
234
- const n = children.length;
235
- if (n === 0) return [];
236
- const pad = resolvePadding(container.padding);
237
- const gap = container.gap ?? 0;
238
- const isRow = container.direction === "row";
239
- const mainSize = (isRow ? container.width : container.height) - (isRow ? pad.left + pad.right : pad.top + pad.bottom);
240
- const crossSize = (isRow ? container.height : container.width) - (isRow ? pad.top + pad.bottom : pad.left + pad.right);
241
- const mainStart = isRow ? pad.left : pad.top;
242
- const crossStart = isRow ? pad.top : pad.left;
243
- const justify = container.justifyContent ?? "start";
244
- const align = container.alignItems ?? "stretch";
245
- const totalGap = gap * Math.max(0, n - 1);
246
- let totalBasis = 0;
247
- let totalGrow = 0;
248
- for (const c of children) {
249
- totalBasis += c.basis ?? 0;
250
- totalGrow += c.grow ?? 0;
251
- }
252
- const leftover = mainSize - totalBasis - totalGap;
253
- const sizes = new Array(n);
254
- for (let i = 0; i < n; i++) {
255
- const c = children[i];
256
- const base = c.basis ?? 0;
257
- const growShare = totalGrow > 0 ? (c.grow ?? 0) / totalGrow * Math.max(0, leftover) : 0;
258
- sizes[i] = Math.max(0, base + growShare);
259
- }
260
- const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;
261
- const free = Math.max(0, mainSize - used);
262
- let cursor = mainStart;
263
- let spacing = gap;
264
- switch (justify) {
265
- case "start":
266
- break;
267
- case "end":
268
- cursor = mainStart + free;
269
- break;
270
- case "center":
271
- cursor = mainStart + free / 2;
272
- break;
273
- case "space-between":
274
- if (n > 1) spacing = gap + free / (n - 1);
275
- break;
276
- case "space-around":
277
- if (n > 0) {
278
- const s = free / n;
279
- cursor = mainStart + s / 2;
280
- spacing = gap + s;
281
- }
282
- break;
283
- case "space-evenly":
284
- if (n >= 0) {
285
- const s = free / (n + 1);
286
- cursor = mainStart + s;
287
- spacing = gap + s;
288
- }
289
- break;
290
- }
291
- const out = new Array(n);
292
- for (let i = 0; i < n; i++) {
293
- const c = children[i];
294
- const mainLen = sizes[i];
295
- const crossLen = c.crossSize !== void 0 ? c.crossSize : align === "stretch" ? crossSize : 0;
296
- let crossOffset;
297
- switch (align) {
298
- case "start":
299
- crossOffset = 0;
300
- break;
301
- case "end":
302
- crossOffset = crossSize - crossLen;
303
- break;
304
- case "center":
305
- crossOffset = (crossSize - crossLen) / 2;
306
- break;
307
- case "stretch":
308
- crossOffset = 0;
309
- break;
310
- }
311
- const x = isRow ? cursor : crossStart + crossOffset;
312
- const y = isRow ? crossStart + crossOffset : cursor;
313
- const w = isRow ? mainLen : crossLen;
314
- const h = isRow ? crossLen : mainLen;
315
- out[i] = { x, y, width: w, height: h };
316
- cursor += mainLen + spacing;
317
- }
318
- return out;
298
+ //#endregion
299
+ //#region src/focus.ts
300
+ function createFocusManager() {
301
+ const nodes = /* @__PURE__ */ new Map();
302
+ let seqCounter = 0;
303
+ let focusedId = null;
304
+ const listeners = /* @__PURE__ */ new Set();
305
+ function notify() {
306
+ for (const l of listeners) l(focusedId);
307
+ }
308
+ function orderedIds() {
309
+ const entries = Array.from(nodes.values()).filter((e) => !e.disabled);
310
+ entries.sort((a, b) => {
311
+ if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;
312
+ return a.seq - b.seq;
313
+ });
314
+ return entries.map((e) => e.id);
315
+ }
316
+ function setFocused(next) {
317
+ if (next === focusedId) return;
318
+ const prev = focusedId;
319
+ focusedId = next;
320
+ if (prev !== null) nodes.get(prev)?.onBlur?.();
321
+ if (next !== null) nodes.get(next)?.onFocus?.();
322
+ notify();
323
+ }
324
+ function move(delta) {
325
+ const order = orderedIds();
326
+ if (order.length === 0) {
327
+ setFocused(null);
328
+ return;
329
+ }
330
+ if (focusedId === null) {
331
+ setFocused(delta === 1 ? order[0] ?? null : order[order.length - 1] ?? null);
332
+ return;
333
+ }
334
+ const idx = order.indexOf(focusedId);
335
+ if (idx === -1) {
336
+ setFocused(order[0] ?? null);
337
+ return;
338
+ }
339
+ setFocused(order[(idx + delta + order.length) % order.length] ?? null);
340
+ }
341
+ return {
342
+ register(node) {
343
+ const entry = {
344
+ ...node,
345
+ seq: seqCounter++
346
+ };
347
+ nodes.set(node.id, entry);
348
+ return () => {
349
+ this.unregister(node.id);
350
+ };
351
+ },
352
+ unregister(id) {
353
+ if (!nodes.has(id)) return;
354
+ nodes.delete(id);
355
+ if (focusedId === id) setFocused(orderedIds()[0] ?? null);
356
+ },
357
+ focus(id) {
358
+ const entry = nodes.get(id);
359
+ if (!entry || entry.disabled) return;
360
+ setFocused(id);
361
+ },
362
+ focusFirst() {
363
+ setFocused(orderedIds()[0] ?? null);
364
+ },
365
+ blur() {
366
+ setFocused(null);
367
+ },
368
+ next() {
369
+ move(1);
370
+ },
371
+ prev() {
372
+ move(-1);
373
+ },
374
+ activate() {
375
+ if (focusedId === null) return;
376
+ nodes.get(focusedId)?.onActivate?.();
377
+ },
378
+ getFocused() {
379
+ return focusedId;
380
+ },
381
+ getOrder() {
382
+ return orderedIds();
383
+ },
384
+ subscribe(listener) {
385
+ listeners.add(listener);
386
+ return () => {
387
+ listeners.delete(listener);
388
+ };
389
+ }
390
+ };
319
391
  }
320
-
321
- // src/panel.tsx
322
- var import_react_native = require("react-native");
323
- var import_jsx_runtime = require("react/jsx-runtime");
324
- function Panel({
325
- children,
326
- variant = "surface",
327
- padding = "md",
328
- radius = "md",
329
- style
330
- }) {
331
- const theme = useTheme();
332
- const bg = variant === "elevated" ? theme.colors.surfaceAlt : theme.colors.surface;
333
- const pad = padding === "none" ? 0 : theme.spacing[padding];
334
- const r = theme.radii[radius];
335
- const base = {
336
- backgroundColor: bg,
337
- padding: pad,
338
- borderRadius: r,
339
- borderWidth: variant === "elevated" ? 1 : 0,
340
- borderColor: theme.colors.border
341
- };
342
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: [base, style], children });
392
+ //#endregion
393
+ //#region src/focus-keyboard-driver.ts
394
+ const DEFAULT_NEXT = [
395
+ "ArrowDown",
396
+ "ArrowRight",
397
+ "Tab"
398
+ ];
399
+ const DEFAULT_PREV = ["ArrowUp", "ArrowLeft"];
400
+ const DEFAULT_ACTIVATE = ["Enter", "Space"];
401
+ function createFocusKeyboardDriver(manager, keys, options) {
402
+ const nextCodes = options?.next ?? DEFAULT_NEXT;
403
+ const prevCodes = options?.prev ?? DEFAULT_PREV;
404
+ const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;
405
+ return { update() {
406
+ for (let i = 0; i < nextCodes.length; i++) if (keys.wasPressed(nextCodes[i])) {
407
+ manager.next();
408
+ return;
409
+ }
410
+ for (let i = 0; i < prevCodes.length; i++) if (keys.wasPressed(prevCodes[i])) {
411
+ manager.prev();
412
+ return;
413
+ }
414
+ for (let i = 0; i < activateCodes.length; i++) if (keys.wasPressed(activateCodes[i])) {
415
+ manager.activate();
416
+ return;
417
+ }
418
+ } };
343
419
  }
344
-
345
- // src/label.tsx
346
- var import_react_native2 = require("react-native");
347
- var import_jsx_runtime2 = require("react/jsx-runtime");
348
- function Label({
349
- children,
350
- variant = "md",
351
- tone = "default",
352
- mono = false,
353
- style
354
- }) {
355
- const theme = useTheme();
356
- const sizeMap = {
357
- xs: theme.typography.sizeXs,
358
- sm: theme.typography.sizeSm,
359
- md: theme.typography.sizeMd,
360
- lg: theme.typography.sizeLg,
361
- xl: theme.typography.sizeXl
362
- };
363
- const toneMap = {
364
- default: theme.colors.text,
365
- muted: theme.colors.textMuted,
366
- accent: theme.colors.accent,
367
- danger: theme.colors.danger,
368
- success: theme.colors.success,
369
- warning: theme.colors.warning
370
- };
371
- const base = {
372
- color: toneMap[tone],
373
- fontSize: sizeMap[variant],
374
- fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily
375
- };
376
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style: [base, style], children });
420
+ //#endregion
421
+ //#region src/focus-provider.tsx
422
+ /**
423
+ * Instantiates a FocusManager (or uses the one provided) and publishes
424
+ * { manager, focusedId } as context state so consumers re-render on focus
425
+ * moves.
426
+ */
427
+ function FocusProvider({ manager, autoFocus, children }) {
428
+ const [mgr] = (0, react.useState)(() => manager ?? createFocusManager());
429
+ const [focusedId, setFocusedId] = (0, react.useState)(() => mgr.getFocused());
430
+ (0, react.useEffect)(() => {
431
+ setFocusedId(mgr.getFocused());
432
+ return mgr.subscribe((id) => {
433
+ setFocusedId(id);
434
+ });
435
+ }, [mgr]);
436
+ (0, react.useEffect)(() => {
437
+ if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();
438
+ }, [autoFocus, mgr]);
439
+ const value = (0, react.useMemo)(() => ({
440
+ manager: mgr,
441
+ focusedId
442
+ }), [mgr, focusedId]);
443
+ return (0, react.createElement)(FocusContext.Provider, { value }, children);
377
444
  }
378
-
379
- // src/button.tsx
380
- var import_react4 = require("react");
381
- var import_react_native3 = require("react-native");
382
- var import_jsx_runtime3 = require("react/jsx-runtime");
383
- function Button({
384
- label,
385
- onPress,
386
- variant = "primary",
387
- disabled = false,
388
- tabIndex = 0,
389
- focusId,
390
- style
391
- }) {
392
- const theme = useTheme();
393
- const manager = useFocusManager();
394
- const generated = (0, import_react4.useId)();
395
- const id = focusId ?? generated;
396
- (0, import_react4.useEffect)(() => {
397
- if (!manager) return;
398
- return manager.register({
399
- id,
400
- tabIndex,
401
- disabled,
402
- onActivate: () => {
403
- if (!disabled) onPress?.();
404
- }
405
- });
406
- }, [manager, id, tabIndex, disabled, onPress]);
407
- const focused = manager?.getFocused() === id;
408
- let bg = theme.colors.surface;
409
- let fg = theme.colors.text;
410
- let border = theme.colors.border;
411
- switch (variant) {
412
- case "primary":
413
- bg = theme.colors.accent;
414
- fg = theme.colors.accentText;
415
- border = theme.colors.accent;
416
- break;
417
- case "secondary":
418
- bg = theme.colors.surfaceAlt;
419
- fg = theme.colors.text;
420
- border = theme.colors.border;
421
- break;
422
- case "ghost":
423
- bg = "transparent";
424
- fg = theme.colors.text;
425
- border = "transparent";
426
- break;
427
- case "danger":
428
- bg = theme.colors.danger;
429
- fg = theme.colors.accentText;
430
- border = theme.colors.danger;
431
- break;
432
- }
433
- const container = {
434
- backgroundColor: bg,
435
- borderColor: focused ? theme.colors.focus : border,
436
- borderWidth: focused ? 2 : 1,
437
- borderRadius: theme.radii.md,
438
- paddingHorizontal: theme.spacing.md,
439
- paddingVertical: theme.spacing.sm,
440
- opacity: disabled ? 0.5 : 1
441
- };
442
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
443
- import_react_native3.Pressable,
444
- {
445
- onPress: () => {
446
- if (disabled) return;
447
- manager?.focus(id);
448
- onPress?.();
449
- },
450
- disabled,
451
- accessibilityRole: "button",
452
- accessibilityLabel: label,
453
- accessibilityState: { disabled, selected: focused },
454
- style: [styles.wrap, container, style],
455
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { style: { color: fg, fontSize: theme.typography.sizeMd, textAlign: "center" }, children: label }) })
456
- }
457
- );
445
+ //#endregion
446
+ //#region src/progress-bar.tsx
447
+ function ProgressBar({ value, height = 8, trackColor, fillColor, style }) {
448
+ const theme = useTheme();
449
+ const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));
450
+ const r = theme.radii.sm;
451
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
452
+ style: [{
453
+ height,
454
+ borderRadius: r,
455
+ backgroundColor: trackColor ?? theme.colors.surfaceAlt,
456
+ overflow: "hidden"
457
+ }, style],
458
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: {
459
+ width: `${clamped * 100}%`,
460
+ height: "100%",
461
+ backgroundColor: fillColor ?? theme.colors.accent
462
+ } })
463
+ });
458
464
  }
459
- var styles = import_react_native3.StyleSheet.create({
460
- wrap: {
461
- alignSelf: "stretch",
462
- alignItems: "center",
463
- justifyContent: "center"
464
- }
465
- });
466
-
467
- // src/progress-bar.tsx
468
- var import_react_native4 = require("react-native");
469
- var import_jsx_runtime4 = require("react/jsx-runtime");
470
- function ProgressBar({
471
- value,
472
- height = 8,
473
- trackColor,
474
- fillColor,
475
- style
476
- }) {
477
- const theme = useTheme();
478
- const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));
479
- const r = theme.radii.sm;
480
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
481
- import_react_native4.View,
482
- {
483
- style: [
484
- {
485
- height,
486
- borderRadius: r,
487
- backgroundColor: trackColor ?? theme.colors.surfaceAlt,
488
- overflow: "hidden"
489
- },
490
- style
491
- ],
492
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
493
- import_react_native4.View,
494
- {
495
- style: {
496
- width: `${clamped * 100}%`,
497
- height: "100%",
498
- backgroundColor: fillColor ?? theme.colors.accent
499
- }
500
- }
501
- )
502
- }
503
- );
465
+ //#endregion
466
+ //#region src/hud-bar.tsx
467
+ function HUDBar({ label, value, max, kind = "custom", showNumbers = true, fillColor }) {
468
+ const theme = useTheme();
469
+ const ratio = max <= 0 ? 0 : value / max;
470
+ let color = fillColor;
471
+ if (!color) switch (kind) {
472
+ case "hp":
473
+ color = theme.colors.danger;
474
+ break;
475
+ case "mp":
476
+ color = theme.colors.accent;
477
+ break;
478
+ case "xp":
479
+ color = theme.colors.success;
480
+ break;
481
+ default: color = theme.colors.accent;
482
+ }
483
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
484
+ style: {
485
+ flexDirection: "row",
486
+ justifyContent: "space-between",
487
+ marginBottom: theme.spacing.xs
488
+ },
489
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
490
+ variant: "sm",
491
+ tone: "muted",
492
+ children: label
493
+ }), showNumbers && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
494
+ variant: "sm",
495
+ tone: "muted",
496
+ mono: true,
497
+ children: `${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`
498
+ })]
499
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProgressBar, {
500
+ value: ratio,
501
+ fillColor: color
502
+ })] });
504
503
  }
505
-
506
- // src/hud-bar.tsx
507
- var import_react_native5 = require("react-native");
508
- var import_jsx_runtime5 = require("react/jsx-runtime");
509
- function HUDBar({
510
- label,
511
- value,
512
- max,
513
- kind = "custom",
514
- showNumbers = true,
515
- fillColor
516
- }) {
517
- const theme = useTheme();
518
- const ratio = max <= 0 ? 0 : value / max;
519
- let color = fillColor;
520
- if (!color) {
521
- switch (kind) {
522
- case "hp":
523
- color = theme.colors.danger;
524
- break;
525
- case "mp":
526
- color = theme.colors.accent;
527
- break;
528
- case "xp":
529
- color = theme.colors.success;
530
- break;
531
- default:
532
- color = theme.colors.accent;
533
- }
534
- }
535
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native5.View, { children: [
536
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
537
- import_react_native5.View,
538
- {
539
- style: {
540
- flexDirection: "row",
541
- justifyContent: "space-between",
542
- marginBottom: theme.spacing.xs
543
- },
544
- children: [
545
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { variant: "sm", tone: "muted", children: label }),
546
- showNumbers && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { variant: "sm", tone: "muted", mono: true, children: `${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}` })
547
- ]
548
- }
549
- ),
550
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProgressBar, { value: ratio, fillColor: color })
551
- ] });
504
+ //#endregion
505
+ //#region src/layout.ts
506
+ const ZERO_PAD = {
507
+ top: 0,
508
+ right: 0,
509
+ bottom: 0,
510
+ left: 0
511
+ };
512
+ function resolvePadding(p) {
513
+ if (!p) return ZERO_PAD;
514
+ return {
515
+ top: p.top ?? 0,
516
+ right: p.right ?? 0,
517
+ bottom: p.bottom ?? 0,
518
+ left: p.left ?? 0
519
+ };
552
520
  }
553
-
554
- // src/list.tsx
555
- var import_react5 = require("react");
556
- var import_react_native6 = require("react-native");
557
- var import_jsx_runtime6 = require("react/jsx-runtime");
521
+ function resolveLayout(container, children) {
522
+ const n = children.length;
523
+ if (n === 0) return [];
524
+ const pad = resolvePadding(container.padding);
525
+ const gap = container.gap ?? 0;
526
+ const isRow = container.direction === "row";
527
+ const mainSize = (isRow ? container.width : container.height) - (isRow ? pad.left + pad.right : pad.top + pad.bottom);
528
+ const crossSize = (isRow ? container.height : container.width) - (isRow ? pad.top + pad.bottom : pad.left + pad.right);
529
+ const mainStart = isRow ? pad.left : pad.top;
530
+ const crossStart = isRow ? pad.top : pad.left;
531
+ const justify = container.justifyContent ?? "start";
532
+ const align = container.alignItems ?? "stretch";
533
+ const totalGap = gap * Math.max(0, n - 1);
534
+ let totalBasis = 0;
535
+ let totalGrow = 0;
536
+ for (const c of children) {
537
+ totalBasis += c.basis ?? 0;
538
+ totalGrow += c.grow ?? 0;
539
+ }
540
+ const leftover = mainSize - totalBasis - totalGap;
541
+ const sizes = new Array(n);
542
+ for (let i = 0; i < n; i++) {
543
+ const c = children[i];
544
+ const base = c.basis ?? 0;
545
+ const growShare = totalGrow > 0 ? (c.grow ?? 0) / totalGrow * Math.max(0, leftover) : 0;
546
+ sizes[i] = Math.max(0, base + growShare);
547
+ }
548
+ const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;
549
+ const free = Math.max(0, mainSize - used);
550
+ let cursor = mainStart;
551
+ let spacing = gap;
552
+ switch (justify) {
553
+ case "start": break;
554
+ case "end":
555
+ cursor = mainStart + free;
556
+ break;
557
+ case "center":
558
+ cursor = mainStart + free / 2;
559
+ break;
560
+ case "space-between":
561
+ if (n > 1) spacing = gap + free / (n - 1);
562
+ break;
563
+ case "space-around":
564
+ if (n > 0) {
565
+ const s = free / n;
566
+ cursor = mainStart + s / 2;
567
+ spacing = gap + s;
568
+ }
569
+ break;
570
+ case "space-evenly":
571
+ if (n >= 0) {
572
+ const s = free / (n + 1);
573
+ cursor = mainStart + s;
574
+ spacing = gap + s;
575
+ }
576
+ break;
577
+ }
578
+ const out = new Array(n);
579
+ for (let i = 0; i < n; i++) {
580
+ const c = children[i];
581
+ const mainLen = sizes[i];
582
+ const crossLen = c.crossSize !== void 0 ? c.crossSize : align === "stretch" ? crossSize : 0;
583
+ let crossOffset;
584
+ switch (align) {
585
+ case "start":
586
+ crossOffset = 0;
587
+ break;
588
+ case "end":
589
+ crossOffset = crossSize - crossLen;
590
+ break;
591
+ case "center":
592
+ crossOffset = (crossSize - crossLen) / 2;
593
+ break;
594
+ case "stretch":
595
+ crossOffset = 0;
596
+ break;
597
+ }
598
+ out[i] = {
599
+ x: isRow ? cursor : crossStart + crossOffset,
600
+ y: isRow ? crossStart + crossOffset : cursor,
601
+ width: isRow ? mainLen : crossLen,
602
+ height: isRow ? crossLen : mainLen
603
+ };
604
+ cursor += mainLen + spacing;
605
+ }
606
+ return out;
607
+ }
608
+ //#endregion
609
+ //#region src/list.tsx
610
+ /**
611
+ * Vertical (or horizontal) stack with consistent gap. Thin container; the
612
+ * focus manager handles navigation between interactive children.
613
+ */
558
614
  function List({ children, gap, direction = "column", style }) {
559
- const theme = useTheme();
560
- const g = gap ?? theme.spacing.sm;
561
- const items = [];
562
- let i = 0;
563
- const flat = Array.isArray(children) ? children : [children];
564
- for (const child of flat) {
565
- if (child === null || child === void 0 || child === false) continue;
566
- if (i > 0) {
567
- const spacerStyle = direction === "row" ? { width: g } : { height: g };
568
- items.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.View, { style: spacerStyle }, `s-${i}`));
569
- }
570
- items.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react5.Fragment, { children: child }, `i-${i}`));
571
- i++;
572
- }
573
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.View, { style: [{ flexDirection: direction }, style], children: items });
615
+ const theme = useTheme();
616
+ const g = gap ?? theme.spacing.sm;
617
+ const items = [];
618
+ let i = 0;
619
+ const flat = Array.isArray(children) ? children : [children];
620
+ for (const child of flat) {
621
+ if (child === null || child === void 0 || child === false) continue;
622
+ if (i > 0) {
623
+ const spacerStyle = direction === "row" ? { width: g } : { height: g };
624
+ items.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: spacerStyle }, `s-${i}`));
625
+ }
626
+ items.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: child }, `i-${i}`));
627
+ i++;
628
+ }
629
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
630
+ style: [{ flexDirection: direction }, style],
631
+ children: items
632
+ });
574
633
  }
575
-
576
- // src/modal.tsx
577
- var import_react_native7 = require("react-native");
578
- var import_jsx_runtime7 = require("react/jsx-runtime");
579
- function Modal({
580
- visible,
581
- children,
582
- onBackdropPress,
583
- backdropOpacity = 0.6
584
- }) {
585
- if (!visible) return null;
586
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
587
- import_react_native7.View,
588
- {
589
- style: {
590
- position: "absolute",
591
- top: 0,
592
- left: 0,
593
- right: 0,
594
- bottom: 0,
595
- alignItems: "center",
596
- justifyContent: "center"
597
- },
598
- pointerEvents: "box-none",
599
- children: [
600
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
601
- import_react_native7.Pressable,
602
- {
603
- onPress: onBackdropPress,
604
- style: {
605
- position: "absolute",
606
- top: 0,
607
- left: 0,
608
- right: 0,
609
- bottom: 0,
610
- backgroundColor: `rgba(0,0,0,${backdropOpacity})`
611
- }
612
- }
613
- ),
614
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Panel, { variant: "elevated", padding: "lg", style: { minWidth: 240, maxWidth: "80%" }, children })
615
- ]
616
- }
617
- );
634
+ //#endregion
635
+ //#region src/main-menu-kit.tsx
636
+ /**
637
+ * Title-screen kit: headline, optional subtitle, vertical button list,
638
+ * optional footer slot. All strings are caller-supplied (localized upstream).
639
+ *
640
+ * Save-slot / settings / credits panels are built on top of this kit by the
641
+ * consumer; the kit itself is a pure title-menu primitive.
642
+ */
643
+ function MainMenuKit({ title, subtitle, items, footer, style }) {
644
+ const theme = useTheme();
645
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
646
+ style: [{
647
+ flex: 1,
648
+ alignItems: "center",
649
+ justifyContent: "center",
650
+ padding: theme.spacing.lg
651
+ }, style],
652
+ children: [
653
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
654
+ variant: "xl",
655
+ tone: "accent",
656
+ style: { marginBottom: theme.spacing.xs },
657
+ children: title
658
+ }),
659
+ subtitle !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
660
+ variant: "sm",
661
+ tone: "muted",
662
+ style: { marginBottom: theme.spacing.lg },
663
+ children: subtitle
664
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: { height: theme.spacing.lg } }),
665
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
666
+ style: {
667
+ alignSelf: "stretch",
668
+ maxWidth: 320,
669
+ width: "100%"
670
+ },
671
+ children: items.map((item, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
672
+ style: { marginTop: i === 0 ? 0 : theme.spacing.sm },
673
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
674
+ label: item.label,
675
+ onPress: item.onPress,
676
+ variant: item.variant ?? "primary",
677
+ disabled: item.disabled,
678
+ focusId: item.id,
679
+ tabIndex: i
680
+ })
681
+ }, item.id))
682
+ }),
683
+ footer !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
684
+ style: { marginTop: theme.spacing.lg },
685
+ children: footer
686
+ }) : null
687
+ ]
688
+ });
618
689
  }
619
-
620
- // src/dialogue-panel.tsx
621
- var import_react_native8 = require("react-native");
622
- var import_jsx_runtime8 = require("react/jsx-runtime");
623
- function DialoguePanel({
624
- speaker,
625
- text,
626
- portrait,
627
- choices,
628
- onAdvance,
629
- style
630
- }) {
631
- const theme = useTheme();
632
- const body = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native8.View, { style: { flexDirection: "row", alignItems: "flex-start" }, children: [
633
- portrait !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native8.View, { style: { marginRight: theme.spacing.md }, children: portrait }) : null,
634
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native8.View, { style: { flex: 1 }, children: [
635
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { variant: "sm", tone: "accent", style: { marginBottom: theme.spacing.xs }, children: speaker }),
636
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { variant: "md", children: text }),
637
- choices && choices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native8.View, { style: { marginTop: theme.spacing.md }, children: choices.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native8.View, { style: { marginTop: i === 0 ? 0 : theme.spacing.xs }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
638
- Button,
639
- {
640
- label: c.label,
641
- onPress: c.onPress,
642
- disabled: c.disabled,
643
- variant: "secondary"
644
- }
645
- ) }, `${c.label}-${i}`)) }) : null
646
- ] })
647
- ] });
648
- if (choices && choices.length > 0) {
649
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Panel, { variant: "elevated", padding: "md", style, children: body });
650
- }
651
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native8.Pressable, { onPress: onAdvance, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Panel, { variant: "elevated", padding: "md", style, children: body }) });
690
+ //#endregion
691
+ //#region src/modal.tsx
692
+ /**
693
+ * Overlay modal that renders a centered `Panel` with its children. Parent is
694
+ * responsible for controlling visibility and (if desired) focus trapping via
695
+ * the shared FocusManager.
696
+ */
697
+ function Modal({ visible, children, onBackdropPress, backdropOpacity = .6 }) {
698
+ if (!visible) return null;
699
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
700
+ style: {
701
+ position: "absolute",
702
+ top: 0,
703
+ left: 0,
704
+ right: 0,
705
+ bottom: 0,
706
+ alignItems: "center",
707
+ justifyContent: "center"
708
+ },
709
+ pointerEvents: "box-none",
710
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
711
+ onPress: onBackdropPress,
712
+ style: {
713
+ position: "absolute",
714
+ top: 0,
715
+ left: 0,
716
+ right: 0,
717
+ bottom: 0,
718
+ backgroundColor: `rgba(0,0,0,${backdropOpacity})`
719
+ }
720
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
721
+ variant: "elevated",
722
+ padding: "lg",
723
+ style: {
724
+ minWidth: 240,
725
+ maxWidth: "80%"
726
+ },
727
+ children
728
+ })]
729
+ });
652
730
  }
653
-
654
- // src/shop-panel.tsx
655
- var import_react_native9 = require("react-native");
656
- var import_jsx_runtime9 = require("react/jsx-runtime");
657
- function ShopPanel({
658
- items,
659
- isEntitled,
660
- onPurchase,
661
- ownedLabel = "Owned",
662
- purchaseLabelFor,
663
- style
664
- }) {
665
- const theme = useTheme();
666
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Panel, { variant: "elevated", padding: "md", style, children: items.map((item, i) => {
667
- const owned = item.ownedKeys?.some((k) => isEntitled(k)) ?? false;
668
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
669
- import_react_native9.View,
670
- {
671
- style: {
672
- marginTop: i === 0 ? 0 : theme.spacing.md,
673
- paddingTop: i === 0 ? 0 : theme.spacing.md,
674
- borderTopWidth: i === 0 ? 0 : 1,
675
- borderTopColor: theme.colors.border
676
- },
677
- children: [
678
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { variant: "md", children: item.title }),
679
- item.description !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { variant: "sm", tone: "muted", style: { marginTop: theme.spacing.xs }, children: item.description }) : null,
680
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native9.View, { style: { marginTop: theme.spacing.sm }, children: owned ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { label: ownedLabel, variant: "ghost", disabled: true }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
681
- Button,
682
- {
683
- label: purchaseLabelFor ? purchaseLabelFor(item) : item.priceDisplay,
684
- variant: "primary",
685
- disabled: item.disabled,
686
- onPress: () => onPurchase(item.productId)
687
- }
688
- ) })
689
- ]
690
- },
691
- item.productId
692
- );
693
- }) });
731
+ //#endregion
732
+ //#region src/shop-panel.tsx
733
+ /**
734
+ * List-style shop panel. Caller builds the `items` array by joining a
735
+ * `ProductCatalog` with the `Product[]` returned by `IAPProvider.getProducts`.
736
+ *
737
+ * Price strings and ownership copy are caller-provided so the UI kit stays
738
+ * localization-free.
739
+ */
740
+ function ShopPanel({ items, isEntitled, onPurchase, ownedLabel = "Owned", purchaseLabelFor, style }) {
741
+ const theme = useTheme();
742
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
743
+ variant: "elevated",
744
+ padding: "md",
745
+ style,
746
+ children: items.map((item, i) => {
747
+ const owned = item.ownedKeys?.some((k) => isEntitled(k)) ?? false;
748
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
749
+ style: {
750
+ marginTop: i === 0 ? 0 : theme.spacing.md,
751
+ paddingTop: i === 0 ? 0 : theme.spacing.md,
752
+ borderTopWidth: i === 0 ? 0 : 1,
753
+ borderTopColor: theme.colors.border
754
+ },
755
+ children: [
756
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
757
+ variant: "md",
758
+ children: item.title
759
+ }),
760
+ item.description !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
761
+ variant: "sm",
762
+ tone: "muted",
763
+ style: { marginTop: theme.spacing.xs },
764
+ children: item.description
765
+ }) : null,
766
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
767
+ style: { marginTop: theme.spacing.sm },
768
+ children: owned ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
769
+ label: ownedLabel,
770
+ variant: "ghost",
771
+ disabled: true
772
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
773
+ label: purchaseLabelFor ? purchaseLabelFor(item) : item.priceDisplay,
774
+ variant: "primary",
775
+ disabled: item.disabled,
776
+ onPress: () => onPurchase(item.productId)
777
+ })
778
+ })
779
+ ]
780
+ }, item.productId);
781
+ })
782
+ });
694
783
  }
784
+ //#endregion
785
+ exports.Button = Button;
786
+ exports.DialoguePanel = DialoguePanel;
787
+ exports.FocusContext = FocusContext;
788
+ exports.FocusProvider = FocusProvider;
789
+ exports.HUDBar = HUDBar;
790
+ exports.Label = Label;
791
+ exports.List = List;
792
+ exports.MainMenuKit = MainMenuKit;
793
+ exports.Modal = Modal;
794
+ exports.Panel = Panel;
795
+ exports.ProgressBar = ProgressBar;
796
+ exports.ShopPanel = ShopPanel;
797
+ exports.ThemeProvider = ThemeProvider;
798
+ exports.createFocusKeyboardDriver = createFocusKeyboardDriver;
799
+ exports.createFocusManager = createFocusManager;
800
+ exports.darkTheme = darkTheme;
801
+ exports.lightTheme = lightTheme;
802
+ exports.resolveLayout = resolveLayout;
803
+ exports.useFocusManager = useFocusManager;
804
+ exports.useFocusedId = useFocusedId;
805
+ exports.useTheme = useTheme;
695
806
 
696
- // src/main-menu-kit.tsx
697
- var import_react_native10 = require("react-native");
698
- var import_jsx_runtime10 = require("react/jsx-runtime");
699
- function MainMenuKit({
700
- title,
701
- subtitle,
702
- items,
703
- footer,
704
- style
705
- }) {
706
- const theme = useTheme();
707
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
708
- import_react_native10.View,
709
- {
710
- style: [
711
- {
712
- flex: 1,
713
- alignItems: "center",
714
- justifyContent: "center",
715
- padding: theme.spacing.lg
716
- },
717
- style
718
- ],
719
- children: [
720
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Label, { variant: "xl", tone: "accent", style: { marginBottom: theme.spacing.xs }, children: title }),
721
- subtitle !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Label, { variant: "sm", tone: "muted", style: { marginBottom: theme.spacing.lg }, children: subtitle }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: { height: theme.spacing.lg } }),
722
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: { alignSelf: "stretch", maxWidth: 320, width: "100%" }, children: items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: { marginTop: i === 0 ? 0 : theme.spacing.sm }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
723
- Button,
724
- {
725
- label: item.label,
726
- onPress: item.onPress,
727
- variant: item.variant ?? "primary",
728
- disabled: item.disabled,
729
- focusId: item.id,
730
- tabIndex: i
731
- }
732
- ) }, item.id)) }),
733
- footer !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, { style: { marginTop: theme.spacing.lg }, children: footer }) : null
734
- ]
735
- }
736
- );
737
- }
738
- // Annotate the CommonJS export names for ESM import in node:
739
- 0 && (module.exports = {
740
- Button,
741
- DialoguePanel,
742
- FocusContext,
743
- FocusProvider,
744
- HUDBar,
745
- Label,
746
- List,
747
- MainMenuKit,
748
- Modal,
749
- Panel,
750
- ProgressBar,
751
- ShopPanel,
752
- ThemeProvider,
753
- createFocusManager,
754
- darkTheme,
755
- lightTheme,
756
- resolveLayout,
757
- useFocusManager,
758
- useTheme
759
- });
760
807
  //# sourceMappingURL=index.js.map