export default { name: "Switch", acceptsChildren: false, category: "Input", props: [ { label: "Label", name: "children", type: { kind: "text", isDynamic: true }, default: "", placeholder: "Enter some text...", help: "The label to display", }, { label: "Initial Value", name: "defaultChecked", isDefault: true, type: { kind: "boolean", isDynamic: true }, default: false, placeholder: "Enter default value", help: "The input's default value", }, { label: "Is disabled", name: "disabled", type: { kind: "boolean", isDynamic: true }, default: false, placeholder: "", help: "Whether the Switch is disabled", }, ], events: [ { label: "When changed", name: "onChange", isDefault: true, help: "Select an action to run when input's value has changed", }, ], defaultStyles: { "": { display: "inline-flex", "align-items": "center", position: "relative", gap: "8px", "font-family": "var(--theme-fonts-body)", "font-size": "var(--theme-fontSizes-md)", }, }, sources: [ { id: "value", name: "{{= it.component.name }}'s current value", provider: "StateProvider", description: "The current value of the input", template: "$get('{{= it.component.id}}', { value: null }).value", instanceTemplate: `{{= it.component.name }}'s current value`, outputType: { kind: "boolean" }, }, ], actions: [ { id: "set", name: `Set "{{= it.component.name }}"'s value`, provider: "StateProvider", description: "Set the value of the state variable", async: false, template: // eslint-disable-next-line no-template-curly-in-string "$set('{{= it.component.id }}', { value: {{= it.stringify(it.data.value) }} });", instanceTemplate: `{{= it.stringify(it.data.value) }}`, props: [ { label: "Value", name: "value", type: { kind: "boolean", isDynamic: true }, placeholder: "Choose a value", required: true, default: null, help: "The value to set the state variable to", }, ], }, ], } as const;