@zhama/a2ui 0.10.4 → 0.11.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 (49) hide show
  1. package/README.md +179 -70
  2. package/dist/{a2ui-CnaCcq4c.d.ts → a2ui-CZYqbeoz.d.ts} +2 -1
  3. package/dist/{a2ui-vyxwZCoa.d.cts → a2ui-Dpl-E-Do.d.cts} +2 -1
  4. package/dist/context/index.cjs +702 -1
  5. package/dist/context/index.d.cts +35 -2
  6. package/dist/context/index.d.ts +35 -2
  7. package/dist/context/index.js +702 -1
  8. package/dist/data/index.cjs +2 -2
  9. package/dist/data/index.d.cts +3 -2
  10. package/dist/data/index.d.ts +3 -2
  11. package/dist/data/index.js +2 -2
  12. package/dist/events/index.d.cts +3 -2
  13. package/dist/events/index.d.ts +3 -2
  14. package/dist/index-BvhdLkQ7.d.ts +111 -0
  15. package/dist/{index-DCv59E9u.d.cts → index-CWQNUF1X.d.ts} +65 -20
  16. package/dist/index-Ccel8ysN.d.cts +111 -0
  17. package/dist/index-CfG_a073.d.cts +143 -0
  18. package/dist/{index-CEWReOmS.d.ts → index-DF2gGMk6.d.ts} +1 -1
  19. package/dist/index-DZnukf8z.d.ts +143 -0
  20. package/dist/{index-CfuPxsd1.d.cts → index-DfVLIScc.d.cts} +1 -1
  21. package/dist/{index-DKh6MRhF.d.cts → index-K0C1W74m.d.ts} +26 -15
  22. package/dist/{index-BJe-XUR4.d.ts → index-PGBpNFSS.d.cts} +26 -15
  23. package/dist/{index-BWAU7Xp2.d.ts → index-nNr2JOQb.d.cts} +65 -20
  24. package/dist/index.cjs +702 -2
  25. package/dist/index.d.cts +71 -8
  26. package/dist/index.d.ts +71 -8
  27. package/dist/index.js +702 -2
  28. package/dist/styles/index.cjs +702 -1
  29. package/dist/styles/index.d.cts +3 -2
  30. package/dist/styles/index.d.ts +3 -2
  31. package/dist/styles/index.js +702 -1
  32. package/dist/types/index.cjs +1 -1
  33. package/dist/types/index.d.cts +2 -2
  34. package/dist/types/index.d.ts +2 -2
  35. package/dist/types/index.js +1 -0
  36. package/dist/{types-CtrG7MJe.d.cts → types-Csi2jaoN.d.cts} +122 -178
  37. package/dist/{types-CtrG7MJe.d.ts → types-Csi2jaoN.d.ts} +122 -178
  38. package/dist/ui/index.cjs +2 -2
  39. package/dist/ui/index.d.cts +4 -3
  40. package/dist/ui/index.d.ts +4 -3
  41. package/dist/ui/index.js +2 -2
  42. package/package.json +3 -19
  43. package/dist/index-Bgqafemj.d.ts +0 -106
  44. package/dist/index-BltkjFKi.d.ts +0 -67
  45. package/dist/index-Bzqwwd1k.d.cts +0 -106
  46. package/dist/index-CLn74O53.d.cts +0 -67
  47. package/dist/styles/a2ui-variables.css +0 -106
  48. package/dist/styles/a2ui.css +0 -143
  49. package/tailwind.preset.js +0 -326
package/README.md CHANGED
@@ -74,7 +74,9 @@ Then open http://localhost:5174 and try these commands:
74
74
 
75
75
  - 🤖 **AI-First Design** - Built specifically for AI-driven UI generation
76
76
  - 📦 **Complete Protocol Support** - Full implementation of A2UI protocol specifications
77
- - 🎨 **Themeable** - Customizable theme system based on Tailwind CSS
77
+ - 🎨 **Standalone Style System** - No Tailwind dependency, built-in CSS utility classes with `a2-` prefix
78
+ - 🔒 **Style Isolation** - Avoid conflicts with host applications
79
+ - 🌓 **Auto Dark Mode** - Uses CSS `light-dark()` function
78
80
  - 🧩 **Rich Components** - Comprehensive set of UI components (Text, Button, Card, List, TextField, etc.)
