@leafer-ui/display 1.9.0 → 1.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "1.9.0",
26
- "@leafer-ui/data": "1.9.0",
27
- "@leafer-ui/display-module": "1.9.0",
28
- "@leafer-ui/decorator": "1.9.0",
29
- "@leafer-ui/external": "1.9.0"
25
+ "@leafer/core": "1.9.2",
26
+ "@leafer-ui/data": "1.9.2",
27
+ "@leafer-ui/display-module": "1.9.2",
28
+ "@leafer-ui/decorator": "1.9.2",
29
+ "@leafer-ui/external": "1.9.2"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.9.0",
33
- "@leafer-ui/interface": "1.9.0"
32
+ "@leafer/interface": "1.9.2",
33
+ "@leafer-ui/interface": "1.9.2"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -1,16 +1,15 @@
1
- import { ILeaferCanvas, IRenderOptions, IBoundsData, IBoolean, INumber } from '@leafer/interface'
2
- import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType, dataType, boundsType, DataHelper } from '@leafer/core'
1
+ import { ILeaferCanvas, IRenderOptions, IBoolean, INumber, IScrollPointData } from '@leafer/interface'
2
+ import { rewrite, rewriteAble, registerUI, BoundsHelper, dataProcessor, affectRenderBoundsType, dataType, boundsType, DataHelper, getBoundsData } from '@leafer/core'
3
3
 
4
- import { IBox, IBoxData, IBoxInputData, IGroup, IOverflow } from '@leafer-ui/interface'
4
+ import { IBox, IBoxData, IBoxInputData, IOverflow, IScrollConfig, IScroller } from '@leafer-ui/interface'
5
5
  import { BoxData } from '@leafer-ui/data'
6
6
 
7
7
  import { Group } from './Group'
8
8
  import { Rect } from './Rect'
9
9
 
10
10
 
11
- const { copy, add, includes } = BoundsHelper
11
+ const { add, includes, scroll } = BoundsHelper
12
12
  const rect = Rect.prototype, group = Group.prototype
13
- const childrenRenderBounds = {} as IBoundsData
14
13
 
15
14
  @rewriteAble()
16
15
  @registerUI()
