//url=?node-id=977-9039 //source=./index.tsx //component=InputTime import figma from 'figma' const instance = figma.selectedInstance const state = instance.getEnum('State', { Normal: undefined, Error: 'error', Warning: 'warning', }) const withLabel = instance.getBoolean('Label') let label let message if (withLabel) { const labelInstance = instance.findInstance('Form label') if (labelInstance.type !== 'ERROR') { const labelText = labelInstance.findText('Label') if (labelText.type === 'TEXT') { label = labelText.textContent } } label ??= 'Label' } if (state === 'error' || state === 'warning') { const messageInstance = instance.findInstance('Form inline message') if (messageInstance.type !== 'ERROR') { const messageText = messageInstance.findText('Label') if (messageText.type === 'TEXT') { message = messageText.textContent } } message ??= 'Message' } const propLines = [ label ? `label=${JSON.stringify(label)}` : undefined, state === 'error' && message ? `error=${JSON.stringify(message)}` : undefined, state === 'warning' && message ? `warning=${JSON.stringify(message)}` : undefined, ].filter((line): line is string => Boolean(line)) const propsBlock = `\n ${propLines.join('\n ')}\n` export default { id: 'FormInputTime', imports: ['import { InputTime } from "@planview/pv-form"'], example: figma.tsx``, metadata: { nestable: true, }, }