@flare-engine/ui 0.4.17 → 0.4.19

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.
@@ -1 +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,YA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AC3B;EACF;CACF;AACF"}
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 * The default becomes `false` in 0.5.0. Pass `true` to keep today's re-home\n * after that release.\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,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":"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;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ACF;EACA,MAAM,MAAM,MAAM,QAAQ,SAAS;EACnC,IAAI,QAAQ,IAAI;GACd,WAAW,MAAM,MAAM,IAAI;GAC3B;EACF;EAEA,WAAW,OADM,MAAM,QAAQ,MAAM,UAAU,MAAM,WACxB,IAAI;CACnC;CAEA,SAAS,WAAW,IAAkB;EACpC,IAAI,CAAC,MAAM,IAAI,EAAE,GAAG;EACpB,MAAM,OAAO,EAAE;EACf,IAAI,cAAc,IAChB,WAAW,sBAAuB,WAAW,CAAC,CAAC,MAAM,OAAQ,IAAI;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"}
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 * The default becomes `false` in 0.5.0. Pass `true` to keep today's re-home\n * after that release.\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,UA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AI,QAAQ,IAAI;GACd,WAAW,MAAM,MAAM,IAAI;GAC3B;EACF;EAEA,WAAW,OADM,MAAM,QAAQ,MAAM,UAAU,MAAM,WACxB,IAAI;CACnC;CAEA,SAAS,WAAW,IAAkB;EACpC,IAAI,CAAC,MAAM,IAAI,EAAE,GAAG;EACpB,MAAM,OAAO,EAAE;EACf,IAAI,cAAc,IAChB,WAAW,sBAAuB,WAAW,CAAC,CAAC,MAAM,OAAQ,IAAI;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"}
@@ -43,6 +43,9 @@ interface FocusManagerOptions {
43
43
  * order (`true`, the default — keyboard users keep a focus target) or clear
44
44
  * it to `null` (`false`). Subscribers are notified either way, and a later
45
45
  * `next()` / `prev()` starts from the first / last node as it does from `null`.
46
+ *
47
+ * The default becomes `false` in 0.5.0. Pass `true` to keep today's re-home
48
+ * after that release.
46
49
  */
47
50
  refocusOnUnregister?: boolean;
48
51
  }
@@ -62,4 +65,4 @@ interface FocusKeyboardDriverOptions {
62
65
  }
63
66
  declare function createFocusKeyboardDriver(manager: FocusManager, keys: FocusKeySource, options?: FocusKeyboardDriverOptions): FocusKeyboardDriver;
64
67
  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 };
65
- //# sourceMappingURL=focus-ILunQnll.d.ts.map
68
+ //# sourceMappingURL=focus-D8tFqjzU.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-D8tFqjzU.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;;;;;;;;;;EAUf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCxD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
@@ -43,6 +43,9 @@ interface FocusManagerOptions {
43
43
  * order (`true`, the default — keyboard users keep a focus target) or clear
44
44
  * it to `null` (`false`). Subscribers are notified either way, and a later
45
45
  * `next()` / `prev()` starts from the first / last node as it does from `null`.
46
+ *
47
+ * The default becomes `false` in 0.5.0. Pass `true` to keep today's re-home
48
+ * after that release.
46
49
  */
47
50
  refocusOnUnregister?: boolean;
48
51
  }
@@ -62,4 +65,4 @@ interface FocusKeyboardDriverOptions {
62
65
  }
63
66
  declare function createFocusKeyboardDriver(manager: FocusManager, keys: FocusKeySource, options?: FocusKeyboardDriverOptions): FocusKeyboardDriver;
64
67
  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 };
65
- //# sourceMappingURL=focus-ILunQnll.d.mts.map
68
+ //# sourceMappingURL=focus-D8tFqjzU.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-D8tFqjzU.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;;;;;;;;;;EAUf;;iBAOc,mBAAmB,OAAO,sBAAsB;;UCxD/C;EACf,WAAW;;UAGI;;EAEf;;UAGe;EACf;EACA;EACA;;iBAOc,0BACd,SAAS,cACT,MAAM,gBACN,UAAU,6BACT"}
package/dist/focus.d.mts CHANGED
@@ -5,5 +5,5 @@
5
5
  * consumer can drive focus from a bun test / Node harness without React or
6
6
  * React Native installed. The `.` entry re-exports the same names.
7
7
  */
8
- 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";
8
+ 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-D8tFqjzU.mjs";
9
9
  export { type FocusKeySource, type FocusKeyboardDriver, type FocusKeyboardDriverOptions, type FocusManager, type FocusManagerOptions, type FocusNode, createFocusKeyboardDriver, createFocusManager };
package/dist/focus.d.ts CHANGED
@@ -5,5 +5,5 @@
5
5
  * consumer can drive focus from a bun test / Node harness without React or
6
6
  * React Native installed. The `.` entry re-exports the same names.
7
7
  */
8
- 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";
8
+ 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-D8tFqjzU.js";
9
9
  export { type FocusKeySource, type FocusKeyboardDriver, type FocusKeyboardDriverOptions, type FocusManager, type FocusManagerOptions, type FocusNode, createFocusKeyboardDriver, createFocusManager };
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-ILunQnll.mjs";
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-D8tFqjzU.mjs";
2
2
  import { ReactNode, Ref } from "react";
3
3
  import { StyleProp, Text, TextProps, TextStyle, View, 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-ILunQnll.js";
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-D8tFqjzU.js";
2
2
  import { ReactNode, Ref } from "react";
3
3
  import { StyleProp, Text, TextProps, TextStyle, View, ViewStyle } from "react-native";
4
4
  type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/ui",
3
- "version": "0.4.17",
3
+ "version": "0.4.19",
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-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"}
@@ -1 +0,0 @@
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"}