@soybeanjs/ui 0.28.2 → 0.29.0-beta.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 (41) hide show
  1. package/README.md +143 -177
  2. package/README.zh-CN.md +144 -178
  3. package/dist/components/alert/alert.vue.d.ts +2 -2
  4. package/dist/components/autocomplete/autocomplete.vue.d.ts +2 -2
  5. package/dist/components/backtop/backtop.vue.d.ts +1 -1
  6. package/dist/components/button/button-icon.vue.d.ts +1 -1
  7. package/dist/components/button/button-link.vue.d.ts +1 -1
  8. package/dist/components/button/button-loading.vue.d.ts +2 -2
  9. package/dist/components/color-picker/color-picker.vue.d.ts +3 -3
  10. package/dist/components/combobox/combobox.vue.d.ts +2 -2
  11. package/dist/components/config-provider/config-provider.js +1 -1
  12. package/dist/components/context-menu/context-menu-checkbox.vue.d.ts +2 -2
  13. package/dist/components/context-menu/context-menu-radio.vue.d.ts +2 -2
  14. package/dist/components/date-picker/date-picker.js +1 -1
  15. package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
  16. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
  17. package/dist/components/dialog/dialog.vue.d.ts +3 -3
  18. package/dist/components/drawer/drawer.vue.d.ts +3 -3
  19. package/dist/components/dropdown-menu/dropdown-menu-checkbox.vue.d.ts +2 -2
  20. package/dist/components/dropdown-menu/dropdown-menu-radio.vue.d.ts +2 -2
  21. package/dist/components/link/link.vue.d.ts +1 -1
  22. package/dist/components/menubar/menubar.vue.d.ts +2 -2
  23. package/dist/components/navigation-menu/navigation-menu.vue.d.ts +2 -2
  24. package/dist/components/page-tabs/page-tabs.vue.d.ts +1 -1
  25. package/dist/components/popconfirm/popconfirm.vue.d.ts +3 -3
  26. package/dist/components/select/select.vue.d.ts +2 -2
  27. package/dist/styles/alert.d.ts +3 -3
  28. package/dist/styles/badge.d.ts +1 -1
  29. package/dist/styles/button.d.ts +2 -2
  30. package/dist/styles/checkbox.d.ts +1 -1
  31. package/dist/styles/navigation-menu.js +1 -1
  32. package/dist/styles/pagination.d.ts +1 -1
  33. package/dist/styles/radio-group.d.ts +1 -1
  34. package/dist/styles/skeleton.d.ts +1 -1
  35. package/dist/styles/switch.d.ts +2 -2
  36. package/dist/styles/table.d.ts +2 -2
  37. package/dist/styles/tabs.d.ts +1 -1
  38. package/dist/styles/tag.d.ts +2 -2
  39. package/dist/styles/toggle-group.d.ts +1 -1
  40. package/dist/styles/toggle.d.ts +2 -2
  41. package/package.json +17 -62
package/README.md CHANGED
@@ -1,10 +1,4 @@
1
- <p align="center">
2
- <a href="https://github.com/soybeanjs/soybean-ui">
3
- <img src="./public/logo.svg" alt="Logo" width="150" />
4
- </a>
5
- </p>
6
-
7
- # SoybeanUI
1
+ # @soybeanjs/ui
8
2
 
9
3
  English | [中文](./README.zh-CN.md)
10
4
 
