UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

75 lines (74 loc) 2.65 kB
import { isString, each } from "../../../zrender/lib/core/util.mjs"; import { parseClassType } from "./clazz.mjs"; var ECEventProcessor = function() { function ECEventProcessor2() { } ECEventProcessor2.prototype.normalizeQuery = function(query) { var cptQuery = {}; var dataQuery = {}; var otherQuery = {}; if (isString(query)) { var condCptType = parseClassType(query); cptQuery.mainType = condCptType.main || null; cptQuery.subType = condCptType.sub || null; } else { var suffixes_1 = ["Index", "Name", "Id"]; var dataKeys_1 = { name: 1, dataIndex: 1, dataType: 1 }; each(query, function(val, key) { var reserved = false; for (var i = 0; i < suffixes_1.length; i++) { var propSuffix = suffixes_1[i]; var suffixPos = key.lastIndexOf(propSuffix); if (suffixPos > 0 && suffixPos === key.length - propSuffix.length) { var mainType = key.slice(0, suffixPos); if (mainType !== "data") { cptQuery.mainType = mainType; cptQuery[propSuffix.toLowerCase()] = val; reserved = true; } } } if (dataKeys_1.hasOwnProperty(key)) { dataQuery[key] = val; reserved = true; } if (!reserved) { otherQuery[key] = val; } }); } return { cptQuery, dataQuery, otherQuery }; }; ECEventProcessor2.prototype.filter = function(eventType, query) { var eventInfo = this.eventInfo; if (!eventInfo) { return true; } var targetEl = eventInfo.targetEl; var packedEvent = eventInfo.packedEvent; var model = eventInfo.model; var view = eventInfo.view; if (!model || !view) { return true; } var cptQuery = query.cptQuery; var dataQuery = query.dataQuery; return check(cptQuery, model, "mainType") && check(cptQuery, model, "subType") && check(cptQuery, model, "index", "componentIndex") && check(cptQuery, model, "name") && check(cptQuery, model, "id") && check(dataQuery, packedEvent, "name") && check(dataQuery, packedEvent, "dataIndex") && check(dataQuery, packedEvent, "dataType") && (!view.filterForExposedEvent || view.filterForExposedEvent(eventType, query.otherQuery, targetEl, packedEvent)); function check(query2, host, prop, propOnHost) { return query2[prop] == null || host[propOnHost || prop] === query2[prop]; } }; ECEventProcessor2.prototype.afterTrigger = function() { this.eventInfo = null; }; return ECEventProcessor2; }(); export { ECEventProcessor };