@lucasvu/scope-ui 0.0.1 → 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.
- package/README.md +84 -15
- package/dist/index.cjs +497 -6
- package/dist/index.d.cts +107 -5
- package/dist/index.d.ts +107 -5
- package/dist/index.js +489 -7
- package/dist/styles.css +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @lucasvu/scope-ui
|
|
2
2
|
|
|
3
3
|
Bộ component phong cách **shadcn** dùng chung cho các app/micro-frontend trong workspace. Tất cả đều là React component thuần, kèm sẵn theme tối và hiệu ứng kính mờ.
|
|
4
4
|
|
|
@@ -27,26 +27,36 @@ npm login
|
|
|
27
27
|
npm publish
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
`publishConfig.access: public` đã được bật sẵn, nên với package dạng scope như `@
|
|
30
|
+
`publishConfig.access: public` đã được bật sẵn, nên với package dạng scope như `@lucasvu/scope-ui` không cần nhớ thêm `--access public`.
|
|
31
31
|
|
|
32
32
|
## Cách dùng nhanh
|
|
33
33
|
|
|
34
34
|
1) Cài package:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
npm install @
|
|
37
|
+
npm install @lucasvu/scope-ui
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
2) Import global style một lần ở entry (ví dụ `main.tsx`):
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import '@
|
|
43
|
+
import '@lucasvu/scope-ui/styles.css'
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
3) Dùng component:
|
|
47
47
|
|
|
48
48
|
```tsx
|
|
49
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
Button,
|
|
51
|
+
Card,
|
|
52
|
+
CardContent,
|
|
53
|
+
CardHeader,
|
|
54
|
+
CardTitle,
|
|
55
|
+
DataTable,
|
|
56
|
+
Field,
|
|
57
|
+
Input,
|
|
58
|
+
Select,
|
|
59
|
+
} from '@lucasvu/scope-ui'
|
|
50
60
|
|
|
51
61
|
export function Example() {
|
|
52
62
|
return (
|
|
@@ -55,10 +65,18 @@ export function Example() {
|
|
|
55
65
|
<CardTitle>Form đăng ký</CardTitle>
|
|
56
66
|
</CardHeader>
|
|
57
67
|
<CardContent className="ui-grid ui-grid--two">
|
|
58
|
-
<Field label="Email" required>
|
|
59
|
-
<Input type="email" placeholder="you@example.com" />
|
|
68
|
+
<Field label="Email" required htmlFor="email">
|
|
69
|
+
<Input id="email" type="email" placeholder="you@example.com" />
|
|
60
70
|
</Field>
|
|
61
|
-
<
|
|
71
|
+
<Select
|
|
72
|
+
label="Gói sử dụng"
|
|
73
|
+
placeholder="Chọn gói"
|
|
74
|
+
options={[
|
|
75
|
+
{ label: 'Starter', value: 'starter' },
|
|
76
|
+
{ label: 'Pro', value: 'pro' },
|
|
77
|
+
]}
|
|
78
|
+
/>
|
|
79
|
+
<Field label="Bảng giá theo gói" helperText="Ví dụ DataTable cơ bản">
|
|
62
80
|
<DataTable
|
|
63
81
|
data={[{ name: 'Starter', price: '$19' }]}
|
|
64
82
|
rowKey="name"
|
|
@@ -77,10 +95,10 @@ export function Example() {
|
|
|
77
95
|
|
|
78
96
|
## Thành phần có sẵn
|
|
79
97
|
|
|
80
|
-
- Nút: `Button` (variant `
|
|
98
|
+
- Nút: `Button` (variant `default | secondary | ghost | outline | destructive | link | confirm | create`, size `sm | md | lg | icon`, hỗ trợ `block`)
|
|
81
99
|
- Badge: `Badge` (solid, outline, success, warning)
|
|
82
100
|
- Thẻ: `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter`
|
|
83
|
-
- Form: `Field`, `Label`, `
|
|
101
|
+
- Form: `Form`, `Field`, `Item`, `Label`, `Control`, `Description`, `Message`, `Input`, `Textarea`, `Select`, `SearchableSelect`, `Combobox`, `AsyncCombobox`, `MultiSelect`
|
|
84
102
|
- Numeric: `NumericInput` (hỗ trợ integer/decimal, parse an toàn, format/clamp khi blur, dùng cho price/amount)
|
|
85
103
|
- Tabs: `Tabs` với mảng `items` `{ value, label, content, badge? }`
|
|
86
104
|
- Thông báo: `Alert` (tone info/success/warning/danger)
|
|
@@ -88,7 +106,58 @@ export function Example() {
|
|
|
88
106
|
- Bảng: `DataTable<T>` với `columns` và `render` tuỳ biến
|
|
89
107
|
- Tooltip: `Tooltip`, `OverflowTooltip`, `LineClampTooltip` (hiển thị tooltip khi bị cắt theo dòng)
|
|
90
108
|
- Lưới tiện dụng: class `ui-grid`, `ui-grid--two`, `ui-grid--three` để xếp block nhanh
|
|
91
|
-
- `
|
|
109
|
+
- `MainFe`: nhóm component dành cho main frontend cũ vẫn được export riêng để tương thích ngược
|
|
110
|
+
|
|
111
|
+
## Ghi chú DX
|
|
112
|
+
|
|
113
|
+
- `Input`, `Textarea`, `Select`, `SearchableSelect`, `Combobox` đã hỗ trợ trực tiếp `label`, `helperText`, `errorMessage`.
|
|
114
|
+
- `Field` phù hợp khi bạn cần bọc một control custom hoặc gom nhiều control dưới cùng một nhãn.
|
|
115
|
+
- Nếu bạn đổi tên package trước khi publish, thay `@lucasvu/scope-ui` trong các ví dụ bằng package name mới.
|
|
116
|
+
|
|
117
|
+
## Dùng cho AI/codegen
|
|
118
|
+
|
|
119
|
+
Nếu muốn AI render UI đúng và ổn định theo thư viện này, đừng chỉ đưa mỗi tên package. Hãy để agent bám vào một surface chuẩn:
|
|
120
|
+
|
|
121
|
+
- Import CSS global một lần: `@lucasvu/scope-ui/styles.css`
|
|
122
|
+
- Import file theme override của project ngay sau package CSS, ví dụ `./styles/ui-theme.css`
|
|
123
|
+
- Chỉ dùng các component canonical ở root package; tránh `MainFe` nếu không phải legacy screen
|
|
124
|
+
- Cho agent đọc `uiAiManifest` để biết component nào dùng cho intent nào, props quan trọng là gì, và khi nào không nên dùng
|
|
125
|
+
- Cho agent đọc `uiThemeContract` để biết màu/token phải override ở đâu
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { uiAiManifest, uiProjectAiRules, uiThemeContract } from '@lucasvu/scope-ui'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`uiAiManifest` mô tả luật chọn component theo intent như: text input, textarea, fixed select, searchable select, async combobox, multi select, data table, alert, card và field wrapper.
|
|
132
|
+
|
|
133
|
+
`uiThemeContract` mô tả token màu, surface, border, shadow, gradient và selector theme (`:root`, `.dark`, `[data-ui-theme='*']`) để AI không hardcode màu sai chỗ.
|
|
134
|
+
|
|
135
|
+
`AI_SETUP.md` chứa sẵn đoạn rule/prompt để copy vào settings của agent trong project.
|
|
136
|
+
|
|
137
|
+
## Theme Override
|
|
138
|
+
|
|
139
|
+
Nên để toàn bộ override theme của project vào một file riêng, ví dụ `src/styles/ui-theme.css`, rồi import file này sau `@lucasvu/scope-ui/styles.css`.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import '@lucasvu/scope-ui/styles.css'
|
|
143
|
+
import './styles/ui-theme.css'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Ví dụ:
|
|
147
|
+
|
|
148
|
+
```css
|
|
149
|
+
:root {
|
|
150
|
+
--tw-primary: 12 88% 56%;
|
|
151
|
+
--tw-accent: 24 95% 52%;
|
|
152
|
+
--primary-grad-from: 24 95% 52%;
|
|
153
|
+
--primary-grad-to: 12 88% 56%;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.dark {
|
|
157
|
+
--tw-primary: 18 100% 62%;
|
|
158
|
+
--tw-accent: 35 100% 58%;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
92
161
|
|
|
93
162
|
## NumericInput
|
|
94
163
|
|
|
@@ -132,7 +201,7 @@ type NumericInputProps = {
|
|
|
132
201
|
### Ví dụ dùng
|
|
133
202
|
|
|
134
203
|
```tsx
|
|
135
|
-
import { NumericInput } from '@
|
|
204
|
+
import { NumericInput } from '@lucasvu/scope-ui';
|
|
136
205
|
|
|
137
206
|
// 1) Integer qty
|
|
138
207
|
<NumericInput
|
|
@@ -168,7 +237,7 @@ import { NumericInput } from '@base/ui';
|
|
|
168
237
|
## DataTable
|
|
169
238
|
|
|
170
239
|
```tsx
|
|
171
|
-
import type { DataTableColumn, DataTableSortState } from '@
|
|
240
|
+
import type { DataTableColumn, DataTableSortState } from '@lucasvu/scope-ui'
|
|
172
241
|
```
|
|
173
242
|
|
|
174
243
|
### Tối thiểu
|
|
@@ -371,7 +440,7 @@ DataTable tự hỗ trợ scroll ngang khi nội dung vượt chiều rộng (đ
|
|
|
371
440
|
Dùng khi cần hiển thị tối đa N dòng, nếu text bị cắt sẽ hiện tooltip đầy đủ khi hover.
|
|
372
441
|
|
|
373
442
|
```tsx
|
|
374
|
-
import { LineClampTooltip } from '@
|
|
443
|
+
import { LineClampTooltip } from '@lucasvu/scope-ui'
|
|
375
444
|
|
|
376
445
|
<LineClampTooltip
|
|
377
446
|
text={record.apiEndpoint}
|
|
@@ -390,5 +459,5 @@ import { LineClampTooltip } from '@base/ui'
|
|
|
390
459
|
|
|
391
460
|
## Gợi ý tích hợp
|
|
392
461
|
|
|
393
|
-
- Import `@
|
|
462
|
+
- Import `@lucasvu/scope-ui/styles.css` ở host để các remote có thể tái sử dụng cùng theme.
|
|
394
463
|
- Nếu muốn kết hợp với Tailwind/shadcn gốc, giữ nguyên class `ui-*` và thêm `content` trỏ tới `packages/ui/src/**/*` trong `tailwind.config`.
|