@idds/react 1.6.12 → 1.6.14
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 +18 -266
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +590 -581
- package/dist/types/index.d.ts +17 -15
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Import the styles in your application entry point:
|
|
|
24
24
|
|
|
25
25
|
```jsx
|
|
26
26
|
// src/main.jsx or src/index.jsx
|
|
27
|
-
import '@idds/react/
|
|
27
|
+
import '@idds/react/index.css';
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### 2. Import and Use Components
|
|
@@ -114,26 +114,6 @@ Or use minified versions for production:
|
|
|
114
114
|
@import '@idds/styles/tailwind/css/bgn.min.css';
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
Then you can use Tailwind utility classes with INA Digital colors:
|
|
118
|
-
|
|
119
|
-
```jsx
|
|
120
|
-
<div className="bg-blue-500 text-white p-4">
|
|
121
|
-
<p className="text-guide-500">This text uses guide-500 color</p>
|
|
122
|
-
<p className="text-neutral-500">This text uses neutral-500 color</p>
|
|
123
|
-
</div>
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Available brand theme files:**
|
|
127
|
-
|
|
128
|
-
- `@idds/styles/tailwind/css/idds.css` - Default theme
|
|
129
|
-
- `@idds/styles/tailwind/css/inagov.css` - INAGov brand
|
|
130
|
-
- `@idds/styles/tailwind/css/inaku.css` - INAKu brand
|
|
131
|
-
- `@idds/styles/tailwind/css/inapas.css` - INAPas brand
|
|
132
|
-
- `@idds/styles/tailwind/css/bgn.css` - BGN brand
|
|
133
|
-
- `@idds/styles/tailwind/css/bkn.css` - BKN brand
|
|
134
|
-
- `@idds/styles/tailwind/css/lan.css` - LAN brand
|
|
135
|
-
- `@idds/styles/tailwind/css/panrb.css` - panrb brand
|
|
136
|
-
|
|
137
117
|
## Available Components
|
|
138
118
|
|
|
139
119
|
### Form Components
|
|
@@ -225,75 +205,27 @@ setBrandTheme('bgn'); // or 'inagov', 'inaku', 'inapas', 'bkn', 'lan', 'panrb'
|
|
|
225
205
|
|
|
226
206
|
// Use default theme
|
|
227
207
|
setBrandTheme('default');
|
|
228
|
-
|
|
229
|
-
// Remove brand theme (use default)
|
|
230
|
-
setBrandTheme(null);
|
|
231
208
|
```
|
|
232
209
|
|
|
233
|
-
###
|
|
210
|
+
### Theme Mode (Light/Dark)
|
|
234
211
|
|
|
235
|
-
|
|
236
|
-
- `'inagov'` - INAGov brand theme
|
|
237
|
-
- `'inaku'` - INAKu brand theme
|
|
238
|
-
- `'inapas'` - INAPas brand theme
|
|
239
|
-
- `'bgn'` - BGN brand theme
|
|
240
|
-
- `'bkn'` - BKN brand theme
|
|
241
|
-
- `'lan'` - LAN brand theme
|
|
242
|
-
- `'panrb'` - panrb brand theme
|
|
243
|
-
|
|
244
|
-
### Custom Theme
|
|
245
|
-
|
|
246
|
-
You can also set a custom theme:
|
|
212
|
+
You can globally set or toggle the theme mode between light and dark:
|
|
247
213
|
|
|
248
214
|
```jsx
|
|
249
|
-
import {
|
|
250
|
-
|
|
251
|
-
setCustomTheme({
|
|
252
|
-
name: 'custom',
|
|
253
|
-
colors: {
|
|
254
|
-
primary500: '#0968f6',
|
|
255
|
-
primary600: '#0754c4',
|
|
256
|
-
// ... other color tokens
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
```
|
|
215
|
+
import { setThemeMode, toggleThemeMode, getThemeMode } from '@idds/react';
|
|
260
216
|
|
|
261
|
-
|
|
217
|
+
// Set specific mode
|
|
218
|
+
setThemeMode('dark'); // or 'light'
|
|
262
219
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
getCurrentTheme,
|
|
266
|
-
getAvailableBrands,
|
|
267
|
-
resetTheme,
|
|
268
|
-
isValidBrand,
|
|
269
|
-
} from '@idds/react';
|
|
270
|
-
|
|
271
|
-
// Get current active theme
|
|
272
|
-
const currentTheme = getCurrentTheme();
|
|
220
|
+
// Toggle current mode
|
|
221
|
+
toggleThemeMode();
|
|
273
222
|
|
|
274
|
-
// Get
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
// Reset to default theme
|
|
278
|
-
resetTheme();
|
|
279
|
-
|
|
280
|
-
// Validate brand name
|
|
281
|
-
if (isValidBrand('bgn')) {
|
|
282
|
-
setBrandTheme('bgn');
|
|
283
|
-
}
|
|
223
|
+
// Get current mode
|
|
224
|
+
const currentMode = getThemeMode();
|
|
284
225
|
```
|
|
285
226
|
|
|
286
227
|
## Utilities
|
|
287
228
|
|
|
288
|
-
### Form Utilities
|
|
289
|
-
|
|
290
|
-
```jsx
|
|
291
|
-
import { useForm, FormProvider, FormField } from '@idds/react';
|
|
292
|
-
|
|
293
|
-
// Form handling with validation
|
|
294
|
-
const { handleSubmit, register, errors } = useForm();
|
|
295
|
-
```
|
|
296
|
-
|
|
297
229
|
### Confirmation Dialog
|
|
298
230
|
|
|
299
231
|
```jsx
|
|
@@ -312,7 +244,6 @@ const handleDelete = async () => {
|
|
|
312
244
|
title: 'Delete Item',
|
|
313
245
|
message: 'Are you sure you want to delete this item?',
|
|
314
246
|
});
|
|
315
|
-
|
|
316
247
|
if (result) {
|
|
317
248
|
// User confirmed
|
|
318
249
|
}
|
|
@@ -331,11 +262,8 @@ import { ToastProvider, useToast } from '@idds/react';
|
|
|
331
262
|
|
|
332
263
|
// Use in components
|
|
333
264
|
const toast = useToast();
|
|
334
|
-
|
|
335
265
|
toast.success('Operation completed successfully!');
|
|
336
266
|
toast.error('An error occurred');
|
|
337
|
-
toast.info('Information message');
|
|
338
|
-
toast.warning('Warning message');
|
|
339
267
|
```
|
|
340
268
|
|
|
341
269
|
### Security Utilities
|
|
@@ -346,6 +274,8 @@ import {
|
|
|
346
274
|
validateInput,
|
|
347
275
|
encodeHtmlEntities,
|
|
348
276
|
decodeHtmlEntities,
|
|
277
|
+
sanitizeFileName,
|
|
278
|
+
containsDangerousPatterns
|
|
349
279
|
} from '@idds/react';
|
|
350
280
|
|
|
351
281
|
// Sanitize user input
|
|
@@ -361,7 +291,7 @@ if (!validation.isValid) {
|
|
|
361
291
|
### File Validation
|
|
362
292
|
|
|
363
293
|
```jsx
|
|
364
|
-
import { validateFile,
|
|
294
|
+
import { validateFile, validateFileMagicNumber, formatFileSize } from '@idds/react';
|
|
365
295
|
|
|
366
296
|
// Validate file
|
|
367
297
|
const result = validateFile(file, {
|
|
@@ -369,199 +299,21 @@ const result = validateFile(file, {
|
|
|
369
299
|
maxSize: 5 * 1024 * 1024, // 5MB
|
|
370
300
|
});
|
|
371
301
|
|
|
372
|
-
// Validate magic number (file signature)
|
|
373
|
-
const magicResult = await validateMagicNumber(file, 'image/png');
|
|
374
|
-
|
|
375
302
|
// Format file size
|
|
376
303
|
const formatted = formatFileSize(1024 * 1024); // "1 MB"
|
|
377
304
|
```
|
|
378
305
|
|
|
379
|
-
###
|
|
380
|
-
|
|
381
|
-
```jsx
|
|
382
|
-
import {
|
|
383
|
-
formattingThousand,
|
|
384
|
-
onlyAlphanumeric,
|
|
385
|
-
onlyNumericValue,
|
|
386
|
-
onlyDecimalNumber,
|
|
387
|
-
} from '@idds/react';
|
|
388
|
-
|
|
389
|
-
formattingThousand(1000000); // "1,000,000"
|
|
390
|
-
onlyAlphanumeric('abc123!@#'); // "abc123"
|
|
391
|
-
onlyNumericValue('123abc'); // "123"
|
|
392
|
-
onlyDecimalNumber('123.45'); // "123.45"
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
## Component Examples
|
|
396
|
-
|
|
397
|
-
### TextField
|
|
398
|
-
|
|
399
|
-
```jsx
|
|
400
|
-
import { TextField } from '@idds/react';
|
|
401
|
-
|
|
402
|
-
<TextField
|
|
403
|
-
label="Email"
|
|
404
|
-
placeholder="Enter your email"
|
|
405
|
-
value={email}
|
|
406
|
-
onChange={setEmail}
|
|
407
|
-
type="email"
|
|
408
|
-
required
|
|
409
|
-
showClearButton
|
|
410
|
-
maxLength={100}
|
|
411
|
-
showCharCount
|
|
412
|
-
/>;
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
### Button
|
|
416
|
-
|
|
417
|
-
```jsx
|
|
418
|
-
import { Button } from '@idds/react';
|
|
419
|
-
|
|
420
|
-
<Button variant="primary" size="md" onClick={handleClick}>
|
|
421
|
-
Submit
|
|
422
|
-
</Button>;
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
### SelectDropdown
|
|
426
|
-
|
|
427
|
-
```jsx
|
|
428
|
-
import { SelectDropdown } from '@idds/react';
|
|
429
|
-
|
|
430
|
-
const options = [
|
|
431
|
-
{ value: '1', label: 'Option 1' },
|
|
432
|
-
{ value: '2', label: 'Option 2' },
|
|
433
|
-
];
|
|
434
|
-
|
|
435
|
-
<SelectDropdown
|
|
436
|
-
label="Select Option"
|
|
437
|
-
options={options}
|
|
438
|
-
value={selected}
|
|
439
|
-
onChange={setSelected}
|
|
440
|
-
searchable
|
|
441
|
-
clearable
|
|
442
|
-
/>;
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
### DatePicker
|
|
446
|
-
|
|
447
|
-
```jsx
|
|
448
|
-
import { DatePicker } from '@idds/react';
|
|
449
|
-
|
|
450
|
-
<DatePicker
|
|
451
|
-
label="Select Date"
|
|
452
|
-
value={date}
|
|
453
|
-
onChange={setDate}
|
|
454
|
-
mode="single"
|
|
455
|
-
dateFormat="DD/MM/YYYY"
|
|
456
|
-
showIcon
|
|
457
|
-
showClearButton
|
|
458
|
-
/>;
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
### Table
|
|
462
|
-
|
|
463
|
-
```jsx
|
|
464
|
-
import { Table } from '@idds/react';
|
|
465
|
-
|
|
466
|
-
const columns = [
|
|
467
|
-
{ key: 'name', label: 'Name' },
|
|
468
|
-
{ key: 'email', label: 'Email' },
|
|
469
|
-
];
|
|
470
|
-
|
|
471
|
-
const data = [
|
|
472
|
-
{ id: 1, name: 'John', email: 'john@example.com' },
|
|
473
|
-
{ id: 2, name: 'Jane', email: 'jane@example.com' },
|
|
474
|
-
];
|
|
475
|
-
|
|
476
|
-
<Table columns={columns} data={data} />;
|
|
477
|
-
```
|
|
478
|
-
|
|
479
|
-
## Styling
|
|
480
|
-
|
|
481
|
-
### CSS Classes
|
|
482
|
-
|
|
483
|
-
Components use BEM-like naming conventions:
|
|
484
|
-
|
|
485
|
-
- `ina-button` - Base button class
|
|
486
|
-
- `ina-button--primary` - Primary variant
|
|
487
|
-
- `ina-button--disabled` - Disabled state
|
|
488
|
-
- `ina-text-field` - Text field component
|
|
489
|
-
- `ina-text-field__input` - Input element
|
|
490
|
-
- `ina-text-field__label` - Label element
|
|
491
|
-
|
|
492
|
-
### Custom Styling
|
|
493
|
-
|
|
494
|
-
You can override component styles using CSS:
|
|
495
|
-
|
|
496
|
-
```css
|
|
497
|
-
.ina-button--primary {
|
|
498
|
-
background-color: your-custom-color;
|
|
499
|
-
}
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
### Using with Tailwind CSS (Optional)
|
|
503
|
-
|
|
504
|
-
If you want to use Tailwind CSS utility classes alongside the design system:
|
|
505
|
-
|
|
506
|
-
1. Install Tailwind CSS in your project
|
|
507
|
-
2. Import color tokens:
|
|
508
|
-
|
|
509
|
-
```js
|
|
510
|
-
// tailwind.config.js
|
|
511
|
-
import iddsColorTokens from '@idds/react';
|
|
512
|
-
|
|
513
|
-
export default {
|
|
514
|
-
theme: {
|
|
515
|
-
extend: {
|
|
516
|
-
colors: iddsColorTokens,
|
|
517
|
-
},
|
|
518
|
-
},
|
|
519
|
-
};
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
3. Use Tailwind classes for custom styling:
|
|
523
|
-
|
|
524
|
-
```jsx
|
|
525
|
-
<div className="bg-blue-500 text-white p-4">
|
|
526
|
-
<Button>Click me</Button>
|
|
527
|
-
</div>
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
> **Note:** Tailwind CSS is **optional**. The design system works perfectly without it. Components are fully styled and functional using only the included CSS.
|
|
306
|
+
### Styling
|
|
307
|
+
Components use BEM-like naming conventions (e.g., `ina-button`, `ina-button--primary`). The `@idds/styles` package serves all necessary core styles. Tailwind integration is completely **optional**.
|
|
531
308
|
|
|
532
309
|
## TypeScript Support
|
|
533
310
|
|
|
534
|
-
All components are fully typed with
|
|
311
|
+
All components are fully typed and expose their prop types along with their sub-types (e.g. sizes, variants).
|
|
535
312
|
|
|
536
313
|
```tsx
|
|
537
|
-
import { TextField, type TextFieldProps } from '@idds/react';
|
|
538
|
-
|
|
539
|
-
const props: TextFieldProps = {
|
|
540
|
-
label: 'Email',
|
|
541
|
-
value: email,
|
|
542
|
-
onChange: setEmail,
|
|
543
|
-
};
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
## Development
|
|
547
|
-
|
|
548
|
-
```bash
|
|
549
|
-
# Install dependencies
|
|
550
|
-
npm install
|
|
551
|
-
|
|
552
|
-
# Start development server
|
|
553
|
-
npm run dev
|
|
554
|
-
|
|
555
|
-
# Build for production
|
|
556
|
-
npm run build
|
|
557
|
-
|
|
558
|
-
# Type checking
|
|
559
|
-
npm run type-check
|
|
560
|
-
|
|
561
|
-
# Linting
|
|
562
|
-
npm run lint
|
|
314
|
+
import { TextField, type TextFieldProps, type TextFieldSize } from '@idds/react';
|
|
563
315
|
```
|
|
564
316
|
|
|
565
317
|
## License
|
|
566
318
|
|
|
567
|
-
|
|
319
|
+
MIT
|