@kdcloudjs/kdesign 1.7.59 → 1.7.60

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +3 -12
  2. package/dist/kdesign-complete.less +126 -1
  3. package/dist/kdesign.css +212 -1
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +2118 -83
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +2 -2
  8. package/dist/kdesign.min.js +16 -12
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/domUtil.d.ts +2 -0
  11. package/es/_utils/domUtil.js +15 -0
  12. package/es/cascader/cascader.js +41 -10
  13. package/es/config-provider/compDefaultProps.d.ts +7 -0
  14. package/es/config-provider/compDefaultProps.js +7 -0
  15. package/es/date-picker/date-picker.js +19 -17
  16. package/es/date-picker/hooks/use-range-view-dates.js +8 -2
  17. package/es/date-picker/range-picker.js +4 -1
  18. package/es/index.d.ts +1 -0
  19. package/es/index.js +2 -1
  20. package/es/locale/locale.d.ts +5 -0
  21. package/es/locale/zh-CN.d.ts +5 -0
  22. package/es/locale/zh-CN.js +6 -1
  23. package/es/signature/drawingBoard.d.ts +15 -0
  24. package/es/signature/drawingBoard.js +163 -0
  25. package/es/signature/index.d.ts +3 -0
  26. package/es/signature/index.js +3 -0
  27. package/es/signature/signature.d.ts +32 -0
  28. package/es/signature/signature.js +268 -0
  29. package/es/signature/style/css.js +2 -0
  30. package/es/signature/style/index.css +210 -0
  31. package/es/signature/style/index.d.ts +2 -0
  32. package/es/signature/style/index.js +2 -0
  33. package/es/signature/style/index.less +95 -0
  34. package/es/signature/style/mixin.less +6 -0
  35. package/es/signature/style/token.less +22 -0
  36. package/es/signature/utils/signature_pad.d.ts +106 -0
  37. package/es/signature/utils/signature_pad.js +690 -0
  38. package/es/style/themes/default.less +1 -1
  39. package/lib/_utils/domUtil.d.ts +2 -0
  40. package/lib/_utils/domUtil.js +23 -0
  41. package/lib/cascader/cascader.js +41 -10
  42. package/lib/config-provider/compDefaultProps.d.ts +7 -0
  43. package/lib/config-provider/compDefaultProps.js +7 -0
  44. package/lib/date-picker/date-picker.js +18 -16
  45. package/lib/date-picker/hooks/use-range-view-dates.js +7 -1
  46. package/lib/date-picker/range-picker.js +4 -1
  47. package/lib/index.d.ts +1 -0
  48. package/lib/index.js +7 -0
  49. package/lib/locale/locale.d.ts +5 -0
  50. package/lib/locale/zh-CN.d.ts +5 -0
  51. package/lib/locale/zh-CN.js +6 -1
  52. package/lib/signature/drawingBoard.d.ts +15 -0
  53. package/lib/signature/drawingBoard.js +176 -0
  54. package/lib/signature/index.d.ts +3 -0
  55. package/lib/signature/index.js +27 -0
  56. package/lib/signature/signature.d.ts +32 -0
  57. package/lib/signature/signature.js +282 -0
  58. package/lib/signature/style/css.js +4 -0
  59. package/lib/signature/style/index.css +210 -0
  60. package/lib/signature/style/index.d.ts +2 -0
  61. package/lib/signature/style/index.js +4 -0
  62. package/lib/signature/style/index.less +95 -0
  63. package/lib/signature/style/mixin.less +6 -0
  64. package/lib/signature/style/token.less +22 -0
  65. package/lib/signature/utils/signature_pad.d.ts +106 -0
  66. package/lib/signature/utils/signature_pad.js +697 -0
  67. package/lib/style/components.less +1 -0
  68. package/lib/style/themes/default.less +1 -1
  69. package/package.json +3 -2
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const scrollToDirectory: (ref: React.MutableRefObject<any>) => void;
@@ -0,0 +1,15 @@
1
+ import scrollIntoView from 'dom-scroll-into-view';
2
+ export var scrollToDirectory = function scrollToDirectory(ref) {
3
+ var directoryElement = ref.current;
4
+ if (directoryElement) {
5
+ var rect = ref.current.getBoundingClientRect();
6
+ var parent = ref.current.parentElement;
7
+ var parentRect = parent.getBoundingClientRect();
8
+ var relativeTop = rect.top - parentRect.top;
9
+ var relativeBottom = rect.bottom - parentRect.top;
10
+ var isHide = relativeTop < 0 || relativeBottom > parent.clientHeight;
11
+ if (isHide) {
12
+ scrollIntoView(ref.current, ref.current.parentElement);
13
+ }
14
+ }
15
+ };
@@ -1,7 +1,7 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/extends";
2
1
  import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
