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,8 +0,0 @@
1
- export type ButtonAsLinkTheme = {
2
- container: Record<string, boolean>;
3
- element: Record<string, boolean>;
4
- };
5
- export declare const buttonAsLinkComponents: ButtonAsLinkTheme;
6
- /** Theme override slot. Base and variant styles are applied by the UI ButtonAsLink primitive. */
7
- export declare const buttonAsLinkAdditionalStyles: Record<string, string>;
8
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/ButtonAsLink/theme.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAKpC,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC"}
@@ -1,8 +0,0 @@
1
- export const buttonAsLinkComponents = {
2
- container: {},
3
- element: {
4
- 'glchat-a2ui-button': true,
5
- },
6
- };
7
- /** Theme override slot. Base and variant styles are applied by the UI ButtonAsLink primitive. */
8
- export const buttonAsLinkAdditionalStyles = {};
@@ -1,4 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- export declare const cardComponents: Theme['components']['Card'];
3
- export declare const cardAdditionalStyles: NonNullable<Theme['additionalStyles']>['Card'];
4
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Card/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAEtD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAW/E,CAAC"}
@@ -1,15 +0,0 @@
1
- export const cardComponents = {
2
- 'layout-p-4': true,
3
- };
4
- export const cardAdditionalStyles = {
5
- backgroundColor: 'hsl(var(--card))',
6
- color: 'hsl(var(--card-foreground))',
7
- borderColor: 'hsl(var(--border))',
8
- borderWidth: '1px',
9
- borderStyle: 'solid',
10
- borderRadius: 'var(--radius)',
11
- boxShadow: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
12
- transitionProperty: 'color, background-color, border-color, box-shadow',
13
- transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
14
- transitionDuration: '300ms',
15
- };
@@ -1,4 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- export declare const checkBoxComponents: Theme['components']['CheckBox'];
3
- export declare const checkBoxAdditionalStyles: NonNullable<Theme['additionalStyles']>['CheckBox'];
4
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/CheckBox/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,UAAU,CAI9D,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAKvF,CAAC"}
@@ -1,11 +0,0 @@
1
- export const checkBoxComponents = {
2
- container: {},
3
- element: {},
4
- label: {},
5
- };
6
- export const checkBoxAdditionalStyles = {
7
- display: 'flex',
8
- alignItems: 'center',
9
- gap: '0.5rem',
10
- width: '100%',
11
- };
@@ -1,8 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- /**
3
- * DateTimeInput structural class map.
4
- */
5
- export declare const dateTimeInputComponents: Theme['components']['DateTimeInput'];
6
- /** Applied inline on the native date/time input. */
7
- export declare const dateTimeInputAdditionalStyles: NonNullable<Theme['additionalStyles']>['DateTimeInput'];
8
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/DateTimeInput/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,eAAe,CAIxE,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,6BAA6B,EAAE,WAAW,CACrD,KAAK,CAAC,kBAAkB,CAAC,CAC1B,CAAC,eAAe,CAAkD,CAAC"}
@@ -1,11 +0,0 @@
1
- import { textFieldInputStyles } from '../../ui/TextField/theme.js';
2
- /**
3
- * DateTimeInput structural class map.
4
- */
5
- export const dateTimeInputComponents = {
6
- container: {},
7
- label: {},
8
- element: { 'glchat-a2ui-datetime-input': true },
9
- };
10
- /** Applied inline on the native date/time input. */
11
- export const dateTimeInputAdditionalStyles = textFieldInputStyles;
@@ -1,4 +0,0 @@
1
- import { type A2UIComponentProps } from '@a2ui/react';
2
- import type { CustomNode } from '@a2ui/web_core/types/types';
3
- export declare function CustomDestructiveButtonComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<CustomNode>>): import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=DestructiveButton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DestructiveButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/DestructiveButton/DestructiveButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAUzE,wBAAgB,gCAAgC,CAAC,EAC/C,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CA0C1C"}
@@ -1,22 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react';
4
- import { useMemo } from 'react';
5
- import { Button } from '../../ui/Button/Button.js';
6
- import { destructiveButtonComponents } from './theme.js';
7
- export function CustomDestructiveButtonComponent({ node, surfaceId, }) {
8
- const { sendAction, theme } = useA2UIComponent(node, surfaceId);
9
- const { child, action } = node.properties;
10
- const destructiveButtonTheme = useMemo(() => {
11
- const components = theme.components;
12
- return components.DestructiveButton ?? destructiveButtonComponents;
13
- }, [theme.components]);
14
- const buttonStyle = useMemo(() => stylesToObject(theme.additionalStyles?.DestructiveButton), [theme.additionalStyles]);
15
- const handleClick = () => {
16
- if (action) {
17
- sendAction(action);
18
- }
19
- };
20
- const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
21
- return (_jsx("div", { className: `a2ui-button a2ui-destructive-button ${classMapToString(destructiveButtonTheme.container)}`.trim(), style: hostStyle, children: _jsx(Button, { variant: "destructive", className: classMapToString(destructiveButtonTheme.element), style: buttonStyle, onClick: handleClick, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
22
- }
@@ -1,8 +0,0 @@
1
- export type DestructiveButtonTheme = {
2
- container: Record<string, boolean>;
3
- element: Record<string, boolean>;
4
- };
5
- export declare const destructiveButtonComponents: DestructiveButtonTheme;
6
- /** Theme override slot. Base and variant styles are applied by the UI Button primitive. */
7
- export declare const destructiveButtonAdditionalStyles: Record<string, string>;
8
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/DestructiveButton/theme.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,sBAKzC,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAC"}
@@ -1,8 +0,0 @@
1
- export const destructiveButtonComponents = {
2
- container: {},
3
- element: {
4
- 'glchat-a2ui-button': true,
5
- },
6
- };
7
- /** Theme override slot. Base and variant styles are applied by the UI Button primitive. */
8
- export const destructiveButtonAdditionalStyles = {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"CheckboxList.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/MultipleChoice/CheckboxList.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAQvE,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,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,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,aAAa,EACb,UAAkB,EAClB,SAAS,GACV,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CA2E7B"}
@@ -1,4 +0,0 @@
1
- import { type A2UIComponentProps } from '@a2ui/react';
2
- import type { MultipleChoiceNode } from '@a2ui/web_core/types/types';
3
- export declare function CustomMultipleChoiceComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<MultipleChoiceNode>>): import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=MultipleChoice.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultipleChoice.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/MultipleChoice/MultipleChoice.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAoGrE,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC,2CAuFlD"}
@@ -1,72 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { classMapToString, useA2UIComponent, } from '@a2ui/react';
4
- import { useCallback, useMemo } from 'react';
5
- import { MultiSelect } from '../../ui/MultiSelect/MultiSelect.js';
6
- import { Select, SelectContent, SelectItem, SelectTrigger, } from '../../ui/Select/Select.js';
7
- import { selectTriggerLabelStyles, selectTriggerPlaceholderStyles, } from '../../ui/Select/theme.js';
8
- import { CheckboxList } from './CheckboxList.js';
9
- import { multipleChoiceComponents } from './theme.js';
10
- function isSingleSelect(maxAllowedSelections) {
11
- return !maxAllowedSelections || maxAllowedSelections <= 1;
12
- }
13
- /** GLChat/Standard catalog uses `variant`; A2UI schema (in code) uses `type`. */
14
- function getVariant(properties) {
15
- const extended = properties;
16
- return extended.variant ?? properties.type;
17
- }
18
- function getSelectedValues(selections, getValue) {
19
- if (selections?.path) {
20
- const raw = getValue(selections.path);
21
- if (Array.isArray(raw)) {
22
- return raw.filter((item) => typeof item === 'string');
23
- }
24
- return [];
25
- }
26
- return selections?.literalArray ?? [];
27
- }
28
- function SingleSelectChips({ elementClass, options, value, onValueChange, }) {
29
- const selectedLabel = useMemo(() => {
30
- const match = options.find((opt) => opt.value === value);
31
- return match?.label ?? '';
32
- }, [options, value]);
33
- const triggerLabelStyle = useMemo(() => ({
34
- ...selectTriggerLabelStyles,
35
- ...(selectedLabel ? undefined : selectTriggerPlaceholderStyles),
36
- }), [selectedLabel]);
37
- return (_jsxs(Select, { value: value, onValueChange: onValueChange, children: [_jsx(SelectTrigger, { className: `glchat-a2ui-select-trigger ${elementClass}`.trim(), "aria-label": "Select option", children: _jsx("span", { style: triggerLabelStyle, ...(selectedLabel ? {} : { 'data-placeholder': '' }), children: selectedLabel || 'Select an item' }) }), _jsx(SelectContent, { className: "glchat-a2ui-select-content", children: options.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value))) })] }));
38
- }
39
- export function CustomMultipleChoiceComponent({ node, surfaceId, }) {
40
- const { theme, resolveString, setValue, getValue } = useA2UIComponent(node, surfaceId);
41
- const { selections, options = [], maxAllowedSelections, filterable } = node.properties;
42
- const variant = getVariant(node.properties);
43
- const singleSelect = isSingleSelect(maxAllowedSelections);
44
- const selectionsPath = selections?.path;
45
- const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
46
- const multipleChoiceTheme = theme.components.MultipleChoice ?? multipleChoiceComponents;
47
- const containerClass = classMapToString(multipleChoiceTheme.container);
48
- const elementClass = classMapToString(multipleChoiceTheme.element);
49
- const selectedValues = getSelectedValues(selections, getValue);
50
- const resolvedOptions = useMemo(() => options.map((option) => ({
51
- value: option.value,
52
- label: resolveString(option.label) ?? option.value,
53
- })), [options, resolveString]);
54
- const handleSingleValueChange = useCallback((nextValue) => {
55
- if (selectionsPath) {
56
- setValue(selectionsPath, [nextValue]);
57
- }
58
- }, [selectionsPath, setValue]);
59
- const handleMultiValueChange = useCallback((values) => {
60
- if (selectionsPath) {
61
- setValue(selectionsPath, values);
62
- }
63
- }, [selectionsPath, setValue]);
64
- const wrapper = (content) => (_jsx("div", { className: "a2ui-multiplechoice", style: hostStyle, children: _jsx("section", { className: containerClass, children: content }) }));
65
- if (variant === 'checkbox') {
66
- return wrapper(_jsx(CheckboxList, { className: elementClass, options: resolvedOptions, value: selectedValues, onValueChange: handleMultiValueChange, singleSelect: singleSelect, maxSelections: singleSelect ? 1 : maxAllowedSelections, filterable: filterable ?? false }));
67
- }
68
- if (singleSelect) {
69
- return wrapper(_jsx(SingleSelectChips, { elementClass: elementClass, options: resolvedOptions, value: selectedValues[0] ?? '', onValueChange: handleSingleValueChange }));
70
- }
71
- return wrapper(_jsx(MultiSelect, { className: elementClass, options: resolvedOptions, value: selectedValues, onValueChange: handleMultiValueChange, placeholder: "Select options", filterable: filterable ?? false, maxSelections: maxAllowedSelections }));
72
- }
@@ -1,13 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
- import type { Theme } from '@a2ui/web_core/types/types';
3
- /**
4
- * MultipleChoice structural class map.
5
- */
6
- export declare const multipleChoiceComponents: Theme['components']['MultipleChoice'];
7
- /**
8
- * Checkbox variant — vertical list of options.
9
- */
10
- export declare const checkboxListContainerStyles: CSSProperties;
11
- export declare const checkboxListItemStyles: CSSProperties;
12
- export declare const checkboxListSearchStyles: CSSProperties;
13
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/MultipleChoice/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,gBAAgB,CAI1E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,aAKzC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAKpC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAWtC,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- export declare const textFieldComponents: Theme['components']['TextField'];
3
- export declare const textFieldAdditionalStyles: NonNullable<Theme['additionalStyles']>['TextField'];
4
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/TextField/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,WAAW,CAMhE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,CACb,CAAC"}
@@ -1,9 +0,0 @@
1
- import { textFieldInputStyles } from '../../ui/TextField/theme.js';
2
- export const textFieldComponents = {
3
- container: {},
4
- label: {},
5
- element: {
6
- 'glchat-a2ui-text-field': true,
7
- },
8
- };
9
- export const textFieldAdditionalStyles = textFieldInputStyles;
@@ -1,8 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
- /**
3
- * Tokenized style for GLChat Timeout countdown text.
4
- *
5
- * `--foreground` is client-overridable
6
- */
7
- export declare function getGlchatTimeoutTextStyle(): CSSProperties;
8
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Timeout/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,aAAa,CAMzD"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Tokenized style for GLChat Timeout countdown text.
3
- *
4
- * `--foreground` is client-overridable
5
- */
6
- export function getGlchatTimeoutTextStyle() {
7
- return {
8
- color: `hsl(var(--foreground) / 0.5)`,
9
- fontSize: '0.875rem',
10
- lineHeight: '1.25rem',
11
- };
12
- }
@@ -1,12 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- import type { ButtonAsLinkTheme } from './ButtonAsLink/theme.js';
3
- import type { DestructiveButtonTheme } from './DestructiveButton/theme.js';
4
- export type ExtendedAdditionalStyles = NonNullable<Theme['additionalStyles']> & {
5
- DestructiveButton?: Record<string, string>;
6
- ButtonAsLink?: Record<string, string>;
7
- };
8
- export type ExtendedComponents = Theme['components'] & {
9
- DestructiveButton?: DestructiveButtonTheme;
10
- ButtonAsLink?: ButtonAsLinkTheme;
11
- };
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/a2ui/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG;IAC9E,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG;IACrD,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import type { AnchorHTMLAttributes, CSSProperties, ReactNode } from 'react';
2
- import { type ButtonVariant } from './theme.js';
3
- export type ButtonAsLinkProps = {
4
- variant?: ButtonVariant;
5
- className?: string;
6
- style?: CSSProperties;
7
- children?: ReactNode;
8
- } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'style'>;
9
- export declare const ButtonAsLink: import("react").ForwardRefExoticComponent<{
10
- variant?: ButtonVariant;
11
- className?: string;
12
- style?: CSSProperties;
13
- children?: ReactNode;
14
- } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "style"> & import("react").RefAttributes<HTMLAnchorElement>>;
15
- //# sourceMappingURL=ButtonAsLink.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ButtonAsLink.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/Button/ButtonAsLink.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC;AAc3D,eAAO,MAAM,YAAY;cAlBb,aAAa;gBACX,MAAM;YACV,aAAa;eACV,SAAS;8GAoCrB,CAAC"}
@@ -1,17 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { forwardRef } from 'react';
4
- import { buttonBaseStyles, getButtonVariantStyles, } from './theme.js';
5
- function mergeStyles(variant, style) {
6
- return {
7
- textDecoration: 'none',
8
- ...buttonBaseStyles,
9
- ...getButtonVariantStyles(variant),
10
- ...style,
11
- };
12
- }
13
- export const ButtonAsLink = forwardRef(function ButtonAsLink({ variant = 'outline', className, style, children, href, target, rel, ...props }, ref) {
14
- const linkClassName = ['glchat-a2ui-button', className].filter(Boolean).join(' ');
15
- return (_jsx("a", { ref: ref, href: href, className: linkClassName, style: mergeStyles(variant, style), ...props, target: target, rel: target === '_blank' ? (rel ?? 'noopener noreferrer') : rel, children: children }));
16
- });
17
- ButtonAsLink.displayName = 'ButtonAsLink';
@@ -1,4 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
- export declare const textFieldFontStyles: CSSProperties;
3
- export declare const textFieldInputStyles: CSSProperties;
4
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/TextField/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,mBAAmB,EAAE,aAGjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,aAiBlC,CAAC"}
@@ -1,22 +0,0 @@
1
- export const textFieldFontStyles = {
2
- fontFamily: 'inherit',
3
- lineHeight: '1.5',
4
- };
5
- export const textFieldInputStyles = {
6
- ...textFieldFontStyles,
7
- height: '2.5rem',
8
- width: '100%',
9
- borderRadius: 'var(--radius-md)',
10
- borderWidth: '1px',
11
- borderStyle: 'solid',
12
- borderColor: 'hsl(var(--border))',
13
- backgroundColor: 'hsl(var(--background))',
14
- paddingTop: '0.5rem',
15
- paddingBottom: '0.5rem',
16
- paddingLeft: '0.75rem',
17
- paddingRight: '0.75rem',
18
- fontSize: '0.875rem',
19
- color: 'hsl(var(--foreground))',
20
- caretColor: 'currentColor',
21
- boxSizing: 'border-box',
22
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Returns a safe anchor target value, or undefined when the value is missing or invalid.
3
- */
4
- export declare function sanitizeTarget(target: string): string | undefined;
5
- /**
6
- * Returns a safe href for use in anchor elements.
7
- * Blocks dangerous schemes (e.g. javascript:, data:) and only allows
8
- * relative paths, fragments, and a small set of absolute URL schemes.
9
- */
10
- export declare function sanitizeHref(href: string): string;
11
- //# sourceMappingURL=href.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"href.d.ts","sourceRoot":"","sources":["../../../src/utils/href.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBjD"}
@@ -1,34 +0,0 @@
1
- const DANGEROUS_SCHEME_PATTERN = /^(javascript|data|vbscript|file|blob):/i;
2
- const ABSOLUTE_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:/i;
3
- const SCHEME_CAPTURE_PATTERN = /^([a-z][a-z0-9+.-]*):/i;
4
- const ALLOWED_ABSOLUTE_SCHEMES = new Set(['http', 'https', 'mailto', 'tel']);
5
- const ALLOWED_TARGETS = new Set(['_self', '_blank', '_parent', '_top']);
6
- /**
7
- * Returns a safe anchor target value, or undefined when the value is missing or invalid.
8
- */
9
- export function sanitizeTarget(target) {
10
- const value = target.trim();
11
- return ALLOWED_TARGETS.has(value) ? value : undefined;
12
- }
13
- /**
14
- * Returns a safe href for use in anchor elements.
15
- * Blocks dangerous schemes (e.g. javascript:, data:) and only allows
16
- * relative paths, fragments, and a small set of absolute URL schemes.
17
- */
18
- export function sanitizeHref(href) {
19
- const value = href.trim();
20
- if (!value || value === '#')
21
- return '#';
22
- if (DANGEROUS_SCHEME_PATTERN.test(value))
23
- return '#';
24
- if (value.startsWith('/') ||
25
- value.startsWith('./') ||
26
- value.startsWith('../') ||
27
- value.startsWith('#') ||
28
- !ABSOLUTE_SCHEME_PATTERN.test(value)) {
29
- return value;
30
- }
31
- const schemeMatch = SCHEME_CAPTURE_PATTERN.exec(value);
32
- const scheme = schemeMatch?.[1]?.toLowerCase();
33
- return scheme && ALLOWED_ABSOLUTE_SCHEMES.has(scheme) ? value : '#';
34
- }
@@ -1,15 +0,0 @@
1
- import type { Theme } from '@a2ui/web_core/types/types';
2
- /**
3
- * Default theme passed to Provider. Starts from upstream litTheme and layers
4
- * GLChat component class maps and inline styles from each a2ui component theme file.
5
- */
6
- export declare const glchatDefaultTheme: Theme;
7
- /**
8
- * Merges consumer overrides into glchatDefaultTheme.
9
- *
10
- * Top-level theme keys (elements, markdown, etc.) are shallow-merged.
11
- * GLChat component entries are deep-merged so partial overrides (e.g. only
12
- * components.Button) do not wipe the rest of that component's defaults.
13
- */
14
- export declare function mergeGlchatTheme(override?: Partial<Theme>): Theme;
15
- //# sourceMappingURL=theme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/utils/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AA6DxD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAIhC,CAAC;AAmCF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CA6BjE"}
@@ -1,93 +0,0 @@
1
- import { litTheme } from '@a2ui/react';
2
- import { buttonAdditionalStyles, buttonComponents, } from '../components/a2ui/Button/theme.js';
3
- import { buttonAsLinkAdditionalStyles, buttonAsLinkComponents, } from '../components/a2ui/ButtonAsLink/theme.js';
4
- import { cardAdditionalStyles, cardComponents, } from '../components/a2ui/Card/theme.js';
5
- import { checkBoxAdditionalStyles, checkBoxComponents, } from '../components/a2ui/CheckBox/theme.js';
6
- import { destructiveButtonAdditionalStyles, destructiveButtonComponents, } from '../components/a2ui/DestructiveButton/theme.js';
7
- import { dateTimeInputAdditionalStyles, dateTimeInputComponents, } from '../components/a2ui/DateTimeInput/theme.js';
8
- import { multipleChoiceComponents } from '../components/a2ui/MultipleChoice/theme.js';
9
- import { textFieldAdditionalStyles, textFieldComponents, } from '../components/a2ui/TextField/theme.js';
10
- /** GLChat-owned component class maps merged into the default A2UI theme. */
11
- const components = {
12
- ...litTheme.components,
13
- Card: cardComponents,
14
- Button: buttonComponents,
15
- CheckBox: checkBoxComponents,
16
- TextField: textFieldComponents,
17
- DateTimeInput: dateTimeInputComponents,
18
- MultipleChoice: multipleChoiceComponents,
19
- DestructiveButton: destructiveButtonComponents,
20
- ButtonAsLink: buttonAsLinkComponents,
21
- };
22
- /** GLChat-owned inline style overrides merged into the default A2UI theme. */
23
- const additionalStyles = {
24
- ...litTheme.additionalStyles,
25
- Card: { ...cardAdditionalStyles },
26
- Button: { ...buttonAdditionalStyles },
27
- CheckBox: { ...checkBoxAdditionalStyles },
28
- TextField: { ...textFieldAdditionalStyles },
29
- DateTimeInput: { ...dateTimeInputAdditionalStyles },
30
- DestructiveButton: { ...destructiveButtonAdditionalStyles },
31
- ButtonAsLink: { ...buttonAsLinkAdditionalStyles },
32
- };
33
- /**
34
- * Default theme passed to Provider. Starts from upstream litTheme and layers
35
- * GLChat component class maps and inline styles from each a2ui component theme file.
36
- */
37
- export const glchatDefaultTheme = {
38
- ...litTheme,
39
- components,
40
- additionalStyles,
41
- };
42
- const DEEP_MERGE_COMPONENT_KEYS = [
43
- 'Card',
44
- 'Button',
45
- 'CheckBox',
46
- 'TextField',
47
- 'MultipleChoice',
48
- 'DateTimeInput',
49
- 'DestructiveButton',
50
- 'ButtonAsLink',
51
- ];
52
- function mergeSection(base, patch, deepMergeKeys) {
53
- if (!patch)
54
- return base;
55
- const merged = { ...base, ...patch };
56
- for (const key of deepMergeKeys) {
57
- if (patch[key] === undefined)
58
- continue;
59
- if (!(key in base))
60
- continue;
61
- merged[key] = {
62
- ...base[key],
63
- ...patch[key],
64
- };
65
- }
66
- return merged;
67
- }
68
- /**
69
- * Merges consumer overrides into glchatDefaultTheme.
70
- *
71
- * Top-level theme keys (elements, markdown, etc.) are shallow-merged.
72
- * GLChat component entries are deep-merged so partial overrides (e.g. only
73
- * components.Button) do not wipe the rest of that component's defaults.
74
- */
75
- export function mergeGlchatTheme(override) {
76
- if (!override) {
77
- return glchatDefaultTheme;
78
- }
79
- const mergedComponents = mergeSection(components, override.components, DEEP_MERGE_COMPONENT_KEYS);
80
- const mergedAdditionalStyles = mergeSection(additionalStyles, override.additionalStyles, DEEP_MERGE_COMPONENT_KEYS);
81
- return {
82
- ...glchatDefaultTheme,
83
- ...override,
84
- components: mergedComponents,
85
- elements: override.elements
86
- ? { ...glchatDefaultTheme.elements, ...override.elements }
87
- : glchatDefaultTheme.elements,
88
- markdown: override.markdown
89
- ? { ...glchatDefaultTheme.markdown, ...override.markdown }
90
- : glchatDefaultTheme.markdown,
91
- additionalStyles: mergedAdditionalStyles,
92
- };
93
- }