@leafer-in/find 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/find.esm.js +1 -1
- package/dist/find.esm.min.js +1 -1
- package/package.json +4 -4
package/dist/find.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataHelper, LeafHelper, ChildEvent, PropertyEvent,
|
|
1
|
+
import { Answer, DataHelper, LeafHelper, ChildEvent, PropertyEvent, UI, Platform, Creator, Plugin } from '@leafer-ui/draw';
|
|
2
2
|
|
|
3
3
|
const { Yes, NoAndSkip, YesAndSkip } = Answer;
|
|
4
4
|
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
package/dist/find.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Answer as t,DataHelper as e,LeafHelper as i,ChildEvent as s,PropertyEvent as n,UI as h,Platform as r,Creator as d,Plugin as a}from"@leafer-ui/draw";const{Yes:o,NoAndSkip:c,YesAndSkip:l}=t,g={},f={},u={};class _{constructor(t){this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},(this.target=t)&&this.__listenEvents()}getBy(t,i,s,n){switch(typeof t){case"number":const h=this.getByInnerId(t,i);return s?h:h?[h]:[];case"string":switch(t[0]){case"#":g.id=t.substring(1),t=g;break;case".":f.className=t.substring(1),t=f;break;default:u.tag=t,t=u}case"object":if(void 0!==t.id){const e=this.getById(t.id,i);return s?e:e?[e]:[]}if(t.tag){const{tag:n}=t,h=n instanceof Array;return this.getByMethod(h?this.methods.tags:this.methods.tag,i,s,h?e.toMap(n):n)}return this.getByMethod(this.methods.className,i,s,t.className);case"function":return this.getByMethod(t,i,s,n)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const s=this.idMap[t];return s&&i.hasParent(s,e||this.target)?s:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,h;for(let r=0,d=t.length;r<d;r++){if(n=t[r],h=e(n,s),h===o||h===l){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&h<c&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(n.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){const{__eventIds:t}=this;t&&t.length&&(this.__removeListenEvents(),this.innerIdMap={},this.idMap={}),this.findLeaf=null}}const m=h.prototype;function p(t){return t.leafer?t.leafer.selector:r.selector||(r.selector=d.selector())}m.find=function(t,e){return p(this).getBy(t,this,!1,e)},m.findOne=function(t,e){return p(this).getBy(t,this,!0,e)},a.add("find"),d.finder=function(t){return new _(t)};export{_ as Finder};
|
|
2
2
|
//# sourceMappingURL=find.esm.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/find",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "@leafer-in/find",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^1.4.
|
|
38
|
-
"@leafer-ui/interface": "^1.4.
|
|
39
|
-
"@leafer-in/interface": "^1.4.
|
|
37
|
+
"@leafer-ui/draw": "^1.4.2",
|
|
38
|
+
"@leafer-ui/interface": "^1.4.2",
|
|
39
|
+
"@leafer-in/interface": "^1.4.2"
|
|
40
40
|
}
|
|
41
41
|
}
|