@leafer-in/find 1.3.0 → 1.3.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.cjs +1 -0
- package/dist/find.esm.js +2 -1
- package/dist/find.esm.min.js +1 -1
- package/dist/find.js +1 -0
- package/dist/find.min.cjs +1 -1
- package/dist/find.min.js +1 -1
- package/package.json +4 -4
- package/src/index.ts +5 -1
package/dist/find.cjs
CHANGED
package/dist/find.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataHelper, LeafHelper, ChildEvent, PropertyEvent, Answer, UI, Platform, Creator } from '@leafer-ui/draw';
|
|
1
|
+
import { DataHelper, LeafHelper, ChildEvent, PropertyEvent, Answer, UI, Platform, Creator, Plugin } from '@leafer-ui/draw';
|
|
2
2
|
|
|
3
3
|
const { Yes, NoAndSkip, YesAndSkip } = Answer;
|
|
4
4
|
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
@@ -141,6 +141,7 @@ ui.findOne = function (condition, options) {
|
|
|
141
141
|
return getSelector(this).getBy(condition, this, true, options);
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
Plugin.add('find');
|
|
144
145
|
Creator.finder = function (target) {
|
|
145
146
|
return new Finder(target);
|
|
146
147
|
};
|
package/dist/find.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DataHelper as t,LeafHelper as e,ChildEvent as i,PropertyEvent as s,Answer as n,UI as h,Platform as r,Creator as a}from"@leafer-ui/draw";const{Yes:
|
|
1
|
+
import{DataHelper as t,LeafHelper as e,ChildEvent as i,PropertyEvent as s,Answer 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}=n,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(e,i,s,n){switch(typeof e){case"number":const h=this.getByInnerId(e,i);return s?h:h?[h]:[];case"string":switch(e[0]){case"#":g.id=e.substring(1),e=g;break;case".":f.className=e.substring(1),e=f;break;default:u.tag=e,e=u}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return s?t:t?[t]:[]}if(e.tag){const{tag:n}=e,h=n instanceof Array;return this.getByMethod(h?this.methods.tags:this.methods.tag,i,s,h?t.toMap(n):n)}return this.getByMethod(this.methods.className,i,s,e.className);case"function":return this.getByMethod(e,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,i){const s=this.idMap[t];return s&&e.hasParent(s,i||this.target)?s:(this.eachFind(this.toChildren(i),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_(i.REMOVE,this.__onRemoveChild,this),this.target.on_(s.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};
|
package/dist/find.js
CHANGED
package/dist/find.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw");const{Yes:e,NoAndSkip:i,YesAndSkip:s}=t.Answer,n={},h={},r={};class a{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(e,i,s,a){switch(typeof e){case"number":const d=this.getByInnerId(e,i);return s?d:d?[d]:[];case"string":switch(e[0]){case"#":n.id=e.substring(1),e=n;break;case".":h.className=e.substring(1),e=h;break;default:r.tag=e,e=r}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return s?t:t?[t]:[]}if(e.tag){const{tag:n}=e,h=n instanceof Array;return this.getByMethod(h?this.methods.tags:this.methods.tag,i,s,h?t.DataHelper.toMap(n):n)}return this.getByMethod(this.methods.className,i,s,e.className);case"function":return this.getByMethod(e,i,s,a)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const s=this.idMap[e];return s&&t.LeafHelper.hasParent(s,i||this.target)?s:(this.eachFind(this.toChildren(i),this.methods.id,null,e),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,n,h,r){let a,d;for(let o=0,c=t.length;o<c;o++){if(a=t[o],d=n(a,r),d===e||d===s){if(!h)return void(this.findLeaf=a);h.push(a)}a.isBranch&&d<i&&this.eachFind(a.children,n,h,r)}}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_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.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 d=t.UI.prototype;function o(e){return e.leafer?e.leafer.selector:t.Platform.selector||(t.Platform.selector=t.Creator.selector())}d.find=function(t,e){return o(this).getBy(t,this,!1,e)},d.findOne=function(t,e){return o(this).getBy(t,this,!0,e)},t.Creator.finder=function(t){return new a(t)},exports.Finder=a;
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw");const{Yes:e,NoAndSkip:i,YesAndSkip:s}=t.Answer,n={},h={},r={};class a{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(e,i,s,a){switch(typeof e){case"number":const d=this.getByInnerId(e,i);return s?d:d?[d]:[];case"string":switch(e[0]){case"#":n.id=e.substring(1),e=n;break;case".":h.className=e.substring(1),e=h;break;default:r.tag=e,e=r}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return s?t:t?[t]:[]}if(e.tag){const{tag:n}=e,h=n instanceof Array;return this.getByMethod(h?this.methods.tags:this.methods.tag,i,s,h?t.DataHelper.toMap(n):n)}return this.getByMethod(this.methods.className,i,s,e.className);case"function":return this.getByMethod(e,i,s,a)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const s=this.idMap[e];return s&&t.LeafHelper.hasParent(s,i||this.target)?s:(this.eachFind(this.toChildren(i),this.methods.id,null,e),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,n,h,r){let a,d;for(let o=0,c=t.length;o<c;o++){if(a=t[o],d=n(a,r),d===e||d===s){if(!h)return void(this.findLeaf=a);h.push(a)}a.isBranch&&d<i&&this.eachFind(a.children,n,h,r)}}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_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.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 d=t.UI.prototype;function o(e){return e.leafer?e.leafer.selector:t.Platform.selector||(t.Platform.selector=t.Creator.selector())}d.find=function(t,e){return o(this).getBy(t,this,!1,e)},d.findOne=function(t,e){return o(this).getBy(t,this,!0,e)},t.Plugin.add("find"),t.Creator.finder=function(t){return new a(t)},exports.Finder=a;
|
package/dist/find.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.find=function(t,e){"use strict";const{Yes:i,NoAndSkip:s,YesAndSkip:n}=e.Answer,h={},r={},a={};class d{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 d=this.getByInnerId(t,i);return s?d:d?[d]:[];case"string":switch(t[0]){case"#":h.id=t.substring(1),t=h;break;case".":r.className=t.substring(1),t=r;break;default:a.tag=t,t=a}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.DataHelper.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,i){const s=this.idMap[t];return s&&e.LeafHelper.hasParent(s,i||this.target)?s:(this.eachFind(this.toChildren(i),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,h,r){let a,d;for(let o=0,c=t.length;o<c;o++){if(a=t[o],d=e(a,r),d===i||d===n){if(!h)return void(this.findLeaf=a);h.push(a)}a.isBranch&&d<s&&this.eachFind(a.children,e,h,r)}}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_(e.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(e.PropertyEvent.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 o=e.UI.prototype;function c(t){return t.leafer?t.leafer.selector:e.Platform.selector||(e.Platform.selector=e.Creator.selector())}return o.find=function(t,e){return c(this).getBy(t,this,!1,e)},o.findOne=function(t,e){return c(this).getBy(t,this,!0,e)},e.Creator.finder=function(t){return new d(t)},t.Finder=d,t}({},LeaferUI);
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.find=function(t,e){"use strict";const{Yes:i,NoAndSkip:s,YesAndSkip:n}=e.Answer,h={},r={},a={};class d{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 d=this.getByInnerId(t,i);return s?d:d?[d]:[];case"string":switch(t[0]){case"#":h.id=t.substring(1),t=h;break;case".":r.className=t.substring(1),t=r;break;default:a.tag=t,t=a}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.DataHelper.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,i){const s=this.idMap[t];return s&&e.LeafHelper.hasParent(s,i||this.target)?s:(this.eachFind(this.toChildren(i),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,h,r){let a,d;for(let o=0,c=t.length;o<c;o++){if(a=t[o],d=e(a,r),d===i||d===n){if(!h)return void(this.findLeaf=a);h.push(a)}a.isBranch&&d<s&&this.eachFind(a.children,e,h,r)}}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_(e.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(e.PropertyEvent.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 o=e.UI.prototype;function c(t){return t.leafer?t.leafer.selector:e.Platform.selector||(e.Platform.selector=e.Creator.selector())}return o.find=function(t,e){return c(this).getBy(t,this,!1,e)},o.findOne=function(t,e){return c(this).getBy(t,this,!0,e)},e.Plugin.add("find"),e.Creator.finder=function(t){return new d(t)},t.Finder=d,t}({},LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/find",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.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.3.
|
|
38
|
-
"@leafer-ui/interface": "^1.3.
|
|
39
|
-
"@leafer-in/interface": "^1.3.
|
|
37
|
+
"@leafer-ui/draw": "^1.3.2",
|
|
38
|
+
"@leafer-ui/interface": "^1.3.2",
|
|
39
|
+
"@leafer-in/interface": "^1.3.2"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export { Finder } from './Finder'
|
|
2
2
|
|
|
3
|
-
import { Creator } from '@leafer-ui/draw'
|
|
3
|
+
import { Creator, Plugin } from '@leafer-ui/draw'
|
|
4
4
|
import { Finder } from './Finder'
|
|
5
5
|
import './find'
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
Plugin.add('find')
|
|
9
|
+
|
|
10
|
+
|
|
7
11
|
Creator.finder = function (target) {
|
|
8
12
|
return new Finder(target)
|
|
9
13
|
}
|