79
81
  - 🔌 **Extensible** - Support for custom component registration
80
82
  - 📱 **Responsive** - Mobile-first responsive design
@@ -103,34 +105,27 @@ npm install react react-dom react-markdown
103
105
 
104
106
  #### Basic Setup
105
107
 
106
- 1. **Configure Tailwind CSS**
108
+ 1. **Wrap with StyleProvider and ThemeProvider**
107
109
 
108
- ```js
109
- // tailwind.config.js
110
- import a2uiPreset from '@zhama/a2ui/tailwind.preset';
110
+ ```tsx
111
+ import { StyleProvider, ThemeProvider, A2UIRoot } from '@zhama/a2ui';
111
112
 
112
- export default {
113
- presets: [a2uiPreset],
114
- content: [
115
- './src/**/*.{js,ts,jsx,tsx}',
116
- './node_modules/@zhama/a2ui/**/*.{js,ts,jsx,tsx}',
117
- ],
118
- };
113
+ function App() {
114
+ return (
115
+ <StyleProvider>
116
+ <ThemeProvider>
117
+ <div className="a2ui-root">
118
+ {/* Your A2UI components */}
119
+ </div>
120
+ </ThemeProvider>
121
+ </StyleProvider>
122
+ );
123
+ }
119
124
  ```
120
125
 
121
- 2. **Import CSS Variables**
122
-
123
- ```css
124
- /* globals.css */
125
- @import '@zhama/a2ui/styles/a2ui-variables.css';
126
- @import '@zhama/a2ui/styles/a2ui.css';
127
-
128
- @tailwind base;
129
- @tailwind components;
130
- @tailwind utilities;
131
- ```
126
+ > 💡 **Note:** `StyleProvider` automatically injects A2UI's CSS utility classes. The `a2ui-root` class applies base styles and CSS variables.
132
127
 
133
- 3. **Use A2UIRoot Component**
128
+ 2. **Use A2UIRoot Component**
134
129
 
135
130
  ```tsx
136
131
  import { A2UIRoot } from '@zhama/a2ui';
@@ -212,26 +207,86 @@ import { A2UIProvider, useA2UI } from '@zhama/a2ui/context';
212
207
  A2UI comes with a customizable theme system:
213
208
 
214
209
  ```tsx
215
- import { A2UIProvider } from '@zhama/a2ui/context';
216
- import { defaultTheme } from '@zhama/a2ui/styles/default-theme';
210
+ import { ThemeProvider, createTheme } from '@zhama/a2ui';
217
211
 
218
- const customTheme = {
219
- ...defaultTheme,
212
+ const customTheme = createTheme({
220
213
  components: {
221
- ...defaultTheme.components,
222
- Button: 'custom-button-class',
214
+ Button: {
215
+ 'a2-bgc-p40': true, // Custom button background
216
+ 'a2-br-4': true, // Larger border radius
217
+ },
218
+ Card: {
219
+ 'a2-shadow-lg': true, // Larger shadow
220
+ },
223
221
  },
224
- };
222
+ });
225
223
 
226
224
  function App() {
227
225
  return (
228
- <A2UIProvider theme={customTheme}>
226
+ <ThemeProvider theme={customTheme}>
229
227
  <YourApp />
230
- </A2UIProvider>
228
+ </ThemeProvider>
231
229
  );
232
230
  }
233
231
  ```
234
232
 
