es-grid-template 1.2.3 → 1.2.4

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.
@@ -42,6 +42,14 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
42
42
  //font-weight: 500;
43
43
  }
44
44
 
45
+ .ui-rc-table {
46
+ .#{$prefix}-table-cell {
47
+ &.#{$prefix}-table-selection-column {
48
+ //padding: 6px 8px !important;
49
+ //padding: 6px 8px !important;
50
+ }
51
+ }
52
+ }
45
53
 
46
54
 
47
55
  &.table-none-column-select {
@@ -57,9 +65,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
57
65
  }
58
66
 
59
67
  .#{$prefix}-table {
60
- line-height: 20px;
68
+
69
+ //line-height: 20px;
70
+
61
71
  .#{$prefix}-table-cell {
62
- min-height: 35px;
72
+ //min-height: 35px;
73
+ //height: 35px;
63
74
 
64
75
  .#{$prefix}-table-filter-column {
65
76
  .#{$prefix}-dropdown-trigger.#{$prefix}-table-filter-trigger {
@@ -324,6 +335,13 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
324
335
 
325
336
  .#{$prefix}-table-wrapper {
326
337
 
338
+ .#{$prefix}-table.#{$prefix}-table-small {
339
+ .#{$prefix}-table-selection-column{
340
+ //padding: 8px 8px;
341
+ //padding: 6px 8px;
342
+ }
343
+ }
344
+
327
345
  &.grid-editable {
328
346
 
329
347
  .#{$prefix}-table-row {
@@ -528,7 +546,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
528
546
  .#{$prefix}-table.#{$prefix}-table-small {
529
547
  .#{$prefix}-table-selection-column{
530
548
  //padding: 8px 8px;
531
- padding: 6px 8px;
549
+ //padding: 6px 8px;
532
550
  }
533
551
  }
534
552
 
@@ -620,7 +638,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
620
638
  .#{$prefix}-table-row-expand-icon {
621
639
  position: absolute;
622
640
  //.ui-rc_content {
623
- padding-left: $i * 10px;
641
+ //padding-left: $i * 10px;
624
642
  //}
625
643
  }
626
644
 
@@ -36,7 +36,8 @@ const Grid = props => {
36
36
  rowSelectedHoverBg: '#eb4619',
37
37
  cellFontSize: 12,
38
38
  cellFontSizeSM: 13,
39
- headerBg: '#ffffff'
39
+ headerBg: '#ffffff',
40
+ cellPaddingBlockSM: 7
40
41
  }
41
42
  }
42
43
  }
@@ -92,8 +92,6 @@ const GridEdit = props => {
92
92
  const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
93
93
  const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
94
94
 
95
- // const [showDraggingPoint, setShowDraggingPoint] = useState(false);
96
-
97
95
  const [rowsSelected, setRowsSelected] = (0, _react.useState)(new Set());
98
96
  const [startSelectedCells, setStartSelectedCell] = (0, _react.useState)(null);
99
97
  const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
@@ -266,10 +264,54 @@ const GridEdit = props => {
266
264
  }
267
265
  }
268
266
  };
