leafer-ui 1.4.2 → 1.5.0

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.
@@ -4070,12 +4070,11 @@ function defineDataProcessor(target, key, defaultValue) {
4070
4070
  if (defaultValue === undefined) {
4071
4071
  property.get = function () { return this[computedKey]; };
4072
4072
  }
4073
- else if (typeof defaultValue === 'object') {
4074
- const { clone } = DataHelper;
4073
+ else if (typeof defaultValue === 'function') {
4075
4074
  property.get = function () {
4076
4075
  let v = this[computedKey];
4077
4076
  if (v === undefined)
4078
- this[computedKey] = v = clone(defaultValue);
4077
+ this[computedKey] = v = defaultValue(this.__leaf);
4079
4078
  return v;
4080
4079
  };
4081
4080
  }
@@ -5722,10 +5721,10 @@ let Leaf = class Leaf {
5722
5721
  static changeAttr(attrName, defaultValue, fn) {
5723
5722
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5724
5723
  }
5725
- static addAttr(attrName, defaultValue, fn) {
5724
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5726
5725
  if (!fn)
5727
5726
  fn = boundsType;
5728
- fn(defaultValue)(this.prototype, attrName);
5727
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5729
5728
  }
5730
5729
  __emitLifeEvent(type) {
5731
5730
  if (this.hasEvent(type))
@@ -6052,7 +6051,7 @@ class LeafLevelList {
6052
6051
  }
6053
6052
  }
6054
6053
 
6055
- const version = "1.4.2";
6054
+ const version = "1.5.0";
6056
6055
 
6057
6056
  const debug$5 = Debug.get('LeaferCanvas');
6058
6057
  class LeaferCanvas extends LeaferCanvasBase {
@@ -7120,7 +7119,11 @@ const State = {
7120
7119
  setStyleName() { return Plugin.need('state'); },
7121
7120
  set() { return Plugin.need('state'); }
7122
7121
  };
7123
- const Transition = {};
7122
+ const Transition = {
7123
+ list: {},
7124
+ register(attrName, fn) { Transition.list[attrName] = fn; },
7125
+ get(attrName) { return Transition.list[attrName]; }
7126
+ };
7124
7127
 
7125
7128
  const { parse, objectToCanvasData } = PathConvert;
7126
7129
  const emptyPaint = {};
@@ -7544,9 +7547,6 @@ let UI = UI_1 = class UI extends Leaf {
7544
7547
  this.__drawPathByBox(pen);
7545
7548
  return pen;
7546
7549
  }
7547
- get editConfig() { return undefined; }
7548
- get editOuter() { return ''; }
7549
- get editInner() { return ''; }
7550
7550
  constructor(data) {
7551
7551
  super(data);
7552
7552
  }
@@ -7628,8 +7628,11 @@ let UI = UI_1 = class UI extends Leaf {
7628
7628
  export(_filename, _options) {
7629
7629
  return Plugin.need('export');
7630
7630
  }
7631
+ syncExport(_filename, _options) {
7632
+ return Plugin.need('export');
7633
+ }
7631
7634
  clone(data) {
7632
- const json = this.toJSON();
7635
+ const json = DataHelper.clone(this.toJSON());
7633
7636
  if (data)
7634
7637
  Object.assign(json, data);
7635
7638
  return UI_1.one(json);
@@ -7928,7 +7931,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7928
7931
  get layoutLocked() { return !this.layouter.running; }
7929
7932
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7930
7933
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7931
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7934
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7932
7935
  constructor(userConfig, data) {
7933
7936
  super(data);
7934
7937
  this.config = {
@@ -8230,6 +8233,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8230
8233
  getPagePointByClient(clientPoint, updateClient) {
8231
8234
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8232
8235
  }
8236
+ getClientPointByWorld(worldPoint) {
8237
+ const { x, y } = this.clientBounds;
8238
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8239
+ }
8233
8240
  updateClientBounds() {
8234
8241
  this.canvas && this.canvas.updateClientBounds();
8235
8242
  }
@@ -10198,8 +10205,6 @@ ui$1.__updateHitCanvas = function () {
10198
10205
  h.setStrokeOptions(data);
10199
10206
  };
10200
10207
  ui$1.__hit = function (inner) {
10201
- if (Platform.name === 'miniapp')
10202
- this.__drawHitPath(this.__hitCanvas);
10203
10208
  const data = this.__;
10204
10209
  if (data.__isHitPixel && this.__hitPixel(inner))
10205
10210
  return true;
@@ -11863,13 +11868,14 @@ function toChar(data, charX, rowData, isOverflow) {
11863
11868
  }
11864
11869
 
11865
11870
  function layoutText(drawData, style) {
11866
- const { rows, bounds } = drawData;
11871
+ const { rows, bounds } = drawData, countRows = rows.length;
11867
11872
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11868
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11873
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11869
11874
  let starY = __baseLine;
11870
11875
  if (__clipText && realHeight > height) {
11871
11876
  realHeight = Math.max(height, __lineHeight);
11872
- drawData.overflow = rows.length;
11877
+ if (countRows > 1)
11878
+ drawData.overflow = countRows;
11873
11879
  }
11874
11880
  else if (height || autoSizeAlign) {
11875
11881
  switch (verticalAlign) {
@@ -11881,7 +11887,7 @@ function layoutText(drawData, style) {
11881
11887
  }
11882
11888
  starY += y;
11883
11889
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11884
- for (let i = 0, len = rows.length; i < len; i++) {
11890
+ for (let i = 0, len = countRows; i < len; i++) {
11885
11891
  row = rows[i];
11886
11892
  row.x = x;
11887
11893
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -11950,7 +11956,7 @@ function clipText(drawData, style, x, width) {
11950
11956
  if (i === end && charRight < right) {
11951
11957
  break;
11952
11958
  }
11953
- else if (charRight < right && char.char !== ' ') {
11959
+ else if ((charRight < right && char.char !== ' ') || !i) {
11954
11960
  row.data.splice(i + 1);
11955
11961
  row.width -= char.width;
11956
11962
  break;