mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-12 02:15:09 +01:00
update choice widget to add radio buttons option.
This commit is contained in:
parent
da6a462864
commit
7b5807089b
1 changed files with 18 additions and 4 deletions
|
|
@ -3,6 +3,10 @@ import React from "react";
|
|||
import {FieldBasicProps, fieldToSchemaGeneric} from "cad/mdf/ui/field";
|
||||
import {Types} from "cad/craft/schema/types";
|
||||
import {ComboBoxOption} from "ui/components/controls/ComboBoxControl";
|
||||
import {RadioButton} from 'ui/components/controls/RadioButtons';
|
||||
|
||||
import {RadioButtonsField} from '../../craft/wizard/components/form/Fields';
|
||||
|
||||
|
||||
type ValueDef = [string, string] | string;
|
||||
|
||||
|
|
@ -18,7 +22,6 @@ export interface ChoiceWidgetProps extends FieldBasicProps {
|
|||
|
||||
export function ChoiceWidget(props: ChoiceWidgetProps) {
|
||||
if (!props.style || props.style === 'dropdown') {
|
||||
|
||||
return <ComboBoxField name={props.name} defaultValue={props.defaultValue} label={props.label} includeNonExistent>
|
||||
{props.values.map((value: any) => {
|
||||
let val, name;
|
||||
|
|
@ -31,9 +34,20 @@ export function ChoiceWidget(props: ChoiceWidgetProps) {
|
|||
return <ComboBoxOption value={val} key={val}>{name}</ComboBoxOption>
|
||||
})}
|
||||
</ComboBoxField>;
|
||||
|
||||
} else {
|
||||
throw 'implement me';
|
||||
}
|
||||
if (props.style === 'radio'){
|
||||
return <RadioButtonsField name={props.name} defaultValue={props.defaultValue} label={props.label} includeNonExistent>
|
||||
{props.values.map((value: any) => {
|
||||
let val, name;
|
||||
if (Array.isArray(value)) {
|
||||
[val, name] = value;
|
||||
} else {
|
||||
val = value;
|
||||
name = value;
|
||||
}
|
||||
return <RadioButton value={val} key={val}>{name}</RadioButton>
|
||||
})}
|
||||
</RadioButtonsField>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue