dcp-design-react 1.8.20 → 1.8.22

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.
@@ -0,0 +1,3 @@
1
+ import Signature from './src/signature';
2
+ export type { SignatureProps } from './src/signature';
3
+ export default Signature;
@@ -0,0 +1,17 @@
1
+ import { BasicPoint, Point } from './point';
2
+ export declare class Bezier {
3
+ startPoint: Point;
4
+ control2: BasicPoint;
5
+ control1: BasicPoint;
6
+ endPoint: Point;
7
+ startWidth: number;
8
+ endWidth: number;
9
+ static fromPoints(points: Point[], widths: {
10
+ start: number;
11
+ end: number;
12
+ }): Bezier;
13
+ private static calculateControlPoints;
14
+ constructor(startPoint: Point, control2: BasicPoint, control1: BasicPoint, endPoint: Point, startWidth: number, endWidth: number);
15
+ length(): number;
16
+ private point;
17
+ }
@@ -0,0 +1,124 @@
1
+ import { Bezier } from './bezier';
2
+ import { BasicPoint, Point } from './point';
3
+ interface IOptions {
4
+ width?: number;
5
+ height?: number;
6
+ penColor?: string;
7
+ backgroundColor?: string;
8
+ mode?: IDrawMode;
9
+ openSmooth?: boolean;
10
+ minWidth?: number;
11
+ maxWidth?: number;
12
+ onStart?: (ev: MouseEvent) => void;
13
+ onEnd?: (ev: MouseEvent) => void;
14
+ }
15
+ interface SignatureEvent {
16
+ event: MouseEvent | TouchEvent | PointerEvent;
17
+ type: string;
18
+ x: number;
19
+ y: number;
20
+ pressure: number;
21
+ }
22
+ interface PointGroupOptions {
23
+ dotSize: number;
24
+ minWidth: number;
25
+ maxWidth: number;
26
+ penColor: string;
27
+ velocityFilterWeight: number;
28
+ compositeOperation: GlobalCompositeOperation;
29
+ }
30
+ interface PointGroup extends PointGroupOptions {
31
+ points: BasicPoint[];
32
+ }
33
+ export type IDrawMode = 'line' | 'square' | 'round' | 'arrow' | 'text' | undefined;
34
+ declare class Signature {
35
+ canvas: HTMLCanvasElement;
36
+ ctx: CanvasRenderingContext2D;
37
+ textInput: HTMLDivElement;
38
+ width: number;
39
+ height: number;
40
+ ratio: number;
41
+ penColor: string;
42
+ backgroundColor: string;
43
+ canAddHistory: boolean;
44
+ mode: IDrawMode;
45
+ openSmooth: boolean;
46
+ dotSize: number;
47
+ throttle: number;
48
+ minDistance: number;
49
+ velocityFilterWeight: number;
50
+ compositeOperation: GlobalCompositeOperation;
51
+ minWidth: number;
52
+ maxWidth: number;
53
+ fontSize: number;
54
+ textInputPos: Pick<Point, 'x' | 'y'>;
55
+ isMobile: boolean;
56
+ onStart: IOptions[`onStart`];
57
+ onEnd: IOptions[`onEnd`];
58
+ private _drawingStroke;
59
+ private _lastPoints;
60
+ private _data;
61
+ private _historyList;
62
+ private _lastVelocity;
63
+ private _lastWidth;
64
+ private _strokeMoveUpdate;
65
+ constructor(canvas: HTMLCanvasElement, options: IOptions);
66
+ initial(canvas: HTMLCanvasElement, options?: IOptions): void;
67
+ update(): void;
68
+ setCanvasSize: () => void;
69
+ setTextInput: () => void;
70
+ addListener: () => void;
71
+ removeListener: () => void;
72
+ _isLeftButtonPressed: (ev: MouseEvent, only?: boolean) => boolean;
73
+ _pointerEventToSignatureEvent: (ev: MouseEvent | PointerEvent) => SignatureEvent;
74
+ _getPointGroupOptions: (group?: PointGroup) => PointGroupOptions;
75
+ _strokeBegin: (ev: SignatureEvent) => void;
76
+ _strokeUpdate: (ev: SignatureEvent, shouldUpdate?: boolean) => void;
77
+ _strokeEnd: (ev: SignatureEvent, shouldUpdate?: boolean) => void;
78
+ _reset: (options: PointGroupOptions) => void;
79
+ _drawDot: (point: BasicPoint, options: PointGroupOptions) => void;
80
+ _drawCurve: (curve: Bezier, options: PointGroupOptions) => void;
81
+ _drawCurveSegment: (x: number, y: number, width: number) => void;
82
+ _createPoint: (x: number, y: number, pressure: number) => Point;
83
+ _createPointByEvent: (ev: SignatureEvent) => Point;
84
+ _addPoint: (point: Point, options: PointGroupOptions) => Bezier | null;
85
+ _strokeWidth: (velocity: number, options: PointGroupOptions) => number;
86
+ _calculateCurveWidths: (startPoint: Point, endPoint: Point, options: PointGroupOptions) => {
87
+ start: number;
88
+ end: number;
89
+ };
90
+ onDrawStart: (ev: any) => void;
91
+ onDrawMove: (ev: any) => void;
92
+ onDrawEnd: (ev: any) => void;
93
+ onInputBlur: (ev: any) => void;
94
+ drawHandler: (ev: any) => void;
95
+ drawSquare: (ev: any) => void;
96
+ drawRound: (ev: any) => void;
97
+ drawArrow: (ev: any) => void;
98
+ drawText: (ev: any) => void;
99
+ initPencil: (ev: any) => void;
100
+ drawPencil: (ev: any) => void;
101
+ drawLine: (ev: any) => void;
102
+ initTextInput: (ev: any) => void;
103
+ setInputStyle: (ev: any) => void;
104
+ drawBgColor: () => void;
105
+ clearWorkSpace: () => void;
106
+ addHistory: () => void;
107
+ getLastHistory: () => ImageData;
108
+ setLastHistory: () => void;
109
+ clear: () => void;
110
+ undo: () => void;
111
+ setDrawMode: (value: IDrawMode) => void;
112
+ setLineWidth: (value: number) => void;
113
+ setPenColor: (value: string) => void;
114
+ setFontSize: (value: number) => void;
115
+ static dataURLToBlob: (dataURL: string) => Blob;
116
+ static canvasToDataURL: (canvas: HTMLCanvasElement) => string;
117
+ static canvasToBlob: (canvas: HTMLCanvasElement) => Promise<Blob | null>;
118
+ isEmpty: () => boolean;
119
+ toDataURL: (type?: string, quality?: number) => string;
120
+ getPNG: () => string;
121
+ getJPG: (quality?: number) => string;
122
+ destroy: () => void;
123
+ }
124
+ export default Signature;
@@ -0,0 +1,16 @@
1
+ export interface BasicPoint {
2
+ x: number;
3
+ y: number;
4
+ pressure: number;
5
+ time: number;
6
+ }
7
+ export declare class Point implements BasicPoint {
8
+ x: number;
9
+ y: number;
10
+ pressure: number;
11
+ time: number;
12
+ constructor(x: number, y: number, pressure?: number, time?: number);
13
+ distanceTo(start: BasicPoint): number;
14
+ equals(other: BasicPoint): boolean;
15
+ velocityFrom(start: BasicPoint): number;
16
+ }
@@ -0,0 +1 @@
1
+ export declare function throttle(fn: (...args: any[]) => any, wait?: number): (this: any, ...args: any[]) => any;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { CSSProperties } from '../../_utils/types';
3
+ type IProps = {
4
+ open?: boolean;
5
+ width?: number;
6
+ height?: number;
7
+ penColor?: string;
8
+ minWidth?: number;
9
+ maxWidth?: number;
10
+ backgroundColor?: string;
11
+ imageName?: string;
12
+ className?: string;
13
+ style?: CSSProperties;
14
+ children?: React.ReactNode;
15
+ onOk?: (dataUrl?: string) => void;
16
+ onCancel?: () => void;
17
+ };
18
+ export type SignatureRef = {
19
+ OPEN: () => void;
20
+ CLOSE: () => void;
21
+ UPDATE: (force?: boolean) => void;
22
+ GET_DATE_URL: () => Promise<string | undefined>;
23
+ };
24
+ export type SignatureProps = IProps;
25
+ declare const QmSignature: React.ForwardRefExoticComponent<IProps & React.RefAttributes<SignatureRef>>;
26
+ export default QmSignature;
@@ -0,0 +1,165 @@
1
+ /*
2
+ * @Author: 焦质晔
3
+ * @Date: 2024-05-11 10:14:22
4
+ * @Last Modified by: 焦质晔
5
+ * @Last Modified time: 2024-05-12 19:31:51
6
+ */
7
+ @import '../../style/common';
8
+
9
+ @prefix-signature: ~'@{qm-prefix}-signature';
10
+
11
+ .@{prefix-signature} {
12
+ &.is-annotation {
13
+ position: relative;
14
+ .signature {
15
+ position: absolute;
16
+ left: 0;
17
+ top: 0;
18
+ width: 100%;
19
+ height: 100%;
20
+ z-index: 9;
21
+ display: none;
22
+ &.show {
23
+ display: flex;
24
+ }
25
+ }
26
+ }
27
+ .signature {
28
+ display: flex;
29
+ flex-direction: column;
30
+ position: relative;
31
+ &__tool-bar {
32
+ position: sticky;
33
+ bottom: 0;
34
+ margin-top: 4px;
35
+ pointer-events: none;
36
+ .wrapper {
37
+ display: flex;
38
+ float: right;
39
+ padding: 4px;
40
+ border-radius: 6px;
41
+ background-color: #212c33;
42
+ pointer-events: auto;
43
+ .actions {
44
+ display: inherit;
45
+ flex-direction: row;
46
+ align-items: center;
47
+ column-gap: 4px;
48
+ margin-right: 6px;
49
+ &.hidden {
50
+ display: none;
51
+ }
52
+ }
53
+ .btn {
54
+ display: inline-block;
55
+ text-align: center;
56
+ text-transform: none;
57
+ text-decoration: none;
58
+ background: transparent;
59
+ border: 0;
60
+ outline: 0;
61
+ padding: 6px;
62
+ color: #fff;
63
+ font-size: 16px;
64
+ line-height: 0;
65
+ border-radius: 4px;
66
+ transition: all 0.3s ease;
67
+ cursor: pointer;
68
+ &:hover,
69
+ &.ant-dropdown-open {
70
+ background: rgba(180, 180, 180, 0.45);
71
+ }
72
+ &-fold {
73
+ padding: 8px 0;
74
+ font-size: @--font-size-sm;
75
+ background: rgba(180, 180, 180, 0.45);
76
+ }
77
+ }
78
+ .divider {
79
+ width: 0;
80
+ height: 18px;
81
+ border-left: 1px solid #a2a2a2;
82
+ }
83
+ }
84
+ }
85
+ &__text-input {
86
+ min-width: 5px;
87
+ min-height: 20px;
88
+ position: absolute;
89
+ outline: none;
90
+ border: none;
91
+ background: transparent;
92
+ font-weight: bold;
93
+ font-family: none;
94
+ border: 1px dashed #505050;
95
+ top: 0;
96
+ left: 0;
97
+ z-index: 9999;
98
+ display: none;
99
+ &.show {
100
+ display: block;
101
+ }
102
+ }
103
+ }
104
+
105
+ &__popper {
106
+ .content {
107
+ display: flex;
108
+ align-items: center;
109
+ padding: 8px 10px;
110
+ .lineWidth {
111
+ display: inline-flex;
112
+ align-items: center;
113
+ column-gap: 8px;
114
+ .dot {
115
+ border-radius: 50%;
116
+ width: 14px;
117
+ height: 14px;
118
+ background-color: #b9b9b9;
119
+ cursor: pointer;
120
+ &.active {
121
+ background: @--primary-color;
122
+ }
123
+ &.s2 {
124
+ width: 10px;
125
+ height: 10px;
126
+ }
127
+ &.s6 {
128
+ width: 16px;
129
+ height: 16px;
130
+ }
131
+ }
132
+ }
133
+ .divider {
134
+ width: 0;
135
+ height: 20px;
136
+ margin: 0 12px;
137
+ border-left: 1px solid @--border-color-base;
138
+ }
139
+ .penColor {
140
+ display: inline-flex;
141
+ align-items: center;
142
+ column-gap: 8px;
143
+ .dot {
144
+ display: inline-flex;
145
+ align-items: center;
146
+ justify-content: center;
147
+ width: 20px;
148
+ height: 20px;
149
+ border-radius: 4px;
150
+ cursor: pointer;
151
+ .icon {
152
+ font-size: @--font-size-sm;
153
+ color: #fff;
154
+ display: none;
155
+ }
156
+ &.active {
157
+ .icon {
158
+ display: block;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
@@ -2,7 +2,7 @@
2
2
  * @Author: 焦质晔
3
3
  * @Date: 2021-07-23 18:23:59
4
4
  * @Last Modified by: 焦质晔
5
- * @Last Modified time: 2024-02-28 21:23:42
5
+ * @Last Modified time: 2024-05-10 15:53:22
6
6
  */
7
7
  /*
8
8
  * @Author: 焦质晔
@@ -30585,3 +30585,160 @@ table {
30585
30585
  .qm-lazy-load .placeholder {
30586
30586
  min-height: 200px;
30587
30587
  }
30588
+ /*
30589
+ * @Author: 焦质晔
30590
+ * @Date: 2024-05-11 10:14:22
30591
+ * @Last Modified by: 焦质晔
30592
+ * @Last Modified time: 2024-05-12 19:31:51
30593
+ */
30594
+ .qm-signature.is-annotation {
30595
+ position: relative;
30596
+ }
30597
+ .qm-signature.is-annotation .signature {
30598
+ position: absolute;
30599
+ left: 0;
30600
+ top: 0;
30601
+ width: 100%;
30602
+ height: 100%;
30603
+ z-index: 9;
30604
+ display: none;
30605
+ }
30606
+ .qm-signature.is-annotation .signature.show {
30607
+ display: flex;
30608
+ }
30609
+ .qm-signature .signature {
30610
+ display: flex;
30611
+ flex-direction: column;
30612
+ position: relative;
30613
+ }
30614
+ .qm-signature .signature__tool-bar {
30615
+ position: sticky;
30616
+ bottom: 0;
30617
+ margin-top: 4px;
30618
+ pointer-events: none;
30619
+ }
30620
+ .qm-signature .signature__tool-bar .wrapper {
30621
+ display: flex;
30622
+ float: right;
30623
+ padding: 4px;
30624
+ border-radius: 6px;
30625
+ background-color: #212c33;
30626
+ pointer-events: auto;
30627
+ }
30628
+ .qm-signature .signature__tool-bar .wrapper .actions {
30629
+ display: inherit;
30630
+ flex-direction: row;
30631
+ align-items: center;
30632
+ -moz-column-gap: 4px;
30633
+ column-gap: 4px;
30634
+ margin-right: 6px;
30635
+ }
30636
+ .qm-signature .signature__tool-bar .wrapper .actions.hidden {
30637
+ display: none;
30638
+ }
30639
+ .qm-signature .signature__tool-bar .wrapper .btn {
30640
+ display: inline-block;
30641
+ text-align: center;
30642
+ text-transform: none;
30643
+ text-decoration: none;
30644
+ background: transparent;
30645
+ border: 0;
30646
+ outline: 0;
30647
+ padding: 6px;
30648
+ color: #fff;
30649
+ font-size: 16px;
30650
+ line-height: 0;
30651
+ border-radius: 4px;
30652
+ transition: all 0.3s ease;
30653
+ cursor: pointer;
30654
+ }
30655
+ .qm-signature .signature__tool-bar .wrapper .btn:hover,
30656
+ .qm-signature .signature__tool-bar .wrapper .btn.ant-dropdown-open {
30657
+ background: rgba(180, 180, 180, 0.45);
30658
+ }
30659
+ .qm-signature .signature__tool-bar .wrapper .btn-fold {
30660
+ padding: 8px 0;
30661
+ font-size: 12px;
30662
+ background: rgba(180, 180, 180, 0.45);
30663
+ }
30664
+ .qm-signature .signature__tool-bar .wrapper .divider {
30665
+ width: 0;
30666
+ height: 18px;
30667
+ border-left: 1px solid #a2a2a2;
30668
+ }
30669
+ .qm-signature .signature__text-input {
30670
+ min-width: 5px;
30671
+ min-height: 20px;
30672
+ position: absolute;
30673
+ outline: none;
30674
+ border: none;
30675
+ background: transparent;
30676
+ font-weight: bold;
30677
+ font-family: none;
30678
+ border: 1px dashed #505050;
30679
+ top: 0;
30680
+ left: 0;
30681
+ z-index: 9999;
30682
+ display: none;
30683
+ }
30684
+ .qm-signature .signature__text-input.show {
30685
+ display: block;
30686
+ }
30687
+ .qm-signature__popper .content {
30688
+ display: flex;
30689
+ align-items: center;
30690
+ padding: 8px 10px;
30691
+ }
30692
+ .qm-signature__popper .content .lineWidth {
30693
+ display: inline-flex;
30694
+ align-items: center;
30695
+ -moz-column-gap: 8px;
30696
+ column-gap: 8px;
30697
+ }
30698
+ .qm-signature__popper .content .lineWidth .dot {
30699
+ border-radius: 50%;
30700
+ width: 14px;
30701
+ height: 14px;
30702
+ background-color: #b9b9b9;
30703
+ cursor: pointer;
30704
+ }
30705
+ .qm-signature__popper .content .lineWidth .dot.active {
30706
+ background: #1890ff;
30707
+ }
30708
+ .qm-signature__popper .content .lineWidth .dot.s2 {
30709
+ width: 10px;
30710
+ height: 10px;
30711
+ }
30712
+ .qm-signature__popper .content .lineWidth .dot.s6 {
30713
+ width: 16px;
30714
+ height: 16px;
30715
+ }
30716
+ .qm-signature__popper .content .divider {
30717
+ width: 0;
30718
+ height: 20px;
30719
+ margin: 0 12px;
30720
+ border-left: 1px solid #d9d9d9;
30721
+ }
30722
+ .qm-signature__popper .content .penColor {
30723
+ display: inline-flex;
30724
+ align-items: center;
30725
+ -moz-column-gap: 8px;
30726
+ column-gap: 8px;
30727
+ }
30728
+ .qm-signature__popper .content .penColor .dot {
30729
+ display: inline-flex;
30730
+ align-items: center;
30731
+ justify-content: center;
30732
+ width: 20px;
30733
+ height: 20px;
30734
+ border-radius: 4px;
30735
+ cursor: pointer;
30736
+ }
30737
+ .qm-signature__popper .content .penColor .dot .icon {
30738
+ font-size: 12px;
30739
+ color: #fff;
30740
+ display: none;
30741
+ }
30742
+ .qm-signature__popper .content .penColor .dot.active .icon {
30743
+ display: block;
30744
+ }
@@ -1,40 +1,41 @@
1
- /*
2
- * @Author: 焦质晔
3
- * @Date: 2021-07-23 18:23:59
4
- * @Last Modified by: 焦质晔
5
- * @Last Modified time: 2024-02-28 21:23:42
6
- */
7
- @import '../antd/index.less';
8
- @import './var.less';
9
- @import './reset.less';
10
-
11
- /* QmDesign */
12
- @import '../button/style/index.less';
13
- @import '../space/style/index.less';
14
- @import '../divider/style/index.less';
15
- @import '../split/style/index.less';
16
- @import '../countup/style/index.less';
17
- @import '../empty/style/index.less';
18
- @import '../spin/style/index.less';
19
- @import '../scrollbar/style/index.less';
20
- @import '../download/style/index.less';
21
- @import '../anchor/style/index.less';
22
- @import '../tabs/style/index.less';
23
- @import '../drawer/style/index.less';
24
- @import '../modal/style/index.less';
25
- @import '../form/style/index.less';
26
- @import '../tinymce/style/index.less';
27
- @import '../cropper/style/index.less';
28
- @import '../collapse/style/index.less';
29
- @import '../upload-file/style/index.less';
30
- @import '../upload-img/style/index.less';
31
- @import '../table/style/index.less';
32
- @import '../search-helper/style/index.less';
33
- @import '../tree-helper/style/index.less';
34
- @import '../tree-table-helper/style/index.less';
35
- @import '../range-table-helper/style/index.less';
36
- @import '../search-tree/style/index.less';
37
- @import '../tour/style/index.less';
38
- @import '../guide-tracker/style/index.less';
39
- @import '../print/style/index.less';
40
- @import '../lazy-load/style/index.less';
1
+ /*
2
+ * @Author: 焦质晔
3
+ * @Date: 2021-07-23 18:23:59
4
+ * @Last Modified by: 焦质晔
5
+ * @Last Modified time: 2024-05-10 15:53:22
6
+ */
7
+ @import '../antd/index.less';
8
+ @import './var.less';
9
+ @import './reset.less';
10
+
11
+ /* QmDesign */
12
+ @import '../button/style/index.less';
13
+ @import '../space/style/index.less';
14
+ @import '../divider/style/index.less';
15
+ @import '../split/style/index.less';
16
+ @import '../countup/style/index.less';
17
+ @import '../empty/style/index.less';
18
+ @import '../spin/style/index.less';
19
+ @import '../scrollbar/style/index.less';
20
+ @import '../download/style/index.less';
21
+ @import '../anchor/style/index.less';
22
+ @import '../tabs/style/index.less';
23
+ @import '../drawer/style/index.less';
24
+ @import '../modal/style/index.less';
25
+ @import '../form/style/index.less';
26
+ @import '../tinymce/style/index.less';
27
+ @import '../cropper/style/index.less';
28
+ @import '../collapse/style/index.less';
29
+ @import '../upload-file/style/index.less';
30
+ @import '../upload-img/style/index.less';
31
+ @import '../table/style/index.less';
32
+ @import '../search-helper/style/index.less';
33
+ @import '../tree-helper/style/index.less';
34
+ @import '../tree-table-helper/style/index.less';
35
+ @import '../range-table-helper/style/index.less';
36
+ @import '../search-tree/style/index.less';
37
+ @import '../tour/style/index.less';
38
+ @import '../guide-tracker/style/index.less';
39
+ @import '../print/style/index.less';
40
+ @import '../lazy-load/style/index.less';
41
+ @import '../signature/style/index.less';