finish custom class and improved options overhaul
This commit is contained in:
@@ -1,39 +1,13 @@
|
||||
<script lang="ts" module>
|
||||
export type RadioGroupOption =
|
||||
| {
|
||||
value: string;
|
||||
label?: string;
|
||||
}
|
||||
| string;
|
||||
|
||||
/** getLabel returns the option label if it exists*/
|
||||
const getLabel = (option: RadioGroupOption): string => {
|
||||
if (typeof option === 'string') {
|
||||
return option;
|
||||
} else {
|
||||
return option.label ?? option.value;
|
||||
}
|
||||
};
|
||||
|
||||
/** getValue returns the option value */
|
||||
const getValue = (option: RadioGroupOption): string => {
|
||||
if (typeof option === 'string') {
|
||||
return option;
|
||||
} else {
|
||||
return option.value;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { RadioGroup, type RadioGroupProps } from 'melt/builders';
|
||||
import type { ClassValue } from 'svelte/elements';
|
||||
import { scale } from 'svelte/transition';
|
||||
import Label from './Label.svelte';
|
||||
import { validate } from '@svelte-toolkit/validate';
|
||||
import { getLabel, getValue, type Option } from './util.js';
|
||||
|
||||
interface Props extends RadioGroupProps {
|
||||
options: RadioGroupOption[];
|
||||
options: Option[];
|
||||
label?: string;
|
||||
required?: boolean;
|
||||
invalidMessage?: string;
|
||||
|
||||
Reference in New Issue
Block a user