glchat-a2ui-react-renderer 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +200 -267
  2. package/dist/index.d.ts +13 -6
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +14 -4
  5. package/dist/src/Provider.d.ts +33 -8
  6. package/dist/src/Provider.d.ts.map +1 -1
  7. package/dist/src/Provider.js +12 -10
  8. package/dist/src/SurfaceRenderer.d.ts +7 -1
  9. package/dist/src/SurfaceRenderer.d.ts.map +1 -1
  10. package/dist/src/SurfaceRenderer.js +2 -2
  11. package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts.map +1 -1
  12. package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.js +1 -1
  13. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts +1 -5
  14. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts.map +1 -1
  15. package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js +2 -12
  16. package/dist/src/components/a2ui/v0_9/Button/Button.d.ts +75 -241
  17. package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -1
  18. package/dist/src/components/a2ui/v0_9/Button/Button.js +2 -13
  19. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts +1 -8
  20. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts.map +1 -1
  21. package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js +2 -51
  22. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts +40 -196
  23. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts.map +1 -1
  24. package/dist/src/components/a2ui/v0_9/TagInput/TagInput.js +3 -10
  25. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts +26 -102
  26. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts.map +1 -1
  27. package/dist/src/components/a2ui/v0_9/Timeout/Timeout.js +3 -23
  28. package/dist/src/components/a2ui/v0_9/common.d.ts +11 -57
  29. package/dist/src/components/a2ui/v0_9/common.d.ts.map +1 -1
  30. package/dist/src/components/a2ui/v0_9/common.js +0 -9
  31. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.d.ts +3 -0
  32. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.d.ts.map +1 -0
  33. package/dist/src/components/a2ui/v1_0/AudioPlayer/AudioPlayer.js +6 -0
  34. package/dist/src/components/a2ui/v1_0/Button/Button.d.ts +223 -0
  35. package/dist/src/components/a2ui/v1_0/Button/Button.d.ts.map +1 -0
  36. package/dist/src/components/a2ui/v1_0/Button/Button.js +26 -0
  37. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.d.ts +3 -0
  38. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  39. package/dist/src/components/a2ui/v1_0/ChoicePicker/ChoicePicker.js +6 -0
  40. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.d.ts +214 -0
  41. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.d.ts.map +1 -0
  42. package/dist/src/components/a2ui/v1_0/TagInput/TagInput.js +34 -0
  43. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.d.ts +58 -0
  44. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.d.ts.map +1 -0
  45. package/dist/src/components/a2ui/v1_0/Timeout/Timeout.js +25 -0
  46. package/dist/src/components/a2ui/v1_0/common.d.ts +15 -0
  47. package/dist/src/components/a2ui/v1_0/common.d.ts.map +1 -0
  48. package/dist/src/components/a2ui/v1_0/common.js +16 -0
  49. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.d.ts +14 -0
  50. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.d.ts.map +1 -0
  51. package/dist/src/components/a2ui/views/AudioPlayer/AudioPlayer.js +10 -0
  52. package/dist/src/components/a2ui/views/Button/Button.d.ts +18 -0
  53. package/dist/src/components/a2ui/views/Button/Button.d.ts.map +1 -0
  54. package/dist/src/components/a2ui/views/Button/Button.js +22 -0
  55. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.d.ts +25 -0
  56. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  57. package/dist/src/components/a2ui/views/ChoicePicker/ChoicePicker.js +46 -0
  58. package/dist/src/components/a2ui/views/ChoicePicker/theme.d.ts.map +1 -0
  59. package/dist/src/components/a2ui/views/TagInput/TagInput.d.ts +16 -0
  60. package/dist/src/components/a2ui/views/TagInput/TagInput.d.ts.map +1 -0
  61. package/dist/src/components/a2ui/views/TagInput/TagInput.js +12 -0
  62. package/dist/src/components/a2ui/views/Timeout/Timeout.d.ts +9 -0
  63. package/dist/src/components/a2ui/views/Timeout/Timeout.d.ts.map +1 -0
  64. package/dist/src/components/a2ui/views/Timeout/Timeout.js +27 -0
  65. package/dist/src/components/a2ui/views/weight.d.ts +7 -0
  66. package/dist/src/components/a2ui/views/weight.d.ts.map +1 -0
  67. package/dist/src/components/a2ui/views/weight.js +9 -0
  68. package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts +60 -9
  69. package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts.map +1 -1
  70. package/dist/src/components/ui/InlineAlert/InlineAlert.js +4 -3
  71. package/dist/src/core/SurfaceErrorBoundary.d.ts +27 -0
  72. package/dist/src/core/SurfaceErrorBoundary.d.ts.map +1 -0
  73. package/dist/src/core/SurfaceErrorBoundary.js +24 -0
  74. package/dist/src/core/SurfaceGroupProvider.d.ts +38 -0
  75. package/dist/src/core/SurfaceGroupProvider.d.ts.map +1 -0
  76. package/dist/src/core/SurfaceGroupProvider.js +142 -0
  77. package/dist/src/core/SurfaceRenderer.d.ts +4 -0
  78. package/dist/src/core/SurfaceRenderer.d.ts.map +1 -0
  79. package/dist/src/core/SurfaceRenderer.js +64 -0
  80. package/dist/src/core/errors.d.ts +44 -0
  81. package/dist/src/core/errors.d.ts.map +1 -0
  82. package/dist/src/core/errors.js +42 -0
  83. package/dist/src/core/types.d.ts +11 -0
  84. package/dist/src/core/types.d.ts.map +1 -0
  85. package/dist/src/core/types.js +1 -0
  86. package/dist/src/core/unknownComponent.d.ts +28 -0
  87. package/dist/src/core/unknownComponent.d.ts.map +1 -0
  88. package/dist/src/core/unknownComponent.js +41 -0
  89. package/dist/src/{v0_9 → core}/useSurfaces.d.ts +3 -3
  90. package/dist/src/core/useSurfaces.d.ts.map +1 -0
  91. package/dist/src/utils/detectVersion.d.ts +1 -1
  92. package/dist/src/utils/detectVersion.d.ts.map +1 -1
  93. package/dist/src/utils/detectVersion.js +5 -1
  94. package/dist/src/v0_8/Provider.d.ts +2 -1
  95. package/dist/src/v0_8/Provider.d.ts.map +1 -1
  96. package/dist/src/v0_8/Provider.js +4 -9
  97. package/dist/src/v0_9/Provider.d.ts +13 -13
  98. package/dist/src/v0_9/Provider.d.ts.map +1 -1
  99. package/dist/src/v0_9/Provider.js +14 -61
  100. package/dist/src/v0_9/catalog.d.ts +2 -8
  101. package/dist/src/v0_9/catalog.d.ts.map +1 -1
  102. package/dist/src/v0_9/catalog.js +3 -17
  103. package/dist/src/v1_0/Provider.d.ts +27 -0
  104. package/dist/src/v1_0/Provider.d.ts.map +1 -0
  105. package/dist/src/v1_0/Provider.js +35 -0
  106. package/dist/src/v1_0/catalog.d.ts +52 -0
  107. package/dist/src/v1_0/catalog.d.ts.map +1 -0
  108. package/dist/src/v1_0/catalog.js +118 -0
  109. package/dist/src/v1_0/types.d.ts +13 -0
  110. package/dist/src/v1_0/types.d.ts.map +1 -0
  111. package/dist/src/v1_0/types.js +1 -0
  112. package/json/README.md +27 -30
  113. package/json/v0_9/glchat_standard_catalog_definition.json +5 -5
  114. package/json/v1_0/a2ui-sample-messages-extension.json +150 -0
  115. package/json/v1_0/a2ui-sample-messages.json +144 -0
  116. package/json/v1_0/glchat_extension_catalog_definition.json +794 -0
  117. package/json/v1_0/glchat_standard_catalog_definition.json +1487 -0
  118. package/package.json +4 -4
  119. package/styles/globals.css +180 -86
  120. package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts.map +0 -1
  121. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts +0 -231
  122. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts.map +0 -1
  123. package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.js +0 -24
  124. package/dist/src/v0_9/SurfaceErrorBoundary.d.ts +0 -18
  125. package/dist/src/v0_9/SurfaceErrorBoundary.d.ts.map +0 -1
  126. package/dist/src/v0_9/SurfaceErrorBoundary.js +0 -24
  127. package/dist/src/v0_9/SurfaceRenderer.d.ts +0 -3
  128. package/dist/src/v0_9/SurfaceRenderer.d.ts.map +0 -1
  129. package/dist/src/v0_9/SurfaceRenderer.js +0 -47
  130. package/dist/src/v0_9/useSurfaces.d.ts.map +0 -1
  131. /package/dist/src/components/a2ui/{v0_9 → views}/ChoicePicker/theme.d.ts +0 -0
  132. /package/dist/src/components/a2ui/{v0_9 → views}/ChoicePicker/theme.js +0 -0
  133. /package/dist/src/{v0_9 → core}/useSurfaces.js +0 -0
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Countdown to a target UTC time (GLChat extension, v1.0). Displays the
4
+ * remaining time as HH:MM:SS, updating every second.
5
+ */
6
+ export declare const TimeoutApiV1: {
7
+ name: string;
8
+ schema: z.ZodObject<{
9
+ targetTimeUtc: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodObject<{
10
+ '@path': z.ZodOptional<z.ZodString>;
11
+ path: z.ZodOptional<z.ZodString>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ path?: string | undefined;
14
+ '@path'?: string | undefined;
15
+ }, {
16
+ path?: string | undefined;
17
+ '@path'?: string | undefined;
18
+ }>, {
19
+ path?: string | undefined;
20
+ '@path'?: string | undefined;
21
+ }, {
22
+ path?: string | undefined;
23
+ '@path'?: string | undefined;
24
+ }>, z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodIntersection<z.ZodEffects<z.ZodObject<{
25
+ '@call': z.ZodOptional<z.ZodString>;
26
+ call: z.ZodOptional<z.ZodString>;
27
+ catalogId: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ call?: string | undefined;
30
+ '@call'?: string | undefined;
31
+ catalogId?: string | undefined;
32
+ }, {
33
+ call?: string | undefined;
34
+ '@call'?: string | undefined;
35
+ catalogId?: string | undefined;
36
+ }>, {
37
+ call?: string | undefined;
38
+ '@call'?: string | undefined;
39
+ catalogId?: string | undefined;
40
+ }, {
41
+ call?: string | undefined;
42
+ '@call'?: string | undefined;
43
+ catalogId?: string | undefined;
44
+ }>, z.ZodAny>>]>;
45
+ variant: z.ZodOptional<z.ZodEnum<["body", "caption", "h3", "h4", "h5"]>>;
46
+ weight: z.ZodOptional<z.ZodNumber>;
47
+ }, "strict", z.ZodTypeAny, {
48
+ weight?: number | undefined;
49
+ variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
50
+ targetTimeUtc?: any;
51
+ }, {
52
+ weight?: number | undefined;
53
+ variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
54
+ targetTimeUtc?: any;
55
+ }>;
56
+ };
57
+ export declare const GlchatTimeoutComponentV1: import("@a2ui/react").ReactComponentImplementation<z.ZodTypeAny>;
58
+ //# sourceMappingURL=Timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v1_0/Timeout/Timeout.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,kEAGpC,CAAC"}
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import { createComponentImplementation } from '@a2ui/react';
3
+ import { DynamicStringSchema } from '@a2ui/web_core/v1_0';
4
+ import { z } from 'zod';
5
+ import { GlchatTimeoutView } from '../../views/Timeout/Timeout.js';
6
+ import { CommonProps, describeDynamic } from '../common.js';
7
+ /**
8
+ * Countdown to a target UTC time (GLChat extension, v1.0). Displays the
9
+ * remaining time as HH:MM:SS, updating every second.
10
+ */
11
+ export const TimeoutApiV1 = {
12
+ name: 'Timeout',
13
+ schema: z
14
+ .object({
15
+ ...CommonProps,
16
+ targetTimeUtc: describeDynamic(DynamicStringSchema, 'DynamicString', 'The target time as a UTC ISO 8601 string to count down to.'),
17
+ variant: z
18
+ .enum(['body', 'caption', 'h3', 'h4', 'h5'])
19
+ .describe('A hint for the base text style.')
20
+ .optional(),
21
+ })
22
+ .strict()
23
+ .describe('A countdown timer to a target UTC time.'),
24
+ };
25
+ export const GlchatTimeoutComponentV1 = createComponentImplementation(TimeoutApiV1, GlchatTimeoutView);
@@ -0,0 +1,15 @@
1
+ import type { ZodTypeAny } from 'zod';
2
+ /**
3
+ * Catalog-level common properties shared by GLChat v1.0 components, mirroring
4
+ * the v1.0 basic catalog: only `weight`. In v1.0, accessibility is the
5
+ * `@accessibility` envelope key, not a component property.
6
+ */
7
+ export declare const CommonProps: {
8
+ weight: import("zod").ZodOptional<import("zod").ZodNumber>;
9
+ };
10
+ /**
11
+ * Adds a field description while keeping the v1.0 `REF:` marker, so
12
+ * `Catalog.toJson()` emits a `$ref` to the common type (e.g. `DynamicString`).
13
+ */
14
+ export declare function describeDynamic<T extends ZodTypeAny>(schema: T, def: string, description: string): T;
15
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/v1_0/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,WAAW;;CAEvB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,EAClD,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,GAClB,CAAC,CAEH"}
@@ -0,0 +1,16 @@
1
+ import { WeightSchema } from '@a2ui/web_core/catalogs/basic/v1';
2
+ /**
3
+ * Catalog-level common properties shared by GLChat v1.0 components, mirroring
4
+ * the v1.0 basic catalog: only `weight`. In v1.0, accessibility is the
5
+ * `@accessibility` envelope key, not a component property.
6
+ */
7
+ export const CommonProps = {
8
+ weight: WeightSchema.optional(),
9
+ };
10
+ /**
11
+ * Adds a field description while keeping the v1.0 `REF:` marker, so
12
+ * `Catalog.toJson()` emits a `$ref` to the common type (e.g. `DynamicString`).
13
+ */
14
+ export function describeDynamic(schema, def, description) {
15
+ return schema.describe(`REF:#/$defs/${def}|${description}`);
16
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * GLChat-styled AudioPlayer. Overrides the basic catalog native `<audio controls>`
3
+ * with the custom player UI (play/pause, scrubber, download).
4
+ */
5
+ export type GlchatAudioPlayerViewProps = Readonly<{
6
+ props: {
7
+ url?: string;
8
+ description?: string;
9
+ weight?: number;
10
+ };
11
+ }>;
12
+ /** GLChat AudioPlayer view, shared by the v0.9 and v1.0 catalogs. */
13
+ export declare function GlchatAudioPlayerView({ props }: GlchatAudioPlayerViewProps): import("react").JSX.Element | null;
14
+ //# sourceMappingURL=AudioPlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/AudioPlayer/AudioPlayer.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,KAAK,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE,CAAC,CAAC;AAEH,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,EAAE,0BAA0B,sCAQ1E"}
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { AudioPlayer } from '../../../../components/ui/AudioPlayer/AudioPlayer.js';
4
+ import { getWeightStyle } from '../weight.js';
5
+ /** GLChat AudioPlayer view, shared by the v0.9 and v1.0 catalogs. */
6
+ export function GlchatAudioPlayerView({ props }) {
7
+ if (!props.url)
8
+ return null;
9
+ return (_jsx("div", { className: "a2ui-audioplayer", style: getWeightStyle(props.weight), children: _jsx(AudioPlayer, { src: props.url, title: props.description }) }));
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * Resolved props the GLChat Button view needs. Satisfied by both the v0.9
4
+ * (`GlchatButtonApi`) and v1.0 (`GlchatButtonApiV1`) component props.
5
+ */
6
+ export type GlchatButtonViewProps = Readonly<{
7
+ props: {
8
+ variant?: string;
9
+ isValid?: boolean;
10
+ weight?: number;
11
+ child?: string;
12
+ action?: () => unknown;
13
+ };
14
+ buildChild: (id: string) => ReactNode;
15
+ }>;
16
+ /** GLChat Button view, shared by the v0.9 and v1.0 catalogs. */
17
+ export declare function GlchatButtonView({ props, buildChild }: GlchatButtonViewProps): import("react").JSX.Element;
18
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,SAAS,CAAC;CACvC,CAAC,CAAC;AAEH,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,qBAAqB,+BAgB5E"}
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Button } from '../../../../components/ui/Button/Button.js';
4
+ import { getWeightStyle } from '../weight.js';
5
+ function toButtonVariant(variant) {
6
+ if (variant === 'primary')
7
+ return 'primary';
8
+ if (variant === 'borderless')
9
+ return 'borderless';
10
+ if (variant === 'destructive')
11
+ return 'destructive';
12
+ return 'outline';
13
+ }
14
+ /** GLChat Button view, shared by the v0.9 and v1.0 catalogs. */
15
+ export function GlchatButtonView({ props, buildChild }) {
16
+ return (_jsx("div", { className: "a2ui-button", style: getWeightStyle(props.weight), children: _jsx(Button, { variant: toButtonVariant(props.variant), disabled: props.isValid === false,
17
+ // Call explicitly: since @a2ui/react 0.15 the action takes optional
18
+ // dispatch options, so passing it directly would forward the click event.
19
+ onClick: () => {
20
+ void props.action?.();
21
+ }, children: props.child ? buildChild(props.child) : null }) }));
22
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GLChat-styled ChoicePicker. Overrides the basic catalog `ChoicePicker`.
3
+ *
4
+ * - `variant`: `mutuallyExclusive` (single) or `multipleSelection` (multi).
5
+ * - `displayStyle`: `checkbox` renders a checkbox/radio list; otherwise a
6
+ * GLChat select (single) or multi-select dropdown is used.
7
+ */
8
+ export type GlchatChoicePickerViewProps = Readonly<{
9
+ props: {
10
+ variant?: string;
11
+ filterable?: boolean;
12
+ displayStyle?: string;
13
+ label?: unknown;
14
+ value?: unknown;
15
+ options?: ReadonlyArray<{
16
+ value: string;
17
+ label?: unknown;
18
+ }>;
19
+ setValue: (value: string[]) => void;
20
+ weight?: number;
21
+ };
22
+ }>;
23
+ /** GLChat ChoicePicker view, shared by the v0.9 and v1.0 catalogs. */
24
+ export declare function GlchatChoicePickerView({ props }: GlchatChoicePickerViewProps): import("react").JSX.Element;
25
+ //# sourceMappingURL=ChoicePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoicePicker.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/ChoicePicker/ChoicePicker.tsx"],"names":[],"mappings":"AAuDA;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,aAAa,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;QAC5D,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;QACpC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC,CAAC;AAEH,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,EAAE,KAAK,EAAE,EAAE,2BAA2B,+BA0E5E"}
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useMemo } from 'react';
4
+ import { MultiSelect } from '../../../../components/ui/MultiSelect/MultiSelect.js';
5
+ import { Select, SelectContent, SelectItem, SelectTrigger } from '../../../../components/ui/Select/Select.js';
6
+ import { selectTriggerLabelStyles, selectTriggerPlaceholderStyles, } from '../../../../components/ui/Select/theme.js';
7
+ import { getWeightStyle } from '../weight.js';
8
+ import { CheckboxList } from '../../../../components/ui/CheckboxList/CheckboxList.js';
9
+ import { choicePickerContainerStyles, choicePickerLabelStyles } from './theme.js';
10
+ function SingleSelectChips({ options, value, onValueChange }) {
11
+ const selectedLabel = useMemo(() => {
12
+ const match = options.find((opt) => opt.value === value);
13
+ return match?.label ?? '';
14
+ }, [options, value]);
15
+ const triggerLabelStyle = useMemo(() => ({
16
+ ...selectTriggerLabelStyles,
17
+ ...(selectedLabel ? undefined : selectTriggerPlaceholderStyles),
18
+ }), [selectedLabel]);
19
+ return (_jsxs(Select, { value: value, onValueChange: onValueChange, children: [_jsx(SelectTrigger, { className: "glchat-a2ui-select-trigger", "aria-label": "Select option", children: _jsx("span", { style: triggerLabelStyle, ...(selectedLabel ? {} : { 'data-placeholder': '' }), children: selectedLabel || 'Select an item' }) }), _jsx(SelectContent, { className: "glchat-a2ui-select-content", children: options.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value))) })] }));
20
+ }
21
+ /** GLChat ChoicePicker view, shared by the v0.9 and v1.0 catalogs. */
22
+ export function GlchatChoicePickerView({ props }) {
23
+ const singleSelect = props.variant !== 'multipleSelection';
24
+ const filterable = props.filterable ?? false;
25
+ const useCheckboxes = props.displayStyle === 'checkbox';
26
+ const label = typeof props.label === 'string' ? props.label : '';
27
+ const selectedValues = useMemo(() => (Array.isArray(props.value) ? props.value : []), [props.value]);
28
+ const resolvedOptions = useMemo(() => (props.options ?? []).map((option) => ({
29
+ value: option.value,
30
+ label: typeof option.label === 'string' ? option.label : option.value,
31
+ })), [props.options]);
32
+ const handleSingleValueChange = useCallback((nextValue) => {
33
+ props.setValue([nextValue]);
34
+ }, [props]);
35
+ const handleMultiValueChange = useCallback((values) => {
36
+ props.setValue(values);
37
+ }, [props]);
38
+ const wrapper = (content) => (_jsx("div", { className: "a2ui-choicepicker", style: getWeightStyle(props.weight), children: _jsxs("section", { style: choicePickerContainerStyles, children: [label ? _jsx("strong", { style: choicePickerLabelStyles, children: label }) : null, content] }) }));
39
+ if (useCheckboxes) {
40
+ return wrapper(_jsx(CheckboxList, { options: resolvedOptions, value: selectedValues, onValueChange: handleMultiValueChange, singleSelect: singleSelect, filterable: filterable }));
41
+ }
42
+ if (singleSelect) {
43
+ return wrapper(_jsx(SingleSelectChips, { options: resolvedOptions, value: selectedValues[0] ?? '', onValueChange: handleSingleValueChange }));
44
+ }
45
+ return wrapper(_jsx(MultiSelect, { options: resolvedOptions, value: selectedValues, onValueChange: handleMultiValueChange, placeholder: "Select options", filterable: filterable }));
46
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/ChoicePicker/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,2BAA2B,EAAE,aAKzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,aAIrC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type GlchatTagInputViewProps = Readonly<{
2
+ props: {
3
+ value?: string[];
4
+ setValue: (value: string[]) => void;
5
+ label?: string;
6
+ placeholder?: string;
7
+ disabled?: boolean;
8
+ disableTextInput?: boolean;
9
+ validationRegexp?: string;
10
+ validationErrorMessage?: string;
11
+ weight?: number;
12
+ };
13
+ }>;
14
+ /** GLChat TagInput view, shared by the v0.9 and v1.0 catalogs. */
15
+ export declare function GlchatTagInputView({ props }: GlchatTagInputViewProps): import("react").JSX.Element;
16
+ //# sourceMappingURL=TagInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagInput.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/TagInput/TagInput.tsx"],"names":[],"mappings":"AAOA,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC,CAAC;AAEH,kEAAkE;AAClE,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,uBAAuB,+BAqBpE"}
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useCallback } from 'react';
4
+ import { TagInput } from '../../../../components/ui/TagInput/TagInput.js';
5
+ import { getWeightStyle } from '../weight.js';
6
+ /** GLChat TagInput view, shared by the v0.9 and v1.0 catalogs. */
7
+ export function GlchatTagInputView({ props }) {
8
+ const handleValueChange = useCallback((nextTags) => {
9
+ props.setValue(nextTags);
10
+ }, [props]);
11
+ return (_jsx(TagInput, { value: props.value ?? [], onValueChange: handleValueChange, label: props.label, placeholder: props.placeholder, disabled: props.disabled === true, disableTextInput: props.disableTextInput === true, validationRegexp: props.validationRegexp, validationErrorMessage: props.validationErrorMessage, style: getWeightStyle(props.weight) }));
12
+ }
@@ -0,0 +1,9 @@
1
+ export type GlchatTimeoutViewProps = Readonly<{
2
+ props: {
3
+ targetTimeUtc?: unknown;
4
+ weight?: number;
5
+ };
6
+ }>;
7
+ /** GLChat Timeout view, shared by the v0.9 and v1.0 catalogs. */
8
+ export declare function GlchatTimeoutView({ props }: GlchatTimeoutViewProps): import("react").JSX.Element;
9
+ //# sourceMappingURL=Timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/views/Timeout/Timeout.tsx"],"names":[],"mappings":"AAaA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,KAAK,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD,CAAC,CAAC;AAEH,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,sBAAsB,+BAwBlE"}
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useState } from 'react';
4
+ import { formatAsHhMmSs, getRemainingSeconds } from '../../../../utils/time.js';
5
+ import { getWeightStyle } from '../weight.js';
6
+ const textStyle = {
7
+ color: `hsl(var(--foreground) / 0.5)`,
8
+ fontSize: '0.875rem',
9
+ lineHeight: '1.25rem',
10
+ };
11
+ /** GLChat Timeout view, shared by the v0.9 and v1.0 catalogs. */
12
+ export function GlchatTimeoutView({ props }) {
13
+ const targetTimeUtc = typeof props.targetTimeUtc === 'string' ? props.targetTimeUtc : '';
14
+ // Re-render every second; the remaining time is derived from the clock on
15
+ // each render, so a new `targetTimeUtc` takes effect immediately.
16
+ const [, setTick] = useState(0);
17
+ useEffect(() => {
18
+ if (!targetTimeUtc)
19
+ return;
20
+ const timer = setInterval(() => {
21
+ setTick((tick) => tick + 1);
22
+ }, 1000);
23
+ return () => clearInterval(timer);
24
+ }, [targetTimeUtc]);
25
+ const remaining = getRemainingSeconds(targetTimeUtc);
26
+ return (_jsx("div", { className: "a2ui-text a2ui-timeout", style: getWeightStyle(props.weight), children: _jsx("p", { style: textStyle, children: formatAsHhMmSs(remaining) }) }));
27
+ }
@@ -0,0 +1,7 @@
1
+ import type { CSSProperties } from 'react';
2
+ /**
3
+ * Maps the A2UI `weight` property to a flex style, matching the basic catalog.
4
+ * Only meaningful when the component is a direct child of a Row/Column.
5
+ */
6
+ export declare function getWeightStyle(weight: number | undefined): CSSProperties | undefined;
7
+ //# sourceMappingURL=weight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weight.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/views/weight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAGpF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Maps the A2UI `weight` property to a flex style, matching the basic catalog.
3
+ * Only meaningful when the component is a direct child of a Row/Column.
4
+ */
5
+ export function getWeightStyle(weight) {
6
+ if (typeof weight !== 'number')
7
+ return undefined;
8
+ return { flex: `${weight}`, minWidth: 0, minHeight: 0 };
9
+ }
@@ -1,14 +1,65 @@
1
- import { type HTMLAttributes } from 'react';
1
+ import { type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
2
+ export type InlineAlertVariant = 'neutral' | 'warning' | 'error' | 'success';
2
3
  export type InlineAlertProps = HTMLAttributes<HTMLDivElement> & {
3
- /** Visual tone. Defaults to `warning`. */
4
- variant?: 'warning' | 'error';
5
- /** Alert message text. */
6
- message?: string;
4
+ /**
5
+ * Visual tone. Defaults to `warning` for A2UI status surfaces.
6
+ */
7
+ variant?: InlineAlertVariant;
8
+ /**
9
+ * Alert message content.
10
+ */
11
+ children?: ReactNode;
12
+ /**
13
+ * Called when the action button is clicked.
14
+ * Shown only when both `actionClick` and `actionLabel` are set.
15
+ */
16
+ actionClick?: () => void;
17
+ /**
18
+ * Label for the optional action button.
19
+ */
20
+ actionLabel?: string;
21
+ /**
22
+ * Extra class name for the action button.
23
+ */
24
+ actionClassName?: string;
25
+ /**
26
+ * Optional custom icon. Defaults to a circle alert mark.
27
+ */
28
+ icon?: ReactElement;
29
+ /**
30
+ * Extra class name for the message element.
31
+ */
32
+ messageClassName?: string;
7
33
  };
8
34
  export declare const InlineAlert: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
9
- /** Visual tone. Defaults to `warning`. */
10
- variant?: "warning" | "error";
11
- /** Alert message text. */
12
- message?: string;
35
+ /**
36
+ * Visual tone. Defaults to `warning` for A2UI status surfaces.
37
+ */
38
+ variant?: InlineAlertVariant;
39
+ /**
40
+ * Alert message content.
41
+ */
42
+ children?: ReactNode;
43
+ /**
44
+ * Called when the action button is clicked.
45
+ * Shown only when both `actionClick` and `actionLabel` are set.
46
+ */
47
+ actionClick?: () => void;
48
+ /**
49
+ * Label for the optional action button.
50
+ */
51
+ actionLabel?: string;
52
+ /**
53
+ * Extra class name for the action button.
54
+ */
55
+ actionClassName?: string;
56
+ /**
57
+ * Optional custom icon. Defaults to a circle alert mark.
58
+ */
59
+ icon?: ReactElement;
60
+ /**
61
+ * Extra class name for the message element.
62
+ */
63
+ messageClassName?: string;
13
64
  } & import("react").RefAttributes<HTMLDivElement>>;
