@volverjs/ui-vue 0.0.10-beta.22 → 0.0.10-beta.24

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 (89) hide show
  1. package/dist/components/VvAccordion/VvAccordion.es.js +119 -79
  2. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +18 -4
  4. package/dist/components/VvAccordion/index.d.ts +4 -8
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +250 -119
  6. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  7. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +18 -6
  8. package/dist/components/VvAccordionGroup/index.d.ts +3 -1
  9. package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
  11. package/dist/components/VvButton/VvButton.es.js +92 -98
  12. package/dist/components/VvButton/VvButton.umd.js +1 -1
  13. package/dist/components/VvButton/VvButton.vue.d.ts +7 -7
  14. package/dist/components/VvButton/index.d.ts +11 -11
  15. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -13
  16. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  17. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +3 -3
  18. package/dist/components/VvCheckbox/VvCheckbox.es.js +81 -87
  19. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  20. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +6 -6
  21. package/dist/components/VvCheckbox/index.d.ts +2 -2
  22. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +15 -29
  23. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  24. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +5 -5
  25. package/dist/components/VvCombobox/VvCombobox.es.js +13 -16
  26. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  27. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +11 -11
  28. package/dist/components/VvCombobox/index.d.ts +1 -1
  29. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +5 -5
  30. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
  31. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
  32. package/dist/components/VvDropdown/index.d.ts +1 -1
  33. package/dist/components/VvInputFile/VvInputFile.es.js +199 -169
  34. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  35. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +55 -9
  36. package/dist/components/VvInputFile/index.d.ts +24 -3
  37. package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
  38. package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
  39. package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
  40. package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
  41. package/dist/components/VvRadio/VvRadio.es.js +64 -70
  42. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  43. package/dist/components/VvRadio/VvRadio.vue.d.ts +6 -6
  44. package/dist/components/VvRadio/index.d.ts +6 -6
  45. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +15 -29
  46. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  47. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +5 -5
  48. package/dist/components/VvSelect/VvSelect.vue.d.ts +8 -8
  49. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +5 -5
  50. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +3 -3
  51. package/dist/components/VvTooltip/index.d.ts +1 -1
  52. package/dist/components/index.es.js +478 -324
  53. package/dist/components/index.umd.js +1 -1
  54. package/dist/composables/alert/useInjectAlert.d.ts +1 -6
  55. package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
  56. package/dist/composables/group/useProvideGroupState.d.ts +3 -3
  57. package/dist/constants.d.ts +6 -10
  58. package/dist/icons.es.js +3 -3
  59. package/dist/icons.umd.js +1 -1
  60. package/dist/index.es.js +3 -2
  61. package/dist/index.umd.js +1 -1
  62. package/dist/props/index.d.ts +1 -1
  63. package/dist/resolvers/unplugin.es.js +3 -2
  64. package/dist/resolvers/unplugin.umd.js +1 -1
  65. package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +38 -14
  66. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +259 -101
  67. package/dist/types/group.d.ts +37 -15
  68. package/package.json +37 -36
  69. package/src/assets/icons/detailed.json +1 -1
  70. package/src/assets/icons/normal.json +1 -1
  71. package/src/assets/icons/simple.json +1 -1
  72. package/src/components/VvAccordion/VvAccordion.vue +119 -56
  73. package/src/components/VvAccordion/index.ts +8 -23
  74. package/src/components/VvAccordionGroup/VvAccordionGroup.vue +140 -41
  75. package/src/components/VvAccordionGroup/index.ts +3 -1
  76. package/src/components/VvButton/index.ts +7 -12
  77. package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
  78. package/src/components/VvCheckbox/index.ts +2 -2
  79. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
  80. package/src/components/VvInputFile/VvInputFile.vue +72 -47
  81. package/src/components/VvInputFile/index.ts +22 -3
  82. package/src/components/VvRadio/index.ts +5 -5
  83. package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
  84. package/src/composables/group/useInjectedGroupState.ts +20 -16
  85. package/src/composables/group/useProvideGroupState.ts +10 -15
  86. package/src/constants.ts +19 -14
  87. package/src/stories/AccordionGroup/AccordionGroup.test.ts +15 -9
  88. package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
  89. package/src/types/group.ts +22 -14
