linkmore-design 1.1.27-alpha.1 → 1.1.27-alpha.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.
@@ -15,6 +15,7 @@ interface ILmEditTable extends TableProps<any> {
15
15
  size?: TableProps<any>['size'];
16
16
  colSortOpen?: boolean;
17
17
  indexCol?: boolean | Record<string, any>;
18
+ autoSizer?: boolean;
18
19
  filterChange?: (data: TableProps<any>['columns']) => void;
19
20
  recordCreatorProps?: {
20
21
  creatorButtonText?: string;
@@ -27,6 +28,9 @@ interface ILmEditTable extends TableProps<any> {
27
28
  rowSelection?: TableProps<any>['rowSelection'] & {
28
29
  selectedRows?: Record<string, any>;
29
30
  };
31
+ rowDisabled?: {
32
+ disabledRows?: Record<string, any>;
33
+ };
30
34
  }
31
35
  export interface CountdownHandle {
32
36
  setRow: (data: any) => void;
@@ -9,7 +9,9 @@ export declare function checkExpandIconColumnIndex({ rowSelection, sortOpen, ind
9
9
  sortOpen: any;
10
10
  indexCol: any;
11
11
  }): number;
12
- export declare function checkDataSourceIsEmpty(config: any, dataSource: any): any;
12
+ export declare function checkDataSourceIsEmpty(config: any, dataSource: any, scrollInfo: any): any;
13
+ /** 根据传入的disabedRows, 得出最终需要disabed的rowKeys */
14
+ export declare function checkTableRowIsDisable(deepDataSource: any, disabledRows: any, rowKey: any): any[];
13
15
  declare const _default: {
14
16
  isObjEmpty: typeof isObjEmpty;
15
17
  };
package/dist/index.umd.js CHANGED
@@ -91007,8 +91007,9 @@
91007
91007
  // 二级过滤 => 基础过滤组件
91008
91008
  var LmFilterBase = /*#__PURE__*/React__default['default'].memo(function (_ref) {
91009
91009
  var instance = _ref.instance;
91010
- var dataSource = instance.dataSource;
91011
- return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(FuzzySearch, {
91010
+ var dataSource = instance.dataSource,
91011
+ enableSearch = instance.enableSearch;
91012
+ return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, enableSearch && /*#__PURE__*/React__default['default'].createElement(FuzzySearch, {
91012
91013
  instance: instance
91013
91014
  }), dataSource.map(function (v, index) {
91014
91015
  var isHidden = !v.show && typeof v.show === 'boolean';
@@ -92881,6 +92882,7 @@
92881
92882
 
92882
92883
  if (getIsHas(itemValue) && !!item) {
92883
92884
  return [].concat(_toConsumableArray$1(pre), [{
92885
+ relation: obj[cur].mode || 'and',
92884
92886
  fieldName: cur,
92885
92887
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
92886
92888
  type: item.type,
@@ -92890,7 +92892,7 @@
92890
92892
  * and 等同于逻辑关系contains: 选中的值包含所有值
92891
92893
  * or 等同于逻辑关系in: 选中的值存在于所有值之中
92892
92894
  */
92893
- operator: obj[cur].mode === 'and' ? 'contains' : 'in'
92895
+ operator: 'in'
92894
92896
  }]);
92895
92897
  }
92896
92898
 
@@ -93056,11 +93058,12 @@
93056
93058
  if (getIsHas(itemValue) && !!item) {
93057
93059
  // eslint-disable-next-line no-param-reassign
93058
93060
  pre[cur] = {
93061
+ relation: complexFilter[cur].mode || 'and',
93059
93062
  fieldName: cur,
93060
93063
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
93061
93064
  type: item.type,
93062
93065
  value: Array.isArray(itemValue) ? itemValue : [itemValue],
93063
- operator: complexFilter[cur].mode === 'and' ? 'contains' : 'in'
93066
+ operator: 'in'
93064
93067
  };
93065
93068
  }
93066
93069
 
@@ -182040,7 +182043,7 @@
182040
182043
  var isUploading = getUploadStatus().uploading;
182041
182044
  if (isUploading) return;
182042
182045
  inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
182043
- }, [getUploadStatus]); // 上传触发事件
182046
+ }, [disabled, getUploadStatus]); // 上传触发事件
182044
182047
 
182045
182048
  var uploadChange = React.useCallback(function (e) {
182046
182049
  var _inputRef$current2;
@@ -288702,14 +288705,18 @@
288702
288705
  }));
288703
288706
  };
288704
288707
 
288705
- var _excluded$2g = ["children"],
288708
+ var _excluded$2g = ["children", "disabled"],
288706
288709
  _excluded2$y = ["children", "size", "buttonStyle", "direction", "className"];
288707
288710
 
288708
288711
  var LMRadio = function LMRadio(props) {
288709
288712
  var children = props.children,
288713
+ customDisabled = props.disabled,
288710
288714
  restProps = _objectWithoutProperties$1(props, _excluded$2g);
288711
288715
 
288716
+ var disabled = React__default['default'].useContext(DisabledContext$1);
288717
+ var mergedDisabled = customDisabled || disabled;
288712
288718
  return /*#__PURE__*/React__default['default'].createElement(Radio$1, _extends$2({
288719
+ disabled: mergedDisabled,
288713
288720
  className: "lm-radio"
288714
288721
  }, restProps), children);
288715
288722
  };
@@ -293639,17 +293646,21 @@
293639
293646
  Tabs$3.TabPane = TabPane$3;
293640
293647
  Tabs$3.AntdTabs = Tabs$1;
293641
293648
 
293642
- var _excluded$2w = ["size", "className"];
293649
+ var _excluded$2w = ["size", "className", "disabled"];
293643
293650
 
293644
293651
  var Switch$2 = function Switch(props) {
293645
293652
  var _props$size = props.size,
293646
293653
  size = _props$size === void 0 ? 'default' : _props$size,
293647
293654
  className = props.className,
293655
+ customDisabled = props.disabled,
293648
293656
  restProps = _objectWithoutProperties$1(props, _excluded$2w);
293649
293657
 
293658
+ var disabled = React__default['default'].useContext(DisabledContext$1);
293659
+ var mergedDisabled = customDisabled || disabled;
293650
293660
  var classs = classnames('lm-switch', className, _defineProperty$1({}, "lm-switch-".concat(size), size));
293651
293661
  return /*#__PURE__*/React__default['default'].createElement(Switch$1, _objectSpread(_objectSpread({
293652
- className: classs
293662
+ className: classs,
293663
+ disabled: mergedDisabled
293653
293664
  }, restProps), {}, {
293654
293665
  size: size
293655
293666
  }));
@@ -313402,17 +313413,66 @@
313402
313413
  });
313403
313414
  return arr.length;
313404
313415
  }
313405
- function checkDataSourceIsEmpty(config, dataSource) {
313416
+ function checkDataSourceIsEmpty(config, dataSource, scrollInfo) {
313417
+ var resultConfig = _objectSpread({}, config);
313418
+
313419
+ if (scrollInfo) {
313420
+ var _resultConfig$scroll, _resultConfig$scroll2;
313421
+
313422
+ resultConfig = _objectSpread(_objectSpread({}, resultConfig), {}, {
313423
+ scroll: {
313424
+ x: ((_resultConfig$scroll = resultConfig.scroll) === null || _resultConfig$scroll === void 0 ? void 0 : _resultConfig$scroll.x) || '100%',
313425
+ y: scrollInfo.height || ((_resultConfig$scroll2 = resultConfig.scroll) === null || _resultConfig$scroll2 === void 0 ? void 0 : _resultConfig$scroll2.y)
313426
+ }
313427
+ });
313428
+ }
313429
+
313406
313430
  if (dataSource.length) {
313407
- return config;
313431
+ return resultConfig;
313408
313432
  }
313409
313433
 
313410
- return _objectSpread(_objectSpread({}, config), {}, {
313411
- components: _objectSpread(_objectSpread({}, config.components), {}, {
313434
+ return _objectSpread(_objectSpread({}, resultConfig), {}, {
313435
+ components: _objectSpread(_objectSpread({}, resultConfig.components), {}, {
313412
313436
  body: {}
313413
313437
  })
313414
313438
  });
313415
313439
  }
313440
+ /** 根据传入的disabedRows, 得出最终需要disabed的rowKeys */
313441
+
313442
+ function checkTableRowIsDisable(deepDataSource, disabledRows, rowKey) {
313443
+ var disabledRkeys = [];
313444
+
313445
+ if (!disabledRows.length) {
313446
+ return disabledRkeys;
313447
+ }
313448
+
313449
+ var disableIds = disabledRows.map(function (item) {
313450
+ return lodash.isObject(item) ? item === null || item === void 0 ? void 0 : item[rowKey] : item;
313451
+ });
313452
+
313453
+ function deep(children, arrs) {
313454
+ children === null || children === void 0 ? void 0 : children.forEach(function (item) {
313455
+ arrs.push(item[rowKey]);
313456
+
313457
+ if (item.children) {
313458
+ deep(item.children, arrs);
313459
+ }
313460
+ });
313461
+ }
313462
+
313463
+ if (disableIds.length) {
313464
+ disableIds === null || disableIds === void 0 ? void 0 : disableIds.forEach(function (item) {
313465
+ disabledRkeys.push(item);
313466
+ var record = deepDataSource[item];
313467
+
313468
+ if (record === null || record === void 0 ? void 0 : record.children) {
313469
+ deep(record.children, disabledRkeys);
313470
+ }
313471
+ });
313472
+ }
313473
+
313474
+ return disabledRkeys;
313475
+ }
313416
313476
 
313417
313477
  var DndContainer$3 = function DndContainer(_ref) {
313418
313478
  var children = _ref.children,
@@ -313463,19 +313523,8 @@
313463
313523
  if (active.id !== over.id) {
313464
313524
  move(active.id, over.id);
313465
313525
  }
313466
- };
313526
+ }; // @ts-ignore
313467
313527
 
313468
- var instance = {
313469
- isDragging: isDragging,
313470
- activeId: activeId,
313471
- options: options,
313472
- rowKey: rowKey,
313473
- children: children,
313474
- move: move,
313475
- items: items,
313476
- tableWidth: tableWidth
313477
- };
313478
- console.log('instance', instance);
313479
313528
  return /*#__PURE__*/React__default['default'].createElement(DndContext, {
313480
313529
  sensors: sensors,
313481
313530
  onDragStart: handleDragStart,
@@ -313694,7 +313743,7 @@
313694
313743
  _excluded3$b = ["value", "onChange", "record", "rowIndex", "colIndex", "validator"],
313695
313744
  _excluded4$2 = ["record", "rowKey", "isEdit", "col", "rowIndex", "colIndex", "handleTableRowDelete", "handleTableRowAdd", "quickOpetateClearAll", "getLength", "isHoverEdit", "editEnum", "valueType", "children", "handleSave", "handleAdd", "handleDelete", "handleCopy", "itemProps"],
313696
313745
  _excluded5 = ["onMouseEnter", "onMouseLeave"],
313697
- _excluded6 = ["value", "columns", "isEdit", "isAdd", "onChange", "rowKey", "rowHoverEdit", "isUseForm", "isHoverEdit", "useQuickOpetate", "quickOpetateClearAll", "rowSelection", "virtual", "sortOpen", "disabled", "colSortOpen", "indexCol", "filterChange", "size", "recordCreatorProps", "shouldUpdate", "loading"];
313746
+ _excluded6 = ["value", "columns", "isEdit", "isAdd", "onChange", "rowKey", "rowHoverEdit", "isUseForm", "isHoverEdit", "useQuickOpetate", "quickOpetateClearAll", "rowSelection", "rowDisabled", "virtual", "sortOpen", "disabled", "colSortOpen", "indexCol", "filterChange", "size", "recordCreatorProps", "shouldUpdate", "loading", "autoSizer"];
313698
313747
  var UploadBtn$1 = UploadOss.UploadBtn;
313699
313748
  var EditableContext$1 = /*#__PURE__*/React__default['default'].createContext(null); // 表格行
313700
313749
 
@@ -313709,6 +313758,7 @@
313709
313758
 
313710
313759
  return /*#__PURE__*/React__default['default'].createElement(Form$4, {
313711
313760
  form: form,
313761
+ disabled: props.disabled || false,
313712
313762
  component: false
313713
313763
  }, /*#__PURE__*/React__default['default'].createElement(EditableContext$1.Provider, {
313714
313764
  value: form
@@ -314293,6 +314343,7 @@
314293
314343
  _props$quickOpetateCl = props.quickOpetateClearAll,
314294
314344
  quickOpetateClearAll = _props$quickOpetateCl === void 0 ? true : _props$quickOpetateCl,
314295
314345
  rowSelection = props.rowSelection,
314346
+ rowDisabled = props.rowDisabled,
314296
314347
  virtual = props.virtual,
314297
314348
  sortOpen = props.sortOpen,
314298
314349
  disabled = props.disabled,
@@ -314307,6 +314358,8 @@
314307
314358
  shouldUpdate = _props$shouldUpdate === void 0 ? false : _props$shouldUpdate,
314308
314359
  _props$loading = props.loading,
314309
314360
  loading = _props$loading === void 0 ? false : _props$loading,
314361
+ _props$autoSizer = props.autoSizer,
314362
+ autoSizer = _props$autoSizer === void 0 ? false : _props$autoSizer,
314310
314363
  resetProps = _objectWithoutProperties$1(props, _excluded6);
314311
314364
 
314312
314365
  var _useControllableValue = useControllableValue({
@@ -314332,6 +314385,14 @@
314332
314385
  _useControllableValue4 = _slicedToArray$1(_useControllableValue3, 2),
314333
314386
  localRowSelectList = _useControllableValue4[0],
314334
314387
  setLocalRowSelectList = _useControllableValue4[1];
314388
+
314389
+ var _useControllableValue5 = useControllableValue({
314390
+ value: {
314391
+ disabledRows: (rowDisabled === null || rowDisabled === void 0 ? void 0 : rowDisabled.disabledRows) || []
314392
+ }
314393
+ }),
314394
+ _useControllableValue6 = _slicedToArray$1(_useControllableValue5, 1),
314395
+ localDisabledRows = _useControllableValue6[0];
314335
314396
  /** TODO: 当前展开的列 */
314336
314397
 
314337
314398
 
@@ -314344,7 +314405,10 @@
314344
314405
  var deepDataSourceRef = React.useRef(deepDataSourcePreKeys(dataSource, _rowKey));
314345
314406
  dataSourceRef.current = dataSource;
314346
314407
  deepDataSourceRef.current = deepDataSourcePreKeys(dataSource, _rowKey);
314408
+ var disabledDataSourceRowKeys = React.useRef(checkTableRowIsDisable(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey));
314409
+ disabledDataSourceRowKeys.current = checkTableRowIsDisable(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey);
314347
314410
  var tableWarpRef = React.useRef(null);
314411
+ var autoSizerRef = React.useRef(null);
314348
314412
 
314349
314413
  var onColSortEnd = function onColSortEnd(active, over) {
314350
314414
  var _arrayMove;
@@ -314729,7 +314793,6 @@
314729
314793
  render: function render(_, record, index) {
314730
314794
  var _deepDataSourceRef$cu9, _deepDataSourceRef$cu10, _deepDataSourceRef$cu11;
314731
314795
 
314732
- console.log(deepDataSourceRef.current, '--deepDataSourceRef.current', _rowKey);
314733
314796
  return ((_deepDataSourceRef$cu9 = deepDataSourceRef.current) === null || _deepDataSourceRef$cu9 === void 0 ? void 0 : (_deepDataSourceRef$cu10 = _deepDataSourceRef$cu9[record[_rowKey]]) === null || _deepDataSourceRef$cu10 === void 0 ? void 0 : (_deepDataSourceRef$cu11 = _deepDataSourceRef$cu10['_deepIds']) === null || _deepDataSourceRef$cu11 === void 0 ? void 0 : _deepDataSourceRef$cu11.join('-')) || "".concat(index + 1);
314734
314797
  }
314735
314798
  } : _objectSpread(_objectSpread({
@@ -314949,11 +315012,39 @@
314949
315012
  }
314950
315013
  },
314951
315014
  onRow: function onRow(record, index) {
315015
+ var _disabledDataSourceRo;
315016
+
314952
315017
  return {
314953
- disabled: disabled
315018
+ disabled: disabled || !!((_disabledDataSourceRo = disabledDataSourceRowKeys.current) === null || _disabledDataSourceRo === void 0 ? void 0 : _disabledDataSourceRo.includes(record[_rowKey]))
314954
315019
  };
314955
315020
  }
314956
315021
  }, resetProps));
315022
+ React.useEffect(function () {
315023
+ if (autoSizer) {
315024
+ var _tableWarpRef$current3;
315025
+
315026
+ var tableClient = tableWarpRef === null || tableWarpRef === void 0 ? void 0 : (_tableWarpRef$current3 = tableWarpRef.current) === null || _tableWarpRef$current3 === void 0 ? void 0 : _tableWarpRef$current3.getBoundingClientRect();
315027
+ var height = (tableClient === null || tableClient === void 0 ? void 0 : tableClient.height) || '100%';
315028
+ var TailorHeight = size === 'middle' ? 48 : 40;
315029
+
315030
+ if (isAdd) {
315031
+ TailorHeight += 48;
315032
+ }
315033
+
315034
+ if (props.summary) {
315035
+ TailorHeight += 48;
315036
+ }
315037
+
315038
+ if (props.pagination) {
315039
+ TailorHeight += 48;
315040
+ }
315041
+
315042
+ autoSizerRef.current = {
315043
+ width: tableClient === null || tableClient === void 0 ? void 0 : tableClient.width,
315044
+ height: typeof height === 'string' ? "calc(".concat(height, " - ").concat(TailorHeight, "px)") : height - TailorHeight
315045
+ };
315046
+ }
315047
+ }, []);
314957
315048
 
314958
315049
  if (colSortOpen) {
314959
315050
  var _localRowSelectList$s;
@@ -314973,7 +315064,7 @@
314973
315064
  items: columns.reduce(function (acc, item) {
314974
315065
  return [].concat(_toConsumableArray$1(acc), [item.dataIndex]);
314975
315066
  }, [])
314976
- }, /*#__PURE__*/React__default['default'].createElement(Table$1, _objectSpread(_objectSpread({}, checkDataSourceIsEmpty(config.current, dataSourceRef.current)), {}, {
315067
+ }, /*#__PURE__*/React__default['default'].createElement(Table$1, _objectSpread(_objectSpread({}, checkDataSourceIsEmpty(config.current, dataSourceRef.current, autoSizerRef.current)), {}, {
314977
315068
  loading: loading,
314978
315069
  size: size || 'small',
314979
315070
  columns: resultColumns,
@@ -315003,18 +315094,21 @@
315003
315094
 
315004
315095
 
315005
315096
  return /*#__PURE__*/React__default['default'].createElement("div", {
315006
- className: "lm_editTable_warpper",
315097
+ className: classnames('lm_editTable_warpper', autoSizer && 'lm_editable_autosize'),
315007
315098
  ref: tableWarpRef
315008
315099
  }, /*#__PURE__*/React__default['default'].createElement(ConfigProvider$1, {
315009
315100
  renderEmpty: loading ? function () {
315010
315101
  return null;
315011
315102
  } : CustomizeRenderEmpty$1
315012
- }, /*#__PURE__*/React__default['default'].createElement(Table$1, _objectSpread(_objectSpread({}, checkDataSourceIsEmpty(config.current, dataSourceRef.current)), {}, {
315103
+ }, /*#__PURE__*/React__default['default'].createElement(Table$1, _objectSpread(_objectSpread({}, checkDataSourceIsEmpty(config.current, dataSourceRef.current, autoSizerRef.current)), {}, {
315013
315104
  size: size || 'small',
315014
315105
  columns: resultColumns,
315015
315106
  rowClassName: "editable-row",
315016
315107
  bordered: true,
315017
315108
  loading: loading,
315109
+ style: autoSizer ? {
315110
+ height: isAdd ? "calc(100% - ".concat(48, "px)") : '100%'
315111
+ } : undefined,
315018
315112
  pagination: false,
315019
315113
  // components={tableComponents}
315020
315114
  expandable: (resetProps === null || resetProps === void 0 ? void 0 : resetProps.expandable) || {