cemtrik-dependencies 1.0.257 → 1.1.1
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 +348 -337
- package/dist/index.js +21 -16
- package/package.json +57 -57
package/README.md
CHANGED
|
@@ -1,337 +1,348 @@
|
|
|
1
|
-
# Cemtrik Dependencies
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
-
|
|
336
|
-
-
|
|
337
|
-
-
|
|
1
|
+
# Cemtrik Dependencies
|
|
2
|
+
|
|
3
|
+
A React component library for building consistent, accessible, modern UI in Cemtrik applications.
|
|
4
|
+
The library follows Atomic Design principles and includes a full Storybook workspace for
|
|
5
|
+
documentation and component exploration.
|
|
6
|
+
|
|
7
|
+
## What This Project Provides
|
|
8
|
+
|
|
9
|
+
- **Reusable React Components**: 28+ UI components organized by Atomic Design
|
|
10
|
+
- **Custom React Hooks**: form, modal, and responsive helpers
|
|
11
|
+
- **Utility Functions**: helpers for email validation, grouping data, and class name handling
|
|
12
|
+
- **Complete Documentation**: interactive Storybook with dynamic brand themes
|
|
13
|
+
|
|
14
|
+
The library is built to support **consistency**, **accessibility** (WCAG 2.1 AA), and a strong
|
|
15
|
+
developer experience across Cemtrik applications.
|
|
16
|
+
|
|
17
|
+
## Components and Modules
|
|
18
|
+
|
|
19
|
+
### Atoms
|
|
20
|
+
|
|
21
|
+
- Alert
|
|
22
|
+
- Avatar
|
|
23
|
+
- Bullets
|
|
24
|
+
- ButtonSolid
|
|
25
|
+
- ButtonOutline
|
|
26
|
+
- ButtonPagination
|
|
27
|
+
- Checkbox
|
|
28
|
+
- ConfirmationAbandoningCreation
|
|
29
|
+
- Divider
|
|
30
|
+
- GoBack
|
|
31
|
+
- Image
|
|
32
|
+
- Input
|
|
33
|
+
- InputDropdown
|
|
34
|
+
- Select
|
|
35
|
+
- SelectColor
|
|
36
|
+
- Spinner
|
|
37
|
+
- Switch
|
|
38
|
+
- Textarea
|
|
39
|
+
- Tooltip
|
|
40
|
+
|
|
41
|
+
### Molecules
|
|
42
|
+
|
|
43
|
+
- CoverPhoto
|
|
44
|
+
- Dropdown
|
|
45
|
+
- IconSelectPicker
|
|
46
|
+
- Modal
|
|
47
|
+
- Pagination
|
|
48
|
+
- SketchColorPicker
|
|
49
|
+
- FileUploadPreview
|
|
50
|
+
- UploadImage
|
|
51
|
+
|
|
52
|
+
### Templates
|
|
53
|
+
|
|
54
|
+
- Accordion
|
|
55
|
+
|
|
56
|
+
### Hooks
|
|
57
|
+
|
|
58
|
+
- `useForm`
|
|
59
|
+
- `useCloseModal`
|
|
60
|
+
- `useMediaQuery`
|
|
61
|
+
- `useWindowDimensions`
|
|
62
|
+
|
|
63
|
+
### Utilities
|
|
64
|
+
|
|
65
|
+
- `copyOptions`
|
|
66
|
+
- `classNames`
|
|
67
|
+
- `validateEmail`
|
|
68
|
+
- `generateAvatarInitials`
|
|
69
|
+
- `groupBy`
|
|
70
|
+
- `isPromise`
|
|
71
|
+
|
|
72
|
+
## Storybook Features
|
|
73
|
+
|
|
74
|
+
- 4 dynamic themes: Cemtrik, Dark Mode, Nature, and Ocean
|
|
75
|
+
- Documentation in English
|
|
76
|
+
- WCAG 2.1 AA accessibility goals
|
|
77
|
+
- Interactive controls for live prop editing
|
|
78
|
+
- Automatic discovery of new components
|
|
79
|
+
|
|
80
|
+
## Architecture
|
|
81
|
+
|
|
82
|
+
The library is organized using Atomic Design:
|
|
83
|
+
|
|
84
|
+
- Atoms: basic building blocks such as buttons, inputs, and icons
|
|
85
|
+
- Molecules: composed components such as modals and dropdowns
|
|
86
|
+
- Templates: page-level structures such as accordions
|
|
87
|
+
|
|
88
|
+
All components, hooks, and utilities are exported from `src/index.js` and documented in Storybook.
|
|
89
|
+
|
|
90
|
+
## Tech Stack
|
|
91
|
+
|
|
92
|
+
| Category | Technology | Version | Purpose |
|
|
93
|
+
| --- | --- | --- | --- |
|
|
94
|
+
| Framework | React | 18.2.0 | UI library |
|
|
95
|
+
| Build Tool | Vite | 5.4.0 | Development and bundling |
|
|
96
|
+
| Styling | Tailwind CSS | Latest | Utility-first CSS |
|
|
97
|
+
| Icons | Heroicons | 2.0.18 | SVG icon set |
|
|
98
|
+
| Headless UI | Headless UI | 1.7.15 | Accessible primitives |
|
|
99
|
+
|
|
100
|
+
## Development Tooling
|
|
101
|
+
|
|
102
|
+
| Technology | Purpose |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| Storybook | Component documentation and exploration |
|
|
105
|
+
| Vite (Storybook) | Storybook build system |
|
|
106
|
+
| MDX | Documentation with JSX |
|
|
107
|
+
|
|
108
|
+
## Code Quality
|
|
109
|
+
|
|
110
|
+
| Technology | Purpose |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| ESLint | JavaScript and React linting |
|
|
113
|
+
| Prettier | Code formatting |
|
|
114
|
+
| Husky | Git hooks |
|
|
115
|
+
| Commitlint | Commit message conventions |
|
|
116
|
+
| Jest | Unit tests |
|
|
117
|
+
| React Testing Library | Component tests |
|
|
118
|
+
|
|
119
|
+
## Package Management
|
|
120
|
+
|
|
121
|
+
| Technology | Purpose |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| npm | Package management |
|
|
124
|
+
| Babel | JavaScript transpilation |
|
|
125
|
+
|
|
126
|
+
## Installation
|
|
127
|
+
|
|
128
|
+
### Requirements
|
|
129
|
+
|
|
130
|
+
- Node.js 16+
|
|
131
|
+
- npm 8+ or yarn 1.22+
|
|
132
|
+
|
|
133
|
+
### Install as a Dependency
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm install cemtrik-dependencies
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Peer Dependencies
|
|
140
|
+
|
|
141
|
+
Install these packages in your application:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm install react react-dom
|
|
145
|
+
npm install @headlessui/react @heroicons/react classnames
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Development Setup
|
|
149
|
+
|
|
150
|
+
1. Clone or open the repository.
|
|
151
|
+
2. Install dependencies.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npm install
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
3. Start the app locally.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
npm run dev
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
4. Run tests.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm test
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
5. Run linting.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm run lint
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
6. Build for production.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm run build
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Storybook Setup
|
|
182
|
+
|
|
183
|
+
Storybook lives in the `storybook/` subproject.
|
|
184
|
+
|
|
185
|
+
1. Install Storybook dependencies.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cd storybook
|
|
189
|
+
npm install
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
2. Start Storybook.
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
cd storybook
|
|
196
|
+
npm run storybook
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
3. Open `http://localhost:6006` in your browser.
|
|
200
|
+
|
|
201
|
+
## Quick Start
|
|
202
|
+
|
|
203
|
+
### Use Components
|
|
204
|
+
|
|
205
|
+
```jsx
|
|
206
|
+
import { ButtonSolid, Input, useForm } from "cemtrik-dependencies";
|
|
207
|
+
|
|
208
|
+
function MyForm() {
|
|
209
|
+
const { handleSubmit, handleChange, model, messageError } = useForm();
|
|
210
|
+
|
|
211
|
+
const onSubmit = (data) => {
|
|
212
|
+
console.log("Form data:", data);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
217
|
+
<Input
|
|
218
|
+
name="email"
|
|
219
|
+
onChange={(e) => handleChange(e, setForm, form)}
|
|
220
|
+
placeholder="Enter email"
|
|
221
|
+
/>
|
|
222
|
+
{messageError.email && <span>{messageError.email}</span>}
|
|
223
|
+
|
|
224
|
+
<ButtonSolid type="submit">Submit</ButtonSolid>
|
|
225
|
+
</form>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Use Utilities
|
|
231
|
+
|
|
232
|
+
```jsx
|
|
233
|
+
import { validateEmail, classNames, groupBy } from "cemtrik-dependencies";
|
|
234
|
+
|
|
235
|
+
// Email validation
|
|
236
|
+
const isValid = validateEmail("user@example.com"); // true
|
|
237
|
+
|
|
238
|
+
// Conditional class names
|
|
239
|
+
const buttonClass = classNames("btn", isPrimary && "btn-primary", isDisabled && "btn-disabled");
|
|
240
|
+
|
|
241
|
+
// Group array items
|
|
242
|
+
const grouped = groupBy({
|
|
243
|
+
items: users,
|
|
244
|
+
key: "department",
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Available Scripts
|
|
249
|
+
|
|
250
|
+
| Script | Description |
|
|
251
|
+
| --- | --- |
|
|
252
|
+
| `npm run dev` | Start the Vite development server |
|
|
253
|
+
| `npm run build` | Build the library for production |
|
|
254
|
+
| `npm run preview` | Preview the production build |
|
|
255
|
+
| `npm test` | Run Jest tests |
|
|
256
|
+
| `npm run coverage` | Run tests with coverage reporting |
|
|
257
|
+
| `npm run lint` | Run ESLint |
|
|
258
|
+
| `npm run format` | Format code with Prettier |
|
|
259
|
+
|
|
260
|
+
Storybook scripts live in `storybook/package.json`:
|
|
261
|
+
|
|
262
|
+
| Script | Description |
|
|
263
|
+
| --- | --- |
|
|
264
|
+
| `npm run storybook` | Start Storybook development mode |
|
|
265
|
+
| `npm run build` | Build Storybook for production |
|
|
266
|
+
| `npm run generate-docs` | Generate Storybook docs |
|
|
267
|
+
| `npm run deploy` | Deploy Storybook to Firebase hosting |
|
|
268
|
+
|
|
269
|
+
## Publishing
|
|
270
|
+
|
|
271
|
+
Use this flow to publish a new version of the package safely from the repository root.
|
|
272
|
+
|
|
273
|
+
### 1. Confirm access
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npm whoami
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
If npm requires 2FA for publishing, use a granular access token with `Bypass two-factor authentication` enabled and configure it locally for the session.
|
|
280
|
+
|
|
281
|
+
### 2. Verify the release candidate
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
npm run lint
|
|
285
|
+
npm test -- --runInBand
|
|
286
|
+
npm run build
|
|
287
|
+
npm publish --dry-run
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 3. Bump the version
|
|
291
|
+
|
|
292
|
+
Use semantic versioning intentionally:
|
|
293
|
+
|
|
294
|
+
- `npm version patch` for bug fixes and non-breaking changes
|
|
295
|
+
- `npm version minor` for new backward-compatible features
|
|
296
|
+
- `npm version major` for breaking changes
|
|
297
|
+
|
|
298
|
+
### 4. Publish
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
npm publish
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 5. Verify on npm
|
|
305
|
+
|
|
306
|
+
Confirm the new version on the package page:
|
|
307
|
+
|
|
308
|
+
https://www.npmjs.com/package/cemtrik-dependencies
|
|
309
|
+
|
|
310
|
+
Notes:
|
|
311
|
+
|
|
312
|
+
- Do not run `npm version` more than once for the same release.
|
|
313
|
+
- The published tarball comes from `dist/` only.
|
|
314
|
+
- Do not commit npm tokens or store them in the repository.
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
|
|
318
|
+
Copyright 2024 Cemtrik. All rights reserved.
|
|
319
|
+
|
|
320
|
+
## Contributing
|
|
321
|
+
|
|
322
|
+
1. Keep code aligned with the existing style (ESLint + Prettier).
|
|
323
|
+
2. Write tests for new features.
|
|
324
|
+
3. Update Storybook documentation.
|
|
325
|
+
4. Use conventional commit messages.
|
|
326
|
+
5. Run `npm run lint` before committing.
|
|
327
|
+
|
|
328
|
+
## Pull Request Workflow
|
|
329
|
+
|
|
330
|
+
Use the `pr-workflow` skill when you need to propose changes through a formal review process.
|
|
331
|
+
It covers source code, skills, documentation, and configuration changes.
|
|
332
|
+
|
|
333
|
+
The workflow enforces:
|
|
334
|
+
|
|
335
|
+
- Work on the current branch instead of creating a new branch
|
|
336
|
+
- Use `CVP-XXXX` as the branch reference convention when needed
|
|
337
|
+
- Conventional Commits for every commit
|
|
338
|
+
- `gh`-based pull request creation right after push
|
|
339
|
+
- Secrets, credentials, and PII checks before commit
|
|
340
|
+
- Tests and coverage evidence for logic changes
|
|
341
|
+
|
|
342
|
+
## Support
|
|
343
|
+
|
|
344
|
+
For questions or support:
|
|
345
|
+
|
|
346
|
+
- Check the Storybook documentation at `http://localhost:6006`
|
|
347
|
+
- Review existing component implementations in `src/components/`
|
|
348
|
+
- Review Storybook stories in `storybook/stories/`
|