@teleporthq/teleport-shared
Advanced tools
Comparing version 0.35.0-alpha.0 to 0.36.0-alpha.0
@@ -39,3 +39,3 @@ import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, UIDLResourceItem, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
export declare const transformStylesAssignmentsToJson: (styleObject: Record<string, unknown>) => UIDLStyleDefinitions; | ||
export declare const transformAttributesAssignmentsToJson: (attributesObject: Record<string, unknown>) => Record<string, UIDLAttributeValue>; | ||
export declare const transformAttributesAssignmentsToJson: (attributesObject: Record<string, unknown>, isLocalComponent?: boolean) => Record<string, UIDLAttributeValue>; | ||
export declare const findFirstElementNode: (node: UIDLNode) => UIDLElementNode; | ||
@@ -42,0 +42,0 @@ export declare const removeChildNodes: (node: UIDLNode, criteria: (element: UIDLNode) => boolean) => void; |
@@ -544,4 +544,11 @@ "use strict"; | ||
exports.transformStylesAssignmentsToJson = transformStylesAssignmentsToJson; | ||
var transformAttributesAssignmentsToJson = function (attributesObject) { | ||
var newStyleObject = {}; | ||
/* | ||
All the props passed to the components are transformed to a unique case | ||
to minimize the collision of using cameCalse in one place and dashCase in | ||
another place. So, all the attrs that are being passed to the local compoenents | ||
need to be transformed since these are basically props. | ||
*/ | ||
var transformAttributesAssignmentsToJson = function (attributesObject, isLocalComponent) { | ||
if (isLocalComponent === void 0) { isLocalComponent = false; } | ||
var newAttrObject = {}; | ||
Object.keys(attributesObject).reduce(function (acc, key) { | ||
@@ -551,3 +558,4 @@ var attributeContent = attributesObject[key]; | ||
if (['string', 'number'].indexOf(entityType) !== -1) { | ||
acc[key] = (0, exports.transformStringAssignmentToJson)(attributeContent); | ||
var propKey = isLocalComponent ? __1.StringUtils.createStateOrPropStoringValue(key) : key; | ||
acc[propKey] = (0, exports.transformStringAssignmentToJson)(attributeContent); | ||
return acc; | ||
@@ -559,3 +567,4 @@ } | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type) !== -1) { | ||
acc[key] = attributeContent; | ||
var propKey = isLocalComponent ? __1.StringUtils.createStateOrPropStoringValue(key) : key; | ||
acc[propKey] = attributeContent; | ||
return acc; | ||
@@ -585,4 +594,4 @@ } | ||
} | ||
}, newStyleObject); | ||
return newStyleObject; | ||
}, newAttrObject); | ||
return newAttrObject; | ||
}; | ||
@@ -589,0 +598,0 @@ exports.transformAttributesAssignmentsToJson = transformAttributesAssignmentsToJson; |
@@ -39,3 +39,3 @@ import { ComponentUIDL, UIDLStyleDefinitions, UIDLConditionalNode, UIDLElement, UIDLNode, UIDLStaticValue, UIDLAttributeValue, UIDLDynamicReference, UIDLRepeatContent, UIDLRepeatMeta, UIDLElementNode, UIDLDependency, UIDLStyleValue, UIDLStyleSheetContent, UIDLComponentStyleReference, UIDLRootComponent, UIDLResourceItem, GeneratorOptions } from '@teleporthq/teleport-types'; | ||
export declare const transformStylesAssignmentsToJson: (styleObject: Record<string, unknown>) => UIDLStyleDefinitions; | ||
export declare const transformAttributesAssignmentsToJson: (attributesObject: Record<string, unknown>) => Record<string, UIDLAttributeValue>; | ||
export declare const transformAttributesAssignmentsToJson: (attributesObject: Record<string, unknown>, isLocalComponent?: boolean) => Record<string, UIDLAttributeValue>; | ||
export declare const findFirstElementNode: (node: UIDLNode) => UIDLElementNode; | ||
@@ -42,0 +42,0 @@ export declare const removeChildNodes: (node: UIDLNode, criteria: (element: UIDLNode) => boolean) => void; |
@@ -521,4 +521,11 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
export var transformAttributesAssignmentsToJson = function (attributesObject) { | ||
var newStyleObject = {}; | ||
/* | ||
All the props passed to the components are transformed to a unique case | ||
to minimize the collision of using cameCalse in one place and dashCase in | ||
another place. So, all the attrs that are being passed to the local compoenents | ||
need to be transformed since these are basically props. | ||
*/ | ||
export var transformAttributesAssignmentsToJson = function (attributesObject, isLocalComponent) { | ||
if (isLocalComponent === void 0) { isLocalComponent = false; } | ||
var newAttrObject = {}; | ||
Object.keys(attributesObject).reduce(function (acc, key) { | ||
@@ -528,3 +535,4 @@ var attributeContent = attributesObject[key]; | ||
if (['string', 'number'].indexOf(entityType) !== -1) { | ||
acc[key] = transformStringAssignmentToJson(attributeContent); | ||
var propKey = isLocalComponent ? StringUtils.createStateOrPropStoringValue(key) : key; | ||
acc[propKey] = transformStringAssignmentToJson(attributeContent); | ||
return acc; | ||
@@ -536,3 +544,4 @@ } | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type) !== -1) { | ||
acc[key] = attributeContent; | ||
var propKey = isLocalComponent ? StringUtils.createStateOrPropStoringValue(key) : key; | ||
acc[propKey] = attributeContent; | ||
return acc; | ||
@@ -562,4 +571,4 @@ } | ||
} | ||
}, newStyleObject); | ||
return newStyleObject; | ||
}, newAttrObject); | ||
return newAttrObject; | ||
}; | ||
@@ -566,0 +575,0 @@ export var findFirstElementNode = function (node) { |
{ | ||
"name": "@teleporthq/teleport-shared", | ||
"version": "0.35.0-alpha.0", | ||
"version": "0.36.0-alpha.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.35.0-alpha.0", | ||
"@teleporthq/teleport-types": "^0.36.0-alpha.0", | ||
"jss": "^10.0.0", | ||
"jss-preset-default": "^10.0.0" | ||
}, | ||
"gitHead": "e8ce842bf620a51081ff6f1cdf95b276325c19d2" | ||
"gitHead": "4f42496a502dc3bacb427e2ecc6fabda42cde0c2" | ||
} |
@@ -699,6 +699,14 @@ import { | ||
/* | ||
All the props passed to the components are transformed to a unique case | ||
to minimize the collision of using cameCalse in one place and dashCase in | ||
another place. So, all the attrs that are being passed to the local compoenents | ||
need to be transformed since these are basically props. | ||
*/ | ||
export const transformAttributesAssignmentsToJson = ( | ||
attributesObject: Record<string, unknown> | ||
attributesObject: Record<string, unknown>, | ||
isLocalComponent = false | ||
): Record<string, UIDLAttributeValue> => { | ||
const newStyleObject: Record<string, UIDLAttributeValue> = {} | ||
const newAttrObject: Record<string, UIDLAttributeValue> = {} | ||
@@ -710,3 +718,5 @@ Object.keys(attributesObject).reduce((acc, key) => { | ||
if (['string', 'number'].indexOf(entityType) !== -1) { | ||
acc[key] = transformStringAssignmentToJson( | ||
const propKey = isLocalComponent ? StringUtils.createStateOrPropStoringValue(key) : key | ||
acc[propKey] = transformStringAssignmentToJson( | ||
attributeContent as string | number | ||
@@ -719,5 +729,6 @@ ) as UIDLAttributeValue | ||
// if this value is already properly declared, make sure it is not | ||
const { type } = attributeContent as Record<string, unknown> | ||
const { type } = attributeContent as UIDLAttributeValue | ||
if (['static', 'import', 'raw', 'expr'].indexOf(type as string) !== -1) { | ||
acc[key] = attributeContent as UIDLAttributeValue | ||
const propKey = isLocalComponent ? StringUtils.createStateOrPropStoringValue(key) : key | ||
acc[propKey] = attributeContent as UIDLAttributeValue | ||
return acc | ||
@@ -760,5 +771,5 @@ } | ||
} | ||
}, newStyleObject) | ||
}, newAttrObject) | ||
return newStyleObject | ||
return newAttrObject | ||
} | ||
@@ -765,0 +776,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
238388
3431
+ Added@teleporthq/teleport-types@0.36.6(transitive)
- Removed@teleporthq/teleport-types@0.35.0(transitive)