UNPKG

@builder.io/mitosis

Version:

Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io

32 lines (31 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseIfElse = void 0; const astring_1 = require("astring"); const _1 = require("."); const children_1 = require("../helpers/children"); const mitosis_node_1 = require("../helpers/mitosis-node"); const bindings_1 = require("../../../helpers/bindings"); function parseIfElse(json, node) { var _a, _b, _c; const mitosisNode = (0, mitosis_node_1.createMitosisNode)(); mitosisNode.name = 'Show'; mitosisNode.bindings = { when: (0, bindings_1.createSingleBinding)({ code: (0, astring_1.generate)(node.expression), }), }; mitosisNode.children = (0, children_1.parseChildren)(json, node); if (node.else) { mitosisNode.meta.else = ((_a = node.else.children) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (0, _1.parseHtmlNode)(json, node.else.children[0]) : { ...(0, mitosis_node_1.createMitosisNode)(), name: 'div', children: (_c = (_b = node.else.children) === null || _b === void 0 ? void 0 : _b.map((n) => (0, _1.parseHtmlNode)(json, n))) !== null && _c !== void 0 ? _c : [], }; } return mitosisNode; } exports.parseIfElse = parseIfElse;