@nhatdev94/common-ui 1.1.6 → 1.1.8

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 CHANGED
@@ -0,0 +1,200 @@
1
+ # 📦 Common UI Library
2
+
3
+ **Package Name:** `@nhatdev94/common-ui`\
4
+ **Document Version:** 1.0\
5
+ **Last Updated:**
6
+ **Owner:**
7
+ **Status:**
8
+
9
+ ------------------------------------------------------------------------
10
+
11
+ ## Requirements
12
+
13
+ This package requires:
14
+
15
+ - React 18+
16
+ - Tailwind CSS v4
17
+
18
+ ------------------------------------------------------------------------
19
+
20
+ ## Installation
21
+
22
+ Để sử dụng các thành phần UI, bạn cần cài đặt thư viện và cấu hình Tailwind CSS v4 để nhận diện các lớp tiện ích (utility classes) từ gói package này.
23
+
24
+ 1. Cài đặt package
25
+ npm install @nhatdev94/common-ui
26
+ or
27
+ pnpm add @nhatdev94/common-ui
28
+
29
+ 2. Import Theme
30
+ Thư viện cung cấp các bộ giao diện (themes) khác nhau. Bạn cần import file CSS của theme vào file CSS chính (ví dụ index.css hoặc globals.css) để áp dụng các biến màu sắc và kiểu dáng:
31
+
32
+ /* Trong file CSS chính của bạn */
33
+ @import "tailwindcss";
34
+ @import "@nhatdev94/common-ui/themes/default.css";
35
+
36
+ Bạn có thể thay đổi default.css bằng các theme khác nếu thư viện có hỗ trợ (ví dụ: emerald.css).
37
+
38
+ 3. Cấu hình Tailwind v4 (Nếu thiếu Style)
39
+ Nếu bạn nhận thấy các Component hiển thị nhưng bị mất các class tiện ích của Tailwind (như padding, margin, màu sắc động), đó là do Tailwind v4 chưa quét qua mã nguồn của thư viện.
40
+
41
+ Hãy thêm dòng @source bên dưới phần import trong file CSS:
42
+ @import "tailwindcss";
43
+ @import "@nhatdev94/common-ui/themes/emerald.css";
44
+
45
+ /* Thêm dòng này nếu Component không hiển thị đúng Style */
46
+ @source "../node_modules/@nhatdev94/common-ui/dist/**/*.js";
47
+
48
+ ------------------------------------------------------------------------
49
+
50
+ # 1. Executive Summary
51
+
52
+ `@nhatdev94/common-ui` là thư viện UI component dùng chung cho toàn bộ hệ
53
+ sinh thái frontend của công ty.
54
+
55
+ Mục tiêu:
56
+
57
+ - Chuẩn hóa giao diện giữa các hệ thống
58
+ - Giảm duplication code
59
+ - Tăng tốc độ phát triển
60
+ - Đảm bảo tính nhất quán (consistency)
61
+ - Tăng khả năng maintain và scale
62
+
63
+ ------------------------------------------------------------------------
64
+
65
+ # 2. Scope
66
+
67
+ ## 2.1 In Scope
68
+
69
+ - Atomic UI Components (Button, Input, Modal, Table, etc.)
70
+ - Design tokens (color, spacing, typography)
71
+ - Accessibility compliant components
72
+
73
+ ## 2.2 Out of Scope
74
+
75
+ - Business logic
76
+ - API integration
77
+ - Global state management
78
+ - Application routing
79
+ - Domain-specific UI
80
+
81
+ ------------------------------------------------------------------------
82
+
83
+ # 3. Architecture Overview
84
+
85
+ ## 3.1 Design Principles
86
+
87
+ 1. Component-driven development
88
+ 2. Stateless by default
89
+ 3. Business-agnostic
90
+ 4. Backward-compatible changes
91
+ 5. Accessibility-first mindset
92
+
93
+ ------------------------------------------------------------------------
94
+
95
+ ## 3.2 Tech Stack
96
+
97
+ - React 18+
98
+ - TypeScript
99
+ - TailwindCSS
100
+ - Storybook
101
+ - Vitest
102
+ - tsup
103
+
104
+ ------------------------------------------------------------------------
105
+
106
+ # 4. Folder Structure
107
+
108
+ ``` bash
109
+ common-ui/
110
+ ├─ src/
111
+ │ ├─ components/
112
+ │ ├─ hooks/
113
+ │ ├─ lib/
114
+ │ ├─ stories/
115
+ │ ├─ themes/
116
+ │ └─ index.ts
117
+ ├─ .storybook/
118
+ ├─ dist/
119
+ ├─ package.json
120
+ ├─ tsconfig.json
121
+ ├─ tsup.config.json
122
+ └─ README.md
123
+ ```
124
+
125
+ ------------------------------------------------------------------------
126
+
127
+ # 5. Component Standards
128
+
129
+ ## Naming Convention
130
+
131
+ - PascalCase cho component name
132
+ - KebabCase cho file name
133
+ - Props interface: `ComponentNameProps`
134
+ - Không sử dụng default export
135
+
136
+ ## Rules
137
+
138
+ - Không gọi API
139
+ - Không import từ application layer
140
+ - Không chứa business validation logic
141
+ - Không phụ thuộc Redux / Zustand / App Context
142
+
143
+ ------------------------------------------------------------------------
144
+
145
+ # 6. Storybook Governance
146
+
147
+ - Mỗi component bắt buộc có story
148
+ - Có default state và variants
149
+ - Có edge cases
150
+
151
+ Run:
152
+
153
+ ``` bash
154
+ npm run storybook
155
+ ```
156
+
157
+ Build:
158
+
159
+ ``` bash
160
+ npm run build-storybook
161
+ ```
162
+
163
+ ------------------------------------------------------------------------
164
+
165
+ # 7. Versioning Policy
166
+
167
+ Tuân theo Semantic Versioning:
168
+
169
+ Type Meaning
170
+ ------- ------------------
171
+ MAJOR Breaking changes
172
+ MINOR New feature
173
+ PATCH Bug fix
174
+
175
+ ------------------------------------------------------------------------
176
+
177
+ # 8. CI/CD Workflow
178
+
179
+ 1. Pull Request
180
+ 2. Lint & Test (planned)
181
+ 3. Review
182
+ 4. Merge to main
183
+ 5. Automated publish (planned)
184
+
185
+ ------------------------------------------------------------------------
186
+
187
+ # 9. Security & Performance
188
+
189
+ - Tree-shakeable exports
190
+ - Không bundle React
191
+ - ESM & CJS output
192
+ - Audit dependency định kỳ
193
+
194
+ ------------------------------------------------------------------------
195
+
196
+ # 10. Conclusion
197
+
198
+ `@nhatdev94/common-ui` là nền tảng UI governance cho toàn bộ frontend
199
+ ecosystem, đảm bảo consistency, scalability và maintainability cho sản
200
+ phẩm.
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "@nhatdev94/common-ui",
3
- "version": "1.1.6",
4
- "description": "",
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "exports": {
12
- ".": {
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs",
15
- "types": "./dist/index.d.ts"
16
- },
17
- "./themes/*": "./dist/themes/*"
18
- },
19
- "sideEffects": [
20
- "**/*.css"
21
- ],
22
- "scripts": {
23
- "build": "tsup && npm run copy-themes",
24
- "copy-themes": "copyfiles -u 1 \"src/themes/*.css\" dist"
25
- },
26
- "keywords": [],
27
- "author": "",
28
- "license": "ISC",
29
- "type": "commonjs",
30
- "dependencies": {
31
- "class-variance-authority": "^0.7.1",
32
- "clsx": "^2.1.1",
33
- "lucide-react": "^0.576.0",
34
- "next-themes": "^0.4.6",
35
- "radix-ui": "^1.4.3",
36
- "sonner": "^2.0.7",
37
- "tailwind-merge": "^3.5.0"
38
- },
39
- "devDependencies": {
40
- "@types/react": "^19.2.14",
41
- "copyfiles": "^2.4.1",
42
- "react": "^19.2.4",
43
- "tsup": "^8.5.1",
44
- "typescript": "^5.9.3"
45
- },
46
- "peerDependencies": {
47
- "react": ">=18"
48
- }
49
- }
1
+ {
2
+ "name": "@nhatdev94/common-ui",
3
+ "version": "1.1.8",
4
+ "description": "",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./themes/*": "./dist/themes/*"
18
+ },
19
+ "sideEffects": [
20
+ "**/*.css"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup && npm run copy-themes",
24
+ "copy-themes": "copyfiles -u 1 \"src/themes/*.css\" dist"
25
+ },
26
+ "keywords": [],
27
+ "author": "",
28
+ "license": "ISC",
29
+ "type": "commonjs",
30
+ "dependencies": {
31
+ "class-variance-authority": "^0.7.1",
32
+ "clsx": "^2.1.1",
33
+ "lucide-react": "^0.576.0",
34
+ "next-themes": "^0.4.6",
35
+ "radix-ui": "^1.4.3",
36
+ "sonner": "^2.0.7",
37
+ "tailwind-merge": "^3.5.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^19.2.14",
41
+ "copyfiles": "^2.4.1",
42
+ "react": "^19.2.4",
43
+ "tsup": "^8.5.1",
44
+ "typescript": "^5.9.3"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=18"
48
+ }
49
+ }
File without changes