@teleporthq/teleport-shared
Advanced tools
Comparing version 0.31.0-alpha.0 to 0.31.0
@@ -132,2 +132,5 @@ import { | ||
}) | ||
it('works with multiple upper case characters to be in a sequence', () => { | ||
expect(camelCaseToDashCase('PRImaryButton')).toBe('pr-imary-button') | ||
}) | ||
}) | ||
@@ -134,0 +137,0 @@ |
@@ -1,7 +0,4 @@ | ||
import { PrettierFormatOptions, UIDLDependency } from '@teleporthq/teleport-types'; | ||
import { PrettierFormatOptions } from '@teleporthq/teleport-types'; | ||
export declare const ASSETS_IDENTIFIER = "playground_assets"; | ||
export declare const PRETTIER_CONFIG: PrettierFormatOptions; | ||
export declare const USE_ROUTER_DEPENDENCY: UIDLDependency; | ||
export declare const USE_EFFECT_DEPENDENCY: UIDLDependency; | ||
export declare const USE_STATE_DEPENDENCY: UIDLDependency; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.USE_STATE_DEPENDENCY = exports.USE_EFFECT_DEPENDENCY = exports.USE_ROUTER_DEPENDENCY = exports.PRETTIER_CONFIG = exports.ASSETS_IDENTIFIER = void 0; | ||
exports.PRETTIER_CONFIG = exports.ASSETS_IDENTIFIER = void 0; | ||
exports.ASSETS_IDENTIFIER = 'playground_assets'; | ||
@@ -15,26 +15,2 @@ exports.PRETTIER_CONFIG = { | ||
}; | ||
exports.USE_ROUTER_DEPENDENCY = { | ||
type: 'library', | ||
path: 'next/router', | ||
version: '12.1.0', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
exports.USE_EFFECT_DEPENDENCY = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
exports.USE_STATE_DEPENDENCY = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
//# sourceMappingURL=index.js.map |
import * as Constants from './constants'; | ||
import * as StringUtils from './utils/string-utils'; | ||
import * as UIDLUtils from './utils/uidl-utils'; | ||
import * as GenericUtils from './utils/generic'; | ||
export { Constants, StringUtils, UIDLUtils, GenericUtils }; | ||
export { Constants, StringUtils, UIDLUtils }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GenericUtils = exports.UIDLUtils = exports.StringUtils = exports.Constants = void 0; | ||
exports.UIDLUtils = exports.StringUtils = exports.Constants = void 0; | ||
var Constants = __importStar(require("./constants")); | ||
@@ -34,4 +34,2 @@ exports.Constants = Constants; | ||
exports.UIDLUtils = UIDLUtils; | ||
var GenericUtils = __importStar(require("./utils/generic")); | ||
exports.GenericUtils = GenericUtils; | ||
//# sourceMappingURL=index.js.map |
export declare const camelCaseToDashCase: (str: string) => string; | ||
export declare const dashCaseToCamelCase: (str: string) => string; | ||
export declare const capitalize: (str: string) => string; | ||
export declare const camelize: (str: string) => string; | ||
export declare const dashCaseToUpperCamelCase: (str: string) => string; | ||
export declare const removeIllegalCharacters: (str: string) => string; | ||
export declare const slugify: (str: string) => string; | ||
export declare const createStateOrPropStoringValue: (value: string) => string; | ||
export declare const createStateStoringFunction: (value: string) => string; | ||
export declare const addSpacesToEachLine: (spaces: string, str: string) => string; | ||
@@ -11,0 +8,0 @@ export declare const removeLastEmptyLine: (str: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateCSSVariableName = exports.generateRandomString = exports.encode = exports.removeLastEmptyLine = exports.addSpacesToEachLine = exports.createStateStoringFunction = exports.createStateOrPropStoringValue = exports.slugify = exports.removeIllegalCharacters = exports.dashCaseToUpperCamelCase = exports.camelize = exports.capitalize = exports.dashCaseToCamelCase = exports.camelCaseToDashCase = void 0; | ||
exports.generateCSSVariableName = exports.generateRandomString = exports.encode = exports.removeLastEmptyLine = exports.addSpacesToEachLine = exports.slugify = exports.removeIllegalCharacters = exports.dashCaseToUpperCamelCase = exports.capitalize = exports.dashCaseToCamelCase = exports.camelCaseToDashCase = void 0; | ||
var camelCaseToDashCase = function (str) { | ||
return str.replace(/([a-z])(?=[A-Z])|([A-Z0-9])(?=[A-Z][a-z])/g, '$1-').toLowerCase(); | ||
return str.replace(/([a-z])(?=[A-Z])|([A-Z0-9][A-Z])(?=[A-Z][a-z])/g, '$1$2-').toLowerCase(); | ||
}; | ||
@@ -14,4 +14,2 @@ exports.camelCaseToDashCase = camelCaseToDashCase; | ||
exports.capitalize = capitalize; | ||
var camelize = function (str) { return str[0].toLowerCase() + str.slice(1); }; | ||
exports.camelize = camelize; | ||
var dashCaseToUpperCamelCase = function (str) { return (0, exports.capitalize)((0, exports.dashCaseToCamelCase)(str)); }; | ||
@@ -45,8 +43,2 @@ exports.dashCaseToUpperCamelCase = dashCaseToUpperCamelCase; | ||
exports.slugify = slugify; | ||
var createStateOrPropStoringValue = function (value) { return (0, exports.camelize)((0, exports.dashCaseToCamelCase)(value)); }; | ||
exports.createStateOrPropStoringValue = createStateOrPropStoringValue; | ||
var createStateStoringFunction = function (value) { | ||
return "set".concat((0, exports.capitalize)((0, exports.dashCaseToUpperCamelCase)(value))); | ||
}; | ||
exports.createStateStoringFunction = createStateStoringFunction; | ||
var addSpacesToEachLine = function (spaces, str) { | ||
@@ -53,0 +45,0 @@ // indent the first line |
@@ -1,2 +0,2 @@ | ||
import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, UIDLResourceItem, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
export declare const extractRoutes: (rootComponent: UIDLRootComponent) => UIDLConditionalNode[]; | ||
@@ -17,3 +17,2 @@ export declare const createWebComponentFriendlyName: (componentName: string) => string; | ||
export declare const traverseNodes: (node: UIDLNode | UIDLComponentStyleReference, fn: (node: UIDLNode | UIDLComponentStyleReference, parentNode: UIDLNode) => void, parent?: UIDLNode | null) => void; | ||
export declare const traverseResources: (node: UIDLNode, fn: (node: UIDLResourceItem, parentNode: UIDLNode) => void) => void; | ||
export declare const traverseElements: (node: UIDLNode, fn: (element: UIDLElement) => void) => void; | ||
@@ -20,0 +19,0 @@ export declare const traverseRepeats: (node: UIDLNode, fn: (element: UIDLRepeatContent) => void) => void; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractExternalDependencies = exports.removeChildNodes = exports.findFirstElementNode = exports.transformAttributesAssignmentsToJson = exports.transformStylesAssignmentsToJson = exports.transformStringAssignmentToJson = exports.transformDynamicStyles = exports.cleanupDynamicStyles = exports.splitDynamicAndStaticStyles = exports.traverseRepeats = exports.traverseElements = exports.traverseResources = exports.traverseNodes = exports.cloneObject = exports.prefixAssetsPath = exports.getRepeatIteratorNameAndKey = exports.getComponentClassName = exports.getComponentFolderPath = exports.getTemplateFileName = exports.getStyleFileName = exports.getComponentFileName = exports.setFriendlyOutputOptions = exports.createWebComponentFriendlyName = exports.extractRoutes = void 0; | ||
exports.extractExternalDependencies = exports.removeChildNodes = exports.findFirstElementNode = exports.transformAttributesAssignmentsToJson = exports.transformStylesAssignmentsToJson = exports.transformStringAssignmentToJson = exports.transformDynamicStyles = exports.cleanupDynamicStyles = exports.splitDynamicAndStaticStyles = exports.traverseRepeats = exports.traverseElements = exports.traverseNodes = exports.cloneObject = exports.prefixAssetsPath = exports.getRepeatIteratorNameAndKey = exports.getComponentClassName = exports.getComponentFolderPath = exports.getTemplateFileName = exports.getStyleFileName = exports.getComponentFileName = exports.setFriendlyOutputOptions = exports.createWebComponentFriendlyName = exports.extractRoutes = void 0; | ||
var string_utils_1 = require("./string-utils"); | ||
var path_1 = require("path"); | ||
var __1 = require(".."); | ||
var extractRoutes = function (rootComponent) { | ||
@@ -185,26 +173,2 @@ // Assuming root element starts with a UIDLElementNode | ||
break; | ||
case 'cms-list': | ||
(0, exports.traverseNodes)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseNodes)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseNodes)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
(0, exports.traverseNodes)(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
(0, exports.traverseNodes)(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
(0, exports.traverseNodes)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseNodes)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseNodes)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -227,65 +191,10 @@ (0, exports.traverseNodes)(node.content.node, fn, node); | ||
case 'import': | ||
case 'expr': | ||
case 'raw': | ||
case 'inject': | ||
break; | ||
default: | ||
throw new Error("traverseNodes was given an unsupported node type: ".concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseNodes was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
}; | ||
exports.traverseNodes = traverseNodes; | ||
var traverseResources = function (node, fn) { | ||
switch (node.type) { | ||
case 'element': | ||
var children = node.content.children; | ||
if (children) { | ||
children.forEach(function (child) { | ||
(0, exports.traverseResources)(child, fn); | ||
}); | ||
} | ||
break; | ||
case 'cms-list': | ||
(0, exports.traverseResources)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseResources)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseResources)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
(0, exports.traverseResources)(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
(0, exports.traverseResources)(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
(0, exports.traverseResources)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseResources)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseResources)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
(0, exports.traverseResources)(node.content.node, fn); | ||
break; | ||
case 'conditional': | ||
(0, exports.traverseResources)(node.content.node, fn); | ||
break; | ||
case 'slot': | ||
if (node.content.fallback) { | ||
(0, exports.traverseResources)(node.content.fallback, fn); | ||
} | ||
break; | ||
case 'static': | ||
case 'dynamic': | ||
case 'import': | ||
case 'raw': | ||
break; | ||
default: | ||
throw new Error("traverseResources was given an unsupported node type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
}; | ||
exports.traverseResources = traverseResources; | ||
var traverseStyleObject = function (style) { | ||
@@ -311,26 +220,2 @@ Object.keys(style).forEach(function (styleKey) { | ||
break; | ||
case 'cms-list': | ||
(0, exports.traverseElements)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseElements)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseElements)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
(0, exports.traverseElements)(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
(0, exports.traverseElements)(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
(0, exports.traverseElements)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseElements)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseElements)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -349,7 +234,7 @@ (0, exports.traverseElements)(node.content.node, fn); | ||
case 'dynamic': | ||
case 'inject': | ||
case 'raw': | ||
case 'expr': | ||
break; | ||
default: | ||
throw new Error("traverseElements was given an unsupported node type : ".concat(node.type, ", ").concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseElements was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -367,26 +252,2 @@ }; | ||
break; | ||
case 'cms-list': | ||
(0, exports.traverseRepeats)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseRepeats)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseRepeats)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
(0, exports.traverseRepeats)(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
(0, exports.traverseRepeats)(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
(0, exports.traverseRepeats)(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
(0, exports.traverseRepeats)(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.traverseRepeats)(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -407,6 +268,6 @@ fn(node.content); | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break; | ||
default: | ||
throw new Error("traverseRepeats was given an unsupported node type: ".concat(node.type, " - ").concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseRepeats was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -503,3 +364,3 @@ }; | ||
referenceType: referenceType, | ||
id: __1.StringUtils.createStateOrPropStoringValue(path), | ||
id: path, | ||
}, | ||
@@ -525,18 +386,7 @@ }; | ||
// if this value is already properly declared, make sure it is not | ||
var _a = styleContentAtKey, type = _a.type, content = _a.content; | ||
if (type === 'static') { | ||
var type = styleContentAtKey.type; | ||
if (['dynamic', 'static'].indexOf(type) !== -1) { | ||
acc[key] = styleContentAtKey; | ||
return acc; | ||
} | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) { | ||
acc[key] = { | ||
type: type, | ||
content: __assign(__assign({}, content), { id: __1.StringUtils.createStateOrPropStoringValue(content.id) }), | ||
}; | ||
} | ||
else { | ||
acc[key] = styleContentAtKey; | ||
} | ||
} | ||
return acc; | ||
@@ -561,28 +411,9 @@ } | ||
var type = attributeContent.type; | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type) !== -1) { | ||
if (['dynamic', 'static', 'import', 'comp-style', 'raw'].indexOf(type) !== -1) { | ||
acc[key] = attributeContent; | ||
return acc; | ||
} | ||
if (type === 'comp-style') { | ||
acc[key] = { | ||
type: 'comp-style', | ||
content: __1.StringUtils.createStateOrPropStoringValue(attributeContent.content), | ||
}; | ||
return acc; | ||
} | ||
var content = attributeContent.content; | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) { | ||
acc[key] = { | ||
type: type, | ||
content: __assign(__assign({}, content), { id: __1.StringUtils.createStateOrPropStoringValue(content.id) }), | ||
}; | ||
} | ||
else { | ||
acc[key] = attributeContent; | ||
} | ||
return acc; | ||
} | ||
throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2))); | ||
} | ||
throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2))); | ||
}, newStyleObject); | ||
@@ -622,26 +453,2 @@ return newStyleObject; | ||
break; | ||
case 'cms-list': | ||
(0, exports.removeChildNodes)(node.content.nodes.success, criteria); | ||
if (node.content.nodes.error) { | ||
(0, exports.removeChildNodes)(node.content.nodes.error, criteria); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.removeChildNodes)(node.content.nodes.loading, criteria); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
(0, exports.removeChildNodes)(node.content.nodes.list, criteria); | ||
if (node.content.nodes.empty) { | ||
(0, exports.removeChildNodes)(node.content.nodes.empty, criteria); | ||
} | ||
break; | ||
case 'cms-item': | ||
(0, exports.removeChildNodes)(node.content.nodes.success, criteria); | ||
if (node.content.nodes.error) { | ||
(0, exports.removeChildNodes)(node.content.nodes.error, criteria); | ||
} | ||
if (node.content.nodes.loading) { | ||
(0, exports.removeChildNodes)(node.content.nodes.loading, criteria); | ||
} | ||
break; | ||
case 'conditional': | ||
@@ -658,3 +465,3 @@ (0, exports.removeChildNodes)(node.content.node, criteria); | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break; | ||
@@ -661,0 +468,0 @@ default: |
@@ -1,7 +0,4 @@ | ||
import { PrettierFormatOptions, UIDLDependency } from '@teleporthq/teleport-types'; | ||
import { PrettierFormatOptions } from '@teleporthq/teleport-types'; | ||
export declare const ASSETS_IDENTIFIER = "playground_assets"; | ||
export declare const PRETTIER_CONFIG: PrettierFormatOptions; | ||
export declare const USE_ROUTER_DEPENDENCY: UIDLDependency; | ||
export declare const USE_EFFECT_DEPENDENCY: UIDLDependency; | ||
export declare const USE_STATE_DEPENDENCY: UIDLDependency; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,26 +12,2 @@ export var ASSETS_IDENTIFIER = 'playground_assets'; | ||
}; | ||
export var USE_ROUTER_DEPENDENCY = { | ||
type: 'library', | ||
path: 'next/router', | ||
version: '12.1.0', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
export var USE_EFFECT_DEPENDENCY = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
export var USE_STATE_DEPENDENCY = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
}; | ||
//# sourceMappingURL=index.js.map |
import * as Constants from './constants'; | ||
import * as StringUtils from './utils/string-utils'; | ||
import * as UIDLUtils from './utils/uidl-utils'; | ||
import * as GenericUtils from './utils/generic'; | ||
export { Constants, StringUtils, UIDLUtils, GenericUtils }; | ||
export { Constants, StringUtils, UIDLUtils }; | ||
//# sourceMappingURL=index.d.ts.map |
import * as Constants from './constants'; | ||
import * as StringUtils from './utils/string-utils'; | ||
import * as UIDLUtils from './utils/uidl-utils'; | ||
import * as GenericUtils from './utils/generic'; | ||
export { Constants, StringUtils, UIDLUtils, GenericUtils }; | ||
export { Constants, StringUtils, UIDLUtils }; | ||
//# sourceMappingURL=index.js.map |
export declare const camelCaseToDashCase: (str: string) => string; | ||
export declare const dashCaseToCamelCase: (str: string) => string; | ||
export declare const capitalize: (str: string) => string; | ||
export declare const camelize: (str: string) => string; | ||
export declare const dashCaseToUpperCamelCase: (str: string) => string; | ||
export declare const removeIllegalCharacters: (str: string) => string; | ||
export declare const slugify: (str: string) => string; | ||
export declare const createStateOrPropStoringValue: (value: string) => string; | ||
export declare const createStateStoringFunction: (value: string) => string; | ||
export declare const addSpacesToEachLine: (spaces: string, str: string) => string; | ||
@@ -11,0 +8,0 @@ export declare const removeLastEmptyLine: (str: string) => string; |
export var camelCaseToDashCase = function (str) { | ||
return str.replace(/([a-z])(?=[A-Z])|([A-Z0-9])(?=[A-Z][a-z])/g, '$1-').toLowerCase(); | ||
return str.replace(/([a-z])(?=[A-Z])|([A-Z0-9][A-Z])(?=[A-Z][a-z])/g, '$1$2-').toLowerCase(); | ||
}; | ||
@@ -8,3 +8,2 @@ export var dashCaseToCamelCase = function (str) { | ||
export var capitalize = function (str) { return str[0].toUpperCase() + str.slice(1); }; | ||
export var camelize = function (str) { return str[0].toLowerCase() + str.slice(1); }; | ||
export var dashCaseToUpperCamelCase = function (str) { return capitalize(dashCaseToCamelCase(str)); }; | ||
@@ -35,6 +34,2 @@ export var removeIllegalCharacters = function (str) { | ||
}; | ||
export var createStateOrPropStoringValue = function (value) { return camelize(dashCaseToCamelCase(value)); }; | ||
export var createStateStoringFunction = function (value) { | ||
return "set".concat(capitalize(dashCaseToUpperCamelCase(value))); | ||
}; | ||
export var addSpacesToEachLine = function (spaces, str) { | ||
@@ -41,0 +36,0 @@ // indent the first line |
@@ -1,2 +0,2 @@ | ||
import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, UIDLResourceItem, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
export declare const extractRoutes: (rootComponent: UIDLRootComponent) => UIDLConditionalNode[]; | ||
@@ -17,3 +17,2 @@ export declare const createWebComponentFriendlyName: (componentName: string) => string; | ||
export declare const traverseNodes: (node: UIDLNode | UIDLComponentStyleReference, fn: (node: UIDLNode | UIDLComponentStyleReference, parentNode: UIDLNode) => void, parent?: UIDLNode | null) => void; | ||
export declare const traverseResources: (node: UIDLNode, fn: (node: UIDLResourceItem, parentNode: UIDLNode) => void) => void; | ||
export declare const traverseElements: (node: UIDLNode, fn: (element: UIDLElement) => void) => void; | ||
@@ -20,0 +19,0 @@ export declare const traverseRepeats: (node: UIDLNode, fn: (element: UIDLRepeatContent) => void) => void; |
@@ -1,15 +0,3 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { camelCaseToDashCase, removeIllegalCharacters, dashCaseToUpperCamelCase, } from './string-utils'; | ||
import { basename } from 'path'; | ||
import { StringUtils } from '..'; | ||
export var extractRoutes = function (rootComponent) { | ||
@@ -171,26 +159,2 @@ // Assuming root element starts with a UIDLElementNode | ||
break; | ||
case 'cms-list': | ||
traverseNodes(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseNodes(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseNodes(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
traverseNodes(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
traverseNodes(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
traverseNodes(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseNodes(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseNodes(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -213,63 +177,9 @@ traverseNodes(node.content.node, fn, node); | ||
case 'import': | ||
case 'expr': | ||
case 'raw': | ||
case 'inject': | ||
break; | ||
default: | ||
throw new Error("traverseNodes was given an unsupported node type: ".concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseNodes was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
}; | ||
export var traverseResources = function (node, fn) { | ||
switch (node.type) { | ||
case 'element': | ||
var children = node.content.children; | ||
if (children) { | ||
children.forEach(function (child) { | ||
traverseResources(child, fn); | ||
}); | ||
} | ||
break; | ||
case 'cms-list': | ||
traverseResources(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseResources(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseResources(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
traverseResources(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
traverseResources(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
traverseResources(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseResources(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseResources(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
traverseResources(node.content.node, fn); | ||
break; | ||
case 'conditional': | ||
traverseResources(node.content.node, fn); | ||
break; | ||
case 'slot': | ||
if (node.content.fallback) { | ||
traverseResources(node.content.fallback, fn); | ||
} | ||
break; | ||
case 'static': | ||
case 'dynamic': | ||
case 'import': | ||
case 'raw': | ||
break; | ||
default: | ||
throw new Error("traverseResources was given an unsupported node type: ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
}; | ||
var traverseStyleObject = function (style) { | ||
@@ -295,26 +205,2 @@ Object.keys(style).forEach(function (styleKey) { | ||
break; | ||
case 'cms-list': | ||
traverseElements(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseElements(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseElements(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
traverseElements(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
traverseElements(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
traverseElements(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseElements(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseElements(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -333,7 +219,7 @@ traverseElements(node.content.node, fn); | ||
case 'dynamic': | ||
case 'inject': | ||
case 'raw': | ||
case 'expr': | ||
break; | ||
default: | ||
throw new Error("traverseElements was given an unsupported node type : ".concat(node.type, ", ").concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseElements was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -350,26 +236,2 @@ }; | ||
break; | ||
case 'cms-list': | ||
traverseRepeats(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseRepeats(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseRepeats(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
traverseRepeats(node.content.nodes.list, fn); | ||
if (node.content.nodes.empty) { | ||
traverseRepeats(node.content.nodes.empty, fn); | ||
} | ||
break; | ||
case 'cms-item': | ||
traverseRepeats(node.content.nodes.success, fn); | ||
if (node.content.nodes.error) { | ||
traverseRepeats(node.content.nodes.error, fn); | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseRepeats(node.content.nodes.loading, fn); | ||
} | ||
break; | ||
case 'repeat': | ||
@@ -390,6 +252,6 @@ fn(node.content); | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break; | ||
default: | ||
throw new Error("traverseRepeats was given an unsupported node type: ".concat(node.type, " - ").concat(JSON.stringify(node, null, 2))); | ||
throw new Error("traverseRepeats was given an unsupported node type ".concat(JSON.stringify(node, null, 2))); | ||
} | ||
@@ -482,3 +344,3 @@ }; | ||
referenceType: referenceType, | ||
id: StringUtils.createStateOrPropStoringValue(path), | ||
id: path, | ||
}, | ||
@@ -503,18 +365,7 @@ }; | ||
// if this value is already properly declared, make sure it is not | ||
var _a = styleContentAtKey, type = _a.type, content = _a.content; | ||
if (type === 'static') { | ||
var type = styleContentAtKey.type; | ||
if (['dynamic', 'static'].indexOf(type) !== -1) { | ||
acc[key] = styleContentAtKey; | ||
return acc; | ||
} | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) { | ||
acc[key] = { | ||
type: type, | ||
content: __assign(__assign({}, content), { id: StringUtils.createStateOrPropStoringValue(content.id) }), | ||
}; | ||
} | ||
else { | ||
acc[key] = styleContentAtKey; | ||
} | ||
} | ||
return acc; | ||
@@ -538,28 +389,9 @@ } | ||
var type = attributeContent.type; | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type) !== -1) { | ||
if (['dynamic', 'static', 'import', 'comp-style', 'raw'].indexOf(type) !== -1) { | ||
acc[key] = attributeContent; | ||
return acc; | ||
} | ||
if (type === 'comp-style') { | ||
acc[key] = { | ||
type: 'comp-style', | ||
content: StringUtils.createStateOrPropStoringValue(attributeContent.content), | ||
}; | ||
return acc; | ||
} | ||
var content = attributeContent.content; | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content === null || content === void 0 ? void 0 : content.referenceType)) { | ||
acc[key] = { | ||
type: type, | ||
content: __assign(__assign({}, content), { id: StringUtils.createStateOrPropStoringValue(content.id) }), | ||
}; | ||
} | ||
else { | ||
acc[key] = attributeContent; | ||
} | ||
return acc; | ||
} | ||
throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2))); | ||
} | ||
throw new Error("transformAttributesAssignmentsToJson encountered a style value that is not supported ".concat(JSON.stringify(attributeContent, null, 2))); | ||
}, newStyleObject); | ||
@@ -597,26 +429,2 @@ return newStyleObject; | ||
break; | ||
case 'cms-list': | ||
removeChildNodes(node.content.nodes.success, criteria); | ||
if (node.content.nodes.error) { | ||
removeChildNodes(node.content.nodes.error, criteria); | ||
} | ||
if (node.content.nodes.loading) { | ||
removeChildNodes(node.content.nodes.loading, criteria); | ||
} | ||
break; | ||
case 'cms-list-repeater': | ||
removeChildNodes(node.content.nodes.list, criteria); | ||
if (node.content.nodes.empty) { | ||
removeChildNodes(node.content.nodes.empty, criteria); | ||
} | ||
break; | ||
case 'cms-item': | ||
removeChildNodes(node.content.nodes.success, criteria); | ||
if (node.content.nodes.error) { | ||
removeChildNodes(node.content.nodes.error, criteria); | ||
} | ||
if (node.content.nodes.loading) { | ||
removeChildNodes(node.content.nodes.loading, criteria); | ||
} | ||
break; | ||
case 'conditional': | ||
@@ -633,3 +441,3 @@ removeChildNodes(node.content.node, criteria); | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break; | ||
@@ -636,0 +444,0 @@ default: |
{ | ||
"name": "@teleporthq/teleport-shared", | ||
"version": "0.31.0-alpha.0", | ||
"version": "0.31.0", | ||
"description": "A utility belt for the entire teleportHQ ecosystem", | ||
@@ -28,7 +28,7 @@ "author": "teleportHQ", | ||
"@babel/types": "^7.5.5", | ||
"@teleporthq/teleport-types": "^0.31.0-alpha.0", | ||
"@teleporthq/teleport-types": "^0.31.0", | ||
"jss": "^10.0.0", | ||
"jss-preset-default": "^10.0.0" | ||
}, | ||
"gitHead": "a5289f88f2d0cf8aae4b93bf05777c5492dd86b2" | ||
"gitHead": "37c3970566832845c57f0ef11088a9214af720b2" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { PrettierFormatOptions, UIDLDependency } from '@teleporthq/teleport-types' | ||
import { PrettierFormatOptions } from '@teleporthq/teleport-types' | ||
@@ -14,28 +14,1 @@ export const ASSETS_IDENTIFIER = 'playground_assets' | ||
} | ||
export const USE_ROUTER_DEPENDENCY: UIDLDependency = { | ||
type: 'library', | ||
path: 'next/router', | ||
version: '12.1.0', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
} | ||
export const USE_EFFECT_DEPENDENCY: UIDLDependency = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
} | ||
export const USE_STATE_DEPENDENCY: UIDLDependency = { | ||
type: 'library', | ||
path: 'react', | ||
version: '16.8.3', | ||
meta: { | ||
namedImport: true, | ||
}, | ||
} |
import * as Constants from './constants' | ||
import * as StringUtils from './utils/string-utils' | ||
import * as UIDLUtils from './utils/uidl-utils' | ||
import * as GenericUtils from './utils/generic' | ||
export { Constants, StringUtils, UIDLUtils, GenericUtils } | ||
export { Constants, StringUtils, UIDLUtils } |
export const camelCaseToDashCase = (str: string): string => | ||
str.replace(/([a-z])(?=[A-Z])|([A-Z0-9])(?=[A-Z][a-z])/g, '$1-').toLowerCase() | ||
str.replace(/([a-z])(?=[A-Z])|([A-Z0-9][A-Z])(?=[A-Z][a-z])/g, '$1$2-').toLowerCase() | ||
export const dashCaseToCamelCase = (str: string): string => | ||
@@ -8,3 +7,2 @@ str.replace(/[-_]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : '')) | ||
export const capitalize = (str: string): string => str[0].toUpperCase() + str.slice(1) | ||
export const camelize = (str: string): string => str[0].toLowerCase() + str.slice(1) | ||
@@ -41,6 +39,2 @@ export const dashCaseToUpperCamelCase = (str: string) => capitalize(dashCaseToCamelCase(str)) | ||
export const createStateOrPropStoringValue = (value: string) => camelize(dashCaseToCamelCase(value)) | ||
export const createStateStoringFunction = (value: string) => | ||
`set${capitalize(dashCaseToUpperCamelCase(value))}` | ||
export const addSpacesToEachLine = (spaces: string, str: string) => { | ||
@@ -47,0 +41,0 @@ // indent the first line |
@@ -23,7 +23,5 @@ import { | ||
UIDLRootComponent, | ||
UIDLResourceItem, | ||
GeneratorOptions, | ||
} from '@teleporthq/teleport-types' | ||
import { basename } from 'path' | ||
import { StringUtils } from '..' | ||
@@ -228,29 +226,2 @@ export const extractRoutes = (rootComponent: UIDLRootComponent) => { | ||
case 'cms-list': | ||
traverseNodes(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseNodes(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseNodes(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'cms-list-repeater': | ||
traverseNodes(node.content.nodes.list, fn) | ||
if (node.content.nodes.empty) { | ||
traverseNodes(node.content.nodes.empty, fn) | ||
} | ||
break | ||
case 'cms-item': | ||
traverseNodes(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseNodes(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseNodes(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'repeat': | ||
@@ -276,4 +247,4 @@ traverseNodes(node.content.node, fn, node) | ||
case 'import': | ||
case 'expr': | ||
case 'raw': | ||
case 'inject': | ||
break | ||
@@ -283,3 +254,3 @@ | ||
throw new Error( | ||
`traverseNodes was given an unsupported node type: ${JSON.stringify(node, null, 2)}` | ||
`traverseNodes was given an unsupported node type ${JSON.stringify(node, null, 2)}` | ||
) | ||
@@ -289,71 +260,2 @@ } | ||
export const traverseResources = ( | ||
node: UIDLNode, | ||
fn: (node: UIDLResourceItem, parentNode: UIDLNode) => void | ||
) => { | ||
switch (node.type) { | ||
case 'element': | ||
const { children } = node.content | ||
if (children) { | ||
children.forEach((child) => { | ||
traverseResources(child, fn) | ||
}) | ||
} | ||
break | ||
case 'cms-list': | ||
traverseResources(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseResources(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseResources(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'cms-list-repeater': | ||
traverseResources(node.content.nodes.list, fn) | ||
if (node.content.nodes.empty) { | ||
traverseResources(node.content.nodes.empty, fn) | ||
} | ||
break | ||
case 'cms-item': | ||
traverseResources(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseResources(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseResources(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'repeat': | ||
traverseResources(node.content.node, fn) | ||
break | ||
case 'conditional': | ||
traverseResources(node.content.node, fn) | ||
break | ||
case 'slot': | ||
if (node.content.fallback) { | ||
traverseResources(node.content.fallback, fn) | ||
} | ||
break | ||
case 'static': | ||
case 'dynamic': | ||
case 'import': | ||
case 'raw': | ||
break | ||
default: | ||
throw new Error( | ||
`traverseResources was given an unsupported node type: ${JSON.stringify(node, null, 2)}` | ||
) | ||
} | ||
} | ||
const traverseStyleObject = (style: UIDLStyleDefinitions) => { | ||
@@ -382,30 +284,2 @@ Object.keys(style).forEach((styleKey) => { | ||
case 'cms-list': | ||
traverseElements(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseElements(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseElements(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'cms-list-repeater': | ||
traverseElements(node.content.nodes.list, fn) | ||
if (node.content.nodes.empty) { | ||
traverseElements(node.content.nodes.empty, fn) | ||
} | ||
break | ||
case 'cms-item': | ||
traverseElements(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseElements(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseElements(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'repeat': | ||
@@ -427,4 +301,4 @@ traverseElements(node.content.node, fn) | ||
case 'dynamic': | ||
case 'inject': | ||
case 'raw': | ||
case 'expr': | ||
break | ||
@@ -434,7 +308,3 @@ | ||
throw new Error( | ||
`traverseElements was given an unsupported node type : ${node.type}, ${JSON.stringify( | ||
node, | ||
null, | ||
2 | ||
)}` | ||
`traverseElements was given an unsupported node type ${JSON.stringify(node, null, 2)}` | ||
) | ||
@@ -455,30 +325,2 @@ } | ||
case 'cms-list': | ||
traverseRepeats(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseRepeats(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseRepeats(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'cms-list-repeater': | ||
traverseRepeats(node.content.nodes.list, fn) | ||
if (node.content.nodes.empty) { | ||
traverseRepeats(node.content.nodes.empty, fn) | ||
} | ||
break | ||
case 'cms-item': | ||
traverseRepeats(node.content.nodes.success, fn) | ||
if (node.content.nodes.error) { | ||
traverseRepeats(node.content.nodes.error, fn) | ||
} | ||
if (node.content.nodes.loading) { | ||
traverseRepeats(node.content.nodes.loading, fn) | ||
} | ||
break | ||
case 'repeat': | ||
@@ -503,3 +345,3 @@ fn(node.content) | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break | ||
@@ -509,7 +351,3 @@ | ||
throw new Error( | ||
`traverseRepeats was given an unsupported node type: ${node.type} - ${JSON.stringify( | ||
node, | ||
null, | ||
2 | ||
)}` | ||
`traverseRepeats was given an unsupported node type ${JSON.stringify(node, null, 2)}` | ||
) | ||
@@ -644,3 +482,3 @@ } | ||
referenceType, | ||
id: StringUtils.createStateOrPropStoringValue(path), | ||
id: path, | ||
}, | ||
@@ -672,23 +510,9 @@ } | ||
// if this value is already properly declared, make sure it is not | ||
const { type, content } = styleContentAtKey as UIDLStaticValue | UIDLDynamicReference | ||
const { type } = styleContentAtKey as Record<string, unknown> | ||
if (type === 'static') { | ||
acc[key] = styleContentAtKey as UIDLStaticValue | ||
if (['dynamic', 'static'].indexOf(type as string) !== -1) { | ||
acc[key] = styleContentAtKey as UIDLStyleValue | ||
return acc | ||
} | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content?.referenceType)) { | ||
acc[key] = { | ||
type, | ||
content: { | ||
...content, | ||
id: StringUtils.createStateOrPropStoringValue(content.id), | ||
}, | ||
} | ||
} else { | ||
acc[key] = styleContentAtKey as UIDLDynamicReference | ||
} | ||
} | ||
return acc | ||
@@ -728,3 +552,3 @@ } | ||
const { type } = attributeContent as Record<string, unknown> | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type as string) !== -1) { | ||
if (['dynamic', 'static', 'import', 'comp-style', 'raw'].indexOf(type as string) !== -1) { | ||
acc[key] = attributeContent as UIDLAttributeValue | ||
@@ -734,28 +558,2 @@ return acc | ||
if (type === 'comp-style') { | ||
acc[key] = { | ||
type: 'comp-style', | ||
content: StringUtils.createStateOrPropStoringValue( | ||
(attributeContent as UIDLComponentStyleReference).content | ||
), | ||
} | ||
return acc | ||
} | ||
const { content } = attributeContent as UIDLDynamicReference | ||
if (type === 'dynamic') { | ||
if (['state', 'prop'].includes(content?.referenceType)) { | ||
acc[key] = { | ||
type, | ||
content: { | ||
...content, | ||
id: StringUtils.createStateOrPropStoringValue(content.id), | ||
}, | ||
} | ||
} else { | ||
acc[key] = attributeContent as UIDLAttributeValue | ||
} | ||
return acc | ||
} | ||
throw new Error( | ||
@@ -769,2 +567,10 @@ `transformAttributesAssignmentsToJson encountered a style value that is not supported ${JSON.stringify( | ||
} | ||
throw new Error( | ||
`transformAttributesAssignmentsToJson encountered a style value that is not supported ${JSON.stringify( | ||
attributeContent, | ||
null, | ||
2 | ||
)}` | ||
) | ||
}, newStyleObject) | ||
@@ -812,29 +618,2 @@ | ||
case 'cms-list': | ||
removeChildNodes(node.content.nodes.success, criteria) | ||
if (node.content.nodes.error) { | ||
removeChildNodes(node.content.nodes.error, criteria) | ||
} | ||
if (node.content.nodes.loading) { | ||
removeChildNodes(node.content.nodes.loading, criteria) | ||
} | ||
break | ||
case 'cms-list-repeater': | ||
removeChildNodes(node.content.nodes.list, criteria) | ||
if (node.content.nodes.empty) { | ||
removeChildNodes(node.content.nodes.empty, criteria) | ||
} | ||
break | ||
case 'cms-item': | ||
removeChildNodes(node.content.nodes.success, criteria) | ||
if (node.content.nodes.error) { | ||
removeChildNodes(node.content.nodes.error, criteria) | ||
} | ||
if (node.content.nodes.loading) { | ||
removeChildNodes(node.content.nodes.loading, criteria) | ||
} | ||
break | ||
case 'conditional': | ||
@@ -853,3 +632,3 @@ removeChildNodes(node.content.node, criteria) | ||
case 'raw': | ||
case 'expr': | ||
case 'inject': | ||
break | ||
@@ -856,0 +635,0 @@ |
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
183492
45
2534