glchat-a2ui-react-renderer 0.2.7 → 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 (110) hide show
  1. package/README.md +223 -178
  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 +29 -14
  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/{MultipleChoice → ChoicePicker}/CheckboxList.js +2 -13
  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 +12 -9
  23. package/dist/src/components/a2ui/TagInput/TagInput.d.ts +289 -3
  24. package/dist/src/components/a2ui/TagInput/TagInput.d.ts.map +1 -1
  25. package/dist/src/components/a2ui/TagInput/TagInput.js +44 -54
  26. package/dist/src/components/a2ui/TagInput/theme.d.ts +0 -9
  27. package/dist/src/components/a2ui/TagInput/theme.d.ts.map +1 -1
  28. package/dist/src/components/a2ui/TagInput/theme.js +1 -9
  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/theme.d.ts +1 -1
  36. package/dist/src/components/ui/Button/theme.d.ts.map +1 -1
  37. package/dist/src/components/ui/Button/theme.js +11 -0
  38. package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts +1 -1
  39. package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
  40. package/dist/src/components/ui/Select/theme.d.ts.map +1 -1
  41. package/dist/src/components/ui/Select/theme.js +0 -1
  42. package/dist/src/utils/catalog.d.ts +16 -4
  43. package/dist/src/utils/catalog.d.ts.map +1 -1
  44. package/dist/src/utils/catalog.js +32 -23
  45. package/dist/src/utils/useSurfaces.d.ts +9 -0
  46. package/dist/src/utils/useSurfaces.d.ts.map +1 -0
  47. package/dist/src/utils/useSurfaces.js +28 -0
  48. package/json/README.md +36 -49
  49. package/json/a2ui-sample-messages.json +170 -315
  50. package/json/glchat_standard_catalog_definition.json +1236 -610
  51. package/package.json +11 -5
  52. package/styles/globals.css +196 -120
  53. package/dist/src/AllSurfacesRenderer.d.ts +0 -14
  54. package/dist/src/AllSurfacesRenderer.d.ts.map +0 -1
  55. package/dist/src/AllSurfacesRenderer.js +0 -18
  56. package/dist/src/SingleSurfaceRenderer.d.ts +0 -15
  57. package/dist/src/SingleSurfaceRenderer.d.ts.map +0 -1
  58. package/dist/src/SingleSurfaceRenderer.js +0 -9
  59. package/dist/src/components/a2ui/Button/theme.d.ts +0 -5
  60. package/dist/src/components/a2ui/Button/theme.d.ts.map +0 -1
  61. package/dist/src/components/a2ui/Button/theme.js +0 -5
  62. package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.d.ts +0 -4
  63. package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.d.ts.map +0 -1
  64. package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.js +0 -42
  65. package/dist/src/components/a2ui/ButtonAsLink/theme.d.ts +0 -8
  66. package/dist/src/components/a2ui/ButtonAsLink/theme.d.ts.map +0 -1
  67. package/dist/src/components/a2ui/ButtonAsLink/theme.js +0 -8
  68. package/dist/src/components/a2ui/Card/theme.d.ts +0 -4
  69. package/dist/src/components/a2ui/Card/theme.d.ts.map +0 -1
  70. package/dist/src/components/a2ui/Card/theme.js +0 -15
  71. package/dist/src/components/a2ui/CheckBox/theme.d.ts +0 -4
  72. package/dist/src/components/a2ui/CheckBox/theme.d.ts.map +0 -1
  73. package/dist/src/components/a2ui/CheckBox/theme.js +0 -11
  74. package/dist/src/components/a2ui/DateTimeInput/theme.d.ts +0 -8
  75. package/dist/src/components/a2ui/DateTimeInput/theme.d.ts.map +0 -1
  76. package/dist/src/components/a2ui/DateTimeInput/theme.js +0 -11
  77. package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.d.ts +0 -4
  78. package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.d.ts.map +0 -1
  79. package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.js +0 -22
  80. package/dist/src/components/a2ui/DestructiveButton/theme.d.ts +0 -8
  81. package/dist/src/components/a2ui/DestructiveButton/theme.d.ts.map +0 -1
  82. package/dist/src/components/a2ui/DestructiveButton/theme.js +0 -8
  83. package/dist/src/components/a2ui/MultipleChoice/CheckboxList.d.ts.map +0 -1
  84. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.d.ts +0 -4
  85. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.d.ts.map +0 -1
  86. package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.js +0 -72
  87. package/dist/src/components/a2ui/MultipleChoice/theme.d.ts +0 -13
  88. package/dist/src/components/a2ui/MultipleChoice/theme.d.ts.map +0 -1
  89. package/dist/src/components/a2ui/TextField/theme.d.ts +0 -4
  90. package/dist/src/components/a2ui/TextField/theme.d.ts.map +0 -1
  91. package/dist/src/components/a2ui/TextField/theme.js +0 -9
  92. package/dist/src/components/a2ui/Timeout/theme.d.ts +0 -8
  93. package/dist/src/components/a2ui/Timeout/theme.d.ts.map +0 -1
  94. package/dist/src/components/a2ui/Timeout/theme.js +0 -12
  95. package/dist/src/components/a2ui/types.d.ts +0 -12
  96. package/dist/src/components/a2ui/types.d.ts.map +0 -1
  97. package/dist/src/components/a2ui/types.js +0 -1
  98. package/dist/src/components/ui/Button/ButtonAsLink.d.ts +0 -15
  99. package/dist/src/components/ui/Button/ButtonAsLink.d.ts.map +0 -1
  100. package/dist/src/components/ui/Button/ButtonAsLink.js +0 -17
  101. package/dist/src/components/ui/TextField/theme.d.ts +0 -4
  102. package/dist/src/components/ui/TextField/theme.d.ts.map +0 -1
  103. package/dist/src/components/ui/TextField/theme.js +0 -22
  104. package/dist/src/utils/href.d.ts +0 -11
  105. package/dist/src/utils/href.d.ts.map +0 -1
  106. package/dist/src/utils/href.js +0 -34
  107. package/dist/src/utils/theme.d.ts +0 -15
  108. package/dist/src/utils/theme.d.ts.map +0 -1
  109. package/dist/src/utils/theme.js +0 -93
  110. package/json/glchat_server_to_client_with_catalog.json +0 -1000
