@flare-engine/ui 0.2.1 → 0.3.1

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,811 @@
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, numberOfLines, ellipsizeMode, adjustsFontSizeToFit, minimumFontScale }) {
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
+ numberOfLines,
206
+ ellipsizeMode,
207
+ adjustsFontSizeToFit,
208
+ minimumFontScale,
209
+ style: [{
210
+ color: {
211
+ default: theme.colors.text,
212
+ muted: theme.colors.textMuted,
213
+ accent: theme.colors.accent,
214
+ danger: theme.colors.danger,
215
+ success: theme.colors.success,
216
+ warning: theme.colors.warning
217
+ }[tone],
218
+ fontSize: sizeMap[variant],
219
+ fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily
220
+ }, style],
221
+ children
222
+ });
207
223
  }
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);
224
+ //#endregion
225
+ //#region src/panel.tsx
226
+ function Panel({ children, variant = "surface", padding = "md", radius = "md", style }) {
227
+ const theme = useTheme();
228
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
229
+ style: [{
230
+ backgroundColor: variant === "elevated" ? theme.colors.surfaceAlt : theme.colors.surface,
231
+ padding: padding === "none" ? 0 : theme.spacing[padding],
232
+ borderRadius: theme.radii[radius],
233
+ borderWidth: variant === "elevated" ? 1 : 0,
234
+ borderColor: theme.colors.border
235
+ }, style],
236
+ children
237
+ });
220
238
  }
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
- };
239
+ //#endregion
240
+ //#region src/dialogue-panel.tsx
241
+ /**
242
+ * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`
243
+ * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your
244
+ * portrait resolver → `portrait` here.
245
+ *
246
+ * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.
247
+ */
248
+ function DialoguePanel({ speaker, text, portrait, choices, onAdvance, style }) {
249
+ const theme = useTheme();
250
+ const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
251
+ style: {
252
+ flexDirection: "row",
253
+ alignItems: "flex-start"
254
+ },
255
+ children: [portrait !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
256
+ style: { marginRight: theme.spacing.md },
257
+ children: portrait
258
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
259
+ style: { flex: 1 },
260
+ children: [
261
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
262
+ variant: "sm",
263
+ tone: "accent",
264
+ style: { marginBottom: theme.spacing.xs },
265
+ children: speaker
266
+ }),
267
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
268
+ variant: "md",
269
+ children: text
270
+ }),
271
+ choices && choices.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
272
+ style: { marginTop: theme.spacing.md },
273
+ children: choices.map((c, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
274
+ style: { marginTop: i === 0 ? 0 : theme.spacing.xs },
275
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
276
+ label: c.label,
277
+ onPress: c.onPress,
278
+ disabled: c.disabled,
279
+ variant: "secondary"
280
+ })
281
+ }, `${c.label}-${i}`))
282
+ }) : null
283
+ ]
284
+ })]
285
+ });
286
+ if (choices && choices.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
287
+ variant: "elevated",
288
+ padding: "md",
289
+ style,
290
+ children: body
291
+ });
292
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
293
+ onPress: onAdvance,
294
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
295
+ variant: "elevated",
296
+ padding: "md",
297
+ style,
298
+ children: body
299
+ })
300
+ });
232
301
  }
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;
302
+ //#endregion
303
+ //#region src/focus.ts
304
+ function createFocusManager() {
305
+ const nodes = /* @__PURE__ */ new Map();
306
+ let seqCounter = 0;
307
+ let focusedId = null;
308
+ const listeners = /* @__PURE__ */ new Set();
309
+ function notify() {
310
+ for (const l of listeners) l(focusedId);
311
+ }
312
+ function orderedIds() {
313
+ const entries = Array.from(nodes.values()).filter((e) => !e.disabled);
314
+ entries.sort((a, b) => {
315
+ if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;
316
+ return a.seq - b.seq;
317
+ });
318
+ return entries.map((e) => e.id);
319
+ }
320
+ function setFocused(next) {
321
+ if (next === focusedId) return;
322
+ const prev = focusedId;
323
+ focusedId = next;
324
+ if (prev !== null) nodes.get(prev)?.onBlur?.();
325
+ if (next !== null) nodes.get(next)?.onFocus?.();
326
+ notify();
327
+ }
328
+ function move(delta) {
329
+ const order = orderedIds();
330
+ if (order.length === 0) {
331
+ setFocused(null);
332
+ return;
333
+ }
334
+ if (focusedId === null) {
335
+ setFocused(delta === 1 ? order[0] ?? null : order[order.length - 1] ?? null);
336
+ return;
337
+ }
338
+ const idx = order.indexOf(focusedId);
339
+ if (idx === -1) {
340
+ setFocused(order[0] ?? null);
341
+ return;
342
+ }
343
+ setFocused(order[(idx + delta + order.length) % order.length] ?? null);
344
+ }
345
+ return {
346
+ register(node) {
347
+ const entry = {
348
+ ...node,
349
+ seq: seqCounter++
350
+ };
351
+ nodes.set(node.id, entry);
352
+ return () => {
353
+ this.unregister(node.id);
354
+ };
355
+ },
356
+ unregister(id) {
357
+ if (!nodes.has(id)) return;
358
+ nodes.delete(id);
359
+ if (focusedId === id) setFocused(orderedIds()[0] ?? null);
360
+ },
361
+ focus(id) {
362
+ const entry = nodes.get(id);
363
+ if (!entry || entry.disabled) return;
364
+ setFocused(id);
365
+ },
366
+ focusFirst() {
367
+ setFocused(orderedIds()[0] ?? null);
368
+ },
369
+ blur() {
370
+ setFocused(null);
371
+ },
372
+ next() {
373
+ move(1);
374
+ },
375
+ prev() {
376
+ move(-1);
377
+ },
378
+ activate() {
379
+ if (focusedId === null) return;
380
+ nodes.get(focusedId)?.onActivate?.();
381
+ },
382
+ getFocused() {
383
+ return focusedId;
384
+ },
385
+ getOrder() {
386
+ return orderedIds();
387
+ },
388
+ subscribe(listener) {
389
+ listeners.add(listener);
390
+ return () => {
391
+ listeners.delete(listener);
392
+ };
393
+ }
394
+ };
319
395
  }
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 });
396
+ //#endregion
397
+ //#region src/focus-keyboard-driver.ts
398
+ const DEFAULT_NEXT = [
399
+ "ArrowDown",
400
+ "ArrowRight",
401
+ "Tab"
402
+ ];
403
+ const DEFAULT_PREV = ["ArrowUp", "ArrowLeft"];
404
+ const DEFAULT_ACTIVATE = ["Enter", "Space"];
405
+ function createFocusKeyboardDriver(manager, keys, options) {
406
+ const nextCodes = options?.next ?? DEFAULT_NEXT;
407
+ const prevCodes = options?.prev ?? DEFAULT_PREV;
408
+ const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;
409
+ return { update() {
410
+ for (let i = 0; i < nextCodes.length; i++) if (keys.wasPressed(nextCodes[i])) {
411
+ manager.next();
412
+ return;
413
+ }
414
+ for (let i = 0; i < prevCodes.length; i++) if (keys.wasPressed(prevCodes[i])) {
415
+ manager.prev();
416
+ return;
417
+ }
418
+ for (let i = 0; i < activateCodes.length; i++) if (keys.wasPressed(activateCodes[i])) {
419
+ manager.activate();
420
+ return;
421
+ }
422
+ } };
343
423
  }
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 });
424
+ //#endregion
425
+ //#region src/focus-provider.tsx
426
+ /**
427
+ * Instantiates a FocusManager (or uses the one provided) and publishes
428
+ * { manager, focusedId } as context state so consumers re-render on focus
429
+ * moves.
430
+ */
431
+ function FocusProvider({ manager, autoFocus, children }) {
432
+ const [mgr] = (0, react.useState)(() => manager ?? createFocusManager());
433
+ const [focusedId, setFocusedId] = (0, react.useState)(() => mgr.getFocused());
434
+ (0, react.useEffect)(() => {
435
+ setFocusedId(mgr.getFocused());
436
+ return mgr.subscribe((id) => {
437
+ setFocusedId(id);
438
+ });
439
+ }, [mgr]);
440
+ (0, react.useEffect)(() => {
441
+ if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();
442
+ }, [autoFocus, mgr]);
443
+ const value = (0, react.useMemo)(() => ({
444
+ manager: mgr,
445
+ focusedId
446
+ }), [mgr, focusedId]);
447
+ return (0, react.createElement)(FocusContext.Provider, { value }, children);
377
448
  }
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
- );
449
+ //#endregion
450
+ //#region src/progress-bar.tsx
451
+ function ProgressBar({ value, height = 8, trackColor, fillColor, style }) {
452
+ const theme = useTheme();
453
+ const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));
454
+ const r = theme.radii.sm;
455
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
456
+ style: [{
457
+ height,
458
+ borderRadius: r,
459
+ backgroundColor: trackColor ?? theme.colors.surfaceAlt,
460
+ overflow: "hidden"
461
+ }, style],
462
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: {
463
+ width: `${clamped * 100}%`,
464
+ height: "100%",
465
+ backgroundColor: fillColor ?? theme.colors.accent
466
+ } })
467
+ });
458
468
  }
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
- );
469
+ //#endregion
470
+ //#region src/hud-bar.tsx
471
+ function HUDBar({ label, value, max, kind = "custom", showNumbers = true, fillColor }) {
472
+ const theme = useTheme();
473
+ const ratio = max <= 0 ? 0 : value / max;
474
+ let color = fillColor;
475
+ if (!color) switch (kind) {
476
+ case "hp":
477
+ color = theme.colors.danger;
478
+ break;
479
+ case "mp":
480
+ color = theme.colors.accent;
481
+ break;
482
+ case "xp":
483
+ color = theme.colors.success;
484
+ break;
485
+ default: color = theme.colors.accent;
486
+ }
487
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
488
+ style: {
489
+ flexDirection: "row",
490
+ justifyContent: "space-between",
491
+ marginBottom: theme.spacing.xs
492
+ },
493
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
494
+ variant: "sm",
495
+ tone: "muted",
496
+ children: label
497
+ }), showNumbers && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
498
+ variant: "sm",
499
+ tone: "muted",
500
+ mono: true,
501
+ children: `${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`
502
+ })]
503
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProgressBar, {
504
+ value: ratio,
505
+ fillColor: color
506
+ })] });
504
507
  }
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
- ] });
508
+ //#endregion
509
+ //#region src/layout.ts
510
+ const ZERO_PAD = {
511
+ top: 0,
512
+ right: 0,
513
+ bottom: 0,
514
+ left: 0
515
+ };
516
+ function resolvePadding(p) {
517
+ if (!p) return ZERO_PAD;
518
+ return {
519
+ top: p.top ?? 0,
520
+ right: p.right ?? 0,
521
+ bottom: p.bottom ?? 0,
522
+ left: p.left ?? 0
523
+ };
552
524
  }
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");
525
+ function resolveLayout(container, children) {
526
+ const n = children.length;
527
+ if (n === 0) return [];
528
+ const pad = resolvePadding(container.padding);
529
+ const gap = container.gap ?? 0;
530
+ const isRow = container.direction === "row";
531
+ const mainSize = (isRow ? container.width : container.height) - (isRow ? pad.left + pad.right : pad.top + pad.bottom);
532
+ const crossSize = (isRow ? container.height : container.width) - (isRow ? pad.top + pad.bottom : pad.left + pad.right);
533
+ const mainStart = isRow ? pad.left : pad.top;
534
+ const crossStart = isRow ? pad.top : pad.left;
535
+ const justify = container.justifyContent ?? "start";
536
+ const align = container.alignItems ?? "stretch";
537
+ const totalGap = gap * Math.max(0, n - 1);
538
+ let totalBasis = 0;
539
+ let totalGrow = 0;
540
+ for (const c of children) {
541
+ totalBasis += c.basis ?? 0;
542
+ totalGrow += c.grow ?? 0;
543
+ }
544
+ const leftover = mainSize - totalBasis - totalGap;
545
+ const sizes = new Array(n);
546
+ for (let i = 0; i < n; i++) {
547
+ const c = children[i];
548
+ const base = c.basis ?? 0;
549
+ const growShare = totalGrow > 0 ? (c.grow ?? 0) / totalGrow * Math.max(0, leftover) : 0;
550
+ sizes[i] = Math.max(0, base + growShare);
551
+ }
552
+ const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;
553
+ const free = Math.max(0, mainSize - used);
554
+ let cursor = mainStart;
555
+ let spacing = gap;
556
+ switch (justify) {
557
+ case "start": break;
558
+ case "end":
559
+ cursor = mainStart + free;
560
+ break;
561
+ case "center":
562
+ cursor = mainStart + free / 2;
563
+ break;
564
+ case "space-between":
565
+ if (n > 1) spacing = gap + free / (n - 1);
566
+ break;
567
+ case "space-around":
568
+ if (n > 0) {
569
+ const s = free / n;
570
+ cursor = mainStart + s / 2;
571
+ spacing = gap + s;
572
+ }
573
+ break;
574
+ case "space-evenly":
575
+ if (n >= 0) {
576
+ const s = free / (n + 1);
577
+ cursor = mainStart + s;
578
+ spacing = gap + s;
579
+ }
580
+ break;
581
+ }
582
+ const out = new Array(n);
583
+ for (let i = 0; i < n; i++) {
584
+ const c = children[i];
585
+ const mainLen = sizes[i];
586
+ const crossLen = c.crossSize !== void 0 ? c.crossSize : align === "stretch" ? crossSize : 0;
587
+ let crossOffset;
588
+ switch (align) {
589
+ case "start":
590
+ crossOffset = 0;
591
+ break;
592
+ case "end":
593
+ crossOffset = crossSize - crossLen;
594
+ break;
595
+ case "center":
596
+ crossOffset = (crossSize - crossLen) / 2;
597
+ break;
598
+ case "stretch":
599
+ crossOffset = 0;
600
+ break;
601
+ }
602
+ out[i] = {
603
+ x: isRow ? cursor : crossStart + crossOffset,
604
+ y: isRow ? crossStart + crossOffset : cursor,
605
+ width: isRow ? mainLen : crossLen,
606
+ height: isRow ? crossLen : mainLen
607
+ };
608
+ cursor += mainLen + spacing;
609
+ }
610
+ return out;
611
+ }
612
+ //#endregion
613
+ //#region src/list.tsx
614
+ /**
615
+ * Vertical (or horizontal) stack with consistent gap. Thin container; the
616
+ * focus manager handles navigation between interactive children.
617
+ */
558
618
  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 });
