@lucasvu/scope-ui 0.0.3 → 0.0.4

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/AI_SETUP.md CHANGED
@@ -8,6 +8,8 @@ Nếu project consumer đã cài package, cách nhanh nhất là chạy:
8
8
  npx scope-ui-init
9
9
  ```
10
10
 
11
+ Nếu chưa cài `@lucasvu/scope-ui`, lệnh trên sẽ báo `E404` vì npm sẽ cố tải package tên `scope-ui-init`.
12
+
11
13
  CLI này sẽ tạo `AGENTS.md` và `src/styles/ui-theme.css` theo đúng convention bên dưới.
12
14
 
13
15
  ## 1. Import style đúng thứ tự
package/README.md CHANGED
@@ -2,56 +2,31 @@
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
 
5
- ## Publish lên npm
6
-
7
- Nếu muốn publish public để người khác chỉ cần cài và import:
8
-
9
- 1. Đổi `name` trong `package.json` sang package name hoặc scope bạn thực sự sở hữu trên npm.
10
- 2. Chạy `npm install` để cài thêm tool build mới nếu máy chưa có lockfile/deps tương ứng.
11
- 3. Build package:
12
-
13
- ```bash
14
- npm run build
15
- ```
16
-
17
- 4. Kiểm tra package trước khi publish:
18
-
19
- ```bash
20
- npm pack --dry-run
21
- ```
22
-
23
- 5. Đăng nhập npm và publish:
24
-
25
- ```bash
26
- npm login
27
- npm publish
28
- ```
29
-
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
-
32
5
  ## Cách dùng nhanh
33
6
 
34
- 1) Cài package:
7
+ 1. Cài package:
35
8
 
36
9
  ```bash
37
10
  npm install @lucasvu/scope-ui
38
11
  ```
39
12
 
40
- 2) Import global style một lần ở entry (ví dụ `main.tsx`):
13
+ 2. Import global style một lần ở entry (ví dụ `main.tsx`):
41
14
 
42
15
  ```ts
43
- import '@lucasvu/scope-ui/styles.css'
16
+ import '@lucasvu/scope-ui/styles.css';
44
17
  ```
45
18
 
46
- 3) Nếu muốn bootstrap rule/theme cho AI trong project consumer:
19
+ 3. Nếu muốn bootstrap rule/theme cho AI trong project consumer:
47
20
 
48
21
  ```bash
49
22
  npx scope-ui-init
50
23
  ```
51
24
 
25
+ Lưu ý: lệnh này chỉ chạy được sau khi project đã cài `@lucasvu/scope-ui`. Nếu chưa cài package, `npx` sẽ đi tìm một package riêng tên `scope-ui-init` trên npm và báo `E404`.
26
+
52
27
  Lệnh này sẽ tạo `AGENTS.md` và `src/styles/ui-theme.css` trong repo hiện tại. Dùng `--force` nếu muốn overwrite file đã tồn tại.
53
28
 
54
- 4) Dùng component:
29
+ 4. Dùng component:
55
30
 
56
31
  ```tsx
57
32
  import {
@@ -64,7 +39,7 @@ import {
64
39
  Field,
65
40
  Input,
66
41
  Select,
67
- } from '@lucasvu/scope-ui'
42
+ } from '@lucasvu/scope-ui';
68
43
 
69
44
  export function Example() {
70
45
  return (
@@ -97,7 +72,7 @@ export function Example() {
97
72
  </CardContent>
98
73
  <Button block>Tiếp tục</Button>
99
74
  </Card>
100
- )
75
+ );
101
76
  }
102
77
  ```
103
78
 
@@ -128,13 +103,17 @@ Nếu muốn AI render UI đúng và ổn định theo thư viện này, đừng
128
103
 
129
104
  - Import CSS global một lần: `@lucasvu/scope-ui/styles.css`
130
105
  - Import file theme override của project ngay sau package CSS, ví dụ `./styles/ui-theme.css`
131
- - Chạy `npx scope-ui-init` ở project consumer để tạo `AGENTS.md` và `src/styles/ui-theme.css`
106
+ - Chạy `npx scope-ui-init` ở project consumer sau khi đã cài `@lucasvu/scope-ui` để tạo `AGENTS.md` và `src/styles/ui-theme.css`
132
107
  - Chỉ dùng các component canonical ở root package; tránh `MainFe` nếu không phải legacy screen
133
108
  - 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
134
109
  - Cho agent đọc `uiThemeContract` để biết màu/token phải override ở đâu
135
110
 
136
111
  ```ts
137
- import { uiAiManifest, uiProjectAiRules, uiThemeContract } from '@lucasvu/scope-ui'
112
+ import {
113
+ uiAiManifest,
114
+ uiProjectAiRules,
115
+ uiThemeContract,
116
+ } from '@lucasvu/scope-ui';
138
117
  ```
139
118
 
140
119
  `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.
@@ -148,8 +127,8 @@ import { uiAiManifest, uiProjectAiRules, uiThemeContract } from '@lucasvu/scope-
148
127
  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`.
149
128
 
150
129
  ```ts