@@ -1,56 +1,70 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { createContext, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
4
- import { A2UIProvider, ComponentRegistry, useA2UI, } from '@a2ui/react';
5
- import { ensureGlchatComponentsRegistered } from './utils/catalog.js';
6
- import { mergeGlchatTheme } from './utils/theme.js';
7
- const A2UIRegistryContext = createContext(null);
8
- function MessagesProcessor({ messages, onError, }) {
9
- const { processMessages } = useA2UI();
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
4
+ import { MarkdownContext } from '@a2ui/react/v0_9';
5
+ import { MessageProcessor, } from '@a2ui/web_core/v0_9';
6
+ import { injectBasicCatalogStyles } from '@a2ui/web_core/v0_9/basic_catalog';
7
+ import { renderMarkdown } from '@a2ui/markdown-it';
8
+ import { createGlchatCatalog } from './utils/catalog.js';
9
+ const SurfaceGroupContext = createContext(null);
10
+ export function Provider({ messages, onAction, onError, catalog, children, }) {
11
+ const onActionRef = useRef(onAction);
12
+ const onErrorRef = useRef(onError);
10
13
  useEffect(() => {
11
- if (!messages)
14
+ onActionRef.current = onAction;
15
+ }, [onAction]);
16
+ useEffect(() => {
17
+ onErrorRef.current = onError;
18
+ }, [onError]);
19
+ const [processor] = useState(() => {
20
+ const resolvedCatalog = catalog ?? createGlchatCatalog();
21
+ return new MessageProcessor([resolvedCatalog]);
22
+ });
23
+ const processedCountRef = useRef(0);
24
+ useEffect(() => {
25
+ const subscription = processor.model.onAction.subscribe((action) => {
26
+ onActionRef.current?.(action);
27
+ });
28
+ return () => subscription.unsubscribe();
29
+ }, [processor]);
30
+ useEffect(() => {
31
+ if (typeof document !== 'undefined' && document.adoptedStyleSheets) {
32
+ injectBasicCatalogStyles();
33
+ }
34
+ }, []);
35
+ useEffect(() => {
36
+ if (!messages?.length)
37
+ return;
38
+ // Shorter list means the consumer reset the stream — reprocess from the start.
39
+ if (messages.length < processedCountRef.current) {
40
+ processedCountRef.current = 0;
41
+ }
42
+ if (processedCountRef.current >= messages.length)
12
43
  return;
44
+ const pending = messages.slice(processedCountRef.current);
45
+ processedCountRef.current = messages.length;
13
46
  try {
14
- processMessages(messages);
47
+ processor.processMessages(pending);
15
48
  }
16
49
  catch (error) {
17
- if (onError) {
18
- onError(error);
50
+ if (onErrorRef.current) {
51
+ onErrorRef.current(error);
19
52
  }
20
53
  else {
21
54
  // eslint-disable-next-line no-console
22
55
  console.error('[glchat-a2ui] Failed to process messages:', error);
23
56
  }
24
57
  }
25
- }, [messages, processMessages, onError]);
26
- return null;
27
- }
28
- export function Provider(props) {
29
- const registry = useMemo(() => props.registry ?? ComponentRegistry.getInstance(), [props.registry]);
30
- const providerOnActionRef = useRef(props.onAction);
31
- useEffect(() => {
32
- providerOnActionRef.current = props.onAction;
33
- }, [props.onAction]);
34
- const onAction = useCallback((event) => {
35
- const userAction = event?.userAction;
36
- if (!userAction)
37
- return;
38
- const handler = providerOnActionRef.current;
39
- if (!handler)
40
- return;
41
- handler(userAction);
42
- }, []);
43
- // Register (or override) components after `@a2ui/react` has initialized its defaults.
44
- // This avoids the official default catalog overwriting our custom component registrations.
45
- useEffect(() => {
46
- ensureGlchatComponentsRegistered(registry);
47
- }, [registry]);
48
- const theme = useMemo(() => mergeGlchatTheme(props.theme), [props.theme]);
49
- return (_jsx(A2UIRegistryContext.Provider, { value: registry, children: _jsxs(A2UIProvider, { onAction: onAction, theme: theme, children: [_jsx(MessagesProcessor, { messages: props.messages, onError: props.onError }), props.children] }) }));
58
+ }, [messages, processor]);
59
+ return (_jsx(SurfaceGroupContext.Provider, { value: processor.model, children: _jsx(MarkdownContext.Provider, { value: renderMarkdown, children: children }) }));
50
60
  }
51
- export function useA2UIRegistry() {
52
- const registry = useContext(A2UIRegistryContext);
53
- if (!registry)
54
- throw new Error('useA2UIRegistry must be used inside Provider');
55
- return registry;
61
+ /**
62
+ * Returns the `SurfaceGroupModel` owned by the nearest `Provider`.
63
+ * Used by the surface renderers to read and subscribe to active surfaces.
64
+ */
65
+ export function useSurfaceGroup() {
66
+ const model = useContext(SurfaceGroupContext);
67
+ if (!model)
68
+ throw new Error('useSurfaceGroup must be used inside Provider');
69
+ return model;
56
70
  }
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ export type SurfaceRendererProps = {
3
+ /** When set, render only this surface. When omitted, render all active surfaces. */
4
+ surfaceId?: string;
5
+ className?: string;
6
+ /** Shown while no surface(s) are available to render. */
7
+ fallback?: ReactNode;
8
+ };
9
+ /**
10
+ * Renders one or all active A2UI surfaces from the nearest `Provider`.
11
+ *
12
+ * - Omit `surfaceId` to render every active surface.
13
+ * - Set `surfaceId` to render a single surface.
14
+ * - Shows `fallback` (default: empty) until surface(s) exist.
15
+ */
16
+ export declare function SurfaceRenderer(props: Readonly<SurfaceRendererProps>): import("react").JSX.Element;
17
+ //# sourceMappingURL=SurfaceRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../src/SurfaceRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,MAAM,MAAM,oBAAoB,GAAG;IACjC,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BA4BpE"}
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { A2uiSurface } from '@a2ui/react/v0_9';
4
+ import { useSurfaceGroup } from './Provider.js';
5
+ import { useSurfaces } from './utils/useSurfaces.js';
6
+ const DEFAULT_FALLBACK = _jsx(_Fragment, {});
7
+ /**
8
+ * Renders one or all active A2UI surfaces from the nearest `Provider`.
9
+ *
10
+ * - Omit `surfaceId` to render every active surface.
11
+ * - Set `surfaceId` to render a single surface.
12
+ * - Shows `fallback` (default: empty) until surface(s) exist.
13
+ */
14
+ export function SurfaceRenderer(props) {
15
+ const model = useSurfaceGroup();
16
+ const surfaces = useSurfaces(model);
17
+ const fallback = props.fallback ?? DEFAULT_FALLBACK;
18
+ const surfaceClassName = props.className ? `a2ui-surface ${props.className}` : 'a2ui-surface';
19
+ if (props.surfaceId !== undefined) {
20
+ const surface = model.getSurface(props.surfaceId);
21
+ if (!surface)
22
+ return _jsx(_Fragment, { children: fallback });
23
+ return (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }));
24
+ }
25
+ if (surfaces.length === 0)
26
+ return _jsx(_Fragment, { children: fallback });
27
+ return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) }));
28
+ }
@@ -1,4 +1,314 @@
1
- import { type A2UIComponentProps } from '@a2ui/react';
2
- import type { ButtonNode } from '@a2ui/web_core/types/types';
3
- export declare function CustomButtonComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<ButtonNode>>): import("react/jsx-runtime").JSX.Element;
1
+ import { z } from 'zod';
2
+ /**
3
+ * GLChat Button schema — upstream `ButtonApi` with an extra `destructive` variant.
4
+ */
5
+ export declare const GlchatButtonApi: {
6
+ name: string;
7
+ schema: z.ZodObject<{
8
+ child: z.ZodString;
9
+ action: z.ZodUnion<[z.ZodObject<{
10
+ event: z.ZodObject<{
11
+ name: z.ZodString;
12
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodAny, "many">, z.ZodObject<{
13
+ path: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ path: string;
16
+ }, {
17
+ path: string;
18
+ }>, z.ZodObject<{
19
+ call: z.ZodString;
20
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
21
+ returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ call: string;
24
+ args: Record<string, any>;
25
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
26
+ }, {
27
+ call: string;
28
+ args: Record<string, any>;
29
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
30
+ }>]>>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ name: string;
33
+ context?: Record<string, string | number | boolean | any[] | {
34
+ path: string;
35
+ } | {
36
+ call: string;
37
+ args: Record<string, any>;
38
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
39
+ }> | undefined;
40
+ }, {
41
+ name: string;
42
+ context?: Record<string, string | number | boolean | any[] | {
43
+ path: string;
44
+ } | {
45
+ call: string;
46
+ args: Record<string, any>;
47
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
48
+ }> | undefined;
49
+ }>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ event: {
52
+ name: string;
53
+ context?: Record<string, string | number | boolean | any[] | {
54
+ path: string;
55
+ } | {
56
+ call: string;
57
+ args: Record<string, any>;
58
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
59
+ }> | undefined;
60
+ };
61
+ }, {
62
+ event: {
63
+ name: string;
64
+ context?: Record<string, string | number | boolean | any[] | {
65
+ path: string;
66
+ } | {
67
+ call: string;
68
+ args: Record<string, any>;
69
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
70
+ }> | undefined;
71
+ };
72
+ }>, z.ZodObject<{
73
+ functionCall: z.ZodObject<{
74
+ call: z.ZodString;
75
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
76
+ returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ call: string;
79
+ args: Record<string, any>;
80
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
81
+ }, {
82
+ call: string;
83
+ args: Record<string, any>;
84
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
85
+ }>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ functionCall: {
88
+ call: string;
89
+ args: Record<string, any>;
90
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
91
+ };
92
+ }, {
93
+ functionCall: {
94
+ call: string;
95
+ args: Record<string, any>;
96
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
97
+ };
98
+ }>]>;
99
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
+ condition: z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
101
+ path: z.ZodString;
102
+ }, "strip", z.ZodTypeAny, {
103
+ path: string;
104
+ }, {
105
+ path: string;
106
+ }>, z.ZodObject<{
107
+ call: z.ZodString;
108
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
109
+ returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ call: string;
112
+ args: Record<string, any>;
113
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
114
+ }, {
115
+ call: string;
116
+ args: Record<string, any>;
117
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
118
+ }>]>;
119
+ message: z.ZodString;
120
+ }, "strip", z.ZodTypeAny, {
121
+ message: string;
122
+ condition: boolean | {
123
+ path: string;
124
+ } | {
125
+ call: string;
126
+ args: Record<string, any>;
127
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
128
+ };
129
+ }, {
130
+ message: string;
131
+ condition: boolean | {
132
+ path: string;
133
+ } | {
134
+ call: string;
135
+ args: Record<string, any>;
136
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
137
+ };
138
+ }>, "many">>;
139
+ accessibility: z.ZodOptional<z.ZodObject<{
140
+ label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
141
+ path: z.ZodString;
142
+ }, "strip", z.ZodTypeAny, {
143
+ path: string;
144
+ }, {
145
+ path: string;
146
+ }>, z.ZodObject<{
147
+ call: z.ZodString;
148
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
149
+ returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ call: string;
152
+ args: Record<string, any>;
153
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
154
+ }, {
155
+ call: string;
156
+ args: Record<string, any>;
157
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
158
+ }>]>>;
159
+ description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
160
+ path: z.ZodString;
161
+ }, "strip", z.ZodTypeAny, {
162
+ path: string;
163
+ }, {
164
+ path: string;
165
+ }>, z.ZodObject<{
166
+ call: z.ZodString;
167
+ args: z.ZodRecord<z.ZodString, z.ZodAny>;
168
+ returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ call: string;
171
+ args: Record<string, any>;
172
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
173
+ }, {
174
+ call: string;
175
+ args: Record<string, any>;
176
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
177
+ }>]>>;
178
+ }, "strip", z.ZodTypeAny, {
179
+ description?: string | {
180
+ path: string;
181
+ } | {
182
+ call: string;
183
+ args: Record<string, any>;
184
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
185
+ } | undefined;
186
+ label?: string | {
187
+ path: string;
188
+ } | {
189
+ call: string;
190
+ args: Record<string, any>;
191
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
192
+ } | undefined;
193
+ }, {
194
+ description?: string | {
195
+ path: string;
196
+ } | {
197
+ call: string;
198
+ args: Record<string, any>;
199
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
200
+ } | undefined;
201
+ label?: string | {
202
+ path: string;
203
+ } | {
204
+ call: string;
205
+ args: Record<string, any>;
206
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
207
+ } | undefined;
208
+ }>>;
209
+ weight: z.ZodOptional<z.ZodNumber>;
210
+ } & {
211
+ variant: z.ZodOptional<z.ZodDefault<z.ZodEnum<["default", "primary", "borderless", "destructive"]>>>;
212
+ }, "strict", z.ZodTypeAny, {
213
+ child: string;
214
+ action: {
215
+ event: {
216
+ name: string;
217
+ context?: Record<string, string | number | boolean | any[] | {
218
+ path: string;
219
+ } | {
220
+ call: string;
221
+ args: Record<string, any>;
222
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
223
+ }> | undefined;
224
+ };
225
+ } | {
226
+ functionCall: {
227
+ call: string;
228
+ args: Record<string, any>;
229
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
230
+ };
231
+ };
232
+ weight?: number | undefined;
233
+ variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
234
+ checks?: {
235
+ message: string;
236
+ condition: boolean | {
237
+ path: string;
238
+ } | {
239
+ call: string;
240
+ args: Record<string, any>;
241
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
242
+ };
243
+ }[] | undefined;
244
+ accessibility?: {
245
+ description?: string | {
246
+ path: string;
247
+ } | {
248
+ call: string;
249
+ args: Record<string, any>;
250
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
251
+ } | undefined;
252
+ label?: string | {
253
+ path: string;
254
+ } | {
255
+ call: string;
256
+ args: Record<string, any>;
257
+ returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
258
+ } | undefined;
259
+ } | undefined;
260
+ }, {
261
+ child: string;
262
+ action: {
263
+ event: {
264
+ name: string;
265
+ context?: Record<string, string | number | boolean | any[] | {
266
+ path: string;
267
+ } | {
268
+ call: string;
269
+ args: Record<string, any>;
270
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
271
+ }> | undefined;
272
+ };
273
+ } | {
274
+ functionCall: {
275
+ call: string;
276
+ args: Record<string, any>;
277
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
278
+ };
279
+ };
280
+ weight?: number | undefined;
281
+ variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
282
+ checks?: {
283
+ message: string;
284
+ condition: boolean | {
285
+ path: string;
286
+ } | {
287
+ call: string;
288
+ args: Record<string, any>;
289
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
290
+ };
291
+ }[] | undefined;
292
+ accessibility?: {
293
+ description?: string | {
294
+ path: string;
295
+ } | {
296
+ call: string;
297
+ args: Record<string, any>;
298
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
299
+ } | undefined;
300
+ label?: string | {
301
+ path: string;
302
+ } | {
303
+ call: string;
304
+ args: Record<string, any>;
305
+ returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
306
+ } | undefined;
307
+ } | undefined;
308
+ }>;
309
+ };
310
+ /**
311
+ * GLChat-styled Button. Overrides the basic catalog `Button` with extended variants.
312
+ */
313
+ export declare const GlchatButtonComponent: import("@a2ui/react/v0_9").ReactComponentImplementation;
4
314
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAO7D,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CAiC1C"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Button/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;8BAqC0wsE,CAAC;;;;uBAA0M,CAAC;;;;;;;;;uBAA6Y,CAAC;;;;;8BAA8N,CAAC;;;;;;uBAAmP,CAAC;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;;;;;;;;;0BAAmuB,CAAC;;;;;;;;;;;;0BAA4e,CAAC;;;;;;;;;;;;;;;;;;;;;0BAA27B,CAAC;;;;;;;;;;;;;;;;;;;0BAAwrB,CAAC;;;;;;;;;;;;;;;;;;;;;0BAAw8B,CAAC;;;;;;;;;;;;;;;;;;;0BAAy4B,CAAC;;;uBAAmK,CAAC;;;;;;;iBAAqR,CAAC;;;;;;;;uBAAwS,CAAC;;;;;0BAAgK,CAAC;;iBAAiI,CAAC;;;;;0BAAgK,CAAC;;;;;;;;;;;uBAA98M,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;0BAAgtC,CAAC;;;;;;;;;;;;0BAAonD,CAAC;;;;;;;;;0BAAstF,CAAC;;;;;;;0BAAkS,CAAC;;;;CA1B/x7E,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,qBAAqB,yDAajC,CAAC"}
@@ -1,18 +1,33 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react';
4
- import { useMemo } from 'react';
3
+ import { createComponentImplementation } from '@a2ui/react/v0_9';
4
+ import { ButtonApi } from '@a2ui/web_core/v0_9/basic_catalog';
5
+ import { z } from 'zod';
5
6
  import { Button } from '../../ui/Button/Button.js';
