@arim-aisdc/public-components 2.3.19 → 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.
@@ -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; }
@@ -55,11 +55,14 @@ var CenterModal = function CenterModal(_ref) {
55
55
  minResizeWidth = _ref$minResizeWidth === void 0 ? 200 : _ref$minResizeWidth,
56
56
  _ref$minResizeHeight = _ref.minResizeHeight,
57
57
  minResizeHeight = _ref$minResizeHeight === void 0 ? 200 : _ref$minResizeHeight,
58
+ maxResizeWidth = _ref.maxResizeWidth,
59
+ maxResizeHeight = _ref.maxResizeHeight,
58
60
  rest = _objectWithoutProperties(_ref, _excluded);
59
- var modalRef = useRef(null);
60
61
  var modalBodyRef = useRef(null);
61
- var startSizeRef = useRef();
62
62
  var titleElementRef = useRef();
63
+ var rndRef = useRef(null);
64
+ var contentObserverRef = useRef();
65
+ var modalContentRef = useRef(null);
63
66
  var dragHandleClassName = useMemo(function () {
64
67
  var _titleElementRef$curr;
65
68
  return "drag-handle-".concat((_titleElementRef$curr = titleElementRef.current) === null || _titleElementRef$curr === void 0 ? void 0 : _titleElementRef$curr.length);
@@ -71,16 +74,75 @@ var CenterModal = function CenterModal(_ref) {
71
74
  }
72
75
  }, []);
73
76
  useEffect(function () {
74
- var modal = modalBodyRef.current;
75
- if (modal) {
76
- var rect = modal.getBoundingClientRect();
77
- console.log('rect', rect.width, rect.height);
78
- startSizeRef.current = {
79
- width: rect.width,
80
- 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
81
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
+ });
82
137
  }
83
- }, [modalBodyRef.current]);
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
+ });
144
+ }
145
+ };
84
146
  return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
85
147
  className: "centerModal".concat(size),
86
148
  wrapClassName: 'wrapClassName',
@@ -114,7 +176,7 @@ var CenterModal = function CenterModal(_ref) {
114
176
  width: width,
115
177
  modalRender: function modalRender(modal) {
116
178
  return /*#__PURE__*/_jsx(Rnd, {
117
- ref: modalRef,
179
+ ref: rndRef,
118
180
  enableResizing: enableResizing,
119
181
  disableDragging: !enableDragging,
120
182
  resizeHandleWrapperClass: "resizeHandles",
@@ -126,23 +188,18 @@ var CenterModal = function CenterModal(_ref) {
126
188
  width: 'fit-content',
127
189
  height: 'fit-content'
128
190
  },
129
- onResizeStop: function onResizeStop(e, direction, ref, delta, position) {
130
- var _ref$querySelector;
131
- if (direction === 'left' || direction === 'right') return;
132
- var modalContent = (_ref$querySelector = ref.querySelector('.ant-modal-content')) === null || _ref$querySelector === void 0 ? void 0 : _ref$querySelector.getBoundingClientRect();
133
- var resizeContent = ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect();
134
- var height = modalContent.height;
135
- if (modalContent.height !== resizeContent.height) {
136
- ref.style.height = height + "px";
137
- }
138
- },
191
+ onResizeStop: adjustResize,
192
+ onResize: adjustResize,
139
193
  style: {
140
194
  display: 'flex',
141
195
  flexDirection: 'column',
142
196
  overflow: 'hidden' // 添加overflow隐藏
143
197
  },
144
198
  minWidth: minResizeWidth,
145
- minHeight: minResizeHeight,
199
+ minHeight: minResizeHeight
200
+ // maxWidth={maxResizeWidth}
201
+ // maxHeight={maxResizeHeight}
202
+ ,
146
203
  children: modal
147
204
  });
148
205
  }
@@ -7,6 +7,8 @@
7
7
  .ant-modal-content {
8
8
  display: flex;
9
9
  flex-direction: column;
10
+ height: 100%;
11
+ overflow: hidden;
10
12
 
11
13
  .ant-modal-body {
12
14
  flex: 1;
@@ -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;
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
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;
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;
6
6
  declare const customSortFns: {
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;
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;
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.19",
3
+ "version": "2.3.20",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",