@easyops-cn/a2ui-react 0.0.0

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 (161) hide show
  1. package/.claude/commands/speckit.analyze.md +184 -0
  2. package/.claude/commands/speckit.checklist.md +294 -0
  3. package/.claude/commands/speckit.clarify.md +181 -0
  4. package/.claude/commands/speckit.constitution.md +82 -0
  5. package/.claude/commands/speckit.implement.md +135 -0
  6. package/.claude/commands/speckit.plan.md +89 -0
  7. package/.claude/commands/speckit.specify.md +256 -0
  8. package/.claude/commands/speckit.tasks.md +137 -0
  9. package/.claude/commands/speckit.taskstoissues.md +30 -0
  10. package/.github/workflows/deploy.yml +69 -0
  11. package/.husky/pre-commit +1 -0
  12. package/.prettierignore +4 -0
  13. package/.prettierrc +7 -0
  14. package/.specify/memory/constitution.md +73 -0
  15. package/.specify/scripts/bash/check-prerequisites.sh +166 -0
  16. package/.specify/scripts/bash/common.sh +156 -0
  17. package/.specify/scripts/bash/create-new-feature.sh +297 -0
  18. package/.specify/scripts/bash/setup-plan.sh +61 -0
  19. package/.specify/scripts/bash/update-agent-context.sh +799 -0
  20. package/.specify/templates/agent-file-template.md +28 -0
  21. package/.specify/templates/checklist-template.md +40 -0
  22. package/.specify/templates/plan-template.md +105 -0
  23. package/.specify/templates/spec-template.md +115 -0
  24. package/.specify/templates/tasks-template.md +250 -0
  25. package/CLAUDE.md +105 -0
  26. package/CONTRIBUTING.md +97 -0
  27. package/README.md +126 -0
  28. package/components.json +21 -0
  29. package/eslint.config.js +25 -0
  30. package/netlify.toml +50 -0
  31. package/package.json +94 -0
  32. package/playground/README.md +75 -0
  33. package/playground/index.html +22 -0
  34. package/playground/package.json +32 -0
  35. package/playground/public/favicon.svg +8 -0
  36. package/playground/src/App.css +256 -0
  37. package/playground/src/App.tsx +115 -0
  38. package/playground/src/assets/react.svg +1 -0
  39. package/playground/src/components/ErrorDisplay.tsx +13 -0
  40. package/playground/src/components/ExampleSelector.tsx +64 -0
  41. package/playground/src/components/Header.tsx +47 -0
  42. package/playground/src/components/JsonEditor.tsx +32 -0
  43. package/playground/src/components/Preview.tsx +78 -0
  44. package/playground/src/components/ThemeToggle.tsx +19 -0
  45. package/playground/src/data/examples.ts +1571 -0
  46. package/playground/src/hooks/useTheme.ts +55 -0
  47. package/playground/src/index.css +220 -0
  48. package/playground/src/main.tsx +10 -0
  49. package/playground/tsconfig.app.json +34 -0
  50. package/playground/tsconfig.json +13 -0
  51. package/playground/tsconfig.node.json +26 -0
  52. package/playground/vite.config.ts +31 -0
  53. package/specs/001-a2ui-renderer/checklists/requirements.md +41 -0
  54. package/specs/001-a2ui-renderer/data-model.md +140 -0
  55. package/specs/001-a2ui-renderer/plan.md +123 -0
  56. package/specs/001-a2ui-renderer/quickstart.md +141 -0
  57. package/specs/001-a2ui-renderer/research.md +140 -0
  58. package/specs/001-a2ui-renderer/spec.md +165 -0
  59. package/specs/001-a2ui-renderer/tasks.md +310 -0
  60. package/specs/002-playground/checklists/requirements.md +37 -0
  61. package/specs/002-playground/contracts/components.md +120 -0
  62. package/specs/002-playground/data-model.md +149 -0
  63. package/specs/002-playground/plan.md +73 -0
  64. package/specs/002-playground/quickstart.md +158 -0
  65. package/specs/002-playground/research.md +117 -0
  66. package/specs/002-playground/spec.md +109 -0
  67. package/specs/002-playground/tasks.md +224 -0
  68. package/src/0.8/A2UIRender.test.tsx +793 -0
  69. package/src/0.8/A2UIRender.tsx +142 -0
  70. package/src/0.8/components/ComponentRenderer.test.tsx +373 -0
  71. package/src/0.8/components/ComponentRenderer.tsx +163 -0
  72. package/src/0.8/components/UnknownComponent.tsx +49 -0
  73. package/src/0.8/components/display/AudioPlayerComponent.tsx +37 -0
  74. package/src/0.8/components/display/DividerComponent.tsx +23 -0
  75. package/src/0.8/components/display/IconComponent.tsx +137 -0
  76. package/src/0.8/components/display/ImageComponent.tsx +57 -0
  77. package/src/0.8/components/display/TextComponent.tsx +56 -0
  78. package/src/0.8/components/display/VideoComponent.tsx +31 -0
  79. package/src/0.8/components/display/display.test.tsx +660 -0
  80. package/src/0.8/components/display/index.ts +10 -0
  81. package/src/0.8/components/index.ts +14 -0
  82. package/src/0.8/components/interactive/ButtonComponent.tsx +44 -0
  83. package/src/0.8/components/interactive/CheckBoxComponent.tsx +45 -0
  84. package/src/0.8/components/interactive/DateTimeInputComponent.tsx +176 -0
  85. package/src/0.8/components/interactive/MultipleChoiceComponent.tsx +157 -0
  86. package/src/0.8/components/interactive/SliderComponent.tsx +53 -0
  87. package/src/0.8/components/interactive/TextFieldComponent.tsx +65 -0
  88. package/src/0.8/components/interactive/index.ts +10 -0
  89. package/src/0.8/components/interactive/interactive.test.tsx +618 -0
  90. package/src/0.8/components/layout/CardComponent.tsx +30 -0
  91. package/src/0.8/components/layout/ColumnComponent.tsx +93 -0
  92. package/src/0.8/components/layout/ListComponent.tsx +81 -0
  93. package/src/0.8/components/layout/ModalComponent.tsx +41 -0
  94. package/src/0.8/components/layout/RowComponent.tsx +94 -0
  95. package/src/0.8/components/layout/TabsComponent.tsx +59 -0
  96. package/src/0.8/components/layout/index.ts +10 -0
  97. package/src/0.8/components/layout/layout.test.tsx +558 -0
  98. package/src/0.8/contexts/A2UIProvider.test.tsx +226 -0
  99. package/src/0.8/contexts/A2UIProvider.tsx +54 -0
  100. package/src/0.8/contexts/ActionContext.test.tsx +242 -0
  101. package/src/0.8/contexts/ActionContext.tsx +105 -0
  102. package/src/0.8/contexts/ComponentsMapContext.tsx +125 -0
  103. package/src/0.8/contexts/DataModelContext.test.tsx +335 -0
  104. package/src/0.8/contexts/DataModelContext.tsx +184 -0
  105. package/src/0.8/contexts/SurfaceContext.test.tsx +339 -0
  106. package/src/0.8/contexts/SurfaceContext.tsx +197 -0
  107. package/src/0.8/hooks/useA2UIMessageHandler.test.tsx +399 -0
  108. package/src/0.8/hooks/useA2UIMessageHandler.ts +123 -0
  109. package/src/0.8/hooks/useComponent.test.tsx +148 -0
  110. package/src/0.8/hooks/useComponent.ts +39 -0
  111. package/src/0.8/hooks/useDataBinding.test.tsx +334 -0
  112. package/src/0.8/hooks/useDataBinding.ts +99 -0
  113. package/src/0.8/hooks/useDispatchAction.test.tsx +83 -0
  114. package/src/0.8/hooks/useDispatchAction.ts +35 -0
  115. package/src/0.8/hooks/useSurface.test.tsx +114 -0
  116. package/src/0.8/hooks/useSurface.ts +34 -0
  117. package/src/0.8/index.ts +38 -0
  118. package/src/0.8/schemas/client_to_server.json +50 -0
  119. package/src/0.8/schemas/server_to_client.json +148 -0
  120. package/src/0.8/schemas/standard_catalog_definition.json +661 -0
  121. package/src/0.8/types/index.ts +448 -0
  122. package/src/0.8/utils/dataBinding.test.ts +443 -0
  123. package/src/0.8/utils/dataBinding.ts +212 -0
  124. package/src/0.8/utils/pathUtils.test.ts +353 -0
  125. package/src/0.8/utils/pathUtils.ts +200 -0
  126. package/src/components/ui/button.tsx +62 -0
  127. package/src/components/ui/calendar.tsx +220 -0
  128. package/src/components/ui/card.tsx +92 -0
  129. package/src/components/ui/checkbox.tsx +30 -0
  130. package/src/components/ui/dialog.tsx +141 -0
  131. package/src/components/ui/input.tsx +21 -0
  132. package/src/components/ui/label.tsx +22 -0
  133. package/src/components/ui/native-select.tsx +53 -0
  134. package/src/components/ui/popover.tsx +46 -0
  135. package/src/components/ui/select.tsx +188 -0
  136. package/src/components/ui/separator.tsx +26 -0
  137. package/src/components/ui/slider.tsx +61 -0
  138. package/src/components/ui/tabs.tsx +64 -0
  139. package/src/components/ui/textarea.tsx +18 -0
  140. package/src/index.ts +1 -0
  141. package/src/lib/utils.ts +6 -0
  142. package/tsconfig.json +28 -0
  143. package/vite.config.ts +29 -0
  144. package/vitest.config.ts +22 -0
  145. package/vitest.setup.ts +8 -0
  146. package/website/README.md +4 -0
  147. package/website/assets/favicon.svg +8 -0
  148. package/website/content/.gitkeep +0 -0
  149. package/website/content/index.md +122 -0
  150. package/website/global.d.ts +9 -0
  151. package/website/package.json +17 -0
  152. package/website/plain.config.js +28 -0
  153. package/website/serve.json +6 -0
  154. package/website/src/client/color-mode-switch.css +47 -0
  155. package/website/src/client/index.js +61 -0
  156. package/website/src/client/moon.svg +1 -0
  157. package/website/src/client/sun.svg +1 -0
  158. package/website/src/components/Footer.jsx +9 -0
  159. package/website/src/components/Header.jsx +44 -0
  160. package/website/src/components/Page.jsx +28 -0
  161. package/website/src/global.css +423 -0
