@volverjs/ui-vue 0.0.10-beta.23 → 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.
- package/dist/components/VvAccordion/VvAccordion.es.js +119 -79
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +18 -4
- package/dist/components/VvAccordion/index.d.ts +4 -8
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +250 -119
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +18 -6
- package/dist/components/VvAccordionGroup/index.d.ts +3 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +92 -98
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +7 -7
- package/dist/components/VvButton/index.d.ts +11 -11
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +3 -3
- package/dist/components/VvCheckbox/VvCheckbox.es.js +81 -87
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +6 -6
- package/dist/components/VvCheckbox/index.d.ts +2 -2
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +15 -29
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +5 -5
- package/dist/components/VvCombobox/VvCombobox.es.js +13 -16
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +11 -11
- package/dist/components/VvCombobox/index.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +5 -5
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +183 -168
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +16 -9
- package/dist/components/VvInputFile/index.d.ts +12 -3
- package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
- package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +64 -70
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +6 -6
- package/dist/components/VvRadio/index.d.ts +6 -6
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +15 -29
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +5 -5
- package/dist/components/VvSelect/VvSelect.vue.d.ts +8 -8
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +5 -5
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +3 -3
- package/dist/components/VvTooltip/index.d.ts +1 -1
- package/dist/components/index.es.js +462 -323
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useInjectAlert.d.ts +1 -6
- package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
- package/dist/composables/group/useProvideGroupState.d.ts +3 -3
- package/dist/constants.d.ts +6 -10
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +3 -2
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +1 -1
- package/dist/resolvers/unplugin.es.js +3 -2
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +38 -14
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +259 -101
- package/dist/types/group.d.ts +37 -15
- package/package.json +37 -36
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordion/VvAccordion.vue +119 -56
- package/src/components/VvAccordion/index.ts +8 -23
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +140 -41
- package/src/components/VvAccordionGroup/index.ts +3 -1
- package/src/components/VvButton/index.ts +7 -12
- package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
- package/src/components/VvCheckbox/index.ts +2 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
- package/src/components/VvInputFile/VvInputFile.vue +71 -47
- package/src/components/VvInputFile/index.ts +5 -4
- package/src/components/VvRadio/index.ts +5 -5
- package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
- package/src/composables/group/useInjectedGroupState.ts +20 -16
- package/src/composables/group/useProvideGroupState.ts +10 -15
- package/src/constants.ts +19 -14
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +15 -9
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
- package/src/types/group.ts +22 -14
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import VvIcon from '../VvIcon/VvIcon.vue'
|
|
13
13
|
import HintSlotFactory from '../common/HintSlot'
|
|
14
14
|
import { VvInputFileProps, type VvInputFileEvents } from '.'
|
|
15
|
+
import Sortable from 'vuedraggable'
|
|
15
16
|
|
|
16
17
|
// props, emit, slots and attrs
|
|
17
18
|
const props = defineProps(VvInputFileProps)
|
|
@@ -66,17 +67,26 @@
|
|
|
66
67
|
} = HintSlotFactory(propsDefaults, slots)
|
|
67
68
|
|
|
68
69
|
const localModelValue = useVModel(props, 'modelValue', emit)
|
|
69
|
-
const files = computed(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
!(localModelValue.value
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
const files = computed({
|
|
71
|
+
get: () => {
|
|
72
|
+
if (
|
|
73
|
+
!localModelValue.value ||
|
|
74
|
+
(!Array.isArray(localModelValue.value) &&
|
|
75
|
+
!(localModelValue.value as File)?.name)
|
|
76
|
+
) {
|
|
77
|
+
return []
|
|
78
|
+
}
|
|
79
|
+
return Array.isArray(localModelValue.value)
|
|
80
|
+
? localModelValue.value
|
|
81
|
+
: [localModelValue.value]
|
|
82
|
+
},
|
|
83
|
+
set: (value) => {
|
|
84
|
+
if (isMultiple.value) {
|
|
85
|
+
localModelValue.value = value
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
localModelValue.value = value?.[0]
|
|
89
|
+
},
|
|
80
90
|
})
|
|
81
91
|
|
|
82
92
|
const hasMax = computed(() => {
|
|
@@ -250,6 +260,12 @@
|
|
|
250
260
|
}
|
|
251
261
|
return props.iconReplace
|
|
252
262
|
})
|
|
263
|
+
|
|
264
|
+
const onSortEnd = ({ newIndex }: { newIndex: number | null }) => {
|
|
265
|
+
if (newIndex !== null) {
|
|
266
|
+
selectedFileIndex.value = newIndex
|
|
267
|
+
}
|
|
268
|
+
}
|
|
253
269
|
</script>
|
|
254
270
|
|
|
255
271
|
<template>
|
|
@@ -316,43 +332,51 @@
|
|
|
316
332
|
</progress>
|
|
317
333
|
<VvIcon v-if="hasIconAfter" v-bind="hasIconAfter" />
|
|
318
334
|
</div>
|
|
319
|
-
<
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
@click.stop="
|
|
335
|
+
<Sortable
|
|
336
|
+
v-model="files"
|
|
337
|
+
tag="ul"
|
|
338
|
+
class="vv-input-file__list"
|
|
339
|
+
item-key="name"
|
|
340
|
+
:move="() => sortable"
|
|
341
|
+
@end="onSortEnd"
|
|
342
|
+
>
|
|
343
|
+
<template #item="{ element: file, index }">
|
|
344
|
+
<li
|
|
345
|
+
class="vv-input-file__item"
|
|
346
|
+
:class="{
|
|
347
|
+
active:
|
|
348
|
+
index === selectedFileIndex &&
|
|
349
|
+
hasDropArea &&
|
|
350
|
+
files.length > 1,
|
|
351
|
+
'cursor-move': sortable,
|
|
352
|
+
}"
|
|
353
|
+
@click.stop="onClickSelectFile(index)"
|
|
338
354
|
>
|
|
339
|
-
<
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
<button
|
|
356
|
+
v-if="hasIconDownload"
|
|
357
|
+
type="button"
|
|
358
|
+
class="vv-input-file__item-action"
|
|
359
|
+
:title="labelDownload"
|
|
360
|
+
@click.stop="onClickDownloadFile(file)"
|
|
361
|
+
>
|
|
362
|
+
<VvIcon v-bind="hasIconDownload" />
|
|
363
|
+
</button>
|
|
364
|
+
<div class="vv-input-file__item-name">
|
|
365
|
+
{{ file.name }}
|
|
366
|
+
</div>
|
|
367
|
+
<small class="vv-input-file__item-info">
|
|
368
|
+
{{ sizeInKiB(file.size) }} KB
|
|
369
|
+
</small>
|
|
370
|
+
<button
|
|
371
|
+
v-if="!readonly"
|
|
372
|
+
type="button"
|
|
373
|
+
class="vv-input-file__item-remove"
|
|
374
|
+
:title="labelRemove"
|
|
375
|
+
@click.stop="onClickRemoveFile(index)"
|
|
376
|
+
/>
|
|
377
|
+
</li>
|
|
378
|
+
</template>
|
|
379
|
+
</Sortable>
|
|
356
380
|
<HintSlot :id="hasHintId" class="vv-input-file__hint">
|
|
357
381
|
<template v-if="$slots.hint" #hint>
|
|
358
382
|
<slot name="hint" v-bind="hintSlotScope" />
|
|
@@ -32,10 +32,7 @@ export const VvInputFileProps = {
|
|
|
32
32
|
* Input value
|
|
33
33
|
*/
|
|
34
34
|
modelValue: {
|
|
35
|
-
type: Object as PropType<
|
|
36
|
-
File | UploadedFile | (File | UploadedFile)[] | undefined
|
|
37
|
-
>,
|
|
38
|
-
required: true,
|
|
35
|
+
type: Object as PropType<File | UploadedFile | (File | UploadedFile)[]>,
|
|
39
36
|
},
|
|
40
37
|
/**
|
|
41
38
|
* Whether to show progress bar
|
|
@@ -79,6 +76,10 @@ export const VvInputFileProps = {
|
|
|
79
76
|
* Show drop area
|
|
80
77
|
*/
|
|
81
78
|
dropArea: { type: Boolean, default: false },
|
|
79
|
+
/**
|
|
80
|
+
* Enable sorting
|
|
81
|
+
*/
|
|
82
|
+
sortable: { type: Boolean, default: false },
|
|
82
83
|
/**
|
|
83
84
|
* Label for add button
|
|
84
85
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractPropTypes
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
2
|
import type { InputGroupState } from '../../types/group'
|
|
3
3
|
import { CheckboxRadioProps } from '../../props'
|
|
4
4
|
import { INJECTION_KEY_RADIO_GROUP } from '../../constants'
|
|
@@ -22,13 +22,13 @@ export function useGroupProps(
|
|
|
22
22
|
|
|
23
23
|
// global props
|
|
24
24
|
const modelValue = getGroupOrLocalRef('modelValue', props, emit)
|
|
25
|
-
const valid = getGroupOrLocalRef('valid', props)
|
|
26
|
-
const invalid = getGroupOrLocalRef('invalid', props)
|
|
25
|
+
const valid = getGroupOrLocalRef('valid', props)
|
|
26
|
+
const invalid = getGroupOrLocalRef('invalid', props)
|
|
27
27
|
const readonly = computed(() =>
|
|
28
|
-
Boolean(props.readonly || group?.
|
|
28
|
+
Boolean(props.readonly || group?.readonly.value),
|
|
29
29
|
)
|
|
30
30
|
const disabled = computed(() =>
|
|
31
|
-
Boolean(props.disabled || group?.
|
|
31
|
+
Boolean(props.disabled || group?.disabled.value),
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
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_RADIO_GROUP,
|
|
32
|
+
useProvideGroupState<InputGroupState>(INJECTION_KEY_RADIO_GROUP, {
|
|
34
33
|
modelValue,
|
|
35
34
|
disabled,
|
|
36
35
|
readonly,
|
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
import type { Ref } from 'vue'
|
|
2
|
-
import type GroupState from '../../types/group'
|
|
1
|
+
import type { Ref, InjectionKey } from 'vue'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Injects a group state
|
|
6
5
|
*/
|
|
7
|
-
export function useInjectedGroupState<GroupStateType
|
|
8
|
-
groupKey:
|
|
6
|
+
export function useInjectedGroupState<GroupStateType>(
|
|
7
|
+
groupKey: InjectionKey<GroupStateType>,
|
|
9
8
|
) {
|
|
10
9
|
// Get group state
|
|
11
|
-
const group = inject<
|
|
10
|
+
const group = inject<GroupStateType | undefined>(groupKey, undefined)
|
|
12
11
|
|
|
13
12
|
// Check if component is in group
|
|
14
|
-
const isInGroup = computed(() =>
|
|
13
|
+
const isInGroup = computed(() => group !== undefined)
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Get a group or local property
|
|
18
17
|
*/
|
|
19
|
-
function getGroupOrLocalRef<
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
function getGroupOrLocalRef<
|
|
19
|
+
TProps extends object,
|
|
20
|
+
TName extends keyof GroupStateType,
|
|
21
|
+
>(
|
|
22
|
+
propName: TName,
|
|
23
|
+
props: TProps,
|
|
22
24
|
emit?: (event: string, ...args: unknown[]) => void,
|
|
23
25
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
const groupPropValue = group?.[propName] as Ref | undefined
|
|
27
|
+
if (groupPropValue) {
|
|
26
28
|
return computed({
|
|
27
29
|
get() {
|
|
28
|
-
return groupPropValue
|
|
30
|
+
return groupPropValue.value
|
|
29
31
|
},
|
|
30
32
|
set(value: unknown) {
|
|
31
33
|
groupPropValue.value = value
|
|
32
34
|
},
|
|
33
|
-
})
|
|
35
|
+
}) as GroupStateType[TName]
|
|
34
36
|
}
|
|
35
|
-
const propRef = toRef(props, propName as keyof
|
|
37
|
+
const propRef = toRef(props, propName as unknown as keyof TProps)
|
|
36
38
|
return computed({
|
|
37
39
|
get() {
|
|
38
40
|
return propRef.value
|
|
39
41
|
},
|
|
40
42
|
set(value: unknown) {
|
|
41
|
-
if (emit)
|
|
43
|
+
if (emit) {
|
|
44
|
+
emit(`update:${propName as string}`, value)
|
|
45
|
+
}
|
|
42
46
|
},
|
|
43
|
-
})
|
|
47
|
+
}) as GroupStateType[TName]
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
return {
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Ref, InjectionKey } from 'vue'
|
|
2
|
+
import type { Emitter } from 'mitt'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Share part of the state of the component with all its children.
|
|
5
|
-
* @param {IGroupState} groupState the group state with all group options
|
|
6
6
|
*/
|
|
7
|
-
export function useProvideGroupState<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
throw Error("One or more groupState props aren't ref.")
|
|
16
|
-
provide(
|
|
17
|
-
groupState.key,
|
|
18
|
-
computed(() => groupState),
|
|
19
|
-
)
|
|
7
|
+
export function useProvideGroupState<
|
|
8
|
+
TGroupState extends Record<
|
|
9
|
+
string,
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
Ref<unknown> | Emitter<any>
|
|
12
|
+
>,
|
|
13
|
+
>(key: InjectionKey<TGroupState>, groupState: TGroupState) {
|
|
14
|
+
provide(key, groupState)
|
|
20
15
|
}
|
package/src/constants.ts
CHANGED
|
@@ -2,6 +2,12 @@ import type { InjectionKey, Ref } from 'vue'
|
|
|
2
2
|
import type { Emitter } from 'mitt'
|
|
3
3
|
import type { Volver } from './Volver'
|
|
4
4
|
import type { AlertModifiers } from './types/alert'
|
|
5
|
+
import type {
|
|
6
|
+
AccordionGroupState,
|
|
7
|
+
InputGroupState,
|
|
8
|
+
ButtonGroupState,
|
|
9
|
+
AlertGroupState,
|
|
10
|
+
} from './types'
|
|
5
11
|
|
|
6
12
|
export const DEFAULT_ICONIFY_PROVIDER = 'vv'
|
|
7
13
|
|
|
@@ -73,10 +79,18 @@ export enum AnchorTarget {
|
|
|
73
79
|
export const INJECTION_KEY_VOLVER = Symbol.for('volver') as InjectionKey<Volver>
|
|
74
80
|
|
|
75
81
|
// groups
|
|
76
|
-
export const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export const
|
|
82
|
+
export const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
83
|
+
'buttonGroup',
|
|
84
|
+
) as InjectionKey<ButtonGroupState>
|
|
85
|
+
export const INJECTION_KEY_RADIO_GROUP = Symbol.for(
|
|
86
|
+
'radioGroup',
|
|
87
|
+
) as InjectionKey<InputGroupState>
|
|
88
|
+
export const INJECTION_KEY_CHECK_GROUP = Symbol.for(
|
|
89
|
+
'checkGroup',
|
|
90
|
+
) as InjectionKey<InputGroupState>
|
|
91
|
+
export const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
|
|
92
|
+
'accordionGroup',
|
|
93
|
+
) as InjectionKey<AccordionGroupState>
|
|
80
94
|
|
|
81
95
|
// dropdown
|
|
82
96
|
export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
@@ -112,10 +126,7 @@ export const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
|
|
|
112
126
|
// alert
|
|
113
127
|
export const INJECTION_KEY_ALERT_GROUP = Symbol.for(
|
|
114
128
|
'alertGroup',
|
|
115
|
-
) as InjectionKey<
|
|
116
|
-
name?: Ref<string | undefined>
|
|
117
|
-
bus?: Emitter<{ close: string }>
|
|
118
|
-
}>
|
|
129
|
+
) as InjectionKey<AlertGroupState>
|
|
119
130
|
export const DEFAULT_ALERT_AUTO_CLOSE = 10000
|
|
120
131
|
export const DEFAULT_ALERT_MODIFIERS = 'info'
|
|
121
132
|
export const DEFAULT_ALERT_DISMISSABLE = true
|
|
@@ -130,9 +141,3 @@ export const DefaultAlertIconMap = new Map<AlertModifiers, string>([
|
|
|
130
141
|
['warning', DEFAULT_ALERT_WARNING_ICON],
|
|
131
142
|
['danger', DEFAULT_ALERT_DANGER_ICON],
|
|
132
143
|
])
|
|
133
|
-
// {
|
|
134
|
-
// success: DEFAULT_ALERT_SUCCESS_ICON,
|
|
135
|
-
// info: DEFAULT_ALERT_INFO_ICON,
|
|
136
|
-
// warning: DEFAULT_ALERT_WARNING_ICON,
|
|
137
|
-
// danger: DEFAULT_ALERT_DANGER_ICON,
|
|
138
|
-
// }
|
|
@@ -29,12 +29,22 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
29
29
|
|
|
30
30
|
// open
|
|
31
31
|
if (!args.disabled && args.items && args.items.length > 0) {
|
|
32
|
-
expect(firstChild.open).toBe(
|
|
32
|
+
expect(firstChild.open).toBe(false)
|
|
33
33
|
expect(firstChildSummary).toBeClicked()
|
|
34
34
|
await sleep()
|
|
35
|
-
expect(firstChild.open).toBe(
|
|
35
|
+
expect(firstChild.open).toBe(true)
|
|
36
36
|
if (firstChild.open) {
|
|
37
|
-
if (args.
|
|
37
|
+
if (args.not) {
|
|
38
|
+
expect(JSON.stringify(JSON.parse(value.innerText))).toBe(
|
|
39
|
+
JSON.stringify(
|
|
40
|
+
[
|
|
41
|
+
...args.items.map(
|
|
42
|
+
(item: { name: string }) => item.name,
|
|
43
|
+
),
|
|
44
|
+
].splice(1),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
} else if (args.collapse) {
|
|
38
48
|
expect(JSON.stringify(JSON.parse(value.innerText))).toBe(
|
|
39
49
|
JSON.stringify([args.items[0].name]),
|
|
40
50
|
)
|
|
@@ -42,13 +52,9 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
42
52
|
expect(value.innerText).toBe(args.items[0].name)
|
|
43
53
|
}
|
|
44
54
|
}
|
|
45
|
-
expect(firstChildSummary.getAttribute('aria-expanded')).toBe(
|
|
46
|
-
args.not ? 'false' : 'true',
|
|
47
|
-
)
|
|
55
|
+
expect(firstChildSummary.getAttribute('aria-expanded')).toBe('true')
|
|
48
56
|
const content = firstChild.lastChild as HTMLElement
|
|
49
|
-
expect(content.getAttribute('aria-hidden')).toBe(
|
|
50
|
-
args.not ? 'true' : 'false',
|
|
51
|
-
)
|
|
57
|
+
expect(content.getAttribute('aria-hidden')).toBe('false')
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
// accessibility
|
|
@@ -46,7 +46,7 @@ export const Default: Story = {
|
|
|
46
46
|
<vv-accordion name="a-3" title="Details 3" :content="content" />
|
|
47
47
|
</vv-accordion-group>
|
|
48
48
|
<div class="mt-24" >
|
|
49
|
-
Opened: <span data-testId="value">{{ selected }}</span>
|
|
49
|
+
{{ args.not ? 'Closed' : 'Opened'}}: <span data-testId="value">{{ selected }}</span>
|
|
50
50
|
</div>
|
|
51
51
|
`,
|
|
52
52
|
}),
|
package/src/types/group.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* State shared for a group of elements
|
|
5
|
-
*/
|
|
6
|
-
export default interface GroupState {
|
|
7
|
-
// The key of the group
|
|
8
|
-
[itemKey: string]: Ref<unknown> | unknown | undefined
|
|
9
|
-
key: string | number | symbol
|
|
10
|
-
}
|
|
2
|
+
import type { Emitter } from 'mitt'
|
|
11
3
|
|
|
12
4
|
/**
|
|
13
5
|
* State shared in a group of inputs
|
|
14
6
|
*/
|
|
15
|
-
export
|
|
7
|
+
export type InputGroupState = {
|
|
8
|
+
modelValue: Ref<unknown>
|
|
16
9
|
readonly: Ref<boolean>
|
|
17
10
|
disabled: Ref<boolean>
|
|
18
11
|
valid: Ref<boolean>
|
|
@@ -22,7 +15,7 @@ export interface InputGroupState extends GroupState {
|
|
|
22
15
|
/**
|
|
23
16
|
* State shared in a group of buttons
|
|
24
17
|
*/
|
|
25
|
-
export
|
|
18
|
+
export type ButtonGroupState = {
|
|
26
19
|
modelValue: Ref<
|
|
27
20
|
string | number | boolean | (string | number | boolean)[] | undefined
|
|
28
21
|
>
|
|
@@ -36,9 +29,24 @@ export interface ButtonGroupState extends GroupState {
|
|
|
36
29
|
/**
|
|
37
30
|
* State shared in a group of accordions
|
|
38
31
|
*/
|
|
39
|
-
export
|
|
40
|
-
|
|
32
|
+
export type AccordionGroupBusEvents = {
|
|
33
|
+
toggle: { name: string; value: boolean }
|
|
34
|
+
register: { name: string }
|
|
35
|
+
unregister: { name: string }
|
|
36
|
+
expand: { name?: string | string[] }
|
|
37
|
+
collapse: { name?: string | string[] }
|
|
38
|
+
}
|
|
39
|
+
export type AccordionGroupState = {
|
|
41
40
|
disabled: Ref<boolean>
|
|
42
41
|
modifiers: Ref<string[] | string | undefined>
|
|
43
|
-
|
|
42
|
+
bus: Emitter<AccordionGroupBusEvents>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* State shared in a group of alerts
|
|
47
|
+
*/
|
|
48
|
+
export type AlertGroupBusEvents = { close: string }
|
|
49
|
+
export type AlertGroupState = {
|
|
50
|
+
name?: Ref<string | undefined>
|
|
51
|
+
bus?: Emitter<AlertGroupBusEvents>
|
|
44
52
|
}
|