es-grid-template 1.9.52 → 1.9.55

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.
Files changed (122) hide show
  1. package/es/ali-table/Grid.d.ts +1 -0
  2. package/es/ali-table/Grid.js +12 -4
  3. package/es/ali-table/InternalTable.js +39 -7
  4. package/es/ali-table/base-table/html-table-default.d.ts +20 -0
  5. package/es/ali-table/base-table/html-table-default.js +224 -0
  6. package/es/ali-table/base-table/html-table-new.d.ts +20 -0
  7. package/es/ali-table/base-table/html-table-new.js +417 -0
  8. package/es/ali-table/base-table/html-table.js +324 -182
  9. package/es/ali-table/base-table/styles.d.ts +1 -0
  10. package/es/ali-table/base-table/styles.js +5 -4
  11. package/es/ali-table/base-table/table.d.ts +4 -0
  12. package/es/ali-table/base-table/table.js +24 -5
  13. package/es/ali-table/common-views.d.ts +1 -1
  14. package/es/ali-table/pipeline/features/columnCustom.js +3 -3
  15. package/es/ali-table/pipeline/features/pagination.js +1 -1
  16. package/es/ali-table/utils/convertColumnsChoose.d.ts +2 -2
  17. package/es/grid-component/control/InputControl/InputControl.js +2 -3
  18. package/es/grid-component/hooks/calender.d.ts +19 -0
  19. package/es/grid-component/hooks/calender.js +32 -0
  20. package/es/grid-component/type.d.ts +15 -2
  21. package/es/group-component/ColumnsChoose.js +1 -2
  22. package/es/group-component/ColumnsGroup/ColumnsGroup.js +1 -2
  23. package/es/group-component/TableContainerEdit.js +1 -2
  24. package/es/group-component/body/EditableCell.js +7 -6
  25. package/es/group-component/components/EditForm/EditForm.js +1 -2
  26. package/es/group-component/components/InputControl/InputControl.js +1 -2
  27. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +1 -2
  28. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
  29. package/es/group-component/components/checkbox-filter/FilterSearch.js +0 -3
  30. package/es/group-component/header/TableHeadCell.js +1 -2
  31. package/es/group-component/header/TableHeadCell2.js +1 -2
  32. package/es/group-component/hook/utils.d.ts +9 -9
  33. package/es/group-component/table/Grid.js +1 -1
  34. package/es/index.d.ts +2 -2
  35. package/es/index.js +1 -1
  36. package/es/table-component/ColumnsChoose.js +1 -1
  37. package/es/table-component/ColumnsConfig.d.ts +17 -0
  38. package/es/table-component/ColumnsConfig.js +302 -0
  39. package/es/table-component/ContextMenu.js +1 -1
  40. package/es/table-component/InternalTable.js +30 -9
  41. package/es/table-component/TableContainer.js +4 -2
  42. package/es/table-component/TableContainerEdit.js +3 -3
  43. package/es/table-component/body/EditableCell.js +9 -5
  44. package/es/table-component/body/TableBodyRow.js +0 -5
  45. package/es/table-component/components/EditForm/EditForm.js +1 -4
  46. package/es/table-component/components/InputControl/InputControl.js +1 -1
  47. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +1 -2
  48. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
  49. package/es/table-component/components/checkbox-filter/FilterSearch.js +4 -2
  50. package/es/table-component/header/TableHeadCell.js +1 -1
  51. package/es/table-component/header/TableHeadCell2.js +1 -1
  52. package/es/table-component/header/TableHeadRow.js +6 -6
  53. package/es/table-component/hook/useColumns.js +0 -1
  54. package/es/table-component/hook/utils.d.ts +3 -3
  55. package/es/table-component/hook/utils.js +35 -6
  56. package/es/table-component/style.js +1 -1
  57. package/es/table-component/table/Grid.js +2 -1
  58. package/es/table-virtuoso/InternalTable.js +2 -0
  59. package/es/table-virtuoso/body/TableBodyCell.js +11 -6
  60. package/lib/ali-table/Grid.d.ts +1 -0
  61. package/lib/ali-table/Grid.js +12 -4
  62. package/lib/ali-table/InternalTable.js +39 -7
  63. package/lib/ali-table/base-table/html-table-default.d.ts +20 -0
  64. package/lib/ali-table/base-table/html-table-default.js +231 -0
  65. package/lib/ali-table/base-table/html-table-new.d.ts +20 -0
  66. package/lib/ali-table/base-table/html-table-new.js +424 -0
  67. package/lib/ali-table/base-table/html-table.js +324 -182
  68. package/lib/ali-table/base-table/styles.d.ts +1 -0
  69. package/lib/ali-table/base-table/styles.js +5 -4
  70. package/lib/ali-table/base-table/table.d.ts +4 -0
  71. package/lib/ali-table/base-table/table.js +24 -5
  72. package/lib/ali-table/pipeline/features/columnCustom.js +4 -4
  73. package/lib/ali-table/pipeline/features/pagination.js +1 -1
  74. package/lib/ali-table/utils/convertColumnsChoose.d.ts +2 -2
  75. package/lib/grid-component/control/InputControl/InputControl.js +4 -6
  76. package/lib/grid-component/hooks/calender.d.ts +19 -0
  77. package/lib/grid-component/hooks/calender.js +40 -0
  78. package/lib/grid-component/type.d.ts +15 -2
  79. package/lib/group-component/ColumnsChoose.js +6 -7
  80. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +3 -4
  81. package/lib/group-component/TableContainerEdit.js +2 -3
  82. package/lib/group-component/body/EditableCell.js +14 -13
  83. package/lib/group-component/components/EditForm/EditForm.js +1 -2
  84. package/lib/group-component/components/InputControl/InputControl.js +4 -6
  85. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +1 -2
  86. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
  87. package/lib/group-component/components/checkbox-filter/FilterSearch.js +0 -2
  88. package/lib/group-component/header/TableHeadCell.js +3 -4
  89. package/lib/group-component/header/TableHeadCell2.js +3 -4
  90. package/lib/group-component/hook/utils.d.ts +1 -1
  91. package/lib/group-component/table/Grid.js +2 -2
  92. package/lib/index.d.ts +2 -2
  93. package/lib/index.js +2 -2
  94. package/lib/table-component/ColumnsChoose.js +5 -5
  95. package/lib/table-component/ColumnsConfig.d.ts +17 -0
  96. package/lib/table-component/ColumnsConfig.js +312 -0
  97. package/lib/table-component/ContextMenu.js +3 -3
  98. package/lib/table-component/InternalTable.js +25 -8
  99. package/lib/table-component/TableContainer.js +4 -2
  100. package/lib/table-component/TableContainerEdit.js +5 -6
  101. package/lib/table-component/body/EditableCell.js +18 -15
  102. package/lib/table-component/body/TableBodyRow.js +0 -5
  103. package/lib/table-component/components/EditForm/EditForm.js +3 -6
  104. package/lib/table-component/components/InputControl/InputControl.js +1 -2
  105. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +1 -2
  106. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +1 -1
  107. package/lib/table-component/components/checkbox-filter/FilterSearch.js +5 -2
  108. package/lib/table-component/header/TableHeadCell.js +4 -5
  109. package/lib/table-component/header/TableHeadCell2.js +2 -3
  110. package/lib/table-component/header/TableHeadRow.js +6 -6
  111. package/lib/table-component/hook/useColumns.js +0 -1
  112. package/lib/table-component/hook/utils.d.ts +3 -3
  113. package/lib/table-component/hook/utils.js +35 -6
  114. package/lib/table-component/style.js +1 -1
  115. package/lib/table-component/table/Grid.js +3 -2
  116. package/lib/table-virtuoso/InternalTable.js +2 -0
  117. package/lib/table-virtuoso/body/TableBodyCell.js +10 -5
  118. package/package.json +2 -2
  119. /package/es/{datepicker → datePicker}/index.d.ts +0 -0
  120. /package/es/{datepicker → datePicker}/index.js +0 -0
  121. /package/lib/{datepicker → datePicker}/index.d.ts +0 -0
  122. /package/lib/{datepicker → datePicker}/index.js +0 -0
@@ -620,7 +620,9 @@ export function getColIdsBetween(table, a, b) {
620
620
  }
621
621
  export function getRowIdsBetween(table, a, b) {
622
622
  // const ids = table.getRowModel().rows.map(r => r.id);
623
- const ids = table.getRowModel().flatRows.map(r => r.id);
623
+ const flatRows = table.getRowModel().flatRows;
624
+ const allRows = flatRows.filter((item, index, self) => index === self.findIndex(x => x.id === item.id));
625
+ const ids = allRows.map(r => r.id);
624
626
  const [start, end] = [ids.indexOf(a), ids.indexOf(b)].sort((x, y) => x - y);
625
627
  return ids.slice(start, end + 1);
626
628
  }
@@ -1366,7 +1368,10 @@ export const getSelectedCellMatrix = (table, startCell, endCell) => {
1366
1368
  };
1367
1369
 
1368
1370
  // const rowIds = table.getRowModel().rows.map(r => r.id);
1369
- const rowIds = table.getRowModel().flatRows.map(r => r.id);
1371
+
1372
+ const flatRows = table.getRowModel().flatRows;
1373
+ const allRows = flatRows.filter((item, index, self) => index === self.findIndex(x => x.id === item.id));
1374
+ const rowIds = allRows.map(r => r.id);
1370
1375
  const colIds = table.getVisibleLeafColumns().map(c => c.id);
1371
1376
 
1372
1377
  // const colIds = table.getAllLeafColumns().map(c => c.id);
@@ -2238,9 +2243,21 @@ export function isObjEqual(obj1, obj2) {
2238
2243
  }
2239
2244
 
2240
2245
  // Sorting function
2241
- export const sortByType = arr => {
2242
- if (arr) {
2243
- return arr.sort((a, b) => {
2246
+ export const sortByType = (arr, rowDnd) => {
2247
+ const colDnd = {
2248
+ field: 'drag-handle',
2249
+ width: 50,
2250
+ fixed: 'left',
2251
+ headerText: '',
2252
+ allowFiltering: false,
2253
+ allowResizing: false,
2254
+ allowSortering: false
2255
+ };
2256
+ const cols = rowDnd?.enabled ? [{
2257
+ ...colDnd
2258
+ }, ...arr] : [...arr];
2259
+ if (cols) {
2260
+ return cols.sort((a, b) => {
2244
2261
  if ((a.fixed ?? a.fixedType) === 'left' && (b.fixed ?? b.fixedType) !== 'left') {
2245
2262
  return -1;
2246
2263
  } else if ((a.fixed ?? a.fixedType) !== 'left' && (b.fixed ?? b.fixedType) === 'left') {
@@ -2392,7 +2409,19 @@ export function updateColumnWidthsRecursive(columns, sizing) {
2392
2409
  return updated;
2393
2410
  });
2394
2411
  }
2395
- export function updateWidthsByOther(source, target) {
2412
+ export function updateWidthsByOther(source, target
2413
+ // rowDnd?: RowDnd
2414
+ ) {
2415
+ // const columnDnd = {
2416
+ // field: 'drag-handle',
2417
+ // headerText: '',
2418
+ // fixed: 'left',
2419
+ // width: 50
2420
+ // }
2421
+
2422
+ // const tg = rowDnd?.enabled ? [{...columnDnd}, ...target] : [...target]
2423
+ // const sour = rowDnd?.enabled ? [{...columnDnd}, ...source] : [...source]
2424
+
2396
2425
  const targetMap = new Map();
2397
2426
 
2398
2427
  // tạo map {field -> width} từ target
@@ -1,6 +1,6 @@
1
1
  import styled from 'styled-components';
2
2
  // const prefix = "ui-rc";
3
- // const antdPrefix = "ant";
3
+ // const rcUiPrefix = "ant";
4
4
  const fontFamily = 'Montserrat, Helvetica, Arial, serif ';
5
5
  // const borderRadius = "6px";
6
6
 
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { Modal } from 'antd';
2
+ import { Modal } from 'rc-master-ui';
3
3
  import { faker } from '@faker-js/faker';
4
4
  import { getCoreRowModel, getExpandedRowModel,
5
5
  // getFilteredRowModel,
@@ -277,6 +277,7 @@ const Grid = props => {
277
277
  active,
278
278
  over
279
279
  } = event;
280
+ // column dnd
280
281
  if (active && over && active.id !== over.id) {
281
282
  setColumnOrder(cols => {
282
283
  const oldIndex = cols.indexOf(active.id);
@@ -197,6 +197,8 @@ const InternalTable = props => {
197
197
  });
198
198
  }
199
199
  };
200
+ console.log('tableData', tableData);
201
+ console.log('isDataTree', isDataTree);
200
202
  const table = useReactTable({
201
203
  _features: [OperatorFeature],
202
204
  data: tableData,
@@ -1,5 +1,5 @@
1
1
  import Space from "rc-master-ui/es/space";
2
- import { getCommonPinningStyles } from "../hook/utils";
2
+ import { getCommonPinningStyles, getFormat } from "../hook/utils";
3
3
  import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
4
4
  import classNames from "classnames";
5
5
  import React from "react";
@@ -9,9 +9,10 @@ import { renderValueCell, toggleRowSelection } from "../../table-component/hook/
9
9
  const renderCellIndex = props => {
10
10
  const {
11
11
  cell,
12
- pagination
12
+ pagination,
13
+ isDataTree
13
14
  } = props;
14
- const parrents = cell.row.getParentRows();
15
+ const parrents = cell.row.parentId && isDataTree ? cell.row.getParentRows?.() : undefined;
15
16
  if (parrents && parrents.length > 0) {
16
17
  return /*#__PURE__*/React.createElement("span", {
17
18
  className: "ui-rc_cell-content"
@@ -250,10 +251,12 @@ const TableBodyCell = props => {
250
251
  className: "ui-rc_cell-content"
251
252
  }, renderCellIndex({
252
253
  cell,
253
- pagination
254
+ pagination,
255
+ isDataTree
254
256
  })) : renderCellIndex({
255
257
  cell,
256
- pagination
258
+ pagination,
259
+ isDataTree
257
260
  }));
258
261
  }
259
262
  if (cell.column.id === "command") {
@@ -313,8 +316,10 @@ const TableBodyCell = props => {
313
316
  })));
314
317
  }
315
318
  const cellValue = cell.getValue();
319
+ const colFormat = typeof columnMeta.format === 'function' ? columnMeta.format(record) : columnMeta.format;
320
+ const cellFormat = getFormat(colFormat, format);
316
321
  const rowIndex = cell.row.index;
317
- const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
322
+ const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, false);
318
323
  const cellContent = columnMeta.template ? typeof columnMeta.template === 'function' ? columnMeta.template({
319
324
  field: columnMeta.field,
320
325
  index: cell.row.index,
@@ -17,5 +17,6 @@ declare const Grid: React.ForwardRefExoticComponent<Omit<TableProps, "useVirtual
17
17
  vertical?: VirtualEnum;
18
18
  header?: VirtualEnum;
19
19
  };
20
+ dataRowIds: any[];
20
21
  } & React.RefAttributes<BaseTable>>;
21
22
  export default Grid;
@@ -66,7 +66,8 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
66
66
  useVirtual,
67
67
  useOuterBorder = true,
68
68
  showHeader = true,
69
- gridLines
69
+ gridLines,
70
+ dataRowIds
70
71
  } = props;
71
72
  const {
72
73
  cssVariables
@@ -173,16 +174,20 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
173
174
  [`${prefix}-grid-line-horizontal`]: gridLines === 'Horizontal',
174
175
  [`${prefix}-grid-line-vertical`]: gridLines === 'Vertical',
175
176
  [`${prefix}-grid-line-none`]: gridLines === 'None',
176
- [`use-outer-border`]: useOuterBorder
177
+ [`use-outer-border`]: useOuterBorder,
178
+ [`auto-height`]: !minHeight
179
+ // [`has-title`]: showToolbar !== false && ( fullScreen !== false || title || topToolbaritems.length > 0)
177
180
  }),
178
181
  style: {
179
- maxHeight: height ?? 700,
182
+ // maxHeight: height ?? 700,
183
+ maxHeight: height ?? minHeight,
184
+ // height: height ?? minHeight,
180
185
  minHeight,
181
186
  display: 'flex',
182
187
  flexDirection: 'column',
183
188
  ...artTableWrapperProps.style
184
189
  }
185
- }, (showToolbar !== false || fullScreen !== false || title || topToolbaritems.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
190
+ }, showToolbar !== false && (fullScreen !== false || title || topToolbaritems.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
186
191
  className: (0, _classnames.default)(`${prefix}-grid-top`, {})
187
192
  }, /*#__PURE__*/_react.default.createElement("div", {
188
193
  style: {
@@ -252,6 +257,8 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
252
257
  isStickyHeader: true,
253
258
  stickyBottom: 0,
254
259
  stickyTop: 0,
260
+ isBottom: !!(bottom || pagination && !infiniteScroll),
261
+ isTitle: !!(showToolbar !== false && (fullScreen !== false || title || topToolbaritems.length > 0)),
255
262
  defaultColumnWidth: 100,
256
263
  originData: originData,
257
264
  format: format
@@ -306,6 +313,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
306
313
  };
307
314
  },
308
315
  theme: theme,
316
+ dataRowIds: dataRowIds,
309
317
  footerDataSource: footerDataSource
310
318
  })), (bottom || pagination && !infiniteScroll) && /*#__PURE__*/_react.default.createElement("div", {
311
319
  className: (0, _classnames.default)(`${prefix}-grid-bottom`, {})
@@ -14,11 +14,13 @@ var _react = _interopRequireDefault(require("react"));
14
14
  require("./base-table/styles.scss");
15
15
  var _utils = require("../table-component/hook/utils");
16
16
  var _rcMasterUi = require("rc-master-ui");
17
- var _antd = require("antd");
18
17
  var _useLocale = require("../locale/useLocale");
19
18
  var _useContext = require("./useContext");
20
19
  var _Grid = _interopRequireDefault(require("./Grid"));
21
20
  var _selected = require("./utils/selected");
21
+ var _core = require("@dnd-kit/core");
22
+ var _modifiers = require("@dnd-kit/modifiers");
23
+ var _sortable = require("@dnd-kit/sortable");
22
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
26
  const InternalTable = props => {
@@ -49,6 +51,7 @@ const InternalTable = props => {
49
51
  footerDataSource,
50
52
  summary,
51
53
  useVirtual,
54
+ rowDnd,
52
55
  ...rest
53
56
  } = props;
54
57
  const prefix = 'ui-rc';
@@ -88,8 +91,8 @@ const InternalTable = props => {
88
91
  const [filterState, setFilterState] = _react.default.useState(undefined);
89
92
  const [sortState, setSortState] = _react.default.useState(undefined);
90
93
  const columns = _react.default.useMemo(() => {
91
- return (0, _utils.sortByType)(propColumns);
92
- }, [propColumns]);
94
+ return (0, _utils.sortByType)(propColumns, rowDnd);
95
+ }, [propColumns, rowDnd]);
93
96
  const convertData = _react.default.useMemo(() => {
94
97
  if (groupAble && groupSetting && groupSetting.client !== false) {
95
98
  return (0, _utils.groupArrayByColumns)(dataSource, groupColumns);
@@ -135,6 +138,7 @@ const InternalTable = props => {
135
138
  // return getInvisibleColumns(columns)
136
139
  // }, [columns])
137
140
 
141
+ const dataIds = _react.default.useMemo(() => mergedData.map(it => it.rowId), [mergedData]);
138
142
  const columnVisibility = _react.default.useMemo(() => {
139
143
  return (0, _utils.getVisibleFields)(columns);
140
144
  }, [columns]);
@@ -235,6 +239,27 @@ const InternalTable = props => {
235
239
 
236
240
  // }
237
241
 
242
+ // reorder rows after drag & drop
243
+ function handleDragEnd(event) {
244
+ const {
245
+ active,
246
+ over
247
+ } = event;
248
+ if (over && active.id !== over.id) {
249
+ // data dạng phẳng
250
+
251
+ const oldIndex = dataIds.indexOf(active.id);
252
+ const newIndex = dataIds.indexOf(over.id);
253
+ const rs = (0, _sortable.arrayMove)(mergedData, oldIndex, newIndex); // this is just a splice util
254
+
255
+ if (rowDnd?.onChange) {
256
+ rowDnd?.onChange({
257
+ rows: rs
258
+ });
259
+ }
260
+ }
261
+ }
262
+ const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor, {}), (0, _core.useSensor)(_core.TouchSensor, {}), (0, _core.useSensor)(_core.KeyboardSensor, {}));
238
263
  return /*#__PURE__*/_react.default.createElement(_rcMasterUi.ConfigProvider, {
239
264
  locale: language,
240
265
  theme: {
@@ -293,6 +318,11 @@ const InternalTable = props => {
293
318
  lang,
294
319
  locale
295
320
  }
321
+ }, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
322
+ collisionDetection: _core.closestCenter,
323
+ modifiers: [_modifiers.restrictToVerticalAxis],
324
+ onDragEnd: handleDragEnd,
325
+ sensors: sensors
296
326
  }, /*#__PURE__*/_react.default.createElement(_Grid.default, (0, _extends2.default)({}, rest, {
297
327
  id: id,
298
328
  useVirtual: {
@@ -313,8 +343,9 @@ const InternalTable = props => {
313
343
  onFilter: onFilter,
314
344
  onSorter: onSorter,
315
345
  defaultFilter: defaultFilter,
316
- defaultSorter: defaultSorter
317
- })), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
346
+ defaultSorter: defaultSorter,
347
+ dataRowIds: dataIds
348
+ })), /*#__PURE__*/_react.default.createElement(_rcMasterUi.Modal, {
318
349
  open: isFullScreen,
319
350
  footer: null,
320
351
  centered: true,
@@ -363,7 +394,8 @@ const InternalTable = props => {
363
394
  onFilter: onFilter,
364
395
  onSorter: onSorter,
365
396
  defaultFilter: defaultFilter,
366
- defaultSorter: defaultSorter
367
- })))))));
397
+ defaultSorter: defaultSorter,
398
+ dataRowIds: dataIds
399
+ }))))))));
368
400
  };
