@idds/vue 1.6.13 → 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.
Files changed (2) hide show
  1. package/README.md +55 -272
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -117,28 +117,6 @@ Or use minified versions for production:
117
117
  @import '@idds/styles/tailwind/css/bgn.min.css';
118
118
  ```
119
119
 
120
- Then you can use Tailwind utility classes with INA Digital colors:
121
-
122
- ```vue
123
- <template>
124
- <div class="bg-blue-500 text-white p-4">
125
- <p class="text-guide-500">This text uses guide-500 color</p>
126
- <p class="text-neutral-500">This text uses neutral-500 color</p>
127
- </div>
128
- </template>
129
- ```
130
-
131
- **Available brand theme files:**
132
-
133
- - `@idds/styles/tailwind/css/idds.css` - Default theme
134
- - `@idds/styles/tailwind/css/inagov.css` - INAGov brand
135
- - `@idds/styles/tailwind/css/inaku.css` - INAKu brand
136
- - `@idds/styles/tailwind/css/inapas.css` - INAPas brand
137
- - `@idds/styles/tailwind/css/bgn.css` - BGN brand
138
- - `@idds/styles/tailwind/css/bkn.css` - BKN brand
139
- - `@idds/styles/tailwind/css/lan.css` - LAN brand
140
- - `@idds/styles/tailwind/css/panrb.css` - panrb brand
141
-
142
120
  ## Available Components
143
121
 
144
122
  ### Form Components
@@ -223,62 +201,23 @@ setBrandTheme('bgn'); // or 'inagov', 'inaku', 'inapas', 'bkn', 'lan', 'panrb'
223
201
 
224
202
  // Use default theme
225
203
  setBrandTheme('default');
226
-
227
- // Remove brand theme (use default)
228
- setBrandTheme(null);
229
204
  ```
230
205
 
231
- ### Available Brand Themes
232
-
233
- - `'default'` - Default INA Digital theme
234
- - `'inagov'` - INAGov brand theme
235
- - `'inaku'` - INAKu brand theme
236
- - `'inapas'` - INAPas brand theme
237
- - `'bgn'` - BGN brand theme
238
- - `'bkn'` - BKN brand theme
239
- - `'lan'` - LAN brand theme
240
- - `'panrb'` - panrb brand theme
241
-
242
- ### Custom Theme
206
+ ### Theme Mode (Light/Dark)
243
207
 
244
- You can also set a custom theme:
208
+ You can globally set or toggle the theme mode between light and dark:
245
209
 
246
210
  ```js
247
- import { setCustomTheme } from '@idds/vue';
248
-
249
- setCustomTheme({
250
- name: 'custom',
251
- colors: {
252
- primary500: '#0968f6',
253
- primary600: '#0754c4',
254
- // ... other color tokens
255
- },
256
- });
257
- ```
211
+ import { setThemeMode, toggleThemeMode, getThemeMode } from '@idds/vue';
258
212
 
259
- ### Theme Utilities
213
+ // Set specific mode
214
+ setThemeMode('dark'); // or 'light'
260
215
 
261
- ```js
262
- import {
263
- getCurrentTheme,
264
- getAvailableBrands,
265
- resetTheme,
266
- isValidBrand,
267
- } from '@idds/vue';
268
-
269
- // Get current active theme
270
- const currentTheme = getCurrentTheme();
271
-
272
- // Get available brand names
273
- const brands = getAvailableBrands();
216
+ // Toggle current mode
217
+ toggleThemeMode();
274
218
 
275
- // Reset to default theme
276
- resetTheme();
277
-
278
- // Validate brand name
279
- if (isValidBrand('bgn')) {
280
- setBrandTheme('bgn');
281
- }
219
+ // Get current mode
220
+ const currentMode = getThemeMode();
282
221
  ```
283
222
 
284
223
  ## Composables
