Comparing version 0.1.14 to 0.1.15
@@ -56,3 +56,3 @@ "use strict"; | ||
}); | ||
let value = this.value; // this.type !== 'string' ? this.value : this.value ? `'${this.value}'` : ''; | ||
let value = this.type !== 'string' ? this.value : this.value ? `'${this.value}'` : ''; | ||
if (this.expression) { | ||
@@ -59,0 +59,0 @@ value = LogicItem_1.evaluate(this.expression); |
@@ -170,2 +170,13 @@ import { LEVEL_ENUM, Vertex, View, Attr, Directive, Event } from '..'; | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag: string): Element; | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name: string, value: string): Element; | ||
/** | ||
* 从 Vue 的 ASTNode 转换成 ASL 元素 | ||
@@ -172,0 +183,0 @@ * @param astNode Vue 的 ASTNode |
@@ -249,2 +249,3 @@ "use strict"; | ||
value, | ||
elementId: this.id, | ||
}, this); | ||
@@ -381,2 +382,33 @@ await attr.create(); | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag) { | ||
if (this.tag === tag) | ||
return this; | ||
else { | ||
for (const child of this.children) { | ||
const result = child.findElementByTag(tag); | ||
if (result) | ||
return result; | ||
} | ||
} | ||
} | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name, value) { | ||
if (this.attrList.find((attr) => attr.name === name && attr.value === value)) | ||
return this; | ||
else { | ||
for (const child of this.children) { | ||
const result = child.findElementByAttr(name, value); | ||
if (result) | ||
return result; | ||
} | ||
} | ||
} | ||
/** | ||
* 从 Vue 的 ASTNode 转换成 ASL 元素 | ||
@@ -445,3 +477,3 @@ * @param astNode Vue 的 ASTNode | ||
catch (e) { | ||
const expression = this._parseExpression(oldAttr.value, $def); | ||
const expression = this._parseExpression(oldAttr.value, $def, dataSchema); | ||
attr = __1.Attr.from({ | ||
@@ -669,3 +701,5 @@ type: 'dynamic', | ||
}; | ||
const ast = compiler.compile(html, compilerOptions).ast; | ||
let ast = compiler.compile(html, compilerOptions).ast; | ||
if (ast.tag === 'template') | ||
ast = ast.children[0]; | ||
let root; | ||
@@ -672,0 +706,0 @@ let dataSchemaArray = html.match(/data-schema="(.*?)"/); |
@@ -40,3 +40,4 @@ "use strict"; | ||
if (this.logicId) { | ||
value = cacheData_1.vertexsMap.get(this.logicId) ? cacheData_1.vertexsMap.get(this.logicId).name : ''; | ||
if (cacheData_1.vertexsMap.get(this.logicId)) | ||
value = cacheData_1.vertexsMap.get(this.logicId).name; | ||
if (value) { | ||
@@ -43,0 +44,0 @@ value = __1.genFinalCode(value, finalCode); |
@@ -94,9 +94,20 @@ import { LEVEL_ENUM, Page, Element } from '..'; | ||
* @examples | ||
* - findElement('', root) 指根节点本身 | ||
* - findElement('/', root) 指根节点本身 | ||
* - findElement('/0', root) 指第0个子节点 | ||
* - findElement('/2/1', root) 指第2个子节点的第1个子节点 | ||
* - findElementByNodePath('', root) 指根节点本身 | ||
* - findElementByNodePath('/', root) 指根节点本身 | ||
* - findElementByNodePath('/0', root) 指第0个子节点 | ||
* - findElementByNodePath('/2/1', root) 指第2个子节点的第1个子节点 | ||
*/ | ||
findElement(nodePath: string, node?: Element): Element; | ||
findElementByNodePath(nodePath: string, node?: Element): Element; | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag: string): Element; | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name: string, value: string): Element; | ||
/** | ||
* 添加子页面 | ||
@@ -103,0 +114,0 @@ */ |
@@ -144,8 +144,8 @@ "use strict"; | ||
* @examples | ||
* - findElement('', root) 指根节点本身 | ||
* - findElement('/', root) 指根节点本身 | ||
* - findElement('/0', root) 指第0个子节点 | ||
* - findElement('/2/1', root) 指第2个子节点的第1个子节点 | ||
* - findElementByNodePath('', root) 指根节点本身 | ||
* - findElementByNodePath('/', root) 指根节点本身 | ||
* - findElementByNodePath('/0', root) 指第0个子节点 | ||
* - findElementByNodePath('/2/1', root) 指第2个子节点的第1个子节点 | ||
*/ | ||
findElement(nodePath, node = this.$html) { | ||
findElementByNodePath(nodePath, node = this.$html) { | ||
if (nodePath[0] === '/') // 这个里边相对和绝对是一样的 | ||
@@ -158,6 +158,21 @@ nodePath = nodePath.slice(1); | ||
const parent = node; | ||
return this.findElement(arr.slice(1).join('/'), parent.children[+arr[0]]); | ||
return this.findElementByNodePath(arr.slice(1).join('/'), parent.children[+arr[0]]); | ||
} | ||
} | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag) { | ||
return this.$html.findElementByTag(tag); | ||
} | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name, value) { | ||
return this.$html.findElementByAttr(name, value); | ||
} | ||
/** | ||
* 添加子页面 | ||
@@ -355,3 +370,3 @@ */ | ||
const body = {}; | ||
const parentNode = this.findElement(nodePath); | ||
const parentNode = this.findElementByNodePath(nodePath); | ||
const viewId = parentNode.view.id; | ||
@@ -358,0 +373,0 @@ const parentId = parentNode.id; |
{ | ||
"name": "@lcap/asl", | ||
"description": "Lowcode Application Specific Language", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"author": "Forrest <rainforest92@126.com>", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -97,3 +97,3 @@ // import stringify = require('json-stringify-safe'); | ||
}); | ||
let value = this.value; // this.type !== 'string' ? this.value : this.value ? `'${this.value}'` : ''; | ||
let value = this.type !== 'string' ? this.value : this.value ? `'${this.value}'` : ''; | ||
if(this.expression) { | ||
@@ -100,0 +100,0 @@ value = evaluate(this.expression); |
@@ -269,2 +269,3 @@ // import stringify = require('json-stringify-safe'); | ||
value, | ||
elementId: this.id, | ||
}, this); | ||
@@ -417,2 +418,33 @@ await attr.create(); | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag: string): Element { | ||
if (this.tag === tag) | ||
return this; | ||
else { | ||
for (const child of this.children) { | ||
const result = child.findElementByTag(tag); | ||
if (result) | ||
return result; | ||
} | ||
} | ||
} | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name: string, value: string): Element { | ||
if (this.attrList.find((attr) => attr.name === name && attr.value === value)) | ||
return this; | ||
else { | ||
for (const child of this.children) { | ||
const result = child.findElementByAttr(name, value); | ||
if (result) | ||
return result; | ||
} | ||
} | ||
} | ||
/** | ||
* 从 Vue 的 ASTNode 转换成 ASL 元素 | ||
@@ -485,3 +517,3 @@ * @param astNode Vue 的 ASTNode | ||
} catch(e) { | ||
const expression = <ExpressionNode>this._parseExpression(oldAttr.value, $def); | ||
const expression = <ExpressionNode>this._parseExpression(oldAttr.value, $def, dataSchema); | ||
attr = Attr.from({ | ||
@@ -725,3 +757,5 @@ type: 'dynamic', | ||
const ast = compiler.compile(html, compilerOptions).ast; | ||
let ast = compiler.compile(html, compilerOptions).ast; | ||
if (ast.tag === 'template') | ||
ast = ast.children[0] as compiler.ASTElement; | ||
let root: Element; | ||
@@ -728,0 +762,0 @@ let dataSchemaArray = html.match(/data-schema="(.*?)"/); |
@@ -71,5 +71,6 @@ // import stringify = require('json-stringify-safe'); | ||
let value = this.value; | ||
if(this.logicId){ | ||
value = vertexsMap.get(this.logicId) ? (vertexsMap.get(this.logicId) as Logic).name : ''; | ||
if(value){ | ||
if (this.logicId) { | ||
if (vertexsMap.get(this.logicId)) | ||
value = vertexsMap.get(this.logicId).name; | ||
if(value) { | ||
value = genFinalCode(value, finalCode); | ||
@@ -76,0 +77,0 @@ const params = ['$event']; |
@@ -162,8 +162,8 @@ import { immutable, circular, action } from '../decorators'; | ||
* @examples | ||
* - findElement('', root) 指根节点本身 | ||
* - findElement('/', root) 指根节点本身 | ||
* - findElement('/0', root) 指第0个子节点 | ||
* - findElement('/2/1', root) 指第2个子节点的第1个子节点 | ||
* - findElementByNodePath('', root) 指根节点本身 | ||
* - findElementByNodePath('/', root) 指根节点本身 | ||
* - findElementByNodePath('/0', root) 指第0个子节点 | ||
* - findElementByNodePath('/2/1', root) 指第2个子节点的第1个子节点 | ||
*/ | ||
findElement(nodePath: string, node: Element = this.$html): Element { | ||
findElementByNodePath(nodePath: string, node: Element = this.$html): Element { | ||
if (nodePath[0] === '/') // 这个里边相对和绝对是一样的 | ||
@@ -176,6 +176,21 @@ nodePath = nodePath.slice(1); | ||
const parent = node; | ||
return this.findElement(arr.slice(1).join('/'), parent.children[+arr[0]]); | ||
return this.findElementByNodePath(arr.slice(1).join('/'), parent.children[+arr[0]]); | ||
} | ||
} | ||
/** | ||
* 根据标签查找元素 | ||
* @param tag | ||
*/ | ||
findElementByTag(tag: string) { | ||
return this.$html.findElementByTag(tag); | ||
} | ||
/** | ||
* 根据属性查找元素 | ||
* @param name | ||
* @param value | ||
*/ | ||
findElementByAttr(name: string, value: string) { | ||
return this.$html.findElementByAttr(name, value); | ||
} | ||
/** | ||
* 添加子页面 | ||
@@ -401,3 +416,3 @@ */ | ||
const body: any = {}; | ||
const parentNode = this.findElement(nodePath); | ||
const parentNode = this.findElementByNodePath(nodePath); | ||
const viewId = parentNode.view.id; | ||
@@ -404,0 +419,0 @@ const parentId = parentNode.id; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6150917
41285