@@ -13,60 +7,128 @@ English | [中文](./README.zh-CN.md)
13
7
  [![npm downloads](https://img.shields.io/npm/dt/@soybeanjs/ui)](https://www.npmjs.com/package/@soybeanjs/ui)
14
8
  [![github stars](https://img.shields.io/github/stars/soybeanjs/soybean-ui)](https://github.com/soybeanjs/soybean-ui)
15
9
 
16
- SoybeanUI is an elegant, modern, accessible and high-quality UI component library with shadcn-like design for Vue 3, built on top of a robust headless foundation. It provides a comprehensive set of accessible, customizable, and performant components.
10
+ An elegant, modern, accessible UI component library with shadcn-like design for Vue 3, built on top of `@soybeanjs/headless`.
17
11
 
18
- ## 📚 Architecture
12
+ ## 📖 Introduction
19
13
 
20
- SoybeanUI is built on a strict **two-layer separation** model:
14
+ `@soybeanjs/ui` provides ready-to-use styled components powered by UnoCSS and `@soybeanjs/cva` class-variance recipes. Each component is an `S`-prefixed wrapper around the corresponding `@soybeanjs/headless` primitive, following the **style injection** pattern: styled wrappers compute classes and inject them via `provide{Name}Ui`, which headless components read through `useUiContext()`.
21
15
 
16
+ ```ts
17
+ // Style injection — one-way data flow
18
+ const ui = computed(() => accordionVariants({ size: props.size }, props.ui, { root: props.class }));
19
+ provideAccordionUi(ui); // headless reads this via useAccordionUi()
22
20
  ```
23
- ┌─────────────────────────────────────────┐
24
- │ @soybeanjs/ui (src/) │
25
- │ S-prefixed components (SButton…) │
26
- │ UnoCSS classes · @soybeanjs/cva │
27
- │ provideXUi(ui) ──────────────────┐ │
28
- └────────────────────────────────────┼────┘
29
- │ style injection
30
- ┌────────────────────────────────────▼────┐
31
- │ @soybeanjs/headless (headless/) │
32
- │ Logic · State · A11y · Keyboard nav │
33
- │ useUiContext() reads injected classes │
34
- │ Zero styles — works with any CSS │
35
- └─────────────────────────────────────────┘
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ pnpm add @soybeanjs/ui
36
26
  ```
37
27
 
38
- ### Packages
28
+ ## 🚀 Usage
39
29
 
40
- | Package | Role | Components |
41
- | ----------------------- | --------------------------------------------------- | --------------------------------- |
42
- | **@soybeanjs/headless** | Logic, state, a11y. Zero styles. | 95 component dirs, 25 composables |
43
- | **@soybeanjs/ui** | Styled wrappers. UnoCSS + `@soybeanjs/cva` recipes. | 91 `S`-prefixed components |
30
+ ### 1. Import Styles
44
31
 
45
- **Data flow is strictly one-way**: `headless` `src`. The styled layer never imports from headless's internals — it injects style tokens via `provideXUi(computedUi)` which headless components read through `useUiContext()`.
32
+ Import the pre-built UnoCSS stylesheet in your main entry file (e.g., `main.ts`):
46
33
 
47
- Some multi-slot headless components also expose `Compact` aggregators, such as `AccordionCompact` and `TableCompact`. They keep item iteration and default content/icon composition inside headless, while the UI layer stays focused on styling and prop forwarding.
34
+ ```ts
35
+ import '@soybeanjs/ui/styles.css';
36
+ ```
48
37
 
49
- Current Compact-style coverage also includes flows such as card, date-field, dialog, editable, hover-card, layout, navigation-menu, pagination, popover, and stepper, when those structures are stable enough to live in headless.
38
+ ### 2. On-demand Import (Recommended)
50
39
 
51
- ### Style Injection
40
+ Use `unplugin-vue-components` with the built-in resolver for auto-importing:
52
41
 
53
- Every multi-slot headless component exposes a `provide{Name}Ui` function. The styled wrapper computes classes with `@soybeanjs/cva` recipes and injects them:
42
+ ```ts
43
+ // vite.config.ts
44
+ import Components from 'unplugin-vue-components/vite';
45
+ import UiResolver from '@soybeanjs/ui/resolver';
46
+
47
+ export default defineConfig({
48
+ plugins: [
49
+ Components({
50
+ resolvers: [UiResolver()]
51
+ })
52
+ ]
53
+ });
54
+ ```
55
+
56
+ ### 3. Nuxt Module
54
57
 
55
58
  ```ts
56
- // In the styled wrapper (src/)
57
- const ui = computed(() => accordionVariants({ size: props.size }, props.ui, { root: props.class }));
58
- provideAccordionUi(ui); // headless reads this via useAccordionUi()
59
+ // nuxt.config.ts
60
+ export default defineNuxtConfig({
61
+ modules: ['@soybeanjs/ui/nuxt']
62
+ });
59
63
  ```
60
64
 
61
- ### Theme System
65
+ ### 4. Direct Import
66
+
67
+ ```vue
68
+ <script setup>
69
+ import { SButton, SDialog } from '@soybeanjs/ui';
70
+ </script>
71
+
72
+ <template>
73
+ <SDialog>
74
+ <SButton>Open Dialog</SButton>
75
+ </SDialog>
76
+ </template>
77
+ ```
78
+
79
+ ## ✨ Features
80
+
81
+ - **shadcn-like design**: Modern, clean aesthetic inspired by shadcn/ui.
82
+ - **Accessible**: Built on `@soybeanjs/headless` primitives with full WAI-ARIA support.
83
+ - **RTL ready**: Switch between LTR and RTL layouts with `ConfigProvider`.
84
+ - **Customizable at every level**: Override individual slot classes via the `ui` prop, or swap the entire style layer.
85
+ - **Theme system**: 8 semantic colors and 6 sizes, controlled via `ConfigProvider`.
86
+ - **Lightweight & Tree-shakable**: Import only the components you use.
87
+ - **Type Safe**: Fully typed in strict TypeScript.
88
+ - **Nuxt ready**: First-class Nuxt module with auto-registration.
89
+ - **unplugin support**: Auto-import resolver for `unplugin-vue-components`.
90
+
91
+ ## 🎨 Theme System
92
+
93
+ ### Theme Colors
94
+
95
+ | Color | Token | Usage |
96
+ | --------------- | ------------- | --------------------------------- |
97
+ | **Primary** | `primary` | Primary actions, active states |
98
+ | **Destructive** | `destructive` | Delete, error, danger actions |
99
+ | **Success** | `success` | Confirm, positive status |
100
+ | **Warning** | `warning` | Caution, pending status |
101
+ | **Info** | `info` | Information, hints |
102
+ | **Carbon** | `carbon` | Neutral backgrounds, surfaces |
103
+ | **Secondary** | `secondary` | Secondary actions, muted elements |
104
+ | **Accent** | `accent` | Highlights, badges |
105
+
106
+ ### Theme Sizes
107
+
108
+ | Size | Base (rem) | Pixel equivalent |
109
+ | ----- | ---------- | ---------------- |
110
+ | `xs` | 0.75 | 12px |
111
+ | `sm` | 0.875 | 14px |
112
+ | `md` | 1 | 16px (default) |
113
+ | `lg` | 1.125 | 18px |
114
+ | `xl` | 1.25 | 20px |
115
+ | `2xl` | 1.5 | 24px |
116
+
117
+ ```vue
118
+ <script setup>
119
+ import { SConfigProvider, SButton } from '@soybeanjs/ui';
120
+ </script>
62
121
 
63
- - **`ThemeColor`** — 8 semantic colors: `primary` · `destructive` · `success` · `warning` · `info` · `carbon` · `secondary` · `accent`
64
- - **`ThemeSize`** 6 sizes: `xs` · `sm` · `md` · `lg` · `xl` · `2xl` (base 16px at `md`)
65
- - **`ConfigProvider`** — sets global `dir`, `locale`, `nonce`, and default `tooltip` config for the entire component tree, including RTL layout switching
122
+ <template>
123
+ <SConfigProvider :theme="{ color: 'primary', size: 'md' }">
124
+ <SButton>Click me</SButton>
125
+ </SConfigProvider>
126
+ </template>
127
+ ```
66
128
 
67
- ### Locale Support
129
+ ## 🌐 Locale Support
68
130
 
69
- `ConfigProvider` supports the following locale bundles:
131
+ `@soybeanjs/ui` inherits locale support from `@soybeanjs/headless` via `ConfigProvider`:
70
132
 
71
133
  | Code | Language |
72
134
  | ------- | ------------------- |
@@ -84,47 +146,28 @@ provideAccordionUi(ui); // headless reads this via useAccordionUi()
84
146
  | `tr` | Turkish |
85
147
  | `id` | Indonesian |
86
148
 
87
- Only `en` and `zh-CN` are pre-registered by default. `registerLocale` supports two registration styles:
88
-
89
- - Pass a `LocaleRegistry` object. Built-in locale files from `@soybeanjs/headless/locale/{code}` already export this shape, including `dir` metadata.
90
- - Pass a locale key plus `LocaleMessages` for a lightweight custom locale.
91
-
92
- The shorthand `registerLocale(key, messages)` form uses the key as the locale name and falls back to `ltr`. Use the object form when you need explicit metadata such as `rtl`.
93
-
94
- ```ts
95
- import { en, registerLocale } from '@soybeanjs/headless/locale';
96
- import type { LocaleMessages } from '@soybeanjs/headless/locale';
97
- import ar from '@soybeanjs/headless/locale/ar';
98
-
99
- registerLocale(ar);
100
-
101
- const customMessages: LocaleMessages = {
102
- ...en.messages,
103
- pagination: {
104
- ...en.messages.pagination,
105
- nextPage: 'Next →',
106
- prevPage: '← Prev'
107
- }
108
- };
109
-
110
- registerLocale('custom', customMessages);
149
+ ```vue
150
+ <template>
151
+ <SConfigProvider :locale="zhCN">
152
+ <App />
153
+ </SConfigProvider>
154
+ </template>
111
155
  ```
112
156
 
113
- ### Package Exports
114
-
115
- **@soybeanjs/headless** ships fine-grained sub-paths:
157
+ ## 📚 Package Structure
116
158
 
117
- ```ts
118
- import { AccordionRoot } from '@soybeanjs/headless'; // all components
119
- import { useControllableState } from '@soybeanjs/headless/composables'; // 25 composables
120
- import { transformPropsToContext } from '@soybeanjs/headless/shared'; // pure TS utils
121
- import { createMonth } from '@soybeanjs/headless/date'; // shared date helpers
122
- import * as Headless from '@soybeanjs/headless/namespaced'; // namespace object
123
- import type { AccordionUiSlot } from '@soybeanjs/headless/accordion'; // per-component
124
- import type { UiClass } from '@soybeanjs/headless/types'; // shared type surface
159
+ ```
160
+ packages/ui/src/
161
+ ├── components/ # 86 styled component dirs (SButton, SDialog, SSelect…)
162
+ ├── styles/ # UnoCSS style recipes and layer definitions
163
+ ├── theme/ # Theme tokens, color scales, and size mappings
164
+ ├── constants/ # Component and theme constants
165
+ ├── nuxt/ # Nuxt module entry
166
+ ├── resolver/ # unplugin-vue-components resolver
167
+ └── index.ts # Main barrel export
125
168
  ```
126
169
 
127
- **@soybeanjs/ui** exports:
170
+ ### Package Exports
128
171
 
129
172
  ```ts
130
173
  import { SButton, SAccordion } from '@soybeanjs/ui'; // all components
@@ -132,116 +175,39 @@ import '@soybeanjs/ui/styles.css'; // pre-built UnoCSS stylesheet
132
175
  // Also: @soybeanjs/ui/nuxt · @soybeanjs/ui/resolver
133
176
  ```
134
177
 
135
- ## 🛠 Development Workflow
136
-
137
- If you contribute new public components, exports, or API descriptions, keep generated surfaces in sync through the official scripts instead of editing generated files by hand.
138
-
139
- ```bash
140
- pnpm sui headless # sync headless component names and namespaced exports
141
- pnpm sui ui # sync ui component names
142
- pnpm sui api # regenerate docs api json and locale baseline data
143
- pnpm sui api-locales # refresh api locale template data only
144
- pnpm sui changelog # regenerate docs changelog json and locale baseline data
145
- pnpm sui api-translate -- --locale zh-CN
146
- pnpm sui changelog-translate -- --locale zh-CN
147
- ```
148
-
149
- The docs site now renders component docs through `UsageCode`, `PlaygroundGallery`, and `ComponentApi`. Component detail pages and `/releases` also read generated changelog data from `docs/src/generated/changelog/` and `docs/src/generated/changelog-locales/`.
150
-
151
- Public API or demo delivery changes should keep docs, playground examples, and generated API data aligned. Changelog mapping, release presentation, and changelog locale template changes should keep generated changelog data aligned as well.
152
-
153
- ## 📦 Installation
154
-
155
- ### Using the Styled UI Library (Recommended)
156
-
157
- If you want ready-to-use components with a modern design:
158
-
159
- ```bash
160
- pnpm add @soybeanjs/ui
161
- ```
162
-
163
- ### Using the Headless Library
164
-
165
- If you want to build your own design system from scratch:
166
-
167
- ```bash
168
- pnpm add @soybeanjs/headless
169
- ```
170
-
171
- ## 🚀 Usage
172
-
173
- ### @soybeanjs/ui
174
-
175
- 1. **Import Styles**
176
-
177
- Import the CSS file in your main entry file (e.g., `main.ts`):
178
-
179
- ```ts
180
- import '@soybeanjs/ui/styles.css';
181
- ```
178
+ ## 🧩 Components
182
179
 
183
- 2. **Global Registration (Optional)**
180
+ `@soybeanjs/ui` ships 86 `S`-prefixed styled components, each wrapping a `@soybeanjs/headless` primitive:
184
181
 
185
- You can register components globally or import them on demand.
182
+ | Category | Components |
183
+ | --------------- | ------------------------------------------------------------------- |
184
+ | **Layout** | `SAccordion`, `SCard`, `SDialog`, `SDrawer`, `SPopover`, `STooltip` |
185
+ | **Form** | `SButton`, `SCheckbox`, `SInput`, `SSelect`, `SSwitch`, `STextarea` |
186
+ | **Navigation** | `SBreadcrumb`, `SPagination`, `SStepper`, `STabs` |
187
+ | **Data** | `STable`, `SDataList`, `STree` |
188
+ | **Feedback** | `SAlert`, `SBadge`, `SToast`, `SProgress` |
189
+ | **Typography** | `SHeading`, `SText`, `SCode`, `SKbd` |
190
+ | **Date & Time** | `SCalendar`, `SDatePicker`, `STimePicker` |
191
+ | **Media** | `SAvatar`, `SCarousel`, `SImage` |
186
192
 
187
- 3. **On-demand Import (Recommended)**
193
+ ## 🔧 Customizing Components
188
194
 
189
- We recommend using `unplugin-vue-components` for auto-importing components.
190
-
191
- ```ts
192
- // vite.config.ts
193
- import Components from 'unplugin-vue-components/vite';
194
- import UiResolver from '@soybeanjs/ui/resolver';
195
-
196
- export default defineConfig({
197
- plugins: [
198
- Components({
199
- resolvers: [UiResolver()]
200
- })
201
- ]
202
- });
203
- ```
204
-
205
- 4. **Nuxt Module**
206
-
207
- ```ts
208
- // nuxt.config.ts
209
- export default defineNuxtConfig({
210
- modules: ['@soybeanjs/ui/nuxt']
211
- });
212
- ```
213
-
214
- ### @soybeanjs/headless
215
-
216
- The headless components provide the functionality without the styles.
217
-
218
- For data-driven multi-slot patterns, prefer the exported `Compact` variant when it exists. It is the headless entry point for opinionated composition, while the regular parts remain available for fully manual assembly.
195
+ Override individual slot classes via the `ui` prop:
219
196
 
220
197
  ```vue
221
- <script setup>
222
- import { AccordionRoot, AccordionItem, AccordionTrigger, AccordionContent } from '@soybeanjs/headless';
223
- </script>
224
-
225
198
  <template>
226
- <AccordionRoot>
227
- <AccordionItem value="item-1">
228
- <AccordionTrigger>Is it accessible?</AccordionTrigger>
229
- <AccordionContent>Yes. It adheres to the WAI-ARIA design pattern.</AccordionContent>
230
- </AccordionItem>
231
- </AccordionRoot>
199
+ <SAccordion :ui="{ trigger: 'bg-blue-100 hover:bg-blue-200 rounded-lg' }">
200
+ <SAccordionItem value="item-1">
201
+ <SAccordionTrigger>Custom styled trigger</SAccordionTrigger>
202
+ <SAccordionContent>Content here</SAccordionContent>
203
+ </SAccordionItem>
204
+ </SAccordion>
232
205
  </template>
233
206
  ```
234
207
 
235
- ## Features
208
+ ## 📖 Documentation
236
209
 
237
- - **Accessible**: Follows WAI-ARIA patterns for roles, focus management, and keyboard navigation.
238
- - **RTL ready**: Switch supported components between LTR and RTL layouts with `ConfigProvider`.
239
- - **Headless-first**: Logic and styles are fully separated — use `@soybeanjs/headless` alone to build any design system.
240
- - **Type Safe**: Written in strict TypeScript. All props, emits, slots, and context values are typed.
241
- - **Customizable at every level**: Override individual slot classes via the `ui` prop, or swap the entire style layer.
242
- - **Lightweight & Tree-shakable**: Import only the components you use. Each component is individually tree-shakable.
243
- - **Nuxt ready**: First-class Nuxt module with auto-registration (`@soybeanjs/ui/nuxt`).
244
- - **unplugin support**: Auto-import resolver for `unplugin-vue-components` (`@soybeanjs/ui/resolver`).
210
+ For full documentation, playground examples, and component API references, visit the [SoybeanUI docs site](https://soybeanjs.github.io/soybean-ui).
245
211
 
246
212
  ## 💝 Credits
247
213