@azx-pbc/axiom-native 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -2
  3. package/dist/configurator.d.ts +39 -0
  4. package/dist/configurator.d.ts.map +1 -0
  5. package/dist/configurator.js +420 -0
  6. package/dist/configurator.js.map +1 -0
  7. package/dist/controls.d.ts +64 -0
  8. package/dist/controls.d.ts.map +1 -0
  9. package/dist/controls.js +8 -0
  10. package/dist/controls.js.map +1 -0
  11. package/dist/copy.d.ts +216 -0
  12. package/dist/copy.d.ts.map +1 -0
  13. package/dist/copy.js +2574 -0
  14. package/dist/copy.js.map +1 -0
  15. package/dist/fields.d.ts +9 -0
  16. package/dist/fields.d.ts.map +1 -0
  17. package/dist/fields.js +1365 -0
  18. package/dist/fields.js.map +1 -0
  19. package/dist/host.d.ts +90 -0
  20. package/dist/host.d.ts.map +1 -0
  21. package/dist/host.js +8 -0
  22. package/dist/host.js.map +1 -0
  23. package/dist/index.d.ts +18 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +10 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/input-chain.d.ts +28 -0
  28. package/dist/input-chain.d.ts.map +1 -0
  29. package/dist/input-chain.js +64 -0
  30. package/dist/input-chain.js.map +1 -0
  31. package/dist/render/layout.d.ts +47 -0
  32. package/dist/render/layout.d.ts.map +1 -0
  33. package/dist/render/layout.js +8 -0
  34. package/dist/render/layout.js.map +1 -0
  35. package/dist/render/native.d.ts +85 -0
  36. package/dist/render/native.d.ts.map +1 -0
  37. package/dist/render/native.js +124 -0
  38. package/dist/render/native.js.map +1 -0
  39. package/dist/render/tree.d.ts +50 -0
  40. package/dist/render/tree.d.ts.map +1 -0
  41. package/dist/render/tree.js +636 -0
  42. package/dist/render/tree.js.map +1 -0
  43. package/dist/theme.d.ts +113 -0
  44. package/dist/theme.d.ts.map +1 -0
  45. package/dist/theme.js +211 -0
  46. package/dist/theme.js.map +1 -0
  47. package/package.json +78 -3
