@kdcloudjs/kdesign 1.7.40 → 1.7.42

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 (50) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/kdesign-complete.less +79 -5
  3. package/dist/kdesign.css +69 -1
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +439 -151
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +2 -2
  8. package/dist/kdesign.min.js +10 -10
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/button/index.d.ts +2 -1
  11. package/es/carousel/index.d.ts +2 -2
  12. package/es/city-picker/index.d.ts +2 -0
  13. package/es/collapse/index.d.ts +2 -2
  14. package/es/config-provider/compDefaultProps.d.ts +1 -0
  15. package/es/config-provider/compDefaultProps.js +2 -1
  16. package/es/input/TextArea.js +16 -8
  17. package/es/input/style/index.css +3 -0
  18. package/es/input/style/index.less +9 -5
  19. package/es/modal/modal.d.ts +4 -0
  20. package/es/modal/modal.js +221 -20
  21. package/es/modal/style/index.css +65 -0
  22. package/es/modal/style/index.less +70 -0
  23. package/es/notification-base/notice.js +6 -1
  24. package/es/pagination/pagination.js +34 -31
  25. package/es/search/search-panel.d.ts +1 -1
  26. package/es/select/index.d.ts +1 -0
  27. package/es/select/index.js +1 -0
  28. package/es/tree/tree.d.ts +1 -1
  29. package/es/tree/treeHooks.js +1 -1
  30. package/lib/button/index.d.ts +2 -1
  31. package/lib/carousel/index.d.ts +2 -2
  32. package/lib/city-picker/index.d.ts +2 -0
  33. package/lib/collapse/index.d.ts +2 -2
  34. package/lib/config-provider/compDefaultProps.d.ts +1 -0
  35. package/lib/config-provider/compDefaultProps.js +2 -1
  36. package/lib/input/TextArea.js +16 -8
  37. package/lib/input/style/index.css +3 -0
  38. package/lib/input/style/index.less +9 -5
  39. package/lib/modal/modal.d.ts +4 -0
  40. package/lib/modal/modal.js +221 -20
  41. package/lib/modal/style/index.css +65 -0
  42. package/lib/modal/style/index.less +70 -0
  43. package/lib/notification-base/notice.js +6 -1
  44. package/lib/pagination/pagination.js +34 -31
  45. package/lib/search/search-panel.d.ts +1 -1
  46. package/lib/select/index.d.ts +1 -0
  47. package/lib/select/index.js +14 -0
  48. package/lib/tree/tree.d.ts +1 -1
  49. package/lib/tree/treeHooks.js +1 -1
  50. package/package.json +8 -2
@@ -3,9 +3,6 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
3
3
  import _extends from "@babel/runtime-corejs3/helpers/extends";
4
4
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
7
- import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
8
- import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
9
6
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
10
7
  import * as React from 'react';
11
8
  import classNames from 'classnames';
@@ -19,7 +16,7 @@ import { tuple } from '../_utils/type';
19
16
  export var PageTypes = tuple('basic', 'bill', 'simple', 'less', 'nicety');
20
17
  export var TotalTypes = tuple('page', 'row', 'all');
21
18
  var Pagination = function Pagination(props) {
22
- var _context4;
19
+ var _context2;
23
20
  var _React$useContext = React.useContext(ConfigContext),
24
21
  getPrefixCls = _React$useContext.getPrefixCls,
25
22
  pkgPrefixCls = _React$useContext.prefixCls,
@@ -178,8 +175,11 @@ var Pagination = function Pagination(props) {
178
175
  };
179
176
  // 生成元素是连续数字的数组
180
177
  function genArray(start, end) {
181
- var _context2, _context3;
182
- return _sliceInstanceProperty(_context2 = _Array$from(_keysInstanceProperty(_context3 = Array(end + 1)).call(_context3))).call(_context2, start);
178
+ var result = [];
179
+ for (var i = start; i <= end; i++) {
180
+ result.push(i);
181
+ }
182
+ return result;
183
183
  }
184
184
  function dropdownVisibleChange(visible) {
185
185
  setIsOpen(visible);
@@ -278,7 +278,7 @@ var Pagination = function Pagination(props) {
278
278
  }, /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('action-item', paginationLangMsg.prevPage)), /*#__PURE__*/React.createElement("button", {
279
279
  onClick: handlePrev,
280
280
  disabled: page === 1 || disabled
281
- }, innerIcon.prev)), /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('action-item', _concatInstanceProperty(_context4 = "".concat(page, "/")).call(_context4, totalPage))), /*#__PURE__*/React.createElement("span", {
281
+ }, innerIcon.prev)), /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('action-item', _concatInstanceProperty(_context2 = "".concat(page, "/")).call(_context2, totalPage))), /*#__PURE__*/React.createElement("span", {
282
282
  className: "".concat(prefixCls, "-current")
283
283
  }, showJumper ? /*#__PURE__*/React.createElement("input", {
284
284
  type: "text",
@@ -295,30 +295,33 @@ var Pagination = function Pagination(props) {
295
295
  disabled: page === totalPage || disabled
296
296
  }, innerIcon.next))));
