glchat-a2ui-react-renderer 0.0.2

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 (75) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +141 -0
  3. package/dist/index.d.ts +19 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +17 -0
  6. package/dist/src/components/Button.d.ts +12 -0
  7. package/dist/src/components/Button.d.ts.map +1 -0
  8. package/dist/src/components/Button.js +38 -0
  9. package/dist/src/components/Card.d.ts +9 -0
  10. package/dist/src/components/Card.d.ts.map +1 -0
  11. package/dist/src/components/Card.js +16 -0
  12. package/dist/src/components/Checkbox.d.ts +5 -0
  13. package/dist/src/components/Checkbox.d.ts.map +1 -0
  14. package/dist/src/components/Checkbox.js +9 -0
  15. package/dist/src/components/Column.d.ts +17 -0
  16. package/dist/src/components/Column.d.ts.map +1 -0
  17. package/dist/src/components/Column.js +20 -0
  18. package/dist/src/components/Image.d.ts +9 -0
  19. package/dist/src/components/Image.d.ts.map +1 -0
  20. package/dist/src/components/Image.js +25 -0
  21. package/dist/src/components/Input.d.ts +8 -0
  22. package/dist/src/components/Input.d.ts.map +1 -0
  23. package/dist/src/components/Input.js +9 -0
  24. package/dist/src/components/Label.d.ts +6 -0
  25. package/dist/src/components/Label.d.ts.map +1 -0
  26. package/dist/src/components/Label.js +10 -0
  27. package/dist/src/components/Row.d.ts +17 -0
  28. package/dist/src/components/Row.d.ts.map +1 -0
  29. package/dist/src/components/Row.js +20 -0
  30. package/dist/src/components/Separator.d.ts +5 -0
  31. package/dist/src/components/Separator.d.ts.map +1 -0
  32. package/dist/src/components/Separator.js +26 -0
  33. package/dist/src/components/Text.d.ts +8 -0
  34. package/dist/src/components/Text.d.ts.map +1 -0
  35. package/dist/src/components/Text.js +22 -0
  36. package/dist/src/components/TextField.d.ts +16 -0
  37. package/dist/src/components/TextField.d.ts.map +1 -0
  38. package/dist/src/components/TextField.js +31 -0
  39. package/dist/src/components/Timeout.d.ts +14 -0
  40. package/dist/src/components/Timeout.d.ts.map +1 -0
  41. package/dist/src/components/Timeout.js +40 -0
  42. package/dist/src/helpers/css.d.ts +11 -0
  43. package/dist/src/helpers/css.d.ts.map +1 -0
  44. package/dist/src/helpers/css.js +13 -0
  45. package/dist/src/helpers/messageParser.d.ts +10 -0
  46. package/dist/src/helpers/messageParser.d.ts.map +1 -0
  47. package/dist/src/helpers/messageParser.js +40 -0
  48. package/dist/src/hooks/useA2UIProcessor.d.ts +17 -0
  49. package/dist/src/hooks/useA2UIProcessor.d.ts.map +1 -0
  50. package/dist/src/hooks/useA2UIProcessor.js +16 -0
  51. package/dist/src/rendering/Surface.d.ts +28 -0
  52. package/dist/src/rendering/Surface.d.ts.map +1 -0
  53. package/dist/src/rendering/Surface.js +55 -0
  54. package/dist/src/rendering/catalog.d.ts +42 -0
  55. package/dist/src/rendering/catalog.d.ts.map +1 -0
  56. package/dist/src/rendering/catalog.js +139 -0
  57. package/dist/src/rendering/componentRegistry.d.ts +9 -0
  58. package/dist/src/rendering/componentRegistry.d.ts.map +1 -0
  59. package/dist/src/rendering/componentRegistry.js +10 -0
  60. package/dist/src/runtime/bindingResolver.d.ts +29 -0
  61. package/dist/src/runtime/bindingResolver.d.ts.map +1 -0
  62. package/dist/src/runtime/bindingResolver.js +143 -0
  63. package/dist/src/runtime/dispatcher.d.ts +15 -0
  64. package/dist/src/runtime/dispatcher.d.ts.map +1 -0
  65. package/dist/src/runtime/dispatcher.js +29 -0
  66. package/dist/src/runtime/messageProcessor.d.ts +54 -0
  67. package/dist/src/runtime/messageProcessor.d.ts.map +1 -0
  68. package/dist/src/runtime/messageProcessor.js +85 -0
  69. package/dist/src/runtime/surfaceManager.d.ts +48 -0
  70. package/dist/src/runtime/surfaceManager.d.ts.map +1 -0
  71. package/dist/src/runtime/surfaceManager.js +90 -0
  72. package/dist/src/types.d.ts +285 -0
  73. package/dist/src/types.d.ts.map +1 -0
  74. package/dist/src/types.js +4 -0
  75. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 GLChat
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # glchat-a2ui-react-renderer
2
+
3
+ A2UI (Agent-to-UI) React renderer for [GLChat](https://github.com/GDP-ADMIN/glchat-sdk). Renders declarative UI from AI agent messages using the [A2UI protocol](https://a2ui.org/).
4
+
5
+ ## Temporary solution
6
+
7
+ **This library is temporary** while waiting for the [official A2UI React renderer](https://a2ui.org/renderers/) to be released (planned Q1 2026). When the official React renderer is available, we recommend migrating to it. This implementation is structured to align with the official Lit and Angular renderers so that switching later should involve minimal changes.
8
+
9
+ ## Implementation guide
10
+
11
+ This renderer is guided by the **[A2UI Renderer Implementation Guide](https://a2ui.org/guides/renderer-development/)** and follows the same patterns as the existing official renderers:
12
+
13
+ - **[Lit (Web Components)](https://github.com/google/A2UI/tree/main/renderers/lit)** — [A2UI Renderers](https://a2ui.org/renderers/)
14
+ - **[Angular](https://github.com/google/A2UI/tree/main/renderers/angular)** — [A2UI Renderers](https://a2ui.org/renderers/)
15
+
16
+ ### Current implementation
17
+
18
+ - **Message processing & state:** JSONL-friendly parsing, message dispatcher (`beginRendering`, `surfaceUpdate`, `dataModelUpdate`, `deleteSurface`), surface manager keyed by `surfaceId`, component buffer (adjacency list) per surface, data model store per surface.
19
+ - **Progressive rendering:** Buffer updates until `beginRendering`; then render from the given `root`; component catalog (type → React component).
20
+ - **Data binding:** `BoundValue` resolution (literal and/or path against the surface data model); `setData(surfaceId, path, value)` for TextField/CheckBox so input changes update the model and refresh the UI.
21
+ - **Client–server:** User actions with resolved `action.context` sent as `userAction` payloads.
22
+
23
+ **Public API (aligned with Lit/Angular):** `MessageProcessor` (`getSurfaces()`, `processMessages()`, `clearSurfaces()`, `setData()`, `dispatch()`, `events.subscribe()`), `A2UISurface` (receives `surfaceId`, `surface`, optional `processor` + `refreshSurfaces`), and `useA2UIProcessor()` hook. No single “messages in, everything handled” component — the app feeds messages into the processor and renders one `A2UISurface` per surface.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ npm install glchat-a2ui-react-renderer
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ One example with all props. **User actions:** subscribe to `processor.events` once; send `event.message` to the backend, then call `event.completion(messages)` after `processMessages(messages)`.
34
+
35
+ ```tsx
36
+ import { useEffect } from 'react';
37
+ import {
38
+ useA2UIProcessor,
39
+ A2UISurface,
40
+ DEFAULT_CATALOG,
41
+ parseJSONLStream,
42
+ } from 'glchat-a2ui-react-renderer';
43
+ import type { Theme, ComponentCatalog } from 'glchat-a2ui-react-renderer';
44
+
45
+ // Optional: theme = classNames per component (styling only)
46
+ const theme: Theme = {
47
+ components: {
48
+ Text: { body: 'text-base text-gray-800', h1: 'text-2xl font-bold' },
49
+ Button: 'px-4 py-2 rounded-lg bg-blue-600 text-white',
50
+ },
51
+ };
52
+
53
+ // Optional: catalog = replace how a component type is rendered (e.g. custom Button)
54
+ const catalog: ComponentCatalog = {
55
+ ...DEFAULT_CATALOG,
56
+ // Button: (data, props) => <YourButton data={data} {...props} />,
57
+ };
58
+
59
+ function ChatSurfaces({ messages }: { messages: string }) {
60
+ const { processor, surfaces, refreshSurfaces } = useA2UIProcessor();
61
+
62
+ useEffect(() => {
63
+ processor.clearSurfaces();
64
+ processor.processMessages(parseJSONLStream(messages));
65
+ refreshSurfaces();
66
+ }, [messages, processor, refreshSurfaces]);
67
+
68
+ // Subscribe once to user actions (button clicks, etc.).
69
+ useEffect(() => {
70
+ const unsubscribe = processor.events.subscribe((event) => {
71
+ fetch('/api/action', {
72
+ method: 'POST',
73
+ body: JSON.stringify(event.message),
74
+ })
75
+ .then((res) => res.json())
76
+ .then((messages) => {
77
+ processor.clearSurfaces();
78
+ processor.processMessages(messages);
79
+ refreshSurfaces();
80
+ event.completion(messages);
81
+ });
82
+ });
83
+ return unsubscribe;
84
+ }, [processor, refreshSurfaces]);
85
+
86
+ return (
87
+ <>
88
+ {Array.from(surfaces.entries()).map(([surfaceId, surface]) => (
89
+ <A2UISurface
90
+ key={surfaceId}
91
+ surfaceId={surfaceId}
92
+ surface={surface}
93
+ processor={processor}
94
+ refreshSurfaces={refreshSurfaces}
95
+ theme={theme}
96
+ catalog={catalog}
97
+ />
98
+ ))}
99
+ </>
100
+ );
101
+ }
102
+ ```
103
+
104
+ | Prop | Required | Description |
105
+ |------|----------|-------------|
106
+ | `surfaceId` | Yes | Surface id (from `processor.getSurfaces()`). |
107
+ | `surface` | Yes | Surface state (from `processor.getSurfaces()`). |
108
+ | `processor` | No | With `refreshSurfaces`, enables TextField/CheckBox two-way binding. Subscribe to `processor.events` for user actions. |
109
+ | `refreshSurfaces` | No | Call after `processMessages()` so UI re-renders; pass with `processor` for inputs. |
110
+ | `theme` | No | ClassNames per component/part for built-in components. |
111
+ | `catalog` | No | Custom renderers: type → `(data, props) => ReactNode`; defaults to built-in catalog. |
112
+
113
+ ### Streaming
114
+
115
+ Append incoming chunks, parse with `parseJSONLStream(chunk)` or your own parser, then call `processor.processMessages(allMessages)` and `refreshSurfaces()` when new messages arrive.
116
+
117
+ ## Exports
118
+
119
+ - **Primary API:** `MessageProcessor`, `A2UISurface`, `A2UISurfaceProps`, `useA2UIProcessor`, `UseA2UIProcessorResult`
120
+ - **Catalog:** `DEFAULT_CATALOG`, `renderComponentFromCatalog`, `ComponentCatalog`, `ComponentRenderer`, `ComponentRenderProps`
121
+ - **Theme:** `defaultTheme`, type `Theme` (optional `components` with className strings per component/part)
122
+ - **Runtime:** `MessageDispatcher`, `SurfaceManager`, `resolveBoundValue`, `getPathFromBoundValue`, `resolveActionContext`, `setPathValue`, `updateDataModel`, `parseJSONLStream`, `isValidMessage`
123
+ - **Types:** `A2UIMessage`, `BoundValue`, `ClientToServerMessage`, `DispatchedEvent`, `UserAction`, `SurfaceState`, `Theme`, `ComponentDefinition`, and other protocol types (aligned with Lit/Angular)
124
+
125
+ ## Supported components
126
+
127
+ The default catalog includes: **Text**, **Button**, **Card**, **Row**, **Column**, **TextField**, **CheckBox**, **Image**, **Divider**, **Timeout**. See `json/glchat_standard_catalog_definition.json` and `json/a2ui-sample-messages.json` for the full GLChat catalog and sample messages.
128
+
129
+ ## Styling
130
+
131
+ Components use Tailwind CSS classes by default. Ensure your app has Tailwind (and the design tokens used by the components, e.g. `border-primary`, `bg-background`) or override with your own CSS. Pass a **theme** (see complete example above) to supply custom `className` strings per component or part (Text, TextField, Button, etc.) without replacing the catalog.
132
+
133
+ ## Docs
134
+
135
+ - [A2UI Renderer Implementation Guide](https://a2ui.org/guides/renderer-development/)
136
+ - [A2UI Renderers (Lit, Angular, Flutter, React roadmap)](https://a2ui.org/renderers/)
137
+ - `src/README.md` in this package for architecture and message flow details.
138
+
139
+ ## License
140
+
141
+ MIT
@@ -0,0 +1,19 @@
1
+ /**
2
+ * glchat-a2ui-react-renderer — A2UI React renderer for GLChat
3
+ * Structure aligned with official Lit/Angular renderers: processor + A2UISurface.
4
+ * @packageDocumentation
5
+ */
6
+ export { MessageProcessor } from './src/runtime/messageProcessor.js';
7
+ export { A2UISurface } from './src/rendering/Surface.js';
8
+ export type { A2UISurfaceProps } from './src/rendering/Surface.js';
9
+ export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
10
+ export type { UseA2UIProcessorResult } from './src/hooks/useA2UIProcessor.js';
11
+ export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
12
+ export type { ComponentCatalog, ComponentRenderer, ComponentRenderProps, } from './src/rendering/catalog.js';
13
+ export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
14
+ export { MessageDispatcher } from './src/runtime/dispatcher.js';
15
+ export { SurfaceManager } from './src/runtime/surfaceManager.js';
16
+ export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
17
+ export type { A2UIMessage, BeginRenderingMessage, SurfaceUpdateMessage, DataModelUpdateMessage, DeleteSurfaceMessage, BoundValue, ComponentDefinition, ClientToServerMessage, ClientError, DispatchedEvent, UserAction, ActionDefinition, ActionContextInput, DataModelContent, ValueMapItem, SurfaceState, Component, Theme, } from './src/types.js';
18
+ export { defaultTheme } from './src/types.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG9E,OAAO,EACL,eAAe,EACf,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAElF,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * glchat-a2ui-react-renderer — A2UI React renderer for GLChat
3
+ * Structure aligned with official Lit/Angular renderers: processor + A2UISurface.
4
+ * @packageDocumentation
5
+ */
6
+ // Primary API (same structure as Lit/Angular)
7
+ export { MessageProcessor } from './src/runtime/messageProcessor.js';
8
+ export { A2UISurface } from './src/rendering/Surface.js';
9
+ export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
10
+ // Catalog (type → component map, same pattern as Lit componentRegistry / Angular Catalog)
11
+ export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
12
+ // Runtime helpers
13
+ export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
14
+ export { MessageDispatcher } from './src/runtime/dispatcher.js';
15
+ export { SurfaceManager } from './src/runtime/surfaceManager.js';
16
+ export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
17
+ export { defaultTheme } from './src/types.js';
@@ -0,0 +1,12 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
3
+ asChild?: boolean;
4
+ }
5
+ declare const buttonVariants: (props?: ({
6
+ variant?: "primary" | "secondary" | "destructive" | "destructive-subtle" | "outline" | "ghost-primary" | "ghost-neutral" | "ghost-destructive" | "link-primary" | "link-neutral" | null | undefined;
7
+ size?: "small" | "tiny" | "medium" | "large" | "icon" | null | undefined;
8
+ shape?: "normal" | "pill" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
11
+ export { Button, buttonVariants };
12
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,cAAc;;;;8EAiFnB,CAAC;AAEF,QAAA,MAAM,MAAM,2GAsBX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Slot } from '@radix-ui/react-slot';
3
+ import { forwardRef } from 'react';
4
+ import { cn } from '../helpers/css.js';
5
+ import { cva } from 'class-variance-authority';
6
+ const buttonVariants = cva(cn('group inline-flex font-semibold border items-center justify-center whitespace-nowrap ring-offset-background transition-colors', 'disabled:pointer-events-none disabled:opacity-secondary'), {
7
+ variants: {
8
+ variant: {
9
+ primary: cn('border-primary bg-primary text-primary-foreground', 'hover:border-primary-hover hover:bg-primary-hover', 'focus:bg-primary-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-primary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-primary-hover active:outline-none active:ring-2 active:ring-ring'),
10
+ secondary: cn('border-primary-subtle bg-primary-subtle text-primary-subtle-foreground', 'hover:border-primary-subtle-hover hover:bg-primary-subtle-hover ', 'focus:border-primary-subtle-hover focus:bg-primary-subtle-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:border-primary-subtle-hover focus-visible:bg-primary-subtle-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:border-primary-subtle-hover active:bg-primary-subtle-hover active:outline-none active:ring-2 active:ring-ring'),
11
+ destructive: cn('border-destructive bg-destructive text-destructive-foreground', 'hover:border-destructive-hover hover:bg-destructive-hover', 'focus:bg-destructive-hover focus:border-destructive-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-hover focus-visible:border-destructive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-hover active:border-destructive-hover active:outline-none active:ring-2 active:ring-ring'),
12
+ 'destructive-subtle': cn('border-destructive-alternate bg-destructive-alternate text-destructive', 'hover:border-destructive-alternate-hover hover:bg-destructive-alternate-hover', 'focus:bg-destructive-alternate-hover focus:border-destructive-alternate-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-alternate-hover focus-visible:border-destructive-alternate-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-alternate-hover active:border-destructive-alternate-hover active:outline-none active:ring-2 active:ring-ring'),
13
+ outline: cn('bg-background text-foreground border-border', 'hover:bg-background-hover', 'focus:bg-background-hover', 'focus-visible:bg-background-hover', 'active:bg-background-hover'),
14
+ 'ghost-primary': cn('group-hover:underline group-hover:decoration-primary group-active:underline group-active:decoration-primary', 'text-primary border-transparent', 'hover:bg-primary-hover hover:border-primary-hover', 'focus:bg-primary-hover focus:border-primary-hover', 'focus-visible:bg-primary-hover focus-visible:border-primary-hover', 'active:bg-primary-hover active:border-primary-hover'),
15
+ 'ghost-neutral': cn('border-transparent text-foreground', 'hover:bg-background-hover hover:border-background-hover', 'focus:bg-background-hover focus:border-background-hover', 'focus-visible:bg-background-hover focus-visible:border-background-hover', 'active:bg-background-hover active:border-background-hover'),
16
+ 'ghost-destructive': cn('border-transparent text-destructive', 'hover:bg-destructive-alternate hover:border-destructive-alternate', 'focus:bg-destructive-alternate focus:border-destructive-alternate', 'focus-visible:bg-destructive-alternate focus-visible:border-destructive-alternate', 'active:bg-destructive-alternate active:border-destructive-alternate'),
17
+ 'link-primary': cn('border-transparent text-primary'),
18
+ 'link-neutral': cn('border-transparent text-foreground'),
19
+ },
20
+ size: {
21
+ tiny: 'text-sm px-[12px] py-[6px] rounded-[6px]',
22
+ small: 'text-base px-[16px] py-[8px] rounded-[8px]',
23
+ medium: 'text-base px-[16px] py-[10px] rounded-[10px]',
24
+ large: 'text-lg px-[20px] py-[10px] rounded-[12px]',
25
+ icon: 'h-10 w-10 rounded-[8px]',
26
+ },
27
+ shape: {
28
+ normal: '',
29
+ pill: 'rounded-full',
30
+ },
31
+ },
32
+ });
33
+ const Button = forwardRef(({ className, variant = 'primary', size = 'medium', shape = 'normal', asChild = false, ...props }, ref) => {
34
+ const Comp = asChild ? Slot : 'button';
35
+ return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, shape }), className), ref: ref, ...props }));
36
+ });
37
+ Button.displayName = 'Button';
38
+ export { Button, buttonVariants };
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ declare const Card: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
3
+ declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
4
+ declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
5
+ declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
6
+ declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
7
+ declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
8
+ export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
9
+ //# sourceMappingURL=Card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,QAAA,MAAM,IAAI,6GAYR,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,QAAA,MAAM,SAAS,uHASb,CAAC;AAGH,QAAA,MAAM,eAAe,yHAKnB,CAAC;AAGH,QAAA,MAAM,WAAW,6GAKf,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { cn } from '../helpers/css.js';
4
+ const Card = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('rounded-lg border bg-card text-card-foreground shadow-sm transition-colors duration-300 hover:bg-card-hover', className), ...props })));
5
+ Card.displayName = 'Card';
6
+ const CardHeader = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('flex flex-col space-y-1.5 p-6', className), ...props })));
7
+ CardHeader.displayName = 'CardHeader';
8
+ const CardTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx("h3", { ref: ref, className: cn('font-semibold leading-none tracking-tight', className), ...props })));
9
+ CardTitle.displayName = 'CardTitle';
10
+ const CardDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx("p", { ref: ref, className: cn('text-sm', className), ...props })));
11
+ CardDescription.displayName = 'CardDescription';
12
+ const CardContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('p-6 pt-0', className), ...props })));
13
+ CardContent.displayName = 'CardContent';
14
+ const CardFooter = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('flex items-center p-6 pt-0', className), ...props })));
15
+ CardFooter.displayName = 'CardFooter';
16
+ export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
@@ -0,0 +1,5 @@
1
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
2
+ import * as React from 'react';
3
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Checkbox };
5
+ //# sourceMappingURL=Checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,QAAA,MAAM,QAAQ,iKAkBZ,CAAC;AAGH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
4
+ import { Check } from 'lucide-react';
5
+ import * as React from 'react';
6
+ import { cn } from '../helpers/css.js';
7
+ const Checkbox = React.forwardRef(({ className, ...props }, ref) => (_jsx(CheckboxPrimitive.Root, { ref: ref, className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { className: cn('flex items-center justify-center text-current'), children: _jsx(Check, { className: "h-4 w-4", strokeWidth: 1.5 }) }) })));
8
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
9
+ export { Checkbox };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A2UI Column component
3
+ * @param children - The content of the column
4
+ * @param distribution - The distribution of the column
5
+ * @param alignment - The alignment of the column
6
+ * @param className - The class name to apply to the column
7
+ */
8
+ import type { ReactNode } from 'react';
9
+ interface ColumnProps {
10
+ children: ReactNode;
11
+ distribution?: 'start' | 'end' | 'center' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly';
12
+ alignment?: 'start' | 'end' | 'center' | 'stretch';
13
+ className?: string;
14
+ }
15
+ export declare function A2UIColumn({ children, distribution, alignment, className, }: ColumnProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=Column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Column.d.ts","sourceRoot":"","sources":["../../../src/components/Column.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,UAAU,WAAW;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EACT,OAAO,GACP,KAAK,GACL,QAAQ,GACR,cAAc,GACd,aAAa,GACb,aAAa,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkBD,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,YAAsB,EACtB,SAAqB,EACrB,SAAS,GACV,EAAE,WAAW,2CAab"}
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { cn } from '../helpers/css.js';
4
+ const distributionClasses = {
5
+ start: 'justify-start',
6
+ end: 'justify-end',
7
+ center: 'justify-center',
8
+ spaceBetween: 'justify-between',
9
+ spaceAround: 'justify-around',
10
+ spaceEvenly: 'justify-evenly',
11
+ };
12
+ const alignmentClasses = {
13
+ start: 'items-start',
14
+ end: 'items-end',
15
+ center: 'items-center',
16
+ stretch: 'items-stretch',
17
+ };
18
+ export function A2UIColumn({ children, distribution = 'start', alignment = 'stretch', className, }) {
19
+ return (_jsx("div", { className: cn('flex flex-col gap-2', distributionClasses[distribution], alignmentClasses[alignment], className), children: children }));
20
+ }
@@ -0,0 +1,9 @@
1
+ interface A2UIImageProps {
2
+ url: string;
3
+ fit?: 'cover' | 'contain' | 'fill' | 'none' | 'scaleDown';
4
+ usageHint?: 'avatar' | 'hero' | 'thumbnail';
5
+ className?: string;
6
+ }
7
+ export declare function A2UIImage({ url, fit, usageHint, className, }: A2UIImageProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=Image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../src/components/Image.tsx"],"names":[],"mappings":"AAWA,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IAC1D,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,GAAa,EACb,SAAS,EACT,SAAS,GACV,EAAE,cAAc,2CAahB"}
@@ -0,0 +1,25 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ /**
4
+ * A2UI Image component
5
+ * @param url - The URL of the image
6
+ * @param fit - The fit of the image
7
+ * @param usageHint - The usage hint of the image
8
+ * @param className - The class name to apply to the image
9
+ */
10
+ import { cn } from '../helpers/css.js';
11
+ const fitClasses = {
12
+ cover: 'object-cover',
13
+ contain: 'object-contain',
14
+ fill: 'object-fill',
15
+ none: 'object-none',
16
+ scaleDown: 'object-scale-down',
17
+ };
18
+ const usageHintClasses = {
19
+ avatar: 'rounded-full w-12 h-12',
20
+ hero: 'w-full h-64',
21
+ thumbnail: 'w-24 h-24',
22
+ };
23
+ export function A2UIImage({ url, fit = 'cover', usageHint, className, }) {
24
+ return (_jsx("img", { src: url, alt: "a2ui image", className: cn('max-w-full h-auto', fitClasses[fit], usageHint && usageHintClasses[usageHint], className) }));
25
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
+ actionElement?: React.ReactNode;
4
+ error?: boolean;
5
+ }
6
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
7
+ export { Input };
8
+ //# sourceMappingURL=Input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,UACf,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IACnD,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,KAAK,qFAuBV,CAAC;AAGF,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { cn } from '../helpers/css.js';
4
+ const Input = React.forwardRef(({ actionElement, className, type, error, ...props }, ref) => {
5
+ return (_jsxs("div", { className: "relative flex w-full items-center", children: [_jsx("input", { type: type, className: cn('invalid:text-error invalid:ring-error flex h-10 w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground caret-current file:border-0 file:bg-transparent file:text-sm file:font-medium focus:border-primary focus:outline-none focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50', { 'border-destructive': error }, className), ref: ref, ...props }), actionElement &&
6
+ (type === 'text' || type === 'password' || type === 'number') && (_jsx("span", { className: "absolute inset-y-0 right-0 z-10 flex items-center pr-3", children: actionElement }))] }));
7
+ });
8
+ Input.displayName = 'Input';
9
+ export { Input };
@@ -0,0 +1,6 @@
1
+ import * as LabelPrimitive from '@radix-ui/react-label';
2
+ import * as React from 'react';
3
+ import { type VariantProps } from 'class-variance-authority';
4
+ declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
5
+ export { Label };
6
+ //# sourceMappingURL=Label.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../src/components/Label.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAMlE,QAAA,MAAM,KAAK,4PAUT,CAAC;AAGH,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as LabelPrimitive from '@radix-ui/react-label';
4
+ import * as React from 'react';
5
+ import { cn } from '../helpers/css.js';
6
+ import { cva } from 'class-variance-authority';
7
+ const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
8
+ const Label = React.forwardRef(({ className, ...props }, ref) => (_jsx(LabelPrimitive.Root, { ref: ref, className: cn(labelVariants(), className), ...props })));
9
+ Label.displayName = LabelPrimitive.Root.displayName;
10
+ export { Label };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A2UI Row component
3
+ * @param children - The content of the row
4
+ * @param distribution - The distribution of the row
5
+ * @param alignment - The alignment of the row
6
+ * @param className - The class name to apply to the row
7
+ */
8
+ import type { ReactNode } from 'react';
9
+ interface RowProps {
10
+ children: ReactNode;
11
+ distribution?: 'start' | 'end' | 'center' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly';
12
+ alignment?: 'start' | 'end' | 'center' | 'stretch';
13
+ className?: string;
14
+ }
15
+ export declare function A2UIRow({ children, distribution, alignment, className, }: RowProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=Row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/Row.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,UAAU,QAAQ;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EACT,OAAO,GACP,KAAK,GACL,QAAQ,GACR,cAAc,GACd,aAAa,GACb,aAAa,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkBD,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,YAAsB,EACtB,SAAqB,EACrB,SAAS,GACV,EAAE,QAAQ,2CAaV"}
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { cn } from '../helpers/css.js';
4
+ const distributionClasses = {
5
+ start: 'justify-start',
6
+ end: 'justify-end',
7
+ center: 'justify-center',
8
+ spaceBetween: 'justify-between',
9
+ spaceAround: 'justify-around',
10
+ spaceEvenly: 'justify-evenly',
11
+ };
12
+ const alignmentClasses = {
13
+ start: 'items-start',
14
+ end: 'items-end',
15
+ center: 'items-center',
16
+ stretch: 'items-stretch',
17
+ };
18
+ export function A2UIRow({ children, distribution = 'start', alignment = 'stretch', className, }) {
19
+ return (_jsx("div", { className: cn('flex flex-row gap-2', distributionClasses[distribution], alignmentClasses[alignment], className), children: children }));
20
+ }
@@ -0,0 +1,5 @@
1
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
2
+ import * as React from 'react';
3
+ declare const Separator: React.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ export { Separator };
5
+ //# sourceMappingURL=Separator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Separator.d.ts","sourceRoot":"","sources":["../../../src/components/Separator.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,QAAA,MAAM,SAAS,6JAoBd,CAAC;AAGF,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ /*
4
+ * Separator.tsx
5
+ *
6
+ * Authors:
7
+ * Vincent Chuardi (vincent.chuardi@gdplabs.id)
8
+ * Created at: July 17th 2024
9
+ * -----
10
+ * Last Modified: October 16th 2024
11
+ * Modified By: Ryan Ignatius Hadiwijaya (ryan.i.hadiwijaya@gdplabs.id)
12
+ * -----
13
+ * Reviewers:
14
+ *
15
+ * ---
16
+ * References:
17
+ * NONE
18
+ * ---
19
+ * Copyright (c) 2024 GDP LABS. All rights reserved.
20
+ */
21
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
22
+ import * as React from 'react';
23
+ import { cn } from '../helpers/css.js';
24
+ const Separator = React.forwardRef(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (_jsx(SeparatorPrimitive.Root, { ref: ref, decorative: decorative, orientation: orientation, className: cn('shrink-0 bg-border', orientation === 'horizontal' ? 'h-[2px] w-full' : 'h-full w-[2px]', className), ...props })));
25
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
26
+ export { Separator };
@@ -0,0 +1,8 @@
1
+ interface TextProps {
2
+ text: string;
3
+ usageHint?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'body' | 'caption';
4
+ className?: string;
5
+ }
6
+ export declare function A2UIText({ text, usageHint, className }: TextProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=Text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/components/Text.tsx"],"names":[],"mappings":"AAUA,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAkB,EAAE,SAAS,EAAE,EAAE,SAAS,2CAkB1E"}
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ /**
4
+ * A2UI Text component
5
+ * @param text - The text to display
6
+ * @param usageHint - The usage hint of the text
7
+ * @param className - The class name to apply to the text
8
+ */
9
+ import { cn } from '../helpers/css.js';
10
+ export function A2UIText({ text, usageHint = 'body', className }) {
11
+ const baseClasses = {
12
+ h1: 'text-4xl font-bold',
13
+ h2: 'text-3xl font-bold',
14
+ h3: 'text-2xl font-semibold',
15
+ h4: 'text-xl font-semibold',
16
+ h5: 'text-lg font-medium',
17
+ body: 'text-base',
18
+ caption: 'text-sm text-muted-foreground',
19
+ };
20
+ const Component = ['body', 'caption'].includes(usageHint) ? 'p' : usageHint;
21
+ return (_jsx(Component, { className: cn(baseClasses[usageHint], className), children: text }));
22
+ }
@@ -0,0 +1,16 @@
1
+ interface A2UITextFieldProps {
2
+ label?: string;
3
+ value: string | number;
4
+ onChange?: (value: string | number) => void;
5
+ textFieldType?: 'shortText' | 'longText' | 'number' | 'obscured' | 'date';
6
+ validationRegexp?: string;
7
+ /** Container wrapper className (theme: TextField.container). */
8
+ className?: string;
9
+ /** Label className (theme: TextField.label). */
10
+ labelClassName?: string;
11
+ /** Input/textarea element className (theme: TextField.element). */
12
+ elementClassName?: string;
13
+ }
14
+ export declare function A2UITextField({ label, value, onChange, textFieldType, validationRegexp, className, labelClassName, elementClassName, }: A2UITextFieldProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=TextField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/TextField.tsx"],"names":[],"mappings":"AAiBA,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAA2B,EAC3B,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,EAAE,kBAAkB,2CAsDpB"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cn } from '../helpers/css.js';
4
+ import { Input } from './Input.js';
5
+ import { Label } from './Label.js';
6
+ export function A2UITextField({ label, value, onChange, textFieldType = 'shortText', validationRegexp, className, labelClassName, elementClassName, }) {
7
+ function handleChange(e) {
8
+ if (!onChange)
9
+ return;
10
+ const newValue = e.target.value;
11
+ if (textFieldType === 'number') {
12
+ const numValue = parseFloat(newValue);
13
+ onChange(isNaN(numValue) ? 0 : numValue);
14
+ }
15
+ else {
16
+ onChange(newValue);
17
+ }
18
+ }
19
+ const inputType = textFieldType === 'obscured'
20
+ ? 'password'
21
+ : textFieldType === 'number'
22
+ ? 'number'
23
+ : textFieldType === 'date'
24
+ ? 'date'
25
+ : 'text';
26
+ const inputClasses = cn('border-input mt-2 w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', elementClassName);
27
+ if (textFieldType === 'longText') {
28
+ return (_jsxs("div", { className: className, children: [label && _jsx(Label, { className: labelClassName, children: label }), _jsx("textarea", { value: value, onChange: handleChange, className: cn(inputClasses, 'min-h-[100px]') })] }));
29
+ }
30
+ return (_jsxs("div", { className: className, children: [label && _jsx(Label, { className: labelClassName, children: label }), _jsx(Input, { type: inputType, value: value, onChange: handleChange, pattern: validationRegexp, className: cn('mt-2', elementClassName) })] }));
31
+ }