glchat-a2ui-react-renderer 0.2.6 → 0.2.8

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 (108) hide show
  1. package/README.md +251 -124
  2. package/dist/index.d.ts +10 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +13 -5
  5. package/dist/src/Provider.d.ts +21 -14
  6. package/dist/src/Provider.d.ts.map +1 -1
  7. package/dist/src/Provider.js +56 -42
  8. package/dist/src/SurfaceRenderer.d.ts +17 -0
  9. package/dist/src/SurfaceRenderer.d.ts.map +1 -0
  10. package/dist/src/SurfaceRenderer.js +28 -0
  11. package/dist/src/components/a2ui/Button/Button.d.ts +313 -3
  12. package/dist/src/components/a2ui/Button/Button.d.ts.map +1 -1
  13. package/dist/src/components/a2ui/Button/Button.js +31 -24
  14. package/dist/src/components/a2ui/{MultipleChoice → ChoicePicker}/CheckboxList.d.ts +1 -2
  15. package/dist/src/components/a2ui/ChoicePicker/CheckboxList.d.ts.map +1 -0
  16. package/dist/src/components/a2ui/ChoicePicker/CheckboxList.js +34 -0
  17. package/dist/src/components/a2ui/ChoicePicker/ChoicePicker.d.ts +9 -0
  18. package/dist/src/components/a2ui/ChoicePicker/ChoicePicker.d.ts.map +1 -0
  19. package/dist/src/components/a2ui/ChoicePicker/ChoicePicker.js +54 -0
  20. package/dist/src/components/a2ui/ChoicePicker/theme.d.ts +10 -0
  21. package/dist/src/components/a2ui/ChoicePicker/theme.d.ts.map +1 -0
  22. package/dist/src/components/a2ui/{MultipleChoice → ChoicePicker}/theme.js +15 -12
  23. package/dist/src/components/a2ui/TagInput/TagInput.d.ts +290 -0
  24. package/dist/src/components/a2ui/TagInput/TagInput.d.ts.map +1 -0
  25. package/dist/src/components/a2ui/TagInput/TagInput.js +110 -0
  26. package/dist/src/components/a2ui/TagInput/theme.d.ts +13 -0
  27. package/dist/src/components/a2ui/TagInput/theme.d.ts.map +1 -0
  28. package/dist/src/components/a2ui/TagInput/theme.js +74 -0
  29. package/dist/src/components/a2ui/Timeout/Timeout.d.ts +154 -3
  30. package/dist/src/components/a2ui/Timeout/Timeout.d.ts.map +1 -1
  31. package/dist/src/components/a2ui/Timeout/Timeout.js +40 -25
  32. package/dist/src/components/a2ui/common.d.ts +87 -0
  33. package/dist/src/components/a2ui/common.d.ts.map +1 -0
  34. package/dist/src/components/a2ui/common.js +23 -0
  35. package/dist/src/components/ui/Button/Button.d.ts +15 -0
  36. package/dist/src/components/ui/Button/Button.d.ts.map +1 -0
  37. package/dist/src/components/ui/Button/Button.js +16 -0
  38. package/dist/src/components/ui/Button/theme.d.ts +5 -0
  39. package/dist/src/components/ui/Button/theme.d.ts.map +1 -0
  40. package/dist/src/components/{a2ui → ui}/Button/theme.js +13 -10
  41. package/dist/src/components/ui/Checkbox/Checkbox.js +2 -2
  42. package/dist/src/components/ui/Checkbox/theme.d.ts +3 -3
  43. package/dist/src/components/ui/Checkbox/theme.d.ts.map +1 -1
  44. package/dist/src/components/ui/Checkbox/theme.js +3 -3
  45. package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts +1 -1
  46. package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
  47. package/dist/src/components/ui/MultiSelect/MultiSelect.js +12 -12
  48. package/dist/src/components/ui/MultiSelect/theme.d.ts +12 -12
  49. package/dist/src/components/ui/MultiSelect/theme.d.ts.map +1 -1
  50. package/dist/src/components/ui/MultiSelect/theme.js +13 -13
  51. package/dist/src/components/ui/Select/Select.js +8 -8
  52. package/dist/src/components/ui/Select/theme.d.ts +8 -8
  53. package/dist/src/components/ui/Select/theme.d.ts.map +1 -1
  54. package/dist/src/components/ui/Select/theme.js +8 -9
  55. package/dist/src/utils/catalog.d.ts +16 -4
  56. package/dist/src/utils/catalog.d.ts.map +1 -1
  57. package/dist/src/utils/catalog.js +32 -27
  58. package/dist/src/utils/useSurfaces.d.ts +9 -0
  59. package/dist/src/utils/useSurfaces.d.ts.map +1 -0
  60. package/dist/src/utils/useSurfaces.js +28 -0
  61. package/json/README.md +61 -0
  62. package/json/a2ui-sample-messages.json +193 -0
  63. package/json/glchat_standard_catalog_definition.json +1470 -0
  64. package/package.json +15 -6
  65. package/styles/globals.css +232 -38
  66. package/dist/src/AllSurfacesRenderer.d.ts +0 -14
  67. package/dist/src/AllSurfacesRenderer.d.ts.map +0 -1
  68. package/dist/src/AllSurfacesRenderer.js +0 -18
  69. package/dist/src/SingleSurfaceRenderer.d.ts +0 -15
  70. package/dist/src/SingleSurfaceRenderer.d.ts.map +0 -1
  71. package/dist/src/SingleSurfaceRenderer.js +0 -9
  72. package/dist/src/components/a2ui/Button/theme.d.ts +0 -14
  73. package/dist/src/components/a2ui/Button/theme.d.ts.map +0 -1
  74. package/dist/src/components/a2ui/Card/Card.d.ts +0 -4
  75. package/dist/src/components/a2ui/Card/Card.d.ts.map +0 -1
  76. package/dist/src/components/a2ui/Card/Card.js +0 -16
  77. package/dist/src/components/a2ui/Card/theme.d.ts +0 -10
  78. package/dist/src/components/a2ui/Card/theme.d.ts.map +0 -1
  79. package/dist/src/components/a2ui/Card/theme.js +0 -21
  80. package/dist/src/components/a2ui/CheckBox/CheckBox.d.ts +0 -4
  81. package/dist/src/components/a2ui/CheckBox/CheckBox.d.ts.map +0 -1
  82. package/dist/src/components/a2ui/CheckBox/CheckBox.js +0 -26
  83. package/dist/src/components/a2ui/CheckBox/theme.d.ts +0 -11
  84. package/dist/src/components/a2ui/CheckBox/theme.d.ts.map +0 -1
  85. package/dist/src/components/a2ui/CheckBox/theme.js +0 -17
  86. package/dist/src/components/a2ui/DateTimeInput/theme.d.ts +0 -8
  87. package/dist/src/components/a2ui/DateTimeInput/theme.d.ts.map +0 -1
  88. package/dist/src/components/a2ui/DateTimeInput/theme.js +0 -11
  89. package/dist/src/components/a2ui/MultipleChoice/CheckboxList.d.ts.map +0 -1
  90. package/dist/src/components/a2ui/MultipleChoice/CheckboxList.js +0 -45
  91. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.d.ts +0 -4
  92. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.d.ts.map +0 -1
  93. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.js +0 -72
  94. package/dist/src/components/a2ui/MultipleChoice/theme.d.ts +0 -13
  95. package/dist/src/components/a2ui/MultipleChoice/theme.d.ts.map +0 -1
  96. package/dist/src/components/a2ui/TextField/TextField.d.ts +0 -4
  97. package/dist/src/components/a2ui/TextField/TextField.d.ts.map +0 -1
  98. package/dist/src/components/a2ui/TextField/TextField.js +0 -54
  99. package/dist/src/components/a2ui/TextField/theme.d.ts +0 -28
  100. package/dist/src/components/a2ui/TextField/theme.d.ts.map +0 -1
  101. package/dist/src/components/a2ui/TextField/theme.js +0 -82
  102. package/dist/src/components/a2ui/Timeout/theme.d.ts +0 -8
  103. package/dist/src/components/a2ui/Timeout/theme.d.ts.map +0 -1
  104. package/dist/src/components/a2ui/Timeout/theme.js +0 -12
  105. package/dist/src/utils/theme.d.ts +0 -4
  106. package/dist/src/utils/theme.d.ts.map +0 -1
  107. package/dist/src/utils/theme.js +0 -92
  108. package/patches/@a2ui+web_core+0.10.0.patch +0 -55