233
+ ### 🎨 Style System
234
+
235
+ A2UI uses a standalone CSS utility class system that doesn't depend on Tailwind CSS.
236
+
237
+ #### Class Naming Convention
238
+
239
+ All style classes use the `a2-` prefix:
240
+
241
+ | Category | Prefix | Examples |
242
+ |----------|--------|----------|
243
+ | Layout | `a2-p-*`, `a2-m-*`, `a2-gap-*` | `a2-p-4`, `a2-mx-2`, `a2-gap-2` |
244
+ | Display | `a2-dsp-*` | `a2-dsp-flex`, `a2-dsp-grid` |
245
+ | Flex | `a2-flex-*`, `a2-al-*`, `a2-jc-*` | `a2-flex-1`, `a2-al-center` |
246
+ | Colors | `a2-c-*`, `a2-bgc-*`, `a2-bc-*` | `a2-c-p50`, `a2-bgc-n0` |
247
+ | Typography | `a2-font-*`, `a2-fw-*`, `a2-text-*` | `a2-font-sans`, `a2-fw-500` |
248
+ | Border | `a2-br-*`, `a2-bw-*`, `a2-bs-*` | `a2-br-4`, `a2-bw-1` |
249
+ | Behavior | `a2-opacity-*`, `a2-shadow-*` | `a2-opacity-80`, `a2-shadow-md` |
250
+
251
+ #### Color System
252
+
253
+ Uses OKLCH color space with 6 palettes:
254
+
255
+ | Prefix | Description |
256
+ |--------|-------------|
257
+ | `p` | Primary - Main color |
258
+ | `s` | Secondary - Secondary color |
259
+ | `t` | Tertiary - Third color |
260
+ | `n` | Neutral - Gray tones |
261
+ | `nv` | Neutral Variant - Neutral variant |
262
+ | `e` | Error - Error color |
263
+
264
+ Color scale: 0 (lightest) ~ 100 (darkest)
265
+
266
+ ```css
267
+ /* Examples */
268
+ .a2-c-p50 { /* Primary 50% */ }
269
+ .a2-bgc-n0 { /* White background */ }
270
+ .a2-bc-e40 { /* Error color border */ }
271
+ ```
272
+
273
+ #### Manual Style Injection
274
+
275
+ For SSR or special scenarios:
276
+
277
+ ```tsx
278
+ import { getStylesCSS } from '@zhama/a2ui';
279
+
280
+ // Get complete CSS string
281
+ const css = getStylesCSS();
282
+
283
+ // Inject into head
284
+ const style = document.createElement('style');
285
+ style.textContent = css;
286
+ document.head.appendChild(style);
287
+ ```
288
+
289
+
235
290
  ### 🧩 Available Components
236
291
 
237
292
  | Component | Description | Use Case |
@@ -391,7 +446,6 @@ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) fi
391
446
 
