@leafer-ui/interface 1.0.0-rc.19 → 1.0.0-rc.20

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/interface",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.20",
4
4
  "description": "@leafer-ui/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,6 +22,6 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/interface": "1.0.0-rc.19"
25
+ "@leafer/interface": "1.0.0-rc.20"
26
26
  }
27
27
  }
package/src/IUI.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IExportOptions, IExportResult, IPathDrawer, IPointData, IPathCommandData, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IPathCreator, IAnswer, IPickOptions, IPickResult, IValue } from '@leafer/interface'
1
+ import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IExportOptions, IExportResult, IPathDrawer, IPointData, IPathCommandData, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IPathCreator, IAnswer, IPickOptions, IPickResult, IValue, ICanvasContext2DSettings } from '@leafer/interface'
2
2
 
3
3
  import {
4
4
  IFillAttrData, IFillInputData, IFillComputedData,
@@ -10,6 +10,7 @@ import {
10
10
  } from './ICommonAttr'
11
11
  import { IOverflow } from './type/IType'
12
12
  import { ILeafer } from './app/ILeafer'
13
+ import { IEditorConfig } from './editor/IEditor'
13
14
 
14
15
  // Line
15
16
  export interface ILine extends IUI {
@@ -111,7 +112,6 @@ export interface IPen extends IGroup, IPathCreator {
111
112
  pathStyle: IPathInputData
112
113
  path: IPathCommandData
113
114
  paint(): void
114
- clear(): void
115
115
  }
116
116
 
117
117
  export interface IPenData extends IGroupData { }
@@ -201,11 +201,13 @@ export interface IImageInputData extends IImageAttrData, IUIBaseInputData { }
201
201
  export interface ICanvas extends IRect {
202
202
  __: ICanvasData
203
203
  smooth: boolean
204
+ contextSettings: ICanvasContext2DSettings
204
205
  canvas: ILeaferCanvas
205
206
  __updateSize(): void
206
207
  }
207
208
  interface ICanvasAttrData {
208
209
  smooth?: boolean
210
+ contextSettings?: ICanvasContext2DSettings
209
211
  }
210
212
  export interface ICanvasData extends ICanvasAttrData, IRectData { }
211
213
  export interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData { }
@@ -291,6 +293,8 @@ export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrDa
291
293
  selectedStyle: IUIInputData
292
294
  disabledStyle: IUIInputData
293
295
 
296
+ editorStyle: IEditorConfig
297
+
294
298
  children?: IUI[]
295
299
 
296
300
  reset(data?: IUIInputData): void
@@ -330,6 +334,8 @@ export interface IUIData extends IUIComputedData, ILeafData {
330
334
  selectedStyle?: IUIInputData
331
335
  disabledStyle?: IUIInputData
332
336
 
337
+ editorStyle?: IEditorConfig
338
+
333
339
  // 非数据属性, 自动计算的缓存数据
334
340
  __isFills?: boolean
335
341
  __isStrokes?: boolean
@@ -339,6 +345,8 @@ export interface IUIData extends IUIComputedData, ILeafData {
339
345
  __pixelFill?: boolean // png / svg / webp
340
346
  __pixelStroke?: boolean
341
347
 
348
+ __isHitPixel?: boolean
349
+
342
350
  __opacityFill?: boolean // 半透明的
343
351
  __opacityStroke?: boolean
344
352
 
@@ -375,6 +383,8 @@ export interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITex
375
383
  selectedStyle?: IUIInputData
376
384
  disabledStyle?: IUIInputData
377
385
 
386
+ editorStyle?: IEditorConfig
387
+
378
388
  children?: IUIInputData[]
379
389
  }
380
390
 
@@ -18,4 +18,5 @@ export interface ILeafer extends IGroup, ILeaferAttrData, IControl {
18
18
 
19
19
  onInit(): void
20
20
  initType(type: ILeaferType): void
21
+ destroy(sync?: boolean): void
21
22
  }
@@ -70,6 +70,7 @@ export interface IEditorConfig {
70
70
  buttonsMargin?: number
71
71
 
72
72
  hideOnMove?: boolean
73
+ hideOnSmall?: boolean | number
73
74
 
74
75
  moveCursor?: ICursorType
75
76
  resizeCursor?: IImageCursor
@@ -77,12 +78,15 @@ export interface IEditorConfig {
77
78
  skewCursor?: IImageCursor
78
79
 
79
80
  around?: IAround
80
- lockRatio?: boolean
81
+ lockRatio?: boolean | 'corner'
82
+ lockMove?: boolean | 'x' | 'y'
81
83
  rotateGap?: number
82
84
 
83
85
  selector?: boolean
84
86
  hover?: boolean
87
+ select?: 'press' | 'tap'
85
88
  boxSelect?: boolean
89
+ continuousSelect?: boolean // 点击可以连续选择
86
90
 
87
91
  moveable?: boolean
88
92
  rotateable?: boolean
package/src/type/IType.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData } from '@leafer/interface'
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData, IFourNumber } from '@leafer/interface'
2
2
  import { IColorString, IPaintString } from './IStringType'
3
3
 
4
4
  export interface IUnitData {
@@ -71,6 +71,7 @@ export interface IImagePaint extends IPaintBase {
71
71
 
72
72
  filters?: IImageFilters
73
73
 
74
+ padding?: IFourNumber
74
75
  offset?: IPointData
75
76
  size?: number | ISizeData
76
77
  scale?: number | IPointData
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IPointData, IExportFileType, ISizeData, IPathCommandData, IWindingRule, IBlendMode, IMatrixData, ILeaferImage, ITaskItem, INumber, IBoolean, IString, IPathCreator, IBoundsData, ILeaferImageConfig, ILeaferCanvas, IRenderOptions, IPickOptions, IPickResult, ILeaf, IValue, IPathString, IPathDrawer, IExportOptions, IExportResult, IAnswer, ILeafData, ILeafComputedData, ILeafInputData, IObject, ILeaferAttrData, IControl, ILeaferConfig, ILeaferType, ILeafRender, ILeafBounds, ILeafHit, IStateStyleType, ICachedLeaf, IBooleanMap } from '@leafer/interface';
1
+ import { IPointData, IExportFileType, IFourNumber, ISizeData, IPathCommandData, IWindingRule, IBlendMode, IMatrixData, ILeaferImage, ITaskItem, INumber, IBoolean, IString, IPathCreator, IBoundsData, ILeaferImageConfig, ICanvasContext2DSettings, ILeaferCanvas, IRenderOptions, IPickOptions, IPickResult, ILeaf as ILeaf$1, IValue, IPathString, IPathDrawer, IExportOptions, IExportResult, IAnswer, ILeafData, ILeafComputedData, ILeafInputData, IObject as IObject$1, ILeaferAttrData, IControl, ILeaferConfig, ILeaferType, ILeafRender, ILeafBounds, ILeafHit, IStateStyleType, ICachedLeaf, IBooleanMap } from '@leafer/interface';
2
2
  export * from '@leafer/interface';
3
- import { IGroup as IGroup$1, ISelectorProxy, IUI as IUI$1, IObject as IObject$1, ILeaf as ILeaf$1, IEditSize, IDragEvent, IRotateEvent, IGroupInputData as IGroupInputData$1, IStroke as IStroke$1, IFill as IFill$1, IBoxInputData as IBoxInputData$1, IRectInputData as IRectInputData$1, ICursorType, IImageCursor, IAround } from '@leafer-ui/interface';
3
+ import { IGroup as IGroup$1, ISelectorProxy, IUI as IUI$1, IObject, ILeaf, IEditSize, IDragEvent, IRotateEvent, IGroupInputData as IGroupInputData$1, IStroke as IStroke$1, IFill as IFill$1, IBoxInputData as IBoxInputData$1, IRectInputData as IRectInputData$1, ICursorType, IImageCursor, IAround } from '@leafer-ui/interface';
4
4
 
5
5
  type IPercent = string;
6
6
  type IColorString = string;
@@ -60,6 +60,7 @@ interface IImagePaint extends IPaintBase {
60
60
  mode?: IImagePaintMode;
61
61
  format?: IExportFileType;
62
62
  filters?: IImageFilters;
63
+ padding?: IFourNumber;
63
64
  offset?: IPointData;
64
65
  size?: number | ISizeData;
65
66
  scale?: number | IPointData;
@@ -303,6 +304,76 @@ interface IEffectComputedData {
303
304
  grayscale?: number;
304
305
  }
305
306
 
307
+ interface IEditorBase extends IGroup$1, ISelectorProxy {
308
+ config: IEditorConfig;
309
+ hoverTarget: IUI$1;
310
+ target: IUI$1 | IUI$1[];
311
+ readonly list: IUI$1[];
312
+ readonly hasTarget: boolean;
313
+ readonly multiple: boolean;
314
+ readonly single: boolean;
315
+ readonly dragging: boolean;
316
+ element: IUI$1;
317
+ buttons: IGroup$1;
318
+ selector: IGroup$1;
319
+ editBox: IGroup$1;
320
+ editTool: IObject;
321
+ hasItem(item: IUI$1): boolean;
322
+ shiftItem(item: IUI$1): void;
323
+ addItem(item: IUI$1): void;
324
+ removeItem(item: IUI$1): void;
325
+ update(): void;
326
+ updateEditTool(): void;
327
+ getEditSize(ui: ILeaf): IEditSize;
328
+ onMove(e: IDragEvent): void;
329
+ onScale(e: IDragEvent): void;
330
+ onRotate(e: IDragEvent | IRotateEvent): void;
331
+ onSkew(e: IDragEvent): void;
332
+ group(group?: IGroup$1 | IGroupInputData$1): IGroup$1;
333
+ ungroup(): IUI$1[];
334
+ lock(): void;
335
+ unlock(): void;
336
+ toTop(): void;
337
+ toBottom(): void;
338
+ }
339
+ interface IEditorConfig {
340
+ editSize?: 'auto' | IEditSize;
341
+ dualEvent?: boolean;
342
+ keyEvent?: boolean;
343
+ stroke?: IStroke$1;
344
+ strokeWidth?: number;
345
+ pointFill?: IFill$1;
346
+ pointSize?: number;
347
+ pointRadius?: number;
348
+ point?: IBoxInputData$1 | IBoxInputData$1[];
349
+ middlePoint?: IBoxInputData$1 | IBoxInputData$1[];
350
+ rotatePoint?: IBoxInputData$1;
351
+ rect?: IBoxInputData$1;
352
+ area?: IRectInputData$1;
353
+ buttonsDirection?: 'top' | 'right' | 'bottom' | 'left';
354
+ buttonsFixed?: boolean;
355
+ buttonsMargin?: number;
356
+ hideOnMove?: boolean;
357
+ hideOnSmall?: boolean | number;
358
+ moveCursor?: ICursorType;
359
+ resizeCursor?: IImageCursor;
360
+ rotateCursor?: IImageCursor;
361
+ skewCursor?: IImageCursor;
362
+ around?: IAround;
363
+ lockRatio?: boolean | 'corner';
364
+ lockMove?: boolean | 'x' | 'y';
365
+ rotateGap?: number;
366
+ selector?: boolean;
367
+ hover?: boolean;
368
+ select?: 'press' | 'tap';
369
+ boxSelect?: boolean;
370
+ continuousSelect?: boolean;
371
+ moveable?: boolean;
372
+ rotateable?: boolean;
373
+ resizeable?: boolean;
374
+ skewable?: boolean;
375
+ }
376
+
306
377
  interface ILine extends IUI {
307
378
  __: ILineData;
308
379
  toPoint: IPointData;
@@ -390,7 +461,6 @@ interface IPen extends IGroup, IPathCreator {
390
461
  pathStyle: IPathInputData;
391
462
  path: IPathCommandData;
392
463
  paint(): void;
393
- clear(): void;
394
464
  }
395
465
  interface IPenData extends IGroupData {
396
466
  }
@@ -468,11 +538,13 @@ interface IImageInputData extends IImageAttrData, IUIBaseInputData {
468
538
  interface ICanvas extends IRect {
469
539
  __: ICanvasData;
470
540
  smooth: boolean;
541
+ contextSettings: ICanvasContext2DSettings;
471
542
  canvas: ILeaferCanvas;
472
543
  __updateSize(): void;
473
544
  }
474
545
  interface ICanvasAttrData {
475
546
  smooth?: boolean;
547
+ contextSettings?: ICanvasContext2DSettings;
476
548
  }
477
549
  interface ICanvasData extends ICanvasAttrData, IRectData {
478
550
  }
@@ -513,7 +585,7 @@ interface IGroup extends IUI {
513
585
  addAt(child: IUI, index: number): void;
514
586
  addAfter(child: IUI, after: IUI): void;
515
587
  addBefore(child: IUI, before: IUI): void;
516
- addMany(...children: ILeaf[]): void;
588
+ addMany(...children: ILeaf$1[]): void;
517
589
  remove(child?: IUI): void;
518
590
  removeAll(): void;
519
591
  clear(): void;
@@ -522,7 +594,7 @@ interface IGroupData extends IUIData {
522
594
  }
523
595
  interface IGroupInputData extends IUIBaseInputData {
524
596
  }
525
- interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
597
+ interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf$1 {
526
598
  __: IUIData;
527
599
  readonly app: ILeafer;
528
600
  leafer?: ILeafer;
@@ -537,6 +609,7 @@ interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEf
537
609
  focusStyle: IUIInputData;
538
610
  selectedStyle: IUIInputData;
539
611
  disabledStyle: IUIInputData;
612
+ editorStyle: IEditorConfig;
540
613
  children?: IUI[];
541
614
  reset(data?: IUIInputData): void;
542
615
  set(data: IUIInputData): void;
@@ -564,11 +637,13 @@ interface IUIData extends IUIComputedData, ILeafData {
564
637
  focusStyle?: IUIInputData;
565
638
  selectedStyle?: IUIInputData;
566
639
  disabledStyle?: IUIInputData;
640
+ editorStyle?: IEditorConfig;
567
641
  __isFills?: boolean;
568
642
  __isStrokes?: boolean;
569
643
  readonly __strokeWidth: number;
570
644
  __pixelFill?: boolean;
571
645
  __pixelStroke?: boolean;
646
+ __isHitPixel?: boolean;
572
647
  __opacityFill?: boolean;
573
648
  __opacityStroke?: boolean;
574
649
  __drawAfterFill?: boolean;
@@ -595,79 +670,14 @@ interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleI
595
670
  focusStyle?: IUIInputData;
596
671
  selectedStyle?: IUIInputData;
597
672
  disabledStyle?: IUIInputData;
673
+ editorStyle?: IEditorConfig;
598
674
  children?: IUIInputData[];
599
675
  }
600
676
  type IUITag = 'App' | 'Leafer' | 'Rect' | 'Ellipse' | 'Polygon' | 'Star' | 'Line' | 'Path' | 'Pen' | 'Text' | 'Image' | 'Canvas' | 'Group' | 'Frame' | 'Box';
601
- interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
677
+ interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject$1 {
602
678
  children?: IUIInputData[];
603
679
  }
604
680
 
605
- interface IEditorBase extends IGroup$1, ISelectorProxy {
606
- config: IEditorConfig;
607
- hoverTarget: IUI$1;
608
- target: IUI$1 | IUI$1[];
609
- readonly list: IUI$1[];
610
- readonly hasTarget: boolean;
611
- readonly multiple: boolean;
612
- readonly single: boolean;
613
- readonly dragging: boolean;
614
- element: IUI$1;
615
- buttons: IGroup$1;
616
- selector: IGroup$1;
617
- editBox: IGroup$1;
618
- editTool: IObject$1;
619
- hasItem(item: IUI$1): boolean;
620
- shiftItem(item: IUI$1): void;
621
- addItem(item: IUI$1): void;
622
- removeItem(item: IUI$1): void;
623
- update(): void;
624
- updateEditTool(): void;
625
- getEditSize(ui: ILeaf$1): IEditSize;
626
- onMove(e: IDragEvent): void;
627
- onScale(e: IDragEvent): void;
628
- onRotate(e: IDragEvent | IRotateEvent): void;
629
- onSkew(e: IDragEvent): void;
630
- group(group?: IGroup$1 | IGroupInputData$1): IGroup$1;
631
- ungroup(): IUI$1[];
632
- lock(): void;
633
- unlock(): void;
634
- toTop(): void;
635
- toBottom(): void;
636
- }
637
- interface IEditorConfig {
638
- editSize?: 'auto' | IEditSize;
639
- dualEvent?: boolean;
640
- keyEvent?: boolean;
641
- stroke?: IStroke$1;
642
- strokeWidth?: number;
643
- pointFill?: IFill$1;
644
- pointSize?: number;
645
- pointRadius?: number;
646
- point?: IBoxInputData$1 | IBoxInputData$1[];
647
- middlePoint?: IBoxInputData$1 | IBoxInputData$1[];
648
- rotatePoint?: IBoxInputData$1;
649
- rect?: IBoxInputData$1;
650
- area?: IRectInputData$1;
651
- buttonsDirection?: 'top' | 'right' | 'bottom' | 'left';
652
- buttonsFixed?: boolean;
653
- buttonsMargin?: number;
654
- hideOnMove?: boolean;
655
- moveCursor?: ICursorType;
656
- resizeCursor?: IImageCursor;
657
- rotateCursor?: IImageCursor;
658
- skewCursor?: IImageCursor;
659
- around?: IAround;
660
- lockRatio?: boolean;
661
- rotateGap?: number;
662
- selector?: boolean;
663
- hover?: boolean;
664
- boxSelect?: boolean;
665
- moveable?: boolean;
666
- rotateable?: boolean;
667
- resizeable?: boolean;
668
- skewable?: boolean;
669
- }
670
-
671
681
  interface ILeafer extends IGroup, ILeaferAttrData, IControl {
672
682
  readonly isApp: boolean;
673
683
  readonly app: ILeafer;
@@ -680,6 +690,7 @@ interface ILeafer extends IGroup, ILeaferAttrData, IControl {
680
690
  userConfig?: ILeaferConfig;
681
691
  onInit(): void;
682
692
  initType(type: ILeaferType): void;
693
+ destroy(sync?: boolean): void;
683
694
  }
684
695
 
685
696
  interface IApp extends ILeafer {
@@ -734,16 +745,16 @@ interface IColorConvertModule {
734
745
 
735
746
  interface IExportModule {
736
747
  running?: boolean;
737
- export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
748
+ export(leaf: ILeaf$1, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
738
749
  }
739
750
 
740
751
  interface IStateModule {
741
- isHover(leaf: ILeaf): boolean;
742
- isPress(leaf: ILeaf): boolean;
743
- isFocus(leaf: ILeaf): boolean;
744
- isDrag(leaf: ILeaf): boolean;
745
- setStyle(leaf: ILeaf, stateType: IStateStyleType, value: boolean): void;
746
- updateEventStyle(leaf: ILeaf, eventType: string): void;
752
+ isHover(leaf: ILeaf$1): boolean;
753
+ isPress(leaf: ILeaf$1): boolean;
754
+ isFocus(leaf: ILeaf$1): boolean;
755
+ isDrag(leaf: ILeaf$1): boolean;
756
+ setStyle(leaf: ILeaf$1, stateType: IStateStyleType, value: boolean): void;
757
+ updateEventStyle(leaf: ILeaf$1, eventType: string): void;
747
758
  }
748
759
 
749
760
  interface ICachedShape extends ICachedLeaf {