@@ -3,27 +3,27 @@ import type { CSSProperties } from 'react';
3
3
  * SelectTrigger inline styles — glchat-ui Select baseline.
4
4
  */
5
5
  /** Label text inside SelectTrigger (not Radix SelectValue). */
6
- export declare const glchatSelectTriggerLabelStyles: CSSProperties;
7
- export declare const glchatSelectTriggerPlaceholderStyles: CSSProperties;
8
- export declare const glchatSelectTriggerStyles: CSSProperties;
6
+ export declare const selectTriggerLabelStyles: CSSProperties;
7
+ export declare const selectTriggerPlaceholderStyles: CSSProperties;
8
+ export declare const selectTriggerStyles: CSSProperties;
9
9
  /**
10
10
  * SelectContent inline styles — dropdown panel.
11
11
  */
12
- export declare const glchatSelectContentStyles: CSSProperties;
12
+ export declare const selectContentStyles: CSSProperties;
13
13
  /**
14
14
  * SelectViewport padding wrapper.
15
15
  */
16
- export declare const glchatSelectViewportStyles: CSSProperties;
16
+ export declare const selectViewportStyles: CSSProperties;
17
17
  /**
18
18
  * SelectItem inline styles.
19
19
  */
20
- export declare const glchatSelectItemStyles: CSSProperties;
20
+ export declare const selectItemStyles: CSSProperties;
21
21
  /**
22
22
  * SelectItem check indicator container.
23
23
  */
