design-system-next 2.11.17 → 2.11.19

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 (94) hide show
  1. package/dist/design-system-next.es.js +6885 -6987
  2. package/dist/design-system-next.es.js.gz +0 -0
  3. package/dist/design-system-next.umd.js +12 -12
  4. package/dist/design-system-next.umd.js.gz +0 -0
  5. package/dist/main.css +1 -1
  6. package/dist/main.css.gz +0 -0
  7. package/dist/package.json.d.ts +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/scripts/border-radius.ts +15 -15
  10. package/src/assets/scripts/colors.ts +134 -134
  11. package/src/assets/scripts/max-width.ts +11 -11
  12. package/src/assets/scripts/spacing.ts +23 -23
  13. package/src/assets/scripts/utilities.ts +15 -15
  14. package/src/assets/styles/tailwind.css +6 -18
  15. package/src/components/accordion/accordion.ts +43 -43
  16. package/src/components/accordion/use-accordion.ts +43 -43
  17. package/src/components/avatar/avatar.ts +64 -64
  18. package/src/components/badge/badge.ts +43 -43
  19. package/src/components/banner/banner.ts +20 -20
  20. package/src/components/button/button.ts +72 -72
  21. package/src/components/button/button.vue +15 -15
  22. package/src/components/calendar/calendar.ts +89 -89
  23. package/src/components/card/card.ts +52 -52
  24. package/src/components/checkbox/checkbox.ts +45 -45
  25. package/src/components/chips/chips.ts +95 -95
  26. package/src/components/collapsible/collapsible.ts +21 -21
  27. package/src/components/collapsible/collapsible.vue +27 -27
  28. package/src/components/date-picker/__tests__/date-picker.test.ts +112 -112
  29. package/src/components/date-picker/date-picker.ts +157 -157
  30. package/src/components/dropdown/__tests__/dropdown-fixes.spec.ts +106 -106
  31. package/src/components/dropdown/__tests__/dropdown-value-types.spec.ts +213 -213
  32. package/src/components/dropdown/dropdown.ts +4 -0
  33. package/src/components/dropdown/dropdown.vue +2 -0
  34. package/src/components/dropdown/fix-multi-number.ts +92 -92
  35. package/src/components/dropdown/use-dropdown.ts +488 -488
  36. package/src/components/empty-state/empty-state.ts +50 -50
  37. package/src/components/file-upload/file-upload.ts +87 -87
  38. package/src/components/floating-action/floating-action.ts +12 -12
  39. package/src/components/input/input-contact-number/input-contact-number.ts +83 -83
  40. package/src/components/input/input-email/input-email.vue +17 -17
  41. package/src/components/input/input-password/use-input-password.ts +19 -19
  42. package/src/components/input/input-search/input-search.vue +13 -13
  43. package/src/components/input/input-url/input-url.vue +20 -20
  44. package/src/components/input/input-username/input-username.vue +17 -17
  45. package/src/components/input/input.vue +72 -72
  46. package/src/components/list/ladderized-list/ladderized-list.ts +39 -39
  47. package/src/components/list/list.ts +4 -0
  48. package/src/components/list/list.vue +33 -24
  49. package/src/components/logo/logo.ts +43 -43
  50. package/src/components/logo/logo.vue +14 -14
  51. package/src/components/logo/use-logo.ts +41 -41
  52. package/src/components/lozenge/lozenge.ts +61 -61
  53. package/src/components/modal/modal.ts +45 -45
  54. package/src/components/progress-bar/progress-bar.ts +39 -39
  55. package/src/components/radio/radio.ts +42 -42
  56. package/src/components/select/select.ts +144 -144
  57. package/src/components/sidenav/sidenav.ts +172 -173
  58. package/src/components/sidenav/sidenav.vue +211 -126
  59. package/src/components/sidenav/use-sidenav.ts +85 -76
  60. package/src/components/sidepanel/sidepanel.ts +104 -100
  61. package/src/components/sidepanel/sidepanel.vue +55 -55
  62. package/src/components/sidepanel/stacking-sidepanel/stacking-sidepanel.ts +16 -16
  63. package/src/components/sidepanel/stacking-sidepanel/stacking-sidepanel.vue +39 -39
  64. package/src/components/sidepanel/use-sidepanel.ts +5 -2
  65. package/src/components/slider/slider.ts +38 -38
  66. package/src/components/snackbar/snack/snack.ts +71 -71
  67. package/src/components/snackbar/use-snackbar.ts +34 -34
  68. package/src/components/status/status.ts +19 -19
  69. package/src/components/status/status.vue +13 -13
  70. package/src/components/stepper/step/step.ts +47 -47
  71. package/src/components/stepper/stepper.ts +47 -47
  72. package/src/components/stepper/stepper.vue +34 -34
  73. package/src/components/switch/switch.ts +42 -42
  74. package/src/components/table/table-actions/table-actions.ts +42 -42
  75. package/src/components/table/table-actions/table-actions.vue +40 -40
  76. package/src/components/table/table-chips-title/table-chips-title.ts +27 -27
  77. package/src/components/table/table-chips-title/table-chips-title.vue +32 -32
  78. package/src/components/table/table-chips-title/use-table-chips-title.ts +22 -22
  79. package/src/components/table/table-lozenge-title/table-lozenge-title.ts +23 -23
  80. package/src/components/table/table-lozenge-title/table-lozenge-title.vue +26 -26
  81. package/src/components/table/table-lozenge-title/use-table-lozenge-title.ts +21 -21
  82. package/src/components/table/table-pagination/table-pagination.ts +63 -63
  83. package/src/components/table/table-pagination/table-pagination.vue +72 -72
  84. package/src/components/table/table.ts +173 -173
  85. package/src/components/tabs/tabs.ts +43 -43
  86. package/src/components/textarea/textarea.ts +72 -72
  87. package/src/components/textarea/textarea.vue +45 -45
  88. package/src/components/time-picker/time-picker.ts +69 -69
  89. package/src/components/tooltip/tooltip.ts +44 -46
  90. package/src/components/tooltip/tooltip.vue +4 -1
  91. package/src/components/tooltip/use-tooltip.ts +13 -13
  92. package/src/examples/dropdown-number-multi-select.vue +76 -76
  93. package/src/stores/useSnackbarStore.ts +44 -44
  94. package/src/vite-env.d.ts +0 -6
