UNPKG

@builder.io/mitosis

Version:

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

33 lines (32 loc) 1.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPropsRef = void 0; const legacy_1 = __importDefault(require("neotraverse/legacy")); const is_mitosis_node_1 = require("./is-mitosis-node"); function getPropsRef(json, shouldRemove) { let has = false; let prop = ''; (0, legacy_1.default)(json).forEach(function (item) { if ((0, is_mitosis_node_1.isMitosisNode)(item)) { const binding = item.bindings.ref; const regexp = /(.+)?props\.(.+)( |\)|;|\()?$/; if (binding && regexp.test(binding.code)) { const match = regexp.exec(binding.code); const _prop = match === null || match === void 0 ? void 0 : match[2]; if (_prop) { prop = _prop; } if (shouldRemove) { delete item.bindings.ref; } has = true; this.stop(); } } }); return [prop, has]; } exports.getPropsRef = getPropsRef;