4
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
4
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
5
5
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
6
6
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
7
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
@@ -22,6 +22,7 @@ import { tuple } from '../_utils/type';
22
22
  import { getCompProps } from '../_utils';
23
23
  import { ConfigContext } from '../config-provider';
24
24
  import usePopper from '../_utils/usePopper';
25
+ import { scrollToDirectory } from '../_utils/domUtil';
25
26
  import Input from '../input';
26
27
  import Icon from '../icon';
27
28
  import Empty from '../empty';
@@ -29,6 +30,28 @@ import Checkbox from '../checkbox';
29
30
  import Tag from '../tag';
30
31
  import { flattenAll, useChecked, getHalfChecked, getChecked, getMultipleCheckValue, getAllCheckedKeys } from './util';
31
32
  export var CascaderPlacement = tuple('topLeft', 'topRight', 'bottomLeft', 'bottomRight');
33
+ var CascaderMenuSubmenu = function CascaderMenuSubmenu(props) {
34
+ var optionProps = props.optionProps,
35
+ label = props.label,
36
+ children = props.children,
37
+ selected = props.selected,
38
+ isMultiple = props.isMultiple;
39
+ var ref = useRef(null);
40
+ var isFirst = useRef(!isMultiple);
41
+ useEffect(function () {
42
+ if (typeof selected === 'boolean' && isFirst.current && ref.current) {
43
+ isFirst.current = false;
44
+ if (selected && !isMultiple) {
45
+ scrollToDirectory(ref);
46
+ }
47
+ }
48
+ }, [selected]);
49
+ return /*#__PURE__*/React.createElement("li", _extends({
50
+ ref: ref
51
+ }, optionProps, {
52
+ title: label
53
+ }), children);
54
+ };
32
55
  var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
33
56
  var _React$useContext = React.useContext(ConfigContext),
34
57
  getPrefixCls = _React$useContext.getPrefixCls,
@@ -72,13 +95,18 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
72
95
  var inputRef = useRef();
73
96
  var suffixRef = useRef(null);
74
97
  var wrapperRef = useRef();
75
- var _useState = useState(!!props.popperVisible || !!props.popupVisible || defaultPopupVisible),
98
+ var _useState = useState(false),
76
99
  _useState2 = _slicedToArray(_useState, 2),
77
100
  visible = _useState2[0],
78
101
  setVisible = _useState2[1];
79
102
  React.useEffect(function () {
80
103
  setVisible(!!props.popperVisible || !!props.popupVisible);
81
104
  }, [props.popperVisible, props.popupVisible]);
105
+ React.useEffect(function () {
106
+ if (!!props.popperVisible || !!props.popupVisible || defaultPopupVisible) {
107
+ setVisible(true);
108
+ }
109
+ }, []);
82
110
  var _useState3 = useState([options]),
83
111
  _useState4 = _slicedToArray(_useState3, 2),
84
112
  menus = _useState4[0],
@@ -399,11 +427,11 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
399
427
  }
400
428
  props.onChange && props.onChange(selectedValue, selectedOptions);
401
429
  };
