Skip to content

Commit 0033455

Browse files
committed
feat(FormSelect): support for multiple values
1 parent 938bc8e commit 0033455

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

apps/docs/src/stories/Components/FormSelect.story.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
## Examples
2424
</pre>
2525

26-
<story-canvas title="Example">
27-
<pf-form-select required>
26+
<story-canvas title="Single value">
27+
<pf-form-select required v-model="value">
2828
<pf-form-select-option value="" label="Please Choose" placeholder disabled />
2929
<pf-form-select-option value="mr" label="Mr" />
3030
<pf-form-select-option value="miss" label="Miss" />
@@ -43,6 +43,30 @@
4343
<pf-form-select-option value="other" label="Other" />
4444
</optgroup>
4545
</pf-form-select>
46+
<br>
47+
<p>Value: {{ JSON.stringify(value) }}</p>
48+
</story-canvas>
49+
50+
<story-canvas title="Multiple value">
51+
<pf-form-select required v-model="values" multiple>
52+
<pf-form-select-option value="" label="Please Choose" placeholder disabled />
53+
<pf-form-select-option value="white" label="White" />
54+
<pf-form-select-option value="black" label="Black" />
55+
<pf-form-select-option value="red" label="Red" />
56+
<pf-form-select-option value="green" label="Green" />
57+
<pf-form-select-option value="blue" label="Blue" />
58+
<pf-form-select-option value="yellow" label="Yellow" />
59+
<pf-form-select-option value="purple" label="Purple" disabled />
60+
</pf-form-select>
61+
<br>
62+
<p>Values: {{ JSON.stringify(values) }}</p>
4663
</story-canvas>
4764
</doc-page>
4865
</template>
66+
67+
<script setup lang="ts">
68+
import { ref, type Ref } from 'vue';
69+
70+
const value = ref('');
71+
const values: Ref<string[]> = ref([]);
72+
</script>

packages/core/src/components/FormSelect/FormSelect.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const FormSelectOptionsKey = Symbol("FormSelectOptionsKey") as ChildrenTr
3333
3434
export interface Props extends OUIAProps, /* @vue-ignore */ Omit<SelectHTMLAttributes, 'value'> {
3535
/** @model */
36-
modelValue?: string | null;
36+
modelValue?: string | string[] | null;
3737
3838
disabled?: boolean;
3939
@@ -66,7 +66,7 @@ const props = defineProps<Props>();
6666
const ouiaProps = useOUIAProps({id: props.ouiaId, safe: props.ouiaSafe});
6767
6868
defineEmits<{
69-
(name: 'update:modelValue', value: string): void;
69+
(name: 'update:modelValue', value: string | string[]): void;
7070
}>();
7171
7272
defineSlots<{

0 commit comments

Comments
 (0)