glchat-a2ui-react-renderer 0.3.2 → 0.3.4
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.js +13 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts +6 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js +15 -0
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts +22 -22
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -1
- package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts +2 -2
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts +231 -0
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.js +24 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.d.ts +9 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.d.ts.map +1 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.js +156 -0
- package/dist/src/components/ui/AudioPlayer/theme.d.ts +12 -0
- package/dist/src/components/ui/AudioPlayer/theme.d.ts.map +1 -0
- package/dist/src/components/ui/AudioPlayer/theme.js +69 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts +14 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts.map +1 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.js +9 -0
- package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/src/components/ui/MultiSelect/MultiSelect.js +4 -10
- package/dist/src/components/ui/Select/Select.d.ts.map +1 -1
- package/dist/src/components/ui/Select/Select.js +1 -1
- package/dist/src/v0_8/Provider.d.ts.map +1 -1
- package/dist/src/v0_8/Provider.js +10 -2
- package/dist/src/v0_8/registry.d.ts +5 -0
- package/dist/src/v0_8/registry.d.ts.map +1 -1
- package/dist/src/v0_8/registry.js +26 -12
- package/dist/src/v0_9/Provider.d.ts +6 -1
- package/dist/src/v0_9/Provider.d.ts.map +1 -1
- package/dist/src/v0_9/Provider.js +17 -8
- package/dist/src/v0_9/SurfaceRenderer.d.ts.map +1 -1
- package/dist/src/v0_9/SurfaceRenderer.js +28 -3
- package/dist/src/v0_9/catalog.d.ts +8 -2
- package/dist/src/v0_9/catalog.d.ts.map +1 -1
- package/dist/src/v0_9/catalog.js +20 -3
- package/json/v0_8/a2ui-sample-messages.json +1 -14
- package/json/v0_8/glchat_standard_catalog_definition.json +1 -1
- package/json/v0_9/glchat_standard_catalog_definition.json +1 -1
- package/package.json +1 -1
- package/styles/globals.css +124 -0
- package/styles/theme-v4.css +5 -0
- package/tailwind.config.cjs +9 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const audioPlayerRootStyles = {
|
|
2
|
+
width: '100%',
|
|
3
|
+
maxWidth: '100%',
|
|
4
|
+
margin: '1rem 0',
|
|
5
|
+
};
|
|
6
|
+
export const audioPlayerCardStyles = {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
width: '100%',
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
gap: '0.375rem',
|
|
11
|
+
borderRadius: 'var(--radius-md)',
|
|
12
|
+
border: '1px solid hsl(var(--border))',
|
|
13
|
+
padding: '0.5rem 0.75rem',
|
|
14
|
+
boxSizing: 'border-box',
|
|
15
|
+
};
|
|
16
|
+
export const audioPlayerHeaderStyles = {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'space-between',
|
|
20
|
+
gap: '0.5rem',
|
|
21
|
+
minWidth: 0,
|
|
22
|
+
};
|
|
23
|
+
export const audioPlayerTitleStyles = {
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
textOverflow: 'ellipsis',
|
|
26
|
+
whiteSpace: 'nowrap',
|
|
27
|
+
fontSize: '0.875rem',
|
|
28
|
+
fontWeight: 600,
|
|
29
|
+
color: 'hsl(var(--foreground))',
|
|
30
|
+
minWidth: 0,
|
|
31
|
+
};
|
|
32
|
+
export const audioPlayerMetaStyles = {
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
fontSize: '0.75rem',
|
|
35
|
+
color: 'hsl(var(--foreground) / 0.5)',
|
|
36
|
+
};
|
|
37
|
+
export const audioPlayerControlsStyles = {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
gap: '0.5rem',
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
};
|
|
43
|
+
export const audioPlayerIconButtonStyles = {
|
|
44
|
+
width: '1.75rem',
|
|
45
|
+
height: '1.75rem',
|
|
46
|
+
padding: 0,
|
|
47
|
+
flexShrink: 0,
|
|
48
|
+
borderRadius: 'var(--radius-sm)',
|
|
49
|
+
};
|
|
50
|
+
export const audioPlayerTimeStyles = {
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
fontSize: '0.75rem',
|
|
53
|
+
fontVariantNumeric: 'tabular-nums',
|
|
54
|
+
color: 'hsl(var(--foreground) / 0.5)',
|
|
55
|
+
};
|
|
56
|
+
export const audioPlayerProgressStyles = {
|
|
57
|
+
height: '0.25rem',
|
|
58
|
+
minWidth: 0,
|
|
59
|
+
flex: 1,
|
|
60
|
+
cursor: 'pointer',
|
|
61
|
+
appearance: 'none',
|
|
62
|
+
WebkitAppearance: 'none',
|
|
63
|
+
borderRadius: '9999px',
|
|
64
|
+
border: 'none',
|
|
65
|
+
outline: 'none',
|
|
66
|
+
};
|
|
67
|
+
export const audioPlayerHiddenAudioStyles = {
|
|
68
|
+
display: 'none',
|
|
69
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
export type InlineAlertProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
/** Visual tone. Defaults to `warning`. */
|
|
4
|
+
variant?: 'warning' | 'error';
|
|
5
|
+
/** Alert message text. */
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
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;
|
|
13
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
//# sourceMappingURL=InlineAlert.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleAlert } from 'lucide-react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
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 }) })] }));
|
|
8
|
+
});
|
|
9
|
+
InlineAlert.displayName = 'InlineAlert';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQ3C,OAAO,EAaL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,KAAK,EACL,aAAa,EACb,WAA8B,EAC9B,QAAgB,EAChB,UAAkB,EAClB,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,QAAQ,CAAC,gBAAgB,CAAC,+
|
|
1
|
+
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/MultiSelect/MultiSelect.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQ3C,OAAO,EAaL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,KAAK,EACL,aAAa,EACb,WAA8B,EAC9B,QAAgB,EAChB,UAAkB,EAClB,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,QAAQ,CAAC,gBAAgB,CAAC,+BA2R5B"}
|
|
@@ -104,28 +104,22 @@ export function MultiSelect({ options, value, onValueChange, placeholder = 'Sele
|
|
|
104
104
|
width: '100%',
|
|
105
105
|
alignItems: 'center',
|
|
106
106
|
justifyContent: 'space-between',
|
|
107
|
-
}, children: [_jsx("span", { style: multiSelectPlaceholderStyles, children: placeholder }), _jsx(ChevronDown, { style: { height: '1rem', width: '1rem', opacity: 0.5 }, strokeWidth: 1.5, "aria-hidden": true })] })) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { align: "start",
|
|
107
|
+
}, children: [_jsx("span", { style: multiSelectPlaceholderStyles, children: placeholder }), _jsx(ChevronDown, { style: { height: '1rem', width: '1rem', opacity: 0.5 }, strokeWidth: 1.5, "aria-hidden": true })] })) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { align: "start", className: "glchat-a2ui-multiselect-content", style: multiSelectContentStyles, onEscapeKeyDown: () => setOpen(false), children: [filterable && (_jsx("input", { type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Search...", style: multiSelectSearchInputStyles })), _jsxs("div", { style: multiSelectListStyles, children: [options.length > 0 && (_jsxs("button", { type: "button", className: "glchat-a2ui-multiselect-option", style: {
|
|
108
108
|
...multiSelectOptionStyles,
|
|
109
109
|
...(hoveredOption === '__all__' ? optionHoverStyle : {}),
|
|
110
|
-
}, onMouseEnter: () => setHoveredOption('__all__'), onMouseLeave: () => setHoveredOption(null), onClick: toggleAll, children: [_jsx("span", { style: isAllSelected
|
|
111
|
-
? multiSelectCheckboxCheckedStyles
|
|
112
|
-
: multiSelectCheckboxStyles, children: isAllSelected && (_jsx(Check, { style: { height: '1rem', width: '1rem' }, strokeWidth: 1.5 })) }), _jsx("span", { children: "Select all" })] })), filteredOptions.length === 0 ? (_jsx("div", { style: {
|
|
110
|
+
}, onMouseEnter: () => setHoveredOption('__all__'), onMouseLeave: () => setHoveredOption(null), onClick: toggleAll, children: [_jsx("span", { style: isAllSelected ? multiSelectCheckboxCheckedStyles : multiSelectCheckboxStyles, children: isAllSelected && (_jsx(Check, { style: { height: '1rem', width: '1rem' }, strokeWidth: 1.5 })) }), _jsx("span", { children: "Select all" })] })), filteredOptions.length === 0 ? (_jsx("div", { style: {
|
|
113
111
|
padding: '0.5rem 0.75rem',
|
|
114
112
|
fontSize: '0.875rem',
|
|
115
113
|
color: 'hsl(var(--foreground) / 0.5)',
|
|
116
114
|
}, children: "No results" })) : (filteredOptions.map((option) => {
|
|
117
115
|
const isSelected = value.includes(option.value);
|
|
118
|
-
const atMax = maxSelections !== void 0 &&
|
|
119
|
-
value.length >= maxSelections &&
|
|
120
|
-
!isSelected;
|
|
116
|
+
const atMax = maxSelections !== void 0 && value.length >= maxSelections && !isSelected;
|
|
121
117
|
return (_jsxs("button", { type: "button", className: "glchat-a2ui-multiselect-option", disabled: atMax, style: {
|
|
122
118
|
...multiSelectOptionStyles,
|
|
123
119
|
...(hoveredOption === option.value ? optionHoverStyle : {}),
|
|
124
120
|
opacity: atMax ? 0.5 : 1,
|
|
125
121
|
cursor: atMax ? 'not-allowed' : 'pointer',
|
|
126
|
-
}, onMouseEnter: () => setHoveredOption(option.value), onMouseLeave: () => setHoveredOption(null), onClick: () => toggleOption(option.value), children: [_jsx("span", { style: isSelected
|
|
127
|
-
? multiSelectCheckboxCheckedStyles
|
|
128
|
-
: multiSelectCheckboxStyles, children: isSelected && (_jsx(Check, { style: { height: '1rem', width: '1rem' }, strokeWidth: 1.5 })) }), _jsx("span", { style: {
|
|
122
|
+
}, onMouseEnter: () => setHoveredOption(option.value), onMouseLeave: () => setHoveredOption(null), onClick: () => toggleOption(option.value), children: [_jsx("span", { style: isSelected ? multiSelectCheckboxCheckedStyles : multiSelectCheckboxStyles, children: isSelected && (_jsx(Check, { style: { height: '1rem', width: '1rem' }, strokeWidth: 1.5 })) }), _jsx("span", { style: {
|
|
129
123
|
overflow: 'hidden',
|
|
130
124
|
display: '-webkit-box',
|
|
131
125
|
WebkitLineClamp: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/Select/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAa3C,QAAA,MAAM,MAAM,uCAAuB,CAAC;AAEpC,QAAA,MAAM,WAAW,yGAAwB,CAAC;AAE1C,QAAA,MAAM,WAAW,0GAAwB,CAAC;AAM1C,QAAA,MAAM,aAAa;YAHT,aAAa;2CAqBrB,CAAC;AAGH,QAAA,MAAM,oBAAoB,qKAWxB,CAAC;AAGH,QAAA,MAAM,sBAAsB,uKAW1B,CAAC;AAOH,QAAA,MAAM,aAAa;YAHT,aAAa;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/Select/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAa3C,QAAA,MAAM,MAAM,uCAAuB,CAAC;AAEpC,QAAA,MAAM,WAAW,yGAAwB,CAAC;AAE1C,QAAA,MAAM,WAAW,0GAAwB,CAAC;AAM1C,QAAA,MAAM,aAAa;YAHT,aAAa;2CAqBrB,CAAC;AAGH,QAAA,MAAM,oBAAoB,qKAWxB,CAAC;AAGH,QAAA,MAAM,sBAAsB,uKAW1B,CAAC;AAOH,QAAA,MAAM,aAAa;YAHT,aAAa;wCAkCrB,CAAC;AAOH,QAAA,MAAM,UAAU;YAHN,aAAa;wCAoBrB,CAAC;AAGH,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,WAAW,GACZ,CAAC"}
|
|
@@ -14,7 +14,7 @@ const SelectScrollUpButton = React.forwardRef(({ style, ...props }, ref) => (_js
|
|
|
14
14
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
15
15
|
const SelectScrollDownButton = React.forwardRef(({ style, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, style: { ...selectScrollButtonStyles, ...style }, ...props, children: _jsx(ChevronDown, { style: { height: '1rem', width: '1rem' }, "aria-hidden": true }) })));
|
|
16
16
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
17
|
-
const SelectContent = React.forwardRef(({ className, children, position = 'popper', style, ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: className, position: position, style: { ...selectContentStyles, ...style }, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { style: position === 'popper'
|
|
17
|
+
const SelectContent = React.forwardRef(({ className, children, position = 'popper', style, sideOffset = 0, ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: className, position: position, sideOffset: sideOffset, style: { ...selectContentStyles, ...style }, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { style: position === 'popper'
|
|
18
18
|
? {
|
|
19
19
|
...selectViewportStyles,
|
|
20
20
|
height: 'var(--radix-select-trigger-height)',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_8/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_8/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAW/C,OAAO,EAEL,iBAAiB,EAEjB,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC;AACjF,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAqDF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EAAE,YAAY,EACtB,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAgC/C;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAInD"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
4
4
|
import { A2UIProvider, ComponentRegistry, useA2UI, } from '@a2ui/react/v0_8';
|
|
5
|
+
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
5
6
|
import { ensureGlchatComponentsRegistered } from './registry.js';
|
|
6
7
|
import { mergeGlchatTheme } from './theme.js';
|
|
7
8
|
const A2UIRegistryContext = createContext(null);
|
|
9
|
+
const PROCESS_ERROR_MESSAGE = '[A2UI] Failed to process v0.8 messages';
|
|
8
10
|
function MessagesProcessor({ messages, onError, }) {
|
|
9
11
|
const { processMessages } = useA2UI();
|
|
10
12
|
const processedCountRef = useRef(0);
|
|
13
|
+
const [processError, setProcessError] = useState(null);
|
|
11
14
|
useEffect(() => {
|
|
12
15
|
if (!messages?.length)
|
|
13
16
|
return;
|
|
@@ -20,8 +23,11 @@ function MessagesProcessor({ messages, onError, }) {
|
|
|
20
23
|
processedCountRef.current = messages.length;
|
|
21
24
|
try {
|
|
22
25
|
processMessages(pending);
|
|
26
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- sync process result into alert UI
|
|
27
|
+
setProcessError(null);
|
|
23
28
|
}
|
|
24
29
|
catch (error) {
|
|
30
|
+
setProcessError(PROCESS_ERROR_MESSAGE);
|
|
25
31
|
if (onError) {
|
|
26
32
|
onError(error);
|
|
27
33
|
}
|
|
@@ -31,7 +37,9 @@ function MessagesProcessor({ messages, onError, }) {
|
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
}, [messages, onError, processMessages]);
|
|
34
|
-
|
|
40
|
+
if (!processError)
|
|
41
|
+
return null;
|
|
42
|
+
return (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning", message: processError }) }));
|
|
35
43
|
}
|
|
36
44
|
export function V08Provider({ messages, theme, onAction, onError, registry: registryProp, children, }) {
|
|
37
45
|
const registry = useMemo(() => registryProp ?? ComponentRegistry.getInstance(), [registryProp]);
|
|
@@ -3,6 +3,11 @@ import { ComponentRegistry } from '@a2ui/react/v0_8';
|
|
|
3
3
|
* Catalog identifier for the GLChat extended A2UI v0.8 catalog.
|
|
4
4
|
*/
|
|
5
5
|
export declare const GLCHAT_CATALOG_ID_V08 = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json";
|
|
6
|
+
/**
|
|
7
|
+
* Makes `registry.get(type)` return the warning fallback when the type is not
|
|
8
|
+
* registered, so unknown components render an alert instead of nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function installUnknownComponentFallback(registry: ComponentRegistry): void;
|
|
6
11
|
/**
|
|
7
12
|
* Ensures the registry has the official default A2UI components
|
|
8
13
|
* extended with GLChat-specific components.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/v0_8/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/v0_8/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,kBAAkB,CAAC;AAU7E;;GAEG;AACH,eAAO,MAAM,qBAAqB,sIACmG,CAAC;AAKtI;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAOjF;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,iBAAiB,QAkB3E;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAIxD"}
|
|
@@ -5,28 +5,42 @@ import { CustomDestructiveButtonComponent } from '../components/a2ui/v0_8/Destru
|
|
|
5
5
|
import { CustomMultipleChoiceComponent } from '../components/a2ui/v0_8/MultipleChoice/MultipleChoice.js';
|
|
6
6
|
import { CustomTagInputComponent } from '../components/a2ui/v0_8/TagInput/TagInput.js';
|
|
7
7
|
import { CustomTimeoutComponent } from '../components/a2ui/v0_8/Timeout/Timeout.js';
|
|
8
|
+
import { CustomUnknownComponent } from '../components/a2ui/v0_8/UnknownComponent/UnknownComponent.js';
|
|
8
9
|
/**
|
|
9
10
|
* Catalog identifier for the GLChat extended A2UI v0.8 catalog.
|
|
10
11
|
*/
|
|
11
12
|
export const GLCHAT_CATALOG_ID_V08 = 'https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json';
|
|
12
13
|
const registeredRegistries = new WeakSet();
|
|
14
|
+
const fallbackRegistries = new WeakSet();
|
|
15
|
+
/**
|
|
16
|
+
* Makes `registry.get(type)` return the warning fallback when the type is not
|
|
17
|
+
* registered, so unknown components render an alert instead of nothing.
|
|
18
|
+
*/
|
|
19
|
+
export function installUnknownComponentFallback(registry) {
|
|
20
|
+
if (fallbackRegistries.has(registry))
|
|
21
|
+
return;
|
|
22
|
+
const originalGet = registry.get.bind(registry);
|
|
23
|
+
registry.get = ((type) => originalGet(type) ?? CustomUnknownComponent);
|
|
24
|
+
fallbackRegistries.add(registry);
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
27
|
* Ensures the registry has the official default A2UI components
|
|
15
28
|
* extended with GLChat-specific components.
|
|
16
29
|
*/
|
|
17
30
|
export function ensureGlchatComponentsRegistered(registry) {
|
|
18
|
-
if (registeredRegistries.has(registry))
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
if (!registeredRegistries.has(registry)) {
|
|
32
|
+
registerDefaultCatalog(registry);
|
|
33
|
+
registry.unregister('Button');
|
|
34
|
+
registry.unregister('MultipleChoice');
|
|
35
|
+
registry.register('Button', { component: CustomButtonComponent });
|
|
36
|
+
registry.register('ButtonAsLink', { component: CustomButtonAsLinkComponent });
|
|
37
|
+
registry.register('DestructiveButton', { component: CustomDestructiveButtonComponent });
|
|
38
|
+
registry.register('MultipleChoice', { component: CustomMultipleChoiceComponent });
|
|
39
|
+
registry.register('TagInput', { component: CustomTagInputComponent });
|
|
40
|
+
registry.register('Timeout', { component: CustomTimeoutComponent });
|
|
41
|
+
registeredRegistries.add(registry);
|
|
42
|
+
}
|
|
43
|
+
installUnknownComponentFallback(registry);
|
|
30
44
|
}
|
|
31
45
|
export function createGlchatRegistry() {
|
|
32
46
|
const registry = new ComponentRegistry();
|
|
@@ -11,6 +11,11 @@ export type V09ProviderProps = {
|
|
|
11
11
|
onError?: V09MessageErrorHandler;
|
|
12
12
|
catalog?: Catalog<ReactComponentImplementation>;
|
|
13
13
|
};
|
|
14
|
+
type SurfaceGroupContextValue = {
|
|
15
|
+
model: SurfaceGroupModel<ReactComponentImplementation>;
|
|
16
|
+
hasMessages: boolean;
|
|
17
|
+
};
|
|
14
18
|
export declare function V09Provider({ messages, onAction, onError, catalog, children, }: Readonly<PropsWithChildren<V09ProviderProps>>): import("react").JSX.Element;
|
|
15
|
-
export declare function useSurfaceGroup():
|
|
19
|
+
export declare function useSurfaceGroup(): SurfaceGroupContextValue;
|
|
20
|
+
export {};
|
|
16
21
|
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAmB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAmB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAQ5D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACjD,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IACvD,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAkF/C;AAED,wBAAgB,eAAe,IAAI,wBAAwB,CAI1D"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { MarkdownContext } from '@a2ui/react/v0_9';
|
|
5
5
|
import { MessageProcessor, } from '@a2ui/web_core/v0_9';
|
|
6
6
|
import { injectBasicCatalogStyles } from '@a2ui/web_core/v0_9/basic_catalog';
|
|
7
7
|
import { renderMarkdown } from '@a2ui/markdown-it';
|
|
8
|
-
import {
|
|
8
|
+
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
9
|
+
import { createGlchatCatalog, GLCHAT_CATALOG_ID, installUnknownComponentFallback, withFallbackCatalogId, } from './catalog.js';
|
|
9
10
|
const SurfaceGroupContext = createContext(null);
|
|
11
|
+
const PROCESS_ERROR_MESSAGE = '[A2UI] Failed to process v0.9 messages';
|
|
10
12
|
export function V09Provider({ messages, onAction, onError, catalog, children, }) {
|
|
11
13
|
const onActionRef = useRef(onAction);
|
|
12
14
|
const onErrorRef = useRef(onError);
|
|
15
|
+
const [processError, setProcessError] = useState(null);
|
|
16
|
+
const hasMessages = !!messages?.length;
|
|
13
17
|
useEffect(() => {
|
|
14
18
|
onActionRef.current = onAction;
|
|
15
19
|
}, [onAction]);
|
|
@@ -18,6 +22,7 @@ export function V09Provider({ messages, onAction, onError, catalog, children, })
|
|
|
18
22
|
}, [onError]);
|
|
19
23
|
const [processor] = useState(() => {
|
|
20
24
|
const resolvedCatalog = catalog ?? createGlchatCatalog();
|
|
25
|
+
installUnknownComponentFallback(resolvedCatalog);
|
|
21
26
|
return new MessageProcessor([resolvedCatalog]);
|
|
22
27
|
});
|
|
23
28
|
const processedCountRef = useRef(0);
|
|
@@ -44,8 +49,11 @@ export function V09Provider({ messages, onAction, onError, catalog, children, })
|
|
|
44
49
|
processedCountRef.current = messages.length;
|
|
45
50
|
try {
|
|
46
51
|
processor.processMessages(pending);
|
|
52
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- sync process result into alert UI
|
|
53
|
+
setProcessError(null);
|
|
47
54
|
}
|
|
48
55
|
catch (error) {
|
|
56
|
+
setProcessError(PROCESS_ERROR_MESSAGE);
|
|
49
57
|
if (onErrorRef.current) {
|
|
50
58
|
onErrorRef.current(error);
|
|
51
59
|
}
|
|
@@ -54,12 +62,13 @@ export function V09Provider({ messages, onAction, onError, catalog, children, })
|
|
|
54
62
|
console.error('[glchat-a2ui] Failed to process v0.9 messages:', error);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
}, [messages, processor]);
|
|
58
|
-
|
|
65
|
+
}, [messages, processor, catalog?.id]);
|
|
66
|
+
const contextValue = useMemo(() => ({ model: processor.model, hasMessages }), [processor.model, hasMessages]);
|
|
67
|
+
return (_jsx(SurfaceGroupContext.Provider, { value: contextValue, children: _jsxs(MarkdownContext.Provider, { value: renderMarkdown, children: [processError ? (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning", message: processError }) })) : null, children] }) }));
|
|
59
68
|
}
|
|
60
69
|
export function useSurfaceGroup() {
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
70
|
+
const ctx = useContext(SurfaceGroupContext);
|
|
71
|
+
if (!ctx)
|
|
63
72
|
throw new Error('useSurfaceGroup must be used inside Provider (v0.9)');
|
|
64
|
-
return
|
|
73
|
+
return ctx;
|
|
65
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAuDlE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BAkCvE"}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useSyncExternalStore } from 'react';
|
|
3
4
|
import { A2uiSurface } from '@a2ui/react/v0_9';
|
|
5
|
+
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
4
6
|
import { useSurfaceGroup } from './Provider.js';
|
|
5
7
|
import { useSurfaces } from './useSurfaces.js';
|
|
6
8
|
const DEFAULT_FALLBACK = _jsx(_Fragment, {});
|
|
9
|
+
const ROOT_MISSING_MESSAGE = '[A2UI] Root component not found';
|
|
10
|
+
/** True when the surface has a `root` component (replace `@a2ui` "[Loading root...]"). */
|
|
11
|
+
function useHasRootComponent(surface) {
|
|
12
|
+
const subscribe = useCallback((onStoreChange) => {
|
|
13
|
+
const created = surface.componentsModel.onCreated.subscribe(() => onStoreChange());
|
|
14
|
+
const deleted = surface.componentsModel.onDeleted.subscribe(() => onStoreChange());
|
|
15
|
+
return () => {
|
|
16
|
+
created.unsubscribe();
|
|
17
|
+
deleted.unsubscribe();
|
|
18
|
+
};
|
|
19
|
+
}, [surface]);
|
|
20
|
+
const getSnapshot = useCallback(() => surface.componentsModel.get('root') != null, [surface]);
|
|
21
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
22
|
+
}
|
|
23
|
+
function SurfaceView({ surface, className, fallback, hasMessages, }) {
|
|
24
|
+
const hasRoot = useHasRootComponent(surface);
|
|
25
|
+
if (!hasRoot) {
|
|
26
|
+
if (!hasMessages)
|
|
27
|
+
return _jsx(_Fragment, { children: fallback });
|
|
28
|
+
return (_jsx("div", { className: className, children: _jsx(InlineAlert, { role: "alert", variant: "warning", message: ROOT_MISSING_MESSAGE }) }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx("div", { className: className, children: _jsx(A2uiSurface, { surface: surface }) }));
|
|
31
|
+
}
|
|
7
32
|
export function V09SurfaceRenderer(props) {
|
|
8
|
-
const model = useSurfaceGroup();
|
|
33
|
+
const { model, hasMessages } = useSurfaceGroup();
|
|
9
34
|
const surfaces = useSurfaces(model);
|
|
10
35
|
const fallback = props.fallback ?? DEFAULT_FALLBACK;
|
|
11
36
|
const surfaceClassName = props.className ? `a2ui-surface ${props.className}` : 'a2ui-surface';
|
|
@@ -13,9 +38,9 @@ export function V09SurfaceRenderer(props) {
|
|
|
13
38
|
const surface = model.getSurface(props.surfaceId);
|
|
14
39
|
if (!surface)
|
|
15
40
|
return _jsx(_Fragment, { children: fallback });
|
|
16
|
-
return (_jsx(
|
|
41
|
+
return (_jsx(SurfaceView, { surface: surface, className: surfaceClassName, fallback: fallback, hasMessages: hasMessages }));
|
|
17
42
|
}
|
|
18
43
|
if (surfaces.length === 0)
|
|
19
44
|
return _jsx(_Fragment, { children: fallback });
|
|
20
|
-
return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx(
|
|
45
|
+
return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx(SurfaceView, { surface: surface, className: surfaceClassName, fallback: fallback, hasMessages: hasMessages }, surface.id))) }));
|
|
21
46
|
}
|
|
@@ -8,10 +8,16 @@ export declare const GLCHAT_CATALOG_ID = "https://github.com/GDP-ADMIN/glchat-sd
|
|
|
8
8
|
export declare const GLCHAT_CATALOG_OVERRIDES: readonly ["Button"];
|
|
9
9
|
/** GLChat-only components not present in the basic catalog. */
|
|
10
10
|
export declare const GLCHAT_CATALOG_EXTENSIONS: readonly ["TagInput", "Timeout"];
|
|
11
|
+
/**
|
|
12
|
+
* Makes `catalog.components.get(type)` return the warning fallback when the
|
|
13
|
+
* type is not registered, so unknown components render an alert instead of
|
|
14
|
+
* `@a2ui/react`'s red placeholder.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installUnknownComponentFallback(catalog: Catalog<ReactComponentImplementation>): void;
|
|
11
17
|
/**
|
|
12
18
|
* Builds the GLChat A2UI v0.9 catalog:
|
|
13
|
-
* - Includes basic catalog components except those GLChat overrides (`Button`, `ChoicePicker`).
|
|
14
|
-
* - Adds GLChat overrides and extensions (`Button`, `ChoicePicker`, `TagInput`, `Timeout`).
|
|
19
|
+
* - Includes basic catalog components except those GLChat overrides (`AudioPlayer`, `Button`, `ChoicePicker`).
|
|
20
|
+
* - Adds GLChat overrides and extensions (`AudioPlayer`, `Button`, `ChoicePicker`, `TagInput`, `Timeout`).
|
|
15
21
|
* - Reuses basic catalog functions unchanged.
|
|
16
22
|
*/
|
|
17
23
|
export declare function createGlchatCatalog(): Catalog<ReactComponentImplementation>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAShE;;GAEG;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;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAC7C,IAAI,CASN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAiB3E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,MAAM,GACnB,WAAW,EAAE,CAqBf"}
|
package/dist/src/v0_9/catalog.js
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import { basicCatalog } from '@a2ui/react/v0_9';
|
|
2
2
|
import { Catalog } from '@a2ui/web_core/v0_9';
|
|
3
|
+
import { GlchatAudioPlayerComponent } from '../components/a2ui/v0_9/AudioPlayer/AudioPlayer.js';
|
|
3
4
|
import { GlchatButtonComponent } from '../components/a2ui/v0_9/Button/Button.js';
|
|
4
5
|
import { GlchatChoicePickerComponent } from '../components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
5
6
|
import { GlchatTagInputComponent } from '../components/a2ui/v0_9/TagInput/TagInput.js';
|
|
6
7
|
import { GlchatTimeoutComponent } from '../components/a2ui/v0_9/Timeout/Timeout.js';
|
|
8
|
+
import { UnknownComponentFallback } from '../components/a2ui/v0_9/UnknownComponent/UnknownComponent.js';
|
|
7
9
|
/**
|
|
8
10
|
* Catalog identifier for the GLChat extended A2UI v0.9 catalog.
|
|
9
11
|
*/
|
|
10
12
|
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';
|
|
11
13
|
/** Basic catalog components overridden at runtime by GLChat implementations. */
|
|
12
|
-
const OVERRIDDEN_COMPONENTS = new Set(['Button', 'ChoicePicker']);
|
|
14
|
+
const OVERRIDDEN_COMPONENTS = new Set(['AudioPlayer', 'Button', 'ChoicePicker']);
|
|
13
15
|
/** Basic catalog components whose JSON Schema is regenerated from Zod. */
|
|
14
16
|
export const GLCHAT_CATALOG_OVERRIDES = ['Button'];
|
|
15
17
|
/** GLChat-only components not present in the basic catalog. */
|
|
16
18
|
export const GLCHAT_CATALOG_EXTENSIONS = ['TagInput', 'Timeout'];
|
|
19
|
+
/**
|
|
20
|
+
* Makes `catalog.components.get(type)` return the warning fallback when the
|
|
21
|
+
* type is not registered, so unknown components render an alert instead of
|
|
22
|
+
* `@a2ui/react`'s red placeholder.
|
|
23
|
+
*/
|
|
24
|
+
export function installUnknownComponentFallback(catalog) {
|
|
25
|
+
const map = catalog.components;
|
|
26
|
+
if (map.__glchatUnknownFallback) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const originalGet = map.get.bind(map);
|
|
30
|
+
map.get = ((name) => originalGet(name) ?? UnknownComponentFallback);
|
|
31
|
+
map.__glchatUnknownFallback = true;
|
|
32
|
+
}
|
|
17
33
|
/**
|
|
18
34
|
* Builds the GLChat A2UI v0.9 catalog:
|
|
19
|
-
* - Includes basic catalog components except those GLChat overrides (`Button`, `ChoicePicker`).
|
|
20
|
-
* - Adds GLChat overrides and extensions (`Button`, `ChoicePicker`, `TagInput`, `Timeout`).
|
|
35
|
+
* - Includes basic catalog components except those GLChat overrides (`AudioPlayer`, `Button`, `ChoicePicker`).
|
|
36
|
+
* - Adds GLChat overrides and extensions (`AudioPlayer`, `Button`, `ChoicePicker`, `TagInput`, `Timeout`).
|
|
21
37
|
* - Reuses basic catalog functions unchanged.
|
|
22
38
|
*/
|
|
23
39
|
export function createGlchatCatalog() {
|
|
24
40
|
const baseComponents = Array.from(basicCatalog.components.values()).filter((component) => !OVERRIDDEN_COMPONENTS.has(component.name));
|
|
25
41
|
const components = [
|
|
26
42
|
...baseComponents,
|
|
43
|
+
GlchatAudioPlayerComponent,
|
|
27
44
|
GlchatButtonComponent,
|
|
28
45
|
GlchatChoicePickerComponent,
|
|
29
46
|
GlchatTagInputComponent,
|
|
@@ -907,24 +907,11 @@
|
|
|
907
907
|
"id": "catalog-modal",
|
|
908
908
|
"component": {
|
|
909
909
|
"Modal": {
|
|
910
|
-
"entryPointChild": "modal-open-
|
|
910
|
+
"entryPointChild": "modal-open-text",
|
|
911
911
|
"contentChild": "modal-body-col"
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
},
|
|
915
|
-
{
|
|
916
|
-
"id": "modal-open-btn",
|
|
917
|
-
"component": {
|
|
918
|
-
"Button": {
|
|
919
|
-
"child": "modal-open-text",
|
|
920
|
-
"action": {
|
|
921
|
-
"name": "modal_open",
|
|
922
|
-
"context": []
|
|
923
|
-
},
|
|
924
|
-
"primary": false
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
},
|
|
928
915
|
{
|
|
929
916
|
"id": "modal-open-text",
|
|
930
917
|
"component": {
|
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
"properties": {
|
|
387
387
|
"entryPointChild": {
|
|
388
388
|
"type": "string",
|
|
389
|
-
"description": "The ID of the component that opens the modal when interacted with (e.g
|
|
389
|
+
"description": "The ID of the component that opens the modal when interacted with (e.g. Text). Do NOT use Button as the entry point — Modal opens locally on click, and Button would also dispatch an action."
|
|
390
390
|
},
|
|
391
391
|
"contentChild": {
|
|
392
392
|
"type": "string",
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
},
|
|
521
521
|
"trigger": {
|
|
522
522
|
"$ref": "common_types.json#/$defs/ComponentId",
|
|
523
|
-
"description": "The ID of the component that opens the modal when interacted with (e.g
|
|
523
|
+
"description": "The ID of the component that opens the modal when interacted with (e.g. Text). Do NOT use Button as the trigger — Modal opens locally on click, and Button would also dispatch an action. Do NOT define the component inline."
|
|
524
524
|
},
|
|
525
525
|
"content": {
|
|
526
526
|
"$ref": "common_types.json#/$defs/ComponentId",
|