@@ -286,168 +225,79 @@ if (isValidBrand('bgn')) {
286
225
  ### Toast Notifications
287
226
 
288
227
  ```vue
228
+ <!-- Root Component (e.g. App.vue) -->
289
229
  <template>
290
230
  <ToastProvider>
291
- <App />
231
+ <router-view />
292
232
  </ToastProvider>
293
233
  </template>
294
234
 
295
235
  <script setup>
296
- import { ToastProvider, useToast } from '@idds/vue';
297
-
298
- const toast = useToast();
299
-
300
- const showSuccess = () => {
301
- toast.success('Operation completed successfully!');
302
- };
303
-
304
- const showError = () => {
305
- toast.error('An error occurred');
306
- };
236
+ import { ToastProvider } from '@idds/vue';
307
237
  </script>
308
238
  ```
309
239
 
310
- ### Confirmation Dialog
311
-
312
240
  ```vue
241
+ <!-- Child Component -->
313
242
  <template>
314
- <ConfirmationProvider>
315
- <App />
316
- </ConfirmationProvider>
243
+ <Button @click="handleShowToast">Show Toast</Button>
317
244
  </template>
318
245
 
319
246
  <script setup>
320
- import { ConfirmationProvider, useConfirmation } from '@idds/vue';
247
+ import { useToast, Button } from '@idds/vue';
321
248
 
322
- const confirm = useConfirmation();
249
+ const { toast } = useToast();
323
250
 
324
- const handleDelete = async () => {
325
- const result = await confirm({
326
- title: 'Delete Item',
327
- message: 'Are you sure you want to delete this item?',
251
+ const handleShowToast = () => {
252
+ toast({
253
+ state: 'positive',
254
+ title: 'Berhasil',
255
+ description: 'Data berhasil disimpan',
256
+ duration: 3000,
328
257
  });
329
-
330
- if (result) {
331
- // User confirmed
332
- }
333
- };
334
- </script>
335
- ```
336
-
337
- ## Component Examples
338
-
339
- ### TextField
340
-
341
- ```vue
342
- <template>
343
- <TextField
344
- v-model="email"
345
- label="Email"
346
- placeholder="Enter your email"
347
- type="email"
348
- :required="true"
349
- :show-clear-button="true"
350
- :max-length="100"
351
- :show-char-count="true"
352
- @input="handleInput"
353
- />
354
- </template>
355
-
356
- <script setup>
357
- import { ref } from 'vue';
358
- import { TextField } from '@idds/vue';
359
-
360
- const email = ref('');
361
- const handleInput = (event) => {
362
- console.log('Input event:', event);
363
258
  };
364
259
  </script>
365
260
  ```
366
261
 
367
- ### Button
368
-
369
- ```vue
370
- <template>
371
- <Button variant="primary" size="md" @click="handleClick"> Submit </Button>
372
- </template>
373
-
374
- <script setup>
375
- import { Button } from '@idds/vue';
376
-
377
- const handleClick = () => {
378
- console.log('Button clicked');
379
- };
380
- </script>
381
- ```
382
-
383
- ### SelectDropdown
262
+ ### Confirmation Dialog
384
263
 
385
264
  ```vue
265
+ <!-- Root Component -->
386
266
  <template>
387
- <SelectDropdown
388
- v-model="selected"
389
- :options="options"
390
- label="Select Option"
391
- placeholder="Choose an option"
392
- :searchable="true"
393
- :clearable="true"
394
- />
267
+ <ConfirmationProvider>
268
+ <router-view />
269
+ </ConfirmationProvider>
395
270
  </template>
396
271
 
397
272
  <script setup>
398
- import { ref } from 'vue';
399
- import { SelectDropdown } from '@idds/vue';
400
-
401
- const selected = ref(null);
402
- const options = [
403
- { value: '1', label: 'Option 1' },
404
- { value: '2', label: 'Option 2' },
405
- ];
273
+ import { ConfirmationProvider } from '@idds/vue';
406
274
  </script>
407
275
  ```
408
276
 
409
- ### DatePicker
410
-
411
277
  ```vue
278
+ <!-- Child Component -->
412
279
  <template>
413
- <DatePicker
414
- v-model="date"
415
- mode="single"
416
- label="Select Date"
417
- placeholder="Choose a date"
418
- date-format="DD/MM/YYYY"
419
- :show-icon="true"
420
- :show-clear-button="true"
421
- />
280
+ <Button @click="handleDelete" variant="error">Hapus Item</Button>
422
281
  </template>
423
282
 
424
283
  <script setup>
425
- import { ref } from 'vue';
426
- import { DatePicker } from '@idds/vue';
427
-
428
- const date = ref('');
429
- </script>
430
- ```
431
-
432
- ### Table
433
-
434
- ```vue
435
- <template>
436
- <Table :columns="columns" :data="data" />
437
- </template>
284
+ import { useConfirmation, Button } from '@idds/vue';
438
285
 
439
- <script setup>
440
- import { Table } from '@idds/vue';
286
+ const { confirm } = useConfirmation();
441
287
 
442
- const columns = [
443
- { key: 'name', label: 'Name' },
444
- { key: 'email', label: 'Email' },
445
- ];
288
+ const handleDelete = async () => {
289
+ const isConfirmed = await confirm({
290
+ title: 'Hapus Data?',
291
+ message: 'Apakah Anda yakin ingin menghapus data ini?',
292
+ confirmText: 'Hapus',
293
+ cancelText: 'Batal',
294
+ confirmClassName: 'bg-red-600 hover:bg-red-700 text-white',
295
+ });
446
296
 
447
- const data = [
448
- { id: 1, name: 'John', email: 'john@example.com' },
449
- { id: 2, name: 'Jane', email: 'jane@example.com' },
450
- ];
297
+ if (isConfirmed) {
298
+ console.log('User confirmed deletion');
299
+ }
300
+ };
451
301
  </script>
452
302
  ```
453
303
 
@@ -461,6 +311,8 @@ import {
461
311
  validateInput,
462
312
  encodeHtmlEntities,
463
313
  decodeHtmlEntities,
314
+ sanitizeFileName,
315
+ containsDangerousPatterns,
464
316
  } from '@idds/vue';
465
317
 
466
318
  // Sanitize user input
@@ -476,7 +328,11 @@ if (!validation.isValid) {
476
328
  ### File Validation
477
329
 
478
330
  ```js
479
- import { validateFile, validateMagicNumber, formatFileSize } from '@idds/vue';
331
+ import {
332
+ validateFile,
333
+ validateFileMagicNumber,
334
+ formatFileSize,
335
+ } from '@idds/vue';
480
336
 
481
337
  // Validate file
482
338
  const result = validateFile(file, {
@@ -484,75 +340,21 @@ const result = validateFile(file, {
484
340
  maxSize: 5 * 1024 * 1024, // 5MB
485
341
  });
486
342
 
487
- // Validate magic number (file signature)
488
- const magicResult = await validateMagicNumber(file, 'image/png');
489
-
490
343
  // Format file size
491
344
  const formatted = formatFileSize(1024 * 1024); // "1 MB"
492
345
  ```
493
346
 
494
- ## Styling
495
-
496
- ### CSS Classes
497
-
498
- Components use BEM-like naming conventions:
499
-
500
- - `ina-button` - Base button class
501
- - `ina-button--primary` - Primary variant
502
- - `ina-button--disabled` - Disabled state
503
- - `ina-text-field` - Text field component
504
- - `ina-text-field__input` - Input element
505
- - `ina-text-field__label` - Label element
506
-
507
- ### Custom Styling
508
-
509
- You can override component styles using CSS:
510
-
511
- ```css
512
- .ina-button--primary {
513
- background-color: your-custom-color;
514
- }
515
- ```
347
+ ### Styling
516
348
 
517
- ### Using with Tailwind CSS (Optional)
518
-
519
- If you want to use Tailwind CSS utility classes alongside the design system:
520
-
521
- 1. Install Tailwind CSS in your project
522
- 2. Import color tokens:
523
-
524
- ```js
525
- // tailwind.config.js
526
- import iddsColorTokens from '@idds/vue';
527
-
528
- export default {
529
- theme: {
530
- extend: {
531
- colors: iddsColorTokens,
532
- },
533
- },
534
- };
535
- ```
536
-
537
- 3. Use Tailwind classes for custom styling:
538
-
539
- ```vue
540
- <template>
541
- <div class="bg-blue-500 text-white p-4">
542
- <Button>Click me</Button>
543
- </div>
544
- </template>
545
- ```
546
-
547
- > **Note:** Tailwind CSS is **optional**. The design system works perfectly without it. Components are fully styled and functional using only the included CSS.
349
+ 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**.
548
350
 
549
351
  ## TypeScript Support
550
352
 
551
- All components are fully typed with TypeScript:
353
+ All components are fully typed with TypeScript, exporting interfaces for Props and their related strict Types:
552
354
 
553
355
  ```vue
554
356
  <script setup lang="ts">
555
- import { TextField, type TextFieldProps } from '@idds/vue';
357
+ import { TextField, type TextFieldProps, type TextFieldSize } from '@idds/vue';
556
358
 
557
359
  const props: TextFieldProps = {
558
360
  modelValue: '',
@@ -561,25 +363,6 @@ const props: TextFieldProps = {
561
363
  </script>
562
364
  ```
563
365
 
564
- ## Development
565
-
566
- ```bash
567
- # Install dependencies
568
- npm install
569
-
570
- # Start development server
571
- npm run dev
572
-
573
- # Build for production
574
- npm run build
575
-
576
- # Type checking
577
- npm run type-check
578
-
579
- # Linting
580
- npm run lint
581
- ```
582
-
583
366
  ## License
584
367
 
585
368
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idds/vue",
3
- "version": "1.6.13",
3
+ "version": "1.6.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -63,7 +63,7 @@
63
63
  "vue-tsc": "^2.0.6"
64
64
  },
65
65
  "dependencies": {
66
- "@idds/styles": "^1.6.13",
66
+ "@idds/styles": "^1.6.15",
67
67
  "clsx": "^2.1.1"
68
68
  }
69
69
  }