@idds/react 1.6.14 → 1.6.15
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 +47 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -229,7 +229,7 @@ const currentMode = getThemeMode();
|
|
|
229
229
|
### Confirmation Dialog
|
|
230
230
|
|
|
231
231
|
```jsx
|
|
232
|
-
import { ConfirmationProvider, useConfirmation } from '@idds/react';
|
|
232
|
+
import { ConfirmationProvider, useConfirmation, Button } from '@idds/react';
|
|
233
233
|
|
|
234
234
|
// Wrap your app
|
|
235
235
|
<ConfirmationProvider>
|
|
@@ -237,23 +237,31 @@ import { ConfirmationProvider, useConfirmation } from '@idds/react';
|
|
|
237
237
|
</ConfirmationProvider>;
|
|
238
238
|
|
|
239
239
|
// Use in components
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
};
|
|
240
|
+
export default function DeleteItem() {
|
|
241
|
+
const { confirm } = useConfirmation();
|
|
242
|
+
|
|
243
|
+
const handleDelete = async () => {
|
|
244
|
+
const isConfirmed = await confirm({
|
|
245
|
+
title: 'Hapus Data?',
|
|
246
|
+
message: 'Apakah Anda yakin ingin menghapus data ini? Tindakan ini tidak dapat dibatalkan.',
|
|
247
|
+
confirmText: 'Hapus',
|
|
248
|
+
cancelText: 'Batal',
|
|
249
|
+
confirmClassName: 'bg-red-600 hover:bg-red-700 text-white', // Custom class for confirm button
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (isConfirmed) {
|
|
253
|
+
console.log('User confirmed deletion');
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return <Button onClick={handleDelete} className="bg-red-600 hover:bg-red-700 text-white border-none">Hapus Item</Button>;
|
|
258
|
+
}
|
|
251
259
|
```
|
|
252
260
|
|
|
253
261
|
### Toast Notifications
|
|
254
262
|
|
|
255
263
|
```jsx
|
|
256
|
-
import { ToastProvider, useToast } from '@idds/react';
|
|
264
|
+
import { ToastProvider, useToast, Button } from '@idds/react';
|
|
257
265
|
|
|
258
266
|
// Wrap your app
|
|
259
267
|
<ToastProvider>
|
|
@@ -261,9 +269,20 @@ import { ToastProvider, useToast } from '@idds/react';
|
|
|
261
269
|
</ToastProvider>;
|
|
262
270
|
|
|
263
271
|
// Use in components
|
|
264
|
-
|
|
265
|
-
toast
|
|
266
|
-
|
|
272
|
+
export default function MyComponent() {
|
|
273
|
+
const { toast } = useToast();
|
|
274
|
+
|
|
275
|
+
const handleShowToast = () => {
|
|
276
|
+
toast({
|
|
277
|
+
state: 'positive',
|
|
278
|
+
title: 'Berhasil',
|
|
279
|
+
description: 'Data berhasil disimpan',
|
|
280
|
+
duration: 3000,
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
return <Button onClick={handleShowToast}>Show Toast</Button>;
|
|
285
|
+
}
|
|
267
286
|
```
|
|
268
287
|
|
|
269
288
|
### Security Utilities
|
|
@@ -275,7 +294,7 @@ import {
|
|
|
275
294
|
encodeHtmlEntities,
|
|
276
295
|
decodeHtmlEntities,
|
|
277
296
|
sanitizeFileName,
|
|
278
|
-
containsDangerousPatterns
|
|
297
|
+
containsDangerousPatterns,
|
|
279
298
|
} from '@idds/react';
|
|
280
299
|
|
|
281
300
|
// Sanitize user input
|
|
@@ -291,7 +310,11 @@ if (!validation.isValid) {
|
|
|
291
310
|
### File Validation
|
|
292
311
|
|
|
293
312
|
```jsx
|
|
294
|
-
import {
|
|
313
|
+
import {
|
|
314
|
+
validateFile,
|
|
315
|
+
validateFileMagicNumber,
|
|
316
|
+
formatFileSize,
|
|
317
|
+
} from '@idds/react';
|
|
295
318
|
|
|
296
319
|
// Validate file
|
|
297
320
|
const result = validateFile(file, {
|
|
@@ -304,6 +327,7 @@ const formatted = formatFileSize(1024 * 1024); // "1 MB"
|
|
|
304
327
|
```
|
|
305
328
|
|
|
306
329
|
### Styling
|
|
330
|
+
|
|
307
331
|
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**.
|
|
308
332
|
|
|
309
333
|
## TypeScript Support
|
|
@@ -311,7 +335,11 @@ Components use BEM-like naming conventions (e.g., `ina-button`, `ina-button--pri
|
|
|
311
335
|
All components are fully typed and expose their prop types along with their sub-types (e.g. sizes, variants).
|
|
312
336
|
|
|
313
337
|
```tsx
|
|
314
|
-
import {
|
|
338
|
+
import {
|
|
339
|
+
TextField,
|
|
340
|
+
type TextFieldProps,
|
|
341
|
+
type TextFieldSize,
|
|
342
|
+
} from '@idds/react';
|
|
315
343
|
```
|
|
316
344
|
|
|
317
345
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idds/react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.15",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"./*": "./dist/*"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@idds/styles": "^1.6.
|
|
54
|
+
"@idds/styles": "^1.6.15",
|
|
55
55
|
"clsx": "^2.1.1",
|
|
56
56
|
"react-hook-form": "^7.60.0"
|
|
57
57
|
},
|