402
- var onVisibleChange = function onVisibleChange(visible) {
403
- setVisible(visible);
404
- onPopupVisibleChange && onPopupVisibleChange(visible);
405
- onPopperVisibleChange && onPopperVisibleChange(visible);
406
- visible && setSelectedOptions(_sliceInstanceProperty(currentOptions).call(currentOptions, 0));
430
+ var onVisibleChange = function onVisibleChange(v) {
431
+ setVisible(v);
432
+ onPopupVisibleChange && onPopupVisibleChange(v);
433
+ onPopperVisibleChange && onPopperVisibleChange(v);
434
+ v && setSelectedOptions(_sliceInstanceProperty(currentOptions).call(currentOptions, 0));
407
435
  };
408
436
  var cascaderMenus = /*#__PURE__*/React.createElement(React.Fragment, null, (options === null || options === void 0 ? void 0 : options.length) ? (menus === null || menus === void 0 ? void 0 : menus.length) && _mapInstanceProperty(menus).call(menus, function (opts, index) {
409
437
  return /*#__PURE__*/React.createElement("ul", {
@@ -436,10 +464,13 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
436
464
  }) : ((children === null || children === void 0 ? void 0 : children.length) || isLeaf === false) && (props.expandIcon || /*#__PURE__*/React.createElement(Icon, {
437
465
  type: "arrow-right"
438
466
  })));
439
- return /*#__PURE__*/React.createElement("li", _extends({
467
+ return /*#__PURE__*/React.createElement(CascaderMenuSubmenu, _extends({
440
468
  key: value
441
- }, optionProps, {
442
- title: label
469
+ }, {
470
+ isMultiple: isMultiple,
471
+ optionProps: optionProps,
472
+ label: label,
473
+ selected: selected
443
474
  }), isMultiple ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
444
475
  checked: getChecked(checkedKeys, value),
445
476
  indeterminate: getHalfChecked(halfCheckedKeys, value),
@@ -488,5 +488,12 @@ declare const compDefaultProps: {
488
488
  errorLevel: string;
489
489
  color: string;
490
490
  };
491
+ Signature: {
492
+ penColor: string;
493
+ backgroundColor: string;
494
+ containerWidth: number;
495
+ containerHeight: number;
496
+ canFullScreen: boolean;
497
+ };
491
498
  };
492
499
  export default compDefaultProps;
@@ -505,6 +505,13 @@ var compDefaultProps = {
505
505
  type: 'canvas',
506
506
  errorLevel: 'H',
507
507
  color: '#000000'
508
+ },
509
+ Signature: {
510
+ penColor: 'black',
511
+ backgroundColor: 'white',
512
+ containerWidth: 610,
513
+ containerHeight: 500,
514
+ canFullScreen: true
508
515
  }
509
516
  };
510
517
  export default compDefaultProps;
@@ -12,7 +12,7 @@ import InputDate from './single/input-date';
12
12
  import { getDefaultFormat, getDataOrAriaProps, getInternalNextMode, generateUnits } from './utils';
13
13
  import useValueTexts from './hooks/use-value-texts';
14
14
  import useHoverValue from './hooks/use-hover-value';
15
- import { formatDate, getHours, getLowerBoundTime, getMinutes, getSeconds, isEqual, isValid, newDate, parseDate, setTime, isDate } from './utils/date-fns';
15
+ import { formatDate, getHours, getLowerBoundTime, getMinutes, getSeconds, isEqual, isValid, newDate, parseDate, setTime } from './utils/date-fns';
16
16
  import useTextValueMapping from './hooks/use-text-value-mapping';
17
17
  import getExtraFooter from './utils/get-extra-footer';
18
18
  import getRanges from './utils/get-ranges';
@@ -102,10 +102,15 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
102
102
  _useMergedState2 = _slicedToArray(_useMergedState, 2),
103
103
  dateValue = _useMergedState2[0],
104
104
  setDateValue = _useMergedState2[1];
105
- var _React$useState = React.useState(dateValue),
106
- _React$useState2 = _slicedToArray(_React$useState, 2),
107
- selectedValue = _React$useState2[0],
108
- setSelectedValue = _React$useState2[1];
105
+ var _useMergedState3 = useMergedState(null, {
106
+ value: dateValue,
107
+ postState: function postState(v) {
108
+ return v && !isValid(v) ? null : v;
109
+ }
110
+ }),
111
+ _useMergedState4 = _slicedToArray(_useMergedState3, 2),
112
+ selectedValue = _useMergedState4[0],
113
+ setSelectedValue = _useMergedState4[1];
109
114
  var hours;
110
115
  var minutes;
111
116
  var seconds;
@@ -136,7 +141,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
136
141
  viewDate = _useState2[0],
137
142
  setInnerViewDate = _useState2[1];
138
143
  var setViewDate = function setViewDate(date) {
139
- setInnerViewDate(isDate(date) ? date : new Date());
144
+ setInnerViewDate(isValid(date) ? date : new Date());
140
145
  };
141
146
  useEffect(function () {
142
147
  setViewDate(dateValue);
@@ -175,7 +180,7 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
175
180
  hoverValue = _useHoverValue2[0],
176
181
  onEnter = _useHoverValue2[1],
177
182
  onLeave = _useHoverValue2[2];
178
- var _useMergedState3 = useMergedState(false, {
183
+ var _useMergedState5 = useMergedState(false, {
179
184
  value: open,
180
185
  defaultValue: defaultOpen,
181
186
  postState: function postState(postOpen) {
@@ -190,10 +195,10 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
190
195
  // }
191
196
  }
192
197
  }),
193
- _useMergedState4 = _slicedToArray(_useMergedState3, 2),
194
- openValue = _useMergedState4[0],
195
- triggerInnerOpen = _useMergedState4[1];
196
- var _useMergedState5 = useMergedState(function () {
198
+ _useMergedState6 = _slicedToArray(_useMergedState5, 2),
199
+ openValue = _useMergedState6[0],
200
+ triggerInnerOpen = _useMergedState6[1];
201
+ var _useMergedState7 = useMergedState(function () {
197
202
  if (picker === 'time') {
198
203
  return 'time';
199
204
  }
@@ -201,9 +206,9 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
201
206
  }, {
202
207
  value: mode
203
208
  }),
204
- _useMergedState6 = _slicedToArray(_useMergedState5, 2),
205
- mergedMode = _useMergedState6[0],
206
- setInnerMode = _useMergedState6[1];
209
+ _useMergedState8 = _slicedToArray(_useMergedState7, 2),
210
+ mergedMode = _useMergedState8[0],
211
+ setInnerMode = _useMergedState8[1];
207
212
  var _useState3 = useState(undefined),
208
213
  _useState4 = _slicedToArray(_useState3, 2),
209
214
  innerPicker = _useState4[0],
@@ -231,9 +236,6 @@ var InternalDatePicker = function InternalDatePicker(props, ref) {
231
236
  }
232
237
  // eslint-disable-next-line react-hooks/exhaustive-deps
233
238
  }, [picker]);
234
- useEffect(function () {
235
- setSelectedValue(dateValue);
236
- }, [dateValue]);
237
239
  useOnClickOutside([popperRef, inputDivRef], function () {
238
240
  setViewDate(selectedValue || newDate());
239
241
  triggerOpen(false);
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
2
  import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
3
3
  import * as React from 'react';
4
4
  import { getValue, updateValues, getClosingViewDate } from '../utils';
5
- import { newDate, isSameYear, isSameMonth } from '../utils/date-fns';
5
+ import { newDate, isSameYear, isSameMonth, isValid } from '../utils/date-fns';
6
6
  // import { getClosingViewDate, isSameYear, isSameMonth, isSameDecade } from '../utils/dateUtil'
7
7
  function getStartEndDistance(startDate, endDate, picker) {
8
8
  var startNext = getClosingViewDate(startDate, picker, 1);
@@ -48,6 +48,12 @@ function getRangeViewDate(values, index, picker) {
48
48
  }
49
49
  return startDate;
50
50
  }
51
+ function checkViewDate(value) {
52
+ if (value && !isValid(value)) {
53
+ return false;
54
+ }
55
+ return value;
56
+ }
51
57
  export default function useRangeViewDates(_ref) {
52
58
  var values = _valuesInstanceProperty(_ref),
53
59
  picker = _ref.picker,
@@ -68,7 +74,7 @@ export default function useRangeViewDates(_ref) {
68
74
  if (defaultViewDates[index]) {
69
75
  return defaultViewDates[index];
70
76
  }
71
- return getValue(viewDates, index) || getRangeViewDate(values, index, picker) || startDate || endDate || newDate();
77
+ return checkViewDate(getValue(viewDates, index)) || checkViewDate(getRangeViewDate(values, index, picker)) || checkViewDate(startDate) || checkViewDate(endDate) || newDate();
72
78
  }
73
79
  function setViewDate(viewDate, index) {
74
80
  if (viewDate) {
@@ -152,8 +152,11 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
152
152
  }
153
153
  // Fill disabled unit
154
154
  for (var i = 0; i < 2; i++) {
155
- if (mergedDisabled[i] && !getValue(postValues, i) && !getValue(allowEmpty, i)) {
155
+ var v = getValue(postValues, i);
156
+ if (mergedDisabled[i] && !v && !getValue(allowEmpty, i)) {
156
157
  postValues = updateValues(postValues, newDate(), i);
158
+ } else if (v && !isValid(v)) {
159
+ postValues = updateValues(postValues, null, i);
157
160
  }
158
161
  }
159
162
  return postValues;
package/es/index.d.ts CHANGED
@@ -59,3 +59,4 @@ export { default as ColorPicker } from './color-picker';
59
59
  export { default as Clipboard } from './clipboard';
60
60
  export { default as QRCode } from './qr-code';
61
61
  export { default as Divider } from './divider';
62
+ export { default as Signature } from './signature';
package/es/index.js CHANGED
@@ -58,4 +58,5 @@ export { default as TreeSelect } from './tree-select';
58
58
  export { default as ColorPicker } from './color-picker';
59
59
  export { default as Clipboard } from './clipboard';
60
60
  export { default as QRCode } from './qr-code';
61
- export { default as Divider } from './divider';
61
+ export { default as Divider } from './divider';
62
+ export { default as Signature } from './signature';
@@ -100,6 +100,11 @@ declare class LocaleCache {
100
100
  'Table.confirmFilter': string;
101
101
  'Select.selectAll': string;
102
102
  'Select.seleted': string;
103
+ 'Signature.clickToSign': string;
104
+ 'Signature.pleaseWriteHere': string;
105
+ 'Signature.okText': string;
106
+ 'Signature.cancelText': string;
107
+ 'Signature.handwrittenSignature': string;
103
108
  'DatePicker.placeholder': string;
104
109
  'DatePicker.yearPlaceholder': string;
105
110
  'DatePicker.quarterPlaceholder': string;
@@ -74,6 +74,11 @@ declare const locale: {
74
74
  'Table.confirmFilter': string;
75
75
  'Select.selectAll': string;
76
76
  'Select.seleted': string;
77
+ 'Signature.clickToSign': string;
78
+ 'Signature.pleaseWriteHere': string;
79
+ 'Signature.okText': string;
80
+ 'Signature.cancelText': string;
81
+ 'Signature.handwrittenSignature': string;
77
82
  'DatePicker.placeholder': string;
78
83
  'DatePicker.yearPlaceholder': string;
79
84
  'DatePicker.quarterPlaceholder': string;
@@ -77,6 +77,11 @@ var locale = _extends(_extends({
77
77
  'Table.resetFilter': '重置',
78
78
  'Table.confirmFilter': '确定',
79
79
  'Select.selectAll': '全选',
80
- 'Select.seleted': '已选{size}项'
80
+ 'Select.seleted': '已选{size}项',
81
+ 'Signature.clickToSign': '点击签名',
82
+ 'Signature.pleaseWriteHere': '请在此处横向书写签名',
83
+ 'Signature.okText': '确定',
84
+ 'Signature.cancelText': '取消',
85
+ 'Signature.handwrittenSignature': '手写签名'
81
86
  });
82
87
  export default locale;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import SignaturePad from './utils/signature_pad';
3
+ export interface DrawingBoardProps {
4
+ prefixCls: string;
5
+ signatureLangMsg: any;
6
+ isEmpty: boolean;
7
+ setDataUrl: (dataUrl: string) => void;
8
+ setIsEmpty: (value: boolean) => void;
9
+ signaturePad: () => SignaturePad | null | undefined;
10
+ undo?: () => void;
11
+ redo?: () => void;
12
+ onClear?: () => void;
13
+ }
14
+ declare const DrawingBoard: React.ForwardRefExoticComponent<DrawingBoardProps & React.RefAttributes<unknown>>;
15
+ export default DrawingBoard;
@@ -0,0 +1,163 @@
1
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
4
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
5
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
+ import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
7
+ import Icon from '../icon';
8
+ import classNames from 'classnames';
9
+ var DrawingBoard = /*#__PURE__*/forwardRef(function (props, ref) {
10
+ var _classNames;
11
+ var prefixCls = props.prefixCls,
12
+ isEmpty = props.isEmpty,
13
+ setIsEmpty = props.setIsEmpty,
14
+ onClear = props.onClear,
15
+ signaturePad = props.signaturePad,
16
+ undo = props.undo,
17
+ redo = props.redo,
18
+ signatureLangMsg = props.signatureLangMsg;
19
+ var _useState = useState(-1),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ currentHistoryIndex = _useState2[0],
22
+ setCurrentHistoryIndex = _useState2[1];
23
+ var _useState3 = useState([]),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ signatureHistory = _useState4[0],
26
+ setSignatureHistory = _useState4[1];
27
+ var canvasRef = useRef();
28
+ var canvasWrapperRef = useRef();
29
+ var handleOnClear = function handleOnClear() {
30
+ var _a;
31
+ (_a = signaturePad()) === null || _a === void 0 ? void 0 : _a.clear();
32
+ setIsEmpty(true);
33
+ setSignatureHistory(_sliceInstanceProperty(signatureHistory).call(signatureHistory, 0, 1));
34
+ setCurrentHistoryIndex(0);
35
+ onClear && onClear();
36
+ };
37
+ var saveSignatureToHistory = function saveSignatureToHistory() {
38
+ var _a;
39
+ if (signaturePad()) {
40
+ var data = (_a = signaturePad()) === null || _a === void 0 ? void 0 : _a.toDataURL();
41
+ if (data !== undefined) setSignatureHistory(function (prevHistory) {
42
+ var _context;
43
+ return _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(prevHistory), [{
44
+ data: data
45
+ }]);
46
+ });
47
+ setCurrentHistoryIndex(function (prevIndex) {
48
+ return prevIndex + 1;
49
+ });
50
+ }
51
+ };
52
+ var handleUndo = function handleUndo() {
53
+ var _a, _b;
54
+ if (currentHistoryIndex > 0) {
55
+ setCurrentHistoryIndex(function (prevIndex) {
56
+ return prevIndex - 1;
57
+ });
58
+ var historyItem = signatureHistory[currentHistoryIndex - 1];
59
+ if (signaturePad() && historyItem) {
60
+ (_a = signaturePad()) === null || _a === void 0 ? void 0 : _a.clear();
61
+ (_b = signaturePad()) === null || _b === void 0 ? void 0 : _b.fromDataURL(historyItem.data, {
62
+ ratio: 1
63
+ });
64
+ undo && undo();
65
+ }
66
+ }
67
+ };
68
+ var handleRedo = function handleRedo() {
69
+ var _a;
70
+ if (currentHistoryIndex < signatureHistory.length - 1) {
71
+ setCurrentHistoryIndex(function (prevIndex) {
72
+ return prevIndex + 1;
73
+ });
74
+ var historyItem = signatureHistory[currentHistoryIndex + 1];
75
+ if (signaturePad() && historyItem) {
76
+ (_a = signaturePad()) === null || _a === void 0 ? void 0 : _a.fromDataURL(historyItem.data, {
77
+ ratio: 1
78
+ });
79
+ redo && redo();
80
+ }
81
+ }
82
+ };
83
+ useEffect(function () {
84
+ currentHistoryIndex > 0 ? setIsEmpty(false) : setIsEmpty(true);
85
+ }, [currentHistoryIndex]);
86
+ useImperativeHandle(ref, function () {
87
+ return {
88
+ getCanvasRef: function getCanvasRef() {
89
+ return canvasRef.current;
90
+ },
91
+ getCanvasWrapperRef: function getCanvasWrapperRef() {
92
+ return canvasWrapperRef.current;
93
+ },
94
+ saveSignatureToHistory: saveSignatureToHistory,
95
+ signatureHistory: signatureHistory,
96
+ setSignatureHistory: setSignatureHistory,
97
+ setCurrentHistoryIndex: setCurrentHistoryIndex
98
+ };
99
+ });
100
+ return /*#__PURE__*/React.createElement("div", {
101
+ className: "".concat(prefixCls, "-drawing-board"),
102
+ ref: canvasWrapperRef
103
+ }, /*#__PURE__*/React.createElement("div", {
104
+ className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-drawing-board-operation"), true), _defineProperty(_classNames, "enabled", !isEmpty), _classNames))
105
+ }, undo ? /*#__PURE__*/React.createElement("span", {
106
+ onClick: function onClick() {
107
+ return handleUndo();
108
+ }
109
+ }, /*#__PURE__*/React.createElement("svg", {
110
+ width: "1em",
111
+ height: "1em",
112
+ viewBox: "0 0 32 32"
113
+ }, /*#__PURE__*/React.createElement("g", {
114
+ id: "1016.\u64A4\u9500",
115
+ stroke: "none",
116
+ "stroke-width": "1",
117
+ fill: "none",
118
+ "fill-rule": "evenodd"
119
+ }, /*#__PURE__*/React.createElement("g", {
120
+ id: "\u7F16\u7EC4",
121
+ transform: "translate(2.000000, 1.000000)",
122
+ fill: "#000000",
123
+ "fill-rule": "nonzero"
124
+ }, /*#__PURE__*/React.createElement("path", {
125
+ d: "M9.16767025,16.9762781 C9.5300869,17.3386948 9.5300869,17.9262881 9.16767025,18.2887049 C8.84552213,18.6108529 8.34545651,18.6466472 7.98377112,18.3960875 L7.85524348,18.2887049 L0.815437446,11.2488988 C-0.203859357,10.229602 -0.267565411,8.61657722 0.624319283,7.52306442 L0.815437446,7.31161852 L7.85524348,0.271812484 C8.21766013,-0.0906041612 8.80525361,-0.0906041612 9.16767025,0.271812484 C9.48981838,0.593960608 9.5256126,1.09402626 9.27505297,1.45571158 L9.16767025,1.58423925 L2.39801882,8.35223283 L18.7197413,8.35223283 C24.8235066,8.35223283 28,11.88167 28,18.5605173 C28,25.0286774 25.0409921,28.8154573 19.1996764,29.6367412 L18.7197413,29.6968277 L3.87132753,29.6968277 C3.358793,29.6968277 2.94330165,29.2813365 2.94330165,28.7688019 C2.94330165,28.3132156 3.27159111,27.9343054 3.70451369,27.8557278 L3.87132753,27.840776 L18.6172581,27.846452 C23.6969089,27.2820464 26.1439483,24.2912204 26.1439483,18.5605173 C26.1439483,13.0283959 23.8870007,10.3626156 19.1446408,10.2148013 L18.7197413,10.2082845 L2.39987488,10.2082845 L9.16767025,16.9762781 Z",
126
+ id: "\u8DEF\u5F84",
127
+ fill: "currentColor"
128
+ }))))) : null, redo ? /*#__PURE__*/React.createElement("span", {
129
+ onClick: function onClick() {
130
+ return handleRedo();
131
+ }
132
+ }, /*#__PURE__*/React.createElement("svg", {
133
+ width: "1em",
134
+ height: "1em",
135
+ viewBox: "0 0 32 32"
136
+ }, /*#__PURE__*/React.createElement("g", {
137
+ id: "1016.\u64A4\u9500",
138
+ stroke: "none",
139
+ "stroke-width": "1",
140
+ fill: "none",
141
+ "fill-rule": "evenodd"
142
+ }, /*#__PURE__*/React.createElement("g", {
143
+ id: "\u7F16\u7EC4",
144
+ transform: "translate(2.000000, 1.000000)",
145
+ fill: "#000000",
146
+ "fill-rule": "nonzero"
147
+ }, /*#__PURE__*/React.createElement("path", {
148
+ d: "M9.16767025,16.9762781 C9.5300869,17.3386948 9.5300869,17.9262881 9.16767025,18.2887049 C8.84552213,18.6108529 8.34545651,18.6466472 7.98377112,18.3960875 L7.85524348,18.2887049 L0.815437446,11.2488988 C-0.203859357,10.229602 -0.267565411,8.61657722 0.624319283,7.52306442 L0.815437446,7.31161852 L7.85524348,0.271812484 C8.21766013,-0.0906041612 8.80525361,-0.0906041612 9.16767025,0.271812484 C9.48981838,0.593960608 9.5256126,1.09402626 9.27505297,1.45571158 L9.16767025,1.58423925 L2.39801882,8.35223283 L18.7197413,8.35223283 C24.8235066,8.35223283 28,11.88167 28,18.5605173 C28,25.0286774 25.0409921,28.8154573 19.1996764,29.6367412 L18.7197413,29.6968277 L3.87132753,29.6968277 C3.358793,29.6968277 2.94330165,29.2813365 2.94330165,28.7688019 C2.94330165,28.3132156 3.27159111,27.9343054 3.70451369,27.8557278 L3.87132753,27.840776 L18.6172581,27.846452 C23.6969089,27.2820464 26.1439483,24.2912204 26.1439483,18.5605173 C26.1439483,13.0283959 23.8870007,10.3626156 19.1446408,10.2148013 L18.7197413,10.2082845 L2.39987488,10.2082845 L9.16767025,16.9762781 Z",
149
+ id: "\u8DEF\u5F84",
150
+ fill: "currentColor"
151
+ }))))) : null, onClear ? /*#__PURE__*/React.createElement(Icon, {
152
+ type: "delete",
153
+ className: "".concat(prefixCls, "-drawing-board-clear"),
154
+ onClick: function onClick() {
155
+ return handleOnClear();
156
+ }
157
+ }) : null), /*#__PURE__*/React.createElement("span", {
158
+ className: "".concat(prefixCls, "-drawing-board-tip")
159
+ }, isEmpty ? signatureLangMsg === null || signatureLangMsg === void 0 ? void 0 : signatureLangMsg.pleaseWriteHere : ''), /*#__PURE__*/React.createElement("canvas", {
160
+ ref: canvasRef
161
+ }));
162
+ });
163
+ export default DrawingBoard;
@@ -0,0 +1,3 @@
1
+ import Signature from './signature';
2
+ export * from './signature';
3
+ export default Signature;
@@ -0,0 +1,3 @@
1
+ import Signature from './signature';
2
+ export * from './signature';
3
+ export default Signature;
@@ -0,0 +1,32 @@
1
+ import React, { FunctionComponentElement } from 'react';
2
+ export declare const DataUrlTypes: ["png", "jpeg", "svg"];
3
+ export declare type DataUrlType = typeof DataUrlTypes[number];
4
+ declare type CSSSelector = string;
5
+ export interface ISignatureProps {
6
+ dataUrlType?: DataUrlType;
7
+ style?: Record<string, unknown>;
8
+ className?: string;
9
+ prefixCls?: string;
10
+ disabled?: boolean;
11
+ containerWidth?: number;
12
+ containerHeight?: number;
13
+ penColor?: string;
14
+ backgroundColor?: string;
15
+ children?: React.ReactNode;
16
+ title?: React.ReactNode;
17
+ preview?: boolean;
18
+ canFullScreen?: boolean;
19
+ getContainer?: HTMLElement | (() => HTMLElement | CSSSelector | null | false) | null | false;
20
+ undo?: () => void;
21
+ redo?: () => void;
22
+ onClear?: () => void;
23
+ onStart?: () => void;
24
+ onEnd?: () => void;
25
+ getSignatureData?: (dataUrl: string) => void;
26
+ onClose?: () => void;
27
+ }
28
+ declare const Signature: {
29
+ (props: ISignatureProps): FunctionComponentElement<ISignatureProps>;
30
+ displayName: string;
31
+ };
32
+ export default Signature;