392
447
  - Inspired by [Google's A2UI Protocol](https://developers.google.com/assistant/conversational/a2ui)
393
448
  - Built with [React](https://reactjs.org/) and [TypeScript](https://www.typescriptlang.org/)
394
- - Styled with [Tailwind CSS](https://tailwindcss.com/)
395
449
 
396
450
  ### 📞 Support
397
451
 
@@ -437,7 +491,7 @@ Any LLM that can output structured JSON works. We've tested with:
437
491
  <details>
438
492
  <summary><b>Can I customize the styling?</b></summary>
439
493
 
440
- Yes! A2UI uses Tailwind CSS and provides a theme system. You can override default styles through the A2UIProvider theme prop or by modifying Tailwind classes.
494
+ Yes! A2UI uses a standalone CSS utility class system with the `a2-` prefix. You can override default styles through the ThemeProvider theme prop or by overriding CSS variables.
441
495
 
442
496
  </details>
443
497
 
@@ -507,7 +561,9 @@ npm run dev
507
561
 
508
562
  - 🤖 **AI 优先设计** - 专为 AI 驱动的 UI 生成而构建
509
563
  - 📦 **完整协议支持** - 完整实现 A2UI 协议规范
510
- - 🎨 **主题化** - 基于 Tailwind CSS 的可定制主题系统
564
+ - 🎨 **独立样式系统** - 不依赖 Tailwind,自带完整的 `a2-` 前缀 CSS 工具类
565
+ - 🔒 **样式隔离** - 使用 `a2-` 前缀避免与宿主应用冲突
566
+ - 🌓 **自动暗色模式** - 使用 CSS `light-dark()` 函数
511
567
  - 🧩 **丰富组件** - 全面的 UI 组件集(Text、Button、Card、List、TextField 等)
512
568
  - 🔌 **可扩展** - 支持自定义组件注册
513
569
  - 📱 **响应式** - 移动优先的响应式设计
@@ -536,34 +592,27 @@ npm install react react-dom react-markdown
536
592
 
537
593
  #### 基础设置
538
594
 
539
- 1. **配置 Tailwind CSS**
595
+ 1. **使用 StyleProvider 和 ThemeProvider 包裹应用**
540
596
 
541
- ```js
542
- // tailwind.config.js
543
- import a2uiPreset from '@zhama/a2ui/tailwind.preset';
597
+ ```tsx
598
+ import { StyleProvider, ThemeProvider, A2UIRoot } from '@zhama/a2ui';
544
599
 
545
- export default {
546
- presets: [a2uiPreset],
547
- content: [
548
- './src/**/*.{js,ts,jsx,tsx}',
549
- './node_modules/@zhama/a2ui/**/*.{js,ts,jsx,tsx}',
550
- ],
551
- };
600
+ function App() {
601
+ return (
602
+ <StyleProvider>
603
+ <ThemeProvider>
604
+ <div className="a2ui-root">
605
+ {/* 你的 A2UI 组件 */}
606
+ </div>
607
+ </ThemeProvider>
608
+ </StyleProvider>
609
+ );
610
+ }
552
611
  ```
553
612
 
554
- 2. **导入 CSS 变量**
555
-
556
- ```css
557
- /* globals.css */
558
- @import '@zhama/a2ui/styles/a2ui-variables.css';
559
- @import '@zhama/a2ui/styles/a2ui.css';
560
-
561
- @tailwind base;
562
- @tailwind components;
563
- @tailwind utilities;
564
- ```
613
+ > 💡 **注意:** `StyleProvider` 会自动注入 A2UI 的 CSS 工具类。`a2ui-root` 类会应用基础样式和 CSS 变量。
565
614
 
566
- 3. **使用 A2UIRoot 组件**
615
+ 2. **使用 A2UIRoot 组件**
567
616
 
568
617
  ```tsx
569
618
  import { A2UIRoot } from '@zhama/a2ui';
@@ -645,26 +694,86 @@ import { A2UIProvider, useA2UI } from '@zhama/a2ui/context';
645
694
  A2UI 自带可定制的主题系统:
646
695
 
647
696
  ```tsx
648
- import { A2UIProvider } from '@zhama/a2ui/context';
649
- import { defaultTheme } from '@zhama/a2ui/styles/default-theme';
697
+ import { ThemeProvider, createTheme } from '@zhama/a2ui';
650
698
 
651
- const customTheme = {
652
- ...defaultTheme,
699
+ const customTheme = createTheme({
653
700
  components: {
654
- ...defaultTheme.components,
655
- Button: 'custom-button-class',
701
+ Button: {
702
+ 'a2-bgc-p40': true, // 自定义按钮背景
703
+ 'a2-br-4': true, // 更大圆角
704
+ },
705
+ Card: {
706
+ 'a2-shadow-lg': true, // 更大阴影
707
+ },
656
708
  },
657
- };
709
+ });
658
710
 
659
711
  function App() {
660
712
  return (
661
- <A2UIProvider theme={customTheme}>
713
+ <ThemeProvider theme={customTheme}>
662
714
  <YourApp />
663
- </A2UIProvider>
715
+ </ThemeProvider>
664
716
  );
665
717
  }
666
718
  ```
667
719
 
720
+ ### 🎨 样式系统
721
+
722
+ A2UI 使用独立的 CSS 工具类系统,不依赖 Tailwind CSS。
723
+
724
+ #### 类名规范
725
+
726
+ 所有样式类使用 `a2-` 前缀:
727
+
728
+ | 类别 | 前缀 | 示例 |
729
+ |------|------|------|
730
+ | Layout | `a2-p-*`, `a2-m-*`, `a2-gap-*` | `a2-p-4`, `a2-mx-2`, `a2-gap-2` |
731
+ | Display | `a2-dsp-*` | `a2-dsp-flex`, `a2-dsp-grid` |
732
+ | Flex | `a2-flex-*`, `a2-al-*`, `a2-jc-*` | `a2-flex-1`, `a2-al-center` |
733
+ | Colors | `a2-c-*`, `a2-bgc-*`, `a2-bc-*` | `a2-c-p50`, `a2-bgc-n0` |
734
+ | Typography | `a2-font-*`, `a2-fw-*`, `a2-text-*` | `a2-font-sans`, `a2-fw-500` |
735
+ | Border | `a2-br-*`, `a2-bw-*`, `a2-bs-*` | `a2-br-4`, `a2-bw-1` |
736
+ | Behavior | `a2-opacity-*`, `a2-shadow-*` | `a2-opacity-80`, `a2-shadow-md` |
737
+
738
+ #### 颜色系统
739
+
740
+ 使用 OKLCH 色彩空间,支持 6 个调色板:
741
+
742
+ | 前缀 | 说明 |
743
+ |------|------|
744
+ | `p` | Primary - 主色调 |
745
+ | `s` | Secondary - 次要色 |
746
+ | `t` | Tertiary - 第三色 |
747
+ | `n` | Neutral - 中性灰色 |
748
+ | `nv` | Neutral Variant - 中性变体 |
749
+ | `e` | Error - 错误色 |
750
+
751
+ 色阶:0 (最亮) ~ 100 (最暗)
752
+
753
+ ```css
754
+ /* 示例 */
755
+ .a2-c-p50 { /* 主色 50% */ }
756
+ .a2-bgc-n0 { /* 白色背景 */ }
757
+ .a2-bc-e40 { /* 错误色边框 */ }
758
+ ```
759
+
760
+ #### 手动注入样式
761
+
762
+ 对于 SSR 或特殊场景:
763
+
764
+ ```tsx
765
+ import { getStylesCSS } from '@zhama/a2ui';
766
+
767
+ // 获取完整 CSS 字符串
768
+ const css = getStylesCSS();
769
+
770
+ // 注入到 head
771
+ const style = document.createElement('style');
772
+ style.textContent = css;
773
+ document.head.appendChild(style);
774
+ ```
775
+
776
+
668
777
  ### 🧩 可用组件
669
778
 
670
779
  | 组件 | 描述 | 使用场景 |
@@ -824,7 +933,6 @@ zhama/a2ui/
824
933
 
825
934
  - 受 [Google 的 A2UI 协议](https://developers.google.com/assistant/conversational/a2ui)启发
826
935
  - 使用 [React](https://reactjs.org/) 和 [TypeScript](https://www.typescriptlang.org/) 构建
827
- - 使用 [Tailwind CSS](https://tailwindcss.com/) 样式化
828
936
 
829
937
  ### 📞 支持
830
938
 
@@ -869,7 +977,7 @@ A2UI 是协议优先,专为 AI 生成设计。shadcn/ui 是开发者优先,
869
977
  <details>
870
978
  <summary><b>可以自定义样式吗?</b></summary>
871
979
 
872
- 可以!A2UI 使用 Tailwind CSS 并提供主题系统。你可以通过 A2UIProvider 的 theme 属性覆盖默认样式,或修改 Tailwind 类。
980
+ 可以!A2UI 使用独立的 `a2-` 前缀 CSS 工具类系统。你可以通过 ThemeProvider 的 theme 属性覆盖默认样式,或覆盖 CSS 变量。
873
981
 
874
982
  </details>
875
983
 
@@ -889,3 +997,4 @@ Made with ❤️ by [Zhama AI](https://zhama.com)
889
997
  **如果你觉得有帮助,请给个 Star ⭐!**
890
998
 
891
999
  </div>
1000
+
@@ -1,4 +1,5 @@
1
- import { A as Action, E as AnyComponentNode } from './types-CtrG7MJe.js';
1
+ import { Action } from '@zhama/a2ui-core';
2
+ import { A as AnyComponentNode } from './types-Csi2jaoN.js';
2
3
 
3
4
  /**
4
5
  * A2UI Base Event Types
@@ -1,4 +1,5 @@
1
- import { A as Action, E as AnyComponentNode } from './types-CtrG7MJe.cjs';
1
+ import { Action } from '@zhama/a2ui-core';
2
+ import { A as AnyComponentNode } from './types-Csi2jaoN.cjs';
2
3
 
3
4
  /**
4
5
  * A2UI Base Event Types