@teleporthq/teleport-uidl-builders
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -1,2 +0,2 @@ | ||
import { ComponentUIDL, ReferenceType, UIDLDependency, UIDLNode, UIDLSlotNode, UIDLStyleValue, UIDLRepeatNode, UIDLElementNode, UIDLStaticValue, UIDLAttributeValue, UIDLPropDefinition, UIDLStateDefinition, UIDLConditionalNode, UIDLDynamicReference, UIDLRawValue } from '@teleporthq/teleport-types'; | ||
import { ComponentUIDL, ReferenceType, UIDLDependency, UIDLNode, UIDLSlotNode, UIDLRepeatNode, UIDLElementNode, UIDLStaticValue, UIDLAttributeValue, UIDLPropDefinition, UIDLStateDefinition, UIDLConditionalNode, UIDLDynamicReference, UIDLRawValue, UIDLElement } from '@teleporthq/teleport-types'; | ||
export declare const component: (name: string, node: UIDLElementNode, propDefinitions?: Record<string, UIDLPropDefinition>, stateDefinitions?: Record<string, UIDLStateDefinition>) => ComponentUIDL; | ||
@@ -7,28 +7,10 @@ export declare const definition: (type: string, defaultValue: string | number | boolean | object | unknown[]) => { | ||
}; | ||
export declare const elementNode: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, style?: Record<string, UIDLStyleValue>, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>) => UIDLElementNode; | ||
export declare const element: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, style?: Record<string, UIDLStyleValue>) => { | ||
elementType: string; | ||
semanticType: string; | ||
name: string; | ||
dependency: UIDLDependency; | ||
attrs: Record<string, UIDLAttributeValue>; | ||
style: Record<string, UIDLStyleValue>; | ||
events: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>; | ||
children: UIDLNode[]; | ||
} | { | ||
elementType: string; | ||
name: string; | ||
attrs: Record<string, UIDLAttributeValue>; | ||
style: Record<string, UIDLStyleValue>; | ||
events: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>; | ||
children: UIDLNode[]; | ||
semanticType?: undefined; | ||
dependency?: undefined; | ||
}; | ||
export declare const elementNode: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, style?: Record<string, UIDLAttributeValue>, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, referencedStyles?: Record<string, import("@teleporthq/teleport-types").UIDLElementNodeReferenceStyles>) => UIDLElementNode; | ||
export declare const element: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, style?: Record<string, UIDLAttributeValue>, referencedStyles?: Record<string, import("@teleporthq/teleport-types").UIDLElementNodeReferenceStyles>) => UIDLElement; | ||
export declare const componentDependency: (type: "local" | "library" | "package", path?: string, version?: string, meta?: Record<string, string | boolean>) => UIDLDependency; | ||
export declare const staticNode: (content: string) => UIDLStaticValue; | ||
export declare const dynamicNode: (referenceType: ReferenceType, id: string) => UIDLDynamicReference; | ||
export declare const slotNode: (fallback?: UIDLElementNode | UIDLDynamicReference | UIDLStaticValue, name?: string) => UIDLSlotNode; | ||
export declare const slotNode: (fallback?: UIDLElementNode | UIDLStaticValue | UIDLDynamicReference, name?: string) => UIDLSlotNode; | ||
export declare const conditionalNode: (reference: UIDLDynamicReference, node: UIDLNode, value: string | number | boolean) => UIDLConditionalNode; | ||
export declare const repeatNode: (node: UIDLElementNode, dataSource: UIDLAttributeValue, meta?: Record<string, unknown>) => UIDLRepeatNode; | ||
export declare const rawNode: (content: string) => UIDLRawValue; |
@@ -17,32 +17,32 @@ "use strict"; | ||
}; | ||
exports.elementNode = function (elementType, attrs, children, dependency, style, events) { | ||
exports.elementNode = function (elementType, attrs, children, dependency, style, events, referencedStyles) { | ||
return { | ||
type: 'element', | ||
content: style | ||
? exports.element(elementType, attrs, children, dependency, events, style) | ||
: exports.element(elementType, attrs, children, dependency, events), | ||
content: exports.element(elementType, attrs, children, dependency, events, style, referencedStyles), | ||
}; | ||
}; | ||
exports.element = function (elementType, attrs, children, dependency, events, style) { | ||
if (dependency) { | ||
return { | ||
elementType: 'component', | ||
semanticType: elementType, | ||
name: elementType, | ||
dependency: dependency, | ||
attrs: attrs, | ||
style: style, | ||
events: events, | ||
children: children, | ||
}; | ||
} | ||
return { | ||
exports.element = function (elementType, attrs, children, dependency, events, style, referencedStyles) { | ||
var elementObj = { | ||
elementType: elementType, | ||
// TODO: Handle semantic type in the element builder as well | ||
name: elementType, | ||
attrs: attrs, | ||
style: style, | ||
events: events, | ||
children: children, | ||
}; | ||
if (attrs) { | ||
elementObj.attrs = attrs; | ||
} | ||
if (events) { | ||
elementObj.events = events; | ||
} | ||
if (dependency) { | ||
elementObj.elementType = 'component'; | ||
elementObj.semanticType = elementType; | ||
elementObj.dependency = dependency; | ||
} | ||
if (style) { | ||
elementObj.style = style; | ||
} | ||
if (referencedStyles) { | ||
elementObj.referencedStyles = referencedStyles; | ||
} | ||
return elementObj; | ||
}; | ||
@@ -49,0 +49,0 @@ exports.componentDependency = function (type, path, version, meta) { |
@@ -1,2 +0,2 @@ | ||
import { ComponentUIDL, ReferenceType, UIDLDependency, UIDLNode, UIDLSlotNode, UIDLStyleValue, UIDLRepeatNode, UIDLElementNode, UIDLStaticValue, UIDLAttributeValue, UIDLPropDefinition, UIDLStateDefinition, UIDLConditionalNode, UIDLDynamicReference, UIDLRawValue } from '@teleporthq/teleport-types'; | ||
import { ComponentUIDL, ReferenceType, UIDLDependency, UIDLNode, UIDLSlotNode, UIDLRepeatNode, UIDLElementNode, UIDLStaticValue, UIDLAttributeValue, UIDLPropDefinition, UIDLStateDefinition, UIDLConditionalNode, UIDLDynamicReference, UIDLRawValue, UIDLElement } from '@teleporthq/teleport-types'; | ||
export declare const component: (name: string, node: UIDLElementNode, propDefinitions?: Record<string, UIDLPropDefinition>, stateDefinitions?: Record<string, UIDLStateDefinition>) => ComponentUIDL; | ||
@@ -7,28 +7,10 @@ export declare const definition: (type: string, defaultValue: string | number | boolean | object | unknown[]) => { | ||
}; | ||
export declare const elementNode: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, style?: Record<string, UIDLStyleValue>, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>) => UIDLElementNode; | ||
export declare const element: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, style?: Record<string, UIDLStyleValue>) => { | ||
elementType: string; | ||
semanticType: string; | ||
name: string; | ||
dependency: UIDLDependency; | ||
attrs: Record<string, UIDLAttributeValue>; | ||
style: Record<string, UIDLStyleValue>; | ||
events: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>; | ||
children: UIDLNode[]; | ||
} | { | ||
elementType: string; | ||
name: string; | ||
attrs: Record<string, UIDLAttributeValue>; | ||
style: Record<string, UIDLStyleValue>; | ||
events: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>; | ||
children: UIDLNode[]; | ||
semanticType?: undefined; | ||
dependency?: undefined; | ||
}; | ||
export declare const elementNode: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, style?: Record<string, UIDLAttributeValue>, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, referencedStyles?: Record<string, import("@teleporthq/teleport-types").UIDLElementNodeReferenceStyles>) => UIDLElementNode; | ||
export declare const element: (elementType: string, attrs?: Record<string, UIDLAttributeValue>, children?: UIDLNode[], dependency?: UIDLDependency, events?: Record<string, import("@teleporthq/teleport-types").UIDLEventHandlerStatement[]>, style?: Record<string, UIDLAttributeValue>, referencedStyles?: Record<string, import("@teleporthq/teleport-types").UIDLElementNodeReferenceStyles>) => UIDLElement; | ||
export declare const componentDependency: (type: "local" | "library" | "package", path?: string, version?: string, meta?: Record<string, string | boolean>) => UIDLDependency; | ||
export declare const staticNode: (content: string) => UIDLStaticValue; | ||
export declare const dynamicNode: (referenceType: ReferenceType, id: string) => UIDLDynamicReference; | ||
export declare const slotNode: (fallback?: UIDLElementNode | UIDLDynamicReference | UIDLStaticValue, name?: string) => UIDLSlotNode; | ||
export declare const slotNode: (fallback?: UIDLElementNode | UIDLStaticValue | UIDLDynamicReference, name?: string) => UIDLSlotNode; | ||
export declare const conditionalNode: (reference: UIDLDynamicReference, node: UIDLNode, value: string | number | boolean) => UIDLConditionalNode; | ||
export declare const repeatNode: (node: UIDLElementNode, dataSource: UIDLAttributeValue, meta?: Record<string, unknown>) => UIDLRepeatNode; | ||
export declare const rawNode: (content: string) => UIDLRawValue; |
@@ -15,32 +15,32 @@ export const component = (name, node, propDefinitions, stateDefinitions) => { | ||
}; | ||
export const elementNode = (elementType, attrs, children, dependency, style, events) => { | ||
export const elementNode = (elementType, attrs, children, dependency, style, events, referencedStyles) => { | ||
return { | ||
type: 'element', | ||
content: style | ||
? element(elementType, attrs, children, dependency, events, style) | ||
: element(elementType, attrs, children, dependency, events), | ||
content: element(elementType, attrs, children, dependency, events, style, referencedStyles), | ||
}; | ||
}; | ||
export const element = (elementType, attrs, children, dependency, events, style) => { | ||
if (dependency) { | ||
return { | ||
elementType: 'component', | ||
semanticType: elementType, | ||
name: elementType, | ||
dependency, | ||
attrs, | ||
style, | ||
events, | ||
children, | ||
}; | ||
} | ||
return { | ||
export const element = (elementType, attrs, children, dependency, events, style, referencedStyles) => { | ||
const elementObj = { | ||
elementType, | ||
// TODO: Handle semantic type in the element builder as well | ||
name: elementType, | ||
attrs, | ||
style, | ||
events, | ||
children, | ||
}; | ||
if (attrs) { | ||
elementObj.attrs = attrs; | ||
} | ||
if (events) { | ||
elementObj.events = events; | ||
} | ||
if (dependency) { | ||
elementObj.elementType = 'component'; | ||
elementObj.semanticType = elementType; | ||
elementObj.dependency = dependency; | ||
} | ||
if (style) { | ||
elementObj.style = style; | ||
} | ||
if (referencedStyles) { | ||
elementObj.referencedStyles = referencedStyles; | ||
} | ||
return elementObj; | ||
}; | ||
@@ -47,0 +47,0 @@ export const componentDependency = (type, path, version, meta) => { |
{ | ||
"name": "@teleporthq/teleport-uidl-builders", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"description": "A set of functions used for constructing UIDL structures", | ||
@@ -29,5 +29,5 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-types": "^0.11.0" | ||
"@teleporthq/teleport-types": "^0.12.0" | ||
}, | ||
"gitHead": "f6ed005a4cdb5b1b8050f9368ff436b9c48a4fde" | ||
"gitHead": "f5ef80f8d15eb5da2bce57dee16ded1513d051b9" | ||
} |
@@ -18,2 +18,4 @@ import { | ||
UIDLRawValue, | ||
UIDLReferencedStyles, | ||
UIDLElement, | ||
} from '@teleporthq/teleport-types' | ||
@@ -51,9 +53,8 @@ | ||
style?: Record<string, UIDLStyleValue>, | ||
events?: UIDLEventDefinitions | ||
events?: UIDLEventDefinitions, | ||
referencedStyles?: UIDLReferencedStyles | ||
): UIDLElementNode => { | ||
return { | ||
type: 'element', | ||
content: style | ||
? element(elementType, attrs, children, dependency, events, style) | ||
: element(elementType, attrs, children, dependency, events), | ||
content: element(elementType, attrs, children, dependency, events, style, referencedStyles), | ||
} | ||
@@ -68,25 +69,34 @@ } | ||
events?: UIDLEventDefinitions, | ||
style?: Record<string, UIDLStyleValue> | ||
style?: Record<string, UIDLStyleValue>, | ||
referencedStyles?: UIDLReferencedStyles | ||
) => { | ||
if (dependency) { | ||
return { | ||
elementType: 'component', | ||
semanticType: elementType, | ||
name: elementType, | ||
dependency, | ||
attrs, | ||
style, | ||
events, | ||
children, | ||
} | ||
} | ||
return { | ||
const elementObj: UIDLElement = { | ||
elementType, | ||
// TODO: Handle semantic type in the element builder as well | ||
name: elementType, | ||
attrs, | ||
style, | ||
events, | ||
children, | ||
} | ||
if (attrs) { | ||
elementObj.attrs = attrs | ||
} | ||
if (events) { | ||
elementObj.events = events | ||
} | ||
if (dependency) { | ||
elementObj.elementType = 'component' | ||
elementObj.semanticType = elementType | ||
elementObj.dependency = dependency | ||
} | ||
if (style) { | ||
elementObj.style = style | ||
} | ||
if (referencedStyles) { | ||
elementObj.referencedStyles = referencedStyles | ||
} | ||
return elementObj | ||
} | ||
@@ -93,0 +103,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
236628
911
+ Added@teleporthq/teleport-types@0.12.4(transitive)
- Removed@teleporthq/teleport-types@0.11.0(transitive)