@arim-aisdc/public-components 2.3.20 → 2.3.22

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.
@@ -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", "maxResizeWidth", "maxResizeHeight"];
2
+ var _excluded = ["open", "title", "okText", "hasfooter", "footer", "width", "height", "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; }
@@ -33,6 +33,7 @@ var CenterModal = function CenterModal(_ref) {
33
33
  footer = _ref.footer,
34
34
  _ref$width = _ref.width,
35
35
  width = _ref$width === void 0 ? 500 : _ref$width,
36
+ height = _ref.height,
36
37
  _ref$size = _ref.size,
37
38
  size = _ref$size === void 0 ? '' : _ref$size,
38
39
  renderContent = _ref.renderContent,
@@ -41,7 +42,7 @@ var CenterModal = function CenterModal(_ref) {
41
42
  _ref$confirmLoading = _ref.confirmLoading,
42
43
  confirmLoading = _ref$confirmLoading === void 0 ? false : _ref$confirmLoading,
43
44
  _ref$maskClosable = _ref.maskClosable,
44
- maskClosable = _ref$maskClosable === void 0 ? true : _ref$maskClosable,
45
+ maskClosable = _ref$maskClosable === void 0 ? false : _ref$maskClosable,
45
46
  _ref$bodyStyle = _ref.bodyStyle,
46
47
  bodyStyle = _ref$bodyStyle === void 0 ? {
47
48
  position: 'relative'
@@ -54,76 +55,110 @@ var CenterModal = function CenterModal(_ref) {
54
55
  _ref$minResizeWidth = _ref.minResizeWidth,
55
56
  minResizeWidth = _ref$minResizeWidth === void 0 ? 200 : _ref$minResizeWidth,
56
57
  _ref$minResizeHeight = _ref.minResizeHeight,
57
- minResizeHeight = _ref$minResizeHeight === void 0 ? 200 : _ref$minResizeHeight,
58
- maxResizeWidth = _ref.maxResizeWidth,
58
+ minResizeHeight = _ref$minResizeHeight === void 0 ? 50 : _ref$minResizeHeight,
59
+ _ref$maxResizeWidth = _ref.maxResizeWidth,
60
+ maxResizeWidth = _ref$maxResizeWidth === void 0 ? 1800 : _ref$maxResizeWidth,
59
61
  maxResizeHeight = _ref.maxResizeHeight,
60
62
  rest = _objectWithoutProperties(_ref, _excluded);
61
63
  var modalBodyRef = useRef(null);
62
- var titleElementRef = useRef();
64
+ var modalBodySizeRef = useRef(null);
63
65
  var rndRef = useRef(null);
64
66
  var contentObserverRef = useRef();
65
67
  var modalContentRef = useRef(null);
68
+ var hasResized = useRef(false);
66
69
  var dragHandleClassName = useMemo(function () {
67
- var _titleElementRef$curr;
68
- return "drag-handle-".concat((_titleElementRef$curr = titleElementRef.current) === null || _titleElementRef$curr === void 0 ? void 0 : _titleElementRef$curr.length);
69
- }, [titleElementRef.current]);
70
- useEffect(function () {
71
70
  var titleElements = document.querySelectorAll('.modal-header');
72
- if (titleElements) {
73
- titleElementRef.current = titleElements;
74
- }
75
- }, []);
71
+ if (!open || !titleElements) return "drag-handle";
72
+ return "drag-handle-".concat(titleElements.length);
73
+ }, [open]);
76
74
  useEffect(function () {
77
- if (!open) {
75
+ var timer;
76
+ var cleanup = function cleanup() {
78
77
  var _contentObserverRef$c;
79
- // 关闭时清理 observer
78
+ clearTimeout(timer);
80
79
  (_contentObserverRef$c = contentObserverRef.current) === null || _contentObserverRef$c === void 0 || _contentObserverRef$c.disconnect();
80
+ };
81
+ if (!open) {
82
+ cleanup();
81
83
  return;
82
84
  }
85
+ timer = setTimeout(function () {
86
+ if (height) {
87
+ var _modalContentRef$curr, _rndRef$current;
88
+ var contentRect = (_modalContentRef$curr = modalContentRef.current) === null || _modalContentRef$curr === void 0 ? void 0 : _modalContentRef$curr.getBoundingClientRect();
89
+ if (!contentRect) return;
90
+ (_rndRef$current = rndRef.current) === null || _rndRef$current === void 0 || _rndRef$current.updateSize({
91
+ width: formatSize(width, contentRect.width),
92
+ height: formatSize(height, contentRect.height)
93
+ });
94
+ return;
95
+ }
96
+ if (!modalContentRef.current || !rndRef.current || !modalBodyRef.current) return;
83
97
 
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
- // 初始化同步尺寸
98
+ // Initialize size synchronization
91
99
  syncSizeIfNeeded();
92
100
 
93
- // 设置 ResizeObserver 监听内容区域尺寸变化
94
- contentObserverRef.current = new ResizeObserver(function () {
95
- syncSizeIfNeeded();
96
- });
97
- contentObserverRef.current.observe(modalContent);
101
+ // Set up ResizeObserver for content area
102
+ contentObserverRef.current = new ResizeObserver(syncSizeIfNeeded);
103
+ contentObserverRef.current.observe(modalBodyRef.current);
98
104
  }, 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
+ return cleanup;
106
+ }, [open, height, width]);
107
+
108
+ // Helper function to format size values
109
+ var formatSize = function formatSize(size, defaultSize) {
110
+ if (typeof size === 'string') return size;
111
+ if (typeof size === 'number') return "".concat(size, "px");
112
+ return defaultSize;
113
+ };
105
114
 
106
- // 同步尺寸的逻辑
115
+ // Optimized size synchronization logic
107
116
  var syncSizeIfNeeded = function syncSizeIfNeeded() {
108
117
  if (!rndRef.current || !modalContentRef.current) return;
109
118
  var rndElement = rndRef.current.getSelfElement();
110
119
  var contentRect = modalContentRef.current.getBoundingClientRect();
111
-
112
- // 检查 Rnd 是否已经设置了显式的 width/height 样式
120
+ var bodyRect = modalBodyRef.current;
121
+ var documentRect = document.body.getBoundingClientRect();
113
122
  var hasExplicitWidth = rndElement.style.width !== '';
114
123
  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
124
+ var rndElementWidth = Number(rndElement.style.width.split('px')[0]);
125
+ var rndElementHeight = Number(rndElement.style.height.split('px')[0]);
126
+ var needsSync = !hasExplicitWidth || !hasExplicitHeight;
127
+ var maxHeight = documentRect.height - contentRect.top - 24;
128
+ if (needsSync) {
129
+ rndRef.current.updateSize({
130
+ width: width || !hasExplicitWidth ? Math.ceil(contentRect.width) : undefined,
131
+ height: !hasExplicitHeight ? Math.min(Math.ceil(contentRect.height), maxHeight) : undefined
132
+ });
133
+ modalBodySizeRef.current = {
134
+ width: bodyRect.scrollWidth,
135
+ height: bodyRect.scrollHeight
121
136
  };
122
- rndRef.current.updateSize(updates);
137
+ return;
138
+ }
139
+ if (!hasResized.current && modalBodySizeRef.current) {
140
+ var widthDiff = Math.abs(modalBodySizeRef.current.width - bodyRect.scrollWidth);
141
+ var heightDiff = Math.abs(modalBodySizeRef.current.height - bodyRect.scrollHeight);
142
+ var significantChange = widthDiff > 5 || heightDiff > 5;
143
+ if (significantChange) {
144
+ var delta = {
145
+ width: bodyRect.scrollWidth - modalBodySizeRef.current.width,
146
+ height: bodyRect.scrollHeight - modalBodySizeRef.current.height
147
+ };
148
+ rndRef.current.updateSize({
149
+ width: width || Math.ceil(rndElementWidth + delta.width),
150
+ height: Math.min(Math.ceil(rndElementHeight + delta.height), maxHeight)
151
+ });
152
+ modalBodySizeRef.current = {
153
+ width: bodyRect.scrollWidth,
154
+ height: bodyRect.scrollHeight
155
+ };
156
+ }
123
157
  }
124
158
  };
125
159
  var adjustResize = function adjustResize(e, direction, ref, delta, position) {
126
160
  var _ref$querySelector, _ref$style$height, _ref$style$width;
161
+ hasResized.current = true;
127
162
  var modalContent = (_ref$querySelector = ref.querySelector('.ant-modal-content')) === null || _ref$querySelector === void 0 ? void 0 : _ref$querySelector.getBoundingClientRect();
128
163
  var modalContentHeight = Math.ceil(modalContent.height);
129
164
  var modalContentWidth = Math.ceil(modalContent.width);
@@ -144,7 +179,7 @@ var CenterModal = function CenterModal(_ref) {
144
179
  }
145
180
  };
146
181
  return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
147
- className: "centerModal".concat(size),
182
+ className: "centerModalContainer centerModal".concat(size),
148
183
  wrapClassName: 'wrapClassName',
149
184
  title: /*#__PURE__*/_jsx("div", {
150
185
  className: "modal-header ".concat(dragHandleClassName),
@@ -196,16 +231,26 @@ var CenterModal = function CenterModal(_ref) {
196
231
  overflow: 'hidden' // 添加overflow隐藏
197
232
  },
198
233
  minWidth: minResizeWidth,
199
- minHeight: minResizeHeight
200
- // maxWidth={maxResizeWidth}
201
- // maxHeight={maxResizeHeight}
202
- ,
203
- children: modal
234
+ minHeight: minResizeHeight,
235
+ maxWidth: maxResizeWidth,
236
+ maxHeight: maxResizeHeight,
237
+ children: /*#__PURE__*/_jsx("div", {
238
+ ref: modalContentRef,
239
+ className: "custom-modal-content",
240
+ style: {
241
+ height: '100%'
242
+ },
243
+ children: modal
244
+ })
204
245
  });
205
246
  }
206
247
  }, rest), {}, {
207
248
  children: /*#__PURE__*/_jsx("div", {
208
249
  ref: modalBodyRef,
250
+ className: "custom-modal-body",
251
+ style: {
252
+ height: height ? '100%' : 'fit-content'
253
+ },
209
254
  children: renderContent || /*#__PURE__*/_jsx("div", {
210
255
  className: "gantt-leftbar-defalutItem"
211
256
  })
@@ -1,4 +1,6 @@
1
- .centerModal {
1
+
2
+
3
+ .centerModalContainer {
2
4
  .resizeHandles div {
3
5
  pointer-events: auto;
4
6
  z-index: 1002;
@@ -18,6 +20,10 @@
18
20
 
19
21
  .react-draggable {
20
22
  position: relative !important;
23
+
24
+ .custom-modal-body {
25
+ height: fit-content;
26
+ }
21
27
  }
22
28
 
23
29
  .resizeHandleBottomLeft, .resizeHandleBottomRight, .resizeHandleTopLeft, .resizeHandleTopRight {
@@ -27,6 +27,7 @@ export interface CenterModalPropsType extends ModalProps {
27
27
  minResizeHeight?: string | number;
28
28
  maxResizeWidth?: string | number;
29
29
  maxResizeHeight?: string | number;
30
+ height?: string | number;
30
31
  }
31
32
  export type ModalSizeType = {
32
33
  width: number | string;
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.20",
3
+ "version": "2.3.22",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",