6
- export function CustomButtonComponent({ node, surfaceId, }) {
7
- const { sendAction, theme } = useA2UIComponent(node, surfaceId);
8
- const { child, action, primary } = node.properties;
9
- const variant = useMemo(() => (primary ? 'primary' : 'outline'), [primary]);
10
- const buttonStyle = useMemo(() => stylesToObject(theme.additionalStyles?.Button), [theme.additionalStyles?.Button]);
11
- const handleClick = () => {
12
- if (action) {
13
- sendAction(action);
14
- }
15
- };
16
- const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
17
- return (_jsx("div", { className: "a2ui-button", style: hostStyle, children: _jsx(Button, { variant: variant, className: classMapToString(theme.components.Button), style: buttonStyle, onClick: handleClick, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
7
+ import { getWeightStyle } from '../common.js';
8
+ /**
9
+ * GLChat Button schema — upstream `ButtonApi` with an extra `destructive` variant.
10
+ */
11
+ export const GlchatButtonApi = {
12
+ name: 'Button',
13
+ schema: ButtonApi.schema.extend({
14
+ variant: z
15
+ .enum(['default', 'primary', 'borderless', 'destructive'])
16
+ .default('default')
17
+ .describe("A hint for the button style. If omitted, a default button style is used. 'primary' indicates this is the main call-to-action button. 'borderless' means the button has no visual border or background, making its child content appear like a clickable link. 'destructive' indicates a dangerous or irreversible action.")
18
+ .optional(),
19
+ }),
20
+ };
21
+ function toButtonVariant(variant) {
22
+ if (variant === 'primary')
23
+ return 'primary';
24
+ if (variant === 'borderless')
25
+ return 'borderless';
26
+ if (variant === 'destructive')
27
+ return 'destructive';
28
+ return 'outline';
18
29
  }
30
+ /**
31
+ * GLChat-styled Button. Overrides the basic catalog `Button` with extended variants.
32
+ */
33
+ export const GlchatButtonComponent = createComponentImplementation(GlchatButtonApi, ({ props, buildChild }) => (_jsx("div", { className: "a2ui-button", style: getWeightStyle(props.weight), children: _jsx(Button, { variant: toButtonVariant(props.variant), disabled: props.isValid === false, onClick: props.action, children: props.child ? buildChild(props.child) : null }) })));
@@ -4,9 +4,8 @@ export type CheckboxListProps = {
4
4
  value: string[];
5
5
  onValueChange: (value: string[]) => void;
6
6
  singleSelect: boolean;
7
- maxSelections?: number;
8
7
  filterable?: boolean;
9
8
  className?: string;
10
9
  };
11
- export declare function CheckboxList({ options, value, onValueChange, singleSelect, maxSelections, filterable, className, }: Readonly<CheckboxListProps>): import("react/jsx-runtime").JSX.Element;
10
+ export declare function CheckboxList({ options, value, onValueChange, singleSelect, filterable, className, }: Readonly<CheckboxListProps>): import("react").JSX.Element;
12
11
  //# sourceMappingURL=CheckboxList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxList.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/ChoicePicker/CheckboxList.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAOvE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,aAAa,EACb,YAAY,EACZ,UAAkB,EAClB,SAAS,GACV,EAAE,QAAQ,CAAC,iBAAiB,CAAC,+BA6D7B"}
@@ -4,7 +4,7 @@ import { useId, useMemo, useState } from 'react';
4
4
  import { Checkbox } from '../../ui/Checkbox/Checkbox.js';
5
5
  import { checkboxLabelStyles } from '../../ui/Checkbox/theme.js';
6
6
  import { checkboxListContainerStyles, checkboxListItemStyles, checkboxListSearchStyles, } from './theme.js';
7
- export function CheckboxList({ options, value, onValueChange, singleSelect, maxSelections, filterable = false, className, }) {
7
+ export function CheckboxList({ options, value, onValueChange, singleSelect, filterable = false, className, }) {
8
8
  const [search, setSearch] = useState('');
9
9
  const groupId = useId();
10
10
  const filteredOptions = useMemo(() => {
@@ -23,23 +23,12 @@ export function CheckboxList({ options, value, onValueChange, singleSelect, maxS
23
23
  onValueChange(value.filter((v) => v !== optionValue));
24
24
  return;
25
25
  }
26
- if (maxSelections !== void 0 && value.length >= maxSelections) {
27
- return;
28
- }
29
26
  onValueChange([...value, optionValue]);
30
27
  };
31
28
  const listClassName = ['glchat-a2ui-checkbox-list', className].filter(Boolean).join(' ');
32
29
  return (_jsxs("div", { className: listClassName, style: checkboxListContainerStyles, children: [filterable && (_jsx("input", { type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Search...", style: checkboxListSearchStyles })), filteredOptions.map((option) => {
33
30
  const isSelected = value.includes(option.value);
34
- const atMax = !singleSelect &&
35
- maxSelections !== void 0 &&
36
- value.length >= maxSelections &&
37
- !isSelected;
38
31
  const optionId = `${groupId}-${option.value}`;
39
- return (_jsxs("label", { htmlFor: optionId, className: "glchat-a2ui-checkbox-option", style: {
40
- ...checkboxListItemStyles,
41
- opacity: atMax ? 0.5 : 1,
42
- cursor: atMax ? 'not-allowed' : 'pointer',
43
- }, children: [_jsx(Checkbox, { id: optionId, checked: isSelected, disabled: atMax, onCheckedChange: () => toggleOption(option.value) }), _jsx("span", { style: checkboxLabelStyles, children: option.label })] }, option.value));
32
+ return (_jsxs("label", { htmlFor: optionId, className: "glchat-a2ui-checkbox-option", style: { ...checkboxListItemStyles, cursor: 'pointer' }, children: [_jsx(Checkbox, { id: optionId, checked: isSelected, onCheckedChange: () => toggleOption(option.value) }), _jsx("span", { style: checkboxLabelStyles, children: option.label })] }, option.value));
44
33
  })] }));
45
34
  }
@@ -0,0 +1,9 @@
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 declare const GlchatChoicePickerComponent: import("@a2ui/react/v0_9").ReactComponentImplementation;
9
+ //# sourceMappingURL=ChoicePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoicePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/ChoicePicker/ChoicePicker.tsx"],"names":[],"mappings":"AA6DA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,yDA6EvC,CAAC"}