@leafer-ui/miniapp 1.0.6 → 1.0.7

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.
@@ -4426,13 +4426,10 @@ class LeafLayout {
4426
4426
  update() {
4427
4427
  const { leafer } = this.leaf;
4428
4428
  if (leafer) {
4429
- if (leafer.ready) {
4430
- if (leafer.watcher.changed)
4431
- leafer.layouter.layout();
4432
- }
4433
- else {
4429
+ if (leafer.ready)
4430
+ leafer.watcher.changed && leafer.layouter.layout();
4431
+ else
4434
4432
  leafer.start();
4435
- }
4436
4433
  }
4437
4434
  else {
4438
4435
  let root = this.leaf;
@@ -5959,7 +5956,7 @@ class LeafLevelList {
5959
5956
  }
5960
5957
  }
5961
5958
 
5962
- const version = "1.0.6";
5959
+ const version = "1.0.7";
5963
5960
 
5964
5961
  class LeaferCanvas extends LeaferCanvasBase {
5965
5962
  get allowBackgroundColor() { return false; }
@@ -6815,7 +6812,8 @@ class Picker {
6815
6812
  path.add(leaf);
6816
6813
  leaf = leaf.parent;
6817
6814
  }
6818
- path.add(this.target);
6815
+ if (this.target)
6816
+ path.add(this.target);
6819
6817
  return path;
6820
6818
  }
6821
6819
  getHitablePath(leaf) {
@@ -6901,8 +6899,8 @@ class Selector {
6901
6899
  this.innerIdMap = {};
6902
6900
  this.idMap = {};
6903
6901
  this.methods = {
6904
- id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
6905
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6902
+ id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6903
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6906
6904
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6907
6905
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6908
6906
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
@@ -6911,7 +6909,8 @@ class Selector {
6911
6909
  if (userConfig)
6912
6910
  this.config = DataHelper.default(userConfig, this.config);
6913
6911
  this.picker = new Picker(target, this);
6914
- this.__listenEvents();
6912
+ if (target)
6913
+ this.__listenEvents();
6915
6914
  }
6916
6915
  getBy(condition, branch, one, options) {
6917
6916
  switch (typeof condition) {
@@ -6946,7 +6945,7 @@ class Selector {
6946
6945
  }
6947
6946
  }
6948
6947
  getByPoint(hitPoint, hitRadius, options) {
6949
- if (Platform.name === 'node')
6948
+ if (Platform.name === 'node' && this.target)
6950
6949
  this.target.emit(LayoutEvent.CHECK_UPDATE);
6951
6950
  return this.picker.getByPoint(hitPoint, hitRadius, options);
6952
6951
  }
@@ -8788,9 +8787,8 @@ let Text = class Text extends UI {
8788
8787
  layout.renderChanged = true;
8789
8788
  setList(data.__textBoxBounds = {}, [b, bounds]);
8790
8789
  }
8791
- else {
8790
+ else
8792
8791
  data.__textBoxBounds = contentBounds;
8793
- }
8794
8792
  }
8795
8793
  __updateRenderSpread() {
8796
8794
  let width = super.__updateRenderSpread();
@@ -10464,17 +10462,20 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
10464
10462
  };
10465
10463
 
10466
10464
  const ui = UI.prototype, group = Group.prototype;
10465
+ function getSelector(ui) {
10466
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10467
+ }
10467
10468
  ui.find = function (condition, options) {
10468
- return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
10469
+ return getSelector(this).getBy(condition, this, false, options);
10469
10470
  };
10470
10471
  ui.findOne = function (condition, options) {
10471
- return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
10472
+ return getSelector(this).getBy(condition, this, true, options);
10472
10473
  };
10473
10474
  group.pick = function (hitPoint, options) {
10474
10475
  this.__layout.update();
10475
10476
  if (!options)
10476
10477
  options = {};
10477
- return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
10478
+ return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10478
10479
  };
10479
10480
 
10480
10481
  const canvas$1 = LeaferCanvasBase.prototype;