369
401
  var _default = exports.default = InternalTable;
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import type { RenderInfo } from './interfaces';
3
+ import type { BaseTableProps } from './table';
4
+ import type { CommandClick, IFormat } from '../../grid-component/type';
5
+ export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowProps' | 'primaryKey' | 'components'>> {
6
+ tbodyHtmlTag: 'tbody' | 'tfoot';
7
+ data: any[];
8
+ originData: any[];
9
+ format?: IFormat;
10
+ id: string;
11
+ commandClick?: (args: CommandClick<any>) => void;
12
+ horizontalRenderInfo: Pick<RenderInfo, 'flat' | 'visible' | 'horizontalRenderRange' | 'stickyLeftMap' | 'stickyRightMap'>;
13
+ verticalRenderInfo: {
14
+ offset: number;
15
+ first: number;
16
+ last: number;
17
+ limit: number;
18
+ };
19
+ }
20
+ export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, data, originData, format, commandClick, id, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo, components: { Row, Cell, TableBody }, }: HtmlTableProps): JSX.Element;
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.HtmlTable = HtmlTable;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _internals = require("../internals");
12
+ var _colgroup = require("./colgroup");
13
+ var _SpanManager = _interopRequireDefault(require("./helpers/SpanManager"));
14
+ var _styles = require("./styles");
15
+ var _hooks = require("../../grid-component/hooks");
16
+ var _rcMasterUi = require("rc-master-ui");
17
+ var _Command = _interopRequireDefault(require("../../table-component/components/command/Command"));
18
+ var _useColumns = require("../../table-component/hook/useColumns");
19
+ function HtmlTable({
20
+ tbodyHtmlTag,
21
+ getRowProps,
22
+ primaryKey,
23
+ data,
24
+ originData,
25
+ format,
26
+ commandClick,
27
+ id,
28
+ verticalRenderInfo: verInfo,
29
+ horizontalRenderInfo: hozInfo,
30
+ components: {
31
+ Row,
32
+ Cell,
33
+ TableBody
34
+ }
35
+ }) {
36
+ const {
37
+ flat,
38
+ horizontalRenderRange: hoz
39
+ } = hozInfo;
40
+ const spanManager = new _SpanManager.default();
41
+ const fullFlatCount = flat.full.length;
42
+ const leftFlatCount = flat.left.length;
43
+ const rightFlatCount = flat.right.length;
44
+ const tbody = TableBody != null && tbodyHtmlTag === 'tbody' ? /*#__PURE__*/_react.default.createElement(TableBody, {
45
+ tbodyProps: {
46
+ children: data.map(renderRow)
47
+ }
48
+ }) : ( /*#__PURE__*/_react.default.createElement(tbodyHtmlTag, null, data.map(renderRow)));
49
+ return /*#__PURE__*/_react.default.createElement("table", null, /*#__PURE__*/_react.default.createElement(_colgroup.Colgroup, {
50
+ descriptors: hozInfo.visible
51
+ }), tbody);
52
+ function renderRow(row, i) {
53
+ const rowIndex = verInfo.offset + i;
54
+ spanManager.stripUpwards(rowIndex);
55
+ const rowProps = getRowProps(row, rowIndex);
56
+ const rowClass = (0, _classnames.default)(_styles.Classes.tableRow, {
57
+ first: rowIndex === verInfo.first,
58
+ last: rowIndex === verInfo.last,
59
+ even: rowIndex % 2 === 0,
60
+ odd: rowIndex % 2 === 1
61
+ }, rowProps?.className);
62
+ const onContextMenu = rowProps?.onContextMenu;
63
+ const trProps = {
64
+ ...rowProps,
65
+ className: rowClass,
66
+ onContextMenu: tbodyHtmlTag === 'tbody' ? onContextMenu : undefined,
67
+ 'data-rowindex': rowIndex,
68
+ children: hozInfo.visible.map(descriptor => {
69
+ if (descriptor.type === 'blank') {
70
+ return /*#__PURE__*/_react.default.createElement("td", {
71
+ key: descriptor.blankSide
72
+ });
73
+ }
74
+ return renderBodyCell(row, rowIndex, descriptor.col, descriptor.colIndex);
75
+ })
76
+ };
77
+ const key = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
78
+ if (Row != null && tbodyHtmlTag === 'tbody') {
79
+ return /*#__PURE__*/_react.default.createElement(Row, {
80
+ key,
81
+ row,
82
+ rowIndex,
83
+ trProps
84
+ });
85
+ } else {
86
+ return /*#__PURE__*/_react.default.createElement("tr", (0, _extends2.default)({
87
+ key: key
88
+ }, trProps));
89
+ }
90
+ }
91
+ function renderBodyCell(row, rowIndex, column, colIndex) {
92
+ if (spanManager.testSkip(rowIndex, colIndex)) {
93
+ return null;
94
+ }
95
+ const value = _internals.internals.safeGetValue(column, row, rowIndex);
96
+ const cellProps = column.getCellProps?.(value, row, rowIndex) ?? {};
97
+ const a = (0, _useColumns.renderValueCell)(column, value, row, rowIndex, colIndex, format, false);
98
+
99
+ // let cellContent: ReactNode = value
100
+ let cellContent = a;
101
+
102
+ // if (column.render) {
103
+ // cellContent = column.render(value, row, rowIndex)
104
+ // }
105
+ // if (column.field === '#') {
106
+
107
+ // cellContent = findItemPath(originData, row, primaryKey)
108
+ // }
109
+
110
+ if (column.field === 'command') {
111
+ const commands = column.commandItems ? column.commandItems.map(it => {
112
+ return {
113
+ ...it,
114
+ visible: typeof it.visible === 'function' ? it.visible?.(row) : it.visible
115
+ };
116
+ }) : [];
117
+ cellContent = /*#__PURE__*/_react.default.createElement("div", {
118
+ className: "ui-rc_cell-content"
119
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Space, null, commands.filter(it => it.visible !== false).map(item => {
120
+ return /*#__PURE__*/_react.default.createElement(_Command.default, {
121
+ id: id,
122
+ key: item.id,
123
+ item: item,
124
+ record: row,
125
+ onClick: () => {
126
+ commandClick?.({
127
+ id: item.id,
128
+ // rowId: getRowKey(record, index) as any,
129
+ rowId: row.rowId,
130
+ rowData: row,
131
+ index: rowIndex,
132
+ rows: [...originData]
133
+ });
134
+ }
135
+ });
136
+ })));
137
+ }
138
+ if (column.template) {
139
+ cellContent = column.template({
140
+ value,
141
+ rowData: row,
142
+ index: rowIndex,
143
+ field: column.field ?? ''
144
+ });
145
+ }
146
+
147
+ //
148
+
149
+ let colSpan = 1;
150
+ let rowSpan = 1;
151
+ if (column.getSpanRect) {
152
+ const spanRect = column.getSpanRect(value, row, rowIndex);
153
+ colSpan = spanRect == null ? 1 : spanRect.right - colIndex;
154
+ rowSpan = spanRect == null ? 1 : spanRect.bottom - rowIndex;
155
+ } else {
156
+ if (cellProps.colSpan != null) {
157
+ colSpan = cellProps.colSpan;
158
+ }
159
+ if (cellProps.rowSpan != null) {
160
+ rowSpan = cellProps.rowSpan;
161
+ }
162
+ }
163
+
164
+ // rowSpan/colSpan should not be too large to avoid affecting cells that are not rendered due to virtual scrolling
165
+ rowSpan = Math.min(rowSpan, verInfo.limit - rowIndex);
166
+ colSpan = Math.min(colSpan, leftFlatCount + hoz.rightIndex - colIndex);
167
+ const hasSpan = colSpan > 1 || rowSpan > 1;
168
+ if (hasSpan) {
169
+ spanManager.add(rowIndex, colIndex, colSpan, rowSpan);
170
+ }
171
+ const positionStyle = {};
172
+ if (colIndex < leftFlatCount) {
173
+ positionStyle.position = 'sticky';
174
+ positionStyle.left = hozInfo.stickyLeftMap.get(colIndex);
175
+ } else if (colIndex >= fullFlatCount - rightFlatCount) {
176
+ positionStyle.position = 'sticky';
177
+ positionStyle.right = hozInfo.stickyRightMap.get(colIndex);
178
+ }
179
+ const tdProps = {
180
+ ...cellProps,
181
+ className: (0, _classnames.default)(_styles.Classes.tableCell, cellProps.className, {
182
+ first: colIndex === 0,
183
+ last: colIndex + colSpan === fullFlatCount,
184
+ 'lock-left': colIndex < leftFlatCount,
185
+ 'lock-right': colIndex >= fullFlatCount - rightFlatCount
186
+ }),
187
+ ...(hasSpan ? {
188
+ colSpan,
189
+ rowSpan
190
+ } : null),
191
+ style: {
192
+ textAlign: column.textAlign,
193
+ ...cellProps.style,
194
+ ...positionStyle
195
+ },
196
+ // children: <div className='ui-rc_cell-content'>{cellContent}</div>
197
+
198
+ children: cellContent
199
+ // children: () => {
200
+ // return (
201
+ // <span className='abcccc'>{cellContent}</span>
202
+ // )
203
+ // },
204
+ };
205
+ if (tbodyHtmlTag === 'tfoot') {
206
+ if (!_hooks.nonActionColumn.includes(column.field) && column.isSummary !== false) {
207
+ return /*#__PURE__*/_react.default.createElement("td", (0, _extends2.default)({
208
+ key: colIndex
209
+ }, tdProps));
210
+ } else {
211
+ return /*#__PURE__*/_react.default.createElement("td", (0, _extends2.default)({
212
+ key: colIndex
213
+ }, tdProps), '');
214
+ }
215
+ }
216
+ if (Cell != null && tbodyHtmlTag === 'tbody') {
217
+ return /*#__PURE__*/_react.default.createElement(Cell, {
218
+ key: colIndex,
219
+ tdProps: tdProps,
220
+ row: row,
221
+ rowIndex: rowIndex,
222
+ column: column,
223
+ colIndex: colIndex
224
+ });
225
+ } else {
226
+ return /*#__PURE__*/_react.default.createElement("td", (0, _extends2.default)({
227
+ key: colIndex
228
+ }, tdProps));
229
+ }
230
+ }
231
+ }
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import type { RenderInfo } from './interfaces';
3
+ import type { BaseTableProps } from './table';
4
+ import type { CommandClick, IFormat } from '../../grid-component/type';
5
+ export interface HtmlTableProps extends Required<Pick<BaseTableProps, 'getRowProps' | 'primaryKey' | 'components'>> {
6
+ tbodyHtmlTag: 'tbody' | 'tfoot';
7
+ data: any[];
8
+ originData: any[];
9
+ format?: IFormat;
10
+ id: string;
11
+ commandClick?: (args: CommandClick<any>) => void;
12
+ horizontalRenderInfo: Pick<RenderInfo, 'flat' | 'visible' | 'horizontalRenderRange' | 'stickyLeftMap' | 'stickyRightMap'>;
13
+ verticalRenderInfo: {
14
+ offset: number;
15
+ first: number;
16
+ last: number;
17
+ limit: number;
18
+ };
19
+ }
20
+ export declare function HtmlTable({ tbodyHtmlTag, getRowProps, primaryKey, data, originData, format, commandClick, id, verticalRenderInfo: verInfo, horizontalRenderInfo: hozInfo, components: { Row, Cell, TableBody }, }: HtmlTableProps): JSX.Element;