@kdcloudjs/kdesign 1.5.10 → 1.5.11

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 (49) hide show
  1. package/dist/kdesign-complete.less +4 -7
  2. package/dist/kdesign.css +5 -8
  3. package/dist/kdesign.css.map +1 -1
  4. package/dist/kdesign.js +959 -221
  5. package/dist/kdesign.js.map +1 -1
  6. package/dist/kdesign.min.css +3 -3
  7. package/dist/kdesign.min.js +6 -6
  8. package/dist/kdesign.min.js.map +1 -1
  9. package/es/_utils/KeyCode.d.ts +436 -0
  10. package/es/_utils/KeyCode.js +623 -0
  11. package/es/_utils/hooks.d.ts +1 -0
  12. package/es/_utils/hooks.js +51 -1
  13. package/es/alert/style/index.css +0 -1
  14. package/es/alert/style/index.less +0 -1
  15. package/es/button/style/index.css +3 -0
  16. package/es/button/style/mixin.less +3 -0
  17. package/es/config-provider/compDefaultProps.d.ts +1 -0
  18. package/es/config-provider/compDefaultProps.js +2 -1
  19. package/es/date-picker/date-picker.js +15 -14
  20. package/es/date-picker/hooks/use-picker-input.js +44 -38
  21. package/es/date-picker/range-picker.js +24 -13
  22. package/es/drawer/drawer.d.ts +1 -0
  23. package/es/drawer/drawer.js +6 -3
  24. package/es/notification-base/notification.js +4 -4
  25. package/es/pagination/style/index.css +1 -3
  26. package/es/pagination/style/index.less +1 -3
  27. package/es/transfer/style/index.css +0 -3
  28. package/es/transfer/style/index.less +0 -3
  29. package/lib/_utils/KeyCode.d.ts +436 -0
  30. package/lib/_utils/KeyCode.js +631 -0
  31. package/lib/_utils/hooks.d.ts +1 -0
  32. package/lib/_utils/hooks.js +54 -1
  33. package/lib/alert/style/index.css +0 -1
  34. package/lib/alert/style/index.less +0 -1
  35. package/lib/button/style/index.css +3 -0
  36. package/lib/button/style/mixin.less +3 -0
  37. package/lib/config-provider/compDefaultProps.d.ts +1 -0
  38. package/lib/config-provider/compDefaultProps.js +2 -1
  39. package/lib/date-picker/date-picker.js +15 -15
  40. package/lib/date-picker/hooks/use-picker-input.js +45 -37
  41. package/lib/date-picker/range-picker.js +24 -14
  42. package/lib/drawer/drawer.d.ts +1 -0
  43. package/lib/drawer/drawer.js +5 -2
  44. package/lib/notification-base/notification.js +4 -3
  45. package/lib/pagination/style/index.css +1 -3
  46. package/lib/pagination/style/index.less +1 -3
  47. package/lib/transfer/style/index.css +0 -3
  48. package/lib/transfer/style/index.less +0 -3
  49. package/package.json +1 -1
@@ -106,6 +106,7 @@ declare const compDefaultProps: {
106
106
  placement: string;
107
107
  width: number;
108
108
  zIndex: number;
109
+ disableScroll: boolean;
109
110
  };
110
111
  Empty: {};