151
- import '@lucasvu/scope-ui/styles.css'
152
- import './styles/ui-theme.css'
130
+ import '@lucasvu/scope-ui/styles.css';
131
+ import './styles/ui-theme.css';
153
132
  ```
154
133
 
155
134
  Ví dụ:
@@ -213,12 +192,7 @@ type NumericInputProps = {
213
192
  import { NumericInput } from '@lucasvu/scope-ui';
214
193
 
215
194
  // 1) Integer qty
216
- <NumericInput
217
- mode="integer"
218
- min={0}
219
- value={qty}
220
- onValueChange={setQty}
221
- />;
195
+ <NumericInput mode="integer" min={0} value={qty} onValueChange={setQty} />;
222
196
 
223
197
  // 2) Money
224
198
  <NumericInput
@@ -246,7 +220,7 @@ import { NumericInput } from '@lucasvu/scope-ui';
246
220
  ## DataTable
247
221
 
248
222
  ```tsx
249
- import type { DataTableColumn, DataTableSortState } from '@lucasvu/scope-ui'
223
+ import type { DataTableColumn, DataTableSortState } from '@lucasvu/scope-ui';
250
224
  ```
251
225
 
252
226
  ### Tối thiểu
@@ -289,13 +263,13 @@ type DataTableProps<T> = {
289
263
 
290
264
  ```tsx
291
265
  type DataTableColumn<T> = {
292
- key: string; // khóa duy nhất của cột
293
- title: ReactNode; // tiêu đề hiển thị ở header
294
- dataIndex?: keyof T; // map dữ liệu (mặc định lấy theo key)
295
- width?: number | string; // độ rộng ưu tiên (vd: 180, '180px', '20%')
266
+ key: string; // khóa duy nhất của cột
267
+ title: ReactNode; // tiêu đề hiển thị ở header
268
+ dataIndex?: keyof T; // map dữ liệu (mặc định lấy theo key)
269
+ width?: number | string; // độ rộng ưu tiên (vd: 180, '180px', '20%')
296
270
  render?: (value, record, index) => ReactNode; // custom cell
297
- sortable?: boolean; // bật/tắt sort cho cột (ưu tiên cao nhất)
298
- sorter?: (a, b) => number; // so sánh asc/desc
271
+ sortable?: boolean; // bật/tắt sort cho cột (ưu tiên cao nhất)
272
+ sorter?: (a, b) => number; // so sánh asc/desc
299
273
  sortValue?: (record) => string | number | Date | null;
300
274
  };
301
275
  ```
@@ -371,7 +345,7 @@ Checkbox chỉ hiện khi truyền `rowSelection`. Không truyền thì sẽ ẩ
371
345
  selectedRowKeys,
372
346
  onChange: setSelectedRowKeys,
373
347
  }}
374
- />;
348
+ />
375
349
  ```
376
350
 
377
351
  ### Pagination + chọn page size
@@ -409,7 +383,7 @@ const [pageSize, setPageSize] = useState(20);
409
383
  rowKey="id"
410
384
  onRowClick={(row) => console.log(row)}
411
385
  renderActions={(row) => <ActionMenu row={row} />}
412
- />;
386
+ />
413
387
  ```
414
388
 
415
389
  ### Loading + empty
@@ -421,7 +395,7 @@ const [pageSize, setPageSize] = useState(20);
421
395
  rowKey="id"
422
396
  loading={isLoading}
423
397
  emptyText="No data"
424
- />;
398
+ />
425
399
  ```
426
400
 
427
401
  ### Sticky header khi scroll
@@ -449,7 +423,7 @@ DataTable tự hỗ trợ scroll ngang khi nội dung vượt chiều rộng (đ
449
423
  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.
450
424
 
451
425
  ```tsx
452
- import { LineClampTooltip } from '@lucasvu/scope-ui'
426
+ import { LineClampTooltip } from '@lucasvu/scope-ui';
453
427
 
454
428
  <LineClampTooltip
455
429
  text={record.apiEndpoint}
@@ -458,7 +432,7 @@ import { LineClampTooltip } from '@lucasvu/scope-ui'
458
432
  side="top"
459
433
  wrap
460
434
  portal
461
- />
435
+ />;
462
436
  ```
463
437
 
464
438
  ## Tuỳ chỉnh theme
@@ -45,6 +45,8 @@ Create bootstrap files for using ${PACKAGE_NAME} with AI/codegen.
45
45
 
46
46
  Usage:
47
47
  npx scope-ui-init
48
+ Run this after @lucasvu/scope-ui has been installed in the consumer project.
49
+
48
50
  npx scope-ui-init --force
49
51
  npx scope-ui-init --agents-file AGENTS.md --theme-file src/styles/ui-theme.css
50
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucasvu/scope-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -53,4 +53,4 @@
53
53
  "tsup": "^8.5.0",
54
54
  "typescript": "^5.8.3"
55
55
  }
56
- }
56
+ }