@@ -39,9 +38,13 @@ export class Box extends Group implements IBox {
39
38
  @affectRenderBoundsType('show')
40
39
  declare public overflow?: IOverflow
41
40
 
42
- public isOverflow: boolean
41
+ public isOverflow?: boolean
43
42
 
44
- public scrollBar?: IGroup
43
+ // scroller rewrite
44
+ public scrollConfig?: IScrollConfig
45
+
46
+ public scroller?: IScroller
47
+ public hasScroller?: boolean
45
48
 
46
49
  constructor(data?: IBoxInputData) {
47
50
  super(data)
@@ -99,32 +102,36 @@ export class Box extends Group implements IBox {
99
102
  let isOverflow: boolean
100
103
 
101
104
  if (this.children.length) {
102
- const data = this.__, { renderBounds, boxBounds } = this.__layout
105
+ const data = this.__, layout = this.__layout, { renderBounds, boxBounds } = layout
103
106
 
104
- super.__updateRenderBounds()
105
- copy(childrenRenderBounds, renderBounds)
106
- this.__updateRectRenderBounds()
107
+ const childrenRenderBounds = layout.childrenRenderBounds || (layout.childrenRenderBounds = getBoundsData())
108
+ super.__updateRenderBounds(childrenRenderBounds)
109
+ scroll(childrenRenderBounds, data as IScrollPointData) // 增加滚动逻辑
107
110
 
108
- // 增加滚动逻辑
109
- if (data.scrollY || data.scrollX) {
110
- childrenRenderBounds.x += data.scrollX
111
- childrenRenderBounds.y += data.scrollY
112
- }
111
+ this.__updateRectRenderBounds()
113
112
 
114
113
  isOverflow = !includes(boxBounds, childrenRenderBounds)
115
- if (isOverflow && data.overflow !== 'hide') add(renderBounds, childrenRenderBounds)
114
+ if (isOverflow && data.overflow === 'show') add(renderBounds, childrenRenderBounds)
116
115
  } else this.__updateRectRenderBounds()
117
116
 
118
117
  DataHelper.stintSet(this, 'isOverflow', isOverflow)
119
118
 
120
- this.__updateScrollBar()
119
+ this.__checkScroll()
121
120
  }
122
121
 
123
122
  @rewrite(rect.__updateRenderBounds)
124
123
  public __updateRectRenderBounds(): void { }
125
124
 
126
- // need rewrite
127
- public __updateScrollBar(): void { }
125
+ public __updateWorldBounds(): void {
126
+ if (this.hasScroller) this.__updateScroll()
127
+ super.__updateWorldBounds()
128
+ }
129
+
130
+
131
+ // scroller will rewrite
132
+ public __checkScroll(): void { }
133
+
134
+ public __updateScroll(): void { }
128
135
 
129
136
 
130
137
  @rewrite(rect.__updateChange)
@@ -150,7 +157,7 @@ export class Box extends Group implements IBox {
150
157
  this.__renderRect(canvas, options)
151
158
  if (this.children.length) this.__renderGroup(canvas, options)
152
159
  }
153
- if (this.scrollBar) this.scrollBar.__render(canvas, options)
160
+ if (this.hasScroller) this.scroller.__render(canvas, options)
154
161
  }
155
162
 
156
163
  // in __drawAfterFill()
package/src/Group.ts CHANGED
@@ -27,6 +27,8 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
27
27
 
28
28
  declare public children: IUI[]
29
29
 
30
+ declare public topChildren?: IUI[]
31
+
30
32
  public childlessJSON?: boolean
31
33
 
32
34
  constructor(data?: IGroupInputData) {
package/src/Leafer.ts CHANGED
@@ -391,7 +391,7 @@ export class Leafer extends Group implements ILeafer {
391
391
 
392
392
 
393
393
  // interaction window rewrite
394
- public getValidMove(moveX: number, moveY: number): IPointData { return { x: moveX, y: moveY } }
394
+ public getValidMove(moveX: number, moveY: number, _checkLimit?: boolean): IPointData { return { x: moveX, y: moveY } }
395
395
  public getValidScale(changeScale: number): number { return changeScale }
396
396
 
397
397
 
package/src/Text.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferCanvas, IBoolean, INumber, IString, IBoundsData, IUnitData, IRenderOptions } from '@leafer/interface'
2
2
  import { BoundsHelper, boundsType, surfaceType, dataProcessor, registerUI, affectStrokeBoundsType, dataType, hitType, MathHelper, DataHelper } from '@leafer/core'
3
3
 
4
- import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, IOverflow, IStrokeAlign, IHitType, ITextWrap, IWritingMode, IBackgroundBoxStyle } from '@leafer-ui/interface'
4
+ import { IFill, IText, IFontWeight, ITextCase, ITextDecoration, ITextData, ITextInputData, ITextAlign, IVerticalAlign, ITextDrawData, ITextOverflow, IStrokeAlign, IHitType, ITextWrap, IWritingMode, IBackgroundBoxStyle } from '@leafer-ui/interface'
5
5
  import { TextData } from '@leafer-ui/data'
6
6
 
7
7
  import { TextConvert, UnitConvert } from '@leafer-ui/external'
@@ -93,7 +93,7 @@ export class Text extends UI implements IText {
93
93
  public textWrap?: ITextWrap
94
94
 
95
95
  @boundsType('show')
96
- public textOverflow?: IOverflow | string
96
+ public textOverflow?: ITextOverflow
97
97
 
98
98
  @surfaceType(false)
99
99
  public textEditing: boolean
@@ -115,7 +115,7 @@ export class Text extends UI implements IText {
115
115
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize)
116
116
  data.__padding = padding ? MathHelper.fourNumber(padding) : undefined
117
117
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2 // 基线位置
118
- data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`
118
+ data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize || 12}px ${fontFamily || 'caption'}`
119
119
  data.__clipText = textOverflow !== 'show' && !data.__autoSize
120
120
 
121
121
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === '') ? data.placeholder : data.text, this.__)
package/src/UI.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject, ITransition, IFilter, ILeaferImage, IScaleFixed } from '@leafer/interface'
2
- import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, Plugin, DataHelper, affectRenderBoundsType, isString, isNumber } from '@leafer/core'
1
+ import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject, ITransition, IFilter, ILeaferImage, IScaleFixed, IDragBoundsType } from '@leafer/interface'
2
+ import { Leaf, PathDrawer, surfaceType, dataType, positionType, scrollType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, Plugin, DataHelper, affectRenderBoundsType, isString, isNumber } from '@leafer/core'
3
3
 
4
4
  import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, IAnimateType, IStateStyle, IColorString, IAnimateList } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
@@ -120,10 +120,10 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
120
120
  public offsetY?: INumber
121
121
 
122
122
  // scroll
123
- @positionType(0, true)
123
+ @scrollType(0, true)
124
124
  public scrollX?: INumber
125
125
 
126
- @positionType(0, true)
126
+ @scrollType(0, true)
127
127
  public scrollY?: INumber
128
128
 
129
129
 
@@ -199,6 +199,9 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
199
199
  @dataType()
200
200
  public dragBounds?: IBoundsData | 'parent'
201
201
 
202
+ @dataType('auto')
203
+ dragBoundsType?: IDragBoundsType
204
+
202
205
 
203
206
  @dataType(false)
204
207
  public editable?: IBoolean
@@ -516,14 +519,15 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
516
519
  return Plugin.need('export')
517
520
  }
518
521
 
