@easyv/admin-utils
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -85,1 +85,9 @@ /** | ||
export function getModelTypes(): string[]; | ||
export function findExpandedKeys(data: any, keys: any, expanedKeys?: any[]): { | ||
tempExpanedKeys: any[]; | ||
expanedFather: boolean; | ||
}; | ||
export function searchExpandedKeys(data: any, title: any, expanedKeys?: any[]): { | ||
tempExpanedKeys: any[]; | ||
expanedFather: boolean; | ||
}; |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getModelTypes = exports.getId = exports.getPanelWithStates = exports.getPanelOptions = exports.getComponentOptions = exports.getStateOptions = exports.filterLayersWithEvents = exports.getEvents = exports.getLayersWithCustomId = exports.getValueFromConfig = exports.getValueObjFromConfig = exports.isOldConfig = exports.isConfigShow = exports.isFullConfigShow = exports.transformToOldConfig = exports.transformConfig = exports.updateArrayWithObject = exports.mergeStyleConfig = exports.mergeConfig = exports.getConfig = exports.updateArrayConfig = exports.getComponentConfig = exports.getComponentDimension = exports.reduceConfig = exports.getScreenDimension = void 0; | ||
exports.searchExpandedKeys = exports.findExpandedKeys = exports.getModelTypes = exports.getId = exports.getPanelWithStates = exports.getPanelOptions = exports.getComponentOptions = exports.getStateOptions = exports.filterLayersWithEvents = exports.getEvents = exports.getLayersWithCustomId = exports.getValueFromConfig = exports.getValueObjFromConfig = exports.isOldConfig = exports.isConfigShow = exports.isFullConfigShow = exports.transformToOldConfig = exports.transformConfig = exports.updateArrayWithObject = exports.mergeStyleConfig = exports.mergeConfig = exports.getConfig = exports.updateArrayConfig = exports.getComponentConfig = exports.getComponentDimension = exports.reduceConfig = exports.getScreenDimension = void 0; | ||
const utils_js_1 = require("./utils.js"); | ||
@@ -603,15 +603,45 @@ const config_new_js_1 = require("./config.new.js"); | ||
exports.getComponentOptions = getComponentOptions; | ||
function transformChildren(children, customer, componentsById) { | ||
const marks = new Set(); | ||
const result = []; | ||
if (Array.isArray(customer) && customer.length) { | ||
customer.forEach((item) => { | ||
const newItem = {}; | ||
if (item.children) { | ||
newItem.title = item.name; | ||
newItem.value = `childGroup(${item.id})`; | ||
newItem.disabled = true; | ||
newItem.children = item.children.map((child) => { | ||
marks.add(child.id); | ||
const component = componentsById[child.id]; | ||
return { | ||
value: `$component(${child.id})`, | ||
title: component ? component.name : `$component(${child.id})` | ||
}; | ||
}); | ||
} | ||
else { | ||
marks.add(item.id); | ||
const component = componentsById[item.id]; | ||
newItem.value = `$component(${item.id})`; | ||
newItem.title = component ? component.name : `$component(${item.id})`; | ||
} | ||
result.push(newItem); | ||
}); | ||
} | ||
const filterComponentChildren = children.filter((d) => !marks.has(d)); | ||
filterComponentChildren.forEach((item) => { | ||
const component = componentsById[item]; | ||
result.push({ | ||
value: `$component(${item})`, | ||
title: component ? component.name : '' | ||
}); | ||
}); | ||
return result; | ||
} | ||
function getComponentLayerWithChildren({ componentsById, id, name }, type) { | ||
let component = componentsById[id] || {}; | ||
let { children = [] } = component; | ||
let { children = [], customInfo = [] } = component; | ||
if (children.length > 0) { | ||
children = children.reduce((result, childId) => { | ||
let child = componentsById[childId]; | ||
return child | ||
? result.concat({ | ||
value: updateBindName(`component(${childId})`, type), | ||
title: child.name | ||
}) | ||
: result; | ||
}, []); | ||
children = transformChildren(children, customInfo, componentsById); | ||
return { | ||
@@ -760,1 +790,41 @@ title: name, | ||
]; | ||
exports.findExpandedKeys = (data, keys, expanedKeys = []) => { | ||
let [tempData, tempKeys, tempExpanedKeys] = [[...data], [...keys], [...expanedKeys]]; | ||
let expanedFather = false; | ||
tempData.map((d) => { | ||
if (tempKeys.includes(d.value)) { | ||
tempExpanedKeys.push(d.value); | ||
tempKeys = tempKeys.filter((v) => v.value !== d.value); | ||
expanedFather = true; | ||
} | ||
if (d.children && d.children.length > 0) { | ||
const childrenResult = Object.assign({}, exports.findExpandedKeys(d.children, tempKeys, tempExpanedKeys)); | ||
tempExpanedKeys = childrenResult.tempExpanedKeys; | ||
if (childrenResult.expanedFather && !tempExpanedKeys.includes(d.value)) { | ||
tempExpanedKeys.push(d.value); | ||
tempKeys = tempKeys.filter((v) => v.value !== d.value); | ||
expanedFather = true; | ||
} | ||
} | ||
}); | ||
return { tempExpanedKeys, expanedFather }; | ||
}; | ||
exports.searchExpandedKeys = (data, title, expanedKeys = []) => { | ||
let [tempData, tempTitle, tempExpanedKeys] = [[...data], title, [...expanedKeys]]; | ||
let expanedFather = false; | ||
tempData.map((d) => { | ||
if (d.title.indexOf(tempTitle) !== -1) { | ||
tempExpanedKeys.push(d.value); | ||
expanedFather = true; | ||
} | ||
if (d.children && d.children.length > 0) { | ||
const childrenResult = Object.assign({}, exports.searchExpandedKeys(d.children, title, tempExpanedKeys)); | ||
tempExpanedKeys = childrenResult.tempExpanedKeys; | ||
if (childrenResult.expanedFather && d.title.indexOf(tempTitle) === -1) { | ||
tempExpanedKeys.push(d.value); | ||
expanedFather = true; | ||
} | ||
} | ||
}); | ||
return { tempExpanedKeys, expanedFather }; | ||
}; |
{ | ||
"name": "@easyv/admin-utils", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "utils 集合", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is too big to display
200561
5478