@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.
- package/README.md +143 -177
- package/README.zh-CN.md +144 -178
- package/dist/components/alert/alert.vue.d.ts +2 -2
- package/dist/components/autocomplete/autocomplete.vue.d.ts +2 -2
- package/dist/components/backtop/backtop.vue.d.ts +1 -1
- package/dist/components/button/button-icon.vue.d.ts +1 -1
- package/dist/components/button/button-link.vue.d.ts +1 -1
- package/dist/components/button/button-loading.vue.d.ts +2 -2
- package/dist/components/color-picker/color-picker.vue.d.ts +3 -3
- package/dist/components/combobox/combobox.vue.d.ts +2 -2
- package/dist/components/config-provider/config-provider.js +1 -1
- package/dist/components/context-menu/context-menu-checkbox.vue.d.ts +2 -2
- package/dist/components/context-menu/context-menu-radio.vue.d.ts +2 -2
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/dialog/dialog.vue.d.ts +3 -3
- package/dist/components/drawer/drawer.vue.d.ts +3 -3
- package/dist/components/dropdown-menu/dropdown-menu-checkbox.vue.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-radio.vue.d.ts +2 -2
- package/dist/components/link/link.vue.d.ts +1 -1
- package/dist/components/menubar/menubar.vue.d.ts +2 -2
- package/dist/components/navigation-menu/navigation-menu.vue.d.ts +2 -2
- package/dist/components/page-tabs/page-tabs.vue.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.vue.d.ts +3 -3
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/styles/alert.d.ts +3 -3
- package/dist/styles/badge.d.ts +1 -1
- package/dist/styles/button.d.ts +2 -2
- package/dist/styles/checkbox.d.ts +1 -1
- package/dist/styles/navigation-menu.js +1 -1
- package/dist/styles/pagination.d.ts +1 -1
- package/dist/styles/radio-group.d.ts +1 -1
- package/dist/styles/skeleton.d.ts +1 -1
- package/dist/styles/switch.d.ts +2 -2
- package/dist/styles/table.d.ts +2 -2
- package/dist/styles/tabs.d.ts +1 -1
- package/dist/styles/tag.d.ts +2 -2
- package/dist/styles/toggle-group.d.ts +1 -1
- package/dist/styles/toggle.d.ts +2 -2
- package/package.json +17 -62
package/README.md
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
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
|
[](https://www.npmjs.com/package/@soybeanjs/ui)
|
|
14
8
|
[](https://github.com/soybeanjs/soybean-ui)
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
An elegant, modern, accessible UI component library with shadcn-like design for Vue 3, built on top of `@soybeanjs/headless`.
|
|
17
11
|
|
|
18
|
-
##
|
|
12
|
+
## 📖 Introduction
|
|
19
13
|
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
28
|
+
## 🚀 Usage
|
|
39
29
|
|
|
40
|
-
|
|
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
|
-
|
|
32
|
+
Import the pre-built UnoCSS stylesheet in your main entry file (e.g., `main.ts`):
|
|
46
33
|
|
|
47
|
-
|
|
34
|
+
```ts
|
|
35
|
+
import '@soybeanjs/ui/styles.css';
|
|
36
|
+
```
|
|
48
37
|
|
|
49
|
-
|
|
38
|
+
### 2. On-demand Import (Recommended)
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
Use `unplugin-vue-components` with the built-in resolver for auto-importing:
|
|
52
41
|
|
|
53
|
-
|
|
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
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
// nuxt.config.ts
|
|
60
|
+
export default defineNuxtConfig({
|
|
61
|
+
modules: ['@soybeanjs/ui/nuxt']
|
|
62
|
+
});
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
###
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
122
|
+
<template>
|
|
123
|
+
<SConfigProvider :theme="{ color: 'primary', size: 'md' }">
|
|
124
|
+
<SButton>Click me</SButton>
|
|
125
|
+
</SConfigProvider>
|
|
126
|
+
</template>
|
|
127
|
+
```
|
|
66
128
|
|
|
67
|
-
|
|
129
|
+
## 🌐 Locale Support
|
|
68
130
|
|
|
69
|
-
`
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
**@soybeanjs/headless** ships fine-grained sub-paths:
|
|
157
|
+
## 📚 Package Structure
|
|
116
158
|
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
180
|
+
`@soybeanjs/ui` ships 86 `S`-prefixed styled components, each wrapping a `@soybeanjs/headless` primitive:
|
|
184
181
|
|
|
185
|
-
|
|
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
|
-
|
|
193
|
+
## 🔧 Customizing Components
|
|
188
194
|
|
|
189
|
-
|
|
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
|
-
<
|
|
227
|
-
<
|
|
228
|
-
<
|
|
229
|
-
<
|
|
230
|
-
</
|
|
231
|
-
</
|
|
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
|
-
##
|
|
208
|
+
## 📖 Documentation
|
|
236
209
|
|
|
237
|
-
|
|
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
|
|