@@ -1,134 +1,134 @@
1
- /*
2
- Toge Design System v3.0 - Color Scheme
3
- (https://www.figma.com/design/tlGkN8uKvxVIHB1FgYRIaF/%F0%9F%8C%B1-Toge-Styles-3.0?node-id=2281-4697&node-type=section&m=dev)
4
- */
5
-
6
- type ColorShadesTypes = {
7
- [key: number]: string;
8
- };
9
-
10
- type ColorPaletteTypes = {
11
- [colorName: string]: ColorShadesTypes;
12
- };
13
-
14
- const colorScheme: ColorPaletteTypes = {
15
- white: {
16
- 50: '#FFFFFF',
17
- 100: '#F1F2F3',
18
- 200: '#DBDBDD',
19
- 300: '#BABCC0',
20
- 400: '#989898',
21
- 500: '#7C7C7C',
22
- 600: '#656565',
23
- 700: '#525252',
24
- 800: '#464646',
25
- 900: '#3D3D3D',
26
- 950: '#292929',
27
- },
28
- mushroom: {
29
- 50: '#EFF1F1',
30
- 100: '#E6EAEA',
31
- 200: '#D9DEDE',
32
- 300: '#B8C1C0',
33
- 400: '#919F9D',
34
- 500: '#738482',
35
- 600: '#5D6C6B',
36
- 700: '#4C5857',
37
- 800: '#414B4B',
38
- 900: '#394141',
39
- 950: '#262B2B',
40
- },
41
- tomato: {
42
- 50: '#FEF2F3',
43
- 100: '#FEE2E3',
44
- 200: '#FDCBCE',
45
- 300: '#FBA6AA',
46
- 400: '#F6737A',
47
- 500: '#EC4750',
48
- 600: '#DA2F38',
49
- 700: '#B61F27',
50
- 800: '#971D23',
51
- 900: '#7D1F24',
52
- 950: '#440B0E',
53
- },
54
- carrot: {
55
- 50: '#FFFAEC',
56
- 100: '#FFF4D3',
57
- 200: '#FFE5A5',
58
- 300: '#FFD16D',
59
- 400: '#FFB132',
60
- 500: '#FF970A',
61
- 600: '#FF7F00',
62
- 700: '#CC5C02',
63
- 800: '#A1470B',
64
- 900: '#823C0C',
65
- 950: '#461C04',
66
- },
67
- mango: {
68
- 50: '#FFFFEA',
69
- 100: '#FFFBC5',
70
- 200: '#FFF885',
71
- 300: '#FFED46',
72
- 400: '#FFDF1B',
73
- 500: '#FFBF00',
74
- 600: '#E29300',
75
- 700: '#BB6802',
76
- 800: '#985008',
77
- 900: '#7C420B',
78
- 950: '#482200',
79
- },
80
- kangkong: {
81
- 50: '#F0FDF4',
82
- 100: '#DCFCE6',
83
- 200: '#BBF7CE',
84
- 300: '#86EFA8',
85
- 400: '#4ADE7B',
86
- 500: '#22C558',
87
- 600: '#17AD49',
88
- 700: '#158039',
89
- 800: '#166531',
90
- 900: '#14532B',
91
- 950: '#052E15',
92
- },
93
- wintermelon: {
94
- 50: '#ECFEFF',
95
- 100: '#CEFBFF',
96
- 200: '#A3F3FE',
97
- 300: '#64E9FC',
98
- 400: '#1ED5F2',
99
- 500: '#02AFCE',
100
- 600: '#0592B5',
101
- 700: '#0C7492',
102
- 800: '#135E77',
103
- 900: '#154E64',
104
- 950: '#073345',
105
- },
106
- blueberry: {
107
- 50: '#EEF7FF',
108
- 100: '#D8EBFF',
109
- 200: '#BADCFF',
110
- 300: '#8BBDFF',
111
- 400: '#549EFF',
112
- 500: '#2D88FF',
113
- 600: '#1679FA',
114
- 700: '#0F6EEB',
115
- 800: '#1356BA',
116
- 900: '#164B92',
117
- 950: '#122E59',
118
- },
119
- ubas: {
120
- 50: '#F5F3FF',
121
- 100: '#EEE9FE',
122
- 200: '#DED6FE',
123
- 300: '#C6B5FD',
124
- 400: '#AA8BFA',
125
- 500: '#8952F6',
126
- 600: '#8139EE',
127
- 700: '#7227DA',
128
- 800: '#5F21B6',
129
- 900: '#501D95',
130
- 950: '#311065',
131
- },
132
- };
133
- export type { ColorShadesTypes, ColorPaletteTypes };
134
- export default colorScheme;
1
+ /*
2
+ Toge Design System v3.0 - Color Scheme
3
+ (https://www.figma.com/design/tlGkN8uKvxVIHB1FgYRIaF/%F0%9F%8C%B1-Toge-Styles-3.0?node-id=2281-4697&node-type=section&m=dev)
4
+ */
5
+
6
+ type ColorShadesTypes = {
7
+ [key: number]: string;
8
+ };
9
+
10
+ type ColorPaletteTypes = {
11
+ [colorName: string]: ColorShadesTypes;
12
+ };
13
+
14
+ const colorScheme: ColorPaletteTypes = {
15
+ white: {
16
+ 50: '#FFFFFF',
17
+ 100: '#F1F2F3',
18
+ 200: '#DBDBDD',
19
+ 300: '#BABCC0',
20
+ 400: '#989898',
21
+ 500: '#7C7C7C',
22
+ 600: '#656565',
23
+ 700: '#525252',
24
+ 800: '#464646',
25
+ 900: '#3D3D3D',
26
+ 950: '#292929',
27
+ },
28
+ mushroom: {
29
+ 50: '#EFF1F1',
30
+ 100: '#E6EAEA',
31
+ 200: '#D9DEDE',
32
+ 300: '#B8C1C0',
33
+ 400: '#919F9D',
34
+ 500: '#738482',
35
+ 600: '#5D6C6B',
36
+ 700: '#4C5857',
37
+ 800: '#414B4B',
38
+ 900: '#394141',
39
+ 950: '#262B2B',
40
+ },
41
+ tomato: {
42
+ 50: '#FEF2F3',
43
+ 100: '#FEE2E3',
44
+ 200: '#FDCBCE',
45
+ 300: '#FBA6AA',
46
+ 400: '#F6737A',
47
+ 500: '#EC4750',
48
+ 600: '#DA2F38',
49
+ 700: '#B61F27',
50
+ 800: '#971D23',
51
+ 900: '#7D1F24',
52
+ 950: '#440B0E',
53
+ },
54
+ carrot: {
55
+ 50: '#FFFAEC',
56
+ 100: '#FFF4D3',
57
+ 200: '#FFE5A5',
58
+ 300: '#FFD16D',
59
+ 400: '#FFB132',
60
+ 500: '#FF970A',
61
+ 600: '#FF7F00',
62
+ 700: '#CC5C02',
63
+ 800: '#A1470B',
64
+ 900: '#823C0C',
65
+ 950: '#461C04',
66
+ },
67
+ mango: {
68
+ 50: '#FFFFEA',
69
+ 100: '#FFFBC5',
70
+ 200: '#FFF885',
71
+ 300: '#FFED46',
72
+ 400: '#FFDF1B',
73
+ 500: '#FFBF00',
74
+ 600: '#E29300',
75
+ 700: '#BB6802',
76
+ 800: '#985008',
77
+ 900: '#7C420B',
78
+ 950: '#482200',
79
+ },
80
+ kangkong: {
81
+ 50: '#F0FDF4',
82
+ 100: '#DCFCE6',
83
+ 200: '#BBF7CE',
84
+ 300: '#86EFA8',
85
+ 400: '#4ADE7B',
86
+ 500: '#22C558',
87
+ 600: '#17AD49',
88
+ 700: '#158039',
89
+ 800: '#166531',
90
+ 900: '#14532B',
91
+ 950: '#052E15',
92
+ },
93
+ wintermelon: {
94
+ 50: '#ECFEFF',
95
+ 100: '#CEFBFF',
96
+ 200: '#A3F3FE',
97
+ 300: '#64E9FC',
98
+ 400: '#1ED5F2',
99
+ 500: '#02AFCE',
100
+ 600: '#0592B5',
101
+ 700: '#0C7492',
102
+ 800: '#135E77',
103
+ 900: '#154E64',
104
+ 950: '#073345',
105
+ },
106
+ blueberry: {
107
+ 50: '#EEF7FF',
108
+ 100: '#D8EBFF',
109
+ 200: '#BADCFF',
110
+ 300: '#8BBDFF',
111
+ 400: '#549EFF',
112
+ 500: '#2D88FF',
113
+ 600: '#1679FA',
114
+ 700: '#0F6EEB',
115
+ 800: '#1356BA',
116
+ 900: '#164B92',
117
+ 950: '#122E59',
118
+ },
119
+ ubas: {
120
+ 50: '#F5F3FF',
121
+ 100: '#EEE9FE',
122
+ 200: '#DED6FE',
123
+ 300: '#C6B5FD',
124
+ 400: '#AA8BFA',
125
+ 500: '#8952F6',
126
+ 600: '#8139EE',
127
+ 700: '#7227DA',
128
+ 800: '#5F21B6',
129
+ 900: '#501D95',
130
+ 950: '#311065',
131
+ },
132
+ };
133
+ export type { ColorShadesTypes, ColorPaletteTypes };
134
+ export default colorScheme;
@@ -1,11 +1,11 @@
1
- type MaxWidthTypes = {
2
- [key: string]: string;
3
- };
4
-
5
- const maxWidth: MaxWidthTypes = {
6
- 'sm': '640px',
7
- 'md': '1000px',
8
- 'lg': '1320px',
9
- };
10
-
11
- export default maxWidth;
1
+ type MaxWidthTypes = {
2
+ [key: string]: string;
3
+ };
4
+
5
+ const maxWidth: MaxWidthTypes = {
6
+ 'sm': '640px',
7
+ 'md': '1000px',
8
+ 'lg': '1320px',
9
+ };
10
+
11
+ export default maxWidth;
@@ -1,23 +1,23 @@
1
- type spacingTypes = {
2
- [key: string]: string;
3
- };
4
-
5
- const spacing: spacingTypes = {
6
- 'size-spacing-6xs': 'var(--size-50)',
7
- 'size-spacing-5xs': 'var(--size-100)',
8
- 'size-spacing-4xs': 'var(--size-150)',
9
- 'size-spacing-3xs': 'var(--size-200)',
10
- 'size-spacing-2xs': 'var(--size-250)',
11
- 'size-spacing-xs': 'var(--size-300)',
12
- 'size-spacing-sm': 'var(--size-400)',
13
- 'size-spacing-md': 'var(--size-500)',
14
- 'size-spacing-lg': 'var(--size-600)',
15
- 'size-spacing-xl': 'var(--size-700)',
16
- 'size-spacing-2xl': 'var(--size-800)',
17
- 'size-spacing-3xl': 'var(--size-900)',
18
- 'size-spacing-4xl': 'var(--size-1000)',
19
- 'size-spacing-5xl': 'var(--size-1100)',
20
- 'size-spacing-6xl': 'var(--size-1200)',
21
- };
22
-
23
- export default spacing;
1
+ type spacingTypes = {
2
+ [key: string]: string;
3
+ };
4
+
5
+ const spacing: spacingTypes = {
6
+ 'size-spacing-6xs': 'var(--size-50)',
7
+ 'size-spacing-5xs': 'var(--size-100)',
8
+ 'size-spacing-4xs': 'var(--size-150)',
9
+ 'size-spacing-3xs': 'var(--size-200)',
10
+ 'size-spacing-2xs': 'var(--size-250)',
11
+ 'size-spacing-xs': 'var(--size-300)',
12
+ 'size-spacing-sm': 'var(--size-400)',
13
+ 'size-spacing-md': 'var(--size-500)',
14
+ 'size-spacing-lg': 'var(--size-600)',
15
+ 'size-spacing-xl': 'var(--size-700)',
16
+ 'size-spacing-2xl': 'var(--size-800)',
17
+ 'size-spacing-3xl': 'var(--size-900)',
18
+ 'size-spacing-4xl': 'var(--size-1000)',
19
+ 'size-spacing-5xl': 'var(--size-1100)',
20
+ 'size-spacing-6xl': 'var(--size-1200)',
21
+ };
22
+
23
+ export default spacing;
@@ -1,15 +1,15 @@
1
- type utilitiesTypes = {
2
- [key: string]: {
3
- backgroundColor?: string;
4
- opacity?: string;
5
- };
6
- };
7
-
8
- const utilities: utilitiesTypes = {
9
- 'bg-overlay': {
10
- backgroundColor: '#4C5857',
11
- opacity: '0.6',
12
- },
13
- };
14
-
15
- export default utilities;
1
+ type utilitiesTypes = {
2
+ [key: string]: {
3
+ backgroundColor?: string;
4
+ opacity?: string;
5
+ };
6
+ };
7
+
8
+ const utilities: utilitiesTypes = {
9
+ 'bg-overlay': {
10
+ backgroundColor: '#4C5857',
11
+ opacity: '0.6',
12
+ },
13
+ };
14
+
15
+ export default utilities;
@@ -48,21 +48,21 @@
48
48
  @apply spr-max-h-[500px] spr-w-[215px];
