@flare-engine/ui 0.4.10 → 0.4.11
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/{focus-Yx4Wyt5Q.js → focus-86LvCtcF.js} +13 -11
- package/dist/focus-86LvCtcF.js.map +1 -0
- package/dist/{focus-BO0mEf9L.mjs → focus-CtmAYznc.mjs} +13 -11
- package/dist/focus-CtmAYznc.mjs.map +1 -0
- package/dist/{focus-DLq2jGFa.d.mts → focus-ILunQnll.d.mts} +5 -1
- package/dist/focus-ILunQnll.d.mts.map +1 -0
- package/dist/{focus-DLq2jGFa.d.ts → focus-ILunQnll.d.ts} +5 -1
- package/dist/focus-ILunQnll.d.ts.map +1 -0
- package/dist/focus.d.mts +1 -1
- package/dist/focus.d.ts +1 -1
- package/dist/focus.js +1 -1
- package/dist/focus.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/focus-BO0mEf9L.mjs.map +0 -1
- package/dist/focus-DLq2jGFa.d.mts.map +0 -1
- package/dist/focus-DLq2jGFa.d.ts.map +0 -1
- package/dist/focus-Yx4Wyt5Q.js.map +0 -1
|
@@ -68,22 +68,22 @@ function createFocusManager(opts) {
|
|
|
68
68
|
}
|
|
69
69
|
setFocused(order[(idx + delta + order.length) % order.length] ?? null);
|
|
70
70
|
}
|
|
71
|
+
function unregister(id) {
|
|
72
|
+
if (!nodes.has(id)) return;
|
|
73
|
+
nodes.delete(id);
|
|
74
|
+
if (focusedId === id) setFocused(refocusOnUnregister ? orderedIds()[0] ?? null : null);
|
|
75
|
+
}
|
|
71
76
|
return {
|
|
72
77
|
register(node) {
|
|
78
|
+
const existing = nodes.get(node.id);
|
|
73
79
|
const entry = {
|
|
74
80
|
...node,
|
|
75
|
-
seq: seqCounter++
|
|
81
|
+
seq: existing?.seq ?? seqCounter++
|
|
76
82
|
};
|
|
77
83
|
nodes.set(node.id, entry);
|
|
78
|
-
return () =>
|
|
79
|
-
this.unregister(node.id);
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
unregister(id) {
|
|
83
|
-
if (!nodes.has(id)) return;
|
|
84
|
-
nodes.delete(id);
|
|
85
|
-
if (focusedId === id) setFocused(refocusOnUnregister ? orderedIds()[0] ?? null : null);
|
|
84
|
+
return () => unregister(node.id);
|
|
86
85
|
},
|
|
86
|
+
unregister,
|
|
87
87
|
focus(id) {
|
|
88
88
|
const entry = nodes.get(id);
|
|
89
89
|
if (!entry || entry.disabled) return;
|
|
@@ -103,7 +103,9 @@ function createFocusManager(opts) {
|
|
|
103
103
|
},
|
|
104
104
|
activate() {
|
|
105
105
|
if (focusedId === null) return;
|
|
106
|
-
nodes.get(focusedId)
|
|
106
|
+
const entry = nodes.get(focusedId);
|
|
107
|
+
if (!entry || entry.disabled) return;
|
|
108
|
+
entry.onActivate?.();
|
|
107
109
|
},
|
|
108
110
|
getFocused() {
|
|
109
111
|
return focusedId;
|
|
@@ -132,4 +134,4 @@ Object.defineProperty(exports, "createFocusManager", {
|
|
|
132
134
|
}
|
|
133
135
|
});
|
|
134
136
|
|
|
135
|
-
//# sourceMappingURL=focus-
|
|
137
|
+
//# sourceMappingURL=focus-86LvCtcF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-86LvCtcF.js","names":[],"sources":["../src/focus-keyboard-driver.ts","../src/focus-manager.ts"],"sourcesContent":["import type { FocusManager } from './focus-manager.js';\n\n/** Structural key source — createKeyboard() from @flare-engine/input is assignable; no hard dep. */\nexport interface FocusKeySource {\n wasPressed(code: string): boolean;\n}\n\nexport interface FocusKeyboardDriver {\n /** Call once per frame; polls edges and drives the manager. */\n update(): void;\n}\n\nexport interface FocusKeyboardDriverOptions {\n next?: readonly string[];\n prev?: readonly string[];\n activate?: readonly string[];\n}\n\nconst DEFAULT_NEXT: readonly string[] = ['ArrowDown', 'ArrowRight', 'Tab'];\nconst DEFAULT_PREV: readonly string[] = ['ArrowUp', 'ArrowLeft'];\nconst DEFAULT_ACTIVATE: readonly string[] = ['Enter', 'Space'];\n\nexport function createFocusKeyboardDriver(\n manager: FocusManager,\n keys: FocusKeySource,\n options?: FocusKeyboardDriverOptions,\n): FocusKeyboardDriver {\n const nextCodes = options?.next ?? DEFAULT_NEXT;\n const prevCodes = options?.prev ?? DEFAULT_PREV;\n const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;\n\n return {\n update(): void {\n for (let i = 0; i < nextCodes.length; i++) {\n if (keys.wasPressed(nextCodes[i]!)) {\n manager.next();\n return;\n }\n }\n for (let i = 0; i < prevCodes.length; i++) {\n if (keys.wasPressed(prevCodes[i]!)) {\n manager.prev();\n return;\n }\n }\n for (let i = 0; i < activateCodes.length; i++) {\n if (keys.wasPressed(activateCodes[i]!)) {\n manager.activate();\n return;\n }\n }\n },\n };\n}\n","/**\n * Keyboard + (future) gamepad focus navigation.\n *\n * Primitives register themselves with the focus manager by id + tab order.\n * The manager owns which id is currently focused and exposes `next` / `prev`\n * / `activate` actions for a driver (keyboard key handler, gamepad dpad)\n * to call. Components read `focusedId` to render a focus ring.\n */\n\nexport interface FocusNode {\n id: string;\n /** Lower tabIndex is focused first. Nodes with equal tabIndex fall back to registration order. */\n tabIndex: number;\n /** Called when this node is activated (Enter / A button). */\n onActivate?: () => void;\n /** Called when this node receives focus. */\n onFocus?: () => void;\n /** Called when this node loses focus. */\n onBlur?: () => void;\n /** If true, the node is skipped during navigation. */\n disabled?: boolean;\n}\n\nexport interface FocusManager {\n /**\n * Registering an already-registered id updates that node in place: it keeps\n * its position among equal `tabIndex` and focus is unchanged.\n */\n register(node: FocusNode): () => void;\n unregister(id: string): void;\n focus(id: string): void;\n /** Explicit opt-in initial focus: focuses the first node in tab order (or clears if empty). */\n focusFirst(): void;\n blur(): void;\n next(): void;\n prev(): void;\n activate(): void;\n getFocused(): string | null;\n getOrder(): readonly string[];\n subscribe(listener: (focusedId: string | null) => void): () => void;\n}\n\nexport interface FocusManagerOptions {\n /**\n * When the focused node unregisters, move focus to the first node in tab\n * order (`true`, the default — keyboard users keep a focus target) or clear\n * it to `null` (`false`). Subscribers are notified either way, and a later\n * `next()` / `prev()` starts from the first / last node as it does from `null`.\n */\n refocusOnUnregister?: boolean;\n}\n\ninterface Entry extends FocusNode {\n seq: number;\n}\n\nexport function createFocusManager(opts?: FocusManagerOptions): FocusManager {\n const refocusOnUnregister = opts?.refocusOnUnregister ?? true;\n const nodes = new Map<string, Entry>();\n let seqCounter = 0;\n let focusedId: string | null = null;\n const listeners = new Set<(id: string | null) => void>();\n\n function notify(): void {\n for (const l of listeners) l(focusedId);\n }\n\n function orderedIds(): string[] {\n const entries = Array.from(nodes.values()).filter((e) => !e.disabled);\n entries.sort((a, b) => {\n if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;\n return a.seq - b.seq;\n });\n return entries.map((e) => e.id);\n }\n\n function setFocused(next: string | null): void {\n if (next === focusedId) return;\n const prev = focusedId;\n focusedId = next;\n if (prev !== null) nodes.get(prev)?.onBlur?.();\n if (next !== null) nodes.get(next)?.onFocus?.();\n notify();\n }\n\n function move(delta: 1 | -1): void {\n const order = orderedIds();\n if (order.length === 0) {\n setFocused(null);\n return;\n }\n if (focusedId === null) {\n setFocused(delta === 1 ? (order[0] ?? null) : (order[order.length - 1] ?? null));\n return;\n }\n const idx = order.indexOf(focusedId);\n if (idx === -1) {\n setFocused(order[0] ?? null);\n return;\n }\n const nextIdx = (idx + delta + order.length) % order.length;\n setFocused(order[nextIdx] ?? null);\n }\n\n function unregister(id: string): void {\n if (!nodes.has(id)) return;\n nodes.delete(id);\n if (focusedId === id) {\n setFocused(refocusOnUnregister ? (orderedIds()[0] ?? null) : null);\n }\n }\n\n return {\n register(node) {\n // No focus side-effect: on a touch-first engine an auto-focused first\n // registrant paints a permanent focus ring with no input. Focus stays null\n // until a driver (keyboard/gamepad) or an explicit focusFirst() acts.\n const existing = nodes.get(node.id);\n const entry: Entry = { ...node, seq: existing?.seq ?? seqCounter++ };\n nodes.set(node.id, entry);\n return () => unregister(node.id);\n },\n unregister,\n focus(id) {\n const entry = nodes.get(id);\n if (!entry || entry.disabled) return;\n setFocused(id);\n },\n focusFirst() {\n const order = orderedIds();\n setFocused(order[0] ?? null);\n },\n blur() {\n setFocused(null);\n },\n next() {\n move(1);\n },\n prev() {\n move(-1);\n },\n activate() {\n if (focusedId === null) return;\n const entry = nodes.get(focusedId);\n if (!entry || entry.disabled) return;\n entry.onActivate?.();\n },\n getFocused() {\n return focusedId;\n },\n getOrder() {\n return orderedIds();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n"],"mappings":";AAkBA,MAAM,eAAkC;CAAC;CAAa;CAAc;AAAK;AACzE,MAAM,eAAkC,CAAC,WAAW,WAAW;AAC/D,MAAM,mBAAsC,CAAC,SAAS,OAAO;AAE7D,SAAgB,0BACd,SACA,MACA,SACqB;CACrB,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,gBAAgB,SAAS,YAAY;CAE3C,OAAO,EACL,SAAe;EACb,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,KAAK,WAAW,cAAc,EAAG,GAAG;GACtC,QAAQ,SAAS;GACjB;EACF;CAEJ,EACF;AACF;;ACGA,SAAgB,mBAAmB,MAA0C;CAC3E,MAAM,sBAAsB,MAAM,uBAAuB;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AI;CAErE;CAEA,OAAO;EACL,SAAS,MAAM;GAIb,MAAM,WAAW,MAAM,IAAI,KAAK,EAAE;GAClC,MAAM,QAAe;IAAE,GAAG;IAAM,KAAK,UAAU,OAAO;GAAa;GACnE,MAAM,IAAI,KAAK,IAAI,KAAK;GACxB,aAAa,WAAW,KAAK,EAAE;EACjC;EACA;EACA,MAAM,IAAI;GACR,MAAM,QAAQ,MAAM,IAAI,EAAE;GAC1B,IAAI,CAAC,SAAS,MAAM,UAAU;GAC9B,WAAW,EAAE;EACf;EACA,aAAa;GAEX,WADc,WACC,CAAC,CAAC,MAAM,IAAI;EAC7B;EACA,OAAO;GACL,WAAW,IAAI;EACjB;EACA,OAAO;GACL,KAAK,CAAC;EACR;EACA,OAAO;GACL,KAAK,EAAE;EACT;EACA,WAAW;GACT,IAAI,cAAc,MAAM;GACxB,MAAM,QAAQ,MAAM,IAAI,SAAS;GACjC,IAAI,CAAC,SAAS,MAAM,UAAU;GAC9B,MAAM,aAAa;EACrB;EACA,aAAa;GACX,OAAO;EACT;EACA,WAAW;GACT,OAAO,WAAW;EACpB;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;CACF;AACF"}
|
|
@@ -68,22 +68,22 @@ function createFocusManager(opts) {
|
|
|
68
68
|
}
|
|
69
69
|
setFocused(order[(idx + delta + order.length) % order.length] ?? null);
|
|
70
70
|
}
|
|
71
|
+
function unregister(id) {
|
|
72
|
+
if (!nodes.has(id)) return;
|
|
73
|
+
nodes.delete(id);
|
|
74
|
+
if (focusedId === id) setFocused(refocusOnUnregister ? orderedIds()[0] ?? null : null);
|
|
75
|
+
}
|
|
71
76
|
return {
|
|
72
77
|
register(node) {
|
|
78
|
+
const existing = nodes.get(node.id);
|
|
73
79
|
const entry = {
|
|
74
80
|
...node,
|
|
75
|
-
seq: seqCounter++
|
|
81
|
+
seq: existing?.seq ?? seqCounter++
|
|
76
82
|
};
|
|
77
83
|
nodes.set(node.id, entry);
|
|
78
|
-
return () =>
|
|
79
|
-
this.unregister(node.id);
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
unregister(id) {
|
|
83
|
-
if (!nodes.has(id)) return;
|
|
84
|
-
nodes.delete(id);
|
|
85
|
-
if (focusedId === id) setFocused(refocusOnUnregister ? orderedIds()[0] ?? null : null);
|
|
84
|
+
return () => unregister(node.id);
|
|
86
85
|
},
|
|
86
|
+
unregister,
|
|
87
87
|
focus(id) {
|
|
88
88
|
const entry = nodes.get(id);
|
|
89
89
|
if (!entry || entry.disabled) return;
|
|
@@ -103,7 +103,9 @@ function createFocusManager(opts) {
|
|
|
103
103
|
},
|
|
104
104
|
activate() {
|
|
105
105
|
if (focusedId === null) return;
|
|
106
|
-
nodes.get(focusedId)
|
|
106
|
+
const entry = nodes.get(focusedId);
|
|
107
|
+
if (!entry || entry.disabled) return;
|
|
108
|
+
entry.onActivate?.();
|
|
107
109
|
},
|
|
108
110
|
getFocused() {
|
|
109
111
|
return focusedId;
|
|
@@ -121,4 +123,4 @@ function createFocusManager(opts) {
|
|
|
121
123
|
}
|
|
122
124
|
export { createFocusKeyboardDriver as n, createFocusManager as t };
|
|
123
125
|
|
|
124
|
-
//# sourceMappingURL=focus-
|
|
126
|
+
//# sourceMappingURL=focus-CtmAYznc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-CtmAYznc.mjs","names":[],"sources":["../src/focus-keyboard-driver.ts","../src/focus-manager.ts"],"sourcesContent":["import type { FocusManager } from './focus-manager.js';\n\n/** Structural key source — createKeyboard() from @flare-engine/input is assignable; no hard dep. */\nexport interface FocusKeySource {\n wasPressed(code: string): boolean;\n}\n\nexport interface FocusKeyboardDriver {\n /** Call once per frame; polls edges and drives the manager. */\n update(): void;\n}\n\nexport interface FocusKeyboardDriverOptions {\n next?: readonly string[];\n prev?: readonly string[];\n activate?: readonly string[];\n}\n\nconst DEFAULT_NEXT: readonly string[] = ['ArrowDown', 'ArrowRight', 'Tab'];\nconst DEFAULT_PREV: readonly string[] = ['ArrowUp', 'ArrowLeft'];\nconst DEFAULT_ACTIVATE: readonly string[] = ['Enter', 'Space'];\n\nexport function createFocusKeyboardDriver(\n manager: FocusManager,\n keys: FocusKeySource,\n options?: FocusKeyboardDriverOptions,\n): FocusKeyboardDriver {\n const nextCodes = options?.next ?? DEFAULT_NEXT;\n const prevCodes = options?.prev ?? DEFAULT_PREV;\n const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;\n\n return {\n update(): void {\n for (let i = 0; i < nextCodes.length; i++) {\n if (keys.wasPressed(nextCodes[i]!)) {\n manager.next();\n return;\n }\n }\n for (let i = 0; i < prevCodes.length; i++) {\n if (keys.wasPressed(prevCodes[i]!)) {\n manager.prev();\n return;\n }\n }\n for (let i = 0; i < activateCodes.length; i++) {\n if (keys.wasPressed(activateCodes[i]!)) {\n manager.activate();\n return;\n }\n }\n },\n };\n}\n","/**\n * Keyboard + (future) gamepad focus navigation.\n *\n * Primitives register themselves with the focus manager by id + tab order.\n * The manager owns which id is currently focused and exposes `next` / `prev`\n * / `activate` actions for a driver (keyboard key handler, gamepad dpad)\n * to call. Components read `focusedId` to render a focus ring.\n */\n\nexport interface FocusNode {\n id: string;\n /** Lower tabIndex is focused first. Nodes with equal tabIndex fall back to registration order. */\n tabIndex: number;\n /** Called when this node is activated (Enter / A button). */\n onActivate?: () => void;\n /** Called when this node receives focus. */\n onFocus?: () => void;\n /** Called when this node loses focus. */\n onBlur?: () => void;\n /** If true, the node is skipped during navigation. */\n disabled?: boolean;\n}\n\nexport interface FocusManager {\n /**\n * Registering an already-registered id updates that node in place: it keeps\n * its position among equal `tabIndex` and focus is unchanged.\n */\n register(node: FocusNode): () => void;\n unregister(id: string): void;\n focus(id: string): void;\n /** Explicit opt-in initial focus: focuses the first node in tab order (or clears if empty). */\n focusFirst(): void;\n blur(): void;\n next(): void;\n prev(): void;\n activate(): void;\n getFocused(): string | null;\n getOrder(): readonly string[];\n subscribe(listener: (focusedId: string | null) => void): () => void;\n}\n\nexport interface FocusManagerOptions {\n /**\n * When the focused node unregisters, move focus to the first node in tab\n * order (`true`, the default — keyboard users keep a focus target) or clear\n * it to `null` (`false`). Subscribers are notified either way, and a later\n * `next()` / `prev()` starts from the first / last node as it does from `null`.\n */\n refocusOnUnregister?: boolean;\n}\n\ninterface Entry extends FocusNode {\n seq: number;\n}\n\nexport function createFocusManager(opts?: FocusManagerOptions): FocusManager {\n const refocusOnUnregister = opts?.refocusOnUnregister ?? true;\n const nodes = new Map<string, Entry>();\n let seqCounter = 0;\n let focusedId: string | null = null;\n const listeners = new Set<(id: string | null) => void>();\n\n function notify(): void {\n for (const l of listeners) l(focusedId);\n }\n\n function orderedIds(): string[] {\n const entries = Array.from(nodes.values()).filter((e) => !e.disabled);\n entries.sort((a, b) => {\n if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;\n return a.seq - b.seq;\n });\n return entries.map((e) => e.id);\n }\n\n function setFocused(next: string | null): void {\n if (next === focusedId) return;\n const prev = focusedId;\n focusedId = next;\n if (prev !== null) nodes.get(prev)?.onBlur?.();\n if (next !== null) nodes.get(next)?.onFocus?.();\n notify();\n }\n\n function move(delta: 1 | -1): void {\n const order = orderedIds();\n if (order.length === 0) {\n setFocused(null);\n return;\n }\n if (focusedId === null) {\n setFocused(delta === 1 ? (order[0] ?? null) : (order[order.length - 1] ?? null));\n return;\n }\n const idx = order.indexOf(focusedId);\n if (idx === -1) {\n setFocused(order[0] ?? null);\n return;\n }\n const nextIdx = (idx + delta + order.length) % order.length;\n setFocused(order[nextIdx] ?? null);\n }\n\n function unregister(id: string): void {\n if (!nodes.has(id)) return;\n nodes.delete(id);\n if (focusedId === id) {\n setFocused(refocusOnUnregister ? (orderedIds()[0] ?? null) : null);\n }\n }\n\n return {\n register(node) {\n // No focus side-effect: on a touch-first engine an auto-focused first\n // registrant paints a permanent focus ring with no input. Focus stays null\n // until a driver (keyboard/gamepad) or an explicit focusFirst() acts.\n const existing = nodes.get(node.id);\n const entry: Entry = { ...node, seq: existing?.seq ?? seqCounter++ };\n nodes.set(node.id, entry);\n return () => unregister(node.id);\n },\n unregister,\n focus(id) {\n const entry = nodes.get(id);\n if (!entry || entry.disabled) return;\n setFocused(id);\n },\n focusFirst() {\n const order = orderedIds();\n setFocused(order[0] ?? null);\n },\n blur() {\n setFocused(null);\n },\n next() {\n move(1);\n },\n prev() {\n move(-1);\n },\n activate() {\n if (focusedId === null) return;\n const entry = nodes.get(focusedId);\n if (!entry || entry.disabled) return;\n entry.onActivate?.();\n },\n getFocused() {\n return focusedId;\n },\n getOrder() {\n return orderedIds();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n"],"mappings":";AAkBA,MAAM,eAAkC;CAAC;CAAa;CAAc;AAAK;AACzE,MAAM,eAAkC,CAAC,WAAW,WAAW;AAC/D,MAAM,mBAAsC,CAAC,SAAS,OAAO;AAE7D,SAAgB,0BACd,SACA,MACA,SACqB;CACrB,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,gBAAgB,SAAS,YAAY;CAE3C,OAAO,EACL,SAAe;EACb,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,KAAK,WAAW,cAAc,EAAG,GAAG;GACtC,QAAQ,SAAS;GACjB;EACF;CAEJ,EACF;AACF;;ACGA,SAAgB,mBAAmB,MAA0C;CAC3E,MAAM,sBAAsB,MAAM,uBAAuB;CACzD,MAAM,wBAA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AAO;EACL,SAAS,MAAM;GAIb,MAAM,WAAW,MAAM,IAAI,KAAK,EAAE;GAClC,MAAM,QAAe;IAAE,GAAG;IAAM,KAAK,UAAU,OAAO;GAAa;GACnE,MAAM,IAAI,KAAK,IAAI,KAAK;GACxB,aAAa,WAAW,KAAK,EAAE;EACjC;EACA;EACA,MAAM,IAAI;GACR,MAAM,QAAQ,MAAM,IAAI,EAAE;GAC1B,IAAI,CAAC,SAAS,MAAM,UAAU;GAC9B,WAAW,EAAE;EACf;EACA,aAAa;GAEX,WADc,WACC,CAAC,CAAC,MAAM,IAAI;EAC7B;EACA,OAAO;GACL,WAAW,IAAI;EACjB;EACA,OAAO;GACL,KAAK,CAAC;EACR;EACA,OAAO;GACL,KAAK,EAAE;EACT;EACA,WAAW;GACT,IAAI,cAAc,MAAM;GACxB,MAAM,QAAQ,MAAM,IAAI,SAAS;GACjC,IAAI,CAAC,SAAS,MAAM,UAAU;GAC9B,MAAM,aAAa;EACrB;EACA,aAAa;GACX,OAAO;EACT;EACA,WAAW;GACT,OAAO,WAAW;EACpB;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;CACF;AACF"}
|
|
@@ -20,6 +20,10 @@ interface FocusNode {
|
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
}
|
|
22
22
|
interface FocusManager {
|
|
23
|
+
/**
|
|
24
|
+
* Registering an already-registered id updates that node in place: it keeps
|
|
25
|
+
* its position among equal `tabIndex` and focus is unchanged.
|
|
26
|
+
*/
|
|
23
27
|
register(node: FocusNode): () => void;
|
|
24
28
|
unregister(id: string): void;
|
|
25
29
|
focus(id: string): void;
|
|
@@ -58,4 +62,4 @@ interface FocusKeyboardDriverOptions {
|
|
|
58
62
|
}
|
|
59
63
|
declare function createFocusKeyboardDriver(manager: FocusManager, keys: FocusKeySource, options?: FocusKeyboardDriverOptions): FocusKeyboardDriver;
|
|
60
64
|
export { FocusManager as a, createFocusManager as c, createFocusKeyboardDriver as i, FocusKeyboardDriver as n, FocusManagerOptions as o, FocusKeyboardDriverOptions as r, FocusNode as s, FocusKeySource as t };
|
|
61
|
-
//# sourceMappingURL=focus-
|
|
65
|
+
//# sourceMappingURL=focus-ILunQnll.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-ILunQnll.d.mts","names":[],"sources":["../src/focus-manager.ts","../src/focus-keyboard-driver.ts"],"mappings":";;;;;;;;UASiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;;;;;EAKf,SAAS,MAAM;EACf,WAAW;EACX,MAAM;;EAEN;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,WAAW;;UAGN;;;;;;;EAOf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCrD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
|
|
@@ -20,6 +20,10 @@ interface FocusNode {
|
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
}
|
|
22
22
|
interface FocusManager {
|
|
23
|
+
/**
|
|
24
|
+
* Registering an already-registered id updates that node in place: it keeps
|
|
25
|
+
* its position among equal `tabIndex` and focus is unchanged.
|
|
26
|
+
*/
|
|
23
27
|
register(node: FocusNode): () => void;
|
|
24
28
|
unregister(id: string): void;
|
|
25
29
|
focus(id: string): void;
|
|
@@ -58,4 +62,4 @@ interface FocusKeyboardDriverOptions {
|
|
|
58
62
|
}
|
|
59
63
|
declare function createFocusKeyboardDriver(manager: FocusManager, keys: FocusKeySource, options?: FocusKeyboardDriverOptions): FocusKeyboardDriver;
|
|
60
64
|
export { FocusManager as a, createFocusManager as c, createFocusKeyboardDriver as i, FocusKeyboardDriver as n, FocusManagerOptions as o, FocusKeyboardDriverOptions as r, FocusNode as s, FocusKeySource as t };
|
|
61
|
-
//# sourceMappingURL=focus-
|
|
65
|
+
//# sourceMappingURL=focus-ILunQnll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-ILunQnll.d.ts","names":[],"sources":["../src/focus-manager.ts","../src/focus-keyboard-driver.ts"],"mappings":";;;;;;;;UASiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;;;;;EAKf,SAAS,MAAM;EACf,WAAW;EACX,MAAM;;EAEN;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,WAAW;;UAGN;;;;;;;EAOf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCrD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
|
package/dist/focus.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-
|
|
1
|
+
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-ILunQnll.mjs";
|
|
2
2
|
export { type FocusKeySource, type FocusKeyboardDriver, type FocusKeyboardDriverOptions, type FocusManager, type FocusManagerOptions, type FocusNode, createFocusKeyboardDriver, createFocusManager };
|
package/dist/focus.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-
|
|
1
|
+
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-ILunQnll.js";
|
|
2
2
|
export { type FocusKeySource, type FocusKeyboardDriver, type FocusKeyboardDriverOptions, type FocusManager, type FocusManagerOptions, type FocusNode, createFocusKeyboardDriver, createFocusManager };
|
package/dist/focus.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_focus = require("./focus-
|
|
2
|
+
const require_focus = require("./focus-86LvCtcF.js");
|
|
3
3
|
exports.createFocusKeyboardDriver = require_focus.createFocusKeyboardDriver;
|
|
4
4
|
exports.createFocusManager = require_focus.createFocusManager;
|
package/dist/focus.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as createFocusKeyboardDriver, t as createFocusManager } from "./focus-
|
|
1
|
+
export { n as createFocusKeyboardDriver, t as createFocusManager } from "./focus-CtmAYznc.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-
|
|
1
|
+
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-ILunQnll.mjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { StyleProp, TextProps, TextStyle, ViewStyle } from "react-native";
|
|
4
4
|
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-
|
|
1
|
+
import { a as FocusManager, c as createFocusManager, i as createFocusKeyboardDriver, n as FocusKeyboardDriver, o as FocusManagerOptions, r as FocusKeyboardDriverOptions, s as FocusNode, t as FocusKeySource } from "./focus-ILunQnll.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
import { StyleProp, TextProps, TextStyle, ViewStyle } from "react-native";
|
|
4
4
|
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_focus = require("./focus-
|
|
2
|
+
const require_focus = require("./focus-86LvCtcF.js");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_native = require("react-native");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -104,22 +104,43 @@ function Button({ label, onPress, variant = "primary", disabled = false, tabInde
|
|
|
104
104
|
const focusedId = useFocusedId();
|
|
105
105
|
const generated = (0, react.useId)();
|
|
106
106
|
const id = focusId ?? generated;
|
|
107
|
+
const latest = (0, react.useRef)({
|
|
108
|
+
onPress,
|
|
109
|
+
disabled,
|
|
110
|
+
tabIndex
|
|
111
|
+
});
|
|
112
|
+
latest.current = {
|
|
113
|
+
onPress,
|
|
114
|
+
disabled,
|
|
115
|
+
tabIndex
|
|
116
|
+
};
|
|
117
|
+
const activateRef = (0, react.useRef)(() => {
|
|
118
|
+
const { onPress: press, disabled: off } = latest.current;
|
|
119
|
+
if (!off) press?.();
|
|
120
|
+
});
|
|
107
121
|
(0, react.useEffect)(() => {
|
|
108
122
|
if (!manager) return;
|
|
123
|
+
const { tabIndex: order, disabled: off } = latest.current;
|
|
109
124
|
return manager.register({
|
|
125
|
+
id,
|
|
126
|
+
tabIndex: order,
|
|
127
|
+
disabled: off,
|
|
128
|
+
onActivate: activateRef.current
|
|
129
|
+
});
|
|
130
|
+
}, [manager, id]);
|
|
131
|
+
(0, react.useEffect)(() => {
|
|
132
|
+
if (!manager) return;
|
|
133
|
+
manager.register({
|
|
110
134
|
id,
|
|
111
135
|
tabIndex,
|
|
112
136
|
disabled,
|
|
113
|
-
onActivate:
|
|
114
|
-
if (!disabled) onPress?.();
|
|
115
|
-
}
|
|
137
|
+
onActivate: activateRef.current
|
|
116
138
|
});
|
|
117
139
|
}, [
|
|
118
140
|
manager,
|
|
119
141
|
id,
|
|
120
142
|
tabIndex,
|
|
121
|
-
disabled
|
|
122
|
-
onPress
|
|
143
|
+
disabled
|
|
123
144
|
]);
|
|
124
145
|
const focused = focusedId === id;
|
|
125
146
|
let bg = theme.colors.surface;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createContext","useContext","createContext","createElement","useContext","useId","Pressable","View","Text","StyleSheet","Text","View","View","Pressable","useState","createFocusManager","useMemo","createElement","View","View","Children","View","Fragment","View","View","Pressable"],"sources":["../src/focus-context.ts","../src/theme.ts","../src/button.tsx","../src/label.tsx","../src/panel.tsx","../src/dialogue-panel.tsx","../src/focus-provider.tsx","../src/progress-bar.tsx","../src/hud-bar.tsx","../src/layout.ts","../src/list.tsx","../src/main-menu-kit.tsx","../src/modal.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { FocusManager } from './focus.js';\n\nexport interface FocusContextValue {\n manager: FocusManager;\n focusedId: string | null;\n}\n\nexport const FocusContext = createContext<FocusContextValue | null>(null);\n\nexport function useFocusManager(): FocusManager | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.manager : null;\n}\n\nexport function useFocusedId(): string | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.focusedId : null;\n}\n","import { createContext, createElement, type ReactNode, useContext } from 'react';\n\nexport interface ThemeColors {\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n accent: string;\n accentText: string;\n danger: string;\n success: string;\n warning: string;\n focus: string;\n}\n\nexport interface ThemeSpacing {\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n}\n\nexport interface ThemeTypography {\n sizeXs: number;\n sizeSm: number;\n sizeMd: number;\n sizeLg: number;\n sizeXl: number;\n fontFamily?: string;\n fontFamilyMono?: string;\n}\n\nexport interface ThemeRadii {\n none: number;\n sm: number;\n md: number;\n lg: number;\n pill: number;\n}\n\nexport interface Theme {\n name: string;\n colors: ThemeColors;\n spacing: ThemeSpacing;\n typography: ThemeTypography;\n radii: ThemeRadii;\n}\n\nexport const darkTheme: Theme = {\n name: 'dark',\n colors: {\n bg: '#0b0d10',\n surface: '#14181d',\n surfaceAlt: '#1d232b',\n border: '#2a323c',\n text: '#e7ecf1',\n textMuted: '#8c96a3',\n accent: '#4aa3ff',\n accentText: '#0b0d10',\n danger: '#ff5c5c',\n success: '#5dd39e',\n warning: '#f1c40f',\n focus: '#ffd166',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nexport const lightTheme: Theme = {\n name: 'light',\n colors: {\n bg: '#f6f8fa',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#d4dae0',\n text: '#13181d',\n textMuted: '#5b6670',\n accent: '#0a66d0',\n accentText: '#ffffff',\n danger: '#d12e2e',\n success: '#2f9d69',\n warning: '#c79600',\n focus: '#ff9500',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nconst ThemeContext = createContext<Theme>(darkTheme);\n\nexport interface ThemeProviderProps {\n theme?: Theme;\n children: ReactNode;\n}\n\nexport function ThemeProvider({ theme = darkTheme, children }: ThemeProviderProps): ReactNode {\n return createElement(ThemeContext.Provider, { value: theme }, children);\n}\n\nexport function useTheme(): Theme {\n return useContext(ThemeContext);\n}\n","import { type ReactNode, useEffect, useId } from 'react';\nimport { Pressable, type StyleProp, StyleSheet, Text, View, type ViewStyle } from 'react-native';\nimport { useFocusedId, useFocusManager } from './focus-context.js';\nimport { useTheme } from './theme.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';\n\nexport interface ButtonProps {\n label: string;\n onPress?: () => void;\n variant?: ButtonVariant;\n disabled?: boolean;\n /** Focus-navigation tab order. Lower is earlier. Defaults to 0. */\n tabIndex?: number;\n /** Stable focus id. If omitted, a generated id is used. */\n focusId?: string;\n /**\n * Move focus to this button when it is pressed. Defaults to `true`. Set\n * `false` on touch-first screens so a tap leaves no focus ring behind;\n * `onPress` still fires.\n */\n focusOnPress?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Button({\n label,\n onPress,\n variant = 'primary',\n disabled = false,\n tabIndex = 0,\n focusId,\n focusOnPress = true,\n style,\n}: ButtonProps): ReactNode {\n const theme = useTheme();\n const manager = useFocusManager();\n const focusedId = useFocusedId();\n const generated = useId();\n const id = focusId ?? generated;\n\n useEffect(() => {\n if (!manager) return;\n return manager.register({\n id,\n tabIndex,\n disabled,\n onActivate: () => {\n if (!disabled) onPress?.();\n },\n });\n }, [manager, id, tabIndex, disabled, onPress]);\n\n const focused = focusedId === id;\n\n let bg = theme.colors.surface;\n let fg = theme.colors.text;\n let border = theme.colors.border;\n switch (variant) {\n case 'primary':\n bg = theme.colors.accent;\n fg = theme.colors.accentText;\n border = theme.colors.accent;\n break;\n case 'secondary':\n bg = theme.colors.surfaceAlt;\n fg = theme.colors.text;\n border = theme.colors.border;\n break;\n case 'ghost':\n bg = 'transparent';\n fg = theme.colors.text;\n border = 'transparent';\n break;\n case 'danger':\n bg = theme.colors.danger;\n fg = theme.colors.accentText;\n border = theme.colors.danger;\n break;\n }\n\n const container: ViewStyle = {\n backgroundColor: bg,\n borderColor: focused ? theme.colors.focus : border,\n borderWidth: focused ? 2 : 1,\n borderRadius: theme.radii.md,\n paddingHorizontal: theme.spacing.md,\n paddingVertical: theme.spacing.sm,\n opacity: disabled ? 0.5 : 1,\n };\n\n return (\n <Pressable\n onPress={() => {\n if (disabled) return;\n if (focusOnPress) manager?.focus(id);\n onPress?.();\n }}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled, selected: focused }}\n style={[styles.wrap, container, style]}\n >\n <View>\n <Text style={{ color: fg, fontSize: theme.typography.sizeMd, textAlign: 'center' }}>\n {label}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignSelf: 'stretch',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import type { ReactNode } from 'react';\nimport { type StyleProp, Text, type TextProps, type TextStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport type LabelVariant = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\nexport type LabelTone = 'default' | 'muted' | 'accent' | 'danger' | 'success' | 'warning';\n\nexport interface LabelProps {\n children?: ReactNode;\n variant?: LabelVariant;\n tone?: LabelTone;\n mono?: boolean;\n style?: StyleProp<TextStyle>;\n numberOfLines?: number;\n ellipsizeMode?: TextProps['ellipsizeMode'];\n adjustsFontSizeToFit?: boolean;\n minimumFontScale?: number;\n}\n\nexport function Label({\n children,\n variant = 'md',\n tone = 'default',\n mono = false,\n style,\n numberOfLines,\n ellipsizeMode,\n adjustsFontSizeToFit,\n minimumFontScale,\n}: LabelProps): ReactNode {\n const theme = useTheme();\n const sizeMap = {\n xs: theme.typography.sizeXs,\n sm: theme.typography.sizeSm,\n md: theme.typography.sizeMd,\n lg: theme.typography.sizeLg,\n xl: theme.typography.sizeXl,\n };\n const toneMap = {\n default: theme.colors.text,\n muted: theme.colors.textMuted,\n accent: theme.colors.accent,\n danger: theme.colors.danger,\n success: theme.colors.success,\n warning: theme.colors.warning,\n };\n\n const base: TextStyle = {\n color: toneMap[tone],\n fontSize: sizeMap[variant],\n fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily,\n };\n\n return (\n <Text\n numberOfLines={numberOfLines}\n ellipsizeMode={ellipsizeMode}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n minimumFontScale={minimumFontScale}\n style={[base, style]}\n >\n {children}\n </Text>\n );\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface PanelProps {\n children?: ReactNode;\n /** Visual style: surface (default) or elevated (surfaceAlt + border). */\n variant?: 'surface' | 'elevated';\n /** Padding size token. Defaults to 'md'. */\n padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Corner radius token. Defaults to 'md'. */\n radius?: 'none' | 'sm' | 'md' | 'lg' | 'pill';\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Panel({\n children,\n variant = 'surface',\n padding = 'md',\n radius = 'md',\n style,\n}: PanelProps): ReactNode {\n const theme = useTheme();\n const bg = variant === 'elevated' ? theme.colors.surfaceAlt : theme.colors.surface;\n const pad = padding === 'none' ? 0 : theme.spacing[padding];\n const r = theme.radii[radius];\n\n const base: ViewStyle = {\n backgroundColor: bg,\n padding: pad,\n borderRadius: r,\n borderWidth: variant === 'elevated' ? 1 : 0,\n borderColor: theme.colors.border,\n };\n\n return <View style={[base, style]}>{children}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button } from './button.js';\nimport { Label } from './label.js';\nimport { Panel } from './panel.js';\nimport { useTheme } from './theme.js';\n\nexport interface DialogueChoice {\n /** Display label (already localized by the caller). */\n readonly label: string;\n /** Called when the player selects this choice. */\n readonly onPress: () => void;\n readonly disabled?: boolean;\n}\n\nexport interface DialoguePanelProps {\n /** Speaker name — rendered above the text. */\n readonly speaker: string;\n /** Line text — rendered in the body. */\n readonly text: string;\n /**\n * Portrait node. Typically an `<Image>` or a Skia/shape avatar keyed by\n * `LineNode.speakerPortraitKey`. When omitted, the portrait slot collapses.\n */\n readonly portrait?: ReactNode;\n /**\n * Optional choices. When present, renders a `Button` per option; when\n * absent, the panel tap-advances via `onAdvance`.\n */\n readonly choices?: readonly DialogueChoice[];\n /** Advance callback — used only when `choices` is empty / omitted. */\n readonly onAdvance?: () => void;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`\n * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your\n * portrait resolver → `portrait` here.\n *\n * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.\n */\nexport function DialoguePanel({\n speaker,\n text,\n portrait,\n choices,\n onAdvance,\n style,\n}: DialoguePanelProps): ReactNode {\n const theme = useTheme();\n const body = (\n <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>\n {portrait !== undefined ? (\n <View style={{ marginRight: theme.spacing.md }}>{portrait}</View>\n ) : null}\n <View style={{ flex: 1 }}>\n <Label variant=\"sm\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {speaker}\n </Label>\n <Label variant=\"md\">{text}</Label>\n {choices && choices.length > 0 ? (\n <View style={{ marginTop: theme.spacing.md }}>\n {choices.map((c, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: static choice list, never reordered\n <View key={`${c.label}-${i}`} style={{ marginTop: i === 0 ? 0 : theme.spacing.xs }}>\n <Button\n label={c.label}\n onPress={c.onPress}\n disabled={c.disabled}\n variant=\"secondary\"\n />\n </View>\n ))}\n </View>\n ) : null}\n </View>\n </View>\n );\n\n if (choices && choices.length > 0) {\n return (\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n );\n }\n\n return (\n <Pressable onPress={onAdvance}>\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n </Pressable>\n );\n}\n","import { createElement, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { createFocusManager, type FocusManager } from './focus.js';\nimport { FocusContext, type FocusContextValue } from './focus-context.js';\n\nexport interface FocusProviderProps {\n manager?: FocusManager;\n /**\n * Opt-in initial focus: focus the tab-order first node once, at the commit\n * where this provider mounts. Off by default so a touch-first tree shows no\n * focus ring until a driver acts. This is mount-time only — it picks among the\n * nodes registered by that first commit and does not re-fire for children that\n * mount later (async/lazy sets). For a dynamic set drive focus explicitly\n * (a keyboard/gamepad driver, or manager.focusFirst()).\n */\n autoFocus?: boolean;\n children: ReactNode;\n}\n\n/**\n * Instantiates a FocusManager (or uses the one provided) and publishes\n * { manager, focusedId } as context state so consumers re-render on focus\n * moves.\n */\nexport function FocusProvider({ manager, autoFocus, children }: FocusProviderProps): ReactNode {\n const [mgr] = useState<FocusManager>(() => manager ?? createFocusManager());\n const [focusedId, setFocusedId] = useState<string | null>(() => mgr.getFocused());\n\n useEffect(() => {\n setFocusedId(mgr.getFocused());\n return mgr.subscribe((id) => {\n setFocusedId(id);\n });\n }, [mgr]);\n\n useEffect(() => {\n // Child register effects run before this parent effect, so every node is\n // registered here → focusFirst() picks the true tab-order first.\n if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();\n }, [autoFocus, mgr]);\n\n const value = useMemo<FocusContextValue>(() => ({ manager: mgr, focusedId }), [mgr, focusedId]);\n\n return createElement(FocusContext.Provider, { value }, children);\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ProgressBarProps {\n /** Progress in [0, 1]. Values outside are clamped. */\n value: number;\n /** Height of the bar in pixels. */\n height?: number;\n /** Track color override. Defaults to theme.colors.surfaceAlt. */\n trackColor?: string;\n /** Fill color override. Defaults to theme.colors.accent. */\n fillColor?: string;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function ProgressBar({\n value,\n height = 8,\n trackColor,\n fillColor,\n style,\n}: ProgressBarProps): ReactNode {\n const theme = useTheme();\n const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));\n const r = theme.radii.sm;\n\n return (\n <View\n style={[\n {\n height,\n borderRadius: r,\n backgroundColor: trackColor ?? theme.colors.surfaceAlt,\n overflow: 'hidden',\n },\n style,\n ]}\n >\n <View\n style={{\n width: `${clamped * 100}%`,\n height: '100%',\n backgroundColor: fillColor ?? theme.colors.accent,\n }}\n />\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { View } from 'react-native';\nimport { Label } from './label.js';\nimport { ProgressBar } from './progress-bar.js';\nimport { useTheme } from './theme.js';\n\nexport type HUDBarKind = 'hp' | 'mp' | 'xp' | 'custom';\n\nexport interface HUDBarProps {\n label: string;\n value: number;\n max: number;\n kind?: HUDBarKind;\n /** When true, shows \"value / max\" next to the label. */\n showNumbers?: boolean;\n /** Override bar fill color. */\n fillColor?: string;\n}\n\nexport function HUDBar({\n label,\n value,\n max,\n kind = 'custom',\n showNumbers = true,\n fillColor,\n}: HUDBarProps): ReactNode {\n const theme = useTheme();\n const ratio = max <= 0 ? 0 : value / max;\n\n let color = fillColor;\n if (!color) {\n switch (kind) {\n case 'hp':\n color = theme.colors.danger;\n break;\n case 'mp':\n color = theme.colors.accent;\n break;\n case 'xp':\n color = theme.colors.success;\n break;\n default:\n color = theme.colors.accent;\n }\n }\n\n return (\n <View>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n marginBottom: theme.spacing.xs,\n }}\n >\n <Label variant=\"sm\" tone=\"muted\">\n {label}\n </Label>\n {showNumbers && (\n <Label variant=\"sm\" tone=\"muted\" mono>\n {`${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`}\n </Label>\n )}\n </View>\n <ProgressBar value={ratio} fillColor={color} />\n </View>\n );\n}\n","/**\n * Minimal flex-like layout resolver.\n *\n * Computes positions + sizes for a single container + its direct children.\n * Supports row/column direction, gap, padding, main-axis `justifyContent`,\n * cross-axis `alignItems`, and per-child `grow` / `basis` / fixed size.\n *\n * Pure function — callers use it to drive their own renderer. React Native\n * already does its own flex, so this is primarily for Skia-rendered HUD /\n * menu layouts that need deterministic pixel positions.\n */\n\nexport type FlexDirection = 'row' | 'column';\nexport type JustifyContent =\n | 'start'\n | 'end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\nexport type AlignItems = 'start' | 'end' | 'center' | 'stretch';\n\nexport interface Padding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface LayoutChild {\n /** Fixed main-axis size. Ignored when `grow > 0`. */\n basis?: number;\n /** Fractional share of leftover main-axis space. */\n grow?: number;\n /** Fixed cross-axis size. Overrides stretch. */\n crossSize?: number;\n}\n\nexport interface LayoutContainer {\n width: number;\n height: number;\n direction: FlexDirection;\n gap?: number;\n padding?: Partial<Padding>;\n justifyContent?: JustifyContent;\n alignItems?: AlignItems;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst ZERO_PAD: Padding = { top: 0, right: 0, bottom: 0, left: 0 };\n\nfunction resolvePadding(p: Partial<Padding> | undefined): Padding {\n if (!p) return ZERO_PAD;\n return {\n top: p.top ?? 0,\n right: p.right ?? 0,\n bottom: p.bottom ?? 0,\n left: p.left ?? 0,\n };\n}\n\nexport function resolveLayout(\n container: LayoutContainer,\n children: readonly LayoutChild[],\n): LayoutRect[] {\n const n = children.length;\n if (n === 0) return [];\n\n const pad = resolvePadding(container.padding);\n const gap = container.gap ?? 0;\n const isRow = container.direction === 'row';\n const mainSize =\n (isRow ? container.width : container.height) -\n (isRow ? pad.left + pad.right : pad.top + pad.bottom);\n const crossSize =\n (isRow ? container.height : container.width) -\n (isRow ? pad.top + pad.bottom : pad.left + pad.right);\n const mainStart = isRow ? pad.left : pad.top;\n const crossStart = isRow ? pad.top : pad.left;\n const justify = container.justifyContent ?? 'start';\n const align = container.alignItems ?? 'stretch';\n const totalGap = gap * Math.max(0, n - 1);\n\n let totalBasis = 0;\n let totalGrow = 0;\n for (const c of children) {\n totalBasis += c.basis ?? 0;\n totalGrow += c.grow ?? 0;\n }\n\n const leftover = mainSize - totalBasis - totalGap;\n const sizes: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const base = c.basis ?? 0;\n const growShare = totalGrow > 0 ? ((c.grow ?? 0) / totalGrow) * Math.max(0, leftover) : 0;\n sizes[i] = Math.max(0, base + growShare);\n }\n\n const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;\n const free = Math.max(0, mainSize - used);\n\n let cursor = mainStart;\n let spacing = gap;\n switch (justify) {\n case 'start':\n break;\n case 'end':\n cursor = mainStart + free;\n break;\n case 'center':\n cursor = mainStart + free / 2;\n break;\n case 'space-between':\n if (n > 1) spacing = gap + free / (n - 1);\n break;\n case 'space-around':\n if (n > 0) {\n const s = free / n;\n cursor = mainStart + s / 2;\n spacing = gap + s;\n }\n break;\n case 'space-evenly':\n if (n >= 0) {\n const s = free / (n + 1);\n cursor = mainStart + s;\n spacing = gap + s;\n }\n break;\n }\n\n const out: LayoutRect[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const mainLen = sizes[i] as number;\n const crossLen = c.crossSize !== undefined ? c.crossSize : align === 'stretch' ? crossSize : 0;\n\n let crossOffset: number;\n switch (align) {\n case 'start':\n crossOffset = 0;\n break;\n case 'end':\n crossOffset = crossSize - crossLen;\n break;\n case 'center':\n crossOffset = (crossSize - crossLen) / 2;\n break;\n case 'stretch':\n crossOffset = 0;\n break;\n }\n\n const x = isRow ? cursor : crossStart + crossOffset;\n const y = isRow ? crossStart + crossOffset : cursor;\n const w = isRow ? mainLen : crossLen;\n const h = isRow ? crossLen : mainLen;\n\n out[i] = { x, y, width: w, height: h };\n cursor += mainLen + spacing;\n }\n\n return out;\n}\n","import { Children, Fragment, type ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ListProps {\n children?: ReactNode;\n /** Gap between items in pixels. Defaults to theme.spacing.sm. */\n gap?: number;\n direction?: 'column' | 'row';\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Vertical (or horizontal) stack with consistent gap. Thin container; the\n * focus manager handles navigation between interactive children.\n */\nexport function List({ children, gap, direction = 'column', style }: ListProps): ReactNode {\n const theme = useTheme();\n const g = gap ?? theme.spacing.sm;\n\n const items: ReactNode[] = [];\n let i = 0;\n // `Children.toArray` flattens nested arrays (e.g. a `{items.map(...)}` child\n // sitting alongside JSX siblings) and drops null/undefined/boolean, unlike a\n // manual `Array.isArray` split which only unwraps one level.\n const flat = Children.toArray(children);\n for (const child of flat) {\n if (i > 0) {\n const spacerStyle: ViewStyle = direction === 'row' ? { width: g } : { height: g };\n items.push(<View key={`s-${i}`} style={spacerStyle} />);\n }\n items.push(<Fragment key={`i-${i}`}>{child}</Fragment>);\n i++;\n }\n\n return <View style={[{ flexDirection: direction }, style]}>{items}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button, type ButtonVariant } from './button.js';\nimport { Label } from './label.js';\nimport { useTheme } from './theme.js';\n\nexport interface MainMenuItem {\n /** Stable id — used as focus id + React key. */\n readonly id: string;\n /** Localized label. */\n readonly label: string;\n readonly onPress: () => void;\n readonly variant?: ButtonVariant;\n readonly disabled?: boolean;\n}\n\nexport interface MainMenuKitProps {\n /** Localized title. */\n readonly title: string;\n /** Optional localized subtitle — tagline, version, locale flag, etc. */\n readonly subtitle?: string;\n /** Button list. Rendered top-to-bottom in order. */\n readonly items: readonly MainMenuItem[];\n /**\n * Optional footer slot — typically a row of ghost buttons (credits, links)\n * or a version/build string.\n */\n readonly footer?: ReactNode;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Title-screen kit: headline, optional subtitle, vertical button list,\n * optional footer slot. All strings are caller-supplied (localized upstream).\n *\n * Save-slot / settings / credits panels are built on top of this kit by the\n * consumer; the kit itself is a pure title-menu primitive.\n */\nexport function MainMenuKit({\n title,\n subtitle,\n items,\n footer,\n style,\n}: MainMenuKitProps): ReactNode {\n const theme = useTheme();\n return (\n <View\n style={[\n {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing.lg,\n },\n style,\n ]}\n >\n <Label variant=\"xl\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {title}\n </Label>\n {subtitle !== undefined ? (\n <Label variant=\"sm\" tone=\"muted\" style={{ marginBottom: theme.spacing.lg }}>\n {subtitle}\n </Label>\n ) : (\n <View style={{ height: theme.spacing.lg }} />\n )}\n <View style={{ alignSelf: 'stretch', maxWidth: 320, width: '100%' }}>\n {items.map((item, i) => (\n <View key={item.id} style={{ marginTop: i === 0 ? 0 : theme.spacing.sm }}>\n <Button\n label={item.label}\n onPress={item.onPress}\n variant={item.variant ?? 'primary'}\n disabled={item.disabled}\n focusId={item.id}\n tabIndex={i}\n />\n </View>\n ))}\n </View>\n {footer !== undefined ? <View style={{ marginTop: theme.spacing.lg }}>{footer}</View> : null}\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, View } from 'react-native';\nimport { Panel } from './panel.js';\n\nexport interface ModalProps {\n visible: boolean;\n children?: ReactNode;\n /** Called when the backdrop is pressed. Return nothing to close, or do nothing to make it non-dismissable. */\n onBackdropPress?: () => void;\n /** Backdrop opacity 0..1. Defaults to 0.6. */\n backdropOpacity?: number;\n}\n\n/**\n * Overlay modal that renders a centered `Panel` with its children. Parent is\n * responsible for controlling visibility and (if desired) focus trapping via\n * the shared FocusManager.\n */\nexport function Modal({\n visible,\n children,\n onBackdropPress,\n backdropOpacity = 0.6,\n}: ModalProps): ReactNode {\n if (!visible) return null;\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n }}\n pointerEvents=\"box-none\"\n >\n <Pressable\n onPress={onBackdropPress}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: `rgba(0,0,0,${backdropOpacity})`,\n }}\n />\n <Panel variant=\"elevated\" padding=\"lg\" style={{ minWidth: 240, maxWidth: '80%' }}>\n {children}\n </Panel>\n </View>\n );\n}\n"],"mappings":";;;;;;AAQA,MAAa,gBAAA,GAAeA,MAAAA,cAAAA,CAAwC,IAAI;AAExE,SAAgB,kBAAuC;CACrD,MAAM,OAAA,GAAMC,MAAAA,WAAAA,CAAW,YAAY;CACnC,OAAO,MAAM,IAAI,UAAU;AAC7B;AAEA,SAAgB,eAA8B;CAC5C,MAAM,OAAA,GAAMA,MAAAA,WAAAA,CAAW,YAAY;CACnC,OAAO,MAAM,IAAI,YAAY;AAC/B;;ACiCA,MAAa,YAAmB;CAC9B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CAChD,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV;CACA,OAAO;EAAE,MAAM;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,MAAM;CAAK;AACrD;AAEA,MAAa,aAAoB;CAC/B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CAChD,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV;CACA,OAAO;EAAE,MAAM;EAAG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O,EAAE,WAAW,MAAM,QAAQ,GAAG;IAAI,UAAA;GAAa,CAAA,IAAI;EACpF;;AAEV;;;;;;;ACnEA,SAAgB,MAAM,EACpB,SACA,UACA,iBACA,kBAAkB,MACM;CACxB,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACC,aAAAA,MAAD;EACE,OAAO;GACL,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,YAAY;GACZ,gBAAgB;EAClB;EACA,eAAc;EAVhB,UAAA,CAYE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,WAAD;GACE,SAAS;GACT,OAAO;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,iBAAiB,cAAc,gBAAgB;GACjD;EACD,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAO,SAAQ;GAAW,SAAQ;GAAK,OAAO;IAAE,UAAU;IAAK,UAAU;GAAM;GAC5E;EACI,CAAA,CACH;;AAEV"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","useContext","createContext","createElement","useContext","useId","useRef","Pressable","View","Text","StyleSheet","Text","View","View","Pressable","useState","createFocusManager","useMemo","createElement","View","View","Children","View","Fragment","View","View","Pressable"],"sources":["../src/focus-context.ts","../src/theme.ts","../src/button.tsx","../src/label.tsx","../src/panel.tsx","../src/dialogue-panel.tsx","../src/focus-provider.tsx","../src/progress-bar.tsx","../src/hud-bar.tsx","../src/layout.ts","../src/list.tsx","../src/main-menu-kit.tsx","../src/modal.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { FocusManager } from './focus.js';\n\nexport interface FocusContextValue {\n manager: FocusManager;\n focusedId: string | null;\n}\n\nexport const FocusContext = createContext<FocusContextValue | null>(null);\n\nexport function useFocusManager(): FocusManager | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.manager : null;\n}\n\nexport function useFocusedId(): string | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.focusedId : null;\n}\n","import { createContext, createElement, type ReactNode, useContext } from 'react';\n\nexport interface ThemeColors {\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n accent: string;\n accentText: string;\n danger: string;\n success: string;\n warning: string;\n focus: string;\n}\n\nexport interface ThemeSpacing {\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n}\n\nexport interface ThemeTypography {\n sizeXs: number;\n sizeSm: number;\n sizeMd: number;\n sizeLg: number;\n sizeXl: number;\n fontFamily?: string;\n fontFamilyMono?: string;\n}\n\nexport interface ThemeRadii {\n none: number;\n sm: number;\n md: number;\n lg: number;\n pill: number;\n}\n\nexport interface Theme {\n name: string;\n colors: ThemeColors;\n spacing: ThemeSpacing;\n typography: ThemeTypography;\n radii: ThemeRadii;\n}\n\nexport const darkTheme: Theme = {\n name: 'dark',\n colors: {\n bg: '#0b0d10',\n surface: '#14181d',\n surfaceAlt: '#1d232b',\n border: '#2a323c',\n text: '#e7ecf1',\n textMuted: '#8c96a3',\n accent: '#4aa3ff',\n accentText: '#0b0d10',\n danger: '#ff5c5c',\n success: '#5dd39e',\n warning: '#f1c40f',\n focus: '#ffd166',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nexport const lightTheme: Theme = {\n name: 'light',\n colors: {\n bg: '#f6f8fa',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#d4dae0',\n text: '#13181d',\n textMuted: '#5b6670',\n accent: '#0a66d0',\n accentText: '#ffffff',\n danger: '#d12e2e',\n success: '#2f9d69',\n warning: '#c79600',\n focus: '#ff9500',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nconst ThemeContext = createContext<Theme>(darkTheme);\n\nexport interface ThemeProviderProps {\n theme?: Theme;\n children: ReactNode;\n}\n\nexport function ThemeProvider({ theme = darkTheme, children }: ThemeProviderProps): ReactNode {\n return createElement(ThemeContext.Provider, { value: theme }, children);\n}\n\nexport function useTheme(): Theme {\n return useContext(ThemeContext);\n}\n","import { type ReactNode, useEffect, useId, useRef } from 'react';\nimport { Pressable, type StyleProp, StyleSheet, Text, View, type ViewStyle } from 'react-native';\nimport { useFocusedId, useFocusManager } from './focus-context.js';\nimport { useTheme } from './theme.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';\n\nexport interface ButtonProps {\n label: string;\n onPress?: () => void;\n variant?: ButtonVariant;\n disabled?: boolean;\n /** Focus-navigation tab order. Lower is earlier. Defaults to 0. */\n tabIndex?: number;\n /** Stable focus id. If omitted, a generated id is used. */\n focusId?: string;\n /**\n * Move focus to this button when it is pressed. Defaults to `true`. Set\n * `false` on touch-first screens so a tap leaves no focus ring behind;\n * `onPress` still fires.\n */\n focusOnPress?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Button({\n label,\n onPress,\n variant = 'primary',\n disabled = false,\n tabIndex = 0,\n focusId,\n focusOnPress = true,\n style,\n}: ButtonProps): ReactNode {\n const theme = useTheme();\n const manager = useFocusManager();\n const focusedId = useFocusedId();\n const generated = useId();\n const id = focusId ?? generated;\n\n const latest = useRef({ onPress, disabled, tabIndex });\n latest.current = { onPress, disabled, tabIndex };\n const activateRef = useRef(() => {\n const { onPress: press, disabled: off } = latest.current;\n if (!off) press?.();\n });\n\n // Register once per (manager, id) and own the disposer; prop changes below\n // re-register in place so focus and tab order survive parent re-renders.\n useEffect(() => {\n if (!manager) return;\n const { tabIndex: order, disabled: off } = latest.current;\n return manager.register({\n id,\n tabIndex: order,\n disabled: off,\n onActivate: activateRef.current,\n });\n }, [manager, id]);\n\n useEffect(() => {\n if (!manager) return;\n manager.register({ id, tabIndex, disabled, onActivate: activateRef.current });\n }, [manager, id, tabIndex, disabled]);\n\n const focused = focusedId === id;\n\n let bg = theme.colors.surface;\n let fg = theme.colors.text;\n let border = theme.colors.border;\n switch (variant) {\n case 'primary':\n bg = theme.colors.accent;\n fg = theme.colors.accentText;\n border = theme.colors.accent;\n break;\n case 'secondary':\n bg = theme.colors.surfaceAlt;\n fg = theme.colors.text;\n border = theme.colors.border;\n break;\n case 'ghost':\n bg = 'transparent';\n fg = theme.colors.text;\n border = 'transparent';\n break;\n case 'danger':\n bg = theme.colors.danger;\n fg = theme.colors.accentText;\n border = theme.colors.danger;\n break;\n }\n\n const container: ViewStyle = {\n backgroundColor: bg,\n borderColor: focused ? theme.colors.focus : border,\n borderWidth: focused ? 2 : 1,\n borderRadius: theme.radii.md,\n paddingHorizontal: theme.spacing.md,\n paddingVertical: theme.spacing.sm,\n opacity: disabled ? 0.5 : 1,\n };\n\n return (\n <Pressable\n onPress={() => {\n if (disabled) return;\n if (focusOnPress) manager?.focus(id);\n onPress?.();\n }}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled, selected: focused }}\n style={[styles.wrap, container, style]}\n >\n <View>\n <Text style={{ color: fg, fontSize: theme.typography.sizeMd, textAlign: 'center' }}>\n {label}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignSelf: 'stretch',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import type { ReactNode } from 'react';\nimport { type StyleProp, Text, type TextProps, type TextStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport type LabelVariant = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\nexport type LabelTone = 'default' | 'muted' | 'accent' | 'danger' | 'success' | 'warning';\n\nexport interface LabelProps {\n children?: ReactNode;\n variant?: LabelVariant;\n tone?: LabelTone;\n mono?: boolean;\n style?: StyleProp<TextStyle>;\n numberOfLines?: number;\n ellipsizeMode?: TextProps['ellipsizeMode'];\n adjustsFontSizeToFit?: boolean;\n minimumFontScale?: number;\n}\n\nexport function Label({\n children,\n variant = 'md',\n tone = 'default',\n mono = false,\n style,\n numberOfLines,\n ellipsizeMode,\n adjustsFontSizeToFit,\n minimumFontScale,\n}: LabelProps): ReactNode {\n const theme = useTheme();\n const sizeMap = {\n xs: theme.typography.sizeXs,\n sm: theme.typography.sizeSm,\n md: theme.typography.sizeMd,\n lg: theme.typography.sizeLg,\n xl: theme.typography.sizeXl,\n };\n const toneMap = {\n default: theme.colors.text,\n muted: theme.colors.textMuted,\n accent: theme.colors.accent,\n danger: theme.colors.danger,\n success: theme.colors.success,\n warning: theme.colors.warning,\n };\n\n const base: TextStyle = {\n color: toneMap[tone],\n fontSize: sizeMap[variant],\n fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily,\n };\n\n return (\n <Text\n numberOfLines={numberOfLines}\n ellipsizeMode={ellipsizeMode}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n minimumFontScale={minimumFontScale}\n style={[base, style]}\n >\n {children}\n </Text>\n );\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface PanelProps {\n children?: ReactNode;\n /** Visual style: surface (default) or elevated (surfaceAlt + border). */\n variant?: 'surface' | 'elevated';\n /** Padding size token. Defaults to 'md'. */\n padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Corner radius token. Defaults to 'md'. */\n radius?: 'none' | 'sm' | 'md' | 'lg' | 'pill';\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Panel({\n children,\n variant = 'surface',\n padding = 'md',\n radius = 'md',\n style,\n}: PanelProps): ReactNode {\n const theme = useTheme();\n const bg = variant === 'elevated' ? theme.colors.surfaceAlt : theme.colors.surface;\n const pad = padding === 'none' ? 0 : theme.spacing[padding];\n const r = theme.radii[radius];\n\n const base: ViewStyle = {\n backgroundColor: bg,\n padding: pad,\n borderRadius: r,\n borderWidth: variant === 'elevated' ? 1 : 0,\n borderColor: theme.colors.border,\n };\n\n return <View style={[base, style]}>{children}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button } from './button.js';\nimport { Label } from './label.js';\nimport { Panel } from './panel.js';\nimport { useTheme } from './theme.js';\n\nexport interface DialogueChoice {\n /** Display label (already localized by the caller). */\n readonly label: string;\n /** Called when the player selects this choice. */\n readonly onPress: () => void;\n readonly disabled?: boolean;\n}\n\nexport interface DialoguePanelProps {\n /** Speaker name — rendered above the text. */\n readonly speaker: string;\n /** Line text — rendered in the body. */\n readonly text: string;\n /**\n * Portrait node. Typically an `<Image>` or a Skia/shape avatar keyed by\n * `LineNode.speakerPortraitKey`. When omitted, the portrait slot collapses.\n */\n readonly portrait?: ReactNode;\n /**\n * Optional choices. When present, renders a `Button` per option; when\n * absent, the panel tap-advances via `onAdvance`.\n */\n readonly choices?: readonly DialogueChoice[];\n /** Advance callback — used only when `choices` is empty / omitted. */\n readonly onAdvance?: () => void;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`\n * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your\n * portrait resolver → `portrait` here.\n *\n * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.\n */\nexport function DialoguePanel({\n speaker,\n text,\n portrait,\n choices,\n onAdvance,\n style,\n}: DialoguePanelProps): ReactNode {\n const theme = useTheme();\n const body = (\n <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>\n {portrait !== undefined ? (\n <View style={{ marginRight: theme.spacing.md }}>{portrait}</View>\n ) : null}\n <View style={{ flex: 1 }}>\n <Label variant=\"sm\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {speaker}\n </Label>\n <Label variant=\"md\">{text}</Label>\n {choices && choices.length > 0 ? (\n <View style={{ marginTop: theme.spacing.md }}>\n {choices.map((c, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: static choice list, never reordered\n <View key={`${c.label}-${i}`} style={{ marginTop: i === 0 ? 0 : theme.spacing.xs }}>\n <Button\n label={c.label}\n onPress={c.onPress}\n disabled={c.disabled}\n variant=\"secondary\"\n />\n </View>\n ))}\n </View>\n ) : null}\n </View>\n </View>\n );\n\n if (choices && choices.length > 0) {\n return (\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n );\n }\n\n return (\n <Pressable onPress={onAdvance}>\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n </Pressable>\n );\n}\n","import { createElement, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { createFocusManager, type FocusManager } from './focus.js';\nimport { FocusContext, type FocusContextValue } from './focus-context.js';\n\nexport interface FocusProviderProps {\n manager?: FocusManager;\n /**\n * Opt-in initial focus: focus the tab-order first node once, at the commit\n * where this provider mounts. Off by default so a touch-first tree shows no\n * focus ring until a driver acts. This is mount-time only — it picks among the\n * nodes registered by that first commit and does not re-fire for children that\n * mount later (async/lazy sets). For a dynamic set drive focus explicitly\n * (a keyboard/gamepad driver, or manager.focusFirst()).\n */\n autoFocus?: boolean;\n children: ReactNode;\n}\n\n/**\n * Instantiates a FocusManager (or uses the one provided) and publishes\n * { manager, focusedId } as context state so consumers re-render on focus\n * moves.\n */\nexport function FocusProvider({ manager, autoFocus, children }: FocusProviderProps): ReactNode {\n const [mgr] = useState<FocusManager>(() => manager ?? createFocusManager());\n const [focusedId, setFocusedId] = useState<string | null>(() => mgr.getFocused());\n\n useEffect(() => {\n setFocusedId(mgr.getFocused());\n return mgr.subscribe((id) => {\n setFocusedId(id);\n });\n }, [mgr]);\n\n useEffect(() => {\n // Child register effects run before this parent effect, so every node is\n // registered here → focusFirst() picks the true tab-order first.\n if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();\n }, [autoFocus, mgr]);\n\n const value = useMemo<FocusContextValue>(() => ({ manager: mgr, focusedId }), [mgr, focusedId]);\n\n return createElement(FocusContext.Provider, { value }, children);\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ProgressBarProps {\n /** Progress in [0, 1]. Values outside are clamped. */\n value: number;\n /** Height of the bar in pixels. */\n height?: number;\n /** Track color override. Defaults to theme.colors.surfaceAlt. */\n trackColor?: string;\n /** Fill color override. Defaults to theme.colors.accent. */\n fillColor?: string;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function ProgressBar({\n value,\n height = 8,\n trackColor,\n fillColor,\n style,\n}: ProgressBarProps): ReactNode {\n const theme = useTheme();\n const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));\n const r = theme.radii.sm;\n\n return (\n <View\n style={[\n {\n height,\n borderRadius: r,\n backgroundColor: trackColor ?? theme.colors.surfaceAlt,\n overflow: 'hidden',\n },\n style,\n ]}\n >\n <View\n style={{\n width: `${clamped * 100}%`,\n height: '100%',\n backgroundColor: fillColor ?? theme.colors.accent,\n }}\n />\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { View } from 'react-native';\nimport { Label } from './label.js';\nimport { ProgressBar } from './progress-bar.js';\nimport { useTheme } from './theme.js';\n\nexport type HUDBarKind = 'hp' | 'mp' | 'xp' | 'custom';\n\nexport interface HUDBarProps {\n label: string;\n value: number;\n max: number;\n kind?: HUDBarKind;\n /** When true, shows \"value / max\" next to the label. */\n showNumbers?: boolean;\n /** Override bar fill color. */\n fillColor?: string;\n}\n\nexport function HUDBar({\n label,\n value,\n max,\n kind = 'custom',\n showNumbers = true,\n fillColor,\n}: HUDBarProps): ReactNode {\n const theme = useTheme();\n const ratio = max <= 0 ? 0 : value / max;\n\n let color = fillColor;\n if (!color) {\n switch (kind) {\n case 'hp':\n color = theme.colors.danger;\n break;\n case 'mp':\n color = theme.colors.accent;\n break;\n case 'xp':\n color = theme.colors.success;\n break;\n default:\n color = theme.colors.accent;\n }\n }\n\n return (\n <View>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n marginBottom: theme.spacing.xs,\n }}\n >\n <Label variant=\"sm\" tone=\"muted\">\n {label}\n </Label>\n {showNumbers && (\n <Label variant=\"sm\" tone=\"muted\" mono>\n {`${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`}\n </Label>\n )}\n </View>\n <ProgressBar value={ratio} fillColor={color} />\n </View>\n );\n}\n","/**\n * Minimal flex-like layout resolver.\n *\n * Computes positions + sizes for a single container + its direct children.\n * Supports row/column direction, gap, padding, main-axis `justifyContent`,\n * cross-axis `alignItems`, and per-child `grow` / `basis` / fixed size.\n *\n * Pure function — callers use it to drive their own renderer. React Native\n * already does its own flex, so this is primarily for Skia-rendered HUD /\n * menu layouts that need deterministic pixel positions.\n */\n\nexport type FlexDirection = 'row' | 'column';\nexport type JustifyContent =\n | 'start'\n | 'end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\nexport type AlignItems = 'start' | 'end' | 'center' | 'stretch';\n\nexport interface Padding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface LayoutChild {\n /** Fixed main-axis size. Ignored when `grow > 0`. */\n basis?: number;\n /** Fractional share of leftover main-axis space. */\n grow?: number;\n /** Fixed cross-axis size. Overrides stretch. */\n crossSize?: number;\n}\n\nexport interface LayoutContainer {\n width: number;\n height: number;\n direction: FlexDirection;\n gap?: number;\n padding?: Partial<Padding>;\n justifyContent?: JustifyContent;\n alignItems?: AlignItems;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst ZERO_PAD: Padding = { top: 0, right: 0, bottom: 0, left: 0 };\n\nfunction resolvePadding(p: Partial<Padding> | undefined): Padding {\n if (!p) return ZERO_PAD;\n return {\n top: p.top ?? 0,\n right: p.right ?? 0,\n bottom: p.bottom ?? 0,\n left: p.left ?? 0,\n };\n}\n\nexport function resolveLayout(\n container: LayoutContainer,\n children: readonly LayoutChild[],\n): LayoutRect[] {\n const n = children.length;\n if (n === 0) return [];\n\n const pad = resolvePadding(container.padding);\n const gap = container.gap ?? 0;\n const isRow = container.direction === 'row';\n const mainSize =\n (isRow ? container.width : container.height) -\n (isRow ? pad.left + pad.right : pad.top + pad.bottom);\n const crossSize =\n (isRow ? container.height : container.width) -\n (isRow ? pad.top + pad.bottom : pad.left + pad.right);\n const mainStart = isRow ? pad.left : pad.top;\n const crossStart = isRow ? pad.top : pad.left;\n const justify = container.justifyContent ?? 'start';\n const align = container.alignItems ?? 'stretch';\n const totalGap = gap * Math.max(0, n - 1);\n\n let totalBasis = 0;\n let totalGrow = 0;\n for (const c of children) {\n totalBasis += c.basis ?? 0;\n totalGrow += c.grow ?? 0;\n }\n\n const leftover = mainSize - totalBasis - totalGap;\n const sizes: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const base = c.basis ?? 0;\n const growShare = totalGrow > 0 ? ((c.grow ?? 0) / totalGrow) * Math.max(0, leftover) : 0;\n sizes[i] = Math.max(0, base + growShare);\n }\n\n const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;\n const free = Math.max(0, mainSize - used);\n\n let cursor = mainStart;\n let spacing = gap;\n switch (justify) {\n case 'start':\n break;\n case 'end':\n cursor = mainStart + free;\n break;\n case 'center':\n cursor = mainStart + free / 2;\n break;\n case 'space-between':\n if (n > 1) spacing = gap + free / (n - 1);\n break;\n case 'space-around':\n if (n > 0) {\n const s = free / n;\n cursor = mainStart + s / 2;\n spacing = gap + s;\n }\n break;\n case 'space-evenly':\n if (n >= 0) {\n const s = free / (n + 1);\n cursor = mainStart + s;\n spacing = gap + s;\n }\n break;\n }\n\n const out: LayoutRect[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const mainLen = sizes[i] as number;\n const crossLen = c.crossSize !== undefined ? c.crossSize : align === 'stretch' ? crossSize : 0;\n\n let crossOffset: number;\n switch (align) {\n case 'start':\n crossOffset = 0;\n break;\n case 'end':\n crossOffset = crossSize - crossLen;\n break;\n case 'center':\n crossOffset = (crossSize - crossLen) / 2;\n break;\n case 'stretch':\n crossOffset = 0;\n break;\n }\n\n const x = isRow ? cursor : crossStart + crossOffset;\n const y = isRow ? crossStart + crossOffset : cursor;\n const w = isRow ? mainLen : crossLen;\n const h = isRow ? crossLen : mainLen;\n\n out[i] = { x, y, width: w, height: h };\n cursor += mainLen + spacing;\n }\n\n return out;\n}\n","import { Children, Fragment, type ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ListProps {\n children?: ReactNode;\n /** Gap between items in pixels. Defaults to theme.spacing.sm. */\n gap?: number;\n direction?: 'column' | 'row';\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Vertical (or horizontal) stack with consistent gap. Thin container; the\n * focus manager handles navigation between interactive children.\n */\nexport function List({ children, gap, direction = 'column', style }: ListProps): ReactNode {\n const theme = useTheme();\n const g = gap ?? theme.spacing.sm;\n\n const items: ReactNode[] = [];\n let i = 0;\n // `Children.toArray` flattens nested arrays (e.g. a `{items.map(...)}` child\n // sitting alongside JSX siblings) and drops null/undefined/boolean, unlike a\n // manual `Array.isArray` split which only unwraps one level.\n const flat = Children.toArray(children);\n for (const child of flat) {\n if (i > 0) {\n const spacerStyle: ViewStyle = direction === 'row' ? { width: g } : { height: g };\n items.push(<View key={`s-${i}`} style={spacerStyle} />);\n }\n items.push(<Fragment key={`i-${i}`}>{child}</Fragment>);\n i++;\n }\n\n return <View style={[{ flexDirection: direction }, style]}>{items}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button, type ButtonVariant } from './button.js';\nimport { Label } from './label.js';\nimport { useTheme } from './theme.js';\n\nexport interface MainMenuItem {\n /** Stable id — used as focus id + React key. */\n readonly id: string;\n /** Localized label. */\n readonly label: string;\n readonly onPress: () => void;\n readonly variant?: ButtonVariant;\n readonly disabled?: boolean;\n}\n\nexport interface MainMenuKitProps {\n /** Localized title. */\n readonly title: string;\n /** Optional localized subtitle — tagline, version, locale flag, etc. */\n readonly subtitle?: string;\n /** Button list. Rendered top-to-bottom in order. */\n readonly items: readonly MainMenuItem[];\n /**\n * Optional footer slot — typically a row of ghost buttons (credits, links)\n * or a version/build string.\n */\n readonly footer?: ReactNode;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Title-screen kit: headline, optional subtitle, vertical button list,\n * optional footer slot. All strings are caller-supplied (localized upstream).\n *\n * Save-slot / settings / credits panels are built on top of this kit by the\n * consumer; the kit itself is a pure title-menu primitive.\n */\nexport function MainMenuKit({\n title,\n subtitle,\n items,\n footer,\n style,\n}: MainMenuKitProps): ReactNode {\n const theme = useTheme();\n return (\n <View\n style={[\n {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing.lg,\n },\n style,\n ]}\n >\n <Label variant=\"xl\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {title}\n </Label>\n {subtitle !== undefined ? (\n <Label variant=\"sm\" tone=\"muted\" style={{ marginBottom: theme.spacing.lg }}>\n {subtitle}\n </Label>\n ) : (\n <View style={{ height: theme.spacing.lg }} />\n )}\n <View style={{ alignSelf: 'stretch', maxWidth: 320, width: '100%' }}>\n {items.map((item, i) => (\n <View key={item.id} style={{ marginTop: i === 0 ? 0 : theme.spacing.sm }}>\n <Button\n label={item.label}\n onPress={item.onPress}\n variant={item.variant ?? 'primary'}\n disabled={item.disabled}\n focusId={item.id}\n tabIndex={i}\n />\n </View>\n ))}\n </View>\n {footer !== undefined ? <View style={{ marginTop: theme.spacing.lg }}>{footer}</View> : null}\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, View } from 'react-native';\nimport { Panel } from './panel.js';\n\nexport interface ModalProps {\n visible: boolean;\n children?: ReactNode;\n /** Called when the backdrop is pressed. Return nothing to close, or do nothing to make it non-dismissable. */\n onBackdropPress?: () => void;\n /** Backdrop opacity 0..1. Defaults to 0.6. */\n backdropOpacity?: number;\n}\n\n/**\n * Overlay modal that renders a centered `Panel` with its children. Parent is\n * responsible for controlling visibility and (if desired) focus trapping via\n * the shared FocusManager.\n */\nexport function Modal({\n visible,\n children,\n onBackdropPress,\n backdropOpacity = 0.6,\n}: ModalProps): ReactNode {\n if (!visible) return null;\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n }}\n pointerEvents=\"box-none\"\n >\n <Pressable\n onPress={onBackdropPress}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: `rgba(0,0,0,${backdropOpacity})`,\n }}\n />\n <Panel variant=\"elevated\" padding=\"lg\" style={{ minWidth: 240, maxWidth: '80%' }}>\n {children}\n </Panel>\n </View>\n );\n}\n"],"mappings":";;;;;;AAQA,MAAa,gBAAA,GAAeA,MAAAA,cAAAA,CAAwC,IAAI;AAExE,SAAgB,kBAAuC;CACrD,MAAM,OAAA,GAAMC,MAAAA,WAAAA,CAAW,YAAY;CACnC,OAAO,MAAM,IAAI,UAAU;AAC7B;AAEA,SAAgB,eAA8B;CAC5C,MAAM,OAAA,GAAMA,MAAAA,WAAAA,CAAW,YAAY;CACnC,OAAO,MAAM,IAAI,YAAY;AAC/B;;ACiCA,MAAa,YAAmB;CAC9B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;C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;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,YAAY;GACZ,gBAAgB;EAClB;EACA,eAAc;EAVhB,UAAA,CAYE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,WAAD;GACE,SAAS;GACT,OAAO;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,iBAAiB,cAAc,gBAAgB;GACjD;EACD,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAO,SAAQ;GAAW,SAAQ;GAAK,OAAO;IAAE,UAAU;IAAK,UAAU;GAAM;GAC5E;EACI,CAAA,CACH;;AAEV"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as createFocusKeyboardDriver, t as createFocusManager } from "./focus-
|
|
2
|
-
import { Children, Fragment, createContext, createElement, useContext, useEffect, useId, useMemo, useState } from "react";
|
|
1
|
+
import { n as createFocusKeyboardDriver, t as createFocusManager } from "./focus-CtmAYznc.mjs";
|
|
2
|
+
import { Children, Fragment, createContext, createElement, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/focus-context.ts
|
|
@@ -103,22 +103,43 @@ function Button({ label, onPress, variant = "primary", disabled = false, tabInde
|
|
|
103
103
|
const focusedId = useFocusedId();
|
|
104
104
|
const generated = useId();
|
|
105
105
|
const id = focusId ?? generated;
|
|
106
|
+
const latest = useRef({
|
|
107
|
+
onPress,
|
|
108
|
+
disabled,
|
|
109
|
+
tabIndex
|
|
110
|
+
});
|
|
111
|
+
latest.current = {
|
|
112
|
+
onPress,
|
|
113
|
+
disabled,
|
|
114
|
+
tabIndex
|
|
115
|
+
};
|
|
116
|
+
const activateRef = useRef(() => {
|
|
117
|
+
const { onPress: press, disabled: off } = latest.current;
|
|
118
|
+
if (!off) press?.();
|
|
119
|
+
});
|
|
106
120
|
useEffect(() => {
|
|
107
121
|
if (!manager) return;
|
|
122
|
+
const { tabIndex: order, disabled: off } = latest.current;
|
|
108
123
|
return manager.register({
|
|
124
|
+
id,
|
|
125
|
+
tabIndex: order,
|
|
126
|
+
disabled: off,
|
|
127
|
+
onActivate: activateRef.current
|
|
128
|
+
});
|
|
129
|
+
}, [manager, id]);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!manager) return;
|
|
132
|
+
manager.register({
|
|
109
133
|
id,
|
|
110
134
|
tabIndex,
|
|
111
135
|
disabled,
|
|
112
|
-
onActivate:
|
|
113
|
-
if (!disabled) onPress?.();
|
|
114
|
-
}
|
|
136
|
+
onActivate: activateRef.current
|
|
115
137
|
});
|
|
116
138
|
}, [
|
|
117
139
|
manager,
|
|
118
140
|
id,
|
|
119
141
|
tabIndex,
|
|
120
|
-
disabled
|
|
121
|
-
onPress
|
|
142
|
+
disabled
|
|
122
143
|
]);
|
|
123
144
|
const focused = focusedId === id;
|
|
124
145
|
let bg = theme.colors.surface;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/focus-context.ts","../src/theme.ts","../src/button.tsx","../src/label.tsx","../src/panel.tsx","../src/dialogue-panel.tsx","../src/focus-provider.tsx","../src/progress-bar.tsx","../src/hud-bar.tsx","../src/layout.ts","../src/list.tsx","../src/main-menu-kit.tsx","../src/modal.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { FocusManager } from './focus.js';\n\nexport interface FocusContextValue {\n manager: FocusManager;\n focusedId: string | null;\n}\n\nexport const FocusContext = createContext<FocusContextValue | null>(null);\n\nexport function useFocusManager(): FocusManager | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.manager : null;\n}\n\nexport function useFocusedId(): string | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.focusedId : null;\n}\n","import { createContext, createElement, type ReactNode, useContext } from 'react';\n\nexport interface ThemeColors {\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n accent: string;\n accentText: string;\n danger: string;\n success: string;\n warning: string;\n focus: string;\n}\n\nexport interface ThemeSpacing {\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n}\n\nexport interface ThemeTypography {\n sizeXs: number;\n sizeSm: number;\n sizeMd: number;\n sizeLg: number;\n sizeXl: number;\n fontFamily?: string;\n fontFamilyMono?: string;\n}\n\nexport interface ThemeRadii {\n none: number;\n sm: number;\n md: number;\n lg: number;\n pill: number;\n}\n\nexport interface Theme {\n name: string;\n colors: ThemeColors;\n spacing: ThemeSpacing;\n typography: ThemeTypography;\n radii: ThemeRadii;\n}\n\nexport const darkTheme: Theme = {\n name: 'dark',\n colors: {\n bg: '#0b0d10',\n surface: '#14181d',\n surfaceAlt: '#1d232b',\n border: '#2a323c',\n text: '#e7ecf1',\n textMuted: '#8c96a3',\n accent: '#4aa3ff',\n accentText: '#0b0d10',\n danger: '#ff5c5c',\n success: '#5dd39e',\n warning: '#f1c40f',\n focus: '#ffd166',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nexport const lightTheme: Theme = {\n name: 'light',\n colors: {\n bg: '#f6f8fa',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#d4dae0',\n text: '#13181d',\n textMuted: '#5b6670',\n accent: '#0a66d0',\n accentText: '#ffffff',\n danger: '#d12e2e',\n success: '#2f9d69',\n warning: '#c79600',\n focus: '#ff9500',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nconst ThemeContext = createContext<Theme>(darkTheme);\n\nexport interface ThemeProviderProps {\n theme?: Theme;\n children: ReactNode;\n}\n\nexport function ThemeProvider({ theme = darkTheme, children }: ThemeProviderProps): ReactNode {\n return createElement(ThemeContext.Provider, { value: theme }, children);\n}\n\nexport function useTheme(): Theme {\n return useContext(ThemeContext);\n}\n","import { type ReactNode, useEffect, useId } from 'react';\nimport { Pressable, type StyleProp, StyleSheet, Text, View, type ViewStyle } from 'react-native';\nimport { useFocusedId, useFocusManager } from './focus-context.js';\nimport { useTheme } from './theme.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';\n\nexport interface ButtonProps {\n label: string;\n onPress?: () => void;\n variant?: ButtonVariant;\n disabled?: boolean;\n /** Focus-navigation tab order. Lower is earlier. Defaults to 0. */\n tabIndex?: number;\n /** Stable focus id. If omitted, a generated id is used. */\n focusId?: string;\n /**\n * Move focus to this button when it is pressed. Defaults to `true`. Set\n * `false` on touch-first screens so a tap leaves no focus ring behind;\n * `onPress` still fires.\n */\n focusOnPress?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Button({\n label,\n onPress,\n variant = 'primary',\n disabled = false,\n tabIndex = 0,\n focusId,\n focusOnPress = true,\n style,\n}: ButtonProps): ReactNode {\n const theme = useTheme();\n const manager = useFocusManager();\n const focusedId = useFocusedId();\n const generated = useId();\n const id = focusId ?? generated;\n\n useEffect(() => {\n if (!manager) return;\n return manager.register({\n id,\n tabIndex,\n disabled,\n onActivate: () => {\n if (!disabled) onPress?.();\n },\n });\n }, [manager, id, tabIndex, disabled, onPress]);\n\n const focused = focusedId === id;\n\n let bg = theme.colors.surface;\n let fg = theme.colors.text;\n let border = theme.colors.border;\n switch (variant) {\n case 'primary':\n bg = theme.colors.accent;\n fg = theme.colors.accentText;\n border = theme.colors.accent;\n break;\n case 'secondary':\n bg = theme.colors.surfaceAlt;\n fg = theme.colors.text;\n border = theme.colors.border;\n break;\n case 'ghost':\n bg = 'transparent';\n fg = theme.colors.text;\n border = 'transparent';\n break;\n case 'danger':\n bg = theme.colors.danger;\n fg = theme.colors.accentText;\n border = theme.colors.danger;\n break;\n }\n\n const container: ViewStyle = {\n backgroundColor: bg,\n borderColor: focused ? theme.colors.focus : border,\n borderWidth: focused ? 2 : 1,\n borderRadius: theme.radii.md,\n paddingHorizontal: theme.spacing.md,\n paddingVertical: theme.spacing.sm,\n opacity: disabled ? 0.5 : 1,\n };\n\n return (\n <Pressable\n onPress={() => {\n if (disabled) return;\n if (focusOnPress) manager?.focus(id);\n onPress?.();\n }}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled, selected: focused }}\n style={[styles.wrap, container, style]}\n >\n <View>\n <Text style={{ color: fg, fontSize: theme.typography.sizeMd, textAlign: 'center' }}>\n {label}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignSelf: 'stretch',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import type { ReactNode } from 'react';\nimport { type StyleProp, Text, type TextProps, type TextStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport type LabelVariant = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\nexport type LabelTone = 'default' | 'muted' | 'accent' | 'danger' | 'success' | 'warning';\n\nexport interface LabelProps {\n children?: ReactNode;\n variant?: LabelVariant;\n tone?: LabelTone;\n mono?: boolean;\n style?: StyleProp<TextStyle>;\n numberOfLines?: number;\n ellipsizeMode?: TextProps['ellipsizeMode'];\n adjustsFontSizeToFit?: boolean;\n minimumFontScale?: number;\n}\n\nexport function Label({\n children,\n variant = 'md',\n tone = 'default',\n mono = false,\n style,\n numberOfLines,\n ellipsizeMode,\n adjustsFontSizeToFit,\n minimumFontScale,\n}: LabelProps): ReactNode {\n const theme = useTheme();\n const sizeMap = {\n xs: theme.typography.sizeXs,\n sm: theme.typography.sizeSm,\n md: theme.typography.sizeMd,\n lg: theme.typography.sizeLg,\n xl: theme.typography.sizeXl,\n };\n const toneMap = {\n default: theme.colors.text,\n muted: theme.colors.textMuted,\n accent: theme.colors.accent,\n danger: theme.colors.danger,\n success: theme.colors.success,\n warning: theme.colors.warning,\n };\n\n const base: TextStyle = {\n color: toneMap[tone],\n fontSize: sizeMap[variant],\n fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily,\n };\n\n return (\n <Text\n numberOfLines={numberOfLines}\n ellipsizeMode={ellipsizeMode}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n minimumFontScale={minimumFontScale}\n style={[base, style]}\n >\n {children}\n </Text>\n );\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface PanelProps {\n children?: ReactNode;\n /** Visual style: surface (default) or elevated (surfaceAlt + border). */\n variant?: 'surface' | 'elevated';\n /** Padding size token. Defaults to 'md'. */\n padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Corner radius token. Defaults to 'md'. */\n radius?: 'none' | 'sm' | 'md' | 'lg' | 'pill';\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Panel({\n children,\n variant = 'surface',\n padding = 'md',\n radius = 'md',\n style,\n}: PanelProps): ReactNode {\n const theme = useTheme();\n const bg = variant === 'elevated' ? theme.colors.surfaceAlt : theme.colors.surface;\n const pad = padding === 'none' ? 0 : theme.spacing[padding];\n const r = theme.radii[radius];\n\n const base: ViewStyle = {\n backgroundColor: bg,\n padding: pad,\n borderRadius: r,\n borderWidth: variant === 'elevated' ? 1 : 0,\n borderColor: theme.colors.border,\n };\n\n return <View style={[base, style]}>{children}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button } from './button.js';\nimport { Label } from './label.js';\nimport { Panel } from './panel.js';\nimport { useTheme } from './theme.js';\n\nexport interface DialogueChoice {\n /** Display label (already localized by the caller). */\n readonly label: string;\n /** Called when the player selects this choice. */\n readonly onPress: () => void;\n readonly disabled?: boolean;\n}\n\nexport interface DialoguePanelProps {\n /** Speaker name — rendered above the text. */\n readonly speaker: string;\n /** Line text — rendered in the body. */\n readonly text: string;\n /**\n * Portrait node. Typically an `<Image>` or a Skia/shape avatar keyed by\n * `LineNode.speakerPortraitKey`. When omitted, the portrait slot collapses.\n */\n readonly portrait?: ReactNode;\n /**\n * Optional choices. When present, renders a `Button` per option; when\n * absent, the panel tap-advances via `onAdvance`.\n */\n readonly choices?: readonly DialogueChoice[];\n /** Advance callback — used only when `choices` is empty / omitted. */\n readonly onAdvance?: () => void;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`\n * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your\n * portrait resolver → `portrait` here.\n *\n * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.\n */\nexport function DialoguePanel({\n speaker,\n text,\n portrait,\n choices,\n onAdvance,\n style,\n}: DialoguePanelProps): ReactNode {\n const theme = useTheme();\n const body = (\n <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>\n {portrait !== undefined ? (\n <View style={{ marginRight: theme.spacing.md }}>{portrait}</View>\n ) : null}\n <View style={{ flex: 1 }}>\n <Label variant=\"sm\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {speaker}\n </Label>\n <Label variant=\"md\">{text}</Label>\n {choices && choices.length > 0 ? (\n <View style={{ marginTop: theme.spacing.md }}>\n {choices.map((c, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: static choice list, never reordered\n <View key={`${c.label}-${i}`} style={{ marginTop: i === 0 ? 0 : theme.spacing.xs }}>\n <Button\n label={c.label}\n onPress={c.onPress}\n disabled={c.disabled}\n variant=\"secondary\"\n />\n </View>\n ))}\n </View>\n ) : null}\n </View>\n </View>\n );\n\n if (choices && choices.length > 0) {\n return (\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n );\n }\n\n return (\n <Pressable onPress={onAdvance}>\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n </Pressable>\n );\n}\n","import { createElement, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { createFocusManager, type FocusManager } from './focus.js';\nimport { FocusContext, type FocusContextValue } from './focus-context.js';\n\nexport interface FocusProviderProps {\n manager?: FocusManager;\n /**\n * Opt-in initial focus: focus the tab-order first node once, at the commit\n * where this provider mounts. Off by default so a touch-first tree shows no\n * focus ring until a driver acts. This is mount-time only — it picks among the\n * nodes registered by that first commit and does not re-fire for children that\n * mount later (async/lazy sets). For a dynamic set drive focus explicitly\n * (a keyboard/gamepad driver, or manager.focusFirst()).\n */\n autoFocus?: boolean;\n children: ReactNode;\n}\n\n/**\n * Instantiates a FocusManager (or uses the one provided) and publishes\n * { manager, focusedId } as context state so consumers re-render on focus\n * moves.\n */\nexport function FocusProvider({ manager, autoFocus, children }: FocusProviderProps): ReactNode {\n const [mgr] = useState<FocusManager>(() => manager ?? createFocusManager());\n const [focusedId, setFocusedId] = useState<string | null>(() => mgr.getFocused());\n\n useEffect(() => {\n setFocusedId(mgr.getFocused());\n return mgr.subscribe((id) => {\n setFocusedId(id);\n });\n }, [mgr]);\n\n useEffect(() => {\n // Child register effects run before this parent effect, so every node is\n // registered here → focusFirst() picks the true tab-order first.\n if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();\n }, [autoFocus, mgr]);\n\n const value = useMemo<FocusContextValue>(() => ({ manager: mgr, focusedId }), [mgr, focusedId]);\n\n return createElement(FocusContext.Provider, { value }, children);\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ProgressBarProps {\n /** Progress in [0, 1]. Values outside are clamped. */\n value: number;\n /** Height of the bar in pixels. */\n height?: number;\n /** Track color override. Defaults to theme.colors.surfaceAlt. */\n trackColor?: string;\n /** Fill color override. Defaults to theme.colors.accent. */\n fillColor?: string;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function ProgressBar({\n value,\n height = 8,\n trackColor,\n fillColor,\n style,\n}: ProgressBarProps): ReactNode {\n const theme = useTheme();\n const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));\n const r = theme.radii.sm;\n\n return (\n <View\n style={[\n {\n height,\n borderRadius: r,\n backgroundColor: trackColor ?? theme.colors.surfaceAlt,\n overflow: 'hidden',\n },\n style,\n ]}\n >\n <View\n style={{\n width: `${clamped * 100}%`,\n height: '100%',\n backgroundColor: fillColor ?? theme.colors.accent,\n }}\n />\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { View } from 'react-native';\nimport { Label } from './label.js';\nimport { ProgressBar } from './progress-bar.js';\nimport { useTheme } from './theme.js';\n\nexport type HUDBarKind = 'hp' | 'mp' | 'xp' | 'custom';\n\nexport interface HUDBarProps {\n label: string;\n value: number;\n max: number;\n kind?: HUDBarKind;\n /** When true, shows \"value / max\" next to the label. */\n showNumbers?: boolean;\n /** Override bar fill color. */\n fillColor?: string;\n}\n\nexport function HUDBar({\n label,\n value,\n max,\n kind = 'custom',\n showNumbers = true,\n fillColor,\n}: HUDBarProps): ReactNode {\n const theme = useTheme();\n const ratio = max <= 0 ? 0 : value / max;\n\n let color = fillColor;\n if (!color) {\n switch (kind) {\n case 'hp':\n color = theme.colors.danger;\n break;\n case 'mp':\n color = theme.colors.accent;\n break;\n case 'xp':\n color = theme.colors.success;\n break;\n default:\n color = theme.colors.accent;\n }\n }\n\n return (\n <View>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n marginBottom: theme.spacing.xs,\n }}\n >\n <Label variant=\"sm\" tone=\"muted\">\n {label}\n </Label>\n {showNumbers && (\n <Label variant=\"sm\" tone=\"muted\" mono>\n {`${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`}\n </Label>\n )}\n </View>\n <ProgressBar value={ratio} fillColor={color} />\n </View>\n );\n}\n","/**\n * Minimal flex-like layout resolver.\n *\n * Computes positions + sizes for a single container + its direct children.\n * Supports row/column direction, gap, padding, main-axis `justifyContent`,\n * cross-axis `alignItems`, and per-child `grow` / `basis` / fixed size.\n *\n * Pure function — callers use it to drive their own renderer. React Native\n * already does its own flex, so this is primarily for Skia-rendered HUD /\n * menu layouts that need deterministic pixel positions.\n */\n\nexport type FlexDirection = 'row' | 'column';\nexport type JustifyContent =\n | 'start'\n | 'end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\nexport type AlignItems = 'start' | 'end' | 'center' | 'stretch';\n\nexport interface Padding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface LayoutChild {\n /** Fixed main-axis size. Ignored when `grow > 0`. */\n basis?: number;\n /** Fractional share of leftover main-axis space. */\n grow?: number;\n /** Fixed cross-axis size. Overrides stretch. */\n crossSize?: number;\n}\n\nexport interface LayoutContainer {\n width: number;\n height: number;\n direction: FlexDirection;\n gap?: number;\n padding?: Partial<Padding>;\n justifyContent?: JustifyContent;\n alignItems?: AlignItems;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst ZERO_PAD: Padding = { top: 0, right: 0, bottom: 0, left: 0 };\n\nfunction resolvePadding(p: Partial<Padding> | undefined): Padding {\n if (!p) return ZERO_PAD;\n return {\n top: p.top ?? 0,\n right: p.right ?? 0,\n bottom: p.bottom ?? 0,\n left: p.left ?? 0,\n };\n}\n\nexport function resolveLayout(\n container: LayoutContainer,\n children: readonly LayoutChild[],\n): LayoutRect[] {\n const n = children.length;\n if (n === 0) return [];\n\n const pad = resolvePadding(container.padding);\n const gap = container.gap ?? 0;\n const isRow = container.direction === 'row';\n const mainSize =\n (isRow ? container.width : container.height) -\n (isRow ? pad.left + pad.right : pad.top + pad.bottom);\n const crossSize =\n (isRow ? container.height : container.width) -\n (isRow ? pad.top + pad.bottom : pad.left + pad.right);\n const mainStart = isRow ? pad.left : pad.top;\n const crossStart = isRow ? pad.top : pad.left;\n const justify = container.justifyContent ?? 'start';\n const align = container.alignItems ?? 'stretch';\n const totalGap = gap * Math.max(0, n - 1);\n\n let totalBasis = 0;\n let totalGrow = 0;\n for (const c of children) {\n totalBasis += c.basis ?? 0;\n totalGrow += c.grow ?? 0;\n }\n\n const leftover = mainSize - totalBasis - totalGap;\n const sizes: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const base = c.basis ?? 0;\n const growShare = totalGrow > 0 ? ((c.grow ?? 0) / totalGrow) * Math.max(0, leftover) : 0;\n sizes[i] = Math.max(0, base + growShare);\n }\n\n const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;\n const free = Math.max(0, mainSize - used);\n\n let cursor = mainStart;\n let spacing = gap;\n switch (justify) {\n case 'start':\n break;\n case 'end':\n cursor = mainStart + free;\n break;\n case 'center':\n cursor = mainStart + free / 2;\n break;\n case 'space-between':\n if (n > 1) spacing = gap + free / (n - 1);\n break;\n case 'space-around':\n if (n > 0) {\n const s = free / n;\n cursor = mainStart + s / 2;\n spacing = gap + s;\n }\n break;\n case 'space-evenly':\n if (n >= 0) {\n const s = free / (n + 1);\n cursor = mainStart + s;\n spacing = gap + s;\n }\n break;\n }\n\n const out: LayoutRect[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const mainLen = sizes[i] as number;\n const crossLen = c.crossSize !== undefined ? c.crossSize : align === 'stretch' ? crossSize : 0;\n\n let crossOffset: number;\n switch (align) {\n case 'start':\n crossOffset = 0;\n break;\n case 'end':\n crossOffset = crossSize - crossLen;\n break;\n case 'center':\n crossOffset = (crossSize - crossLen) / 2;\n break;\n case 'stretch':\n crossOffset = 0;\n break;\n }\n\n const x = isRow ? cursor : crossStart + crossOffset;\n const y = isRow ? crossStart + crossOffset : cursor;\n const w = isRow ? mainLen : crossLen;\n const h = isRow ? crossLen : mainLen;\n\n out[i] = { x, y, width: w, height: h };\n cursor += mainLen + spacing;\n }\n\n return out;\n}\n","import { Children, Fragment, type ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ListProps {\n children?: ReactNode;\n /** Gap between items in pixels. Defaults to theme.spacing.sm. */\n gap?: number;\n direction?: 'column' | 'row';\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Vertical (or horizontal) stack with consistent gap. Thin container; the\n * focus manager handles navigation between interactive children.\n */\nexport function List({ children, gap, direction = 'column', style }: ListProps): ReactNode {\n const theme = useTheme();\n const g = gap ?? theme.spacing.sm;\n\n const items: ReactNode[] = [];\n let i = 0;\n // `Children.toArray` flattens nested arrays (e.g. a `{items.map(...)}` child\n // sitting alongside JSX siblings) and drops null/undefined/boolean, unlike a\n // manual `Array.isArray` split which only unwraps one level.\n const flat = Children.toArray(children);\n for (const child of flat) {\n if (i > 0) {\n const spacerStyle: ViewStyle = direction === 'row' ? { width: g } : { height: g };\n items.push(<View key={`s-${i}`} style={spacerStyle} />);\n }\n items.push(<Fragment key={`i-${i}`}>{child}</Fragment>);\n i++;\n }\n\n return <View style={[{ flexDirection: direction }, style]}>{items}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button, type ButtonVariant } from './button.js';\nimport { Label } from './label.js';\nimport { useTheme } from './theme.js';\n\nexport interface MainMenuItem {\n /** Stable id — used as focus id + React key. */\n readonly id: string;\n /** Localized label. */\n readonly label: string;\n readonly onPress: () => void;\n readonly variant?: ButtonVariant;\n readonly disabled?: boolean;\n}\n\nexport interface MainMenuKitProps {\n /** Localized title. */\n readonly title: string;\n /** Optional localized subtitle — tagline, version, locale flag, etc. */\n readonly subtitle?: string;\n /** Button list. Rendered top-to-bottom in order. */\n readonly items: readonly MainMenuItem[];\n /**\n * Optional footer slot — typically a row of ghost buttons (credits, links)\n * or a version/build string.\n */\n readonly footer?: ReactNode;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Title-screen kit: headline, optional subtitle, vertical button list,\n * optional footer slot. All strings are caller-supplied (localized upstream).\n *\n * Save-slot / settings / credits panels are built on top of this kit by the\n * consumer; the kit itself is a pure title-menu primitive.\n */\nexport function MainMenuKit({\n title,\n subtitle,\n items,\n footer,\n style,\n}: MainMenuKitProps): ReactNode {\n const theme = useTheme();\n return (\n <View\n style={[\n {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing.lg,\n },\n style,\n ]}\n >\n <Label variant=\"xl\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {title}\n </Label>\n {subtitle !== undefined ? (\n <Label variant=\"sm\" tone=\"muted\" style={{ marginBottom: theme.spacing.lg }}>\n {subtitle}\n </Label>\n ) : (\n <View style={{ height: theme.spacing.lg }} />\n )}\n <View style={{ alignSelf: 'stretch', maxWidth: 320, width: '100%' }}>\n {items.map((item, i) => (\n <View key={item.id} style={{ marginTop: i === 0 ? 0 : theme.spacing.sm }}>\n <Button\n label={item.label}\n onPress={item.onPress}\n variant={item.variant ?? 'primary'}\n disabled={item.disabled}\n focusId={item.id}\n tabIndex={i}\n />\n </View>\n ))}\n </View>\n {footer !== undefined ? <View style={{ marginTop: theme.spacing.lg }}>{footer}</View> : null}\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, View } from 'react-native';\nimport { Panel } from './panel.js';\n\nexport interface ModalProps {\n visible: boolean;\n children?: ReactNode;\n /** Called when the backdrop is pressed. Return nothing to close, or do nothing to make it non-dismissable. */\n onBackdropPress?: () => void;\n /** Backdrop opacity 0..1. Defaults to 0.6. */\n backdropOpacity?: number;\n}\n\n/**\n * Overlay modal that renders a centered `Panel` with its children. Parent is\n * responsible for controlling visibility and (if desired) focus trapping via\n * the shared FocusManager.\n */\nexport function Modal({\n visible,\n children,\n onBackdropPress,\n backdropOpacity = 0.6,\n}: ModalProps): ReactNode {\n if (!visible) return null;\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n }}\n pointerEvents=\"box-none\"\n >\n <Pressable\n onPress={onBackdropPress}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: `rgba(0,0,0,${backdropOpacity})`,\n }}\n />\n <Panel variant=\"elevated\" padding=\"lg\" style={{ minWidth: 240, maxWidth: '80%' }}>\n {children}\n </Panel>\n </View>\n );\n}\n"],"mappings":";;;;;AAQA,MAAa,eAAe,cAAwC,IAAI;AAExE,SAAgB,kBAAuC;CACrD,MAAM,MAAM,WAAW,YAAY;CACnC,OAAO,MAAM,IAAI,UAAU;AAC7B;AAEA,SAAgB,eAA8B;CAC5C,MAAM,MAAM,WAAW,YAAY;CACnC,OAAO,MAAM,IAAI,YAAY;AAC/B;;ACiCA,MAAa,YAAmB;CAC9B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CAChD,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV;CACA,OAAO;EAAE,MAAM;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,MAAM;CAAK;AACrD;AAEA,MAAa,aAAoB;CAC/B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CA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L,WAAW,KAAA,IAAY,oBAAC,MAAD;IAAM,OAAO,EAAE,WAAW,MAAM,QAAQ,GAAG;IAAI,UAAA;GAAa,CAAA,IAAI;EACpF;;AAEV;;;;;;;ACnEA,SAAgB,MAAM,EACpB,SACA,UACA,iBACA,kBAAkB,MACM;CACxB,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,qBAAC,MAAD;EACE,OAAO;GACL,UAAU;GACV,KAAK;GACL,MAAM;GACN,OAAO;GACP,QAAQ;GACR,YAAY;GACZ,gBAAgB;EAClB;EACA,eAAc;EAVhB,UAAA,CAYE,oBAAC,WAAD;GACE,SAAS;GACT,OAAO;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,iBAAiB,cAAc,gBAAgB;GACjD;EACD,CAAA,GACD,oBAAC,OAAD;GAAO,SAAQ;GAAW,SAAQ;GAAK,OAAO;IAAE,UAAU;IAAK,UAAU;GAAM;GAC5E;EACI,CAAA,CACH;;AAEV"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/focus-context.ts","../src/theme.ts","../src/button.tsx","../src/label.tsx","../src/panel.tsx","../src/dialogue-panel.tsx","../src/focus-provider.tsx","../src/progress-bar.tsx","../src/hud-bar.tsx","../src/layout.ts","../src/list.tsx","../src/main-menu-kit.tsx","../src/modal.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { FocusManager } from './focus.js';\n\nexport interface FocusContextValue {\n manager: FocusManager;\n focusedId: string | null;\n}\n\nexport const FocusContext = createContext<FocusContextValue | null>(null);\n\nexport function useFocusManager(): FocusManager | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.manager : null;\n}\n\nexport function useFocusedId(): string | null {\n const ctx = useContext(FocusContext);\n return ctx ? ctx.focusedId : null;\n}\n","import { createContext, createElement, type ReactNode, useContext } from 'react';\n\nexport interface ThemeColors {\n bg: string;\n surface: string;\n surfaceAlt: string;\n border: string;\n text: string;\n textMuted: string;\n accent: string;\n accentText: string;\n danger: string;\n success: string;\n warning: string;\n focus: string;\n}\n\nexport interface ThemeSpacing {\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n}\n\nexport interface ThemeTypography {\n sizeXs: number;\n sizeSm: number;\n sizeMd: number;\n sizeLg: number;\n sizeXl: number;\n fontFamily?: string;\n fontFamilyMono?: string;\n}\n\nexport interface ThemeRadii {\n none: number;\n sm: number;\n md: number;\n lg: number;\n pill: number;\n}\n\nexport interface Theme {\n name: string;\n colors: ThemeColors;\n spacing: ThemeSpacing;\n typography: ThemeTypography;\n radii: ThemeRadii;\n}\n\nexport const darkTheme: Theme = {\n name: 'dark',\n colors: {\n bg: '#0b0d10',\n surface: '#14181d',\n surfaceAlt: '#1d232b',\n border: '#2a323c',\n text: '#e7ecf1',\n textMuted: '#8c96a3',\n accent: '#4aa3ff',\n accentText: '#0b0d10',\n danger: '#ff5c5c',\n success: '#5dd39e',\n warning: '#f1c40f',\n focus: '#ffd166',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nexport const lightTheme: Theme = {\n name: 'light',\n colors: {\n bg: '#f6f8fa',\n surface: '#ffffff',\n surfaceAlt: '#eef1f4',\n border: '#d4dae0',\n text: '#13181d',\n textMuted: '#5b6670',\n accent: '#0a66d0',\n accentText: '#ffffff',\n danger: '#d12e2e',\n success: '#2f9d69',\n warning: '#c79600',\n focus: '#ff9500',\n },\n spacing: { xs: 4, sm: 8, md: 12, lg: 20, xl: 32 },\n typography: {\n sizeXs: 10,\n sizeSm: 12,\n sizeMd: 14,\n sizeLg: 18,\n sizeXl: 24,\n },\n radii: { none: 0, sm: 4, md: 8, lg: 16, pill: 9999 },\n};\n\nconst ThemeContext = createContext<Theme>(darkTheme);\n\nexport interface ThemeProviderProps {\n theme?: Theme;\n children: ReactNode;\n}\n\nexport function ThemeProvider({ theme = darkTheme, children }: ThemeProviderProps): ReactNode {\n return createElement(ThemeContext.Provider, { value: theme }, children);\n}\n\nexport function useTheme(): Theme {\n return useContext(ThemeContext);\n}\n","import { type ReactNode, useEffect, useId, useRef } from 'react';\nimport { Pressable, type StyleProp, StyleSheet, Text, View, type ViewStyle } from 'react-native';\nimport { useFocusedId, useFocusManager } from './focus-context.js';\nimport { useTheme } from './theme.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';\n\nexport interface ButtonProps {\n label: string;\n onPress?: () => void;\n variant?: ButtonVariant;\n disabled?: boolean;\n /** Focus-navigation tab order. Lower is earlier. Defaults to 0. */\n tabIndex?: number;\n /** Stable focus id. If omitted, a generated id is used. */\n focusId?: string;\n /**\n * Move focus to this button when it is pressed. Defaults to `true`. Set\n * `false` on touch-first screens so a tap leaves no focus ring behind;\n * `onPress` still fires.\n */\n focusOnPress?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Button({\n label,\n onPress,\n variant = 'primary',\n disabled = false,\n tabIndex = 0,\n focusId,\n focusOnPress = true,\n style,\n}: ButtonProps): ReactNode {\n const theme = useTheme();\n const manager = useFocusManager();\n const focusedId = useFocusedId();\n const generated = useId();\n const id = focusId ?? generated;\n\n const latest = useRef({ onPress, disabled, tabIndex });\n latest.current = { onPress, disabled, tabIndex };\n const activateRef = useRef(() => {\n const { onPress: press, disabled: off } = latest.current;\n if (!off) press?.();\n });\n\n // Register once per (manager, id) and own the disposer; prop changes below\n // re-register in place so focus and tab order survive parent re-renders.\n useEffect(() => {\n if (!manager) return;\n const { tabIndex: order, disabled: off } = latest.current;\n return manager.register({\n id,\n tabIndex: order,\n disabled: off,\n onActivate: activateRef.current,\n });\n }, [manager, id]);\n\n useEffect(() => {\n if (!manager) return;\n manager.register({ id, tabIndex, disabled, onActivate: activateRef.current });\n }, [manager, id, tabIndex, disabled]);\n\n const focused = focusedId === id;\n\n let bg = theme.colors.surface;\n let fg = theme.colors.text;\n let border = theme.colors.border;\n switch (variant) {\n case 'primary':\n bg = theme.colors.accent;\n fg = theme.colors.accentText;\n border = theme.colors.accent;\n break;\n case 'secondary':\n bg = theme.colors.surfaceAlt;\n fg = theme.colors.text;\n border = theme.colors.border;\n break;\n case 'ghost':\n bg = 'transparent';\n fg = theme.colors.text;\n border = 'transparent';\n break;\n case 'danger':\n bg = theme.colors.danger;\n fg = theme.colors.accentText;\n border = theme.colors.danger;\n break;\n }\n\n const container: ViewStyle = {\n backgroundColor: bg,\n borderColor: focused ? theme.colors.focus : border,\n borderWidth: focused ? 2 : 1,\n borderRadius: theme.radii.md,\n paddingHorizontal: theme.spacing.md,\n paddingVertical: theme.spacing.sm,\n opacity: disabled ? 0.5 : 1,\n };\n\n return (\n <Pressable\n onPress={() => {\n if (disabled) return;\n if (focusOnPress) manager?.focus(id);\n onPress?.();\n }}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n accessibilityState={{ disabled, selected: focused }}\n style={[styles.wrap, container, style]}\n >\n <View>\n <Text style={{ color: fg, fontSize: theme.typography.sizeMd, textAlign: 'center' }}>\n {label}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignSelf: 'stretch',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import type { ReactNode } from 'react';\nimport { type StyleProp, Text, type TextProps, type TextStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport type LabelVariant = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\nexport type LabelTone = 'default' | 'muted' | 'accent' | 'danger' | 'success' | 'warning';\n\nexport interface LabelProps {\n children?: ReactNode;\n variant?: LabelVariant;\n tone?: LabelTone;\n mono?: boolean;\n style?: StyleProp<TextStyle>;\n numberOfLines?: number;\n ellipsizeMode?: TextProps['ellipsizeMode'];\n adjustsFontSizeToFit?: boolean;\n minimumFontScale?: number;\n}\n\nexport function Label({\n children,\n variant = 'md',\n tone = 'default',\n mono = false,\n style,\n numberOfLines,\n ellipsizeMode,\n adjustsFontSizeToFit,\n minimumFontScale,\n}: LabelProps): ReactNode {\n const theme = useTheme();\n const sizeMap = {\n xs: theme.typography.sizeXs,\n sm: theme.typography.sizeSm,\n md: theme.typography.sizeMd,\n lg: theme.typography.sizeLg,\n xl: theme.typography.sizeXl,\n };\n const toneMap = {\n default: theme.colors.text,\n muted: theme.colors.textMuted,\n accent: theme.colors.accent,\n danger: theme.colors.danger,\n success: theme.colors.success,\n warning: theme.colors.warning,\n };\n\n const base: TextStyle = {\n color: toneMap[tone],\n fontSize: sizeMap[variant],\n fontFamily: mono ? theme.typography.fontFamilyMono : theme.typography.fontFamily,\n };\n\n return (\n <Text\n numberOfLines={numberOfLines}\n ellipsizeMode={ellipsizeMode}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n minimumFontScale={minimumFontScale}\n style={[base, style]}\n >\n {children}\n </Text>\n );\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface PanelProps {\n children?: ReactNode;\n /** Visual style: surface (default) or elevated (surfaceAlt + border). */\n variant?: 'surface' | 'elevated';\n /** Padding size token. Defaults to 'md'. */\n padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Corner radius token. Defaults to 'md'. */\n radius?: 'none' | 'sm' | 'md' | 'lg' | 'pill';\n style?: StyleProp<ViewStyle>;\n}\n\nexport function Panel({\n children,\n variant = 'surface',\n padding = 'md',\n radius = 'md',\n style,\n}: PanelProps): ReactNode {\n const theme = useTheme();\n const bg = variant === 'elevated' ? theme.colors.surfaceAlt : theme.colors.surface;\n const pad = padding === 'none' ? 0 : theme.spacing[padding];\n const r = theme.radii[radius];\n\n const base: ViewStyle = {\n backgroundColor: bg,\n padding: pad,\n borderRadius: r,\n borderWidth: variant === 'elevated' ? 1 : 0,\n borderColor: theme.colors.border,\n };\n\n return <View style={[base, style]}>{children}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button } from './button.js';\nimport { Label } from './label.js';\nimport { Panel } from './panel.js';\nimport { useTheme } from './theme.js';\n\nexport interface DialogueChoice {\n /** Display label (already localized by the caller). */\n readonly label: string;\n /** Called when the player selects this choice. */\n readonly onPress: () => void;\n readonly disabled?: boolean;\n}\n\nexport interface DialoguePanelProps {\n /** Speaker name — rendered above the text. */\n readonly speaker: string;\n /** Line text — rendered in the body. */\n readonly text: string;\n /**\n * Portrait node. Typically an `<Image>` or a Skia/shape avatar keyed by\n * `LineNode.speakerPortraitKey`. When omitted, the portrait slot collapses.\n */\n readonly portrait?: ReactNode;\n /**\n * Optional choices. When present, renders a `Button` per option; when\n * absent, the panel tap-advances via `onAdvance`.\n */\n readonly choices?: readonly DialogueChoice[];\n /** Advance callback — used only when `choices` is empty / omitted. */\n readonly onAdvance?: () => void;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Dialogue panel with a portrait slot. Pairs with `@flare-engine/dialogue`\n * — subscribe to `runner.onLine` and pass `speakerPortraitKey` → your\n * portrait resolver → `portrait` here.\n *\n * Portrait resolution is caller-owned so the UI kit stays asset-agnostic.\n */\nexport function DialoguePanel({\n speaker,\n text,\n portrait,\n choices,\n onAdvance,\n style,\n}: DialoguePanelProps): ReactNode {\n const theme = useTheme();\n const body = (\n <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>\n {portrait !== undefined ? (\n <View style={{ marginRight: theme.spacing.md }}>{portrait}</View>\n ) : null}\n <View style={{ flex: 1 }}>\n <Label variant=\"sm\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {speaker}\n </Label>\n <Label variant=\"md\">{text}</Label>\n {choices && choices.length > 0 ? (\n <View style={{ marginTop: theme.spacing.md }}>\n {choices.map((c, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: static choice list, never reordered\n <View key={`${c.label}-${i}`} style={{ marginTop: i === 0 ? 0 : theme.spacing.xs }}>\n <Button\n label={c.label}\n onPress={c.onPress}\n disabled={c.disabled}\n variant=\"secondary\"\n />\n </View>\n ))}\n </View>\n ) : null}\n </View>\n </View>\n );\n\n if (choices && choices.length > 0) {\n return (\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n );\n }\n\n return (\n <Pressable onPress={onAdvance}>\n <Panel variant=\"elevated\" padding=\"md\" style={style}>\n {body}\n </Panel>\n </Pressable>\n );\n}\n","import { createElement, type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { createFocusManager, type FocusManager } from './focus.js';\nimport { FocusContext, type FocusContextValue } from './focus-context.js';\n\nexport interface FocusProviderProps {\n manager?: FocusManager;\n /**\n * Opt-in initial focus: focus the tab-order first node once, at the commit\n * where this provider mounts. Off by default so a touch-first tree shows no\n * focus ring until a driver acts. This is mount-time only — it picks among the\n * nodes registered by that first commit and does not re-fire for children that\n * mount later (async/lazy sets). For a dynamic set drive focus explicitly\n * (a keyboard/gamepad driver, or manager.focusFirst()).\n */\n autoFocus?: boolean;\n children: ReactNode;\n}\n\n/**\n * Instantiates a FocusManager (or uses the one provided) and publishes\n * { manager, focusedId } as context state so consumers re-render on focus\n * moves.\n */\nexport function FocusProvider({ manager, autoFocus, children }: FocusProviderProps): ReactNode {\n const [mgr] = useState<FocusManager>(() => manager ?? createFocusManager());\n const [focusedId, setFocusedId] = useState<string | null>(() => mgr.getFocused());\n\n useEffect(() => {\n setFocusedId(mgr.getFocused());\n return mgr.subscribe((id) => {\n setFocusedId(id);\n });\n }, [mgr]);\n\n useEffect(() => {\n // Child register effects run before this parent effect, so every node is\n // registered here → focusFirst() picks the true tab-order first.\n if (autoFocus && mgr.getFocused() === null) mgr.focusFirst();\n }, [autoFocus, mgr]);\n\n const value = useMemo<FocusContextValue>(() => ({ manager: mgr, focusedId }), [mgr, focusedId]);\n\n return createElement(FocusContext.Provider, { value }, children);\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ProgressBarProps {\n /** Progress in [0, 1]. Values outside are clamped. */\n value: number;\n /** Height of the bar in pixels. */\n height?: number;\n /** Track color override. Defaults to theme.colors.surfaceAlt. */\n trackColor?: string;\n /** Fill color override. Defaults to theme.colors.accent. */\n fillColor?: string;\n style?: StyleProp<ViewStyle>;\n}\n\nexport function ProgressBar({\n value,\n height = 8,\n trackColor,\n fillColor,\n style,\n}: ProgressBarProps): ReactNode {\n const theme = useTheme();\n const clamped = Number.isNaN(value) ? 0 : Math.max(0, Math.min(1, value));\n const r = theme.radii.sm;\n\n return (\n <View\n style={[\n {\n height,\n borderRadius: r,\n backgroundColor: trackColor ?? theme.colors.surfaceAlt,\n overflow: 'hidden',\n },\n style,\n ]}\n >\n <View\n style={{\n width: `${clamped * 100}%`,\n height: '100%',\n backgroundColor: fillColor ?? theme.colors.accent,\n }}\n />\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { View } from 'react-native';\nimport { Label } from './label.js';\nimport { ProgressBar } from './progress-bar.js';\nimport { useTheme } from './theme.js';\n\nexport type HUDBarKind = 'hp' | 'mp' | 'xp' | 'custom';\n\nexport interface HUDBarProps {\n label: string;\n value: number;\n max: number;\n kind?: HUDBarKind;\n /** When true, shows \"value / max\" next to the label. */\n showNumbers?: boolean;\n /** Override bar fill color. */\n fillColor?: string;\n}\n\nexport function HUDBar({\n label,\n value,\n max,\n kind = 'custom',\n showNumbers = true,\n fillColor,\n}: HUDBarProps): ReactNode {\n const theme = useTheme();\n const ratio = max <= 0 ? 0 : value / max;\n\n let color = fillColor;\n if (!color) {\n switch (kind) {\n case 'hp':\n color = theme.colors.danger;\n break;\n case 'mp':\n color = theme.colors.accent;\n break;\n case 'xp':\n color = theme.colors.success;\n break;\n default:\n color = theme.colors.accent;\n }\n }\n\n return (\n <View>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n marginBottom: theme.spacing.xs,\n }}\n >\n <Label variant=\"sm\" tone=\"muted\">\n {label}\n </Label>\n {showNumbers && (\n <Label variant=\"sm\" tone=\"muted\" mono>\n {`${Math.max(0, Math.floor(value))} / ${Math.max(0, Math.floor(max))}`}\n </Label>\n )}\n </View>\n <ProgressBar value={ratio} fillColor={color} />\n </View>\n );\n}\n","/**\n * Minimal flex-like layout resolver.\n *\n * Computes positions + sizes for a single container + its direct children.\n * Supports row/column direction, gap, padding, main-axis `justifyContent`,\n * cross-axis `alignItems`, and per-child `grow` / `basis` / fixed size.\n *\n * Pure function — callers use it to drive their own renderer. React Native\n * already does its own flex, so this is primarily for Skia-rendered HUD /\n * menu layouts that need deterministic pixel positions.\n */\n\nexport type FlexDirection = 'row' | 'column';\nexport type JustifyContent =\n | 'start'\n | 'end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly';\nexport type AlignItems = 'start' | 'end' | 'center' | 'stretch';\n\nexport interface Padding {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface LayoutChild {\n /** Fixed main-axis size. Ignored when `grow > 0`. */\n basis?: number;\n /** Fractional share of leftover main-axis space. */\n grow?: number;\n /** Fixed cross-axis size. Overrides stretch. */\n crossSize?: number;\n}\n\nexport interface LayoutContainer {\n width: number;\n height: number;\n direction: FlexDirection;\n gap?: number;\n padding?: Partial<Padding>;\n justifyContent?: JustifyContent;\n alignItems?: AlignItems;\n}\n\nexport interface LayoutRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nconst ZERO_PAD: Padding = { top: 0, right: 0, bottom: 0, left: 0 };\n\nfunction resolvePadding(p: Partial<Padding> | undefined): Padding {\n if (!p) return ZERO_PAD;\n return {\n top: p.top ?? 0,\n right: p.right ?? 0,\n bottom: p.bottom ?? 0,\n left: p.left ?? 0,\n };\n}\n\nexport function resolveLayout(\n container: LayoutContainer,\n children: readonly LayoutChild[],\n): LayoutRect[] {\n const n = children.length;\n if (n === 0) return [];\n\n const pad = resolvePadding(container.padding);\n const gap = container.gap ?? 0;\n const isRow = container.direction === 'row';\n const mainSize =\n (isRow ? container.width : container.height) -\n (isRow ? pad.left + pad.right : pad.top + pad.bottom);\n const crossSize =\n (isRow ? container.height : container.width) -\n (isRow ? pad.top + pad.bottom : pad.left + pad.right);\n const mainStart = isRow ? pad.left : pad.top;\n const crossStart = isRow ? pad.top : pad.left;\n const justify = container.justifyContent ?? 'start';\n const align = container.alignItems ?? 'stretch';\n const totalGap = gap * Math.max(0, n - 1);\n\n let totalBasis = 0;\n let totalGrow = 0;\n for (const c of children) {\n totalBasis += c.basis ?? 0;\n totalGrow += c.grow ?? 0;\n }\n\n const leftover = mainSize - totalBasis - totalGap;\n const sizes: number[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const base = c.basis ?? 0;\n const growShare = totalGrow > 0 ? ((c.grow ?? 0) / totalGrow) * Math.max(0, leftover) : 0;\n sizes[i] = Math.max(0, base + growShare);\n }\n\n const used = sizes.reduce((acc, s) => acc + s, 0) + totalGap;\n const free = Math.max(0, mainSize - used);\n\n let cursor = mainStart;\n let spacing = gap;\n switch (justify) {\n case 'start':\n break;\n case 'end':\n cursor = mainStart + free;\n break;\n case 'center':\n cursor = mainStart + free / 2;\n break;\n case 'space-between':\n if (n > 1) spacing = gap + free / (n - 1);\n break;\n case 'space-around':\n if (n > 0) {\n const s = free / n;\n cursor = mainStart + s / 2;\n spacing = gap + s;\n }\n break;\n case 'space-evenly':\n if (n >= 0) {\n const s = free / (n + 1);\n cursor = mainStart + s;\n spacing = gap + s;\n }\n break;\n }\n\n const out: LayoutRect[] = new Array(n);\n for (let i = 0; i < n; i++) {\n const c = children[i] as LayoutChild;\n const mainLen = sizes[i] as number;\n const crossLen = c.crossSize !== undefined ? c.crossSize : align === 'stretch' ? crossSize : 0;\n\n let crossOffset: number;\n switch (align) {\n case 'start':\n crossOffset = 0;\n break;\n case 'end':\n crossOffset = crossSize - crossLen;\n break;\n case 'center':\n crossOffset = (crossSize - crossLen) / 2;\n break;\n case 'stretch':\n crossOffset = 0;\n break;\n }\n\n const x = isRow ? cursor : crossStart + crossOffset;\n const y = isRow ? crossStart + crossOffset : cursor;\n const w = isRow ? mainLen : crossLen;\n const h = isRow ? crossLen : mainLen;\n\n out[i] = { x, y, width: w, height: h };\n cursor += mainLen + spacing;\n }\n\n return out;\n}\n","import { Children, Fragment, type ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { useTheme } from './theme.js';\n\nexport interface ListProps {\n children?: ReactNode;\n /** Gap between items in pixels. Defaults to theme.spacing.sm. */\n gap?: number;\n direction?: 'column' | 'row';\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Vertical (or horizontal) stack with consistent gap. Thin container; the\n * focus manager handles navigation between interactive children.\n */\nexport function List({ children, gap, direction = 'column', style }: ListProps): ReactNode {\n const theme = useTheme();\n const g = gap ?? theme.spacing.sm;\n\n const items: ReactNode[] = [];\n let i = 0;\n // `Children.toArray` flattens nested arrays (e.g. a `{items.map(...)}` child\n // sitting alongside JSX siblings) and drops null/undefined/boolean, unlike a\n // manual `Array.isArray` split which only unwraps one level.\n const flat = Children.toArray(children);\n for (const child of flat) {\n if (i > 0) {\n const spacerStyle: ViewStyle = direction === 'row' ? { width: g } : { height: g };\n items.push(<View key={`s-${i}`} style={spacerStyle} />);\n }\n items.push(<Fragment key={`i-${i}`}>{child}</Fragment>);\n i++;\n }\n\n return <View style={[{ flexDirection: direction }, style]}>{items}</View>;\n}\n","import type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewStyle } from 'react-native';\nimport { Button, type ButtonVariant } from './button.js';\nimport { Label } from './label.js';\nimport { useTheme } from './theme.js';\n\nexport interface MainMenuItem {\n /** Stable id — used as focus id + React key. */\n readonly id: string;\n /** Localized label. */\n readonly label: string;\n readonly onPress: () => void;\n readonly variant?: ButtonVariant;\n readonly disabled?: boolean;\n}\n\nexport interface MainMenuKitProps {\n /** Localized title. */\n readonly title: string;\n /** Optional localized subtitle — tagline, version, locale flag, etc. */\n readonly subtitle?: string;\n /** Button list. Rendered top-to-bottom in order. */\n readonly items: readonly MainMenuItem[];\n /**\n * Optional footer slot — typically a row of ghost buttons (credits, links)\n * or a version/build string.\n */\n readonly footer?: ReactNode;\n readonly style?: StyleProp<ViewStyle>;\n}\n\n/**\n * Title-screen kit: headline, optional subtitle, vertical button list,\n * optional footer slot. All strings are caller-supplied (localized upstream).\n *\n * Save-slot / settings / credits panels are built on top of this kit by the\n * consumer; the kit itself is a pure title-menu primitive.\n */\nexport function MainMenuKit({\n title,\n subtitle,\n items,\n footer,\n style,\n}: MainMenuKitProps): ReactNode {\n const theme = useTheme();\n return (\n <View\n style={[\n {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: theme.spacing.lg,\n },\n style,\n ]}\n >\n <Label variant=\"xl\" tone=\"accent\" style={{ marginBottom: theme.spacing.xs }}>\n {title}\n </Label>\n {subtitle !== undefined ? (\n <Label variant=\"sm\" tone=\"muted\" style={{ marginBottom: theme.spacing.lg }}>\n {subtitle}\n </Label>\n ) : (\n <View style={{ height: theme.spacing.lg }} />\n )}\n <View style={{ alignSelf: 'stretch', maxWidth: 320, width: '100%' }}>\n {items.map((item, i) => (\n <View key={item.id} style={{ marginTop: i === 0 ? 0 : theme.spacing.sm }}>\n <Button\n label={item.label}\n onPress={item.onPress}\n variant={item.variant ?? 'primary'}\n disabled={item.disabled}\n focusId={item.id}\n tabIndex={i}\n />\n </View>\n ))}\n </View>\n {footer !== undefined ? <View style={{ marginTop: theme.spacing.lg }}>{footer}</View> : null}\n </View>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Pressable, View } from 'react-native';\nimport { Panel } from './panel.js';\n\nexport interface ModalProps {\n visible: boolean;\n children?: ReactNode;\n /** Called when the backdrop is pressed. Return nothing to close, or do nothing to make it non-dismissable. */\n onBackdropPress?: () => void;\n /** Backdrop opacity 0..1. Defaults to 0.6. */\n backdropOpacity?: number;\n}\n\n/**\n * Overlay modal that renders a centered `Panel` with its children. Parent is\n * responsible for controlling visibility and (if desired) focus trapping via\n * the shared FocusManager.\n */\nexport function Modal({\n visible,\n children,\n onBackdropPress,\n backdropOpacity = 0.6,\n}: ModalProps): ReactNode {\n if (!visible) return null;\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n }}\n pointerEvents=\"box-none\"\n >\n <Pressable\n onPress={onBackdropPress}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n backgroundColor: `rgba(0,0,0,${backdropOpacity})`,\n }}\n />\n <Panel variant=\"elevated\" padding=\"lg\" style={{ minWidth: 240, maxWidth: '80%' }}>\n {children}\n </Panel>\n </View>\n );\n}\n"],"mappings":";;;;;AAQA,MAAa,eAAe,cAAwC,IAAI;AAExE,SAAgB,kBAAuC;CACrD,MAAM,MAAM,WAAW,YAAY;CACnC,OAAO,MAAM,IAAI,UAAU;AAC7B;AAEA,SAAgB,eAA8B;CAC5C,MAAM,MAAM,WAAW,YAAY;CACnC,OAAO,MAAM,IAAI,YAAY;AAC/B;;ACiCA,MAAa,YAAmB;CAC9B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,WAAW;EACX,QAAQ;EACR,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,SAAS;EACT,OAAO;CACT;CACA,SAAS;EAAE,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,IAAI;EAAI,IAAI;CAAG;CAChD,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACV;CACA,OAAO;EAAE,MAAM;EAAG,IAAI;EAAG,IAAI;EAAG,IAAI;EAAI,MAAM;CAAK;AACrD;AAEA,MAAa,aAAoB;CAC/B,MAAM;CACN,QAAQ;EACN,IAAI;EACJ,SAAS;EACT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@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "UI kit — themed primitives, focus navigation, flex layout resolver",
|
|
5
5
|
"keywords": ["flare-engine", "ui", "react-native", "menu", "hud", "theme", "typescript"],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"focus-BO0mEf9L.mjs","names":[],"sources":["../src/focus-keyboard-driver.ts","../src/focus-manager.ts"],"sourcesContent":["import type { FocusManager } from './focus-manager.js';\n\n/** Structural key source — createKeyboard() from @flare-engine/input is assignable; no hard dep. */\nexport interface FocusKeySource {\n wasPressed(code: string): boolean;\n}\n\nexport interface FocusKeyboardDriver {\n /** Call once per frame; polls edges and drives the manager. */\n update(): void;\n}\n\nexport interface FocusKeyboardDriverOptions {\n next?: readonly string[];\n prev?: readonly string[];\n activate?: readonly string[];\n}\n\nconst DEFAULT_NEXT: readonly string[] = ['ArrowDown', 'ArrowRight', 'Tab'];\nconst DEFAULT_PREV: readonly string[] = ['ArrowUp', 'ArrowLeft'];\nconst DEFAULT_ACTIVATE: readonly string[] = ['Enter', 'Space'];\n\nexport function createFocusKeyboardDriver(\n manager: FocusManager,\n keys: FocusKeySource,\n options?: FocusKeyboardDriverOptions,\n): FocusKeyboardDriver {\n const nextCodes = options?.next ?? DEFAULT_NEXT;\n const prevCodes = options?.prev ?? DEFAULT_PREV;\n const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;\n\n return {\n update(): void {\n for (let i = 0; i < nextCodes.length; i++) {\n if (keys.wasPressed(nextCodes[i]!)) {\n manager.next();\n return;\n }\n }\n for (let i = 0; i < prevCodes.length; i++) {\n if (keys.wasPressed(prevCodes[i]!)) {\n manager.prev();\n return;\n }\n }\n for (let i = 0; i < activateCodes.length; i++) {\n if (keys.wasPressed(activateCodes[i]!)) {\n manager.activate();\n return;\n }\n }\n },\n };\n}\n","/**\n * Keyboard + (future) gamepad focus navigation.\n *\n * Primitives register themselves with the focus manager by id + tab order.\n * The manager owns which id is currently focused and exposes `next` / `prev`\n * / `activate` actions for a driver (keyboard key handler, gamepad dpad)\n * to call. Components read `focusedId` to render a focus ring.\n */\n\nexport interface FocusNode {\n id: string;\n /** Lower tabIndex is focused first. Nodes with equal tabIndex fall back to registration order. */\n tabIndex: number;\n /** Called when this node is activated (Enter / A button). */\n onActivate?: () => void;\n /** Called when this node receives focus. */\n onFocus?: () => void;\n /** Called when this node loses focus. */\n onBlur?: () => void;\n /** If true, the node is skipped during navigation. */\n disabled?: boolean;\n}\n\nexport interface FocusManager {\n register(node: FocusNode): () => void;\n unregister(id: string): void;\n focus(id: string): void;\n /** Explicit opt-in initial focus: focuses the first node in tab order (or clears if empty). */\n focusFirst(): void;\n blur(): void;\n next(): void;\n prev(): void;\n activate(): void;\n getFocused(): string | null;\n getOrder(): readonly string[];\n subscribe(listener: (focusedId: string | null) => void): () => void;\n}\n\nexport interface FocusManagerOptions {\n /**\n * When the focused node unregisters, move focus to the first node in tab\n * order (`true`, the default — keyboard users keep a focus target) or clear\n * it to `null` (`false`). Subscribers are notified either way, and a later\n * `next()` / `prev()` starts from the first / last node as it does from `null`.\n */\n refocusOnUnregister?: boolean;\n}\n\ninterface Entry extends FocusNode {\n seq: number;\n}\n\nexport function createFocusManager(opts?: FocusManagerOptions): FocusManager {\n const refocusOnUnregister = opts?.refocusOnUnregister ?? true;\n const nodes = new Map<string, Entry>();\n let seqCounter = 0;\n let focusedId: string | null = null;\n const listeners = new Set<(id: string | null) => void>();\n\n function notify(): void {\n for (const l of listeners) l(focusedId);\n }\n\n function orderedIds(): string[] {\n const entries = Array.from(nodes.values()).filter((e) => !e.disabled);\n entries.sort((a, b) => {\n if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;\n return a.seq - b.seq;\n });\n return entries.map((e) => e.id);\n }\n\n function setFocused(next: string | null): void {\n if (next === focusedId) return;\n const prev = focusedId;\n focusedId = next;\n if (prev !== null) nodes.get(prev)?.onBlur?.();\n if (next !== null) nodes.get(next)?.onFocus?.();\n notify();\n }\n\n function move(delta: 1 | -1): void {\n const order = orderedIds();\n if (order.length === 0) {\n setFocused(null);\n return;\n }\n if (focusedId === null) {\n setFocused(delta === 1 ? (order[0] ?? null) : (order[order.length - 1] ?? null));\n return;\n }\n const idx = order.indexOf(focusedId);\n if (idx === -1) {\n setFocused(order[0] ?? null);\n return;\n }\n const nextIdx = (idx + delta + order.length) % order.length;\n setFocused(order[nextIdx] ?? null);\n }\n\n return {\n register(node) {\n // No focus side-effect: on a touch-first engine an auto-focused first\n // registrant paints a permanent focus ring with no input. Focus stays null\n // until a driver (keyboard/gamepad) or an explicit focusFirst() acts.\n const entry: Entry = { ...node, seq: seqCounter++ };\n nodes.set(node.id, entry);\n return () => {\n this.unregister(node.id);\n };\n },\n unregister(id) {\n if (!nodes.has(id)) return;\n nodes.delete(id);\n if (focusedId === id) {\n setFocused(refocusOnUnregister ? (orderedIds()[0] ?? null) : null);\n }\n },\n focus(id) {\n const entry = nodes.get(id);\n if (!entry || entry.disabled) return;\n setFocused(id);\n },\n focusFirst() {\n const order = orderedIds();\n setFocused(order[0] ?? null);\n },\n blur() {\n setFocused(null);\n },\n next() {\n move(1);\n },\n prev() {\n move(-1);\n },\n activate() {\n if (focusedId === null) return;\n nodes.get(focusedId)?.onActivate?.();\n },\n getFocused() {\n return focusedId;\n },\n getOrder() {\n return orderedIds();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n"],"mappings":";AAkBA,MAAM,eAAkC;CAAC;CAAa;CAAc;AAAK;AACzE,MAAM,eAAkC,CAAC,WAAW,WAAW;AAC/D,MAAM,mBAAsC,CAAC,SAAS,OAAO;AAE7D,SAAgB,0BACd,SACA,MACA,SACqB;CACrB,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,g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mts","names":[],"sources":["../src/focus-manager.ts","../src/focus-keyboard-driver.ts"],"mappings":";;;;;;;;UASiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf,SAAS,MAAM;EACf,WAAW;EACX,MAAM;;EAEN;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,WAAW;;UAGN;;;;;;;EAOf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCjD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"focus-DLq2jGFa.d.ts","names":[],"sources":["../src/focus-manager.ts","../src/focus-keyboard-driver.ts"],"mappings":";;;;;;;;UASiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf,SAAS,MAAM;EACf,WAAW;EACX,MAAM;;EAEN;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,WAAW;;UAGN;;;;;;;EAOf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCjD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"focus-Yx4Wyt5Q.js","names":[],"sources":["../src/focus-keyboard-driver.ts","../src/focus-manager.ts"],"sourcesContent":["import type { FocusManager } from './focus-manager.js';\n\n/** Structural key source — createKeyboard() from @flare-engine/input is assignable; no hard dep. */\nexport interface FocusKeySource {\n wasPressed(code: string): boolean;\n}\n\nexport interface FocusKeyboardDriver {\n /** Call once per frame; polls edges and drives the manager. */\n update(): void;\n}\n\nexport interface FocusKeyboardDriverOptions {\n next?: readonly string[];\n prev?: readonly string[];\n activate?: readonly string[];\n}\n\nconst DEFAULT_NEXT: readonly string[] = ['ArrowDown', 'ArrowRight', 'Tab'];\nconst DEFAULT_PREV: readonly string[] = ['ArrowUp', 'ArrowLeft'];\nconst DEFAULT_ACTIVATE: readonly string[] = ['Enter', 'Space'];\n\nexport function createFocusKeyboardDriver(\n manager: FocusManager,\n keys: FocusKeySource,\n options?: FocusKeyboardDriverOptions,\n): FocusKeyboardDriver {\n const nextCodes = options?.next ?? DEFAULT_NEXT;\n const prevCodes = options?.prev ?? DEFAULT_PREV;\n const activateCodes = options?.activate ?? DEFAULT_ACTIVATE;\n\n return {\n update(): void {\n for (let i = 0; i < nextCodes.length; i++) {\n if (keys.wasPressed(nextCodes[i]!)) {\n manager.next();\n return;\n }\n }\n for (let i = 0; i < prevCodes.length; i++) {\n if (keys.wasPressed(prevCodes[i]!)) {\n manager.prev();\n return;\n }\n }\n for (let i = 0; i < activateCodes.length; i++) {\n if (keys.wasPressed(activateCodes[i]!)) {\n manager.activate();\n return;\n }\n }\n },\n };\n}\n","/**\n * Keyboard + (future) gamepad focus navigation.\n *\n * Primitives register themselves with the focus manager by id + tab order.\n * The manager owns which id is currently focused and exposes `next` / `prev`\n * / `activate` actions for a driver (keyboard key handler, gamepad dpad)\n * to call. Components read `focusedId` to render a focus ring.\n */\n\nexport interface FocusNode {\n id: string;\n /** Lower tabIndex is focused first. Nodes with equal tabIndex fall back to registration order. */\n tabIndex: number;\n /** Called when this node is activated (Enter / A button). */\n onActivate?: () => void;\n /** Called when this node receives focus. */\n onFocus?: () => void;\n /** Called when this node loses focus. */\n onBlur?: () => void;\n /** If true, the node is skipped during navigation. */\n disabled?: boolean;\n}\n\nexport interface FocusManager {\n register(node: FocusNode): () => void;\n unregister(id: string): void;\n focus(id: string): void;\n /** Explicit opt-in initial focus: focuses the first node in tab order (or clears if empty). */\n focusFirst(): void;\n blur(): void;\n next(): void;\n prev(): void;\n activate(): void;\n getFocused(): string | null;\n getOrder(): readonly string[];\n subscribe(listener: (focusedId: string | null) => void): () => void;\n}\n\nexport interface FocusManagerOptions {\n /**\n * When the focused node unregisters, move focus to the first node in tab\n * order (`true`, the default — keyboard users keep a focus target) or clear\n * it to `null` (`false`). Subscribers are notified either way, and a later\n * `next()` / `prev()` starts from the first / last node as it does from `null`.\n */\n refocusOnUnregister?: boolean;\n}\n\ninterface Entry extends FocusNode {\n seq: number;\n}\n\nexport function createFocusManager(opts?: FocusManagerOptions): FocusManager {\n const refocusOnUnregister = opts?.refocusOnUnregister ?? true;\n const nodes = new Map<string, Entry>();\n let seqCounter = 0;\n let focusedId: string | null = null;\n const listeners = new Set<(id: string | null) => void>();\n\n function notify(): void {\n for (const l of listeners) l(focusedId);\n }\n\n function orderedIds(): string[] {\n const entries = Array.from(nodes.values()).filter((e) => !e.disabled);\n entries.sort((a, b) => {\n if (a.tabIndex !== b.tabIndex) return a.tabIndex - b.tabIndex;\n return a.seq - b.seq;\n });\n return entries.map((e) => e.id);\n }\n\n function setFocused(next: string | null): void {\n if (next === focusedId) return;\n const prev = focusedId;\n focusedId = next;\n if (prev !== null) nodes.get(prev)?.onBlur?.();\n if (next !== null) nodes.get(next)?.onFocus?.();\n notify();\n }\n\n function move(delta: 1 | -1): void {\n const order = orderedIds();\n if (order.length === 0) {\n setFocused(null);\n return;\n }\n if (focusedId === null) {\n setFocused(delta === 1 ? (order[0] ?? null) : (order[order.length - 1] ?? null));\n return;\n }\n const idx = order.indexOf(focusedId);\n if (idx === -1) {\n setFocused(order[0] ?? null);\n return;\n }\n const nextIdx = (idx + delta + order.length) % order.length;\n setFocused(order[nextIdx] ?? null);\n }\n\n return {\n register(node) {\n // No focus side-effect: on a touch-first engine an auto-focused first\n // registrant paints a permanent focus ring with no input. Focus stays null\n // until a driver (keyboard/gamepad) or an explicit focusFirst() acts.\n const entry: Entry = { ...node, seq: seqCounter++ };\n nodes.set(node.id, entry);\n return () => {\n this.unregister(node.id);\n };\n },\n unregister(id) {\n if (!nodes.has(id)) return;\n nodes.delete(id);\n if (focusedId === id) {\n setFocused(refocusOnUnregister ? (orderedIds()[0] ?? null) : null);\n }\n },\n focus(id) {\n const entry = nodes.get(id);\n if (!entry || entry.disabled) return;\n setFocused(id);\n },\n focusFirst() {\n const order = orderedIds();\n setFocused(order[0] ?? null);\n },\n blur() {\n setFocused(null);\n },\n next() {\n move(1);\n },\n prev() {\n move(-1);\n },\n activate() {\n if (focusedId === null) return;\n nodes.get(focusedId)?.onActivate?.();\n },\n getFocused() {\n return focusedId;\n },\n getOrder() {\n return orderedIds();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n"],"mappings":";AAkBA,MAAM,eAAkC;CAAC;CAAa;CAAc;AAAK;AACzE,MAAM,eAAkC,CAAC,WAAW,WAAW;AAC/D,MAAM,mBAAsC,CAAC,SAAS,OAAO;AAE7D,SAAgB,0BACd,SACA,MACA,SACqB;CACrB,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,YAAY,SAAS,QAAQ;CACnC,MAAM,gBAAgB,SAAS,YAAY;CAE3C,OAAO,EACL,SAAe;EACb,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KACpC,IAAI,KAAK,WAAW,UAAU,EAAG,GAAG;GAClC,QAAQ,KAAK;GACb;EACF;EAEF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,KAAK,WAAW,cAAc,EAAG,GAAG;GACtC,QAAQ,SAAS;GACjB;EACF;CAEJ,EACF;AACF;;ACDA,SAAgB,mBAAmB,MAA0C;CAC3E,MAAM,sBAAsB,MAAM,uBAAuB;CACzD,MAAM,wBAAQ,IAAI,IAAmB;CACrC,IAAI,aAAa;CACjB,IAAI,YAA2B;CAC/B,MAAM,4BAAY,IAAI,IAAiC;CAEvD,SAAS,SAAe;EACtB,KAAK,MAAM,KAAK,WAAW,EAAE,SAAS;CACx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