@kdcloudjs/kdesign 1.7.58 → 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.
- package/CHANGELOG.md +22 -0
- package/dist/kdesign-complete.less +126 -1
- package/dist/kdesign.css +212 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +2217 -181
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +2 -2
- package/dist/kdesign.min.js +16 -12
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/domUtil.d.ts +2 -0
- package/es/_utils/domUtil.js +15 -0
- package/es/cascader/cascader.js +41 -10
- package/es/config-provider/compDefaultProps.d.ts +7 -0
- package/es/config-provider/compDefaultProps.js +7 -0
- package/es/date-picker/date-picker.js +19 -17
- package/es/date-picker/hooks/use-range-view-dates.js +8 -2
- package/es/date-picker/panel/time/time.js +18 -3
- package/es/date-picker/range-picker.js +18 -28
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/locale/locale.d.ts +5 -0
- package/es/locale/zh-CN.d.ts +5 -0
- package/es/locale/zh-CN.js +6 -1
- package/es/signature/drawingBoard.d.ts +15 -0
- package/es/signature/drawingBoard.js +163 -0
- package/es/signature/index.d.ts +3 -0
- package/es/signature/index.js +3 -0
- package/es/signature/signature.d.ts +32 -0
- package/es/signature/signature.js +268 -0
- package/es/signature/style/css.js +2 -0
- package/es/signature/style/index.css +210 -0
- package/es/signature/style/index.d.ts +2 -0
- package/es/signature/style/index.js +2 -0
- package/es/signature/style/index.less +95 -0
- package/es/signature/style/mixin.less +6 -0
- package/es/signature/style/token.less +22 -0
- package/es/signature/utils/signature_pad.d.ts +106 -0
- package/es/signature/utils/signature_pad.js +690 -0
- package/es/style/themes/default.less +1 -1
- package/es/tree-select/tree-select.js +1 -1
- package/lib/_utils/domUtil.d.ts +2 -0
- package/lib/_utils/domUtil.js +23 -0
- package/lib/cascader/cascader.js +41 -10
- package/lib/config-provider/compDefaultProps.d.ts +7 -0
- package/lib/config-provider/compDefaultProps.js +7 -0
- package/lib/date-picker/date-picker.js +18 -16
- package/lib/date-picker/hooks/use-range-view-dates.js +7 -1
- package/lib/date-picker/panel/time/time.js +17 -2
- package/lib/date-picker/range-picker.js +18 -28
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/lib/locale/locale.d.ts +5 -0
- package/lib/locale/zh-CN.d.ts +5 -0
- package/lib/locale/zh-CN.js +6 -1
- package/lib/signature/drawingBoard.d.ts +15 -0
- package/lib/signature/drawingBoard.js +176 -0
- package/lib/signature/index.d.ts +3 -0
- package/lib/signature/index.js +27 -0
- package/lib/signature/signature.d.ts +32 -0
- package/lib/signature/signature.js +282 -0
- package/lib/signature/style/css.js +4 -0
- package/lib/signature/style/index.css +210 -0
- package/lib/signature/style/index.d.ts +2 -0
- package/lib/signature/style/index.js +4 -0
- package/lib/signature/style/index.less +95 -0
- package/lib/signature/style/mixin.less +6 -0
- package/lib/signature/style/token.less +22 -0
- package/lib/signature/utils/signature_pad.d.ts +106 -0
- package/lib/signature/utils/signature_pad.js +697 -0
- package/lib/style/components.less +1 -0
- package/lib/style/themes/default.less +1 -1
- package/lib/tree-select/tree-select.js +1 -1
- package/package.json +3 -2
|
@@ -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
|
+
};
|
package/es/cascader/cascader.js
CHANGED
|
@@ -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(
|
|
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(
|
|
403
|
-
setVisible(
|
|
404
|
-
onPopupVisibleChange && onPopupVisibleChange(
|
|
405
|
-
onPopperVisibleChange && onPopperVisibleChange(
|
|
406
|
-
|
|
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(
|
|
467
|
+
return /*#__PURE__*/React.createElement(CascaderMenuSubmenu, _extends({
|
|
440
468
|
key: value
|
|
441
|
-
},
|
|
442
|
-
|
|
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
|
|
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
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
194
|
-
openValue =
|
|
195
|
-
triggerInnerOpen =
|
|
196
|
-
var
|
|
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
|
-
|
|
205
|
-
mergedMode =
|
|
206
|
-
setInnerMode =
|
|
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) {
|
|
@@ -6,7 +6,7 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import TimeColumn from './time-column';
|
|
9
|
-
import { formatDate, newDate, setTime as utilSetTime } from '../../utils/date-fns';
|
|
9
|
+
import { formatDate, newDate, setTime as utilSetTime, isValid } from '../../utils/date-fns';
|
|
10
10
|
import Context from '../../context';
|
|
11
11
|
import useStateMemo from '../../hooks/use-state-memo';
|
|
12
12
|
import { leftPad } from '../../utils';
|
|
@@ -39,7 +39,9 @@ function TimePanel(props) {
|
|
|
39
39
|
minutes = _context$minutes === void 0 ? [] : _context$minutes,
|
|
40
40
|
_context$seconds = context.seconds,
|
|
41
41
|
seconds = _context$seconds === void 0 ? [] : _context$seconds,
|
|
42
|
-
disabledTimePanel = context.disabledTimePanel
|
|
42
|
+
disabledTimePanel = context.disabledTimePanel,
|
|
43
|
+
rangeValue = context.rangeValue,
|
|
44
|
+
panelPosition = context.panelPosition;
|
|
43
45
|
var picker = props.picker,
|
|
44
46
|
_props$format = props.format,
|
|
45
47
|
format = _props$format === void 0 ? 'HH:mm:ss' : _props$format,
|
|
@@ -72,9 +74,22 @@ function TimePanel(props) {
|
|
|
72
74
|
var hour = originHour;
|
|
73
75
|
// const minute = value ? getMinutes(value) : -1
|
|
74
76
|
// const second = value ? getSeconds(value) : -1
|
|
77
|
+
var getDefaultDate = function getDefaultDate() {
|
|
78
|
+
if (panelPosition) {
|
|
79
|
+
if (rangeValue && rangeValue[0] && isValid(rangeValue[0])) {
|
|
80
|
+
return rangeValue[0];
|
|
81
|
+
}
|
|
82
|
+
if (rangeValue && rangeValue[1] && isValid(rangeValue[1])) {
|
|
83
|
+
return rangeValue[1];
|
|
84
|
+
}
|
|
85
|
+
} else if (value && isValid(value)) {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
return newDate();
|
|
89
|
+
};
|
|
75
90
|
var setTime = function setTime(isPM, newHour, newMinute, newSecond) {
|
|
76
91
|
var _a, _b, _c;
|
|
77
|
-
var date =
|
|
92
|
+
var date = getDefaultDate();
|
|
78
93
|
var _hour = newHour > -1 ? newHour : (_a = _findInstanceProperty(rawHours).call(rawHours, function (n) {
|
|
79
94
|
return !n.disabled;
|
|
80
95
|
})) === null || _a === void 0 ? void 0 : _a.value;
|
|
@@ -30,14 +30,6 @@ function reorderValues(values) {
|
|
|
30
30
|
}
|
|
31
31
|
return values;
|
|
32
32
|
}
|
|
33
|
-
// 范围时间顺序错误时报错
|
|
34
|
-
function isErrorValues(values) {
|
|
35
|
-
if (values && values[0] && values[1] && isAfter(values[0], values[1])) {
|
|
36
|
-
console.error('开始日期在结束日期之后');
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
33
|
// 是否可以切换选择器
|
|
42
34
|
function canValueTrigger(value, index, disabled, allowEmpty) {
|
|
43
35
|
if (value) {
|
|
@@ -145,17 +137,7 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
|
|
|
145
137
|
// 原始数据
|
|
146
138
|
var _useMergedState3 = useMergedState(null, {
|
|
147
139
|
value: value,
|
|
148
|
-
defaultValue: defaultValue
|
|
149
|
-
postState: function postState(values) {
|
|
150
|
-
if (picker === 'time' || picker === 'date' && showTime) {
|
|
151
|
-
return order ? reorderValues(values) : values;
|
|
152
|
-
} else {
|
|
153
|
-
if (isErrorValues(values)) {
|
|
154
|
-
return [values[0], null];
|
|
155
|
-
}
|
|
156
|
-
return values;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
140
|
+
defaultValue: defaultValue
|
|
159
141
|
}),
|
|
160
142
|
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
|
|
161
143
|
dateValue = _useMergedState4[0],
|
|
@@ -170,8 +152,11 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
|
|
|
170
152
|
}
|
|
171
153
|
// Fill disabled unit
|
|
172
154
|
for (var i = 0; i < 2; i++) {
|
|
173
|
-
|
|
155
|
+
var v = getValue(postValues, i);
|
|
156
|
+
if (mergedDisabled[i] && !v && !getValue(allowEmpty, i)) {
|
|
174
157
|
postValues = updateValues(postValues, newDate(), i);
|
|
158
|
+
} else if (v && !isValid(v)) {
|
|
159
|
+
postValues = updateValues(postValues, null, i);
|
|
175
160
|
}
|
|
176
161
|
}
|
|
177
162
|
return postValues;
|
|
@@ -352,12 +337,20 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
|
|
|
352
337
|
}
|
|
353
338
|
}, 0);
|
|
354
339
|
};
|
|
340
|
+
var triggerChangeInner = function triggerChangeInner(values) {
|
|
341
|
+
if (typeof value === 'undefined') {
|
|
342
|
+
setInnerValue(values);
|
|
343
|
+
}
|
|
344
|
+
if (onChange && (!isEqual(getValue(dateValue, 0), getValue(values, 0)) || !isEqual(getValue(dateValue, 1), getValue(values, 1)))) {
|
|
345
|
+
onChange(values, [values && values[0] ? formatDate(values[0], _format) : '', values && values[1] ? formatDate(values[1], _format) : '']);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
355
348
|
var triggerChange = function triggerChange(newValue, sourceIndex) {
|
|
356
349
|
var values = newValue;
|
|
357
350
|
var startValue = getValue(values, 0);
|
|
358
351
|
var endValue = getValue(values, 1);
|
|
359
352
|
if (startValue && endValue && isAfter(startValue, endValue)) {
|
|
360
|
-
if (picker === 'week' && !isSameWeek(startValue, endValue) || picker === 'quarter' && !isSameQuarter(startValue, endValue) || picker !== 'week' && picker !== 'quarter' && picker !== 'time' && !isSameDay(startValue, endValue)) {
|
|
353
|
+
if (picker === 'week' && !isSameWeek(startValue, endValue) || picker === 'quarter' && !isSameQuarter(startValue, endValue) || picker === 'time' && !isEqual(startValue, endValue) || picker !== 'week' && picker !== 'quarter' && picker !== 'time' && !isSameDay(startValue, endValue)) {
|
|
361
354
|
if (sourceIndex === 0) {
|
|
362
355
|
values = [startValue, null];
|
|
363
356
|
endValue = null;
|
|
@@ -366,8 +359,6 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
|
|
|
366
359
|
values = [null, endValue];
|
|
367
360
|
}
|
|
368
361
|
openRecordsRef.current = _defineProperty({}, sourceIndex, true);
|
|
369
|
-
} else if (picker === 'time' && order === true) {
|
|
370
|
-
values = reorderValues(values);
|
|
371
362
|
}
|
|
372
363
|
}
|
|
373
364
|
setSelectedValue(values);
|
|
@@ -383,11 +374,10 @@ var InternalRangePicker = function InternalRangePicker(props, ref) {
|
|
|
383
374
|
var canEndValueTrigger = canValueTrigger(endValue, 1, mergedDisabled, allowEmpty);
|
|
384
375
|
var canTrigger = values === null || canStartValueTrigger && canEndValueTrigger;
|
|
385
376
|
if (canTrigger) {
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
onChange(values, [startStr, endStr]);
|
|
377
|
+
if (order) {
|
|
378
|
+
triggerChangeInner(reorderValues(values));
|
|
379
|
+
} else {
|
|
380
|
+
triggerChangeInner(values);
|
|
391
381
|
}
|
|
392
382
|
}
|
|
393
383
|
var curValue = getValue(values, sourceIndex);
|
package/es/index.d.ts
CHANGED
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';
|
package/es/locale/locale.d.ts
CHANGED
|
@@ -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;
|
package/es/locale/zh-CN.d.ts
CHANGED
|
@@ -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;
|
package/es/locale/zh-CN.js
CHANGED
|
@@ -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;
|