297
297
  var lessPages = genArray(1, totalPage);
298
- var lessPagination = /*#__PURE__*/React.createElement("div", {
299
- className: classNames(prefixCls, 'less', {
300
- bordered: bordered,
301
- disabled: disabled
302
- }, className),
303
- style: style
304
- }, Total, /*#__PURE__*/React.createElement("ul", {
305
- className: "".concat(prefixCls, "-pages")
306
- }, /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('pages-item', paginationLangMsg.prevPage)), /*#__PURE__*/React.createElement("button", {
307
- onClick: handlePrev,
308
- disabled: page === 1 || disabled
309
- }, innerIcon.prev)), _mapInstanceProperty(lessPages).call(lessPages, function (item, index) {
310
- return /*#__PURE__*/React.createElement("li", _extends({
311
- key: index
312
- }, itemAttr('pages-item', String(item), item === page)), /*#__PURE__*/React.createElement("button", {
313
- onClick: function onClick() {
314
- return changePage(item);
315
- },
316
- disabled: disabled
317
- }, item));
318
- }), /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('pages-item', paginationLangMsg.nextPage)), /*#__PURE__*/React.createElement("button", {
319
- onClick: handleNext,
320
- disabled: page === totalPage || disabled
321
- }, innerIcon.next))));
298
+ var lessPagination = null;
299
+ if (pageType === 'less') {
300
+ lessPagination = /*#__PURE__*/React.createElement("div", {
301
+ className: classNames(prefixCls, 'less', {
302
+ bordered: bordered,
303
+ disabled: disabled
304
+ }, className),
305
+ style: style
306
+ }, Total, /*#__PURE__*/React.createElement("ul", {
307
+ className: "".concat(prefixCls, "-pages")
308
+ }, /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('pages-item', paginationLangMsg.prevPage)), /*#__PURE__*/React.createElement("button", {
309
+ onClick: handlePrev,
310
+ disabled: page === 1 || disabled
311
+ }, innerIcon.prev)), _mapInstanceProperty(lessPages).call(lessPages, function (item, index) {
312
+ return /*#__PURE__*/React.createElement("li", _extends({
313
+ key: index
314
+ }, itemAttr('pages-item', String(item), item === page)), /*#__PURE__*/React.createElement("button", {
315
+ onClick: function onClick() {
316
+ return changePage(item);
317
+ },
318
+ disabled: disabled
319
+ }, item));
320
+ }), /*#__PURE__*/React.createElement("li", _extends({}, itemAttr('pages-item', paginationLangMsg.nextPage)), /*#__PURE__*/React.createElement("button", {
321
+ onClick: handleNext,
322
+ disabled: page === totalPage || disabled
323
+ }, innerIcon.next))));
324
+ }
322
325
  var nicetyPages = lessPages;