49
49
  }
50
50
 
51
- #sidenav-submenu-wrapper {
51
+ #sidenav-submenu-l1-wrapper {
52
52
  @apply spr-max-h-[500px] spr-w-[215px];
53
53
  }
54
54
 
55
- #user-menu-wrapper {
56
- @apply !spr-top-[-20px] spr-max-h-[500px] spr-w-[300px];
55
+ #sidenav-submenu-l2-wrapper {
56
+ @apply spr-hidden;
57
57
  }
58
58
 
59
- #sidenav-sub-submenu-wrapper {
60
- @apply spr-hidden;
59
+ #user-menu-wrapper {
60
+ @apply !spr-top-[-20px] spr-max-h-[500px] spr-w-[300px];
61
61
  }
62
62
 
63
63
  #quick-action-menu-wrapper,
64
64
  #sidenav-menu-wrapper,
65
- #sidenav-submenu-wrapper,
65
+ #sidenav-submenu-l1-wrapper,
66
66
  #user-menu-wrapper {
67
67
  @apply spr-background-color spr-border-color-base spr-overflow-y-auto spr-overflow-x-hidden spr-rounded-[12px] spr-border spr-border-solid spr-drop-shadow-md;
68
68
 
@@ -121,18 +121,6 @@
121
121
  }