@@ -12,65 +12,114 @@
12
12
  const props = defineProps(VvAccordionProps)
13
13
  const attrs = useAttrs()
14
14
  const emit = defineEmits(VvAccordionEvents)
15
+ const modelValue = useVModel(props, 'modelValue', emit)
15
16
 
16
17
  // data
17
18
  const accordionName = computed(
18
19
  () => props.name || (attrs?.id as string) || uid(),
19
20
  )
20
- const {
21
- modifiers,
22
- title,
23
- content,
24
- disabled,
25
- collapse,
21
+ const { title, content, not } = toRefs(props)
22
+ const { isInGroup, modifiers, disabled, bus } = useGroupProps(props)
23
+
24
+ // state
25
+ const isExpanded = ref(false)
26
+ watch(
26
27
  modelValue,
27
- isInGroup,
28
- not,
29
- } = useGroupProps(props, emit)
30
- const localModelValue = ref(false)
31
- const isOpen = computed({
32
- get: () => {
33
- let toReturn = modelValue.value as boolean
34
- if (isInGroup.value) {
35
- if (collapse.value && Array.isArray(modelValue.value)) {
36
- toReturn = modelValue.value.includes(accordionName.value)
37
- } else {
38
- toReturn = modelValue.value === accordionName.value
39
- }
40
- } else if (modelValue.value === undefined) {
41
- // localModelValue is used when the accordion is not in a group
42
- toReturn = localModelValue.value
28
+ (newValue) => {
29
+ if (typeof newValue === 'boolean') {
30
+ isExpanded.value = not.value ? !newValue : newValue
43
31
  }
44
- return not.value ? !toReturn : toReturn
45
32
  },
46
- set: (newValue) => {
47
- if (not.value) {
48
- newValue = !newValue
49
- }
50
- if (isInGroup.value) {
51
- if (collapse.value && Array.isArray(modelValue.value)) {
52
- if (newValue) {
53
- modelValue.value.push(accordionName.value)
54
- return
55
- }
56
- modelValue.value = modelValue.value.filter(
57
- (name: string) => name !== accordionName.value,
58
- )
59
- return
33
+ { immediate: true },
34
+ )
35
+ watch(isExpanded, (newValue) => {
36
+ modelValue.value = not.value ? !newValue : newValue
37
+ })
38
+ bus?.on('toggle', ({ name, value }) => {
39
+ if (name !== accordionName.value) {
40
+ return
41
+ }
42
+ isExpanded.value = value
43
+ })
44
+ const onClick = () => {
45
+ if (disabled.value) {
46
+ return
47
+ }
48
+ if (isInGroup.value) {
49
+ bus?.emit('toggle', {
50
+ name: accordionName.value,
51
+ value: !isExpanded.value,
52
+ })
53
+ return
54
+ }
55
+ isExpanded.value = !isExpanded.value
56
+ }
57
+
58
+ // register / unregister
59
+ watch(
60
+ accordionName,
61
+ (newValue, oldValue) => {
62
+ if (bus) {
63
+ if (oldValue && oldValue !== newValue) {
64
+ bus.emit('unregister', { name: oldValue })
60
65
  }
61
- modelValue.value = newValue ? accordionName.value : null
62
- return
63
- }
64
- // localModelValue is used when the accordion is not in a group
65
- if (
66
- modelValue.value === undefined &&
67
- typeof newValue === 'boolean'
68
- ) {
69
- localModelValue.value = newValue
70
- return
66
+ bus.emit('register', { name: newValue })
71
67
  }
72
- modelValue.value = newValue
73
68
  },
69
+ {
70
+ immediate: true,
71
+ },
72
+ )
73
+ onBeforeUnmount(() => {
74
+ if (bus) {
75
+ bus.emit('unregister', { name: accordionName.value })
76
+ }
77
+ })
78
+
79
+ // methods
80
+ const expand = () => {
81
+ if (isExpanded.value) {
82
+ return
83
+ }
84
+ onClick()
85
+ }
86
+
87
+ const collapse = () => {
88
+ if (!isExpanded.value) {
89
+ return
90
+ }
91
+ onClick()
92
+ }
93
+
94
+ const groupExpand = (name?: string | string[]) => {
95
+ if (!bus) {
96
+ // eslint-disable-next-line no-console
97
+ console.warn(
98
+ `[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`,
99
+ )
100
+ return
101
+ }
102
+ bus.emit('expand', { name })
103
+ }
104
+
105
+ const groupCollapse = (name?: string | string[]) => {
106
+ if (!bus) {
107
+ // eslint-disable-next-line no-console
108
+ console.warn(
109
+ `[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`,
110
+ )
111
+ return
112
+ }
113
+ bus?.emit('collapse', { name })
114
+ }
115
+
116
+ // expose
117
+ defineExpose({
118
+ isExpanded,
119
+ expand,
120
+ collapse,
121
+ groupExpand,
122
+ groupCollapse,
74
123
  })
75
124
 
76
125
  // styles
@@ -81,27 +130,41 @@
81
130
  disabled: disabled.value,
82
131
  })),
83
132
  )
84
-
85
- // methods
86
- const onClick = useToggle(isOpen)
87
133
  </script>
88
134
 
89
135
  <template>
90
- <details :id="accordionName" :class="bemCssClasses" :open="isOpen">
136
+ <details :id="accordionName" :class="bemCssClasses" :open="isExpanded">
91
137
  <summary
92
138
  :aria-controls="accordionName"
93
- :aria-expanded="isOpen"
139
+ :aria-expanded="isExpanded"
94
140
  class="vv-accordion__summary"
95
141
  @click.prevent="onClick()"
96
142
  >
97
143
  <!-- @slot Slot for title -->
98
- <slot name="summary" v-bind="{ open: isOpen }">
144
+ <slot
145
+ name="summary"
146
+ v-bind="{
147
+ isExpanded,
148
+ expand,
149
+ collapse,
150
+ groupExpand,
151
+ groupCollapse,
152
+ }"
153
+ >
99
154
  {{ title }}
100
155
  </slot>
101
156
  </summary>
102
- <div :aria-hidden="!isOpen" class="vv-accordion__content">
157
+ <div :aria-hidden="!isExpanded" class="vv-accordion__content">
103
158
  <!-- @slot Slot for content -->
104
- <slot name="default" v-bind="{ open: isOpen }">
159
+ <slot
160
+ v-bind="{
161
+ isExpanded,
162
+ expand,
163
+ collapse,
164
+ groupExpand,
165
+ groupCollapse,
166
+ }"
167
+ >
105
168
  {{ content }}
106
169
  </slot>
107
170
  </div>
@@ -1,4 +1,4 @@
1
- import type { ExtractPropTypes, Ref } from 'vue'
1
+ import type { ExtractPropTypes } from 'vue'
2
2
  import type { AccordionGroupState } from '../../types/group'
3
3
  import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
4
4
  import { ModifiersProps } from '@/props'
@@ -40,29 +40,19 @@ export type VvAccordionPropsTypes = ExtractPropTypes<typeof VvAccordionProps>
40
40
  /**
41
41
  * Merges local and group props
42
42
  */
43
- export function useGroupProps(
44
- props: VvAccordionPropsTypes,
45
- emit: (event: string, value: unknown) => void,
46
- ) {
47
- const { group, isInGroup, getGroupOrLocalRef } =
48
- useInjectedGroupState<AccordionGroupState>(
49
- INJECTION_KEY_ACCORDION_GROUP,
50
- )
51
-
52
- // local props
53
- const { title, content } = toRefs(props)
43
+ export function useGroupProps(props: VvAccordionPropsTypes) {
44
+ const { group, isInGroup } = useInjectedGroupState<AccordionGroupState>(
45
+ INJECTION_KEY_ACCORDION_GROUP,
46
+ )
54
47
 
55
48
  // group props
56
- const modelValue = getGroupOrLocalRef('modelValue', props, emit)
57
- const not = getGroupOrLocalRef('not', props) as Ref<boolean>
58
- const collapse = getGroupOrLocalRef('collapse', props) as Ref<boolean>
59
49
  const disabled = computed(() =>
60
- Boolean(props.disabled || group?.value?.disabled.value),
50
+ Boolean(props.disabled || group?.disabled.value),
61
51
  )
62
52
  // merge local and group modifiers
63
53
  const modifiers = computed(() => {
64
54
  let localModifiers = props.modifiers
65
- let groupModifiers = group?.value.modifiers.value
55
+ let groupModifiers = group?.modifiers.value
66
56
 
67
57
  const toReturn = new Set<string>()
68
58
  if (localModifiers) {
@@ -82,15 +72,10 @@ export function useGroupProps(
82
72
 
83
73
  return {
84
74
  // group props
85
- modelValue,
86
- not,
87
75
  isInGroup,
88
76
  group,
89
- collapse,
90
77
  modifiers,
91
78
  disabled,
92
- // local props
93
- title,
94
- content,
79
+ bus: group?.bus,
95
80
  }
96
81
  }
@@ -5,8 +5,11 @@
5
5
  </script>
6
6
 
7
7
  <script setup lang="ts">
8
- import type { Ref } from 'vue'
9
- import type { AccordionGroupState } from '../../types/group'
8
+ import mitt from 'mitt'
9
+ import type {
10
+ AccordionGroupState,
11
+ AccordionGroupBusEvents,
12
+ } from '../../types/group'
10
13
  import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
11
14
  import VvAccordion from '../VvAccordion/VvAccordion.vue'
12
15
  import { VvAccordionGroupProps, VvAccordionGroupEvents } from '.'
@@ -16,67 +19,157 @@
16
19
  const emit = defineEmits(VvAccordionGroupEvents)
17
20
 
18
21
  // data
19
- const { disabled, collapse, modifiers, itemModifiers, items, not } =
20
- toRefs(props)
22
+ const { disabled, modifiers, itemModifiers, items } = toRefs(props)
21
23
  watchEffect(() => {
22
- if (typeof props.modelValue === 'string' && collapse.value) {
23
- // eslint-disable-next-line
24
+ if (typeof props.modelValue === 'string' && props.collapse) {
25
+ // eslint-disable-next-line no-console
24
26
  console.warn(
25
27
  `[VvAccordionGroup]: modelValue is a string but collapse is true.`,
26
28
  )
27
29
  }
28
30
  })
29
- let localModelValue: Ref<string[]> = ref([])
31
+
32
+ const accordionNames = reactive(new Set<string>())
33
+ let modelValue = ref(new Set<string>())
30
34
  watch(
31
35
  () => props.storeKey,
32
- (newKey) => {
36
+ (newKey, oldKey) => {
37
+ if (oldKey && oldKey !== newKey) {
38
+ localStorage.removeItem(oldKey)
39
+ }
33
40
  if (newKey) {
34
- localModelValue = useStorage(newKey, localModelValue.value)
35
- } else {
36
- localModelValue = ref([])
41
+ modelValue = useLocalStorage(newKey, modelValue.value)
42
+ return
37
43
  }
44
+ modelValue = ref(new Set<string>(modelValue.value))
38
45
  },
39
46
  { immediate: true },
40
47
  )
41
- const modelValue = computed({
42
- get: () => {
43
- if (props.modelValue !== undefined) {
44
- if (!collapse.value) {
45
- return Array.isArray(props.modelValue)
46
- ? props.modelValue[0]
47
- : props.modelValue
48
- }
49
- return props.modelValue
48
+ watch(
49
+ [modelValue, accordionNames, () => props.not, () => props.collapse],
50
+ () => {
51
+ if (props.not) {
52
+ emit(
53
+ 'update:modelValue',
54
+ [...accordionNames].filter(
55
+ (name) => !modelValue.value.has(name),
56
+ ),
57
+ )
58
+ return
50
59
  }
51
- return !collapse.value
52
- ? localModelValue.value?.[0]
53
- : localModelValue.value
60
+ if (props.collapse) {
61
+ emit('update:modelValue', [...modelValue.value])
62
+ return
63
+ }
64
+ emit('update:modelValue', modelValue.value.values().next().value)
65
+ },
66
+ {
67
+ deep: true,
68
+ immediate: true,
54
69
  },
55
- set: (newValue) => {
56
- if (props.modelValue !== undefined) {
57
- if (
58
- (Array.isArray(props.modelValue) || collapse.value) &&
59
- !Array.isArray(newValue)
60
- ) {
61
- newValue = [newValue]
70
+ )
71
+ watch(
72
+ () => props.modelValue,
73
+ (newValue, oldValue) => {
74
+ if (
75
+ newValue === undefined ||
76
+ newValue === null ||
77
+ JSON.stringify(newValue) === JSON.stringify(oldValue)
78
+ ) {
79
+ return
80
+ }
81
+ let toReturn = new Set<string>()
82
+ if (props.not) {
83
+ if (typeof newValue === 'string') {
84
+ toReturn = new Set<string>(
85
+ [...accordionNames].filter((name) => name !== newValue),
86
+ )
87
+ } else if (Array.isArray(newValue)) {
88
+ toReturn = new Set<string>(
89
+ [...accordionNames].filter(
90
+ (name) => !newValue.includes(name),
91
+ ),
92
+ )
62
93
  }
63
- return emit('update:modelValue', newValue)
94
+ } else if (typeof newValue === 'string') {
95
+ toReturn = new Set<string>([newValue])
96
+ } else if (Array.isArray(newValue)) {
97
+ toReturn = new Set<string>(newValue)
98
+ }
99
+ for (const name of accordionNames) {
100
+ bus.emit('toggle', { name, value: toReturn.has(name) })
64
101
  }
65
- localModelValue.value = Array.isArray(newValue)
66
- ? newValue
67
- : [newValue]
102
+ modelValue.value = toReturn
68
103
  },
69
- })
104
+ {
105
+ immediate: true,
106
+ },
107
+ )
70
108
 
71
109
  // provide
72
- useProvideGroupState<AccordionGroupState>({
73
- key: INJECTION_KEY_ACCORDION_GROUP,
74
- modelValue,
110
+ const bus = mitt<AccordionGroupBusEvents>()
111
+ useProvideGroupState<AccordionGroupState>(INJECTION_KEY_ACCORDION_GROUP, {
75
112
  disabled,
76
- collapse,
77
113
  modifiers: itemModifiers,
78
- not,
114
+ bus,
115
+ })
116
+ bus.on('register', ({ name }) => {
117
+ accordionNames.add(name)
79
118
  })
119
+ bus.on('unregister', ({ name }) => {
120
+ accordionNames.delete(name)
121
+ })
122
+ bus.on('toggle', ({ name, value }) => {
123
+ if (value) {
124
+ if (!props.collapse) {
125
+ for (const item of modelValue.value) {
126
+ if (item !== name) {
127
+ bus.emit('toggle', { name: item, value: false })
128
+ }
129
+ }
130
+ modelValue.value.clear()
131
+ }
132
+ modelValue.value.add(name)
133
+ return
134
+ }
135
+ modelValue.value.delete(name)
136
+ })
137
+ const expand = (name?: string | string[]) => {
138
+ if (typeof name === 'string') {
139
+ bus.emit('toggle', { name, value: true })
140
+ return
141
+ }
142
+ if (Array.isArray(name)) {
143
+ for (const item of name) {
144
+ bus.emit('toggle', { name: item, value: true })
145
+ }
146
+ return
147
+ }
148
+ for (const item of accordionNames) {
149
+ bus.emit('toggle', { name: item, value: true })
150
+ }
151
+ }
152
+ bus.on('expand', ({ name }) => expand(name))
153
+
154
+ const collapse = (name?: string | string[]) => {
155
+ if (typeof name === 'string') {
156
+ bus.emit('toggle', { name, value: false })
157
+ return
158
+ }
159
+ if (Array.isArray(name)) {
160
+ for (const item of name) {
161
+ bus.emit('toggle', { name: item, value: false })
162
+ }
163
+ return
164
+ }
165
+ for (const item of accordionNames) {
166
+ bus.emit('toggle', { name: item, value: false })
167
+ }
168
+ }
169
+ bus.on('collapse', ({ name }) => collapse(name))
170
+
171
+ // expose
172
+ defineExpose({ modelValue, expand, collapse })
80
173
 
81
174
  // styles
82
175
  const bemCssClasses = useModifiers(
@@ -91,7 +184,13 @@
91
184
  <template>
92
185
  <div :class="bemCssClasses">
93
186
  <!-- @slot Default slot -->
94
- <slot>
187
+ <slot
188
+ v-bind="{
189
+ modelValue,
190
+ expand,
191
+ collapse,
192
+ }"
193
+ >
95
194
  <VvAccordion
96
195
  v-for="item in items"
97
196
  :key="item.title"
@@ -13,7 +13,9 @@ export const VvAccordionGroupProps = {
13
13
  /**
14
14
  * VModel
15
15
  */
16
- modelValue: [String, Array],
16
+ modelValue: {
17
+ type: [String, Array] as PropType<string | string[] | undefined>,
18
+ },
17
19
  /**
18
20
  * Accordion items
19
21
  * @type VvAccordionGroupItem
@@ -1,4 +1,4 @@
1
- import type { Ref, PropType, ExtractPropTypes } from 'vue'
1
+ import type { PropType, ExtractPropTypes } from 'vue'
2
2
  import type { ButtonGroupState } from '../../types/group'
3
3
  import {
4
4
  ActionProps,
@@ -77,19 +77,14 @@ export function useGroupProps(
77
77
  const { id, iconPosition, icon, label, pressed } = toRefs(props)
78
78
 
79
79
  // group props
80
- const modelValue = getGroupOrLocalRef('modelValue', props, emit) as Ref<
81
- string | number | boolean | (string | number | boolean)[] | undefined
82
- >
83
- const toggle = getGroupOrLocalRef('toggle', props) as Ref<boolean>
84
- const unselectable = getGroupOrLocalRef(
85
- 'unselectable',
86
- props,
87
- ) as Ref<boolean>
88
- const multiple = computed(() => group?.value.multiple.value ?? false)
80
+ const modelValue = getGroupOrLocalRef('modelValue', props, emit)
81
+ const toggle = getGroupOrLocalRef('toggle', props)
82
+ const unselectable = getGroupOrLocalRef('unselectable', props)
83
+ const multiple = computed(() => group?.multiple.value ?? false)
89
84
  // merge local and group modifiers
90
85
  const modifiers = computed(() => {
91
86
  let localModifiers = props.modifiers
92
- let groupModifiers = group?.value.modifiers.value
87
+ let groupModifiers = group?.modifiers.value
93
88
 
94
89
  const toReturn = new Set<string>()
95
90
  if (localModifiers) {
@@ -107,7 +102,7 @@ export function useGroupProps(
107
102
  return Array.from(toReturn)
108
103
  })
109
104
  const disabled = computed(() =>
110
- Boolean(props.disabled || group?.value?.disabled.value),
105
+ Boolean(props.disabled || group?.disabled.value),
111
106
  )
112
107
 
113
108
  return {
@@ -52,8 +52,7 @@
52
52
  })
53
53
 
54
54
  // provide
55
- useProvideGroupState<ButtonGroupState>({
56
- key: INJECTION_KEY_BUTTON_GROUP,
55
+ useProvideGroupState<ButtonGroupState>(INJECTION_KEY_BUTTON_GROUP, {
57
56
  modelValue,
58
57
  disabled,
59
58
  toggle,
@@ -42,10 +42,10 @@ export function useGroupProps(
42
42
  const valid = getGroupOrLocalRef('valid', props) as Ref<boolean>
43
43
  const invalid = getGroupOrLocalRef('invalid', props) as Ref<boolean>
44
44
  const readonly = computed(() =>
45
- Boolean(props.readonly || group?.value?.readonly.value),
45
+ Boolean(props.readonly || group?.readonly.value),
46
46
  )
47
47
  const disabled = computed(() =>
48
- Boolean(props.disabled || group?.value?.disabled.value),
48
+ Boolean(props.disabled || group?.disabled.value),
49
49
  )
50
50
 
51
51
  return {
@@ -29,8 +29,7 @@
29
29
  const { disabled, readonly, vertical, valid, invalid, modifiers } =
30
30
  toRefs(props)
31
31
 
32
- useProvideGroupState<InputGroupState>({
33
- key: INJECTION_KEY_CHECK_GROUP,
32
+ useProvideGroupState<InputGroupState>(INJECTION_KEY_CHECK_GROUP, {
34
33
  modelValue,
35
34
  disabled,
36
35
  readonly,