glchat-a2ui-react-renderer 0.2.5 → 0.2.7
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/README.md +88 -6
- package/dist/src/Provider.d.ts +4 -3
- package/dist/src/Provider.d.ts.map +1 -1
- package/dist/src/Provider.js +1 -6
- package/dist/src/components/a2ui/Button/Button.d.ts.map +1 -1
- package/dist/src/components/a2ui/Button/Button.js +6 -14
- package/dist/src/components/a2ui/Button/theme.d.ts +3 -12
- package/dist/src/components/a2ui/Button/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/Button/theme.js +4 -58
- package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.d.ts +4 -0
- package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.d.ts.map +1 -0
- package/dist/src/components/a2ui/ButtonAsLink/ButtonAsLink.js +42 -0
- package/dist/src/components/a2ui/ButtonAsLink/theme.d.ts +8 -0
- package/dist/src/components/a2ui/ButtonAsLink/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/ButtonAsLink/theme.js +8 -0
- package/dist/src/components/a2ui/Card/theme.d.ts +2 -8
- package/dist/src/components/a2ui/Card/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/Card/theme.js +2 -8
- package/dist/src/components/a2ui/CheckBox/theme.d.ts +2 -9
- package/dist/src/components/a2ui/CheckBox/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/CheckBox/theme.js +2 -8
- package/dist/src/components/a2ui/DateTimeInput/theme.d.ts +2 -2
- package/dist/src/components/a2ui/DateTimeInput/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/DateTimeInput/theme.js +3 -3
- package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.d.ts +4 -0
- package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.d.ts.map +1 -0
- package/dist/src/components/a2ui/DestructiveButton/DestructiveButton.js +22 -0
- package/dist/src/components/a2ui/DestructiveButton/theme.d.ts +8 -0
- package/dist/src/components/a2ui/DestructiveButton/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/DestructiveButton/theme.js +8 -0
- package/dist/src/components/a2ui/MultipleChoice/CheckboxList.js +5 -5
- package/dist/src/components/a2ui/MultipleChoice/MultipleChoice.js +5 -5
- package/dist/src/components/a2ui/MultipleChoice/theme.d.ts +4 -4
- package/dist/src/components/a2ui/MultipleChoice/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/MultipleChoice/theme.js +4 -4
- package/dist/src/components/a2ui/TagInput/TagInput.d.ts +4 -0
- package/dist/src/components/a2ui/TagInput/TagInput.d.ts.map +1 -0
- package/dist/src/components/a2ui/TagInput/TagInput.js +120 -0
- package/dist/src/components/a2ui/TagInput/theme.d.ts +22 -0
- package/dist/src/components/a2ui/TagInput/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/TagInput/theme.js +82 -0
- package/dist/src/components/a2ui/TextField/theme.d.ts +2 -26
- package/dist/src/components/a2ui/TextField/theme.d.ts.map +1 -1
- package/dist/src/components/a2ui/TextField/theme.js +6 -79
- package/dist/src/components/a2ui/types.d.ts +12 -0
- package/dist/src/components/a2ui/types.d.ts.map +1 -0
- package/dist/src/components/a2ui/types.js +1 -0
- package/dist/src/components/ui/Button/Button.d.ts +15 -0
- package/dist/src/components/ui/Button/Button.d.ts.map +1 -0
- package/dist/src/components/ui/Button/Button.js +16 -0
- package/dist/src/components/ui/Button/ButtonAsLink.d.ts +15 -0
- package/dist/src/components/ui/Button/ButtonAsLink.d.ts.map +1 -0
- package/dist/src/components/ui/Button/ButtonAsLink.js +17 -0
- package/dist/src/components/ui/Button/theme.d.ts +5 -0
- package/dist/src/components/ui/Button/theme.d.ts.map +1 -0
- package/dist/src/components/ui/Button/theme.js +51 -0
- package/dist/src/components/ui/Checkbox/Checkbox.js +2 -2
- package/dist/src/components/ui/Checkbox/theme.d.ts +3 -3
- package/dist/src/components/ui/Checkbox/theme.d.ts.map +1 -1
- package/dist/src/components/ui/Checkbox/theme.js +3 -3
- package/dist/src/components/ui/MultiSelect/MultiSelect.js +12 -12
- package/dist/src/components/ui/MultiSelect/theme.d.ts +12 -12
- package/dist/src/components/ui/MultiSelect/theme.d.ts.map +1 -1
- package/dist/src/components/ui/MultiSelect/theme.js +13 -13
- package/dist/src/components/ui/Select/Select.js +8 -8
- package/dist/src/components/ui/Select/theme.d.ts +8 -8
- package/dist/src/components/ui/Select/theme.d.ts.map +1 -1
- package/dist/src/components/ui/Select/theme.js +8 -8
- package/dist/src/components/ui/TextField/theme.d.ts +4 -0
- package/dist/src/components/ui/TextField/theme.d.ts.map +1 -0
- package/dist/src/components/ui/TextField/theme.js +22 -0
- package/dist/src/utils/catalog.d.ts +1 -1
- package/dist/src/utils/catalog.d.ts.map +1 -1
- package/dist/src/utils/catalog.js +7 -11
- package/dist/src/utils/href.d.ts +11 -0
- package/dist/src/utils/href.d.ts.map +1 -0
- package/dist/src/utils/href.js +34 -0
- package/dist/src/utils/theme.d.ts +11 -0
- package/dist/src/utils/theme.d.ts.map +1 -1
- package/dist/src/utils/theme.js +80 -79
- package/json/README.md +74 -0
- package/json/a2ui-sample-messages.json +338 -0
- package/json/glchat_server_to_client_with_catalog.json +1000 -0
- package/json/glchat_standard_catalog_definition.json +844 -0
- package/package.json +6 -3
- package/styles/globals.css +135 -17
- package/dist/src/components/a2ui/Card/Card.d.ts +0 -4
- package/dist/src/components/a2ui/Card/Card.d.ts.map +0 -1
- package/dist/src/components/a2ui/Card/Card.js +0 -16
- package/dist/src/components/a2ui/CheckBox/CheckBox.d.ts +0 -4
- package/dist/src/components/a2ui/CheckBox/CheckBox.d.ts.map +0 -1
- package/dist/src/components/a2ui/CheckBox/CheckBox.js +0 -26
- package/dist/src/components/a2ui/TextField/TextField.d.ts +0 -4
- package/dist/src/components/a2ui/TextField/TextField.d.ts.map +0 -1
- package/dist/src/components/a2ui/TextField/TextField.js +0 -54
- package/patches/@a2ui+web_core+0.10.0.patch +0 -55
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
This package provides:
|
|
6
6
|
|
|
7
|
-
* **`Provider`** – `A2UIProvider` wrapper that automatically registers GLChat's custom components
|
|
7
|
+
* **`Provider`** – `A2UIProvider` wrapper that automatically registers GLChat's custom components.
|
|
8
8
|
* **`SingleSurfaceRenderer`** – thin wrapper around `A2UIRenderer` for a single `surfaceId`. Must be used inside `Provider`.
|
|
9
9
|
* **`AllSurfacesRenderer`** – convenience wrapper that renders every active `surfaceId`. Must be used inside `Provider`.
|
|
10
10
|
* **Tailwind theming** – `styles/globals.css`, `styles/theme-v4.css`, and `tailwind-config.cjs` for default tokens and utilities.
|
|
@@ -17,6 +17,7 @@ This library provides **GLChat-specific components and styling** while remaining
|
|
|
17
17
|
|
|
18
18
|
* **React 18+**
|
|
19
19
|
* **Tailwind CSS v3 or v4**
|
|
20
|
+
* **Material Symbols Outlined font** (required for `Icon` components — see [Icons](#icons))
|
|
20
21
|
|
|
21
22
|
---
|
|
22
23
|
|
|
@@ -68,9 +69,48 @@ To render a single surface explicitly:
|
|
|
68
69
|
|
|
69
70
|
> **Note:** `onAction` is configured on `Provider`. Both `SingleSurfaceRenderer` and `AllSurfacesRenderer` must be rendered inside a `Provider`.
|
|
70
71
|
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
# Icons
|
|
75
|
+
|
|
76
|
+
The upstream A2UI `Icon` component renders [Material Symbols Outlined](https://fonts.google.com/icons) via the `.g-icon` CSS class. This package does **not** bundle the font — you must load it in your app.
|
|
77
|
+
|
|
78
|
+
## Load the font
|
|
79
|
+
|
|
80
|
+
Add one of the following to your app shell (e.g. Next.js `layout.tsx`, `index.html`):
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<link
|
|
84
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=swap"
|
|
85
|
+
rel="stylesheet"
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Or import it in your global CSS (before or alongside the GLChat styles):
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=swap');
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Use **`display=swap`** so the browser repaints icons once the font finishes loading.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
71
99
|
# Custom Components (optional)
|
|
72
100
|
|
|
73
|
-
`Provider` automatically registers GLChat's
|
|
101
|
+
`Provider` automatically registers GLChat's standard component overrides — no extra setup needed:
|
|
102
|
+
|
|
103
|
+
| Component | Description |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `Button` | GLChat-styled button with `primary` / `outline` variants |
|
|
106
|
+
| `ButtonAsLink` | Button-styled anchor link with `href` and optional `target` |
|
|
107
|
+
| `DestructiveButton` | Destructive-styled button |
|
|
108
|
+
| `MultipleChoice` | Enhanced multiple-choice field (checkbox list / select) |
|
|
109
|
+
| `TagInput` | Tag input field with add/remove support |
|
|
110
|
+
| `Timeout` | Countdown to a target UTC time |
|
|
111
|
+
|
|
112
|
+
`Card`, `CheckBox`, `TextField`, and other upstream components use **theme-only** overrides (no custom React wrapper).
|
|
113
|
+
|
|
74
114
|
To add your own node types on top, register them on the singleton `ComponentRegistry` before rendering:
|
|
75
115
|
|
|
76
116
|
```tsx
|
|
@@ -155,11 +195,29 @@ The package tokens are declared as plain (unlayered) `:root` rules. To override
|
|
|
155
195
|
}
|
|
156
196
|
```
|
|
157
197
|
|
|
158
|
-
Button
|
|
198
|
+
Button variants use design tokens by default:
|
|
199
|
+
|
|
200
|
+
- **`Button`** (`primary: true`): `--primary`, `--primary-foreground`, `--ring`
|
|
201
|
+
- **`Button`** (default / outline): `--background`, `--background-alternate`, `--foreground`, `--border`, `--ring`
|
|
202
|
+
- **`DestructiveButton`**: `--destructive`, `--destructive-foreground`, `--ring`
|
|
203
|
+
- **`ButtonAsLink`**: same outline styling as `Button`, rendered as an anchor
|
|
159
204
|
|
|
160
|
-
- `
|
|
161
|
-
|
|
162
|
-
|
|
205
|
+
Override per-component inline styles via the `theme` prop on `Provider`:
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
<Provider
|
|
209
|
+
theme={{
|
|
210
|
+
additionalStyles: {
|
|
211
|
+
Button: { padding: '12px 20px' },
|
|
212
|
+
DestructiveButton: { borderRadius: '8px' },
|
|
213
|
+
},
|
|
214
|
+
}}
|
|
215
|
+
>
|
|
216
|
+
<AllSurfacesRenderer />
|
|
217
|
+
</Provider>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
UI primitives apply base and variant styles internally; `additionalStyles` values are theme **deltas** layered on top.
|
|
163
221
|
|
|
164
222
|
You may also extend the theme via:
|
|
165
223
|
|
|
@@ -168,6 +226,24 @@ You may also extend the theme via:
|
|
|
168
226
|
|
|
169
227
|
---
|
|
170
228
|
|
|
229
|
+
# JSON Catalog & Schemas
|
|
230
|
+
|
|
231
|
+
GLChat extends the official A2UI v0.8 catalog with additional components and publishes JSON schema files for validation and LLM structured output.
|
|
232
|
+
|
|
233
|
+
| File | Export path |
|
|
234
|
+
|---|---|
|
|
235
|
+
| GLChat catalog definition | `glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json` |
|
|
236
|
+
| Full server-to-client schema | `glchat-a2ui-react-renderer/json/glchat_server_to_client_with_catalog.json` |
|
|
237
|
+
| Sample messages (all components) | `glchat-a2ui-react-renderer/json/a2ui-sample-messages.json` |
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import catalog from 'glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json';
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
See [`json/README.md`](json/README.md) for a full component reference.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
171
247
|
# Exports
|
|
172
248
|
|
|
173
249
|
## Components
|
|
@@ -207,6 +283,12 @@ You may also extend the theme via:
|
|
|
207
283
|
* `styles/theme-v4.css`
|
|
208
284
|
* `tailwind-config.cjs`
|
|
209
285
|
|
|
286
|
+
## JSON
|
|
287
|
+
|
|
288
|
+
* `json/glchat_standard_catalog_definition.json`
|
|
289
|
+
* `json/glchat_server_to_client_with_catalog.json`
|
|
290
|
+
* `json/a2ui-sample-messages.json`
|
|
291
|
+
|
|
210
292
|
Upstream documentation:
|
|
211
293
|
[https://a2ui.org/renderers/](https://a2ui.org/renderers/)
|
|
212
294
|
|
package/dist/src/Provider.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { ComponentRegistry, type
|
|
2
|
+
import { ComponentRegistry, type ServerToClientMessage } from '@a2ui/react';
|
|
3
|
+
import type { UserAction } from '@a2ui/web_core/types/client-event';
|
|
3
4
|
import type { Theme } from '@a2ui/web_core/types/types';
|
|
4
5
|
export type A2UIMessage = ServerToClientMessage;
|
|
5
|
-
export type ActionPayload =
|
|
6
|
-
export type ActionHandler = (action:
|
|
6
|
+
export type ActionPayload = UserAction;
|
|
7
|
+
export type ActionHandler = (action: UserAction) => void | Promise<void>;
|
|
7
8
|
export type MessageErrorHandler = (error: unknown) => void;
|
|
8
9
|
export type ProviderProps = {
|
|
9
10
|
messages?: A2UIMessage[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAEL,iBAAiB,EAGjB,KAAK,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAEL,iBAAiB,EAGjB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKxD,MAAM,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AACvC,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AA8BF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,2CAsCtD;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAInD"}
|
package/dist/src/Provider.js
CHANGED
|
@@ -38,12 +38,7 @@ export function Provider(props) {
|
|
|
38
38
|
const handler = providerOnActionRef.current;
|
|
39
39
|
if (!handler)
|
|
40
40
|
return;
|
|
41
|
-
handler(
|
|
42
|
-
actionName: userAction.name,
|
|
43
|
-
sourceComponentId: userAction.sourceComponentId,
|
|
44
|
-
timestamp: userAction.timestamp,
|
|
45
|
-
context: userAction.context ?? {},
|
|
46
|
-
});
|
|
41
|
+
handler(userAction);
|
|
47
42
|
}, []);
|
|
48
43
|
// Register (or override) components after `@a2ui/react` has initialized its defaults.
|
|
49
44
|
// This avoids the official default catalog overwriting our custom component registrations.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Button/Button.tsx"],"names":[],"mappings":"
|
|
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,26 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react';
|
|
3
4
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
+
import { Button } from '../../ui/Button/Button.js';
|
|
5
6
|
export function CustomButtonComponent({ node, surfaceId, }) {
|
|
6
7
|
const { sendAction, theme } = useA2UIComponent(node, surfaceId);
|
|
7
|
-
const { child, action, primary
|
|
8
|
-
const variant = useMemo(() =>
|
|
9
|
-
|
|
10
|
-
return 'primary';
|
|
11
|
-
if (destructive)
|
|
12
|
-
return 'destructive';
|
|
13
|
-
return 'outline';
|
|
14
|
-
}, [primary, destructive]);
|
|
15
|
-
const buttonStyle = useMemo(() => ({
|
|
16
|
-
...stylesToObject(theme.additionalStyles?.Button),
|
|
17
|
-
...getGlchatButtonVariantStyles(variant),
|
|
18
|
-
}), [theme.additionalStyles?.Button, variant]);
|
|
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]);
|
|
19
11
|
const handleClick = () => {
|
|
20
12
|
if (action) {
|
|
21
13
|
sendAction(action);
|
|
22
14
|
}
|
|
23
15
|
};
|
|
24
16
|
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
25
|
-
return (_jsx("div", { className: "a2ui-button", style: hostStyle, children: _jsx(
|
|
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 }) }));
|
|
26
18
|
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
2
1
|
import type { Theme } from '@a2ui/web_core/types/types';
|
|
3
|
-
export
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export declare const glchatButtonComponents: Theme['components']['Button'];
|
|
8
|
-
/**
|
|
9
|
-
* Button inline styles aligned with package CSS tokens.
|
|
10
|
-
* Variant colors are layered in runtime via `getGlchatButtonVariantStyles`.
|
|
11
|
-
*/
|
|
12
|
-
export declare const glchatButtonAdditionalStyles: NonNullable<Theme['additionalStyles']>['Button'];
|
|
13
|
-
export declare function getGlchatButtonVariantStyles(variant: GlchatButtonVariant): CSSProperties;
|
|
2
|
+
export declare const buttonComponents: Theme['components']['Button'];
|
|
3
|
+
/** Theme override slot. Base and variant styles are applied by the UI Button primitive. */
|
|
4
|
+
export declare const buttonAdditionalStyles: NonNullable<Theme['additionalStyles']>['Button'];
|
|
14
5
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Button/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/Button/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,CAE1D,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAM,CAAC"}
|
|
@@ -1,59 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export const glchatButtonComponents = {};
|
|
5
|
-
/**
|
|
6
|
-
* Button inline styles aligned with package CSS tokens.
|
|
7
|
-
* Variant colors are layered in runtime via `getGlchatButtonVariantStyles`.
|
|
8
|
-
*/
|
|
9
|
-
export const glchatButtonAdditionalStyles = {
|
|
10
|
-
display: 'inline-flex',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
justifyContent: 'center',
|
|
13
|
-
whiteSpace: 'nowrap',
|
|
14
|
-
borderWidth: '1px',
|
|
15
|
-
borderStyle: 'solid',
|
|
16
|
-
borderRadius: '10px',
|
|
17
|
-
fontWeight: '600',
|
|
18
|
-
fontSize: '1rem',
|
|
19
|
-
lineHeight: '1.5rem',
|
|
20
|
-
padding: '10px 16px',
|
|
21
|
-
cursor: 'pointer',
|
|
22
|
-
transitionProperty: 'color, background-color, background-image, border-color, box-shadow',
|
|
23
|
-
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
24
|
-
transitionDuration: '150ms',
|
|
25
|
-
'--glchat-button-ring-color': 'hsl(var(--ring))',
|
|
1
|
+
export const buttonComponents = {
|
|
2
|
+
'glchat-a2ui-button': true,
|
|
26
3
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
backgroundColor: 'hsl(var(--primary))',
|
|
31
|
-
borderColor: 'hsl(var(--primary))',
|
|
32
|
-
color: 'hsl(var(--primary-foreground))',
|
|
33
|
-
'--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--primary)), hsl(var(--primary)))',
|
|
34
|
-
'--glchat-button-border-hover': 'hsl(var(--primary))',
|
|
35
|
-
'--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--primary)), hsl(var(--primary)))',
|
|
36
|
-
'--glchat-button-border-active': 'hsl(var(--primary))',
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (variant === 'destructive') {
|
|
40
|
-
return {
|
|
41
|
-
backgroundColor: 'hsl(var(--destructive))',
|
|
42
|
-
borderColor: 'hsl(var(--destructive))',
|
|
43
|
-
color: 'hsl(var(--destructive-foreground))',
|
|
44
|
-
'--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--destructive)), hsl(var(--destructive)))',
|
|
45
|
-
'--glchat-button-border-hover': 'hsl(var(--destructive))',
|
|
46
|
-
'--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--destructive)), hsl(var(--destructive)))',
|
|
47
|
-
'--glchat-button-border-active': 'hsl(var(--destructive))',
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
backgroundColor: 'hsl(var(--background))',
|
|
52
|
-
borderColor: 'hsl(var(--border))',
|
|
53
|
-
color: 'hsl(var(--foreground))',
|
|
54
|
-
'--glchat-button-bg-hover': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--background)), hsl(var(--background)))',
|
|
55
|
-
'--glchat-button-border-hover': 'hsl(var(--border))',
|
|
56
|
-
'--glchat-button-bg-active': 'linear-gradient(hsla(var(--hover)), hsla(var(--hover))), linear-gradient(hsl(var(--background)), hsl(var(--background)))',
|
|
57
|
-
'--glchat-button-border-active': 'hsl(var(--border))',
|
|
58
|
-
};
|
|
59
|
-
}
|
|
4
|
+
/** Theme override slot. Base and variant styles are applied by the UI Button primitive. */
|
|
5
|
+
export const buttonAdditionalStyles = {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type A2UIComponentProps } from '@a2ui/react';
|
|
2
|
+
import type { CustomNode } from '@a2ui/web_core/types/types';
|
|
3
|
+
export declare function CustomButtonAsLinkComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<CustomNode>>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=ButtonAsLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonAsLink.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/ButtonAsLink/ButtonAsLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EAExB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,4BAA4B,CAAC;AA0C/E,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,2CA8C1C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { sanitizeHref, sanitizeTarget } from '../../../utils/href.js';
|
|
6
|
+
import { ButtonAsLink } from '../../ui/Button/ButtonAsLink.js';
|
|
7
|
+
import { buttonAsLinkComponents } from './theme.js';
|
|
8
|
+
function resolveStringValue(value, resolveString, getValue) {
|
|
9
|
+
if (!value)
|
|
10
|
+
return undefined;
|
|
11
|
+
if (value.path) {
|
|
12
|
+
const raw = getValue(value.path);
|
|
13
|
+
if (raw == null)
|
|
14
|
+
return undefined;
|
|
15
|
+
if (typeof raw === 'string')
|
|
16
|
+
return raw;
|
|
17
|
+
if (typeof raw === 'number' || typeof raw === 'boolean')
|
|
18
|
+
return String(raw);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return resolveString(value) ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
function resolveHref(href, resolveString, getValue) {
|
|
24
|
+
const resolved = resolveStringValue(href, resolveString, getValue);
|
|
25
|
+
return sanitizeHref(resolved ?? '#');
|
|
26
|
+
}
|
|
27
|
+
export function CustomButtonAsLinkComponent({ node, surfaceId, }) {
|
|
28
|
+
const { theme, resolveString, getValue } = useA2UIComponent(node, surfaceId);
|
|
29
|
+
const { child, href, target } = node.properties;
|
|
30
|
+
const buttonAsLinkTheme = useMemo(() => {
|
|
31
|
+
const components = theme.components;
|
|
32
|
+
return components.ButtonAsLink ?? buttonAsLinkComponents;
|
|
33
|
+
}, [theme.components]);
|
|
34
|
+
const linkStyle = useMemo(() => stylesToObject(theme.additionalStyles?.ButtonAsLink), [theme.additionalStyles]);
|
|
35
|
+
const resolvedHref = useMemo(() => resolveHref(href, resolveString, getValue), [getValue, href, resolveString]);
|
|
36
|
+
const resolvedTarget = useMemo(() => {
|
|
37
|
+
const raw = resolveStringValue(target, resolveString, getValue);
|
|
38
|
+
return raw ? sanitizeTarget(raw) : undefined;
|
|
39
|
+
}, [getValue, resolveString, target]);
|
|
40
|
+
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
41
|
+
return (_jsx("div", { className: `a2ui-button a2ui-button-as-link ${classMapToString(buttonAsLinkTheme.container)}`.trim(), style: hostStyle, children: _jsx(ButtonAsLink, { href: resolvedHref, target: resolvedTarget, className: classMapToString(buttonAsLinkTheme.element), style: linkStyle, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,10 +1,4 @@
|
|
|
1
1
|
import type { Theme } from '@a2ui/web_core/types/types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export declare const glchatCardComponents: Theme['components']['Card'];
|
|
6
|
-
/**
|
|
7
|
-
* Card inline styles aligned with package CSS tokens.
|
|
8
|
-
*/
|
|
9
|
-
export declare const glchatCardAdditionalStyles: NonNullable<Theme['additionalStyles']>['Card'];
|
|
2
|
+
export declare const cardComponents: Theme['components']['Card'];
|
|
3
|
+
export declare const cardAdditionalStyles: NonNullable<Theme['additionalStyles']>['Card'];
|
|
10
4
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* Card structural layout classes.
|
|
3
|
-
*/
|
|
4
|
-
export const glchatCardComponents = {
|
|
1
|
+
export const cardComponents = {
|
|
5
2
|
'layout-p-4': true,
|
|
6
3
|
};
|
|
7
|
-
|
|
8
|
-
* Card inline styles aligned with package CSS tokens.
|
|
9
|
-
*/
|
|
10
|
-
export const glchatCardAdditionalStyles = {
|
|
4
|
+
export const cardAdditionalStyles = {
|
|
11
5
|
backgroundColor: 'hsl(var(--card))',
|
|
12
6
|
color: 'hsl(var(--card-foreground))',
|
|
13
7
|
borderColor: 'hsl(var(--border))',
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
2
1
|
import type { Theme } from '@a2ui/web_core/types/types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare const glchatCheckBoxComponents: Theme['components']['CheckBox'];
|
|
7
|
-
/**
|
|
8
|
-
* A2UI CheckBox row layout — checkbox + label side by side.
|
|
9
|
-
*/
|
|
10
|
-
export declare const glchatCheckBoxContainerStyles: CSSProperties;
|
|
2
|
+
export declare const checkBoxComponents: Theme['components']['CheckBox'];
|
|
3
|
+
export declare const checkBoxAdditionalStyles: NonNullable<Theme['additionalStyles']>['CheckBox'];
|
|
11
4
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/a2ui/CheckBox/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* A2UI CheckBox structural class map.
|
|
3
|
-
*/
|
|
4
|
-
export const glchatCheckBoxComponents = {
|
|
1
|
+
export const checkBoxComponents = {
|
|
5
2
|
container: {},
|
|
6
3
|
element: {},
|
|
7
4
|
label: {},
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
* A2UI CheckBox row layout — checkbox + label side by side.
|
|
11
|
-
*/
|
|
12
|
-
export const glchatCheckBoxContainerStyles = {
|
|
6
|
+
export const checkBoxAdditionalStyles = {
|
|
13
7
|
display: 'flex',
|
|
14
8
|
alignItems: 'center',
|
|
15
9
|
gap: '0.5rem',
|
|
@@ -2,7 +2,7 @@ import type { Theme } from '@a2ui/web_core/types/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* DateTimeInput structural class map.
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const dateTimeInputComponents: Theme['components']['DateTimeInput'];
|
|
6
6
|
/** Applied inline on the native date/time input. */
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const dateTimeInputAdditionalStyles: NonNullable<Theme['additionalStyles']>['DateTimeInput'];
|
|
8
8
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { textFieldInputStyles } from '../../ui/TextField/theme.js';
|
|
2
2
|
/**
|
|
3
3
|
* DateTimeInput structural class map.
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
5
|
+
export const dateTimeInputComponents = {
|
|
6
6
|
container: {},
|
|
7
7
|
label: {},
|
|
8
8
|
element: { 'glchat-a2ui-datetime-input': true },
|
|
9
9
|
};
|
|
10
10
|
/** Applied inline on the native date/time input. */
|
|
11
|
-
export const
|
|
11
|
+
export const dateTimeInputAdditionalStyles = textFieldInputStyles;
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useId, useMemo, useState } from 'react';
|
|
4
4
|
import { Checkbox } from '../../ui/Checkbox/Checkbox.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { checkboxLabelStyles } from '../../ui/Checkbox/theme.js';
|
|
6
|
+
import { checkboxListContainerStyles, checkboxListItemStyles, checkboxListSearchStyles, } from './theme.js';
|
|
7
7
|
export function CheckboxList({ options, value, onValueChange, singleSelect, maxSelections, filterable = false, className, }) {
|
|
8
8
|
const [search, setSearch] = useState('');
|
|
9
9
|
const groupId = useId();
|
|
@@ -29,7 +29,7 @@ export function CheckboxList({ options, value, onValueChange, singleSelect, maxS
|
|
|
29
29
|
onValueChange([...value, optionValue]);
|
|
30
30
|
};
|
|
31
31
|
const listClassName = ['glchat-a2ui-checkbox-list', className].filter(Boolean).join(' ');
|
|
32
|
-
return (_jsxs("div", { className: listClassName, style:
|
|
32
|
+
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
33
|
const isSelected = value.includes(option.value);
|
|
34
34
|
const atMax = !singleSelect &&
|
|
35
35
|
maxSelections !== void 0 &&
|
|
@@ -37,9 +37,9 @@ export function CheckboxList({ options, value, onValueChange, singleSelect, maxS
|
|
|
37
37
|
!isSelected;
|
|
38
38
|
const optionId = `${groupId}-${option.value}`;
|
|
39
39
|
return (_jsxs("label", { htmlFor: optionId, className: "glchat-a2ui-checkbox-option", style: {
|
|
40
|
-
...
|
|
40
|
+
...checkboxListItemStyles,
|
|
41
41
|
opacity: atMax ? 0.5 : 1,
|
|
42
42
|
cursor: atMax ? 'not-allowed' : 'pointer',
|
|
43
|
-
}, children: [_jsx(Checkbox, { id: optionId, checked: isSelected, disabled: atMax, onCheckedChange: () => toggleOption(option.value) }), _jsx("span", { style:
|
|
43
|
+
}, children: [_jsx(Checkbox, { id: optionId, checked: isSelected, disabled: atMax, onCheckedChange: () => toggleOption(option.value) }), _jsx("span", { style: checkboxLabelStyles, children: option.label })] }, option.value));
|
|
44
44
|
})] }));
|
|
45
45
|
}
|
|
@@ -4,9 +4,9 @@ import { classMapToString, useA2UIComponent, } from '@a2ui/react';
|
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { MultiSelect } from '../../ui/MultiSelect/MultiSelect.js';
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, } from '../../ui/Select/Select.js';
|
|
7
|
-
import {
|
|
7
|
+
import { selectTriggerLabelStyles, selectTriggerPlaceholderStyles, } from '../../ui/Select/theme.js';
|
|
8
8
|
import { CheckboxList } from './CheckboxList.js';
|
|
9
|
-
import {
|
|
9
|
+
import { multipleChoiceComponents } from './theme.js';
|
|
10
10
|
function isSingleSelect(maxAllowedSelections) {
|
|
11
11
|
return !maxAllowedSelections || maxAllowedSelections <= 1;
|
|
12
12
|
}
|
|
@@ -31,8 +31,8 @@ function SingleSelectChips({ elementClass, options, value, onValueChange, }) {
|
|
|
31
31
|
return match?.label ?? '';
|
|
32
32
|
}, [options, value]);
|
|
33
33
|
const triggerLabelStyle = useMemo(() => ({
|
|
34
|
-
...
|
|
35
|
-
...(selectedLabel ? undefined :
|
|
34
|
+
...selectTriggerLabelStyles,
|
|
35
|
+
...(selectedLabel ? undefined : selectTriggerPlaceholderStyles),
|
|
36
36
|
}), [selectedLabel]);
|
|
37
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
38
|
}
|
|
@@ -43,7 +43,7 @@ export function CustomMultipleChoiceComponent({ node, surfaceId, }) {
|
|
|
43
43
|
const singleSelect = isSingleSelect(maxAllowedSelections);
|
|
44
44
|
const selectionsPath = selections?.path;
|
|
45
45
|
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
46
|
-
const multipleChoiceTheme = theme.components.MultipleChoice ??
|
|
46
|
+
const multipleChoiceTheme = theme.components.MultipleChoice ?? multipleChoiceComponents;
|
|
47
47
|
const containerClass = classMapToString(multipleChoiceTheme.container);
|
|
48
48
|
const elementClass = classMapToString(multipleChoiceTheme.element);
|
|
49
49
|
const selectedValues = getSelectedValues(selections, getValue);
|