@builder.io/mitosis
Version:
Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io
19 lines (18 loc) • 771 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInputs = void 0;
const getInputs = ({ props, json, options, }) => {
const propsTypeRef = json.propsTypeRef !== 'any' ? json.propsTypeRef : undefined;
return props
.map((prop) => {
const hasDefaultProp = json.defaultProps && json.defaultProps.hasOwnProperty(prop);
const propType = propsTypeRef ? `${propsTypeRef}["${prop}"]` : 'any';
let propDeclaration = `@Input() ${prop}${options.typescript ? `${hasDefaultProp ? '' : '!'}: ${propType}` : ''}`;
if (hasDefaultProp) {
propDeclaration += ` = defaultProps["${prop}"]`;
}
return propDeclaration;
})
.join('\n');
};
exports.getInputs = getInputs;
;