@@ -0,0 +1,97 @@
1
+ # Contributing to A2UI React
2
+
3
+ Thank you for your interest in contributing to `@easyops-cn/a2ui-react`!
4
+
5
+ ## Project Overview
6
+
7
+ A2UI React Renderer Library - A React implementation for rendering A2UI protocol. This is a library package that downstream developers consume.
8
+
9
+ ## Monorepo Structure
10
+
11
+ This is an npm workspaces monorepo:
12
+
13
+ - Root package: `@easyops-cn/a2ui-react` - The main library
14
+ - `website/` - Documentation site using plain-blog
15
+ - `playground/` - Live demo workspace for real-time A2UI rendering development
16
+
17
+ ## Development Setup
18
+
19
+ 1. Clone the repository
20
+ 2. Install dependencies:
21
+ ```bash
22
+ npm install
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ ### Library (root)
28
+
29
+ ```bash
30
+ npm run build # TypeScript compile + Vite build (outputs to dist/)
31
+ npm run dev # Start Vite dev server for local development
32
+ npm test # Run Vitest in watch mode
33
+ npm run test:run # Run tests once
34
+ npm run lint # Run ESLint
35
+ npm run lint:fix # ESLint with auto-fix
36
+ ```
37
+
38
+ ### Website
39
+
40
+ ```bash
41
+ npm run build -w website # Build website (outputs to website/dist/)
42
+ npm run serve -w website # Serve built website locally
43
+ ```
44
+
45
+ ### Playground
46
+
47
+ ```bash
48
+ npm run dev -w playground # Start playground dev server for live A2UI demos
49
+ npm run build -w playground # Build playground
50
+ ```
51
+
52
+ ## Key Directories
53
+
54
+ - `src/0.8/contexts/` - React context providers (Surface, DataModel, Action)
55
+ - `src/0.8/hooks/` - Custom hooks for data binding and actions
56
+ - `src/0.8/components/` - Component implementations (display/, layout/, interactive/)
57
+ - `src/0.8/schemas/` - JSON schemas for A2UI protocol
58
+ - `src/components/ui/` - shadcn/ui primitives
59
+
60
+ ## Testing
61
+
62
+ Tests are co-located with source files (`*.test.tsx`). Uses Vitest + React Testing Library + jsdom.
63
+
64
+ Run tests before submitting:
65
+
66
+ ```bash
67
+ npm run test:run
68
+ ```
69
+
70
+ ## Code Style
71
+
72
+ Run linting before submitting:
73
+
74
+ ```bash
75
+ npm run lint
76
+ ```
77
+
78
+ To auto-fix issues:
79
+
80
+ ```bash
81
+ npm run lint:fix
82
+ ```
83
+
84
+ ## Technologies
85
+
86
+ - TypeScript 5.9
87
+ - React 19
88
+ - Radix UI (for UI primitives)
89
+ - Tailwind CSS (via class-variance-authority)
90
+
91
+ ## Pull Request Process
92
+
93
+ 1. Fork the repository
94
+ 2. Create a feature branch
95
+ 3. Make your changes
96
+ 4. Run tests and linting
97
+ 5. Submit a pull request
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # A2UI React Renderer Library
2
+
3
+ https://easyops-cn.github.io/a2ui-react/
4
+
5
+ A React renderer library for [A2UI](https://a2ui.org) protocol.
6
+
7
+ Supports all components in A2UI standard catalog out of the box. Built with [shadcn/ui](https://ui.shadcn.com/) and [Tailwind CSS](https://tailwindcss.com/).
8
+
9
+ Currently A2UI protocol v0.8 is fully supported. Work on v0.9 is in progress.
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ npm install @easyops-cn/a2ui-react
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ First, use the `@source` directive to tell Tailwind to scan the library code for class names in your global CSS:
20
+
21
+ ```css
22
+ @source "../node_modules/@easyops-cn/a2ui-react";
23
+ ```
24
+
25
+ Next, use the `A2UIRender` component to render A2UI messages:
26
+
27
+ ```tsx
28
+ import {
29
+ A2UIRender,
30
+ type A2UIMessage,
31
+ type A2UIAction,
32
+ } from '@easyops-cn/a2ui-react/0.8'
33
+
34
+ function App() {
35
+ const messages: A2UIMessage[] = []
36
+
37
+ const handleAction = (action: A2UIAction) => {
38
+ console.log('Action received:', action)
39
+ }
40
+
41
+ return <A2UIRender messages={messages} onAction={handleAction} />
42
+ }
43
+ ```
44
+
45
+ ### Custom components
46
+
47
+ You can override default components or add new custom components via the `components` prop, which takes a `Map<string, React.ComponentType>`.
48
+
49
+ ```tsx
50
+ import { A2UIRender, A2UIMessage, A2UIAction } from '@easyops-cn/a2ui-react/0.8'
51
+
52
+ const ComponentsMap = new Map<string, React.ComponentType<any>>([
53
+ // Override default Button component with a custom one
54
+ ['Button', CustomButtonComponent],
55
+
56
+ // Add a new custom Switch component
57
+ ['Switch', CustomSwitchComponent],
58
+ ])
59
+
60
+ function App() {
61
+ return (
62
+ <A2UIRender
63
+ components={ComponentsMap}
64
+ messages={messages}
65
+ onAction={handleAction}
66
+ />
67
+ )
68
+ }
69
+ ```
70
+
71
+ Custom button component with action dispatch:
72
+
73
+ ```tsx
74
+ import {
75
+ useDispatchAction,
76
+ ComponentRenderer,
77
+ type ButtonComponentProps,
78
+ } from '@easyops-cn/a2ui-react/0.8'
79
+
80
+ export function CustomButtonComponent({
81
+ surfaceId,
82
+ componentId,
83
+ child,
84
+ action,
85
+ }: ButtonComponentProps) {
86
+ const dispatchAction = useDispatchAction()
87
+
88
+ const handleClick = () => {
89
+ if (action) {
90
+ dispatchAction(surfaceId, componentId, action)
91
+ }
92
+ }
93
+
94
+ return (
95
+ <button onClick={handleClick}>
96
+ <ComponentRenderer surfaceId={surfaceId} componentId={child} />
97
+ </button>
98
+ )
99
+ }
100
+ ```
101
+
102
+ Custom switch component with data binding:
103
+
104
+ ```tsx
105
+ import { useDataBinding, useFormBinding } from '@easyops-cn/a2ui-react/0.8'
106
+
107
+ export function CustomSwitchComponent({
108
+ surfaceId,
109
+ componentId,
110
+ label,
111
+ value,
112
+ }: SwitchComponentProps) {
113
+ const labelText = useDataBinding<string>(surfaceId, label, '')
114
+ const [checked, setChecked] = useFormBinding<boolean>(surfaceId, value, false)
115
+
116
+ const handleChange = (newChecked: boolean) => {
117
+ setChecked(newChecked)
118
+ }
119
+
120
+ return (
121
+ <Switch checked={checked} onChange={handleChange}>
122
+ {labelText}
123
+ </Switch>
124
+ )
125
+ }
126
+ ```
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/styles/globals.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ },
20
+ "iconLibrary": "lucide"
21
+ }
@@ -0,0 +1,25 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import tseslint from 'typescript-eslint'
5
+ import eslintConfigPrettier from 'eslint-config-prettier'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist', 'node_modules', 'coverage'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ },
19
+ rules: {
20
+ ...reactHooks.configs.recommended.rules,
21
+ 'react-hooks/set-state-in-effect': 'off',
22
+ },
23
+ },
24
+ eslintConfigPrettier
25
+ )
package/netlify.toml ADDED
@@ -0,0 +1,50 @@
1
+ [[redirects]]
2
+ from = "/"
3
+ to = "/a2ui-react/"
4
+ status = 302
5
+ force = true
6
+
7
+ [[headers]]
8
+ for = "*.js" # js files should be set this way
9
+ [headers.values]
10
+ Cache-Control = "public, max-age=604800"
11
+
12
+ [[headers]]
13
+ for = "*.css" # css files too
14
+ [headers.values]
15
+ Cache-Control = "public, max-age=604800"
16
+
17
+ [[headers]]
18
+ for = "*.json"
19
+ [headers.values]
20
+ Cache-Control = "public, max-age=604800"
21
+
22
+ [[headers]]
23
+ for = "*.svg"
24
+ [headers.values]
25
+ Cache-Control = "public, max-age=604800"
26
+
27
+ [[headers]]
28
+ for = "*.png"
29
+ [headers.values]
30
+ Cache-Control = "public, max-age=604800"
31
+
32
+ [[headers]]
33
+ for = "*.jpg"
34
+ [headers.values]
35
+ Cache-Control = "public, max-age=604800"
36
+
37
+ [[headers]]
38
+ for = "*.gif"
39
+ [headers.values]
40
+ Cache-Control = "public, max-age=604800"
41
+
42
+ [[headers]]
43
+ for = "*.ttf"
44
+ [headers.values]
45
+ Cache-Control = "public, max-age=604800"
46
+
47
+ [[headers]]
48
+ for = "*.map"
49
+ [headers.values]
50
+ Cache-Control = "public, max-age=604800"
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@easyops-cn/a2ui-react",
3
+ "version": "0.0.0",
4
+ "description": "A2UI React Renderer Library",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./0.8": {
14
+ "types": "./dist/0.8/index.d.ts",
15
+ "default": "./dist/0.8/index.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "build": "tsc -b && vite build",
21
+ "preview": "vite preview",
22
+ "test": "vitest",
23
+ "test:run": "vitest run",
24
+ "test:coverage": "vitest run --coverage",
25
+ "lint": "eslint .",
26
+ "lint:fix": "eslint . --fix",
27
+ "format": "prettier --write .",
28
+ "format:check": "prettier --check .",
29
+ "prepare": "husky"
30
+ },
31
+ "license": "Apache-2.0",
32
+ "peerDependencies": {
33
+ "react": "^19.0.0",
34
+ "react-dom": "^19.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@eslint/js": "^9.39.2",
38
+ "@testing-library/dom": "^10.4.1",
39
+ "@testing-library/jest-dom": "^6.9.1",
40
+ "@testing-library/react": "^16.3.1",
41
+ "@testing-library/user-event": "^14.6.1",
42
+ "@types/node": "^25.0.5",
43
+ "@types/react": "^19.2.7",
44
+ "@types/react-dom": "^19.2.3",
45
+ "@vitejs/plugin-react": "^5.1.2",
46
+ "@vitest/coverage-v8": "^4.0.16",
47
+ "eslint": "^9.39.2",
48
+ "eslint-config-prettier": "^10.1.8",
49
+ "eslint-plugin-react-hooks": "^7.0.1",
50
+ "globals": "^17.0.0",
51
+ "husky": "^9.1.7",
52
+ "jsdom": "^27.4.0",
53
+ "lint-staged": "^16.2.7",
54
+ "prettier": "^3.7.4",
55
+ "react": "^19.2.3",
56
+ "react-dom": "^19.2.3",
57
+ "typescript": "~5.9.3",
58
+ "typescript-eslint": "^8.52.0",
59
+ "vite": "^7.3.1",
60
+ "vite-plugin-dts": "^4.5.4",
61
+ "vite-tsconfig-paths": "^6.0.4",
62
+ "vitest": "^4.0.16"
63
+ },
64
+ "lint-staged": {
65
+ "*.{js,jsx,ts,tsx}": [
66
+ "eslint --fix",
67
+ "prettier --write"
68
+ ],
69
+ "*.{json,md,css,scss}": [
70
+ "prettier --write"
71
+ ]
72
+ },
73
+ "dependencies": {
74
+ "@radix-ui/react-checkbox": "^1.3.3",
75
+ "@radix-ui/react-dialog": "^1.1.15",
76
+ "@radix-ui/react-label": "^2.1.8",
77
+ "@radix-ui/react-popover": "^1.1.15",
78
+ "@radix-ui/react-select": "^2.2.6",
79
+ "@radix-ui/react-separator": "^1.1.8",
80
+ "@radix-ui/react-slider": "^1.3.6",
81
+ "@radix-ui/react-slot": "^1.2.4",
82
+ "@radix-ui/react-tabs": "^1.1.13",
83
+ "class-variance-authority": "^0.7.1",
84
+ "clsx": "^2.1.1",
85
+ "date-fns": "^4.1.0",
86
+ "lucide-react": "^0.562.0",
87
+ "react-day-picker": "^9.13.0",
88
+ "tailwind-merge": "^3.4.0"
89
+ },
90
+ "workspaces": [
91
+ "website",
92
+ "playground"
93
+ ]
94
+ }
@@ -0,0 +1,75 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
13
+
14
+ Note: This will impact Vite dev & build performances.
15
+
16
+ ## Expanding the ESLint configuration
17
+
18
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
19
+
20
+ ```js
21
+ export default defineConfig([
22
+ globalIgnores(['dist']),
23
+ {
24
+ files: ['**/*.{ts,tsx}'],
25
+ extends: [
26
+ // Other configs...
27
+
28
+ // Remove tseslint.configs.recommended and replace with this
29
+ tseslint.configs.recommendedTypeChecked,
30
+ // Alternatively, use this for stricter rules
31
+ tseslint.configs.strictTypeChecked,
32
+ // Optionally, add this for stylistic rules
33
+ tseslint.configs.stylisticTypeChecked,
34
+
35
+ // Other configs...
36
+ ],
37
+ languageOptions: {
38
+ parserOptions: {
39
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
40
+ tsconfigRootDir: import.meta.dirname,
41
+ },
42
+ // other options...
43
+ },
44
+ },
45
+ ])
46
+ ```
47
+
48
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
49
+
50
+ ```js
51
+ // eslint.config.js
52
+ import reactX from 'eslint-plugin-react-x'
53
+ import reactDom from 'eslint-plugin-react-dom'
54
+
55
+ export default defineConfig([
56
+ globalIgnores(['dist']),
57
+ {
58
+ files: ['**/*.{ts,tsx}'],
59
+ extends: [
60
+ // Other configs...
61
+ // Enable lint rules for React
62
+ reactX.configs['recommended-typescript'],
63
+ // Enable lint rules for React DOM
64
+ reactDom.configs.recommended,
65
+ ],
66
+ languageOptions: {
67
+ parserOptions: {
68
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
69
+ tsconfigRootDir: import.meta.dirname,
70
+ },
71
+ // other options...
72
+ },
73
+ },
74
+ ])
75
+ ```
@@ -0,0 +1,22 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>A2UI React Renderer Playground</title>
8
+ <script>
9
+ // Initialize theme before page renders to prevent flash
10
+ (function() {
11
+ const stored = localStorage.getItem('theme');
12
+ if (stored === 'dark' || stored === 'light') {
13
+ document.documentElement.dataset.theme = stored;
14
+ }
15
+ })();
16
+ </script>
17
+ </head>
18
+ <body>
19
+ <div id="root"></div>
20
+ <script type="module" src="/src/main.tsx"></script>
21
+ </body>
22
+ </html>
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "playground",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@codemirror/lang-json": "^6.0.2",
13
+ "@easyops-cn/a2ui-react": "file:..",
14
+ "@tailwindcss/vite": "^4.1.18",
15
+ "@uiw/react-codemirror": "^4.25.4",
16
+ "lucide-react": "^0.562.0",
17
+ "react": "^19.2.0",
18
+ "react-dom": "^19.2.0",
19
+ "tailwindcss": "^4.1.18",
20
+ "tw-animate-css": "^1.4.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^24.10.6",
24
+ "@types/react": "^19.2.5",
25
+ "@types/react-dom": "^19.2.3",
26
+ "@vitejs/plugin-react": "^5.1.1",
27
+ "babel-plugin-react-compiler": "^1.0.0",
28
+ "globals": "^17.0.0",
29
+ "typescript": "~5.9.3",
30
+ "vite": "^7.2.4"
31
+ }
32
+ }
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
2
+ <!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
3
+ <!-- <rect x="0" y="0" width="512" height="512" fill="white" stroke="none"></rect> -->
4
+ <circle cx="256" cy="256" r="256" fill="white" stroke="none"></circle>
5
+ <g transform="translate(112 64) scale(0.75)">
6
+ <path d="M64 464c-8.8 0-16-7.2-16-16L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm56 256c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0z" fill="#009488" stroke="none" />
7
+ </g>
8
+ </svg>