import React, { useState } from "react";
import PropTypes from "prop-types";
import Pct from "../PatternOptionPercentage";
import Deg from "../PatternOptionDegree";
import Mm from "../PatternOptionMillimeter";
import Bool from "../PatternOptionBool";
import List from "../PatternOptionList";
import Count from "../PatternOptionCount";
import { optionType, optionDefault } from "@freesewing/utils";
import { FormattedMessage } from "react-intl";
import { injectIntl } from "react-intl";
const OptionGroup = props => {
const renderOption = (name, sub = false) => {
let option = props.config.options[name];
let type = optionType(option);
let stringKey = `options.${props.config.name}.${name}.`;
let extraProps = {
name,
dflt: optionDefault(props.config.options[name]),
units: props.units,
updateValue: props.updateValue,
raiseEvent: props.raiseEvent,
title: ,
desc: ,
intl: props.intl,
pattern: props.config.name,
key: name
};
let noyes = [
,
];
switch (type) {
case "pct":
return ;
break;
case "deg":
return ;
break;
case "mm":
return ;
break;
case "bool":
return ;
break;
case "list":
return
;
break;
case "count":
return ;
break;
default:
throw new Error("Unsupported option type: " + type);
}
};
return (
{props.options.map(name => {
let key = name;
let output = [];
if (typeof name === "object") {
key = Object.keys(name).pop();
// Subgroup
for (let subGroup of Object.keys(name)) {
output.push(
);
let children = [];
for (let option of name[subGroup])
children.push(renderOption(option, true));
output.push();
}
} else output.push(renderOption(name));
return output;
})}
);
};
OptionGroup.propTypes = {
config: PropTypes.object.isRequired,
options: PropTypes.array.isRequired,
units: PropTypes.oneOf(["metric", "imperial"]).isRequired
};
OptionGroup.defaultProps = {};
export default injectIntl(OptionGroup);