@pointcloud/pcloud-components 1.0.1 → 1.0.2

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.
@@ -125,14 +125,10 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
125
125
  _useState12 = _slicedToArray(_useState11, 2),
126
126
  conditionVisible = _useState12[0],
127
127
  setConditionVisible = _useState12[1];
128
- var _useState13 = useState(0),
128
+ var _useState13 = useState(props.tableProps || {}),
129
129
  _useState14 = _slicedToArray(_useState13, 2),
130
- refreshKey = _useState14[0],
131
- setRefreshKey = _useState14[1];
132
- var _useState15 = useState(props.tableProps || {}),
133
- _useState16 = _slicedToArray(_useState15, 2),
134
- tablePropsState = _useState16[0],
135
- setTablePropsState = _useState16[1];
130
+ tablePropsState = _useState14[0],
131
+ setTablePropsState = _useState14[1];
136
132
  var originalColumnsRef = useRef(((_props$tableProps = props.tableProps) === null || _props$tableProps === void 0 ? void 0 : _props$tableProps.columns) || []);
137
133
  var _DForm$useForm = DForm.useForm(),
138
134
  _DForm$useForm2 = _slicedToArray(_DForm$useForm, 1),
@@ -307,12 +303,11 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
307
303
  var _tableRef$current2, _tableRef$current2$re;
308
304
  (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 || (_tableRef$current2$re = _tableRef$current2.refreshToPage) === null || _tableRef$current2$re === void 0 || _tableRef$current2$re.call(_tableRef$current2, refreshOptions.targetPage);
309
305
  } else if (!finalStrategy.keepPage) {
310
- setRefreshKey(function (prev) {
311
- return prev + 1;
312
- });
313
- } else {
314
306
  var _tableRef$current3;
315
- (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 || _tableRef$current3.refresh();
307
+ (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 || _tableRef$current3.refreshToPage(1);
308
+ } else {
309
+ var _tableRef$current4;
310
+ (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 || _tableRef$current4.refresh();
316
311
  }
317
312
  onRefresh === null || onRefresh === void 0 || onRefresh();
318
313
  }, [memoizedRefreshStrategy, onRefresh, form]);
@@ -673,7 +668,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
673
668
  ref: tableRef
674
669
  }, tablePropsWithSearch), {}, {
675
670
  className: "".concat(classname, "-table")
676
- }), refreshKey), mergedModalFormProps && /*#__PURE__*/_jsx(ModalForm, _objectSpread({}, mergedModalFormProps))]
671
+ })), mergedModalFormProps && /*#__PURE__*/_jsx(ModalForm, _objectSpread({}, mergedModalFormProps))]
677
672
  });
678
673
  });
679
674
  export default forwardCRUD;
@@ -57,6 +57,10 @@ interface ISLProps<T, P> {
57
57
  * @description 列表底部提示
58
58
  */
59
59
  endMessage?: React.ReactNode;
60
+ /**
61
+ * @description 列表项点击事件
62
+ */
63
+ onItemClick?: (item: P, index: number) => void;
60
64
  }
61
65
  export type InfiniteScrollListProps<T, P> = ISLProps<T, P>;
62
66
  declare const _default: React.MemoExoticComponent<(<T, P>(props: ISLProps<T, P>) => import("react/jsx-runtime").JSX.Element)>;
@@ -32,7 +32,8 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
32
32
  _props$showBackTop = props.showBackTop,
33
33
  showBackTop = _props$showBackTop === void 0 ? true : _props$showBackTop,
34
34
  endMessage = props.endMessage,
35
- _renderItem = props.renderItem;
35
+ _renderItem = props.renderItem,
36
+ onItemClick = props.onItemClick;
36
37
  var _useContext = useContext(ConfigContext),
37
38
  prefixCls = _useContext.prefixCls,
38
39
  getPrefixCls = _useContext.getPrefixCls;
@@ -51,6 +52,7 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
51
52
  _useState2 = _slicedToArray(_useState, 2),
52
53
  listData = _useState2[0],
53
54
  setListData = _useState2[1];
55
+ var listDataRef = useRef(listData);
54
56
  var handleLoadMore = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
55
57
  var _yield$loadMore, data, total, records;
56
58
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -104,12 +106,30 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
104
106
  }
105
107
  }, _callee, null, [[3, 13, 17, 20]]);
106
108
  })), [loadMore]);
109
+ var handleItemClick = useCallback(function (e) {
110
+ var _itemElement$dataset, _listDataRef$current;
111
+ e.stopPropagation();
112
+ e.preventDefault();
113
+ var targetElement = e.target;
114
+ var itemElement = targetElement.closest('[data-key]');
115
+ var key = itemElement === null || itemElement === void 0 || (_itemElement$dataset = itemElement.dataset) === null || _itemElement$dataset === void 0 ? void 0 : _itemElement$dataset.key;
116
+ if (key && ((_listDataRef$current = listDataRef.current) === null || _listDataRef$current === void 0 || (_listDataRef$current = _listDataRef$current.data) === null || _listDataRef$current === void 0 ? void 0 : _listDataRef$current.length) > 0) {
117
+ var _listDataRef$current$;
118
+ var _index = listDataRef.current.data.findIndex(function (item, index) {
119
+ return item[itemKey] === key || index === Number(key);
120
+ });
121
+ if (_index >= 0 && _index < ((_listDataRef$current$ = listDataRef.current.data) === null || _listDataRef$current$ === void 0 ? void 0 : _listDataRef$current$.length)) {
122
+ onItemClick === null || onItemClick === void 0 || onItemClick(listDataRef.current.data[_index], _index);
123
+ }
124
+ }
125
+ }, [itemKey, onItemClick]);
107
126
  useEffect(function () {
108
127
  if (listData.total > 0 && listData.data.length < listData.total) {
109
128
  pageParamsRef.current = _objectSpread(_objectSpread({}, pageParamsRef.current), {}, {
110
129
  current: pageParamsRef.current.current + 1
111
130
  });
112
131
  }
132
+ listDataRef.current = listData;
113
133
  }, [listData]);
114
134
  useEffect(function () {
115
135
  var currentInitialParams = initialParams && _typeof(initialParams) === 'object' ? initialParams : {};
@@ -133,6 +153,7 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
133
153
  style: {
134
154
  height: containerHeight
135
155
  },
156
+ onClick: handleItemClick,
136
157
  children: [/*#__PURE__*/_jsx(InfiniteScroll, {
137
158
  className: "".concat(wrapperClass, " ").concat(className),
138
159
  style: {
@@ -161,8 +182,9 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
161
182
  dataSource: listData.data,
162
183
  renderItem: function renderItem(item, index) {
163
184
  return /*#__PURE__*/_jsx(List.Item, {
185
+ "data-key": item[itemKey] || index,
164
186
  children: _renderItem(item, index)
165
- }, item[itemKey]);
187
+ }, item[itemKey] || index);
166
188
  }
167
189
  })
168
190
  }), showBackTop && /*#__PURE__*/_jsx(BackTop, {