111
112
  Filter: {
@@ -111,7 +111,8 @@ var compDefaultProps = {
111
111
  maskClosable: true,
112
112
  placement: 'right',
113
113
  width: 320,
114
- zIndex: 1050
114
+ zIndex: 1050,
115
+ disableScroll: true
115
116
  },
116
117
  Empty: {},
117
118
  Filter: {
@@ -3,7 +3,6 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
3
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
4
4
  import React, { useContext, useEffect } from 'react';
5
5
  import classnames from 'classnames';
6
- import parse from 'date-fns/parse';
7
6
  import ConfigContext from '../config-provider/ConfigContext';
8
7
  import { useMergedState, useOnClickOutside } from '../_utils/hooks';
9
8
  import { getCompProps } from '../_utils';
@@ -168,19 +167,21 @@ function DatePicker(props) {
168
167
  var _useTextValueMapping = useTextValueMapping({
169
168
  valueText: valueText,
170
169
  onTextChange: function onTextChange(newText) {
171
- // if (typeof _format !== 'function') {
172
- var inputDate;
173
-
174
- if (picker !== 'year') {
175
- inputDate = parseDate(newText, _format);
176
- } else {
177
- var year = parse(newText, _format, newDate());
178
- inputDate = isValid(year) ? year : null;
179
- }
180
-
181
- if (inputDate && (!disabledDate || !disabledDate(inputDate))) {
182
- setSelectedValue(inputDate);
183
- setViewDate(inputDate);
170
+ if (newText === '') {
171
+ setSelectedValue(null);
172
+ setDateValue(null);
173
+ } else if (newText && newText.length === _format.length) {
174
+ var inputTempDate = parseDate(newText, _format);
175
+
176
+ if (inputTempDate && (!disabledDate || !disabledDate(inputTempDate))) {
177
+ if (picker !== 'year') {
178
+ setSelectedValue(inputTempDate);
179
+ setDateValue(inputTempDate);
180
+ } else if (isValid(inputTempDate)) {
181
+ setSelectedValue(inputTempDate);
182
+ setDateValue(inputTempDate);
183
+ }
184
+ }
184
185
  }
185
186
  }
186
187
  }),
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
- import { useState, useEffect, useRef } from 'react'; // import KeyCode from '../../_utils/KeyCode'
3
-
2
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
+ import { useState, useEffect, useRef } from 'react';
4
+ import KeyCode from '../../_utils/KeyCode';
4
5
  export default function usePickerInput(_ref) {
5
6
  var preventBlurRef = _ref.preventBlurRef,
6
7
  open = _ref.open,
@@ -29,42 +30,47 @@ export default function usePickerInput(_ref) {
29
30
  setTyping(true);
30
31
  triggerOpen(true);
31
32
  },
32
- // onKeyDown: (e) => {
33
- // switch (e.which) {
34
- // case KeyCode.ENTER: {
35
- // if (!open) {
36
- // triggerOpen(true)
37
- // } else if (onSubmit() !== false) {
38
- // setTyping(true)
39
- // }
40
- // e.preventDefault()
41
- // return
42
- // }
43
- // case KeyCode.TAB: {
44
- // if (typing && open && !e.shiftKey) {
45
- // setTyping(false)
46
- // e.preventDefault()
47
- // } else if (!typing && open) {
48
- // if (!forwardKeyDown(e) && e.shiftKey) {
49
- // setTyping(true)
50
- // e.preventDefault()
51
- // }
52
- // }
53
- // return
54
- // }
55
- // case KeyCode.ESC: {
56
- // setTyping(true)
57
- // onCancel()
58
- // return
59
- // }
60
- // }
61
- // if (!open && ![KeyCode.SHIFT].includes(e.which)) {
62
- // triggerOpen(true)
63
- // } else if (!typing) {
64
- // // Let popup panel handle keyboard
65
- // forwardKeyDown(e)
66
- // }
67
- // },
33
+ onKeyDown: function onKeyDown(e) {
34
+ var _context;
35
+
36
+ setTyping(true);
37
+ triggerOpen(true);
38
+
39
+ switch (e.which) {
40
+ case KeyCode.ENTER:
41
+ {
42
+ if (!open) {
43
+ triggerOpen(true);
44
+ } else if (onSubmit() !== false) {
45
+ setTyping(true);
46
+ }
47
+
48
+ e.preventDefault();
49
+ return;
50
+ }
51
+
52
+ case KeyCode.TAB:
53
+ {
54
+ if (typing && open && !e.shiftKey) {
55
+ setTyping(false);
56
+ e.preventDefault();
57
+ }
58
+
59
+ return;
60
+ }
61
+
62
+ case KeyCode.ESC:
63
+ {
64
+ setTyping(true);
65
+ onCancel();
66
+ return;
67
+ }
68
+ }
69
+
70
+ if (!open && !_includesInstanceProperty(_context = [KeyCode.SHIFT]).call(_context, e.which)) {
71
+ triggerOpen(true);
72
+ }
73
+ },
68
74
  onFocus: function onFocus(e) {
69
75
  setTyping(true);
70
76
  setFocused(true);
@@ -6,7 +6,6 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
6
6
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
7
  import React, { useContext, useEffect } from 'react';
8
8
  import isSameWeek from 'date-fns/isSameWeek';
9
- import parse from 'date-fns/parse';
10
9
  import ConfigContext from '../config-provider/ConfigContext';
11
10
  import { useMergedState, useOnClickOutside } from '../_utils/hooks';
12
11
  import { getCompProps } from '../_utils';
@@ -249,20 +248,32 @@ function DatePicker(props) {
249
248
  });
250
249
 
251
250
  var _onTextChange = function onTextChange(newText, index) {
252
- var inputDate;
251
+ var inputTempDate;
253
252
 
254
- if (picker !== 'year') {
255
- inputDate = parseDate(newText, _format);
256
- } else {
257
- var year = parse(newText, _format, newDate());
258
- inputDate = isValid(year) ? year : null;
259
- }
260
-
261
- var disabledFunc = index === 0 ? disabledStartDate : disabledEndDate;
253
+ if (newText === '') {
254
+ if (index === 0 && selectedValue && selectedValue.length === 2) {
255
+ inputTempDate = selectedValue[1];
256
+ } else if (index === 1 && selectedValue && selectedValue.length === 2) {
257
+ inputTempDate = selectedValue[0];
258
+ }
262
259
 
263
- if (inputDate && (!disabledFunc || !disabledFunc(inputDate))) {
264
- setSelectedValue(updateValues(selectedValue, inputDate, index));
265
- setViewDate(inputDate, index);
260
+ if (inputTempDate) {
261
+ setSelectedValue(updateValues(selectedValue, inputTempDate, index));
262
+ setViewDate(inputTempDate, index);
263
+ }
264
+ } else if (newText && newText.length === _format.length) {
265
+ inputTempDate = parseDate(newText, _format);
266
+ var disabledFunc = index === 0 ? disabledStartDate : disabledEndDate;
267
+
268
+ if (inputTempDate && (!disabledFunc || !disabledFunc(inputTempDate))) {
269
+ if (picker !== 'year') {
270
+ setSelectedValue(updateValues(selectedValue, inputTempDate, index));
271
+ setViewDate(inputTempDate, index);
272
+ } else if (isValid(inputTempDate)) {
273
+ setSelectedValue(updateValues(selectedValue, inputTempDate, index));
274
+ setViewDate(inputTempDate, index);
275
+ }
276
+ }
266
277
  }
267
278
  }; // input 展示
268
279
 
@@ -36,6 +36,7 @@ export interface IDrawerProps {
36
36
  width?: string | number;
37
37
  height?: string | number;
38
38
  zIndex?: string | number;
39
+ disableScroll?: boolean;
39
40
  }
40
41
  declare const Drawer: React.ForwardRefExoticComponent<IDrawerProps & React.RefAttributes<unknown>>;
41
42
  export default Drawer;
@@ -12,7 +12,7 @@ import classNames from 'classnames';
12
12
  import ConfigContext from '../config-provider/ConfigContext';
13
13
  import { getCompProps } from '../_utils';
14
14
  import devWarning from '../_utils/devwarning';
15
- import { useResizeObserver, useHideDocumentScrollBar } from '../_utils/hooks'; // import { usePrevious } from '../_utils/hooks'
15
+ import { useResizeObserver, useOverflowHidden } from '../_utils/hooks'; // import { usePrevious } from '../_utils/hooks'
16
16
 
17
17
  import { toArray } from '../_utils/react-children';
18
18
  export var PlacementTypes = tuple('top', 'right', 'bottom', 'left');
@@ -37,6 +37,8 @@ var documentBody = document.body; // function transformSize(size: string | numbe
37
37
  var InternalDrawer = function InternalDrawer(props, ref) {
38
38
  var _classNames, _context2, _context3, _classNames2;
39
39
 
40
+ var _a;
41
+
40
42
  var _useContext = useContext(ConfigContext),
41
43
  getPrefixCls = _useContext.getPrefixCls,
42
44
  prefixCls = _useContext.prefixCls,
@@ -70,7 +72,8 @@ var InternalDrawer = function InternalDrawer(props, ref) {
70
72
  getContainer = drawerProps.getContainer,
71
73
  forceRender = drawerProps.forceRender,
72
74
  destroyOnClose = drawerProps.destroyOnClose,
73
- customPrefixcls = drawerProps.prefixCls;
75
+ customPrefixcls = drawerProps.prefixCls,
76
+ disableScroll = drawerProps.disableScroll;
74
77
  var drawerPrefixCls = getPrefixCls(prefixCls, 'drawer', customPrefixcls);
75
78
 
76
79
  var _useState = useState(false),
@@ -138,7 +141,7 @@ var InternalDrawer = function InternalDrawer(props, ref) {
138
141
 
139
142
  return drawerContainer || ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.parentNode);
140
143
  }, handleContainerResize);
141
- useHideDocumentScrollBar(!!visible, isBody, !!mask); // 为了单测
144
+ useOverflowHidden(drawerContainer || ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.parentNode), visible && mask, disableScroll); // 为了单测
142
145
 
143
146
  useEffect(function () {
144
147
  setCurrentWidth(width);
@@ -60,11 +60,11 @@ var Notification = /*#__PURE__*/React.forwardRef(function (props, ref) {
60
60
  };
61
61
 
62
62
  var remove = function remove(key) {
63
- var filter = _filterInstanceProperty(notices).call(notices, function (notice) {
64
- return notice.key !== key;
63
+ setNotices(function (preNotices) {
64
+ return _filterInstanceProperty(preNotices).call(preNotices, function (notice) {
65
+ return notice.key !== key;
66
+ });
65
67
  });
66
-
67
- setNotices(filter);
68
68
  };
69
69
 
70
70
  var _onClose = function onClose(notice) {
@@ -430,9 +430,7 @@
430
430
  }
431
431
  .kd-pagination.less .kd-pagination-pages-item:hover button,
432
432
  .kd-pagination.less .kd-pagination-pages-item:active button,
433
- .kd-pagination.less .kd-pagination-pages-item.active button,
434
- .kd-pagination.less .kd-pagination-pages-item:first-child button,
435
- .kd-pagination.less .kd-pagination-pages-item:last-child button {
433
+ .kd-pagination.less .kd-pagination-pages-item.active button {
436
434
  color: var(--kd-g-color-theme, #5582f3);
437
435
  }
438
436
  .kd-pagination.less .kd-pagination-pages-item:first-child button,
@@ -314,9 +314,7 @@
314
314
 
315
315
  &:hover,
316
316
  &:active,
317
- &.active,
318
- &:first-child,
319
- &:last-child {
317
+ &.active {
320
318
  button {
321
319
  color: @color-theme;
322
320
  }
@@ -352,6 +352,3 @@
352
352
  .kd-transfer-operation .kd-btn + .kd-btn {
353
353
  margin-top: 20px;
354
354
  }
355
- .kd-transfer-operation .kd-btn .kd-btn-iconWrapper-left {
356
- float: none;
357
- }
@@ -182,9 +182,6 @@
182
182
  & + .@{kd-prefix}-btn {
183
183
  margin-top: 20px;
184
184
  }
185
- .@{kd-prefix}-btn-iconWrapper-left {
186
- float: none;
187
- }
188
185
  }
189
186
  }
190
187
  }