@arim-aisdc/public-components 2.3.18 → 2.3.20

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.
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
17
17
  value: any;
18
18
  field: string;
19
19
  label?: string;
20
- text: string | Element | JSX.Element;
20
+ text: string | JSX.Element | Element;
21
21
  units?: string;
22
22
  width?: string;
23
23
  labelWidth?: string;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["open", "title", "okText", "hasfooter", "footer", "width", "size", "renderContent", "handleConfirm", "handleCancel", "confirmLoading", "maskClosable", "bodyStyle", "afterClose", "enableResizing", "enableDragging", "minResizeWidth", "minResizeHeight"];
2
+ var _excluded = ["open", "title", "okText", "hasfooter", "footer", "width", "size", "renderContent", "handleConfirm", "handleCancel", "confirmLoading", "maskClosable", "bodyStyle", "afterClose", "enableResizing", "enableDragging", "minResizeWidth", "minResizeHeight", "maxResizeWidth", "maxResizeHeight"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -12,6 +12,16 @@ import React, { useEffect, useMemo, useRef } from 'react';
12
12
  import { Rnd } from 'react-rnd';
13
13
  import "./index.less";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ var resizeHandleClasses = {
16
+ bottom: "resizeHandleBottom",
17
+ bottomLeft: "resizeHandleBottomLeft",
18
+ bottomRight: "resizeHandleBottomRight",
19
+ left: "resizeHandleLeft",
20
+ right: "resizeHandleRight",
21
+ top: "resizeHandleTop",
22
+ topLeft: "resizeHandleTopLeft",
23
+ topRight: "resizeHandleTopRight"
24
+ };
15
25
  var CenterModal = function CenterModal(_ref) {
16
26
  var _ref$open = _ref.open,
17
27
  open = _ref$open === void 0 ? false : _ref$open,
@@ -45,11 +55,14 @@ var CenterModal = function CenterModal(_ref) {
45
55
  minResizeWidth = _ref$minResizeWidth === void 0 ? 200 : _ref$minResizeWidth,
46
56
  _ref$minResizeHeight = _ref.minResizeHeight,
47
57
  minResizeHeight = _ref$minResizeHeight === void 0 ? 200 : _ref$minResizeHeight,
58
+ maxResizeWidth = _ref.maxResizeWidth,
59
+ maxResizeHeight = _ref.maxResizeHeight,
48
60
  rest = _objectWithoutProperties(_ref, _excluded);
49
- var modalRef = useRef(null);
50
61
  var modalBodyRef = useRef(null);
51
- var startSizeRef = useRef();
52
62
  var titleElementRef = useRef();
63
+ var rndRef = useRef(null);
64
+ var contentObserverRef = useRef();
65
+ var modalContentRef = useRef(null);
53
66
  var dragHandleClassName = useMemo(function () {
54
67
  var _titleElementRef$curr;
55
68
  return "drag-handle-".concat((_titleElementRef$curr = titleElementRef.current) === null || _titleElementRef$curr === void 0 ? void 0 : _titleElementRef$curr.length);
@@ -61,18 +74,78 @@ var CenterModal = function CenterModal(_ref) {
61
74
  }
62
75
  }, []);
63
76
  useEffect(function () {
64
- var modal = modalBodyRef.current;
65
- if (modal) {
66
- var rect = modal.getBoundingClientRect();
67
- console.log('rect', rect.width, rect.height);
68
- startSizeRef.current = {
69
- width: rect.width,
70
- height: rect.height
77
+ if (!open) {
78
+ var _contentObserverRef$c;
79
+ // 关闭时清理 observer
80
+ (_contentObserverRef$c = contentObserverRef.current) === null || _contentObserverRef$c === void 0 || _contentObserverRef$c.disconnect();
81
+ return;
82
+ }
83
+
84
+ // 等待 Modal 渲染完成
85
+ var timer = setTimeout(function () {
86
+ var modalContent = document.querySelector('.ant-modal-content');
87
+ if (!modalContent || !rndRef.current) return;
88
+ modalContentRef.current = modalContent;
89
+
90
+ // 初始化同步尺寸
91
+ syncSizeIfNeeded();
92
+
93
+ // 设置 ResizeObserver 监听内容区域尺寸变化
94
+ contentObserverRef.current = new ResizeObserver(function () {
95
+ syncSizeIfNeeded();
96
+ });
97
+ contentObserverRef.current.observe(modalContent);
98
+ }, 0);
99
+ return function () {
100
+ var _contentObserverRef$c2;
101
+ clearTimeout(timer);
102
+ (_contentObserverRef$c2 = contentObserverRef.current) === null || _contentObserverRef$c2 === void 0 || _contentObserverRef$c2.disconnect();
103
+ };
104
+ }, [open]);
105
+
106
+ // 同步尺寸的逻辑
107
+ var syncSizeIfNeeded = function syncSizeIfNeeded() {
108
+ if (!rndRef.current || !modalContentRef.current) return;
109
+ var rndElement = rndRef.current.getSelfElement();
110
+ var contentRect = modalContentRef.current.getBoundingClientRect();
111
+
112
+ // 检查 Rnd 是否已经设置了显式的 width/height 样式
113
+ var hasExplicitWidth = rndElement.style.width !== '';
114
+ var hasExplicitHeight = rndElement.style.height !== '';
115
+
116
+ // 如果没有设置,则同步尺寸
117
+ if (!hasExplicitWidth || !hasExplicitHeight) {
118
+ var updates = {
119
+ width: !hasExplicitWidth ? Math.ceil(contentRect.width) : undefined,
120
+ height: !hasExplicitHeight ? Math.ceil(contentRect.height) : undefined
71
121
  };
122
+ rndRef.current.updateSize(updates);
123
+ }
124
+ };
125
+ var adjustResize = function adjustResize(e, direction, ref, delta, position) {
126
+ var _ref$querySelector, _ref$style$height, _ref$style$width;
127
+ var modalContent = (_ref$querySelector = ref.querySelector('.ant-modal-content')) === null || _ref$querySelector === void 0 ? void 0 : _ref$querySelector.getBoundingClientRect();
128
+ var modalContentHeight = Math.ceil(modalContent.height);
129
+ var modalContentWidth = Math.ceil(modalContent.width);
130
+ var refHeight = Number((_ref$style$height = ref.style.height) === null || _ref$style$height === void 0 || (_ref$style$height = _ref$style$height.split('px')) === null || _ref$style$height === void 0 ? void 0 : _ref$style$height[0]);
131
+ var refWidth = Number((_ref$style$width = ref.style.width) === null || _ref$style$width === void 0 || (_ref$style$width = _ref$style$width.split('px')) === null || _ref$style$width === void 0 ? void 0 : _ref$style$width[0]);
132
+ if ((direction === 'left' || direction === 'right') && modalContentHeight !== refHeight) {
133
+ rndRef.current.updateSize({
134
+ width: ref.style.width,
135
+ height: modalContentHeight + 'px'
136
+ });
137
+ }
138
+ if ((direction === 'top' || direction === 'bottom') && modalContentWidth !== refWidth) {
139
+ ref.style.width = modalContentWidth + 'px';
140
+ rndRef.current.updateSize({
141
+ width: modalContentWidth + 'px',
142
+ height: ref.style.height
143
+ });
72
144
  }
73
- }, [modalBodyRef.current]);
145
+ };
74
146
  return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
75
147
  className: "centerModal".concat(size),
148
+ wrapClassName: 'wrapClassName',
76
149
  title: /*#__PURE__*/_jsx("div", {
77
150
  className: "modal-header ".concat(dragHandleClassName),
78
151
  style: {
@@ -103,10 +176,11 @@ var CenterModal = function CenterModal(_ref) {
103
176
  width: width,
104
177
  modalRender: function modalRender(modal) {
105
178
  return /*#__PURE__*/_jsx(Rnd, {
106
- ref: modalRef,
179
+ ref: rndRef,
107
180
  enableResizing: enableResizing,
108
181
  disableDragging: !enableDragging,
109
182
  resizeHandleWrapperClass: "resizeHandles",
183
+ resizeHandleClasses: resizeHandleClasses,
110
184
  dragHandleClassName: dragHandleClassName,
111
185
  default: {
112
186
  x: 0,
@@ -114,13 +188,18 @@ var CenterModal = function CenterModal(_ref) {
114
188
  width: 'fit-content',
115
189
  height: 'fit-content'
116
190
  },
191
+ onResizeStop: adjustResize,
192
+ onResize: adjustResize,
117
193
  style: {
118
194
  display: 'flex',
119
195
  flexDirection: 'column',
120
196
  overflow: 'hidden' // 添加overflow隐藏
121
197
  },
122
198
  minWidth: minResizeWidth,
123
- minHeight: minResizeHeight,
199
+ minHeight: minResizeHeight
200
+ // maxWidth={maxResizeWidth}
201
+ // maxHeight={maxResizeHeight}
202
+ ,
124
203
  children: modal
125
204
  });
126
205
  }
@@ -1,89 +1,14 @@
1
- .custom-light-modal {
2
- top: 0 !important;
3
- left: 0 !important;
4
- height: 'none' !important;
5
- }
6
-
7
- .ant-design-draggable-modal-resize-handle {
8
- display: none;
9
-
10
- .ant-design-draggable-modal .ant-design-draggable-modal-title {
11
- padding: 0;
12
- }
13
- }
14
-
15
- .centerModal {
16
- .ant-modal-content {
17
- resize: none; /* disable default resize */
18
- overflow: hidden;
19
- }
20
- }
21
-
22
- .resize-handle {
23
- opacity: 0.6;
24
- transition: opacity 0.2s;
25
-
26
- &:hover {
27
- opacity: 1;
28
- border-color: #40a9ff;
29
- }
30
- }
31
-
32
- .is-resizing .resize-handle {
33
- opacity: 1;
34
- border-color: #096dd9 !important;
35
- }
36
-
37
-
38
-
39
1
  .centerModal {
40
- .react-resizable {
41
- position: absolute !important;
42
- }
43
-
44
- .react-rnd {
45
- border: 1px solid #d9d9d9;
46
- border-radius: 6px;
47
- overflow: hidden;
48
- background: #fff;
49
- box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12),
50
- 0 6px 16px 0 rgba(0, 0, 0, 0.08),
51
- 0 9px 28px 8px rgba(0, 0, 0, 0.05);
52
- }
53
-
54
- .resize-handle {
55
- position: absolute;
56
- right: 0;
57
- bottom: 0;
58
- width: 16px;
59
- height: 16px;
60
- cursor: nwse-resize;
61
- background: transparent;
62
- border-right: 2px solid #1890ff;
63
- border-bottom: 2px solid #1890ff;
64
- z-index: 1001;
65
- opacity: 0.7;
66
- transition: opacity 0.2s;
67
-
68
- &:hover {
69
- opacity: 1;
70
- border-color: #40a9ff;
71
- }
72
- }
73
-
74
- .ant-modal-body {
75
- padding: 0 !important;
76
- }
77
-
78
2
  .resizeHandles div {
79
3
  pointer-events: auto;
80
4
  z-index: 1002;
81
5
  }
82
6
 
83
-
84
7
  .ant-modal-content {
85
8
  display: flex;
86
9
  flex-direction: column;
10
+ height: 100%;
11
+ overflow: hidden;
87
12
 
88
13
  .ant-modal-body {
89
14
  flex: 1;
@@ -94,8 +19,17 @@
94
19
  .react-draggable {
95
20
  position: relative !important;
96
21
  }
97
- }
98
22
 
99
- .react-draggable {
100
- position: relative;
101
- }
23
+ .resizeHandleBottomLeft, .resizeHandleBottomRight, .resizeHandleTopLeft, .resizeHandleTopRight {
24
+ width: 40px !important;
25
+ height: 40px !important;
26
+ }
27
+
28
+ // .resizeHandleLeft, .resizeHandleRight {
29
+ // width: 20px !important;
30
+ // }
31
+
32
+ // .resizeHandleTop, .resizeHandleBottom {
33
+ // height: 20px !important;
34
+ // }
35
+ }
@@ -25,6 +25,8 @@ export interface CenterModalPropsType extends ModalProps {
25
25
  enableDragging?: boolean;
26
26
  minResizeWidth?: string | number;
27
27
  minResizeHeight?: string | number;
28
+ maxResizeWidth?: string | number;
29
+ maxResizeHeight?: string | number;
28
30
  }
29
31
  export type ModalSizeType = {
30
32
  width: number | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.18",
3
+ "version": "2.3.20",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",