import React, { useState } from "react"; import { iconClass } from "../../utils/iconClass"; import { Select } from "./select.component"; const choices = [ { label: "label1", value: "value1" }, { label: "label2", value: "value2" } ]; const useValue = (args: any) => { const [value, useValue] = useState(args.value); return { ...args, value, onChange(name: string, value: any) { useValue(value); args.onChange(name, value); } }; }; export default { title: "ReactFormio/Select", component: Select, argTypes: { label: { control: { type: "text" } }, name: { control: { type: "text" } }, value: { control: { type: "select", options: choices } }, size: { control: { type: "select", options: ["sm", "normal"] } }, layout: { control: { type: "select", options: ["html5", "choicesjs"] } }, placeholder: { control: { type: "text" } }, choices: { control: { type: "object" } } }, parameters: {} }; export const Sandbox = (args: any) => { return ; }; Choicesjs.args = { label: "Label", value: "", size: "", layout: "choicesjs", placeholder: "Placeholder", choices }; export const ChoicesjsPrefix = (args: any) => { return ( } {...useValue(args)} /> ); }; WithPrefix.args = { label: "Label", value: "", size: "", placeholder: "Placeholder", choices }; export const WithSuffix = (args: any) => { return ( ; }; TypeMultiple.args = { label: "Label", name: "name", value: [], size: "", multiple: true, placeholder: "Placeholder", description: "Select multiple values", choices }; export const ChoicesjsMultiple = (args: any) => { return } {...useValue(args)} /> ); }; Sizing.args = { label: "Label", value: "", size: "sm", placeholder: "Placeholder", description: "Use dollars!", choices };