619
+ const theme = useTheme();
620
+ const g = gap ?? theme.spacing.sm;
621
+ const items = [];
622
+ let i = 0;
623
+ const flat = Array.isArray(children) ? children : [children];
624
+ for (const child of flat) {
625
+ if (child === null || child === void 0 || child === false) continue;
626
+ if (i > 0) {
627
+ const spacerStyle = direction === "row" ? { width: g } : { height: g };
628
+ items.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: spacerStyle }, `s-${i}`));
629
+ }
630
+ items.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: child }, `i-${i}`));
631
+ i++;
632
+ }
633
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
634
+ style: [{ flexDirection: direction }, style],
635
+ children: items
636
+ });
574
637
  }
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
- );
638
+ //#endregion
639
+ //#region src/main-menu-kit.tsx
640
+ /**
641
+ * Title-screen kit: headline, optional subtitle, vertical button list,
642
+ * optional footer slot. All strings are caller-supplied (localized upstream).
643
+ *
644
+ * Save-slot / settings / credits panels are built on top of this kit by the
645
+ * consumer; the kit itself is a pure title-menu primitive.
646
+ */
647
+ function MainMenuKit({ title, subtitle, items, footer, style }) {
648
+ const theme = useTheme();
649
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
650
+ style: [{
651
+ flex: 1,
652
+ alignItems: "center",
653
+ justifyContent: "center",
654
+ padding: theme.spacing.lg
655
+ }, style],
656
+ children: [
657
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
658
+ variant: "xl",
659
+ tone: "accent",
660
+ style: { marginBottom: theme.spacing.xs },
661
+ children: title
662
+ }),
663
+ subtitle !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
664
+ variant: "sm",
665
+ tone: "muted",
666
+ style: { marginBottom: theme.spacing.lg },
667
+ children: subtitle
668
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: { height: theme.spacing.lg } }),
669
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
670
+ style: {
671
+ alignSelf: "stretch",
672
+ maxWidth: 320,
673
+ width: "100%"
674
+ },
675
+ children: items.map((item, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
676
+ style: { marginTop: i === 0 ? 0 : theme.spacing.sm },
677
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
678
+ label: item.label,
679
+ onPress: item.onPress,
680
+ variant: item.variant ?? "primary",
681
+ disabled: item.disabled,
682
+ focusId: item.id,
683
+ tabIndex: i
684
+ })
685
+ }, item.id))
686
+ }),
687
+ footer !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
688
+ style: { marginTop: theme.spacing.lg },
689
+ children: footer
690
+ }) : null
691
+ ]
692
+ });
618
693
  }
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 }) });
694
+ //#endregion
695
+ //#region src/modal.tsx
696
+ /**
697
+ * Overlay modal that renders a centered `Panel` with its children. Parent is
698
+ * responsible for controlling visibility and (if desired) focus trapping via
699
+ * the shared FocusManager.
700
+ */
701
+ function Modal({ visible, children, onBackdropPress, backdropOpacity = .6 }) {
702
+ if (!visible) return null;
703
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
704
+ style: {
705
+ position: "absolute",
706
+ top: 0,
707
+ left: 0,
708
+ right: 0,
709
+ bottom: 0,
710
+ alignItems: "center",
711
+ justifyContent: "center"
712
+ },
713
+ pointerEvents: "box-none",
714
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
715
+ onPress: onBackdropPress,
716
+ style: {
717
+ position: "absolute",
718
+ top: 0,
719
+ left: 0,
720
+ right: 0,
721
+ bottom: 0,
722
+ backgroundColor: `rgba(0,0,0,${backdropOpacity})`
723
+ }
724
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
725
+ variant: "elevated",
726
+ padding: "lg",
727
+ style: {
728
+ minWidth: 240,
729
+ maxWidth: "80%"
730
+ },
731
+ children
732
+ })]
733
+ });
652
734
  }
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
- }) });
735
+ //#endregion
736
+ //#region src/shop-panel.tsx
737
+ /**
738
+ * List-style shop panel. Caller builds the `items` array by joining a
739
+ * `ProductCatalog` with the `Product[]` returned by `IAPProvider.getProducts`.
740
+ *
741
+ * Price strings and ownership copy are caller-provided so the UI kit stays
742
+ * localization-free.
743
+ */
744
+ function ShopPanel({ items, isEntitled, onPurchase, ownedLabel = "Owned", purchaseLabelFor, style }) {
745
+ const theme = useTheme();
746
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Panel, {
747
+ variant: "elevated",
748
+ padding: "md",
749
+ style,
750
+ children: items.map((item, i) => {
751
+ const owned = item.ownedKeys?.some((k) => isEntitled(k)) ?? false;
752
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
753
+ style: {
754
+ marginTop: i === 0 ? 0 : theme.spacing.md,
755
+ paddingTop: i === 0 ? 0 : theme.spacing.md,
756
+ borderTopWidth: i === 0 ? 0 : 1,
757
+ borderTopColor: theme.colors.border
758
+ },
759
+ children: [
760
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
761
+ variant: "md",
762
+ children: item.title
763
+ }),
764
+ item.description !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
765
+ variant: "sm",
766
+ tone: "muted",
767
+ style: { marginTop: theme.spacing.xs },
768
+ children: item.description
769
+ }) : null,
770
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
771
+ style: { marginTop: theme.spacing.sm },
772
+ children: owned ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
773
+ label: ownedLabel,
774
+ variant: "ghost",
775
+ disabled: true
776
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
777
+ label: purchaseLabelFor ? purchaseLabelFor(item) : item.priceDisplay,
778
+ variant: "primary",
779
+ disabled: item.disabled,
780
+ onPress: () => onPurchase(item.productId)
781
+ })
782
+ })
783
+ ]
784
+ }, item.productId);
785
+ })
786
+ });
694
787
  }
788
+ //#endregion
789
+ exports.Button = Button;
790
+ exports.DialoguePanel = DialoguePanel;
791
+ exports.FocusContext = FocusContext;
792
+ exports.FocusProvider = FocusProvider;
793
+ exports.HUDBar = HUDBar;
794
+ exports.Label = Label;
795
+ exports.List = List;
796
+ exports.MainMenuKit = MainMenuKit;
797
+ exports.Modal = Modal;
798
+ exports.Panel = Panel;
799
+ exports.ProgressBar = ProgressBar;
800
+ exports.ShopPanel = ShopPanel;
801
+ exports.ThemeProvider = ThemeProvider;
802
+ exports.createFocusKeyboardDriver = createFocusKeyboardDriver;
803
+ exports.createFocusManager = createFocusManager;
804
+ exports.darkTheme = darkTheme;
805
+ exports.lightTheme = lightTheme;
806
+ exports.resolveLayout = resolveLayout;
807
+ exports.useFocusManager = useFocusManager;
808
+ exports.useFocusedId = useFocusedId;
809
+ exports.useTheme = useTheme;
695
810
 
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
811
  //# sourceMappingURL=index.js.map