14
65
  //# sourceMappingURL=InlineAlert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/InlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAIxD,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D,0CAA0C;IAC1C,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC9B,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW;IANtB,0CAA0C;cAChC,SAAS,GAAG,OAAO;IAC7B,0BAA0B;cAChB,MAAM;kDAqBhB,CAAC"}
1
+ {"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/InlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,WAAW;IA/BtB;;OAEG;cACO,kBAAkB;IAC5B;;OAEG;eACQ,SAAS;IACpB;;;OAGG;kBACW,MAAM,IAAI;IACxB;;OAEG;kBACW,MAAM;IACpB;;OAEG;sBACe,MAAM;IACxB;;OAEG;WACI,YAAY;IACnB;;OAEG;uBACgB,MAAM;kDAkD1B,CAAC"}
@@ -1,9 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { CircleAlert } from 'lucide-react';
4
- import { forwardRef } from 'react';
4
+ import { forwardRef, } from 'react';
5
+ import { Button } from '../../../components/ui/Button/Button.js';
5
6
  import { cn } from '../../../utils/css.js';
6
- export const InlineAlert = forwardRef(function InlineAlert({ className, message = 'Alert Message', variant = 'warning', ...props }, ref) {
7
- return (_jsxs("div", { className: cn('glchat-a2ui-inline-alert', `glchat-a2ui-inline-alert--${variant}`, className), ref: ref, ...props, children: [_jsx("div", { className: "glchat-a2ui-inline-alert__icon", children: _jsx(CircleAlert, { className: "glchat-a2ui-inline-alert__svg", strokeWidth: 1.5 }) }), _jsx("div", { className: "glchat-a2ui-inline-alert__body", children: _jsx("p", { className: "glchat-a2ui-inline-alert__message", children: message }) })] }));
7
+ export const InlineAlert = forwardRef(function InlineAlert({ actionClick, actionLabel, actionClassName, className, icon, messageClassName, variant = 'warning', children, ...props }, ref) {
8
+ return (_jsxs("div", { className: cn('glchat-a2ui-inline-alert', `glchat-a2ui-inline-alert--${variant}`, className), ref: ref, ...props, children: [_jsx("div", { className: "glchat-a2ui-inline-alert__icon", children: icon ?? (_jsx(CircleAlert, { className: "glchat-a2ui-inline-alert__svg", strokeWidth: 1.5 })) }), _jsxs("div", { className: "glchat-a2ui-inline-alert__body", children: [_jsx("div", { className: cn('glchat-a2ui-inline-alert__message', messageClassName), children: children }), !!actionClick && !!actionLabel && (_jsx(Button, { className: cn('glchat-a2ui-inline-alert__action', actionClassName), onClick: actionClick, variant: "borderless", children: actionLabel }))] })] }));
8
9
  });
9
10
  InlineAlert.displayName = 'InlineAlert';
@@ -0,0 +1,27 @@
1
+ import { Component, type ReactNode } from 'react';
2
+ import { type A2UIError } from './errors.js';
3
+ type SurfaceErrorBoundaryProps = Readonly<{
4
+ surfaceId: string;
5
+ /** Reports the render error to the host. */
6
+ report: (error: A2UIError) => void;
7
+ /** Renders the error UI. */
8
+ renderError: (error: A2UIError) => ReactNode;
9
+ children: ReactNode;
10
+ }>;
11
+ type SurfaceErrorBoundaryState = {
12
+ failed: boolean;
13
+ cause: unknown;
14
+ };
15
+ /**
16
+ * Catches render errors from `@a2ui/react` catalog components, so one broken
17
+ * surface does not unmount the host tree.
18
+ */
19
+ export declare class SurfaceErrorBoundary extends Component<SurfaceErrorBoundaryProps, SurfaceErrorBoundaryState> {
20
+ state: SurfaceErrorBoundaryState;
21
+ static getDerivedStateFromError(cause: unknown): SurfaceErrorBoundaryState;
22
+ private toError;
23
+ componentDidCatch(): void;
24
+ render(): ReactNode;
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=SurfaceErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/core/SurfaceErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,yBAAyB,GAAG,QAAQ,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACnC,4BAA4B;IAC5B,WAAW,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,SAAS,CAAC;IAC7C,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC,CAAC;AACH,KAAK,yBAAyB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAErE;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CACjD,yBAAyB,EACzB,yBAAyB,CAC1B;IACC,KAAK,EAAE,yBAAyB,CAAuC;IAEvE,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB;IAI1E,OAAO,CAAC,OAAO;IAIf,iBAAiB,IAAI,IAAI;IAIzB,MAAM,IAAI,SAAS;CAIpB"}
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+ import { Component } from 'react';
3
+ import { createError } from './errors.js';
4
+ /**
5
+ * Catches render errors from `@a2ui/react` catalog components, so one broken
6
+ * surface does not unmount the host tree.
7
+ */
8
+ export class SurfaceErrorBoundary extends Component {
9
+ state = { failed: false, cause: undefined };
10
+ static getDerivedStateFromError(cause) {
11
+ return { failed: true, cause };
12
+ }
13
+ toError() {
14
+ return createError('RENDER_FAILED', 'render', this.state.cause, this.props.surfaceId);
15
+ }
16
+ componentDidCatch() {
17
+ this.props.report(this.toError());
18
+ }
19
+ render() {
20
+ if (this.state.failed)
21
+ return this.props.renderError(this.toError());
22
+ return this.props.children;
23
+ }
24
+ }
@@ -0,0 +1,38 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import { type ReactCatalogComponent } from '@a2ui/react';
3
+ import type { MessageProcessor, SurfaceGroupModel } from '@a2ui/web_core';
4
+ import { type V09Message } from '../utils/detectVersion.js';
5
+ import { type A2UIError, type A2UIErrorHandler } from './errors.js';
6
+ import type { ActionOptions } from './types.js';
7
+ /** Protocol versions handled by the shared (v0.9+) message pipeline. */
8
+ export type SurfaceGroupVersion = 'v0.9' | 'v1.0';
9
+ export type SurfaceGroupProviderProps<A> = {
10
+ /** Processor built by the version provider (catalogs, version options). */
11
+ processor: MessageProcessor<ReactCatalogComponent>;
12
+ /** Only this version's messages are processed. */
13
+ version: SurfaceGroupVersion;
14
+ /** Optional rewrite of new messages before processing (e.g. catalog ID fallback). */
15
+ prepareMessages?: (messages: V09Message[]) => V09Message[];
16
+ messages?: V09Message[];
17
+ onAction?: (action: A, options?: ActionOptions) => void | Promise<void>;
18
+ onError?: A2UIErrorHandler;
19
+ };
20
+ type SurfaceGroupContextValue = {
21
+ model: SurfaceGroupModel<ReactCatalogComponent>;
22
+ hasMessages: boolean;
23
+ /** The upstream processor, e.g. for `processor.callAgentFunction(...)` (v1.0). */
24
+ processor: MessageProcessor<ReactCatalogComponent>;
25
+ /** Processing errors by surface ID; the renderer shows them in place of the surface. */
26
+ surfaceErrors: ReadonlyMap<string, A2UIError>;
27
+ /** Reports an error to the host (`onError`, or a short console line). */
28
+ report: (error: A2UIError) => void;
29
+ };
30
+ /**
31
+ * Version-neutral message processing and surface state for A2UI v0.9 and v1.0.
32
+ * The version providers (`V09Provider`, `V1Provider`) build the processor;
33
+ * this component feeds it messages, forwards actions and reports errors.
34
+ */
35
+ export declare function SurfaceGroupProvider<A>({ processor, version, prepareMessages, messages, onAction, onError, children, }: Readonly<PropsWithChildren<SurfaceGroupProviderProps<A>>>): import("react").JSX.Element;
36
+ export declare function useSurfaceGroup(): SurfaceGroupContextValue;
37
+ export {};
38
+ //# sourceMappingURL=SurfaceGroupProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceGroupProvider.d.ts","sourceRoot":"","sources":["../../../src/core/SurfaceGroupProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAW/C,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAI1E,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wEAAwE;AACxE,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI;IACzC,2EAA2E;IAC3E,SAAS,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACnD,kDAAkD;IAClD,OAAO,EAAE,mBAAmB,CAAC;IAC7B,qFAAqF;IACrF,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAChD,WAAW,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,SAAS,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IACnD,wFAAwF;IACxF,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9C,yEAAyE;IACzE,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACpC,CAAC;AAeF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,EACtC,SAAS,EACT,OAAO,EACP,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,+BAuI3D;AAED,wBAAgB,eAAe,IAAI,wBAAwB,CAI1D"}