269
- const handleDeleteAll = () => {};
267
+ const handleInsertChild = item => {
268
+ const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
269
+ const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
270
+ const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
271
+ if (item.onClick) {
272
+ item.onClick({
273
+ toolbar: item
274
+ });
275
+ } else {
276
+ const newData = [...dataSource];
277
+ let newElement = {};
278
+ if (!record.children || record.children.length === 0) {
279
+ newElement = {
280
+ ...record,
281
+ children: [{
282
+ ...defaultRowValue,
283
+ parentId: record.rowId,
284
+ rowId
285
+ }]
286
+ };
287
+ } else {
288
+ newElement = {
289
+ ...record,
290
+ children: [...record.children, {
291
+ ...defaultRowValue,
292
+ parentId: record.rowId,
293
+ rowId
294
+ }]
295
+ };
296
+ }
297
+ const newDataSource = (0, _hooks.updateArrayByKey)(newData, newElement, rowKey);
298
+ triggerChangeData?.(newDataSource, 'INSERT_CHILDREN');
299
+ }
300
+ const key = getRowKey(record, dataSource.indexOf(record));
301
+
302
+ // let newExpandedKeys: Key[];
303
+ const hasKey = mergedExpandedKeys.has(key);
304
+ if (!hasKey) {
305
+ const newExpandedKeys = [...mergedExpandedKeys, key];
306
+ setInnerExpandedKeys(newExpandedKeys);
307
+ }
308
+ };
309
+ const handleDeleteAll = () => {
310
+ triggerChangeData?.([], 'INSERT_BEFORE');
311
+ };
270
312
  const toolbarItemsBottom = (0, _react.useMemo)(() => {
271
313
  if (!rowsFocus || rowsFocus.length === 0) {
272
- return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER').map(item => {
314
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'INSERT_CHILDREN').map(item => {
273
315
  if (item.key === 'ADD') {
274
316
  return {
275
317
  ...item,
@@ -398,6 +440,24 @@ const GridEdit = props => {
398
440
  }
399
441
  };
400
442
  }
443
+ if (item.key === 'INSERT_CHILDREN') {
444
+ return {
445
+ ...item,
446
+ template: () => {
447
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
448
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
449
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
450
+ style: {
451
+ color: '#28c76f',
452
+ borderColor: '#28c76f'
453
+ },
454
+ variant: 'outlined',
455
+ onClick: () => handleInsertChild(item),
456
+ className: "d-flex toolbar-button"
457
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')));
458
+ }
459
+ };
460
+ }
401
461
  if (item.key === 'DELETE') {
402
462
  return {
403
463
  ...item,
@@ -958,8 +1018,8 @@ const GridEdit = props => {
958
1018
  const newData = [...dataSource];
959
1019
 
960
1020
  // @ts-ignore
961
- const index = newData.findIndex(item => formData[rowKey] === item[rowKey]);
962
- const rs = (0, _hooks.updateArrayByKey)(dataSource, row, rowKey);
1021
+ const index = (0, _hooks.flattenData)(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
1022
+ const rs = (0, _hooks.updateArrayByKey)(newData, row, rowKey);
963
1023
  if (index > -1) {
964
1024
  triggerChangeData?.(rs, 'onChange');
965
1025
  }
@@ -1420,7 +1480,8 @@ const GridEdit = props => {
1420
1480
  rowSelectedHoverBg: '#eb4619',
1421
1481
  cellFontSize: 12,
1422
1482
  cellFontSizeSM: 13,
1423
- headerBg: '#ffffff'
1483
+ headerBg: '#ffffff',
1484
+ cellPaddingBlockSM: 7
1424
1485
  // cellPaddingBlock: 0,
1425
1486
  // cellPaddingBlockSM: 0,
1426
1487
  // cellPaddingInlineSM: 0,
@@ -1454,6 +1515,7 @@ const GridEdit = props => {
1454
1515
  rowHoverable: false,
1455
1516
  bottomToolbar: bottomToolbar,
1456
1517
  expandable: {
1518
+ expandIconColumnIndex: (0, _hooks.checkChild)(dataSource) ? 3 : undefined,
1457
1519
  ...expandable,
1458
1520
  expandedRowKeys: innerExpandedKeys,
1459
1521
  expandIcon: args => {
@@ -1488,6 +1550,7 @@ const GridEdit = props => {
1488
1550
  }
1489
1551
  }
1490
1552
  },
1553
+ triggerChangeColumns: triggerChangeColumns,
1491
1554
  rowSelection: columns && columns.length === 0 ? undefined : {
1492
1555
  type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
1493
1556
  columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
package/package.json CHANGED
@@ -1,106 +1,106 @@
1
- {
2
- "name": "es-grid-template",
3
- "version": "1.2.3",
4
- "description": "es-grid-template",
5
- "keywords": [
6
- "react",
7
- "react-component",
8
- "grid",
9
- "table"
10
- ],
11
- "license": "MIT",
12
- "main": "lib/index",
13
- "module": "es/index",
14
- "files": [
15
- "lib",
16
- "es",
17
- "assets/*.css",
18
- "assets/*.scss"
19
- ],
20
- "scripts": {
21
- "__compile": "father build && ",
22
- "compile": "father build && sass assets/index.scss assets/index.css",
23
- "docs:build": "dumi build",
24
- "__docs:deploy": "gh-pages -d dist",
25
- "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
26
- "now-build": "npm run docs:build",
27
- "prepare": "dumi setup",
28
- "prepublishOnly": "npm run compile",
29
- "postpublish": "npm run docs:build",
30
- "__postpublish": "npm run docs:build && npm run docs:deploy",
31
- "start": "dumi dev",
32
- "test": "vitest --watch false",
33
- "coverage": "vitest run --coverage"
34
- },
35
- "dependencies": {
36
- "@ant-design/colors": "^8.0.0",
37
- "@ant-design/cssinjs": "^1.22.0",
38
- "@ant-design/cssinjs-utils": "^1.1.1",
39
- "@ant-design/icons": "^5.5.2",
40
- "@babel/runtime": "^7.11.2",
41
- "@core-rc/rc-select": "^0.0.8",
42
- "@ctrl/tinycolor": "^3.6.1",
43
- "@faker-js/faker": "^9.5.0",
44
- "@floating-ui/react": "^0.27.5",
45
- "@rc-component/color-picker": "^2.0.1",
46
- "@rc-component/father-plugin": "^2.0.1",
47
- "@rc-component/trigger": "^2.0.0",
48
- "@rc-component/util": "^1.0.1",
49
- "@types/react-resizable": "^3.0.8",
50
- "@types/styled-components": "^5.1.34",
51
- "@vitest/coverage-v8": "^2.0.5",
52
- "antd": "^5.24.1",
53
- "antd-style": "^3.7.1",
54
- "becoxy-icons": "^2.0.1",
55
- "classnames": "^2.3.1",
56
- "dayjs": "^1.11.13",
57
- "lodash": "^4.17.21",
58
- "moment": "^2.30.1",
59
- "postcss": "^8.4.35",
60
- "rc-checkbox": "^3.5.0",
61
- "rc-dropdown": "^4.2.1",
62
- "rc-field-form": "^2.6.0",
63
- "rc-master-ui": "^1.1.21",
64
- "rc-select": "^14.16.3",
65
- "rc-tooltip": "^6.3.0",
66
- "rc-tree": "^5.10.1",
67
- "rc-tree-select": "^5.24.5",
68
- "react-hook-form": "^7.54.2",
69
- "react-hot-toast": "^2.5.2",
70
- "react-numeric-component": "^1.0.7",
71
- "react-resizable": "^3.0.5",
72
- "sass": "^1.81.0",
73
- "styled-components": "^6.1.15",
74
- "throttle-debounce": "^5.0.2",
75
- "vitest": "^2.0.5"
76
- },
77
- "devDependencies": {
78
- "@babel/cli": "^7.26.4",
79
- "@babel/preset-env": "^7.26.9",
80
- "@rc-component/np": "^1.0.3",
81
- "@testing-library/react": "^14.0.0",
82
- "@types/jest": "^29.4.0",
83
- "@types/react": "^18.0.26",
84
- "@types/react-dom": "^18.0.10",
85
- "@types/warning": "^3.0.0",
86
- "cross-env": "^7.0.0",
87
- "dumi": "^2.2.13",
88
- "eslint": "^8.56.0",
89
- "eslint-plugin-unicorn": "^55.0.0",
90
- "father": "^4.0.0",
91
- "gh-pages": "^3.1.0",
92
- "less": "^4.1.1",
93
- "np": "^7.1.0",
94
- "rc-test": "^7.0.9",
95
- "react": "^18.2.0",
96
- "react-dom": "^18.2.0",
97
- "typescript": "^4.0.5"
98
- },
99
- "peerDependencies": {
100
- "react": ">=16.9.0",
101
- "react-dom": ">=16.9.0"
102
- },
103
- "umi": {
104
- "configFile": "config.ts"
105
- }
106
- }
1
+ {
2
+ "name": "es-grid-template",
3
+ "version": "1.2.4",
4
+ "description": "es-grid-template",
5
+ "keywords": [
6
+ "react",
7
+ "react-component",
8
+ "grid",
9
+ "table"
10
+ ],
11
+ "license": "MIT",
12
+ "main": "lib/index",
13
+ "module": "es/index",
14
+ "files": [
15
+ "lib",
16
+ "es",
17
+ "assets/*.css",
18
+ "assets/*.scss"
19
+ ],
20
+ "scripts": {
21
+ "__compile": "father build && ",
22
+ "compile": "father build && sass assets/index.scss assets/index.css",
23
+ "docs:build": "dumi build",
24
+ "__docs:deploy": "gh-pages -d dist",
25
+ "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js",
26
+ "now-build": "npm run docs:build",
27
+ "prepare": "dumi setup",
28
+ "prepublishOnly": "npm run compile",
29
+ "postpublish": "npm run docs:build",
30
+ "__postpublish": "npm run docs:build && npm run docs:deploy",
31
+ "start": "dumi dev",
32
+ "test": "vitest --watch false",
33
+ "coverage": "vitest run --coverage"
34
+ },
35
+ "dependencies": {
36
+ "@ant-design/colors": "^8.0.0",
37
+ "@ant-design/cssinjs": "^1.22.0",
38
+ "@ant-design/cssinjs-utils": "^1.1.1",
39
+ "@ant-design/icons": "^5.5.2",
40
+ "@babel/runtime": "^7.11.2",
41
+ "@core-rc/rc-select": "^0.0.8",
42
+ "@ctrl/tinycolor": "^3.6.1",
43
+ "@faker-js/faker": "^9.5.0",
44
+ "@floating-ui/react": "^0.27.5",
45
+ "@rc-component/color-picker": "^2.0.1",
46
+ "@rc-component/father-plugin": "^2.0.1",
47
+ "@rc-component/trigger": "^2.0.0",
48
+ "@rc-component/util": "^1.0.1",
49
+ "@types/react-resizable": "^3.0.8",
50
+ "@types/styled-components": "^5.1.34",
51
+ "@vitest/coverage-v8": "^2.0.5",
52
+ "antd": "^5.24.1",
53
+ "antd-style": "^3.7.1",
54
+ "becoxy-icons": "^2.0.1",
55
+ "classnames": "^2.3.1",
56
+ "dayjs": "^1.11.13",
57
+ "lodash": "^4.17.21",
58
+ "moment": "^2.30.1",
59
+ "postcss": "^8.4.35",
60
+ "rc-checkbox": "^3.5.0",
61
+ "rc-dropdown": "^4.2.1",
62
+ "rc-field-form": "^2.6.0",
63
+ "rc-master-ui": "^1.1.21",
64
+ "rc-select": "^14.16.3",
65
+ "rc-tooltip": "^6.3.0",
66
+ "rc-tree": "^5.10.1",
67
+ "rc-tree-select": "^5.24.5",
68
+ "react-hook-form": "^7.54.2",
69
+ "react-hot-toast": "^2.5.2",
70
+ "react-numeric-component": "^1.0.7",
71
+ "react-resizable": "^3.0.5",
72
+ "sass": "^1.81.0",
73
+ "styled-components": "^6.1.15",
74
+ "throttle-debounce": "^5.0.2",
75
+ "vitest": "^2.0.5"
76
+ },
77
+ "devDependencies": {
78
+ "@babel/cli": "^7.26.4",
79
+ "@babel/preset-env": "^7.26.9",
80
+ "@rc-component/np": "^1.0.3",
81
+ "@testing-library/react": "^14.0.0",
82
+ "@types/jest": "^29.4.0",
83
+ "@types/react": "^18.0.26",
84
+ "@types/react-dom": "^18.0.10",
85
+ "@types/warning": "^3.0.0",
86
+ "cross-env": "^7.0.0",
87
+ "dumi": "^2.2.13",
88
+ "eslint": "^8.56.0",
89
+ "eslint-plugin-unicorn": "^55.0.0",
90
+ "father": "^4.0.0",
91
+ "gh-pages": "^3.1.0",
92
+ "less": "^4.1.1",
93
+ "np": "^7.1.0",
94
+ "rc-test": "^7.0.9",
95
+ "react": "^18.2.0",
96
+ "react-dom": "^18.2.0",
97
+ "typescript": "^4.0.5"
98
+ },
99
+ "peerDependencies": {
100
+ "react": ">=16.9.0",
101
+ "react-dom": ">=16.9.0"
102
+ },
103
+ "umi": {
104
+ "configFile": "config.ts"
105
+ }
106
+ }