323
326
  if (totalPage >= 8) {
324
327
  nicetyPages.length = 0;
@@ -17,7 +17,7 @@ interface ItypeProps {
17
17
  label?: string;
18
18
  code?: string | number;
19
19
  }
20
- interface resultProps {
20
+ export interface resultProps {
21
21
  title?: string;
22
22
  typeName?: string;
23
23
  subTitle?: string;
@@ -5,4 +5,5 @@ interface CompoundedComponent extends React.ForwardRefExoticComponent<ISelectPro
5
5
  Option: typeof Option;
6
6
  }
7
7
  declare const Select: CompoundedComponent;
8
+ export * from './interface';
8
9
  export default Select;
@@ -2,4 +2,5 @@ import InternalSelect from './select';
2
2
  import Option from './option';
3
3
  var Select = InternalSelect;
4
4
  Select.Option = Option;
5
+ export * from './interface';
5
6
  export default Select;
package/es/tree/tree.d.ts CHANGED
@@ -25,7 +25,7 @@ export interface TreeProps {
25
25
  scrollToKey?: string;
26
26
  selectedKeys?: string[];
27
27
  notFoundContent?: ReactNode;
28
- loadData?: () => void;
28
+ loadData?: <T>(data: T) => void;
29
29
  onCheck?: (checkedKeys: string[], { checked, node, event, halfCheckedKeys }: any) => void;
30
30
  onExpand?: (expandedKeys: string[], { expanded, node }: any) => void;
31
31
  onSelect?: (keys: string[], { checked, node, event }: any) => void;
@@ -67,7 +67,7 @@ export var useExpand = function useExpand(flattenAllData, expandedKeysProps, def
67
67
  }
68
68
  var initialExpandedKeys = React.useMemo(function () {
69
69
  return getInitExpandedKeys(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, expandScrollkeys, filterTreeNode, isSearching, keysData, isInit, searchStatus);
70
- }, [flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, filterTreeNode, isSearching, keysData, isInit, searchStatus]);
70
+ }, [flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, filterTreeNode, isSearching, keysData, isInit, searchStatus, filterValue]);
71
71
  var _React$useState7 = React.useState(initialExpandedKeys),
72
72
  _React$useState8 = _slicedToArray(_React$useState7, 2),
73
73
  expandedKeys = _React$useState8[0],
@@ -3,5 +3,6 @@ import Dropdown from './group';
3
3
  declare const Button: import("react").ForwardRefExoticComponent<import("./button").IButtonProps & import("react").RefAttributes<unknown>> & {
4
4
  Dropdown: typeof Dropdown;
5
5
  };
6
- export { ButtonType, IButtonProps } from './button';
6
+ export { ButtonType, IButtonProps, ButtonSize, ButtonShape, ButtonIconPlace, ButtonHTMLType } from './button';
7
+ export { OverlayType, ButtonGroupType } from './group';
7
8
  export default Button;
@@ -1,7 +1,7 @@
1
- import Carousel, { CarouselProps } from './carousel';
1
+ import Carousel, { CarouselProps, DotPositionType, EffectType } from './carousel';
2
2
  import { Slidebar } from './slidebar';
3
3
  import { SlideList } from './slideList';
4
4
  import { FadeList } from './fadeList';
5
5
  export * from './carousel';
6
- export { CarouselProps, Slidebar, FadeList, SlideList };
6
+ export { CarouselProps, DotPositionType, EffectType, Slidebar, FadeList, SlideList };
7
7
  export default Carousel;
@@ -1,3 +1,5 @@
1
1
  import CityPicker from './city-picker';
2
+ import { City, BorderType, Size, Type, CityList, CityPickerProps, ICityPickerOptionProps } from './interface';
3
+ export { City, BorderType, Size, Type, CityList, CityPickerProps, ICityPickerOptionProps };
2
4
  export * from './city-picker';
3
5
  export default CityPicker;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { CollapseProps } from './collapse';
2
+ import { CollapseProps, IconPositionType } from './collapse';
3
3
  import Panel from './panel';
4
4
  export { PanelProps } from './panel';
5
5
  interface CompoundedComponent extends React.ForwardRefExoticComponent<CollapseProps & React.RefAttributes<HTMLElement>> {
6
6
  Panel: typeof Panel;
7
7
  }
8
8
  declare const Collapse: CompoundedComponent;
9
- export { Panel };
9
+ export { Panel, IconPositionType };
10
10
  export default Collapse;
@@ -192,6 +192,7 @@ declare const compDefaultProps: {
192
192
  okButtonProps: {};
193
193
  showline: boolean;
194
194
  overroll: boolean;
195
+ resizable: boolean;
195
196
  };
196
197
  Menu: {
197
198
  mode: string;
@@ -207,7 +207,8 @@ var compDefaultProps = {
207
207
  cancelButtonProps: {},
208
208
  okButtonProps: {},
209
209
  showline: true,
210
- overroll: false
210
+ overroll: false,
211
+ resizable: false
211
212
  },
212
213
  Menu: {
213
214
  mode: 'vertical',
@@ -82,6 +82,10 @@ var InternalTextarea = function InternalTextarea(props, ref) {
82
82
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
83
83
  showNumberMark = _useState6[0],
84
84
  setShowNumberMark = _useState6[1];
85
+ var _useState7 = (0, _react.useState)(false),
86
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
87
+ numberMarkError = _useState8[0],
88
+ setNumberMarkError = _useState8[1];
85
89
  var resizeTextarea = (0, _react.useCallback)(function () {
86
90
  if (!autoSize || !textareaRef.current) {
87
91
  return;
@@ -129,21 +133,25 @@ var InternalTextarea = function InternalTextarea(props, ref) {
129
133
  onChange && onChange(event);
130
134
  };
131
135
  var renderNumberMark = function renderNumberMark() {
132
- var enteredLength = value ? value.length : 0;
133
- if (enteredLength >= maxLength) {
134
- enteredLength = maxLength;
135
- }
136
- if (count && showNumberMark && !disabled && maxLength !== '' && maxLength >= 0) {
137
- var countClass = (0, _classnames.default)("".concat(textAreaPrefixCls, "-textarea-mark"), (0, _defineProperty2.default)({}, "".concat(textAreaPrefixCls, "-textarea-mark-inner"), countPosition === 'inner'));
136
+ if (count && (showNumberMark || numberMarkError) && !disabled && maxLength !== '' && maxLength >= 0) {
137
+ var _classNames;
138
+ var countClass = (0, _classnames.default)("".concat(textAreaPrefixCls, "-textarea-mark"), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(textAreaPrefixCls, "-textarea-mark-inner"), countPosition === 'inner'), (0, _defineProperty2.default)(_classNames, "".concat(textAreaPrefixCls, "-textarea-mark-error"), numberMarkError), _classNames));
138
139
  return /*#__PURE__*/_react.default.createElement("div", {
139
140
  className: countClass
140
- }, enteredLength, "/", maxLength);
141
+ }, value ? value.length : 0, "/", maxLength);
141
142
  }
142
143
  return null;
143
144
  };
144
145
  (0, _react.useEffect)(function () {
145
146
  resizeTextarea();
146
147
  }, [value, resizeTextarea]);
148
+ (0, _react.useEffect)(function () {
149
+ if (value && maxLength && value.length > maxLength) {
150
+ setNumberMarkError(true);
151
+ } else {
152
+ setNumberMarkError(false);
153
+ }
154
+ }, [value]);
147
155
  (0, _react.useEffect)(function () {
148
156
  if (propsValue !== undefined) {
149
157
  setValue(propsValue);
@@ -185,7 +193,7 @@ var InternalTextarea = function InternalTextarea(props, ref) {
185
193
  ref: textareaRef,
186
194
  disabled: disabled,
187
195
  style: (0, _extends2.default)({}, textareaStyles, hadCount || !!allowClear ? otherStyles : style),
188
- className: (0, _classnames.default)("".concat(prefixCls, "-textarea"), (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context = "".concat(prefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-no-resize"), canResize !== true), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-allowClear-spacing"), !!allowClear), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-error"), status === 'error'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _classNames2), (0, _defineProperty2.default)({}, className, className && !allowClear && !hadCount)),
196
+ className: (0, _classnames.default)("".concat(prefixCls, "-textarea"), (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context = "".concat(prefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-no-resize"), canResize !== true), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-allowClear-spacing"), !!allowClear), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-error"), status === 'error' || numberMarkError), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _classNames2), (0, _defineProperty2.default)({}, className, className && !allowClear && !hadCount)),
189
197
  onChange: handleChange,
190
198
  onFocus: !disabled ? handleFocus : undefined,
191
199
  onBlur: !disabled ? handleBlur : undefined,
@@ -215,6 +215,9 @@ textarea {
215
215
  bottom: 5px;
216
216
  right: 8px;
217
217
  }
218
+ .kd-input-textarea-mark-error {
219
+ color: var(--kd-c-input-color-error, var(--kd-g-color-error, #fb2323));
220
+ }
218
221
  .kd-input-no-resize {
219
222
  resize: none;
220
223
  }
@@ -43,12 +43,16 @@ textarea {
43
43
  font-size: @input-small-font-size-inner;
44
44
  line-height: 18px;
45
45
  background-color: #fff;
46
- }
47
46
 
48
- &-mark-inner {
49
- top: auto;
50
- bottom: 5px;
51
- right: 8px;
47
+ &-inner {
48
+ top: auto;
49
+ bottom: 5px;
50
+ right: 8px;
51
+ }
52
+
53
+ &-error {
54
+ color: @input-error-color;
55
+ }
52
56
  }
53
57
  }
54
58
 
@@ -44,6 +44,10 @@ export interface IModalProps {
44
44
  showline?: boolean;
45
45
  bounds?: DraggableBounds | string | false;
46
46
  overroll?: boolean;
47
+ resizable?: boolean;
48
+ onResizeStart?: (event: MouseEvent) => void;
49
+ onResize?: (event: MouseEvent) => void;
50
+ onResizeStop?: (event: MouseEvent) => void;
47
51
  onDragStart?: DraggableEventHandler;
48
52
  onDrag?: DraggableEventHandler;
49
53
  onDragStop?: DraggableEventHandler;
@@ -40,8 +40,30 @@ var ConfirmModalTypes = ['confirm', 'normal'];
40
40
  exports.ConfirmModalTypes = ConfirmModalTypes;
41
41
  var ModalTypes = (0, _type.tuple)('confirm', 'warning', 'error', 'normal');
42
42
  exports.ModalTypes = ModalTypes;
43
+ var DragDirection;
44
+ (function (DragDirection) {
45
+ DragDirection["N"] = "n";
46
+ DragDirection["E"] = "e";
47
+ DragDirection["S"] = "s";
48
+ DragDirection["W"] = "w";
49
+ DragDirection["NE"] = "ne";
50
+ DragDirection["NW"] = "nw";
51
+ DragDirection["SE"] = "se";
52
+ DragDirection["SW"] = "sw";
53
+ })(DragDirection || (DragDirection = {}));
54
+ var initPosition = {
55
+ initialX: 0,
56
+ initialY: 0,
57
+ initialWidth: 0,
58
+ initialHeight: 0,
59
+ top: 0,
60
+ left: 0,
61
+ x: 0,
62
+ y: 0,
63
+ type: null
64
+ };
43
65
  var InternalModal = function InternalModal(props, ref) {
44
- var _classNames3, _classNames4, _context2, _context3, _context4;
66
+ var _classNames3, _classNames4, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12;
45
67
  var _useContext = (0, _react.useContext)(_ConfigContext.default),
46
68
  getPrefixCls = _useContext.getPrefixCls,
47
69
  prefixCls = _useContext.prefixCls,
@@ -85,7 +107,8 @@ var InternalModal = function InternalModal(props, ref) {
85
107
  onDragStop = modalProps.onDragStop,
86
108
  bounds = modalProps.bounds,
87
109
  overroll = modalProps.overroll,
88
- others = __rest(modalProps, ["body", "bodyClassName", "bodyStyle", "cancelButtonProps", "cancelText", "className", "closable", "closeIcon", "destroyOnClose", "draggable", "focusTriggerAfterClose", "footer", "footerClassName", "footerStyle", "footerBtnOrder", "getContainer", "height", "keyboard", "mask", "maskClosable", "maskStyle", "maskClassName", "okButtonProps", "okText", "onCancel", "onOk", "prefixCls", "title", "titleIcon", "type", "visible", "width", "showline", "onDragStart", "onDrag", "onDragStop", "bounds", "overroll"]);
110
+ resizable = modalProps.resizable,
111
+ others = __rest(modalProps, ["body", "bodyClassName", "bodyStyle", "cancelButtonProps", "cancelText", "className", "closable", "closeIcon", "destroyOnClose", "draggable", "focusTriggerAfterClose", "footer", "footerClassName", "footerStyle", "footerBtnOrder", "getContainer", "height", "keyboard", "mask", "maskClosable", "maskStyle", "maskClassName", "okButtonProps", "okText", "onCancel", "onOk", "prefixCls", "title", "titleIcon", "type", "visible", "width", "showline", "onDragStart", "onDrag", "onDragStop", "bounds", "overroll", "resizable"]);
89
112
  var isForceController = visible !== undefined;
90
113
  var _useState = (0, _react.useState)(isForceController ? visible : true),
91
114
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -106,6 +129,16 @@ var InternalModal = function InternalModal(props, ref) {
106
129
  }
107
130
  modalContainer = document.body;
108
131
  }
132
+ var _useState3 = (0, _react.useState)(modalContainer && !overroll ? {
133
+ x: -(width / 2),
134
+ y: -(height / 2)
135
+ } : {
136
+ x: 0,
137
+ y: 0
138
+ }),
139
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
140
+ position = _useState4[0],
141
+ setPosition = _useState4[1];
109
142
  (0, _hooks.useHideDocumentScrollBar)(isForceController ? !!visible : !!innerVisible, modalContainer === document.body, !!mask);
110
143
  var closeModal = (0, _react.useCallback)(function () {
111
144
  setInnerVisible(false);
@@ -196,6 +229,153 @@ var InternalModal = function InternalModal(props, ref) {
196
229
  document.body.removeEventListener('keydown', escapeToCloseModal);
197
230
  };
198
231
  }, [keyboard, escapeToCloseModal, proxyCloseModal, onCancel]);
232
+ var isResizing = false;
233
+ var initPositionRef = (0, _react.useRef)(initPosition);
234
+ var startResize = (0, _react.useCallback)(function (event) {
235
+ var targetElement = event.target;
236
+ if (!targetElement.classList.contains("".concat(modalPrefixCls, "-resise-handle")) || !containerRef.current) {
237
+ return;
238
+ }
239
+ var _containerRef$current = containerRef.current.getBoundingClientRect(),
240
+ initialWidth = _containerRef$current.width,
241
+ initialHeight = _containerRef$current.height,
242
+ top = _containerRef$current.top,
243
+ left = _containerRef$current.left;
244
+ initPositionRef.current = {
245
+ initialX: event.clientX,
246
+ initialY: event.clientY,
247
+ initialWidth: initialWidth,
248
+ initialHeight: initialHeight,
249
+ top: top,
250
+ left: left,
251
+ x: position.x,
252
+ y: position.y,
253
+ type: targetElement.dataset.type
254
+ };
255
+ event.preventDefault();
256
+ isResizing = true;
257
+ if (overroll && wrapperRef.current) {
258
+ wrapperRef.current.classList.add("".concat(modalPrefixCls, "-wrapper-resizable"));
259
+ setPosition({
260
+ x: left,
261
+ y: top
262
+ });
263
+ initPositionRef.current.x = left;
264
+ initPositionRef.current.y = top;
265
+ }
266
+ document.addEventListener('mousemove', resize);
267
+ document.addEventListener('mouseup', stopResize);
268
+ }, [position]);
269
+ (0, _react.useEffect)(function () {
270
+ if (containerRef.current && visible) {
271
+ containerRef.current.addEventListener('mousedown', startResize);
272
+ }
273
+ return function () {
274
+ if (containerRef.current) {
275
+ containerRef.current.removeEventListener('mousedown', startResize);
276
+ }
277
+ };
278
+ }, [containerRef, startResize, visible]);
279
+ var resize = function resize(event) {
280
+ if (!containerRef.current) return;
281
+ if (!isResizing || !containerRef.current) return;
282
+ var _initPositionRef$curr = initPositionRef.current,
283
+ initialX = _initPositionRef$curr.initialX,
284
+ initialY = _initPositionRef$curr.initialY,
285
+ initialHeight = _initPositionRef$curr.initialHeight,
286
+ initialWidth = _initPositionRef$curr.initialWidth,
287
+ y = _initPositionRef$curr.y,
288
+ x = _initPositionRef$curr.x,
289
+ type = _initPositionRef$curr.type;
290
+ var curNHeight = initialY - event.clientY;
291
+ var curSHeight = -curNHeight;
292
+ var curEWidth = event.clientX - initialX;
293
+ var curWWidth = -curEWidth;
294
+ switch (type) {
295
+ case DragDirection.N:
296
+ {
297
+ containerRef.current.style.height = "".concat(curNHeight + initialHeight, "px");
298
+ setPosition(function (pre) {
299
+ return {
300
+ y: y - curNHeight,
301
+ x: pre.x
302
+ };
303
+ });
304
+ break;
305
+ }
306
+ case DragDirection.E:
307
+ {
308
+ containerRef.current.style.width = "".concat(curEWidth + initialWidth, "px");
309
+ break;
310
+ }
311
+ case DragDirection.S:
312
+ {
313
+ containerRef.current.style.height = "".concat(curSHeight + initialHeight, "px");
314
+ break;
315
+ }
316
+ case DragDirection.W:
317
+ {
318
+ containerRef.current.style.width = "".concat(curWWidth + initialWidth, "px");
319
+ setPosition(function (pre) {
320
+ return {
321
+ y: pre.y,
322
+ x: x - curWWidth
323
+ };
324
+ });
325
+ break;
326
+ }
327
+ case DragDirection.NE:
328
+ {
329
+ containerRef.current.style.height = "".concat(curNHeight + initialHeight, "px");
330
+ containerRef.current.style.width = "".concat(curEWidth + initialWidth, "px");
331
+ setPosition(function (pre) {
332
+ return {
333
+ y: y - curNHeight,
334
+ x: pre.x
335
+ };
336
+ });
337
+ break;
338
+ }
339
+ case DragDirection.NW:
340
+ {
341
+ containerRef.current.style.height = "".concat(curNHeight + initialHeight, "px");
342
+ containerRef.current.style.width = "".concat(curWWidth + initialWidth, "px");
343
+ setPosition({
344
+ y: y - curNHeight,
345
+ x: x - curWWidth
346
+ });
347
+ break;
348
+ }
349
+ case DragDirection.SE:
350
+ {
351
+ containerRef.current.style.height = "".concat(curSHeight + initialHeight, "px");
352
+ containerRef.current.style.width = "".concat(curEWidth + initialWidth, "px");
353
+ break;
354
+ }
355
+ case DragDirection.SW:
356
+ {
357
+ containerRef.current.style.width = "".concat(curWWidth + initialWidth, "px");
358
+ containerRef.current.style.height = "".concat(curSHeight + initialHeight, "px");
359
+ setPosition(function (pre) {
360
+ return {
361
+ y: pre.y,
362
+ x: x - curWWidth
363
+ };
364
+ });
365
+ break;
366
+ }
367
+ default:
368
+ {
369
+ break;
370
+ }
371
+ }
372
+ };
373
+ var stopResize = function stopResize() {
374
+ isResizing = false;
375
+ initPositionRef.current = initPosition;
376
+ document.removeEventListener('mousemove', resize);
377
+ document.removeEventListener('mouseup', stopResize);
378
+ };
199
379
  var handleMaskClick = (0, _react.useCallback)(function () {
200
380
  if (maskClosable) {
201
381
  proxyCloseModal(onCancel);
@@ -218,7 +398,31 @@ var InternalModal = function InternalModal(props, ref) {
218
398
  ref: containerRef,
219
399
  tabIndex: -1,
220
400
  onKeyDown: enterToCloseModal
221
- }, /*#__PURE__*/_react.default.createElement("div", {
401
+ }, resizable && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
402
+ "data-type": "n",
403
+ className: (0, _concat.default)(_context2 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context2, modalPrefixCls, "-resise-n")
404
+ }), /*#__PURE__*/_react.default.createElement("div", {
405
+ "data-type": "e",
406
+ className: (0, _concat.default)(_context3 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context3, modalPrefixCls, "-resise-e")
407
+ }), /*#__PURE__*/_react.default.createElement("div", {
408
+ "data-type": "s",
409
+ className: (0, _concat.default)(_context4 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context4, modalPrefixCls, "-resise-s")
410
+ }), /*#__PURE__*/_react.default.createElement("div", {
411
+ "data-type": "w",
412
+ className: (0, _concat.default)(_context5 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context5, modalPrefixCls, "-resise-w")
413
+ }), /*#__PURE__*/_react.default.createElement("div", {
414
+ "data-type": "ne",
415
+ className: (0, _concat.default)(_context6 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context6, modalPrefixCls, "-resise-ne")
416
+ }), /*#__PURE__*/_react.default.createElement("div", {
417
+ "data-type": "se",
418
+ className: (0, _concat.default)(_context7 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context7, modalPrefixCls, "-resise-se")
419
+ }), /*#__PURE__*/_react.default.createElement("div", {
420
+ "data-type": "sw",
421
+ className: (0, _concat.default)(_context8 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context8, modalPrefixCls, "-resise-sw")
422
+ }), /*#__PURE__*/_react.default.createElement("div", {
423
+ "data-type": "nw",
424
+ className: (0, _concat.default)(_context9 = "".concat(modalPrefixCls, "-resise-handle ")).call(_context9, modalPrefixCls, "-resise-nw")
425
+ })), /*#__PURE__*/_react.default.createElement("div", {
222
426
  className: headerClass
223
427
  }, /*#__PURE__*/_react.default.createElement("div", {
224
428
  className: "".concat(modalPrefixCls, "-title-container")
@@ -237,7 +441,7 @@ var InternalModal = function InternalModal(props, ref) {
237
441
  className: (0, _classnames.default)("".concat(modalPrefixCls, "-body"), bodyClassName),
238
442
  style: bodyStyle
239
443
  }, body), footer !== null && /*#__PURE__*/_react.default.createElement("div", {
240
- className: (0, _classnames.default)("".concat(modalPrefixCls, "-footer"), (0, _concat.default)(_context2 = "".concat(modalPrefixCls, "-")).call(_context2, type, "-footer"), footerClassName),
444
+ className: (0, _classnames.default)("".concat(modalPrefixCls, "-footer"), (0, _concat.default)(_context10 = "".concat(modalPrefixCls, "-")).call(_context10, type, "-footer"), footerClassName),
241
445
  style: (0, _extends2.default)({
242
446
  flexDirection: !footer && (!footerBtnOrder || footerBtnOrder === 'normal') ? 'row' : 'row-reverse'
243
447
  }, footerStyle || {})
@@ -247,12 +451,12 @@ var InternalModal = function InternalModal(props, ref) {
247
451
  var handleDragStart = function handleDragStart(e, data) {
248
452
  onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(e, data);
249
453
  };
250
- var defaultPosition = modalContainer ? {
251
- x: -(width / 2),
252
- y: -(height / 2)
253
- } : {
254
- x: 0,
255
- y: 0
454
+ var handleDrag = function handleDrag(e, ui) {
455
+ setPosition({
456
+ x: ui.x,
457
+ y: ui.y
458
+ });
459
+ onDrag === null || onDrag === void 0 ? void 0 : onDrag(e, ui);
256
460
  };
257
461
  var comp = /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
258
462
  className: modalClasses
@@ -264,30 +468,27 @@ var InternalModal = function InternalModal(props, ref) {
264
468
  tabIndex: -1,
265
469
  className: (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(modalPrefixCls, "-wrapper"), modalContainer && ((isForceController ? visible : innerVisible) || !destroyOnClose))),
266
470
  ref: wrapperRef,
267
- onClick: handleWrapperClick
471
+ onMouseDown: handleWrapperClick
268
472
  }, /*#__PURE__*/_react.default.createElement("div", {
269
473
  className: "".concat(modalPrefixCls, "-dialog")
270
474
  }, /*#__PURE__*/_react.default.createElement(_reactDraggable.default, {
271
- defaultPosition: {
272
- x: 0,
273
- y: 0
274
- },
475
+ position: position,
275
476
  handle: ".".concat(headerClass),
276
477
  disabled: !draggable,
277
478
  onStart: handleDragStart,
278
- onDrag: onDrag,
479
+ onDrag: handleDrag,
279
480
  onStop: onDragStop,
280
481
  bounds: bounds,
281
- cancel: (0, _concat.default)(_context3 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context3, modalPrefixCls, "-close-icon")
482
+ cancel: (0, _concat.default)(_context11 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context11, modalPrefixCls, "-close-icon")
282
483
  }, container))) : /*#__PURE__*/_react.default.createElement(_reactDraggable.default, {
283
- defaultPosition: defaultPosition,
284
484
  handle: ".".concat(headerClass),
285
485
  disabled: !draggable,
486
+ position: position,
286
487
  onStart: handleDragStart,
287
- onDrag: onDrag,
488
+ onDrag: handleDrag,
288
489
  onStop: onDragStop,
289
490
  bounds: bounds,
290
- cancel: (0, _concat.default)(_context4 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context4, modalPrefixCls, "-close-icon")
491
+ cancel: (0, _concat.default)(_context12 = ".".concat(modalPrefixCls, "-title-container, .")).call(_context12, modalPrefixCls, "-close-icon")
291
492
  }, container));
292
493
  var renderComp = ((isForceController ? visible : innerVisible) || !destroyOnClose) && comp;
293
494
  if (modalContainer && renderComp) return /*#__PURE__*/_reactDom.default.createPortal(renderComp, modalContainer);