519
- public clone(data?: IUIInputData): IUI {
522
+ public clone(data?: IUIInputData): this {
520
523
  const json = DataHelper.clone(this.toJSON())
521
524
  if (data) Object.assign(json, data)
522
- return UI.one(json)
525
+ return UI.one(json) as this
523
526
  }
524
527
 
525
- static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI {
526
- return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
528
+ // this 参数定义,在编译的时候会移除
529
+ static one<T extends UI>(this: new (...args: any[]) => T, data: IUIInputData, x?: number, y?: number, width?: number, height?: number): T {
530
+ return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as T
527
531
  }
528
532
 
529
533
  static registerUI(): void {
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IHitType, ICursorType, IScaleFixed, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, ILeaferImage, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IZoomOptions, IClientPointData, IRenderOptions, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
1
+ import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IDragBoundsType, IHitType, ICursorType, IScaleFixed, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, ILeaferImage, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IZoomOptions, IClientPointData, IRenderOptions, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
2
  import { Leaf, LeafList } from '@leafer/core';
3
- import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IColorString, IEditorConfig, IAnimate, IAnimateList, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IBackgroundBoxStyle, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData, IPointData as IPointData$1 } from '@leafer-ui/interface';
3
+ import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IColorString, IEditorConfig, IAnimate, IAnimateList, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IScrollConfig, IScroller, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IBackgroundBoxStyle, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextOverflow, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData, IPointData as IPointData$1 } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI extends Leaf implements IUI {
6
6
  __: IUIData;
@@ -60,6 +60,7 @@ declare class UI extends Leaf implements IUI {
60
60
  heightRange?: IRangeSize;
61
61
  draggable?: IBoolean | IAxis;
62
62
  dragBounds?: IBoundsData | 'parent';
63
+ dragBoundsType?: IDragBoundsType;
63
64
  editable?: IBoolean;
64
65
  hittable?: IBoolean;
65
66
  hitFill?: IHitType;
@@ -146,8 +147,8 @@ declare class UI extends Leaf implements IUI {
146
147
  killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void;
147
148
  export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult>;
148
149
  syncExport(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): IExportResult;
149
- clone(data?: IUIInputData): IUI;
150
- static one(data: IUIInputData, x?: number, y?: number, width?: number, height?: number): IUI;
150
+ clone(data?: IUIInputData): this;
151
+ static one<T extends UI>(this: new (...args: any[]) => T, data: IUIInputData, x?: number, y?: number, width?: number, height?: number): T;
151
152
  static registerUI(): void;
152
153
  static registerData(data: IUIData): void;
153
154
  static setEditConfig(_config: IEditorConfig | IEditorConfigFunction): void;
@@ -163,6 +164,7 @@ declare class Group extends UI implements IGroup {
163
164
  width?: INumber;
164
165
  height?: INumber;
165
166
  children: IUI[];
167
+ topChildren?: IUI[];
166
168
  childlessJSON?: boolean;
167
169
  constructor(data?: IGroupInputData);
168
170
  reset(data?: IGroupInputData): void;
@@ -261,7 +263,7 @@ declare class Leafer extends Group implements ILeafer {
261
263
  waitViewCompleted(item: IFunction, bind?: IObject): void;
262
264
  nextRender(item: IFunction, bind?: IObject, off?: 'off'): void;
263
265
  zoom(_zoomType: IZoomType, _optionsOrPadding?: IZoomOptions | IFourNumber, _scroll?: 'x' | 'y' | boolean, _transition?: ITransition): IBoundsData;
264
- getValidMove(moveX: number, moveY: number): IPointData;
266
+ getValidMove(moveX: number, moveY: number, _checkLimit?: boolean): IPointData;
265
267
  getValidScale(changeScale: number): number;
266
268
  getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
267
269
  getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
@@ -283,8 +285,10 @@ declare class Box extends Group implements IBox {
283
285
  resizeChildren?: IBoolean;
284
286
  textBox?: IBoolean;
285
287
  overflow?: IOverflow;
286
- isOverflow: boolean;
287
- scrollBar?: IGroup;
288
+ isOverflow?: boolean;
289
+ scrollConfig?: IScrollConfig;
290
+ scroller?: IScroller;
291
+ hasScroller?: boolean;
288
292
  constructor(data?: IBoxInputData);
289
293
  __updateStrokeSpread(): number;
290
294
  __updateRectRenderSpread(): number;
@@ -294,7 +298,9 @@ declare class Box extends Group implements IBox {
294
298
  __updateStrokeBounds(): void;
295
299
  __updateRenderBounds(): void;
296
300
  __updateRectRenderBounds(): void;
297
- __updateScrollBar(): void;
301
+ __updateWorldBounds(): void;
302
+ __checkScroll(): void;
303
+ __updateScroll(): void;
298
304
  __updateRectChange(): void;
299
305
  __updateChange(): void;
300
306
  __renderRect(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
@@ -424,7 +430,7 @@ declare class Text extends UI implements IText {
424
430
  verticalAlign?: IVerticalAlign;
425
431
  autoSizeAlign?: IBoolean;
426
432
  textWrap?: ITextWrap;
427
- textOverflow?: IOverflow | string;
433
+ textOverflow?: ITextOverflow;
428
434
  textEditing: boolean;
429
435
  isOverflow: boolean;
430
436
  get textDrawData(): ITextDrawData;