@teleporthq/teleport-plugin-common
Advanced tools
Comparing version
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -21,6 +25,10 @@ if (k2 === undefined) k2 = k; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -75,3 +83,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
return t.importSpecifier(t.identifier(imp.identifierName), t.identifier(imp.originalName || imp.identifierName)); | ||
})); | ||
}), true); | ||
} | ||
@@ -99,3 +107,3 @@ else { | ||
var createSelfClosingJSXTag = function (tagName) { | ||
return exports.createJSXTag(tagName, [], true); | ||
return (0, exports.createJSXTag)(tagName, [], true); | ||
}; | ||
@@ -117,3 +125,3 @@ exports.createSelfClosingJSXTag = createSelfClosingJSXTag; | ||
} | ||
return ast_utils_1.convertValueToLiteral(value); | ||
return (0, ast_utils_1.convertValueToLiteral)(value); | ||
}); | ||
@@ -148,3 +156,3 @@ return t.callExpression(t.identifier(functionName), convertedArgs); | ||
if (t === void 0) { t = types; } | ||
return t.decorator(t.callExpression(t.identifier('Component'), [ast_utils_1.objectToObjectExpression(params)])); | ||
return t.decorator(t.callExpression(t.identifier('Component'), [(0, ast_utils_1.objectToObjectExpression)(params)])); | ||
}; | ||
@@ -157,3 +165,3 @@ exports.createComponentDecorator = createComponentDecorator; | ||
? t.unaryExpression('!', t.memberExpression(t.identifier('this'), t.identifier(modifies))) | ||
: ast_utils_1.convertValueToLiteral(newState); | ||
: (0, ast_utils_1.convertValueToLiteral)(newState); | ||
return t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier('this'), t.identifier(modifies)), rightOperand)); | ||
@@ -170,35 +178,35 @@ }; | ||
if (asset.type === 'canonical' && assetPath) { | ||
var linkTag = exports.createJSXTag('link'); | ||
ast_utils_1.addAttributeToJSXTag(linkTag, 'rel', 'canonical'); | ||
ast_utils_1.addAttributeToJSXTag(linkTag, 'href', assetPath); | ||
ast_utils_1.addChildJSXTag(headNode, linkTag); | ||
var linkTag = (0, exports.createJSXTag)('link'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(linkTag, 'rel', 'canonical'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(linkTag, 'href', assetPath); | ||
(0, ast_utils_1.addChildJSXTag)(headNode, linkTag); | ||
} | ||
// link stylesheet (external css, font) | ||
if ((asset.type === 'style' || asset.type === 'font') && assetPath) { | ||
var linkTag = exports.createJSXTag('link'); | ||
ast_utils_1.addAttributeToJSXTag(linkTag, 'rel', 'stylesheet'); | ||
ast_utils_1.addAttributeToJSXTag(linkTag, 'href', assetPath); | ||
ast_utils_1.addChildJSXTag(headNode, linkTag); | ||
var linkTag = (0, exports.createJSXTag)('link'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(linkTag, 'rel', 'stylesheet'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(linkTag, 'href', assetPath); | ||
(0, ast_utils_1.addChildJSXTag)(headNode, linkTag); | ||
} | ||
// inline style | ||
if (asset.type === 'style' && 'content' in asset) { | ||
var styleTag = exports.createJSXTag('style'); | ||
ast_utils_1.addAttributeToJSXTag(styleTag, 'dangerouslySetInnerHTML', { __html: asset.content }); | ||
ast_utils_1.addChildJSXTag(headNode, styleTag); | ||
var styleTag = (0, exports.createJSXTag)('style'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(styleTag, 'dangerouslySetInnerHTML', { __html: asset.content }); | ||
(0, ast_utils_1.addChildJSXTag)(headNode, styleTag); | ||
} | ||
// script (external or inline) | ||
if (asset.type === 'script') { | ||
var scriptTag = exports.createJSXTag('script'); | ||
ast_utils_1.addAttributeToJSXTag(scriptTag, 'type', 'text/javascript'); | ||
var scriptTag = (0, exports.createJSXTag)('script'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(scriptTag, 'type', 'text/javascript'); | ||
if (assetPath) { | ||
ast_utils_1.addAttributeToJSXTag(scriptTag, 'src', assetPath); | ||
(0, ast_utils_1.addAttributeToJSXTag)(scriptTag, 'src', assetPath); | ||
if (asset.options && asset.options.defer) { | ||
ast_utils_1.addAttributeToJSXTag(scriptTag, 'defer', true); | ||
(0, ast_utils_1.addAttributeToJSXTag)(scriptTag, 'defer', true); | ||
} | ||
if (asset.options && asset.options.async) { | ||
ast_utils_1.addAttributeToJSXTag(scriptTag, 'async', true); | ||
(0, ast_utils_1.addAttributeToJSXTag)(scriptTag, 'async', true); | ||
} | ||
} | ||
else if ('content' in asset) { | ||
ast_utils_1.addAttributeToJSXTag(scriptTag, 'dangerouslySetInnerHTML', { | ||
(0, ast_utils_1.addAttributeToJSXTag)(scriptTag, 'dangerouslySetInnerHTML', { | ||
__html: asset.content, | ||
@@ -208,6 +216,6 @@ }); | ||
if (asset.options && asset.options.target === 'body') { | ||
ast_utils_1.addChildJSXTag(bodyNode, scriptTag); | ||
(0, ast_utils_1.addChildJSXTag)(bodyNode, scriptTag); | ||
} | ||
else { | ||
ast_utils_1.addChildJSXTag(headNode, scriptTag); | ||
(0, ast_utils_1.addChildJSXTag)(headNode, scriptTag); | ||
} | ||
@@ -217,12 +225,12 @@ } | ||
if (asset.type === 'icon' && assetPath) { | ||
var iconTag = exports.createJSXTag('link'); | ||
ast_utils_1.addAttributeToJSXTag(iconTag, 'rel', 'shortcut icon'); | ||
ast_utils_1.addAttributeToJSXTag(iconTag, 'href', assetPath); | ||
var iconTag = (0, exports.createJSXTag)('link'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(iconTag, 'rel', 'shortcut icon'); | ||
(0, ast_utils_1.addAttributeToJSXTag)(iconTag, 'href', assetPath); | ||
if (asset.options && asset.options.iconType) { | ||
ast_utils_1.addAttributeToJSXTag(iconTag, 'type', asset.options.iconType); | ||
(0, ast_utils_1.addAttributeToJSXTag)(iconTag, 'type', asset.options.iconType); | ||
} | ||
if (asset.options && asset.options.iconSizes) { | ||
ast_utils_1.addAttributeToJSXTag(iconTag, 'sizes', asset.options.iconSizes); | ||
(0, ast_utils_1.addAttributeToJSXTag)(iconTag, 'sizes', asset.options.iconSizes); | ||
} | ||
ast_utils_1.addChildJSXTag(headNode, iconTag); | ||
(0, ast_utils_1.addChildJSXTag)(headNode, iconTag); | ||
} | ||
@@ -229,0 +237,0 @@ }); |
@@ -15,3 +15,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -44,3 +48,3 @@ if (k2 === undefined) k2 = k; | ||
var style_utils_1 = require("../utils/style-utils"); | ||
jss_1.default.setup(jss_preset_default_1.default()); | ||
jss_1.default.setup((0, jss_preset_default_1.default)()); | ||
var createCSSClass = function (key, styleObject) { | ||
@@ -72,3 +76,3 @@ var _a; | ||
return jss_1.default | ||
.createRule("@media(" + mediaOffset + ")", styleObject, { | ||
.createRule("@media(".concat(mediaOffset, ")"), styleObject, { | ||
generateId: function (data) { return data.key; }, | ||
@@ -89,5 +93,5 @@ }) | ||
case 'token': | ||
return "var(" + teleport_shared_1.StringUtils.generateCSSVariableName(styleValue.content.id) + ")"; | ||
return "var(".concat(teleport_shared_1.StringUtils.generateCSSVariableName(styleValue.content.id), ")"); | ||
default: | ||
throw new Error("createDynamicStyleExpression received unsupported " + JSON.stringify(styleValue, null, 2) + " UIDLDynamicReference value"); | ||
throw new Error("createDynamicStyleExpression received unsupported ".concat(JSON.stringify(styleValue, null, 2), " UIDLDynamicReference value")); | ||
} | ||
@@ -102,3 +106,3 @@ }; | ||
.forEach(function (mediaOffset) { | ||
styles.push(exports.createCSSClassWithMediaQuery("max-width: " + mediaOffset + "px", | ||
styles.push((0, exports.createCSSClassWithMediaQuery)("max-width: ".concat(mediaOffset, "px"), | ||
// @ts-ignore | ||
@@ -116,7 +120,7 @@ mediaStylesMap[mediaOffset])); | ||
var className = forceScoping | ||
? componentFileName + "-" + teleport_shared_1.StringUtils.camelCaseToDashCase(styleId) | ||
? "".concat(componentFileName, "-").concat(teleport_shared_1.StringUtils.camelCaseToDashCase(styleId)) | ||
: styleId; | ||
var _b = teleport_shared_1.UIDLUtils.splitDynamicAndStaticStyles(content), staticStyles = _b.staticStyles, tokenStyles = _b.tokenStyles; | ||
var collectedStyles = __assign(__assign({}, style_utils_1.getContentOfStyleObject(staticStyles)), style_utils_1.getCSSVariablesContentFromTokenStyles(tokenStyles)); | ||
cssMap.push(exports.createCSSClass(className, collectedStyles)); | ||
var collectedStyles = __assign(__assign({}, (0, style_utils_1.getContentOfStyleObject)(staticStyles)), (0, style_utils_1.getCSSVariablesContentFromTokenStyles)(tokenStyles)); | ||
cssMap.push((0, exports.createCSSClass)(className, collectedStyles)); | ||
if (conditions.length === 0) { | ||
@@ -128,5 +132,5 @@ return; | ||
var _b = teleport_shared_1.UIDLUtils.splitDynamicAndStaticStyles(styleRef.content), staticValues = _b.staticStyles, tokenValues = _b.tokenStyles; | ||
var collecedMediaStyles = __assign(__assign({}, style_utils_1.getContentOfStyleObject(staticValues)), style_utils_1.getCSSVariablesContentFromTokenStyles(tokenValues)); | ||
var collecedMediaStyles = __assign(__assign({}, (0, style_utils_1.getContentOfStyleObject)(staticValues)), (0, style_utils_1.getCSSVariablesContentFromTokenStyles)(tokenValues)); | ||
if (styleRef.type === 'element-state') { | ||
cssMap.push(exports.createCSSClassWithSelector(className, "&:" + styleRef.meta.state, collecedMediaStyles)); | ||
cssMap.push((0, exports.createCSSClassWithSelector)(className, "&:".concat(styleRef.meta.state), collecedMediaStyles)); | ||
} | ||
@@ -133,0 +137,0 @@ if (styleRef.type === 'screen-size') { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -6,6 +6,6 @@ "use strict"; | ||
exports.DEFAULT_TEMPLATE_SYNTAX = { | ||
interpolation: function (value) { return "{{ " + value + " }}"; }, | ||
eventBinding: function (value) { return "@" + value; }, | ||
valueBinding: function (value) { return ":" + value; }, | ||
eventEmmitter: function (value) { return "this.$emit('" + value + "')"; }, | ||
interpolation: function (value) { return "{{ ".concat(value, " }}"); }, | ||
eventBinding: function (value) { return "@".concat(value); }, | ||
valueBinding: function (value) { return ":".concat(value); }, | ||
eventEmmitter: function (value) { return "this.$emit('".concat(value, "')"); }, | ||
eventHandlersBindingMode: function (value) { return value; }, | ||
@@ -15,4 +15,4 @@ conditionalAttr: 'v-if', | ||
repeatIterator: function (iteratorName, iteratedCollection, useIndex) { | ||
var iterator = useIndex ? "(" + iteratorName + ", index)" : iteratorName; | ||
return iterator + " in " + iteratedCollection; | ||
var iterator = useIndex ? "(".concat(iteratorName, ", index)") : iteratorName; | ||
return "".concat(iterator, " in ").concat(iteratedCollection); | ||
}, | ||
@@ -19,0 +19,0 @@ customElementTagName: function (value) { return value; }, |
@@ -15,3 +15,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -53,3 +57,3 @@ if (k2 === undefined) k2 = k; | ||
existingDependency && (existingDependency === null || existingDependency === void 0 ? void 0 : existingDependency.path) !== (dependency === null || dependency === void 0 ? void 0 : dependency.path) | ||
? "" + teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(teleport_shared_1.StringUtils.removeIllegalCharacters(dependency.path)) + tagName | ||
? "".concat(teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(teleport_shared_1.StringUtils.removeIllegalCharacters(dependency.path))).concat(tagName) | ||
: tagName; | ||
@@ -67,7 +71,7 @@ dependencies[safeTagName] = __assign({}, dependency); | ||
} | ||
var htmlNode = hast_builders_1.createHTMLNode(safeTagName); | ||
var htmlNode = (0, hast_builders_1.createHTMLNode)(safeTagName); | ||
if (attrs) { | ||
Object.keys(attrs).forEach(function (attrKey) { | ||
var attrValue = attrs[attrKey]; | ||
utils_1.handleAttribute(htmlNode, name, attrKey, attrValue, params, templateSyntax, node); | ||
(0, utils_1.handleAttribute)(htmlNode, name, attrKey, attrValue, params, templateSyntax, node); | ||
}); | ||
@@ -77,3 +81,3 @@ } | ||
Object.keys(events).forEach(function (eventKey) { | ||
return utils_1.handleEvent(htmlNode, name, eventKey, events[eventKey], params, templateSyntax); | ||
return (0, utils_1.handleEvent)(htmlNode, name, eventKey, events[eventKey], params, templateSyntax); | ||
}); | ||
@@ -113,3 +117,3 @@ } | ||
default: | ||
throw new Error("generateHTMLSyntax encountered a node of unsupported type: " + JSON.stringify(node, null, 2)); | ||
throw new Error("generateHTMLSyntax encountered a node of unsupported type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -119,4 +123,4 @@ }; | ||
var attrKey = templateSyntax.domHTMLInjection ? templateSyntax.domHTMLInjection : 'innerHTML'; | ||
var htmlNode = hast_builders_1.createHTMLNode('span'); | ||
var dataObjName = "" + node.type + teleport_shared_1.StringUtils.generateRandomString(); | ||
var htmlNode = (0, hast_builders_1.createHTMLNode)('span'); | ||
var dataObjName = "".concat(node.type).concat(teleport_shared_1.StringUtils.generateRandomString()); | ||
hastUtils.addAttributeToNode(htmlNode, attrKey, dataObjName); | ||
@@ -147,7 +151,7 @@ params.dataObject[dataObjName] = node.content.toString(); | ||
if (typeof conditionalTag === 'string') { | ||
var wrappingSpan = hast_builders_1.createHTMLNode('span'); | ||
var wrappingSpan = (0, hast_builders_1.createHTMLNode)('span'); | ||
hastUtils.addTextNode(wrappingSpan, conditionalTag); | ||
conditionalTag = wrappingSpan; | ||
} | ||
var conditionalStatement = utils_1.createConditionalStatement(node); | ||
var conditionalStatement = (0, utils_1.createConditionalStatement)(node); | ||
hastUtils.addAttributeToNode(conditionalTag, templateSyntax.conditionalAttr, conditionalStatement); | ||
@@ -157,3 +161,3 @@ return conditionalTag; | ||
var generateSlotNode = function (node, params, templateSyntax) { | ||
var slotNode = hast_builders_1.createHTMLNode('slot'); | ||
var slotNode = (0, hast_builders_1.createHTMLNode)('slot'); | ||
if (node.content.name) { | ||
@@ -160,0 +164,0 @@ hastUtils.addAttributeToNode(slotNode, 'name', node.content.name); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -40,3 +44,3 @@ if (k2 === undefined) k2 = k; | ||
// The array will be placed on the dataObject and the data reference is placed on the node | ||
var dataObjectIdentifier = "" + elementName + teleport_shared_1.StringUtils.capitalize(attrKey); | ||
var dataObjectIdentifier = "".concat(elementName).concat(teleport_shared_1.StringUtils.capitalize(attrKey)); | ||
dataObject[dataObjectIdentifier] = attrValue.content; | ||
@@ -59,3 +63,3 @@ hastUtils.addAttributeToNode(htmlNode, dynamicAttrKey, dataObjectIdentifier); | ||
default: | ||
throw new Error("generateElementNode could not generate code for attribute of type " + JSON.stringify(attrValue)); | ||
throw new Error("generateElementNode could not generate code for attribute of type ".concat(JSON.stringify(attrValue))); | ||
} | ||
@@ -75,8 +79,8 @@ }; | ||
hastUtils.addAttributeToNode(htmlNode, eventHandlerKey, statement.newState === '$toggle' | ||
? statement.modifies + " = !" + statement.modifies | ||
: statement.modifies + " = " + statement.newState); | ||
? "".concat(statement.modifies, " = !").concat(statement.modifies) | ||
: "".concat(statement.modifies, " = ").concat(statement.newState)); | ||
} | ||
} | ||
else { | ||
var methodName = "handle" + teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(elementName) + teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(eventKey); | ||
var methodName = "handle".concat(teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(elementName)).concat(teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(eventKey)); | ||
var eventNameBiding = templateSyntax.eventHandlersBindingMode | ||
@@ -95,3 +99,3 @@ ? templateSyntax.eventHandlersBindingMode(methodName) | ||
if (childNode.type === 'conditional') { | ||
return statement + " && " + exports.createConditionalStatement(childNode); | ||
return "".concat(statement, " && ").concat((0, exports.createConditionalStatement)(childNode)); | ||
} | ||
@@ -116,16 +120,16 @@ return statement; | ||
var operation = _a.operation, operand = _a.operand; | ||
return "(" + stringifyConditionalExpression(conditionalKey, operation, operand) + ")"; | ||
return "(".concat(stringifyConditionalExpression(conditionalKey, operation, operand), ")"); | ||
}); | ||
var joinOperator = matchingCriteria === 'all' ? '&&' : '||'; | ||
return stringConditions.join(" " + joinOperator + " "); | ||
return stringConditions.join(" ".concat(joinOperator, " ")); | ||
}; | ||
var stringifyConditionalExpression = function (identifier, operation, value) { | ||
if (typeof value === 'boolean') { | ||
return "" + (value ? '' : '!') + identifier; | ||
return "".concat(value ? '' : '!').concat(identifier); | ||
} | ||
if (typeof value === 'string') { | ||
return identifier + " " + operation + " '" + value + "'"; | ||
return "".concat(identifier, " ").concat(operation, " '").concat(value, "'"); | ||
} | ||
return identifier + " " + operation + " " + value; | ||
return "".concat(identifier, " ").concat(operation, " ").concat(value); | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -15,3 +15,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -50,3 +54,3 @@ if (k2 === undefined) k2 = k; | ||
if (existingDependency && (existingDependency === null || existingDependency === void 0 ? void 0 : existingDependency.path) !== (dependency === null || dependency === void 0 ? void 0 : dependency.path)) { | ||
tagName = "" + teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(teleport_shared_1.StringUtils.removeIllegalCharacters(dependency.path)) + tagName; | ||
tagName = "".concat(teleport_shared_1.StringUtils.dashCaseToUpperCamelCase(teleport_shared_1.StringUtils.removeIllegalCharacters(dependency.path))).concat(tagName); | ||
dependencies[tagName] = __assign(__assign({}, dependency), { meta: __assign(__assign({}, dependency.meta), { originalName: originalElementName }) }); | ||
@@ -63,3 +67,3 @@ } | ||
: tagName; | ||
var elementTag = selfClosing ? ast_builders_1.createSelfClosingJSXTag(elementName) : ast_builders_1.createJSXTag(elementName); | ||
var elementTag = selfClosing ? (0, ast_builders_1.createSelfClosingJSXTag)(elementName) : (0, ast_builders_1.createJSXTag)(elementName); | ||
if (attrs) { | ||
@@ -72,6 +76,6 @@ Object.keys(attrs).forEach(function (attrKey) { | ||
var prefix = options.dynamicReferencePrefixMap[referenceType]; | ||
ast_utils_1.addDynamicAttributeToJSXTag(elementTag, attrKey, id, prefix); | ||
(0, ast_utils_1.addDynamicAttributeToJSXTag)(elementTag, attrKey, id, prefix); | ||
break; | ||
case 'import': | ||
ast_utils_1.addDynamicAttributeToJSXTag(elementTag, attrKey, attributeValue.content.id); | ||
(0, ast_utils_1.addDynamicAttributeToJSXTag)(elementTag, attrKey, attributeValue.content.id); | ||
break; | ||
@@ -81,6 +85,6 @@ case 'comp-style': | ||
var content = attributeValue.content; | ||
ast_utils_1.addAttributeToJSXTag(elementTag, attrKey, content); | ||
(0, ast_utils_1.addAttributeToJSXTag)(elementTag, attrKey, content); | ||
break; | ||
default: | ||
throw new Error("generateElementNode could not generate code for attribute of type " + JSON.stringify(attributeValue)); | ||
throw new Error("generateElementNode could not generate code for attribute of type ".concat(JSON.stringify(attributeValue))); | ||
} | ||
@@ -91,3 +95,3 @@ }); | ||
Object.keys(events).forEach(function (eventKey) { | ||
utils_1.addEventHandlerToTag(elementTag, eventKey, events[eventKey], params, options); | ||
(0, utils_1.addEventHandlerToTag)(elementTag, eventKey, events[eventKey], params, options); | ||
}); | ||
@@ -99,9 +103,9 @@ } | ||
if (typeof childTag === 'string') { | ||
ast_utils_1.addChildJSXText(elementTag, childTag); | ||
(0, ast_utils_1.addChildJSXText)(elementTag, childTag); | ||
} | ||
else if (childTag.type === 'JSXExpressionContainer' || childTag.type === 'JSXElement') { | ||
ast_utils_1.addChildJSXTag(elementTag, childTag); | ||
(0, ast_utils_1.addChildJSXTag)(elementTag, childTag); | ||
} | ||
else { | ||
ast_utils_1.addChildJSXTag(elementTag, types.jsxExpressionContainer(childTag)); | ||
(0, ast_utils_1.addChildJSXTag)(elementTag, types.jsxExpressionContainer(childTag)); | ||
} | ||
@@ -123,3 +127,3 @@ }); | ||
case 'dynamic': | ||
return utils_1.createDynamicValueExpression(node, options); | ||
return (0, utils_1.createDynamicValueExpression)(node, options); | ||
case 'element': | ||
@@ -139,3 +143,3 @@ return generateElementNode(node, params, options); | ||
default: | ||
throw new Error("generateNodeSyntax encountered a node of unsupported type: " + JSON.stringify(node, null, 2)); | ||
throw new Error("generateNodeSyntax encountered a node of unsupported type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -148,4 +152,4 @@ }; | ||
var localIteratorPrefix = options.dynamicReferencePrefixMap.local; | ||
ast_utils_1.addDynamicAttributeToJSXTag(contentAST, 'key', iteratorKey, localIteratorPrefix); | ||
var source = utils_1.getRepeatSourceIdentifier(dataSource, options); | ||
(0, ast_utils_1.addDynamicAttributeToJSXTag)(contentAST, 'key', iteratorKey, localIteratorPrefix); | ||
var source = (0, utils_1.getRepeatSourceIdentifier)(dataSource, options); | ||
var arrowFunctionArguments = [types.identifier(iteratorName)]; | ||
@@ -161,3 +165,3 @@ if (meta.useIndex) { | ||
var _a = node.content, reference = _a.reference, value = _a.value; | ||
var conditionIdentifier = utils_1.createConditionIdentifier(reference, params, options); | ||
var conditionIdentifier = (0, utils_1.createConditionIdentifier)(reference, params, options); | ||
var subTree = generateNode(node.content.node, params, options); | ||
@@ -167,3 +171,3 @@ var condition = value !== undefined && value !== null | ||
: node.content.condition; | ||
return utils_1.createConditionalJSXExpression(subTree, condition, conditionIdentifier); | ||
return (0, utils_1.createConditionalJSXExpression)(subTree, condition, conditionIdentifier); | ||
}; | ||
@@ -180,3 +184,3 @@ var generatePropsSlotNode = function (node, params, options) { | ||
}; | ||
var childrenExpression = utils_1.createDynamicValueExpression(childrenProp, options); | ||
var childrenExpression = (0, utils_1.createDynamicValueExpression)(childrenProp, options); | ||
if (node.content.fallback) { | ||
@@ -194,5 +198,5 @@ var fallbackContent = generateNode(node.content.fallback, params, options); | ||
var generateNativeSlotNode = function (node, params, options) { | ||
var slotNode = ast_builders_1.createSelfClosingJSXTag('slot'); | ||
var slotNode = (0, ast_builders_1.createSelfClosingJSXTag)('slot'); | ||
if (node.content.name) { | ||
ast_utils_1.addAttributeToJSXTag(slotNode, 'name', node.content.name); | ||
(0, ast_utils_1.addAttributeToJSXTag)(slotNode, 'name', node.content.name); | ||
} | ||
@@ -202,9 +206,9 @@ if (node.content.fallback) { | ||
if (typeof fallbackContent === 'string') { | ||
ast_utils_1.addChildJSXText(slotNode, fallbackContent); | ||
(0, ast_utils_1.addChildJSXText)(slotNode, fallbackContent); | ||
} | ||
else if (fallbackContent.type === 'MemberExpression') { | ||
ast_utils_1.addChildJSXTag(slotNode, types.jsxExpressionContainer(fallbackContent)); | ||
(0, ast_utils_1.addChildJSXTag)(slotNode, types.jsxExpressionContainer(fallbackContent)); | ||
} | ||
else { | ||
ast_utils_1.addChildJSXTag(slotNode, fallbackContent); | ||
(0, ast_utils_1.addChildJSXTag)(slotNode, fallbackContent); | ||
} | ||
@@ -211,0 +215,0 @@ } |
@@ -12,2 +12,2 @@ import * as types from '@babel/types'; | ||
}, conditionalIdentifier: ConditionalIdentifier, t?: typeof types) => types.BinaryExpression | types.Identifier | types.MemberExpression | types.UnaryExpression; | ||
export declare const getRepeatSourceIdentifier: (dataSource: UIDLAttributeValue, options: JSXGenerationOptions) => types.MemberExpression | (types.ArrayExpression | types.BooleanLiteral | types.Identifier | types.StringLiteral | types.NumericLiteral | types.NullLiteral | types.ObjectExpression); | ||
export declare const getRepeatSourceIdentifier: (dataSource: UIDLAttributeValue, options: JSXGenerationOptions) => types.MemberExpression | (types.ArrayExpression | types.BooleanLiteral | types.Identifier | types.NullLiteral | types.NumericLiteral | types.ObjectExpression | types.StringLiteral); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -21,6 +25,10 @@ if (k2 === undefined) k2 = k; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -75,3 +83,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
if (!propDefinition || propDefinition.type !== 'func') { | ||
console.warn("No prop definition was found for \"" + propFunctionKey + "\""); | ||
console.warn("No prop definition was found for \"".concat(propFunctionKey, "\"")); | ||
return null; | ||
@@ -82,3 +90,3 @@ } | ||
: ''; | ||
return t.expressionStatement(t.callExpression(t.identifier(prefix + propFunctionKey), __spreadArray([], args.map(function (arg) { return ast_utils_1.convertValueToLiteral(arg); })))); | ||
return t.expressionStatement(t.callExpression(t.identifier(prefix + propFunctionKey), __spreadArray([], args.map(function (arg) { return (0, ast_utils_1.convertValueToLiteral)(arg); }), true))); | ||
}; | ||
@@ -98,6 +106,6 @@ var createStateChangeStatement = function (eventHandlerStatement, stateDefinitions, options, t) { | ||
? t.unaryExpression('!', t.identifier(statePrefix + stateKey)) | ||
: ast_utils_1.convertValueToLiteral(eventHandlerStatement.newState, stateDefinition.type); | ||
: (0, ast_utils_1.convertValueToLiteral)(eventHandlerStatement.newState, stateDefinition.type); | ||
switch (options.stateHandling) { | ||
case 'hooks': | ||
return t.expressionStatement(t.callExpression(t.identifier("set" + teleport_shared_1.StringUtils.capitalize(stateKey)), [newStateValue])); | ||
return t.expressionStatement(t.callExpression(t.identifier("set".concat(teleport_shared_1.StringUtils.capitalize(stateKey))), [newStateValue])); | ||
case 'function': | ||
@@ -141,3 +149,3 @@ return t.expressionStatement(t.callExpression(t.identifier('this.setState'), [ | ||
default: | ||
throw new Error("createConditionIdentifier encountered an invalid reference type: " + JSON.stringify(dynamicReference, null, 2)); | ||
throw new Error("createConditionIdentifier encountered an invalid reference type: ".concat(JSON.stringify(dynamicReference, null, 2))); | ||
} | ||
@@ -162,3 +170,3 @@ }; | ||
var binaryExpressions = conditions.map(function (condition) { | ||
return exports.createBinaryExpression(condition, conditionalIdentifier); | ||
return (0, exports.createBinaryExpression)(condition, conditionalIdentifier); | ||
}); | ||
@@ -197,3 +205,3 @@ if (binaryExpressions.length === 1) { | ||
if (operand !== undefined) { | ||
var stateValueIdentifier = ast_utils_1.convertValueToLiteral(operand, conditionalIdentifier.type); | ||
var stateValueIdentifier = (0, ast_utils_1.convertValueToLiteral)(operand, conditionalIdentifier.type); | ||
return t.binaryExpression(convertToBinaryOperator(operation), identifier, stateValueIdentifier); | ||
@@ -231,8 +239,8 @@ } | ||
case 'static': | ||
return ast_utils_1.convertValueToLiteral(dataSource.content); | ||
return (0, ast_utils_1.convertValueToLiteral)(dataSource.content); | ||
case 'dynamic': { | ||
return exports.createDynamicValueExpression(dataSource, options); | ||
return (0, exports.createDynamicValueExpression)(dataSource, options); | ||
} | ||
default: | ||
throw new Error("Invalid type for dataSource: " + dataSource); | ||
throw new Error("Invalid type for dataSource: ".concat(dataSource)); | ||
} | ||
@@ -239,0 +247,0 @@ }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -21,6 +25,10 @@ if (k2 === undefined) k2 = k; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -130,3 +138,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
if (t === void 0) { t = types; } | ||
var formmattedString = "\n" + str + "\n "; | ||
var formmattedString = "\n".concat(str, "\n "); | ||
return t.templateLiteral([ | ||
@@ -165,3 +173,3 @@ t.templateElement({ | ||
} | ||
return t.jsxExpressionContainer(exports.convertValueToLiteral(value)); | ||
return t.jsxExpressionContainer((0, exports.convertValueToLiteral)(value)); | ||
}; | ||
@@ -210,3 +218,3 @@ var addChildJSXTag = function (tag, childNode, t) { | ||
else if (Array.isArray(value)) { | ||
computedLiteralValue = t.arrayExpression(value.map(function (element) { return exports.convertValueToLiteral(element); })); | ||
computedLiteralValue = t.arrayExpression(value.map(function (element) { return (0, exports.convertValueToLiteral)(element); })); | ||
} | ||
@@ -217,3 +225,3 @@ else if (value === Object) { | ||
else if (typeof value === 'object') { | ||
computedLiteralValue = exports.objectToObjectExpression(value, t); | ||
computedLiteralValue = (0, exports.objectToObjectExpression)(value, t); | ||
} | ||
@@ -248,3 +256,3 @@ else if (value === String) { | ||
if (Array.isArray(value)) { | ||
return t.arrayExpression(value.map(function (val) { return exports.convertValueToLiteral(val); })); | ||
return t.arrayExpression(value.map(function (val) { return (0, exports.convertValueToLiteral)(val); })); | ||
} | ||
@@ -260,3 +268,3 @@ var typeToCompare = explicitType ? explicitType : typeof value; | ||
case 'object': | ||
return exports.objectToObjectExpression(value); | ||
return (0, exports.objectToObjectExpression)(value); | ||
default: | ||
@@ -271,3 +279,3 @@ return t.identifier(value.toString()); | ||
if (t === void 0) { t = types; } | ||
obj.properties.push(t.objectProperty(t.identifier(key), exports.convertValueToLiteral(value))); | ||
obj.properties.push(t.objectProperty(t.identifier(key), (0, exports.convertValueToLiteral)(value))); | ||
}; | ||
@@ -312,3 +320,3 @@ exports.addPropertyToASTObject = addPropertyToASTObject; | ||
var stateDefinition = stateDefinitions[stateKey]; | ||
return t.objectProperty(t.identifier(stateKey), exports.convertValueToLiteral(stateDefinition.defaultValue)); | ||
return t.objectProperty(t.identifier(stateKey), (0, exports.convertValueToLiteral)(stateDefinition.defaultValue)); | ||
}); | ||
@@ -318,5 +326,5 @@ classMethodsAndProperties.push(t.classProperty(t.identifier('state'), t.objectExpression(stateDeclarationsAST))); | ||
} | ||
var classBody = t.classBody(__spreadArray(__spreadArray([], classMethodsAndProperties), [ | ||
var classBody = t.classBody(__spreadArray(__spreadArray([], classMethodsAndProperties, true), [ | ||
t.classMethod('method', t.identifier('render'), renderMethodArguments, t.blockStatement([t.returnStatement(jsxTagTree)])), | ||
])); | ||
], false)); | ||
var classDeclaration = t.classDeclaration(t.identifier(name), t.identifier('Component'), classBody, null); | ||
@@ -328,3 +336,3 @@ return classDeclaration; | ||
if (t === void 0) { t = types; } | ||
var arrowFunctionBody = exports.createReturnExpressionSyntax(stateDefinitions, jsxTagTree); | ||
var arrowFunctionBody = (0, exports.createReturnExpressionSyntax)(stateDefinitions, jsxTagTree); | ||
var arrowFunction = t.arrowFunctionExpression([t.identifier('props')], arrowFunctionBody); | ||
@@ -340,5 +348,5 @@ var declarator = t.variableDeclarator(t.identifier(name), arrowFunction); | ||
var stateHooks = Object.keys(stateDefinitions).map(function (stateKey) { | ||
return exports.createStateHookAST(stateKey, stateDefinitions[stateKey]); | ||
return (0, exports.createStateHookAST)(stateKey, stateDefinitions[stateKey]); | ||
}); | ||
return t.blockStatement(__spreadArray(__spreadArray([], stateHooks), [returnStatement]) || []); | ||
return t.blockStatement(__spreadArray(__spreadArray([], stateHooks, true), [returnStatement], false) || []); | ||
}; | ||
@@ -351,7 +359,7 @@ exports.createReturnExpressionSyntax = createReturnExpressionSyntax; | ||
if (t === void 0) { t = types; } | ||
var defaultValueArgument = exports.convertValueToLiteral(stateDefinition.defaultValue, stateDefinition.type); | ||
var defaultValueArgument = (0, exports.convertValueToLiteral)(stateDefinition.defaultValue, stateDefinition.type); | ||
return t.variableDeclaration('const', [ | ||
t.variableDeclarator(t.arrayPattern([ | ||
t.identifier(stateKey), | ||
t.identifier("set" + teleport_shared_1.StringUtils.capitalize(stateKey)), | ||
t.identifier("set".concat(teleport_shared_1.StringUtils.capitalize(stateKey))), | ||
]), t.callExpression(t.identifier('useState'), [defaultValueArgument])), | ||
@@ -358,0 +366,0 @@ ]); |
@@ -26,5 +26,5 @@ "use strict"; | ||
var addTextNode = function (node, text) { | ||
node.children.push(hast_builders_1.createTextNode(text)); | ||
node.children.push((0, hast_builders_1.createTextNode)(text)); | ||
}; | ||
exports.addTextNode = addTextNode; | ||
//# sourceMappingURL=hast-utils.js.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
} | ||
throw new Error("getContentOfStyleKey received unsupported " + JSON.stringify(styleValue, null, 2) + " UIDLNodeStyleValue value"); | ||
throw new Error("getContentOfStyleKey received unsupported ".concat(JSON.stringify(styleValue, null, 2), " UIDLNodeStyleValue value")); | ||
}; | ||
@@ -30,3 +30,3 @@ var getContentOfStyleObject = function (styleObject) { | ||
if (style.type === 'dynamic' && style.content.referenceType === 'token') { | ||
acc[key] = "var(" + teleport_shared_1.StringUtils.generateCSSVariableName(style.content.id) + ")"; | ||
acc[key] = "var(".concat(teleport_shared_1.StringUtils.generateCSSVariableName(style.content.id), ")"); | ||
} | ||
@@ -33,0 +33,0 @@ return acc; |
@@ -1,5 +0,9 @@ | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -49,3 +53,3 @@ import * as types from '@babel/types'; | ||
return t.importSpecifier(t.identifier(imp.identifierName), t.identifier(imp.originalName || imp.identifierName)); | ||
})); | ||
}), true); | ||
} | ||
@@ -52,0 +56,0 @@ else { |
@@ -43,3 +43,3 @@ var __assign = (this && this.__assign) || function () { | ||
return jss | ||
.createRule("@media(" + mediaOffset + ")", styleObject, { | ||
.createRule("@media(".concat(mediaOffset, ")"), styleObject, { | ||
generateId: function (data) { return data.key; }, | ||
@@ -59,5 +59,5 @@ }) | ||
case 'token': | ||
return "var(" + StringUtils.generateCSSVariableName(styleValue.content.id) + ")"; | ||
return "var(".concat(StringUtils.generateCSSVariableName(styleValue.content.id), ")"); | ||
default: | ||
throw new Error("createDynamicStyleExpression received unsupported " + JSON.stringify(styleValue, null, 2) + " UIDLDynamicReference value"); | ||
throw new Error("createDynamicStyleExpression received unsupported ".concat(JSON.stringify(styleValue, null, 2), " UIDLDynamicReference value")); | ||
} | ||
@@ -71,3 +71,3 @@ }; | ||
.forEach(function (mediaOffset) { | ||
styles.push(createCSSClassWithMediaQuery("max-width: " + mediaOffset + "px", | ||
styles.push(createCSSClassWithMediaQuery("max-width: ".concat(mediaOffset, "px"), | ||
// @ts-ignore | ||
@@ -84,3 +84,3 @@ mediaStylesMap[mediaOffset])); | ||
var className = forceScoping | ||
? componentFileName + "-" + StringUtils.camelCaseToDashCase(styleId) | ||
? "".concat(componentFileName, "-").concat(StringUtils.camelCaseToDashCase(styleId)) | ||
: styleId; | ||
@@ -98,3 +98,3 @@ var _b = UIDLUtils.splitDynamicAndStaticStyles(content), staticStyles = _b.staticStyles, tokenStyles = _b.tokenStyles; | ||
if (styleRef.type === 'element-state') { | ||
cssMap.push(createCSSClassWithSelector(className, "&:" + styleRef.meta.state, collecedMediaStyles)); | ||
cssMap.push(createCSSClassWithSelector(className, "&:".concat(styleRef.meta.state), collecedMediaStyles)); | ||
} | ||
@@ -101,0 +101,0 @@ if (styleRef.type === 'screen-size') { |
// Vue.js template values | ||
export var DEFAULT_TEMPLATE_SYNTAX = { | ||
interpolation: function (value) { return "{{ " + value + " }}"; }, | ||
eventBinding: function (value) { return "@" + value; }, | ||
valueBinding: function (value) { return ":" + value; }, | ||
eventEmmitter: function (value) { return "this.$emit('" + value + "')"; }, | ||
interpolation: function (value) { return "{{ ".concat(value, " }}"); }, | ||
eventBinding: function (value) { return "@".concat(value); }, | ||
valueBinding: function (value) { return ":".concat(value); }, | ||
eventEmmitter: function (value) { return "this.$emit('".concat(value, "')"); }, | ||
eventHandlersBindingMode: function (value) { return value; }, | ||
@@ -11,4 +11,4 @@ conditionalAttr: 'v-if', | ||
repeatIterator: function (iteratorName, iteratedCollection, useIndex) { | ||
var iterator = useIndex ? "(" + iteratorName + ", index)" : iteratorName; | ||
return iterator + " in " + iteratedCollection; | ||
var iterator = useIndex ? "(".concat(iteratorName, ", index)") : iteratorName; | ||
return "".concat(iterator, " in ").concat(iteratedCollection); | ||
}, | ||
@@ -15,0 +15,0 @@ customElementTagName: function (value) { return value; }, |
@@ -31,3 +31,3 @@ var __assign = (this && this.__assign) || function () { | ||
existingDependency && (existingDependency === null || existingDependency === void 0 ? void 0 : existingDependency.path) !== (dependency === null || dependency === void 0 ? void 0 : dependency.path) | ||
? "" + StringUtils.dashCaseToUpperCamelCase(StringUtils.removeIllegalCharacters(dependency.path)) + tagName | ||
? "".concat(StringUtils.dashCaseToUpperCamelCase(StringUtils.removeIllegalCharacters(dependency.path))).concat(tagName) | ||
: tagName; | ||
@@ -89,3 +89,3 @@ dependencies[safeTagName] = __assign({}, dependency); | ||
default: | ||
throw new Error("generateHTMLSyntax encountered a node of unsupported type: " + JSON.stringify(node, null, 2)); | ||
throw new Error("generateHTMLSyntax encountered a node of unsupported type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -96,3 +96,3 @@ }; | ||
var htmlNode = createHTMLNode('span'); | ||
var dataObjName = "" + node.type + StringUtils.generateRandomString(); | ||
var dataObjName = "".concat(node.type).concat(StringUtils.generateRandomString()); | ||
hastUtils.addAttributeToNode(htmlNode, attrKey, dataObjName); | ||
@@ -99,0 +99,0 @@ params.dataObject[dataObjName] = node.content.toString(); |
@@ -18,3 +18,3 @@ import * as hastUtils from '../../utils/hast-utils'; | ||
// The array will be placed on the dataObject and the data reference is placed on the node | ||
var dataObjectIdentifier = "" + elementName + StringUtils.capitalize(attrKey); | ||
var dataObjectIdentifier = "".concat(elementName).concat(StringUtils.capitalize(attrKey)); | ||
dataObject[dataObjectIdentifier] = attrValue.content; | ||
@@ -37,3 +37,3 @@ hastUtils.addAttributeToNode(htmlNode, dynamicAttrKey, dataObjectIdentifier); | ||
default: | ||
throw new Error("generateElementNode could not generate code for attribute of type " + JSON.stringify(attrValue)); | ||
throw new Error("generateElementNode could not generate code for attribute of type ".concat(JSON.stringify(attrValue))); | ||
} | ||
@@ -52,8 +52,8 @@ }; | ||
hastUtils.addAttributeToNode(htmlNode, eventHandlerKey, statement.newState === '$toggle' | ||
? statement.modifies + " = !" + statement.modifies | ||
: statement.modifies + " = " + statement.newState); | ||
? "".concat(statement.modifies, " = !").concat(statement.modifies) | ||
: "".concat(statement.modifies, " = ").concat(statement.newState)); | ||
} | ||
} | ||
else { | ||
var methodName = "handle" + StringUtils.dashCaseToUpperCamelCase(elementName) + StringUtils.dashCaseToUpperCamelCase(eventKey); | ||
var methodName = "handle".concat(StringUtils.dashCaseToUpperCamelCase(elementName)).concat(StringUtils.dashCaseToUpperCamelCase(eventKey)); | ||
var eventNameBiding = templateSyntax.eventHandlersBindingMode | ||
@@ -71,3 +71,3 @@ ? templateSyntax.eventHandlersBindingMode(methodName) | ||
if (childNode.type === 'conditional') { | ||
return statement + " && " + createConditionalStatement(childNode); | ||
return "".concat(statement, " && ").concat(createConditionalStatement(childNode)); | ||
} | ||
@@ -91,16 +91,16 @@ return statement; | ||
var operation = _a.operation, operand = _a.operand; | ||
return "(" + stringifyConditionalExpression(conditionalKey, operation, operand) + ")"; | ||
return "(".concat(stringifyConditionalExpression(conditionalKey, operation, operand), ")"); | ||
}); | ||
var joinOperator = matchingCriteria === 'all' ? '&&' : '||'; | ||
return stringConditions.join(" " + joinOperator + " "); | ||
return stringConditions.join(" ".concat(joinOperator, " ")); | ||
}; | ||
var stringifyConditionalExpression = function (identifier, operation, value) { | ||
if (typeof value === 'boolean') { | ||
return "" + (value ? '' : '!') + identifier; | ||
return "".concat(value ? '' : '!').concat(identifier); | ||
} | ||
if (typeof value === 'string') { | ||
return identifier + " " + operation + " '" + value + "'"; | ||
return "".concat(identifier, " ").concat(operation, " '").concat(value, "'"); | ||
} | ||
return identifier + " " + operation + " " + value; | ||
return "".concat(identifier, " ").concat(operation, " ").concat(value); | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -28,3 +28,3 @@ var __assign = (this && this.__assign) || function () { | ||
if (existingDependency && (existingDependency === null || existingDependency === void 0 ? void 0 : existingDependency.path) !== (dependency === null || dependency === void 0 ? void 0 : dependency.path)) { | ||
tagName = "" + StringUtils.dashCaseToUpperCamelCase(StringUtils.removeIllegalCharacters(dependency.path)) + tagName; | ||
tagName = "".concat(StringUtils.dashCaseToUpperCamelCase(StringUtils.removeIllegalCharacters(dependency.path))).concat(tagName); | ||
dependencies[tagName] = __assign(__assign({}, dependency), { meta: __assign(__assign({}, dependency.meta), { originalName: originalElementName }) }); | ||
@@ -60,3 +60,3 @@ } | ||
default: | ||
throw new Error("generateElementNode could not generate code for attribute of type " + JSON.stringify(attributeValue)); | ||
throw new Error("generateElementNode could not generate code for attribute of type ".concat(JSON.stringify(attributeValue))); | ||
} | ||
@@ -112,3 +112,3 @@ }); | ||
default: | ||
throw new Error("generateNodeSyntax encountered a node of unsupported type: " + JSON.stringify(node, null, 2)); | ||
throw new Error("generateNodeSyntax encountered a node of unsupported type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -115,0 +115,0 @@ }; |
@@ -12,2 +12,2 @@ import * as types from '@babel/types'; | ||
}, conditionalIdentifier: ConditionalIdentifier, t?: typeof types) => types.BinaryExpression | types.Identifier | types.MemberExpression | types.UnaryExpression; | ||
export declare const getRepeatSourceIdentifier: (dataSource: UIDLAttributeValue, options: JSXGenerationOptions) => types.MemberExpression | (types.ArrayExpression | types.BooleanLiteral | types.Identifier | types.StringLiteral | types.NumericLiteral | types.NullLiteral | types.ObjectExpression); | ||
export declare const getRepeatSourceIdentifier: (dataSource: UIDLAttributeValue, options: JSXGenerationOptions) => types.MemberExpression | (types.ArrayExpression | types.BooleanLiteral | types.Identifier | types.NullLiteral | types.NumericLiteral | types.ObjectExpression | types.StringLiteral); |
@@ -1,5 +0,9 @@ | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -51,3 +55,3 @@ import * as types from '@babel/types'; | ||
if (!propDefinition || propDefinition.type !== 'func') { | ||
console.warn("No prop definition was found for \"" + propFunctionKey + "\""); | ||
console.warn("No prop definition was found for \"".concat(propFunctionKey, "\"")); | ||
return null; | ||
@@ -58,3 +62,3 @@ } | ||
: ''; | ||
return t.expressionStatement(t.callExpression(t.identifier(prefix + propFunctionKey), __spreadArray([], args.map(function (arg) { return convertValueToLiteral(arg); })))); | ||
return t.expressionStatement(t.callExpression(t.identifier(prefix + propFunctionKey), __spreadArray([], args.map(function (arg) { return convertValueToLiteral(arg); }), true))); | ||
}; | ||
@@ -77,3 +81,3 @@ var createStateChangeStatement = function (eventHandlerStatement, stateDefinitions, options, t) { | ||
case 'hooks': | ||
return t.expressionStatement(t.callExpression(t.identifier("set" + StringUtils.capitalize(stateKey)), [newStateValue])); | ||
return t.expressionStatement(t.callExpression(t.identifier("set".concat(StringUtils.capitalize(stateKey))), [newStateValue])); | ||
case 'function': | ||
@@ -116,3 +120,3 @@ return t.expressionStatement(t.callExpression(t.identifier('this.setState'), [ | ||
default: | ||
throw new Error("createConditionIdentifier encountered an invalid reference type: " + JSON.stringify(dynamicReference, null, 2)); | ||
throw new Error("createConditionIdentifier encountered an invalid reference type: ".concat(JSON.stringify(dynamicReference, null, 2))); | ||
} | ||
@@ -206,5 +210,5 @@ }; | ||
default: | ||
throw new Error("Invalid type for dataSource: " + dataSource); | ||
throw new Error("Invalid type for dataSource: ".concat(dataSource)); | ||
} | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,5 +0,9 @@ | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -101,3 +105,3 @@ import * as types from '@babel/types'; | ||
if (t === void 0) { t = types; } | ||
var formmattedString = "\n" + str + "\n "; | ||
var formmattedString = "\n".concat(str, "\n "); | ||
return t.templateLiteral([ | ||
@@ -270,5 +274,5 @@ t.templateElement({ | ||
} | ||
var classBody = t.classBody(__spreadArray(__spreadArray([], classMethodsAndProperties), [ | ||
var classBody = t.classBody(__spreadArray(__spreadArray([], classMethodsAndProperties, true), [ | ||
t.classMethod('method', t.identifier('render'), renderMethodArguments, t.blockStatement([t.returnStatement(jsxTagTree)])), | ||
])); | ||
], false)); | ||
var classDeclaration = t.classDeclaration(t.identifier(name), t.identifier('Component'), classBody, null); | ||
@@ -291,3 +295,3 @@ return classDeclaration; | ||
}); | ||
return t.blockStatement(__spreadArray(__spreadArray([], stateHooks), [returnStatement]) || []); | ||
return t.blockStatement(__spreadArray(__spreadArray([], stateHooks, true), [returnStatement], false) || []); | ||
}; | ||
@@ -303,3 +307,3 @@ /** | ||
t.identifier(stateKey), | ||
t.identifier("set" + StringUtils.capitalize(stateKey)), | ||
t.identifier("set".concat(StringUtils.capitalize(stateKey))), | ||
]), t.callExpression(t.identifier('useState'), [defaultValueArgument])), | ||
@@ -306,0 +310,0 @@ ]); |
@@ -6,3 +6,3 @@ import { StringUtils } from '@teleporthq/teleport-shared'; | ||
} | ||
throw new Error("getContentOfStyleKey received unsupported " + JSON.stringify(styleValue, null, 2) + " UIDLNodeStyleValue value"); | ||
throw new Error("getContentOfStyleKey received unsupported ".concat(JSON.stringify(styleValue, null, 2), " UIDLNodeStyleValue value")); | ||
}; | ||
@@ -25,3 +25,3 @@ export var getContentOfStyleObject = function (styleObject) { | ||
if (style.type === 'dynamic' && style.content.referenceType === 'token') { | ||
acc[key] = "var(" + StringUtils.generateCSSVariableName(style.content.id) + ")"; | ||
acc[key] = "var(".concat(StringUtils.generateCSSVariableName(style.content.id), ")"); | ||
} | ||
@@ -28,0 +28,0 @@ return acc; |
{ | ||
"name": "@teleporthq/teleport-plugin-common", | ||
"version": "0.19.18", | ||
"version": "0.19.19", | ||
"description": "Common building and modelating functions for ASTs and HASTs", | ||
@@ -28,8 +28,8 @@ "author": "teleportHQ", | ||
"@babel/types": "^7.14.5", | ||
"@teleporthq/teleport-shared": "^0.19.17", | ||
"@teleporthq/teleport-types": "^0.19.17", | ||
"@teleporthq/teleport-shared": "^0.19.19", | ||
"@teleporthq/teleport-types": "^0.19.19", | ||
"jss": "^10.0.0", | ||
"jss-preset-default": "^10.0.0" | ||
}, | ||
"gitHead": "f286e365fd8a9936f89952ee6f84e33b192c3dc7" | ||
"gitHead": "154a51920ecfcdec93d08b9db2911a2969b61d5c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
414523
1.08%5931
0.95%