@@ -0,0 +1,28 @@
1
+ import type { Context } from 'react';
2
+ import type { TextInputInstance } from 'react-native';
3
+ /**
4
+ * Per-form return-key focus chain.
5
+ *
6
+ * Each mounted `LayoutTree` creates its own registry so two `FormProvider` trees on one screen
7
+ * never collide in a module-global map. Registration happens in a callback ref at commit time and
8
+ * focus moves only from `onSubmitEditing`, so render never reads or writes mutable refs.
9
+ *
10
+ * Inputs supply a dot-separated structural render-order path (for example `"0.0.1.0"` for row 1,
11
+ * member 0 inside section 0's first child) so dynamically appended or reordered repeating rows
12
+ * stay ahead of trailing fields instead of sorting by mount timestamp.
13
+ */
14
+ export interface InputChainRegistry {
15
+ readonly register: (key: string, target: TextInputInstance, order?: string) => void;
16
+ readonly unregister: (key: string) => void;
17
+ readonly focusAfter: (key: string) => void;
18
+ }
19
+ /** Creates an isolated return-key registry for one form tree. */
20
+ export declare function createInputChain(): InputChainRegistry;
21
+ /** The active form tree's return-key registry, or `undefined` outside a `LayoutTree`. */
22
+ export declare const InputChainContext: Context<InputChainRegistry | undefined>;
23
+ /**
24
+ * The enclosing control's dot-separated structural order path within `LayoutTree`, or `undefined`
25
+ * when rendered standalone outside a `LayoutTree`.
26
+ */
27
+ export declare const InputOrderContext: Context<string | undefined>;
28
+ //# sourceMappingURL=input-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-chain.d.ts","sourceRoot":"","sources":["../src/input-chain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpF,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAkCD,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,kBAAkB,CAuBrD;AAED,yFAAyF;AACzF,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAE1D,CAAC;AAEb;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,CAEzD,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { createContext } from 'react';
2
+ /** Compares two dot-separated non-negative integer tree paths lexicographically by segment. */
3
+ function compareOrderPath(left, right) {
4
+ if (left === right)
5
+ return 0;
6
+ const leftParts = left.split('.');
7
+ const rightParts = right.split('.');
8
+ const length = Math.min(leftParts.length, rightParts.length);
9
+ for (let index = 0; index < length; index += 1) {
10
+ const leftNum = Number(leftParts[index]);
11
+ const rightNum = Number(rightParts[index]);
12
+ if (leftNum !== rightNum)
13
+ return leftNum - rightNum;
14
+ }
15
+ return leftParts.length - rightParts.length;
16
+ }
17
+ function compareEntries(left, right) {
18
+ if (left.order !== undefined && right.order !== undefined) {
19
+ const cmp = compareOrderPath(left.order, right.order);
20
+ if (cmp !== 0)
21
+ return cmp;
22
+ return left.seq - right.seq;
23
+ }
24
+ if (left.order !== undefined)
25
+ return -1;
26
+ if (right.order !== undefined)
27
+ return 1;
28
+ return left.seq - right.seq;
29
+ }
30
+ /** Creates an isolated return-key registry for one form tree. */
31
+ export function createInputChain() {
32
+ let nextSeq = 0;
33
+ const entries = new Map();
34
+ return {
35
+ register(key, target, order) {
36
+ const existing = entries.get(key);
37
+ const seq = existing === undefined ? nextSeq++ : existing.seq;
38
+ entries.set(key, { key, target, order, seq });
39
+ },
40
+ unregister(key) {
41
+ entries.delete(key);
42
+ },
43
+ focusAfter(key) {
44
+ const current = entries.get(key);
45
+ if (current === undefined)
46
+ return;
47
+ const ordered = [...entries.values()].sort(compareEntries);
48
+ const index = ordered.findIndex((entry) => entry.key === key);
49
+ const next = index >= 0 ? ordered[index + 1] : undefined;
50
+ const target = next === undefined ? current.target : next.target;
51
+ const method = Reflect.get(target, next === undefined ? 'blur' : 'focus');
52
+ if (typeof method === 'function')
53
+ Reflect.apply(method, target, []);
54
+ },
55
+ };
56
+ }
57
+ /** The active form tree's return-key registry, or `undefined` outside a `LayoutTree`. */
58
+ export const InputChainContext = createContext(undefined);
59
+ /**
60
+ * The enclosing control's dot-separated structural order path within `LayoutTree`, or `undefined`
61
+ * when rendered standalone outside a `LayoutTree`.
62
+ */
63
+ export const InputOrderContext = createContext(undefined);
64
+ //# sourceMappingURL=input-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-chain.js","sourceRoot":"","sources":["../src/input-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA4BtC,+FAA+F;AAC/F,SAAS,gBAAgB,CAAC,IAAY,EAAE,KAAa;IACnD,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,KA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AC;QACD,UAAU,CAAC,GAAG;YACZ,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO;YAClC,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;YAC9D,MAAM,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACzD,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;YACjE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAC1E,IAAI,OAAO,MAAM,KAAK,UAAU;gBAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACtE,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAA4C,aAAa,CAErF,SAAS,CAAC,CAAC;AAEb;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAgC,aAAa,CACzE,SAAS,CACV,CAAC","sourcesContent":["import { createContext } from 'react';\nimport type { Context } from 'react';\nimport type { TextInputInstance } from 'react-native';\n\n/**\n * Per-form return-key focus chain.\n *\n * Each mounted `LayoutTree` creates its own registry so two `FormProvider` trees on one screen\n * never collide in a module-global map. Registration happens in a callback ref at commit time and\n * focus moves only from `onSubmitEditing`, so render never reads or writes mutable refs.\n *\n * Inputs supply a dot-separated structural render-order path (for example `\"0.0.1.0\"` for row 1,\n * member 0 inside section 0's first child) so dynamically appended or reordered repeating rows\n * stay ahead of trailing fields instead of sorting by mount timestamp.\n */\nexport interface InputChainRegistry {\n readonly register: (key: string, target: TextInputInstance, order?: string) => void;\n readonly unregister: (key: string) => void;\n readonly focusAfter: (key: string) => void;\n}\n\ninterface ChainEntry {\n readonly key: string;\n readonly target: TextInputInstance;\n readonly order: string | undefined;\n readonly seq: number;\n}\n\n/** Compares two dot-separated non-negative integer tree paths lexicographically by segment. */\nfunction compareOrderPath(left: string, right: string): number {\n if (left === right) return 0;\n const leftParts = left.split('.');\n const rightParts = right.split('.');\n const length = Math.min(leftParts.length, rightParts.length);\n for (let index = 0; index < length; index += 1) {\n const leftNum = Number(leftParts[index]);\n const rightNum = Number(rightParts[index]);\n if (leftNum !== rightNum) return leftNum - rightNum;\n }\n return leftParts.length - rightParts.length;\n}\n\nfunction compareEntries(left: ChainEntry, right: ChainEntry): number {\n if (left.order !== undefined && right.order !== undefined) {\n const cmp = compareOrderPath(left.order, right.order);\n if (cmp !== 0) return cmp;\n return left.seq - right.seq;\n }\n if (left.order !== undefined) return -1;\n if (right.order !== undefined) return 1;\n return left.seq - right.seq;\n}\n\n/** Creates an isolated return-key registry for one form tree. */\nexport function createInputChain(): InputChainRegistry {\n let nextSeq = 0;\n const entries = new Map<string, ChainEntry>();\n return {\n register(key, target, order) {\n const existing = entries.get(key);\n const seq = existing === undefined ? nextSeq++ : existing.seq;\n entries.set(key, { key, target, order, seq });\n },\n unregister(key) {\n entries.delete(key);\n },\n focusAfter(key) {\n const current = entries.get(key);\n if (current === undefined) return;\n const ordered = [...entries.values()].sort(compareEntries);\n const index = ordered.findIndex((entry) => entry.key === key);\n const next = index >= 0 ? ordered[index + 1] : undefined;\n const target = next === undefined ? current.target : next.target;\n const method = Reflect.get(target, next === undefined ? 'blur' : 'focus');\n if (typeof method === 'function') Reflect.apply(method, target, []);\n },\n };\n}\n\n/** The active form tree's return-key registry, or `undefined` outside a `LayoutTree`. */\nexport const InputChainContext: Context<InputChainRegistry | undefined> = createContext<\n InputChainRegistry | undefined\n>(undefined);\n\n/**\n * The enclosing control's dot-separated structural order path within `LayoutTree`, or `undefined`\n * when rendered standalone outside a `LayoutTree`.\n */\nexport const InputOrderContext: Context<string | undefined> = createContext<string | undefined>(\n undefined,\n);\n"]}
@@ -0,0 +1,47 @@
1
+ import type { Context, ReactElement, ReactNode } from 'react';
2
+ import type { RenderHeadingLevel, RenderNode, RenderTranslate } from '@azx-pbc/axiom-react';
3
+ import type { NativeTheme } from '../theme.js';
4
+ /**
5
+ * The container slots a host may replace without leaving the native adapter.
6
+ *
7
+ * `ControlComponents` replaces one control; this map replaces one container. A section, a step, a
8
+ * records list, and a summary card are all chrome around content the adapter already rendered: a
9
+ * host that wants its own card, its own step header, or its own repeating-row wrapper supplies the
10
+ * component and receives the rendered descendants, so replacing the chrome never means re-walking
11
+ * the tree.
12
+ *
13
+ * `field` is not a member. A field's affordance is a control, and `ControlComponents` is the map
14
+ * that answers for it; the two maps are therefore disjoint and exhaustive over `RenderNode['kind']`.
15
+ */
16
+ export type ContainerKind = Exclude<RenderNode['kind'], 'field'>;
17
+ /** The rendered descendants, when the container has any, and the node and theme that describe them. */
18
+ export interface LayoutSlotProps {
19
+ /** The node being painted; the slot reads its titles, tone, columns, or record rows. */
20
+ readonly node: Exclude<RenderNode, {
21
+ readonly kind: 'field';
22
+ }>;
23
+ /** The document's message formatter, for every label the slot paints itself. */
24
+ readonly translate: RenderTranslate;
25
+ /** The heading depth this node sits at, one below its container. */
26
+ readonly level: RenderHeadingLevel;
27
+ /**
28
+ * The adapter's own rendering of this node, before the slot was consulted.
29
+ *
30
+ * Return it to keep the default, wrap it to add chrome around the adapter's markup, or ignore
31
+ * it and paint the node from `node` alone. Passing the finished element rather than re-walking
32
+ * the tree is what lets a container slot wrap a records list or a wizard without owning their
33
+ * row bindings and cursor.
34
+ */
35
+ readonly children: ReactNode;
36
+ /** The active runtime theme tokens from `NativeThemeContext`. */
37
+ readonly theme: NativeTheme;
38
+ }
39
+ /** One replacement or wrapper for one container kind. */
40
+ export type LayoutComponent = (props: LayoutSlotProps) => ReactElement | null;
41
+ /** The slot map a host supplies to `RenderedForm`, `LayoutTree`, or `LayoutComponentsContext`. */
42
+ export type LayoutComponents = Partial<Record<ContainerKind, LayoutComponent>>;
43
+ /** The map in force for the tree; absent means every container uses the adapter's default. */
44
+ export declare const LayoutComponentsContext: Context<LayoutComponents | undefined>;
45
+ /** The layout container slot map currently in force, or `undefined` when the host supplies none. */
46
+ export declare function useLayoutComponents(): LayoutComponents | undefined;
47
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/render/layout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;AAEjE,uGAAuG;AACvG,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/D,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,YAAY,GAAG,IAAI,CAAC;AAE9E,kGAAkG;AAClG,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;AAE/E,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAE9D,CAAC;AAEb,oGAAoG;AACpG,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,SAAS,CAElE"}
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from 'react';
2
+ /** The map in force for the tree; absent means every container uses the adapter's default. */
3
+ export const LayoutComponentsContext = createContext(undefined);
4
+ /** The layout container slot map currently in force, or `undefined` when the host supplies none. */
5
+ export function useLayoutComponents() {
6
+ return useContext(LayoutComponentsContext);
7
+ }
8
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/render/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AA8ClD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAA0C,aAAa,CAEzF,SAAS,CAAC,CAAC;AAEb,oGAAoG;AACpG,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { createContext, useContext } from 'react';\nimport type { Context, ReactElement, ReactNode } from 'react';\nimport type { RenderHeadingLevel, RenderNode, RenderTranslate } from '@azx-pbc/axiom-react';\nimport type { NativeTheme } from '../theme.js';\n\n/**\n * The container slots a host may replace without leaving the native adapter.\n *\n * `ControlComponents` replaces one control; this map replaces one container. A section, a step, a\n * records list, and a summary card are all chrome around content the adapter already rendered: a\n * host that wants its own card, its own step header, or its own repeating-row wrapper supplies the\n * component and receives the rendered descendants, so replacing the chrome never means re-walking\n * the tree.\n *\n * `field` is not a member. A field's affordance is a control, and `ControlComponents` is the map\n * that answers for it; the two maps are therefore disjoint and exhaustive over `RenderNode['kind']`.\n */\nexport type ContainerKind = Exclude<RenderNode['kind'], 'field'>;\n\n/** The rendered descendants, when the container has any, and the node and theme that describe them. */\nexport interface LayoutSlotProps {\n /** The node being painted; the slot reads its titles, tone, columns, or record rows. */\n readonly node: Exclude<RenderNode, { readonly kind: 'field' }>;\n /** The document's message formatter, for every label the slot paints itself. */\n readonly translate: RenderTranslate;\n /** The heading depth this node sits at, one below its container. */\n readonly level: RenderHeadingLevel;\n /**\n * The adapter's own rendering of this node, before the slot was consulted.\n *\n * Return it to keep the default, wrap it to add chrome around the adapter's markup, or ignore\n * it and paint the node from `node` alone. Passing the finished element rather than re-walking\n * the tree is what lets a container slot wrap a records list or a wizard without owning their\n * row bindings and cursor.\n */\n readonly children: ReactNode;\n /** The active runtime theme tokens from `NativeThemeContext`. */\n readonly theme: NativeTheme;\n}\n\n/** One replacement or wrapper for one container kind. */\nexport type LayoutComponent = (props: LayoutSlotProps) => ReactElement | null;\n\n/** The slot map a host supplies to `RenderedForm`, `LayoutTree`, or `LayoutComponentsContext`. */\nexport type LayoutComponents = Partial<Record<ContainerKind, LayoutComponent>>;\n\n/** The map in force for the tree; absent means every container uses the adapter's default. */\nexport const LayoutComponentsContext: Context<LayoutComponents | undefined> = createContext<\n LayoutComponents | undefined\n>(undefined);\n\n/** The layout container slot map currently in force, or `undefined` when the host supplies none. */\nexport function useLayoutComponents(): LayoutComponents | undefined {\n return useContext(LayoutComponentsContext);\n}\n"]}
@@ -0,0 +1,85 @@
1
+ import type { RenderHeadingLevel, RenderNode } from '@azx-pbc/axiom-react';
2
+ /**
3
+ * The React Native projector: one render node, the accessibility props it exposes.
4
+ *
5
+ * It is pure and platform-free so the device's accessibility contract can be executed on this
6
+ * host: a section is a header, a control states its name and whether it is invalid, and the
7
+ * announced error summary is an alert. React Native 0.88 has no `aria-invalid`, so the invalid
8
+ * fact rides `invalid` for the component to render as text and to place in the hint; the
9
+ * `accessibilityState` the platform does read carries `disabled`.
10
+ *
11
+ * Heading rank limitation: `toNativeProps` forwards `RenderNode.level` through
12
+ * `accessibilityLevel` on every `'header'` node. `react-native-web` maps `accessibilityLevel`
13
+ * (and `aria-level`) on `accessibilityRole="header"` to HTML `<h2>`..`<h6>` elements, preserving
14
+ * the document heading outline on web targets and in the mounted device lane. Real React Native
15
+ * on iOS and Android exposes no numeric heading rank in `ViewAccessibility` (platform header
16
+ * traits are rank-free), so native mobile screen readers announce the `'header'` role without a
17
+ * numeric level.
18
+ */
19
+ export type NativeRole = 'header' | 'text' | 'alert' | 'summary' | 'none';
20
+ /** The accessibility props one node exposes on a native element. */
21
+ export interface NativeNodeProps {
22
+ readonly accessibilityRole: NativeRole;
23
+ readonly accessibilityLabel: string;
24
+ /**
25
+ * Heading rank from `RenderNode.level` when `accessibilityRole` is `'header'`.
26
+ *
27
+ * `react-native-web` projects this to `<h2>`..`<h6>` and `aria-level`; real iOS and Android
28
+ * React Native have no numeric heading-rank accessibility prop and announce `'header'` without
29
+ * rank.
30
+ */
31
+ readonly accessibilityLevel?: RenderHeadingLevel;
32
+ readonly accessibilityHint?: string;
33
+ readonly accessibilityState?: {
34
+ readonly disabled: boolean;
35
+ };
36
+ readonly invalid: boolean;
37
+ }
38
+ /** The field facts the projector reads; a real `FieldProps` satisfies it whole. */
39
+ export interface NativeFieldState {
40
+ readonly showError: boolean;
41
+ readonly disabled: boolean;
42
+ /** The announced requirement, already narrowed for a value the record withholds. */
43
+ readonly a11y: {
44
+ readonly required: boolean;
45
+ };
46
+ }
47
+ /**
48
+ * One cell's width as a share of its parent's columns.
49
+ *
50
+ * React Native has no grid, so a wrapped row of percentage-width cells is the portable
51
+ * equivalent of the Web adapter's CSS grid. It reads the same `columns`/`colSpan` pair, and a
52
+ * chrome node (which states no span) occupies the whole row.
53
+ */
54
+ export declare function columnStyle(columns: number, span: number): {
55
+ readonly width: `${number}%`;
56
+ };
57
+ /**
58
+ * The props one node exposes.
59
+ *
60
+ * `field` is the binding's live state, which the component reads with `useField` and passes in;
61
+ * a schema-level node ignores it. `invalid` is true exactly when the binding reports a failure it
62
+ * shows, which is the same fact the DOM adapter puts on `aria-invalid`.
63
+ */
64
+ export declare function toNativeProps(node: RenderNode, field?: NativeFieldState, requiredMarker?: string): NativeNodeProps;
65
+ /**
66
+ * Accessibility props for an interactive native control, linking its visible error sentence.
67
+ *
68
+ * React Native (iOS and Android) reads `accessibilityHint` alongside the label; `react-native-web`
69
+ * projects `aria-describedby` and `aria-invalid` onto the DOM element. `props.invalid` comes from
70
+ * `toNativeProps`, so non-blocking warnings link their sentence via the hint and description
71
+ * relation without marking the control invalid.
72
+ */
73
+ export interface ControlA11yProps {
74
+ readonly accessibilityLabel: string;
75
+ readonly accessibilityHint?: string;
76
+ readonly 'aria-describedby'?: string;
77
+ readonly 'aria-invalid'?: boolean;
78
+ }
79
+ /** Composes label, error hint, description relation, and invalid state for an interactive control. */
80
+ export declare function controlA11yProps(props: NativeNodeProps, options?: {
81
+ readonly errorHint?: string;
82
+ readonly describedBy?: string;
83
+ readonly invalid?: boolean;
84
+ }): ControlA11yProps;
85
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/render/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,G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gBAAgB,CAC9B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE;IACP,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,gBAAgB,CAYlB"}
@@ -0,0 +1,124 @@
1
+ const NO_LABEL = '';
2
+ /**
3
+ * A heading's props, or none when the node has no name to announce.
4
+ *
5
+ * A group may state no title at all, and a translated title may be empty. A header role with an
6
+ * empty label announces a heading that says nothing, so such a node is plain text instead.
7
+ */
8
+ function headingProps(label, level) {
9
+ if (label === undefined || label.trim() === '') {
10
+ return { accessibilityRole: 'none', accessibilityLabel: NO_LABEL, invalid: false };
11
+ }
12
+ return {
13
+ accessibilityRole: 'header',
14
+ accessibilityLabel: label,
15
+ accessibilityLevel: level,
16
+ invalid: false,
17
+ };
18
+ }
19
+ function textProps(label) {
20
+ return { accessibilityRole: 'text', accessibilityLabel: label, invalid: false };
21
+ }
22
+ /** The label a control announces: its own name, and that it must be answered. */
23
+ function fieldLabel(node, field, requiredMarker) {
24
+ const label = node.kind === 'field' || node.kind === 'records' || node.kind === 'record'
25
+ ? node.label
26
+ : NO_LABEL;
27
+ return field?.a11y.required === true ? `${label} (${requiredMarker})` : label;
28
+ }
29
+ /**
30
+ * One cell's width as a share of its parent's columns.
31
+ *
32
+ * React Native has no grid, so a wrapped row of percentage-width cells is the portable
33
+ * equivalent of the Web adapter's CSS grid. It reads the same `columns`/`colSpan` pair, and a
34
+ * chrome node (which states no span) occupies the whole row.
35
+ */
36
+ export function columnStyle(columns, span) {
37
+ const occupied = Math.min(span, Math.max(columns, 1));
38
+ const percent = (occupied / Math.max(columns, 1)) * 100;
39
+ return { width: `${percent}%` };
40
+ }
41
+ /**
42
+ * The props one node exposes.
43
+ *
44
+ * `field` is the binding's live state, which the component reads with `useField` and passes in;
45
+ * a schema-level node ignores it. `invalid` is true exactly when the binding reports a failure it
46
+ * shows, which is the same fact the DOM adapter puts on `aria-invalid`.
47
+ */
48
+ export function toNativeProps(node, field, requiredMarker = 'required') {
49
+ switch (node.kind) {
50
+ case 'error_summary':
51
+ return {
52
+ accessibilityRole: 'alert',
53
+ accessibilityLabel: node.items
54
+ .map((item) => item.label === undefined ? item.message : `${item.label}: ${item.message}`)
55
+ .join('. '),
56
+ invalid: true,
57
+ };
58
+ case 'section':
59
+ case 'group':
60
+ case 'step':
61
+ case 'heading':
62
+ return headingProps(node.title, node.level);
63
+ case 'wizard':
64
+ return textProps(node.children.map((step) => step.title).join(', '));
65
+ case 'sop_block':
66
+ return headingProps(node.title, node.level);
67
+ case 'summary_card':
68
+ return {
69
+ ...textProps(node.title),
70
+ accessibilityRole: 'summary',
71
+ ...(node.readouts.length === 0
72
+ ? {}
73
+ : { accessibilityHint: node.readouts.map((readout) => readout.label).join(', ') }),
74
+ };
75
+ case 'callout':
76
+ return {
77
+ accessibilityRole: node.tone === 'danger' ? 'alert' : 'text',
78
+ accessibilityLabel: node.title ?? node.body,
79
+ invalid: false,
80
+ };
81
+ case 'field': {
82
+ const disabled = field?.disabled === true;
83
+ return {
84
+ accessibilityRole: 'text',
85
+ accessibilityLabel: fieldLabel(node, field, requiredMarker),
86
+ ...(disabled ? { accessibilityState: { disabled } } : {}),
87
+ invalid: field?.showError === true,
88
+ };
89
+ }
90
+ case 'records':
91
+ return {
92
+ accessibilityRole: 'summary',
93
+ accessibilityLabel: node.label,
94
+ invalid: false,
95
+ };
96
+ case 'record':
97
+ return {
98
+ accessibilityRole: 'summary',
99
+ accessibilityLabel: node.label,
100
+ invalid: false,
101
+ };
102
+ case 'divider':
103
+ return { accessibilityRole: 'none', accessibilityLabel: NO_LABEL, invalid: false };
104
+ default:
105
+ return assertNeverNode(node);
106
+ }
107
+ }
108
+ /** Composes label, error hint, description relation, and invalid state for an interactive control. */
109
+ export function controlA11yProps(props, options = {}) {
110
+ const invalid = props.invalid || options.invalid === true;
111
+ const hintParts = [props.accessibilityHint, options.errorHint].filter((part) => part !== undefined && part !== '');
112
+ const hint = hintParts.length === 0 ? undefined : hintParts.join(' ');
113
+ return {
114
+ accessibilityLabel: props.accessibilityLabel,
115
+ ...(hint === undefined ? {} : { accessibilityHint: hint }),
116
+ ...(options.describedBy === undefined ? {} : { 'aria-describedby': options.describedBy }),
117
+ ...(invalid ? { 'aria-invalid': true } : {}),
118
+ };
119
+ }
120
+ /** A union arm the compiler proves unreachable. */
121
+ function assertNeverNode(value) {
122
+ throw new Error(`unreachable render node: ${JSON.stringify(value)}`);
123
+ }
124
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/render/native.ts"],"names":[],"mappings":"AA8CA,MAAM,QAAQ,GAAG,EAAE,CAAC;AAEpB;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAyB,EAAE,KAAyB;IACxE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACrF,CAAC;IACD,OAAO;QACL,iBAAiB,EAAE,QAAQ;QAC3B,kBAAkB,EAAE,KAAK;QACzB,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClF,CAAC;AAED,iFAAiF;AACjF,SAAS,UAAU,CACjB,IAAgB,EAChB,KAAmC,EACnC,cAAsB;IAEtB,MAAM,KAAK,GACT,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IA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O,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QACzF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,mDAAmD;AACnD,SAAS,eAAe,CAAC,KAAY;IACnC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import type { RenderHeadingLevel, RenderNode } from '@azx-pbc/axiom-react';\n\n/**\n * The React Native projector: one render node, the accessibility props it exposes.\n *\n * It is pure and platform-free so the device's accessibility contract can be executed on this\n * host: a section is a header, a control states its name and whether it is invalid, and the\n * announced error summary is an alert. React Native 0.88 has no `aria-invalid`, so the invalid\n * fact rides `invalid` for the component to render as text and to place in the hint; the\n * `accessibilityState` the platform does read carries `disabled`.\n *\n * Heading rank limitation: `toNativeProps` forwards `RenderNode.level` through\n * `accessibilityLevel` on every `'header'` node. `react-native-web` maps `accessibilityLevel`\n * (and `aria-level`) on `accessibilityRole=\"header\"` to HTML `<h2>`..`<h6>` elements, preserving\n * the document heading outline on web targets and in the mounted device lane. Real React Native\n * on iOS and Android exposes no numeric heading rank in `ViewAccessibility` (platform header\n * traits are rank-free), so native mobile screen readers announce the `'header'` role without a\n * numeric level.\n */\nexport type NativeRole = 'header' | 'text' | 'alert' | 'summary' | 'none';\n\n/** The accessibility props one node exposes on a native element. */\nexport interface NativeNodeProps {\n readonly accessibilityRole: NativeRole;\n readonly accessibilityLabel: string;\n /**\n * Heading rank from `RenderNode.level` when `accessibilityRole` is `'header'`.\n *\n * `react-native-web` projects this to `<h2>`..`<h6>` and `aria-level`; real iOS and Android\n * React Native have no numeric heading-rank accessibility prop and announce `'header'` without\n * rank.\n */\n readonly accessibilityLevel?: RenderHeadingLevel;\n readonly accessibilityHint?: string;\n readonly accessibilityState?: { readonly disabled: boolean };\n readonly invalid: boolean;\n}\n\n/** The field facts the projector reads; a real `FieldProps` satisfies it whole. */\nexport interface NativeFieldState {\n readonly showError: boolean;\n readonly disabled: boolean;\n /** The announced requirement, already narrowed for a value the record withholds. */\n readonly a11y: { readonly required: boolean };\n}\n\nconst NO_LABEL = '';\n\n/**\n * A heading's props, or none when the node has no name to announce.\n *\n * A group may state no title at all, and a translated title may be empty. A header role with an\n * empty label announces a heading that says nothing, so such a node is plain text instead.\n */\nfunction headingProps(label: string | undefined, level: RenderHeadingLevel): NativeNodeProps {\n if (label === undefined || label.trim() === '') {\n return { accessibilityRole: 'none', accessibilityLabel: NO_LABEL, invalid: false };\n }\n return {\n accessibilityRole: 'header',\n accessibilityLabel: label,\n accessibilityLevel: level,\n invalid: false,\n };\n}\n\nfunction textProps(label: string): NativeNodeProps {\n return { accessibilityRole: 'text', accessibilityLabel: label, invalid: false };\n}\n\n/** The label a control announces: its own name, and that it must be answered. */\nfunction fieldLabel(\n node: RenderNode,\n field: NativeFieldState | undefined,\n requiredMarker: string,\n): string {\n const label =\n node.kind === 'field' || node.kind === 'records' || node.kind === 'record'\n ? node.label\n : NO_LABEL;\n return field?.a11y.required === true ? `${label} (${requiredMarker})` : label;\n}\n\n/**\n * One cell's width as a share of its parent's columns.\n *\n * React Native has no grid, so a wrapped row of percentage-width cells is the portable\n * equivalent of the Web adapter's CSS grid. It reads the same `columns`/`colSpan` pair, and a\n * chrome node (which states no span) occupies the whole row.\n */\nexport function columnStyle(columns: number, span: number): { readonly width: `${number}%` } {\n const occupied = Math.min(span, Math.max(columns, 1));\n const percent = (occupied / Math.max(columns, 1)) * 100;\n return { width: `${percent}%` };\n}\n\n/**\n * The props one node exposes.\n *\n * `field` is the binding's live state, which the component reads with `useField` and passes in;\n * a schema-level node ignores it. `invalid` is true exactly when the binding reports a failure it\n * shows, which is the same fact the DOM adapter puts on `aria-invalid`.\n */\nexport function toNativeProps(\n node: RenderNode,\n field?: NativeFieldState,\n requiredMarker = 'required',\n): NativeNodeProps {\n switch (node.kind) {\n case 'error_summary':\n return {\n accessibilityRole: 'alert',\n accessibilityLabel: node.items\n .map((item) =>\n item.label === undefined ? item.message : `${item.label}: ${item.message}`,\n )\n .join('. '),\n invalid: true,\n };\n case 'section':\n case 'group':\n case 'step':\n case 'heading':\n return headingProps(node.title, node.level);\n case 'wizard':\n return textProps(node.children.map((step) => step.title).join(', '));\n case 'sop_block':\n return headingProps(node.title, node.level);\n case 'summary_card':\n return {\n ...textProps(node.title),\n accessibilityRole: 'summary',\n ...(node.readouts.length === 0\n ? {}\n : { accessibilityHint: node.readouts.map((readout) => readout.label).join(', ') }),\n };\n case 'callout':\n return {\n accessibilityRole: node.tone === 'danger' ? 'alert' : 'text',\n accessibilityLabel: node.title ?? node.body,\n invalid: false,\n };\n case 'field': {\n const disabled = field?.disabled === true;\n return {\n accessibilityRole: 'text',\n accessibilityLabel: fieldLabel(node, field, requiredMarker),\n ...(disabled ? { accessibilityState: { disabled } } : {}),\n invalid: field?.showError === true,\n };\n }\n case 'records':\n return {\n accessibilityRole: 'summary',\n accessibilityLabel: node.label,\n invalid: false,\n };\n case 'record':\n return {\n accessibilityRole: 'summary',\n accessibilityLabel: node.label,\n invalid: false,\n };\n case 'divider':\n return { accessibilityRole: 'none', accessibilityLabel: NO_LABEL, invalid: false };\n default:\n return assertNeverNode(node);\n }\n}\n\n/**\n * Accessibility props for an interactive native control, linking its visible error sentence.\n *\n * React Native (iOS and Android) reads `accessibilityHint` alongside the label; `react-native-web`\n * projects `aria-describedby` and `aria-invalid` onto the DOM element. `props.invalid` comes from\n * `toNativeProps`, so non-blocking warnings link their sentence via the hint and description\n * relation without marking the control invalid.\n */\nexport interface ControlA11yProps {\n readonly accessibilityLabel: string;\n readonly accessibilityHint?: string;\n readonly 'aria-describedby'?: string;\n readonly 'aria-invalid'?: boolean;\n}\n\n/** Composes label, error hint, description relation, and invalid state for an interactive control. */\nexport function controlA11yProps(\n props: NativeNodeProps,\n options: {\n readonly errorHint?: string;\n readonly describedBy?: string;\n readonly invalid?: boolean;\n } = {},\n): ControlA11yProps {\n const invalid = props.invalid || options.invalid === true;\n const hintParts = [props.accessibilityHint, options.errorHint].filter(\n (part): part is string => part !== undefined && part !== '',\n );\n const hint = hintParts.length === 0 ? undefined : hintParts.join(' ');\n return {\n accessibilityLabel: props.accessibilityLabel,\n ...(hint === undefined ? {} : { accessibilityHint: hint }),\n ...(options.describedBy === undefined ? {} : { 'aria-describedby': options.describedBy }),\n ...(invalid ? { 'aria-invalid': true } : {}),\n };\n}\n\n/** A union arm the compiler proves unreachable. */\nfunction assertNeverNode(value: never): never {\n throw new Error(`unreachable render node: ${JSON.stringify(value)}`);\n}\n"]}
@@ -0,0 +1,50 @@
1
+ import type { RenderNode, RenderTranslate } from '@azx-pbc/axiom-react';
2
+ import type { CompiledField } from '@azx-pbc/axiom-runtime';
3
+ import type { ReactElement } from 'react';
4
+ import type { ControlComponents } from '../controls.js';
5
+ import type { NativeTheme, NativeThemeOverrides } from '../theme.js';
6
+ import type { LayoutComponents } from './layout.js';
7
+ /** Props for `LayoutTree`. */
8
+ export interface LayoutTreeProps {
9
+ readonly nodes: readonly RenderNode[];
10
+ readonly translate: RenderTranslate;
11
+ /** Host controls that replace default control entries; composes over outer context when supplied. */
12
+ readonly components?: ControlComponents | undefined;
13
+ /** Host containers that replace rendered containers; composes over outer context when supplied. */
14
+ readonly layout?: LayoutComponents | undefined;
15
+ /** Complete or partial theme overrides; composes over outer `NativeThemeProvider` when supplied. */
16
+ readonly theme?: NativeTheme | NativeThemeOverrides | undefined;
17
+ }
18
+ /**
19
+ * The React Native adapter: the same render tree, painted with native primitives.
20
+ *
21
+ * Every node takes its accessibility props from `toNativeProps`, so the header, label and invalid
22
+ * facts are the contract the node test asserts rather than a per-screen decision. The tree is the
23
+ * one `renderLayout` produced; nothing here asks which document it is in.
24
+ */
25
+ export declare function LayoutTree({ nodes, translate, components, layout, theme: themeOverride, }: LayoutTreeProps): ReactElement;
26
+ /** Props for `RenderedForm`. */
27
+ export interface RenderedFormProps {
28
+ readonly fields: readonly CompiledField[];
29
+ readonly translate: RenderTranslate;
30
+ /** Host controls that replace default control entries; composes over outer context when supplied. */
31
+ readonly components?: ControlComponents | undefined;
32
+ /** Host containers that replace rendered containers; composes over outer context when supplied. */
33
+ readonly layout?: LayoutComponents | undefined;
34
+ /** Complete or partial theme overrides; composes over outer `NativeThemeProvider` when supplied. */
35
+ readonly theme?: NativeTheme | NativeThemeOverrides | undefined;
36
+ }
37
+ /**
38
+ * The chrome the layout states, and nothing that a value edit moves.
39
+ *
40
+ * The tree is built from the layout and memoised on its identity, so a keystroke that changes no
41
+ * visibility, message or readout does not rebuild it. The announced failures are their own
42
+ * component for the same reason.
43
+ */
44
+ export declare function RenderedForm({ fields, translate, components, layout: layoutOverride, theme: themeOverride, }: RenderedFormProps): ReactElement;
45
+ /** The announced failures, above the form. */
46
+ export declare function ErrorSummary({ fields, translate, }: {
47
+ readonly fields: readonly CompiledField[];
48
+ readonly translate: RenderTranslate;
49
+ }): ReactElement | null;
50
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/render/tree.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,UAAU,EAGV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAuB1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAoDpD,8BAA8B;A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