24
- export declare const glchatSelectItemIndicatorStyles: CSSProperties;
24
+ export declare const selectItemIndicatorStyles: CSSProperties;
25
25
  /**
26
26
  * Scroll button styles.
27
27
  */
28
- export declare const glchatSelectScrollButtonStyles: CSSProperties;
28
+ export declare const selectScrollButtonStyles: CSSProperties;
29
29
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/Select/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;GAEG;AACH,+DAA+D;AAC/D,eAAO,MAAM,8BAA8B,EAAE,aAO5C,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,aAElD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aAmBvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAcvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAcpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,aAO7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAO5C,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/Select/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;GAEG;AACH,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,EAAE,aAOtC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,aAE5C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAkBjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAcjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAElC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAc9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAOvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAOtC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * SelectTrigger inline styles — glchat-ui Select baseline.
3
3
  */
4
4
  /** Label text inside SelectTrigger (not Radix SelectValue). */
5
- export const glchatSelectTriggerLabelStyles = {
5
+ export const selectTriggerLabelStyles = {
6
6
  flex: 1,
7
7
  minWidth: 0,
8
8
  overflow: 'hidden',
@@ -10,12 +10,11 @@ export const glchatSelectTriggerLabelStyles = {
10
10
  whiteSpace: 'nowrap',
11
11
  textAlign: 'left',
12
12
  };
13
- export const glchatSelectTriggerPlaceholderStyles = {
13
+ export const selectTriggerPlaceholderStyles = {
14
14
  color: 'hsl(var(--foreground) / 0.5)',
15
15
  };
16
- export const glchatSelectTriggerStyles = {
16
+ export const selectTriggerStyles = {
17
17
  display: 'flex',
18
- height: '2.5rem',
19
18
  width: '100%',
20
19
  alignItems: 'center',
21
20
  justifyContent: 'space-between',
@@ -36,7 +35,7 @@ export const glchatSelectTriggerStyles = {
36
35
  /**
37
36
  * SelectContent inline styles — dropdown panel.
38
37
  */
39
- export const glchatSelectContentStyles = {
38
+ export const selectContentStyles = {
40
39
  position: 'relative',
41
40
  zIndex: 50,
42
41
  maxHeight: 'var(--radix-select-content-available-height)',
@@ -54,13 +53,13 @@ export const glchatSelectContentStyles = {
54
53
  /**
55
54
  * SelectViewport padding wrapper.
56
55
  */
57
- export const glchatSelectViewportStyles = {
56
+ export const selectViewportStyles = {
58
57
  padding: '0.25rem',
59
58
  };
60
59
  /**
61
60
  * SelectItem inline styles.
62
61
  */
63
- export const glchatSelectItemStyles = {
62
+ export const selectItemStyles = {
64
63
  position: 'relative',
65
64
  display: 'flex',
66
65
  width: '100%',
@@ -78,7 +77,7 @@ export const glchatSelectItemStyles = {
78
77
  /**
79
78
  * SelectItem check indicator container.
80
79
  */
81
- export const glchatSelectItemIndicatorStyles = {
80
+ export const selectItemIndicatorStyles = {
82
81
  marginLeft: 'auto',
83
82
  display: 'flex',
84
83
  height: '0.875rem',
@@ -89,7 +88,7 @@ export const glchatSelectItemIndicatorStyles = {
89
88
  /**
90
89
  * Scroll button styles.
91
90
  */
92
- export const glchatSelectScrollButtonStyles = {
91
+ export const selectScrollButtonStyles = {
93
92
  display: 'flex',
94
93
  cursor: 'default',
95
94
  alignItems: 'center',
@@ -1,7 +1,19 @@
1
- import { type ComponentRegistry } from '@a2ui/react';
1
+ import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
2
+ import { Catalog } from '@a2ui/web_core/v0_9';
2
3
  /**
3
- * Ensures the registry has the official default A2UI components
4
- * extended with GLChat-specific components (Button/Card/CheckBox/TextField/MultipleChoice/Timeout).
4
+ * Catalog identifier for the GLChat extended A2UI v0.9 catalog. Used as the
5
+ * `catalogId` in `createSurface` messages targeting the GLChat renderer.
5
6
  */
6
- export declare function ensureGlchatComponentsRegistered(registry: ComponentRegistry): void;
7
+ export declare const GLCHAT_CATALOG_ID = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json";
8
+ /** Basic catalog components whose JSON Schema is regenerated from Zod. */
9
+ export declare const GLCHAT_CATALOG_OVERRIDES: readonly ["Button"];
10
+ /** GLChat-only components not present in the basic catalog. */
11
+ export declare const GLCHAT_CATALOG_EXTENSIONS: readonly ["TagInput", "Timeout"];
12
+ /**
13
+ * Builds the GLChat A2UI v0.9 catalog:
14
+ * - Includes basic catalog components except those GLChat overrides (`Button`, `ChoicePicker`).
15
+ * - Adds GLChat overrides and extensions (`Button`, `ChoicePicker`, `TagInput`, `Timeout`).
16
+ * - Reuses basic catalog functions unchanged.
17
+ */
18
+ export declare function createGlchatCatalog(): Catalog<ReactComponentImplementation>;
7
19
  //# sourceMappingURL=catalog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/utils/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AAW7E;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,iBAAiB,QAoB3E"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/utils/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO9C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,iIACkG,CAAC;AAKjI,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,qBAAsB,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAgB3E"}
@@ -1,30 +1,35 @@
1
- import { registerDefaultCatalog } from '@a2ui/react';
2
- import { CustomButtonComponent } from '../components/a2ui/Button/Button.js';
3
- import { CustomCardComponent } from '../components/a2ui/Card/Card.js';
4
- import { CustomCheckBoxComponent } from '../components/a2ui/CheckBox/CheckBox.js';
5
- import { CustomMultipleChoiceComponent } from '../components/a2ui/MultipleChoice/MultipleChoice.js';
6
- import { CustomTextFieldComponent } from '../components/a2ui/TextField/TextField.js';
7
- import { CustomTimeoutComponent } from '../components/a2ui/Timeout/Timeout.js';
8
- const registeredRegistries = new WeakSet();
1
+ import { basicCatalog } from '@a2ui/react/v0_9';
2
+ import { Catalog } from '@a2ui/web_core/v0_9';
3
+ import { GlchatButtonComponent } from '../components/a2ui/Button/Button.js';
4
+ import { GlchatChoicePickerComponent } from '../components/a2ui/ChoicePicker/ChoicePicker.js';
5
+ import { GlchatTagInputComponent } from '../components/a2ui/TagInput/TagInput.js';
6
+ import { GlchatTimeoutComponent } from '../components/a2ui/Timeout/Timeout.js';
9
7
  /**
10
- * Ensures the registry has the official default A2UI components
11
- * extended with GLChat-specific components (Button/Card/CheckBox/TextField/MultipleChoice/Timeout).
8
+ * Catalog identifier for the GLChat extended A2UI v0.9 catalog. Used as the
9
+ * `catalogId` in `createSurface` messages targeting the GLChat renderer.
12
10
  */
13
- export function ensureGlchatComponentsRegistered(registry) {
14
- if (registeredRegistries.has(registry))
15
- return;
16
- registerDefaultCatalog(registry);
17
- registry.unregister('Button');
18
- registry.unregister('Card');
19
- registry.unregister('CheckBox');
20
- registry.unregister('TextField');
21
- registry.unregister('MultipleChoice');
22
- registry.unregister('Timeout');
23
- registry.register('Button', { component: CustomButtonComponent });
24
- registry.register('Card', { component: CustomCardComponent });
25
- registry.register('CheckBox', { component: CustomCheckBoxComponent });
26
- registry.register('TextField', { component: CustomTextFieldComponent });
27
- registry.register('MultipleChoice', { component: CustomMultipleChoiceComponent });
28
- registry.register('Timeout', { component: CustomTimeoutComponent });
29
- registeredRegistries.add(registry);
11
+ export const GLCHAT_CATALOG_ID = 'https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json';
12
+ /** Basic catalog components overridden at runtime by GLChat implementations. */
13
+ const OVERRIDDEN_COMPONENTS = new Set(['Button', 'ChoicePicker']);
14
+ /** Basic catalog components whose JSON Schema is regenerated from Zod. */
15
+ export const GLCHAT_CATALOG_OVERRIDES = ['Button'];
16
+ /** GLChat-only components not present in the basic catalog. */
17
+ export const GLCHAT_CATALOG_EXTENSIONS = ['TagInput', 'Timeout'];
18
+ /**
19
+ * Builds the GLChat A2UI v0.9 catalog:
20
+ * - Includes basic catalog components except those GLChat overrides (`Button`, `ChoicePicker`).
21
+ * - Adds GLChat overrides and extensions (`Button`, `ChoicePicker`, `TagInput`, `Timeout`).
22
+ * - Reuses basic catalog functions unchanged.
23
+ */
24
+ export function createGlchatCatalog() {
25
+ const baseComponents = Array.from(basicCatalog.components.values()).filter((component) => !OVERRIDDEN_COMPONENTS.has(component.name));
26
+ const components = [
27
+ ...baseComponents,
28
+ GlchatButtonComponent,
29
+ GlchatChoicePickerComponent,
30
+ GlchatTagInputComponent,
31
+ GlchatTimeoutComponent,
32
+ ];
33
+ const functions = Array.from(basicCatalog.functions.values());
34
+ return new Catalog(GLCHAT_CATALOG_ID, components, functions);
30
35
  }
@@ -0,0 +1,9 @@
1
+ import type { ReactComponentImplementation } from '@a2ui/react/v0_9';
2
+ import type { SurfaceGroupModel, SurfaceModel } from '@a2ui/web_core/v0_9';
3
+ /**
4
+ * Subscribes to surface creation/deletion on a `SurfaceGroupModel` and returns
5
+ * the current list of surfaces. The returned array is referentially stable
6
+ * until the set of surfaces changes, so it is safe for `useSyncExternalStore`.
7
+ */
8
+ export declare function useSurfaces(model: SurfaceGroupModel<ReactComponentImplementation>): SurfaceModel<ReactComponentImplementation>[];
9
+ //# sourceMappingURL=useSurfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSurfaces.d.ts","sourceRoot":"","sources":["../../../src/utils/useSurfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,GACrD,YAAY,CAAC,4BAA4B,CAAC,EAAE,CA6B9C"}
@@ -0,0 +1,28 @@
1
+ import { useCallback, useRef, useSyncExternalStore } from 'react';
2
+ /**
3
+ * Subscribes to surface creation/deletion on a `SurfaceGroupModel` and returns
4
+ * the current list of surfaces. The returned array is referentially stable
5
+ * until the set of surfaces changes, so it is safe for `useSyncExternalStore`.
6
+ */
7
+ export function useSurfaces(model) {
8
+ const cacheRef = useRef([]);
9
+ const subscribe = useCallback((onStoreChange) => {
10
+ const created = model.onSurfaceCreated.subscribe(() => onStoreChange());
11
+ const deleted = model.onSurfaceDeleted.subscribe(() => onStoreChange());
12
+ return () => {
13
+ created.unsubscribe();
14
+ deleted.unsubscribe();
15
+ };
16
+ }, [model]);
17
+ const getSnapshot = useCallback(() => {
18
+ const surfaces = Array.from(model.surfacesMap.values());
19
+ const cached = cacheRef.current;
20
+ if (cached.length === surfaces.length &&
21
+ cached.every((surface, index) => surface === surfaces[index])) {
22
+ return cached;
23
+ }
24
+ cacheRef.current = surfaces;
25
+ return surfaces;
26
+ }, [model]);
27
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
28
+ }
package/json/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # JSON reference files
2
+
3
+ This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer.
4
+
5
+ These files are generated from the official A2UI v0.9 basic catalog plus GLChat
6
+ extensions. To regenerate the catalog JSON after changing a component schema, run:
7
+
8
+ ```bash
9
+ npm run generate:json
10
+ ```
11
+
12
+ ---
13
+
14
+ ## `glchat_standard_catalog_definition.json` — GLChat component catalog
15
+
16
+ The GLChat extended A2UI **v0.9** unified catalog (components **and** functions).
17
+ It **extends** the official basic catalog JSON Schema (same structure as the
18
+ [rizzcharts custom catalog example](https://github.com/a2ui-project/a2ui/blob/main/samples/community/agent/adk/rizzcharts/catalog_schemas/0.9/rizzcharts_catalog_definition.json)):
19
+ clone [basic/catalog.json](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json),
20
+ normalize `common_types.json` refs, then merge GLChat overrides and extensions
21
+ generated from the live Zod component APIs.
22
+
23
+ **Base specification:** [a2ui-project/a2ui — A2UI v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json)
24
+
25
+ **Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json`
26
+
27
+ The GLChat catalog keeps the v0.9 basic catalog and adds/overrides:
28
+
29
+ 1. **`Button`** (override) — GLChat-styled button. Extends the basic catalog schema
30
+ with a `destructive` variant.
31
+
32
+ 2. **`ChoicePicker`** (override) — GLChat-styled choice picker. Schema matches the
33
+ basic catalog.
34
+
35
+ 3. **`TagInput`** (extension) — tag input field. `label`, `value` (string array),
36
+ `placeholder`, `disabled`, `disableTextInput`, `validationRegexp`,
37
+ `validationErrorMessage`.
38
+
39
+ 4. **`Timeout`** (extension) — countdown to a target UTC time. `targetTimeUtc`
40
+ (ISO 8601) and optional `variant` text style (`body`, `caption`, `h3`, `h4`, `h5`).
41
+
42
+ ### Components
43
+
44
+ | Component | Source |
45
+ |---|---|
46
+ | Text, Image, Icon, Video, AudioPlayer | v0.9 basic catalog |
47
+ | Row, Column, List, Card, Tabs, Divider, Modal | v0.9 basic catalog |
48
+ | TextField, CheckBox, Slider, DateTimeInput | v0.9 basic catalog |
49
+ | Button | GLChat override |
50
+ | ChoicePicker | GLChat override |
51
+ | TagInput | GLChat extension |
52
+ | Timeout | GLChat extension |
53
+
54
+ ---
55
+
56
+ ## `a2ui-sample-messages.json` — sample message sequence (all components)
57
+
58
+ A JSON array of A2UI **v0.9** messages (`createSurface`, `updateDataModel`,
59
+ `updateComponents`) describing a surface that includes **every component** from the
60
+ catalog. Validated against the catalog during generation. Use for reference and
61
+ testing.
@@ -0,0 +1,193 @@
1
+ [
2
+ {
3
+ "version": "v0.9",
4
+ "createSurface": {
5
+ "surfaceId": "main",
6
+ "catalogId": "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json",
7
+ "theme": {
8
+ "primaryColor": "#2563eb"
9
+ }
10
+ }
11
+ },
12
+ {
13
+ "version": "v0.9",
14
+ "updateDataModel": {
15
+ "surfaceId": "main",
16
+ "value": {
17
+ "form": {
18
+ "name": "Ada",
19
+ "agree": true,
20
+ "color": ["blue"],
21
+ "volume": 60,
22
+ "meeting": "2026-07-01T09:30",
23
+ "tags": ["alpha", "beta"],
24
+ "deadline": "2026-12-31T23:59:59Z"
25
+ }
26
+ }
27
+ }
28
+ },
29
+ {
30
+ "version": "v0.9",
31
+ "updateComponents": {
32
+ "surfaceId": "main",
33
+ "components": [
34
+ {
35
+ "id": "root",
36
+ "component": "Column",
37
+ "children": [
38
+ "title",
39
+ "hero",
40
+ "star",
41
+ "clip",
42
+ "audio",
43
+ "infoRow",
44
+ "linkList",
45
+ "profileCard",
46
+ "tabsExample",
47
+ "sep",
48
+ "detailsModal",
49
+ "submitBtn",
50
+ "deleteBtn",
51
+ "docsLink",
52
+ "nameField",
53
+ "agreeBox",
54
+ "colorPicker",
55
+ "volume",
56
+ "meeting",
57
+ "tags",
58
+ "countdown"
59
+ ]
60
+ },
61
+ { "id": "title", "component": "Text", "text": "A2UI v0.9 GLChat sample", "variant": "h3" },
62
+ {
63
+ "id": "hero",
64
+ "component": "Image",
65
+ "url": "https://placehold.co/600x200",
66
+ "variant": "largeFeature",
67
+ "description": "Hero image"
68
+ },
69
+ { "id": "star", "component": "Icon", "name": "star" },
70
+ { "id": "clip", "component": "Video", "url": "https://www.w3schools.com/html/mov_bbb.mp4" },
71
+ {
72
+ "id": "audio",
73
+ "component": "AudioPlayer",
74
+ "url": "https://www.w3schools.com/html/horse.mp3",
75
+ "description": "Sample audio"
76
+ },
77
+ {
78
+ "id": "infoRow",
79
+ "component": "Row",
80
+ "children": ["infoLeft", "infoRight"],
81
+ "justify": "spaceBetween",
82
+ "align": "center"
83
+ },
84
+ { "id": "infoLeft", "component": "Text", "text": "Left" },
85
+ { "id": "infoRight", "component": "Text", "text": "Right" },
86
+ {
87
+ "id": "linkList",
88
+ "component": "List",
89
+ "children": ["item1", "item2"],
90
+ "direction": "vertical"
91
+ },
92
+ { "id": "item1", "component": "Text", "text": "Item one" },
93
+ { "id": "item2", "component": "Text", "text": "Item two" },
94
+ { "id": "profileCard", "component": "Card", "child": "cardText" },
95
+ { "id": "cardText", "component": "Text", "text": "Inside a card" },
96
+ {
97
+ "id": "tabsExample",
98
+ "component": "Tabs",
99
+ "tabs": [
100
+ { "title": "Tab 1", "child": "tab1Text" },
101
+ { "title": "Tab 2", "child": "tab2Text" }
102
+ ]
103
+ },
104
+ { "id": "tab1Text", "component": "Text", "text": "First tab content" },
105
+ { "id": "tab2Text", "component": "Text", "text": "Second tab content" },
106
+ { "id": "sep", "component": "Divider", "axis": "horizontal" },
107
+ { "id": "detailsModal", "component": "Modal", "trigger": "modalTrigger", "content": "modalContent" },
108
+ { "id": "modalTrigger", "component": "Text", "text": "Open details" },
109
+ { "id": "modalContent", "component": "Text", "text": "Modal body content" },
110
+ {
111
+ "id": "submitBtn",
112
+ "component": "Button",
113
+ "child": "submitLabel",
114
+ "variant": "primary",
115
+ "action": { "event": { "name": "submit", "context": { "form": "main" } } }
116
+ },
117
+ { "id": "submitLabel", "component": "Text", "text": "Submit" },
118
+ {
119
+ "id": "deleteBtn",
120
+ "component": "Button",
121
+ "child": "deleteLabel",
122
+ "variant": "destructive",
123
+ "action": { "event": { "name": "delete" } }
124
+ },
125
+ { "id": "deleteLabel", "component": "Text", "text": "Delete" },
126
+ {
127
+ "id": "docsLink",
128
+ "component": "Button",
129
+ "child": "docsLabel",
130
+ "variant": "borderless",
131
+ "action": {
132
+ "functionCall": {
133
+ "call": "openUrl",
134
+ "args": { "url": "https://a2ui.org" },
135
+ "returnType": "void"
136
+ }
137
+ }
138
+ },
139
+ { "id": "docsLabel", "component": "Text", "text": "Open docs" },
140
+ {
141
+ "id": "nameField",
142
+ "component": "TextField",
143
+ "label": "Name",
144
+ "value": { "path": "/form/name" },
145
+ "variant": "shortText"
146
+ },
147
+ { "id": "agreeBox", "component": "CheckBox", "label": "I agree", "value": { "path": "/form/agree" } },
148
+ {
149
+ "id": "colorPicker",
150
+ "component": "ChoicePicker",
151
+ "label": "Favorite color",
152
+ "variant": "mutuallyExclusive",
153
+ "displayStyle": "chips",
154
+ "options": [
155
+ { "label": "Red", "value": "red" },
156
+ { "label": "Green", "value": "green" },
157
+ { "label": "Blue", "value": "blue" }
158
+ ],
159
+ "value": { "path": "/form/color" }
160
+ },
161
+ {
162
+ "id": "volume",
163
+ "component": "Slider",
164
+ "label": "Volume",
165
+ "min": 0,
166
+ "max": 100,
167
+ "value": { "path": "/form/volume" }
168
+ },
169
+ {
170
+ "id": "meeting",
171
+ "component": "DateTimeInput",
172
+ "label": "Meeting",
173
+ "value": { "path": "/form/meeting" },
174
+ "enableDate": true,
175
+ "enableTime": true
176
+ },
177
+ {
178
+ "id": "tags",
179
+ "component": "TagInput",
180
+ "label": "Tags",
181
+ "value": { "path": "/form/tags" },
182
+ "placeholder": "Add a tag"
183
+ },
184
+ {
185
+ "id": "countdown",
186
+ "component": "Timeout",
187
+ "targetTimeUtc": { "path": "/form/deadline" },
188
+ "variant": "body"
189
+ }
190
+ ]
191
+ }
192
+ }
193
+ ]