Skip to content

Commit

Permalink
🛠️: update FormSelection component to accept number values in `valu…
Browse files Browse the repository at this point in the history
…e` prop
  • Loading branch information
itisAliRH committed Apr 19, 2024
1 parent f7ddf49 commit 3f4d02c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions client/src/components/Form/Elements/FormSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@ interface Props {
display?: string;
optional?: boolean;
multiple?: boolean;
value?: string | string[];
options?: [string, string][];
data?: { label: string; value: string }[];
value?: string | string[] | number | number[];
options?: [string, string | number][];
data?: {
label: string;
value: string;
}[];
}
const props = withDefaults(defineProps<Props>(), {
display: "select",
display: undefined,
optional: false,
multiple: false,
value: "",
options: () => [],
data: () => [],
value: undefined,
options: undefined,
data: undefined,
});
const emit = defineEmits<{
(e: "input", value: string | string[]): void;
(e: "input", value: string | string[] | number | number[]): void;
}>();
const { preferredFormSelectElement } = storeToRefs(useUserFlagsStore());
Expand All @@ -55,7 +58,7 @@ const currentOptions = computed(() => {
const data = props.data;
const options = props.options;
let result: { label: string; value: string }[] = [];
let result: { label: string; value?: string | number }[] = [];
if (options && options.length > 0) {
result = options.map((option) => ({ label: option[0], value: option[1] }));
Expand All @@ -66,7 +69,7 @@ const currentOptions = computed(() => {
if (!props.display && !props.multiple && props.optional) {
result.unshift({
label: "Nothing selected",
value: "",
value: undefined,
});
}
Expand Down

0 comments on commit 3f4d02c

Please sign in to comment.