Files
directus/app/src/components/v-item-group.vue
Rijk van Zanten 4eae2de686 Move updated components to app (#15374)
* Move updated components to app

* Make sure storybook is alive
2022-09-02 14:42:00 -04:00

48 lines
1.1 KiB
Vue

<template>
<div class="v-item-group">
<slot />
</div>
</template>
<script setup lang="ts">
import { toRefs } from 'vue';
import { useGroupableParent } from '@directus/shared/composables';
interface Props {
/** If enabled, at least one item has to be selected */
mandatory?: boolean;
/** The maximum amount of items that can be selected */
max?: number;
/** If enabled, multiple elements can be selected */
multiple?: boolean;
/** Model what items should be selected */
modelValue?: (number | string)[];
/** Items that do not have the same scope will be ignored */
scope?: string;
}
const props = withDefaults(defineProps<Props>(), {
mandatory: false,
max: -1,
multiple: false,
modelValue: undefined,
scope: 'item-group',
});
const emit = defineEmits(['update:modelValue']);
const { modelValue: selection, multiple, max, mandatory } = toRefs(props);
useGroupableParent(
{
selection: selection,
onSelectionChange: (newSelectionValues) => emit('update:modelValue', newSelectionValues),
},
{
multiple: multiple,
max: max,
mandatory: mandatory,
},
props.scope
);
</script>