2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>
|
|
|
|
Options can be grouped when a nested data structures is provided. To define the label of a group <i>optionGroupLabel</i> property is needed and also <i>optionGroupChildren</i> is required to define the property that refers to the children
|
|
|
|
of a group.
|
|
|
|
</p>
|
|
|
|
</DocSectionText>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
|
|
|
<MultiSelect v-model="selectedCities" :options="groupedCities" optionLabel="label" filter optionGroupLabel="label" optionGroupChildren="items" display="chip" placeholder="Select Cities" class="w-full md:w-80">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #optiongroup="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<img :alt="slotProps.option.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="`flag flag-${slotProps.option.code.toLowerCase()} mr-2`" style="width: 18px" />
|
|
|
|
<div>{{ slotProps.option.label }}</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MultiSelect>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selectedCities: null,
|
|
|
|
groupedCities: [
|
|
|
|
{
|
|
|
|
label: 'Germany',
|
|
|
|
code: 'DE',
|
|
|
|
items: [
|
|
|
|
{ label: 'Berlin', value: 'Berlin' },
|
|
|
|
{ label: 'Frankfurt', value: 'Frankfurt' },
|
|
|
|
{ label: 'Hamburg', value: 'Hamburg' },
|
|
|
|
{ label: 'Munich', value: 'Munich' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'USA',
|
|
|
|
code: 'US',
|
|
|
|
items: [
|
|
|
|
{ label: 'Chicago', value: 'Chicago' },
|
|
|
|
{ label: 'Los Angeles', value: 'Los Angeles' },
|
|
|
|
{ label: 'New York', value: 'New York' },
|
|
|
|
{ label: 'San Francisco', value: 'San Francisco' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Japan',
|
|
|
|
code: 'JP',
|
|
|
|
items: [
|
|
|
|
{ label: 'Kyoto', value: 'Kyoto' },
|
|
|
|
{ label: 'Osaka', value: 'Osaka' },
|
|
|
|
{ label: 'Tokyo', value: 'Tokyo' },
|
|
|
|
{ label: 'Yokohama', value: 'Yokohama' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
2024-05-20 12:14:38 +00:00
|
|
|
<MultiSelect v-model="selectedCities" :options="groupedCities" optionLabel="label" filter optionGroupLabel="label" optionGroupChildren="items" display="chip" placeholder="Select Cities" class="w-full md:w-80">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #optiongroup="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<img :alt="slotProps.option.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
|
|
|
|
<div>{{ slotProps.option.label }}</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-10-15 09:38:39 +00:00
|
|
|
</MultiSelect>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
|
|
|
<MultiSelect v-model="selectedCities" :options="groupedCities" optionLabel="label" filter optionGroupLabel="label" optionGroupChildren="items" display="chip" placeholder="Select Cities" class="w-full md:w-80">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #optiongroup="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<img :alt="slotProps.option.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
|
|
|
|
<div>{{ slotProps.option.label }}</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MultiSelect>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selectedCities: null,
|
|
|
|
groupedCities: [
|
|
|
|
{
|
|
|
|
label: 'Germany',
|
|
|
|
code: 'DE',
|
|
|
|
items: [
|
|
|
|
{ label: 'Berlin', value: 'Berlin' },
|
|
|
|
{ label: 'Frankfurt', value: 'Frankfurt' },
|
|
|
|
{ label: 'Hamburg', value: 'Hamburg' },
|
|
|
|
{ label: 'Munich', value: 'Munich' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'USA',
|
|
|
|
code: 'US',
|
|
|
|
items: [
|
|
|
|
{ label: 'Chicago', value: 'Chicago' },
|
|
|
|
{ label: 'Los Angeles', value: 'Los Angeles' },
|
|
|
|
{ label: 'New York', value: 'New York' },
|
|
|
|
{ label: 'San Francisco', value: 'San Francisco' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Japan',
|
|
|
|
code: 'JP',
|
|
|
|
items: [
|
|
|
|
{ label: 'Kyoto', value: 'Kyoto' },
|
|
|
|
{ label: 'Osaka', value: 'Osaka' },
|
|
|
|
{ label: 'Tokyo', value: 'Tokyo' },
|
|
|
|
{ label: 'Yokohama', value: 'Yokohama' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
|
|
|
<MultiSelect v-model="selectedCities" :options="groupedCities" optionLabel="label" filter optionGroupLabel="label" optionGroupChildren="items" display="chip" placeholder="Select Cities" class="w-full md:w-80">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #optiongroup="slotProps">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<img :alt="slotProps.option.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
|
|
|
|
<div>{{ slotProps.option.label }}</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MultiSelect>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
|
|
const selectedCities = ref();
|
|
|
|
const groupedCities = ref([
|
|
|
|
{
|
|
|
|
label: 'Germany',
|
|
|
|
code: 'DE',
|
|
|
|
items: [
|
|
|
|
{ label: 'Berlin', value: 'Berlin' },
|
|
|
|
{ label: 'Frankfurt', value: 'Frankfurt' },
|
|
|
|
{ label: 'Hamburg', value: 'Hamburg' },
|
|
|
|
{ label: 'Munich', value: 'Munich' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'USA',
|
|
|
|
code: 'US',
|
|
|
|
items: [
|
|
|
|
{ label: 'Chicago', value: 'Chicago' },
|
|
|
|
{ label: 'Los Angeles', value: 'Los Angeles' },
|
|
|
|
{ label: 'New York', value: 'New York' },
|
|
|
|
{ label: 'San Francisco', value: 'San Francisco' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Japan',
|
|
|
|
code: 'JP',
|
|
|
|
items: [
|
|
|
|
{ label: 'Kyoto', value: 'Kyoto' },
|
|
|
|
{ label: 'Osaka', value: 'Osaka' },
|
|
|
|
{ label: 'Tokyo', value: 'Tokyo' },
|
|
|
|
{ label: 'Yokohama', value: 'Yokohama' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]);
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|