122
122
  }
123
123
  }
124
-
125
- #sidenav-tooltip-wrapper {
126
- .v-popper__wrapper {
127
- .v-popper__inner {
128
- @apply spr-label-xs spr-background-color-inverted spr-rounded-border-radius-md spr-px-2 spr-py-1.5 spr-font-main spr-opacity-100;
129
- }
130
-
131
- .v-popper__arrow-outer {
132
- @apply spr-hidden;
133
- }
134
- }
135
- }
136
124
  /* #endregion - Tooltips */
137
125
 
138
126
  /* #region - Dropdown */
@@ -1,43 +1,43 @@
1
- import type { PropType, ExtractPropTypes } from 'vue';
2
-
3
- const ACCORDION_TRIGGER = ['header', 'button'] as const;
4
-
5
- export interface AccordionItem {
6
- title: string;
7
- subtitle?: string;
8
- collapseId: string;
9
- }
10
-
11
- /**
12
- * Defines the prop types for the Accordion component.
13
- *
14
- * @property accordionItems - An array of accordion items. This property is required and defaults to an empty array.
15
- * @property alwaysOpen - A boolean indicating whether multiple accordion items can be open at the same time. Defaults to `false`.
16
- * @property isDefaultOpen - A boolean indicating whether the accordion is open by default. Defaults to `false`. Won't work if alwaysOpen is false.
17
- */
18
- export const accordionPropTypes = {
19
- accordionItems: {
20
- type: Array as PropType<AccordionItem[]>,
21
- required: true,
22
- default: () => [],
23
- },
24
- alwaysOpen: {
25
- type: Boolean,
26
- default: false,
27
- },
28
- isDefaultOpen: {
29
- type: Boolean,
30
- default: false
31
- },
32
- accordionTrigger: {
33
- type: String,
34
- validator: (value: (typeof ACCORDION_TRIGGER)[number]) => ACCORDION_TRIGGER.includes(value),
35
- default: 'button'
36
- },
37
- bordered: {
38
- type: Boolean,
39
- default: true
40
- }
41
- }
42
-
43
- export type AccordionPropTypes = ExtractPropTypes<typeof accordionPropTypes>;
1
+ import type { PropType, ExtractPropTypes } from 'vue';
2
+
3
+ const ACCORDION_TRIGGER = ['header', 'button'] as const;
4
+
5
+ export interface AccordionItem {
6
+ title: string;
7
+ subtitle?: string;
8
+ collapseId: string;
9
+ }
10
+
11
+ /**
12
+ * Defines the prop types for the Accordion component.
13
+ *
14
+ * @property accordionItems - An array of accordion items. This property is required and defaults to an empty array.
15
+ * @property alwaysOpen - A boolean indicating whether multiple accordion items can be open at the same time. Defaults to `false`.
16
+ * @property isDefaultOpen - A boolean indicating whether the accordion is open by default. Defaults to `false`. Won't work if alwaysOpen is false.
17
+ */
18
+ export const accordionPropTypes = {
19
+ accordionItems: {
20
+ type: Array as PropType<AccordionItem[]>,
21
+ required: true,
22
+ default: () => [],
23
+ },
24
+ alwaysOpen: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+ isDefaultOpen: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ accordionTrigger: {
33
+ type: String,
34
+ validator: (value: (typeof ACCORDION_TRIGGER)[number]) => ACCORDION_TRIGGER.includes(value),
35
+ default: 'button'
36
+ },
37
+ bordered: {
38
+ type: Boolean,
39
+ default: true
40
+ }
41
+ }
42
+
43
+ export type AccordionPropTypes = ExtractPropTypes<typeof accordionPropTypes>;
@@ -1,43 +1,43 @@
1
-
2
- import type { AccordionPropTypes } from './accordion';
3
- import { toRefs, reactive, ref } from 'vue';
4
-
5
- export const useAccordion = (props: AccordionPropTypes) => {
6
- const { accordionItems, isDefaultOpen, alwaysOpen } = toRefs(props);
7
- const clickedIndex = ref<number>()
8
-
9
- const collapsedState = reactive(accordionItems.value.map(() => isDefaultOpen.value && alwaysOpen.value));
10
-
11
- const toggleCollapse = (index: number) => {
12
- if (index < 0 || index >= collapsedState.length) return;
13
-
14
- collapsedState[index] = !collapsedState[index];
15
-
16
- if (!props.alwaysOpen) {
17
- collapsedState.forEach((_, i) => {
18
- if (i !== index) {
19
- collapsedState[i] = false;
20
- }
21
- });
22
- }
23
- };
24
-
25
- const setClickedIndex = (index: number) => {
26
- clickedIndex.value = index
27
- }
28
-
29
- const clearIndex = () => {
30
- clickedIndex.value = undefined
31
- }
32
-
33
- return {
34
- accordionItems,
35
- isDefaultOpen,
36
- alwaysOpen,
37
- collapsedState,
38
- toggleCollapse,
39
- setClickedIndex,
40
- clearIndex,
41
- clickedIndex
42
- }
43
- };
1
+
2
+ import type { AccordionPropTypes } from './accordion';
3
+ import { toRefs, reactive, ref } from 'vue';
4
+
5
+ export const useAccordion = (props: AccordionPropTypes) => {
6
+ const { accordionItems, isDefaultOpen, alwaysOpen } = toRefs(props);
7
+ const clickedIndex = ref<number>()
8
+
9
+ const collapsedState = reactive(accordionItems.value.map(() => isDefaultOpen.value && alwaysOpen.value));
10
+
11
+ const toggleCollapse = (index: number) => {
12
+ if (index < 0 || index >= collapsedState.length) return;
13
+
14
+ collapsedState[index] = !collapsedState[index];
15
+
16
+ if (!props.alwaysOpen) {
17
+ collapsedState.forEach((_, i) => {
18
+ if (i !== index) {
19
+ collapsedState[i] = false;
20
+ }
21
+ });
22
+ }
23
+ };
24
+
25
+ const setClickedIndex = (index: number) => {
26
+ clickedIndex.value = index
27
+ }
28
+
29
+ const clearIndex = () => {
30
+ clickedIndex.value = undefined
31
+ }
32
+
33
+ return {
34
+ accordionItems,
35
+ isDefaultOpen,
36
+ alwaysOpen,
37
+ collapsedState,
38
+ toggleCollapse,
39
+ setClickedIndex,
40
+ clearIndex,
41
+ clickedIndex
42
+ }
43
+ };