es-grid-template 1.9.38 → 1.9.40

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.
@@ -657,6 +657,7 @@ export type ToolbarItem = {
657
657
  title?: React.ReactNode;
658
658
  disabled?: boolean;
659
659
  hasMenu?: boolean;
660
+ fixedRight?: boolean;
660
661
  [key: string]: any;
661
662
  };
662
663
  export type LoadOptionsArgs = {
@@ -1432,6 +1432,221 @@ const TableContainerEdit = props => {
1432
1432
  triggerChangeData?.([...newData]);
1433
1433
  }
1434
1434
  };
1435
+ const toolbarItemsTop = React.useMemo(() => {
1436
+ if (!rowsFocus || rowsFocus.length === 0) {
1437
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.fixedRight !== false && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1438
+ if (item.key === 'ADD') {
1439
+ return {
1440
+ ...item,
1441
+ template: () => {
1442
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
1443
+ className: classNames(`be-toolbar-item`, item?.className)
1444
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
1445
+ overlayClassName: 'be-popup-container',
1446
+ trigger: ['click'],
1447
+ style: {
1448
+ color: '#28c76f',
1449
+ borderColor: '#28c76f'
1450
+ },
1451
+ className: 'toolbar-button toolbar-dropdown-button',
1452
+ menu: {
1453
+ items: itemsAdd,
1454
+ onClick: e => handleAddMulti(item, Number(e.key))
1455
+ }
1456
+ }, /*#__PURE__*/React.createElement("span", {
1457
+ style: {
1458
+ color: '#28c76f'
1459
+ },
1460
+ onClick: () => handleAddMulti(item, 1)
1461
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
1462
+ }
1463
+ };
1464
+ }
1465
+ if (item.key === 'DELETE') {
1466
+ return {
1467
+ ...item,
1468
+ template: () => {
1469
+ return /*#__PURE__*/React.createElement("div", {
1470
+ className: classNames(`be-toolbar-item`, item?.className)
1471
+ }, /*#__PURE__*/React.createElement(Button, {
1472
+ style: {
1473
+ color: '#eb4619',
1474
+ borderColor: '#eb4619'
1475
+ },
1476
+ variant: 'outlined',
1477
+ onClick: () => handleDeleteAll(item),
1478
+ className: "d-flex toolbar-button"
1479
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
1480
+ }
1481
+ };
1482
+ }
1483
+ return {
1484
+ ...item
1485
+ };
1486
+ });
1487
+ }
1488
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
1489
+ if (item.key === 'ADD') {
1490
+ return {
1491
+ ...item,
1492
+ template: () => {
1493
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
1494
+ className: classNames(`be-toolbar-item`, item?.className)
1495
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
1496
+ overlayClassName: 'be-popup-container',
1497
+ style: {
1498
+ color: '#28c76f',
1499
+ borderColor: '#28c76f'
1500
+ },
1501
+ className: 'toolbar-button toolbar-dropdown-button',
1502
+ menu: {
1503
+ items: itemsAdd,
1504
+ onClick: e => handleAddMulti(item, Number(e.key))
1505
+ }
1506
+ }, /*#__PURE__*/React.createElement("span", {
1507
+ style: {
1508
+ color: '#28c76f'
1509
+ },
1510
+ onClick: () => handleAddMulti(item, 1)
1511
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
1512
+ }
1513
+ };
1514
+ }
1515
+ if (item.key === 'DUPLICATE') {
1516
+ return {
1517
+ ...item,
1518
+ template: () => {
1519
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
1520
+ className: classNames(`be-toolbar-item`, item?.className)
1521
+ }, /*#__PURE__*/React.createElement(Button, {
1522
+ style: {
1523
+ color: '#28c76f',
1524
+ borderColor: '#28c76f'
1525
+ },
1526
+ variant: 'outlined',
1527
+ onClick: handleDuplicate,
1528
+ className: "d-flex toolbar-button"
1529
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
1530
+ }
1531
+ };
1532
+ }
1533
+ if (item.key === 'INSERT_BEFORE') {
1534
+ return {
1535
+ ...item,
1536
+ template: () => {
1537
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1538
+ className: classNames(`be-toolbar-item`, item?.className)
1539
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
1540
+ overlayClassName: 'be-popup-container',
1541
+ style: {
1542
+ color: '#28c76f',
1543
+ borderColor: '#28c76f'
1544
+ },
1545
+ className: 'toolbar-button toolbar-dropdown-button',
1546
+ menu: {
1547
+ items: itemsAdd,
1548
+ onClick: e => handleInsertBefore(item, Number(e.key))
1549
+ }
1550
+ }, /*#__PURE__*/React.createElement("span", {
1551
+ style: {
1552
+ color: '#28c76f'
1553
+ },
1554
+ onClick: () => handleInsertBefore(item, 1)
1555
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before'))));
1556
+ }
1557
+ };
1558
+ }
1559
+ if (item.key === 'INSERT_AFTER') {
1560
+ return {
1561
+ ...item,
1562
+ template: () => {
1563
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1564
+ className: classNames(`be-toolbar-item`, item?.className)
1565
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
1566
+ overlayClassName: 'be-popup-container',
1567
+ style: {
1568
+ color: '#28c76f',
1569
+ borderColor: '#28c76f'
1570
+ },
1571
+ className: 'toolbar-button toolbar-dropdown-button',
1572
+ menu: {
1573
+ items: itemsAdd,
1574
+ onClick: e => handleInsertAfter(item, Number(e.key))
1575
+ }
1576
+ }, /*#__PURE__*/React.createElement("span", {
1577
+ style: {
1578
+ color: '#28c76f'
1579
+ },
1580
+ onClick: () => handleInsertAfter(item, 1)
1581
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after'))));
1582
+ }
1583
+ };
1584
+ }
1585
+ if (item.key === 'INSERT_CHILDREN') {
1586
+ return {
1587
+ ...item,
1588
+ template: () => {
1589
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1590
+ className: classNames(`be-toolbar-item`, item?.className)
1591
+ }, /*#__PURE__*/React.createElement(Button, {
1592
+ style: {
1593
+ color: '#28c76f',
1594
+ borderColor: '#28c76f'
1595
+ },
1596
+ variant: 'outlined',
1597
+ onClick: () => handleInsertChild(item),
1598
+ className: "d-flex toolbar-button"
1599
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children')));
1600
+ }
1601
+ };
1602
+ }
1603
+ if (item.key === 'DELETE') {
1604
+ return {
1605
+ ...item,
1606
+ template: () => {
1607
+ return /*#__PURE__*/React.createElement("div", {
1608
+ className: classNames(`be-toolbar-item`, item?.className)
1609
+ }, /*#__PURE__*/React.createElement(Button, {
1610
+ style: {
1611
+ color: '#eb4619',
1612
+ borderColor: '#eb4619'
1613
+ },
1614
+ variant: 'outlined',
1615
+ onClick: handleDeleteAll,
1616
+ className: "d-flex toolbar-button"
1617
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
1618
+ }
1619
+ };
1620
+ }
1621
+ if (item.key === 'DELETE_ROWS') {
1622
+ return {
1623
+ ...item,
1624
+ template: () => {
1625
+ return /*#__PURE__*/React.createElement("div", {
1626
+ className: classNames(`be-toolbar-item`, item?.className)
1627
+ }, /*#__PURE__*/React.createElement(Button, {
1628
+ style: {
1629
+ color: '#eb4619',
1630
+ borderColor: '#eb4619'
1631
+ },
1632
+ variant: 'outlined',
1633
+ onClick: () => handleDeleteRows(item),
1634
+ className: "d-flex toolbar-button"
1635
+ }, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`));
1636
+ }
1637
+ };
1638
+ }
1639
+ return {
1640
+ ...item
1641
+ };
1642
+ });
1643
+ }, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
1644
+ const toolbarItemTopRight = React.useMemo(() => {
1645
+ if (!toolbarItems) {
1646
+ return undefined;
1647
+ }
1648
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight && it.visible !== false);
1649
+ }, [toolbarItems]);
1435
1650
  const toolbarItemsBottom = React.useMemo(() => {
1436
1651
  if (!rowsFocus || rowsFocus.length === 0) {
1437
1652
  return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
@@ -1900,7 +2115,7 @@ const TableContainerEdit = props => {
1900
2115
  overflow: 'hidden'
1901
2116
  }
1902
2117
  }, /*#__PURE__*/React.createElement(Toolbar, {
1903
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
2118
+ items: toolbarItemsTop ?? [],
1904
2119
  mode: 'scroll'
1905
2120
  })), /*#__PURE__*/React.createElement("div", {
1906
2121
  style: {
@@ -1917,7 +2132,15 @@ const TableContainerEdit = props => {
1917
2132
  showTotal: (total, range) =>
1918
2133
  // @ts-ignore
1919
2134
  `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
1920
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
2135
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/React.createElement("div", {
2136
+ style: {
2137
+ flex: 1,
2138
+ overflow: 'hidden'
2139
+ }
2140
+ }, /*#__PURE__*/React.createElement(Toolbar, {
2141
+ items: toolbarItemTopRight,
2142
+ mode: 'responsive'
2143
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
1921
2144
  fontSize: 16,
1922
2145
  onClick: () => {
1923
2146
  setIsFullScreen(!isFullScreen);
@@ -194,10 +194,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
194
194
  value: any;
195
195
  rowData: RecordType;
196
196
  }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
197
- onCellStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width">);
198
- onCellHeaderStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width">);
197
+ onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display">);
198
+ onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display">);
199
199
  onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
200
- onCellFooterStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "minWidth" | "width">);
200
+ onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "right" | "left" | "position" | "display">);
201
201
  getValue?: (row: any, rowIndex: number) => any;
202
202
  getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
203
203
  headerCellProps?: import("./../../grid-component/type").CellProps;
@@ -182,16 +182,23 @@ const InternalTable = props => {
182
182
  colorLink: '#eb4619',
183
183
  colorLinkHover: '#eb4619'
184
184
  },
185
+ TableSelect: {
186
+ activeBorderColor: '#1677ff',
187
+ hoverBorderColor: '#1677ff',
188
+ zIndexPopup: 1059
189
+ },
185
190
  Select: {
186
191
  activeBorderColor: '#1677ff',
187
- hoverBorderColor: '#1677ff'
192
+ hoverBorderColor: '#1677ff',
193
+ zIndexPopup: 1059
188
194
  // colorPrimary: '#eb4619',
189
195
  // colorBgBase: 'red'
190
196
  },
191
197
  DatePicker: {
192
198
  colorPrimary: '#eb4619',
193
199
  activeBorderColor: '#1677ff',
194
- hoverBorderColor: '#1677ff'
200
+ hoverBorderColor: '#1677ff',
201
+ zIndexPopup: 1059
195
202
  },
196
203
  Pagination: {
197
204
  fontSize: 12
@@ -89,7 +89,6 @@ const TableContainer = props => {
89
89
  const [tableHeight, settableHeight] = React.useState(0);
90
90
  const [focusedCell, setFocusedCell] = React.useState(undefined);
91
91
  React.useEffect(() => {
92
- // const totalHeight = minHeight ?? height
93
92
  const totalHeight = getTableHeight(height, minHeight);
94
93
  if (totalHeight) {
95
94
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
@@ -197,6 +196,24 @@ const TableContainer = props => {
197
196
  // })
198
197
  }
199
198
  }, [columnSizingInfo]);
199
+ const toolbarItemTop = React.useMemo(() => {
200
+ if (!toolbarItems) {
201
+ return undefined;
202
+ }
203
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight !== false);
204
+ }, [toolbarItems]);
205
+ const toolbarItemBottom = React.useMemo(() => {
206
+ if (!toolbarItems) {
207
+ return undefined;
208
+ }
209
+ return toolbarItems.filter(it => it.position === 'Bottom');
210
+ }, [toolbarItems]);
211
+ const toolbarItemTopRight = React.useMemo(() => {
212
+ if (!toolbarItems) {
213
+ return undefined;
214
+ }
215
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
216
+ }, [toolbarItems]);
200
217
  const triggerCommandClick = args => {
201
218
  // const { id: idCommand, rowId, rowData, index } = args
202
219
 
@@ -219,7 +236,8 @@ const TableContainer = props => {
219
236
  style: {
220
237
  display: 'flex',
221
238
  justifyContent: 'space-between',
222
- alignItems: 'center'
239
+ alignItems: 'center',
240
+ gap: '1rem'
223
241
  }
224
242
  }, /*#__PURE__*/React.createElement("div", {
225
243
  style: {
@@ -227,7 +245,7 @@ const TableContainer = props => {
227
245
  overflow: 'hidden'
228
246
  }
229
247
  }, /*#__PURE__*/React.createElement(Toolbar, {
230
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom')
248
+ items: toolbarItemTop ?? []
231
249
  // mode={'scroll'}
232
250
  ,
233
251
  mode: toolbarMode
@@ -246,7 +264,15 @@ const TableContainer = props => {
246
264
  showTotal: (totalItems, range) =>
247
265
  // @ts-ignore
248
266
  `${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
249
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
267
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/React.createElement("div", {
268
+ style: {
269
+ flex: 1,
270
+ overflow: 'hidden'
271
+ }
272
+ }, /*#__PURE__*/React.createElement(Toolbar, {
273
+ items: toolbarItemTopRight,
274
+ mode: toolbarMode
275
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
250
276
  fontSize: 16,
251
277
  onClick: () => {
252
278
  setIsFullScreen(!isFullScreen);
@@ -341,7 +367,17 @@ const TableContainer = props => {
341
367
  fixedRightColumns: fixedRightColumns
342
368
  }))), /*#__PURE__*/React.createElement("div", {
343
369
  ref: bottomToolbarRef
344
- }, pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination, _extends({
370
+ }, /*#__PURE__*/React.createElement("div", {
371
+ style: {
372
+ flex: 1,
373
+ overflow: 'hidden'
374
+ }
375
+ }, /*#__PURE__*/React.createElement(Toolbar, {
376
+ items: toolbarItemBottom ?? []
377
+ // mode={'scroll'}
378
+ ,
379
+ mode: toolbarMode
380
+ })), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination, _extends({
345
381
  pageSizeOptions: [20, 50, 100, 1000, 10000],
346
382
  rootClassName: 'pagination-template',
347
383
  showSizeChanger: true,
@@ -1,7 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { Fragment } from "react";
3
3
  import { useCopyToClipboard } from 'usehooks-ts';
4
- import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getEditType, getFormat, getRowIdsBetween, getSelectedCellMatrix, getTableHeight, isEditable, isFormattedNumber, newGuid, parseExcelClipboard,
4
+ import { checkDecimalSeparator, checkThousandSeparator,
5
+ // convertDateToDayjs,
6
+ detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDatepickerFormat,
7
+ // getDatepickerFormat,
8
+ getDefaultValue, getEditType, getFormat, getRowIdsBetween, getSelectedCellMatrix, getTableHeight, isDateValue, isEditable, isEmpty, isFormattedNumber, newGuid, parseExcelClipboard,
5
9
  // parseExcelClipboardText,
6
10
  sumSize,
7
11
  // sumSize,
@@ -24,6 +28,7 @@ import withReactContent from "sweetalert2-react-content";
24
28
  import Swal from "sweetalert2";
25
29
  import { useLocale } from "rc-master-ui/es/locale";
26
30
  import { getToolbarTemplate } from "../grid-component/hooks";
31
+ import moment from "moment";
27
32
  const MySwal = withReactContent(Swal);
28
33
  const {
29
34
  Paragraph,
@@ -409,6 +414,17 @@ const TableContainerEdit = props => {
409
414
  [columnKey]: Number(val)
410
415
  };
411
416
  }
417
+ } else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
418
+ const isDate = isDateValue(cellValue.trim());
419
+ const colFormat = typeof columnOri?.format === 'function' ? columnOri?.format(record) : columnOri?.format;
420
+ const cellFormat = getFormat(colFormat, format);
421
+ const editType = getEditType(columnOri);
422
+ const dateFormat = getDatepickerFormat(editType, cellFormat);
423
+ const date = isDate && !isEmpty(cellValue.trim()) ? moment(cellValue.trim(), dateFormat).format("YYYY-MM-DDTHH:mm:ssZ") : null;
424
+ newData[targetRow] = {
425
+ ...newData[targetRow],
426
+ [columnKey]: date
427
+ };
412
428
  } else {
413
429
  newData[targetRow] = {
414
430
  ...newData[targetRow],
@@ -474,8 +490,6 @@ const TableContainerEdit = props => {
474
490
 
475
491
  if (isEdit) {
476
492
  const columnKey = allCols[targetCol].id;
477
-
478
- // if (columnOri.type === 'number' && isFormattedNumber(cellValue.trim())) {
479
493
  if (columnOri.type === 'number') {
480
494
  if (cellValue.trim() === '') {
481
495
  childData[targetRow] = {
@@ -505,6 +519,17 @@ const TableContainerEdit = props => {
505
519
  [columnKey]: Number(val)
506
520
  };
507
521
  }
522
+ } else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
523
+ const isDate = isDateValue(cellValue.trim());
524
+ const colFormat = typeof columnOri?.format === 'function' ? columnOri?.format(record) : columnOri?.format;
525
+ const cellFormat = getFormat(colFormat, format);
526
+ const editType = getEditType(columnOri);
527
+ const dateFormat = getDatepickerFormat(editType, cellFormat);
528
+ const date = isDate && !isEmpty(cellValue.trim()) ? moment(cellValue.trim(), dateFormat).format("YYYY-MM-DDTHH:mm:ssZ") : null;
529
+ childData[targetRow] = {
530
+ ...childData[targetRow],
531
+ [columnKey]: date
532
+ };
508
533
  } else {
509
534
  childData[targetRow] = {
510
535
  ...childData[targetRow],
@@ -1550,7 +1575,7 @@ const TableContainerEdit = props => {
1550
1575
  const toolbarItemsTop = React.useMemo(() => {
1551
1576
  // Chưa có dòng| ô được chọn
1552
1577
  if (!rowsFocus || rowsFocus.length === 0) {
1553
- return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1578
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1554
1579
  if (item.key === 'ADD') {
1555
1580
  return {
1556
1581
  ...item,
@@ -1611,7 +1636,7 @@ const TableContainerEdit = props => {
1611
1636
  };
1612
1637
  });
1613
1638
  }
1614
- return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false).map(item => {
1639
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== false).map(item => {
1615
1640
  if (item.key === 'ADD') {
1616
1641
  return {
1617
1642
  ...item,
@@ -1799,6 +1824,12 @@ const TableContainerEdit = props => {
1799
1824
  };
1800
1825
  });
1801
1826
  }, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
1827
+ const toolbarItemTopRight = React.useMemo(() => {
1828
+ if (!toolbarItems) {
1829
+ return undefined;
1830
+ }
1831
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
1832
+ }, [toolbarItems]);
1802
1833
  const triggerCommandClick = args => {
1803
1834
  const {
1804
1835
  id: idCommand,
@@ -2007,7 +2038,8 @@ const TableContainerEdit = props => {
2007
2038
  style: {
2008
2039
  display: 'flex',
2009
2040
  justifyContent: 'space-between',
2010
- alignItems: 'center'
2041
+ alignItems: 'center',
2042
+ gap: '1rem'
2011
2043
  }
2012
2044
  }, /*#__PURE__*/React.createElement("div", {
2013
2045
  style: {
@@ -2042,7 +2074,15 @@ const TableContainerEdit = props => {
2042
2074
  showTotal: (total, range) =>
2043
2075
  // @ts-ignore
2044
2076
  `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
2045
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
2077
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/React.createElement("div", {
2078
+ style: {
2079
+ flex: 1,
2080
+ overflow: 'hidden'
2081
+ }
2082
+ }, /*#__PURE__*/React.createElement(Toolbar, {
2083
+ items: toolbarItemTopRight,
2084
+ mode: toolbarMode
2085
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
2046
2086
  fontSize: 16,
2047
2087
  onClick: () => {
2048
2088
  setIsFullScreen(!isFullScreen);
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { useContext } from "react";
3
- import { DatePicker, TimePicker, ColorPicker } from "rc-master-ui";
4
- import { Divider, Row, Col, Input, Button } from "antd";
3
+ import { DatePicker, TimePicker, ColorPicker, Input } from "rc-master-ui";
4
+ import { Divider, Row, Col, Button } from "antd";
5
5
  import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertArrayWithIndent, convertDateToDayjs, convertLabelToTitle, getDatepickerFormat, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets, getFormat, removeVietnameseTones } from "../hook/utils";
6
6
  import classNames from "classnames";
7
7
  import { NumericFormat } from "react-numeric-component";
@@ -1,6 +1,6 @@
1
1
  import Space from "rc-master-ui/es/space";
2
2
  import Command from "../components/command/Command";
3
- import { getCommonPinningStyles } from "../hook/utils";
3
+ import { getCommonPinningStyles, getFormat } from "../hook/utils";
4
4
  import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
5
5
  import classNames from "classnames";
6
6
  import React from "react";
@@ -182,7 +182,7 @@ const TableBodyCell = props => {
182
182
  const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
183
183
  const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
184
184
  const record = cell.row.original;
185
- const columnMeta = cell.column.columnDef.meta ?? {};
185
+ const columnMeta = React.useMemo(() => cell.column.columnDef.meta ?? {}, [cell.column.columnDef.meta]);
186
186
  const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
187
187
 
188
188
  // const tooltipContent: any = (isOpenTooltip === false)
@@ -208,7 +208,9 @@ const TableBodyCell = props => {
208
208
  const parrents = cell.row.getParentRows();
209
209
  const cellValue = cell.getValue();
210
210
  const rowIndex = cell.row.index;
211
- const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
211
+ const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
212
+ const cellFormat = getFormat(colFormat, format);
213
+ const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
212
214
  const valueCellString = getValueCellString(columnMeta, cellValue, record, rowIndex, colIndex, format);
213
215
  const tooltipContent = React.useMemo(() => {
214
216
  if (isOpenTooltip === false) {
@@ -1,6 +1,6 @@
1
1
  import Space from "rc-master-ui/es/space";
2
2
  import Command from "../components/command/Command";
3
- import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
3
+ import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getFormat, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
4
4
  import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
5
5
  import classNames from "classnames";
6
6
  import React from "react";
@@ -1113,7 +1113,9 @@ const TableBodyCellEdit = props => {
1113
1113
  };
1114
1114
  const cellValue = cell.getValue();
1115
1115
  const rowIndex = cell.row.index;
1116
- const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, true);
1116
+ const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
1117
+ const cellFormat = getFormat(colFormat, format);
1118
+ const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
1117
1119
  return /*#__PURE__*/React.createElement("div", {
1118
1120
  key: cell.id,
1119
1121
  ref: el => {
@@ -182,6 +182,10 @@ const TableHeadCell2 = props => {
182
182
  onChange: val => {
183
183
  column.setFilterOperator(val);
184
184
  }
185
+ // dropdownStyle={{
186
+
187
+ // zIndex: 1059
188
+ // }}
185
189
  })), /*#__PURE__*/React.createElement("div", {
186
190
  style: {
187
191
  marginBottom: 8
@@ -109,6 +109,18 @@ const TableContainer = props => {
109
109
  document.removeEventListener('mousedown', handleClickOutside);
110
110
  };
111
111
  }, []);
112
+ const toolbarItemTop = React.useMemo(() => {
113
+ if (!toolbarItems) {
114
+ return undefined;
115
+ }
116
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight !== false);
117
+ }, [toolbarItems]);
118
+ const toolbarItemTopRight = React.useMemo(() => {
119
+ if (!toolbarItems) {
120
+ return undefined;
121
+ }
122
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
123
+ }, [toolbarItems]);
112
124
  const triggerCommandClick = args => {
113
125
  // const { id: idCommand, rowId, rowData, index } = args
114
126
 
@@ -181,7 +193,7 @@ const TableContainer = props => {
181
193
  overflow: 'hidden'
182
194
  }
183
195
  }, /*#__PURE__*/React.createElement(Toolbar, {
184
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
196
+ items: toolbarItemTop ?? [],
185
197
  mode: toolbarMode
186
198
  })), /*#__PURE__*/React.createElement("div", {
187
199
  style: {
@@ -198,7 +210,15 @@ const TableContainer = props => {
198
210
  showTotal: (totalItems, range) =>
199
211
  // @ts-ignore
200
212
  `${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
201
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
213
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/React.createElement("div", {
214
+ style: {
215
+ flex: 1,
216
+ overflow: 'hidden'
217
+ }
218
+ }, /*#__PURE__*/React.createElement(Toolbar, {
219
+ items: toolbarItemTopRight,
220
+ mode: toolbarMode
221
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
202
222
  fontSize: 16,
203
223
  onClick: () => {
204
224
  setIsFullScreen(!isFullScreen);
@@ -657,6 +657,7 @@ export type ToolbarItem = {
657
657
  title?: React.ReactNode;
658
658
  disabled?: boolean;
659
659
  hasMenu?: boolean;
660
+ fixedRight?: boolean;
660
661
  [key: string]: any;
661
662
  };
662
663
  export type LoadOptionsArgs = {
@@ -1440,6 +1440,221 @@ const TableContainerEdit = props => {
1440
1440
  triggerChangeData?.([...newData]);
1441
1441
  }
1442
1442
  };
1443
+ const toolbarItemsTop = _react.default.useMemo(() => {
1444
+ if (!rowsFocus || rowsFocus.length === 0) {
1445
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.fixedRight !== false && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1446
+ if (item.key === 'ADD') {
1447
+ return {
1448
+ ...item,
1449
+ template: () => {
1450
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
1451
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1452
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown.Button, {
1453
+ overlayClassName: 'be-popup-container',
1454
+ trigger: ['click'],
1455
+ style: {
1456
+ color: '#28c76f',
1457
+ borderColor: '#28c76f'
1458
+ },
1459
+ className: 'toolbar-button toolbar-dropdown-button',
1460
+ menu: {
1461
+ items: itemsAdd,
1462
+ onClick: e => handleAddMulti(item, Number(e.key))
1463
+ }
1464
+ }, /*#__PURE__*/_react.default.createElement("span", {
1465
+ style: {
1466
+ color: '#28c76f'
1467
+ },
1468
+ onClick: () => handleAddMulti(item, 1)
1469
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
1470
+ }
1471
+ };
1472
+ }
1473
+ if (item.key === 'DELETE') {
1474
+ return {
1475
+ ...item,
1476
+ template: () => {
1477
+ return /*#__PURE__*/_react.default.createElement("div", {
1478
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1479
+ }, /*#__PURE__*/_react.default.createElement(_button.default, {
1480
+ style: {
1481
+ color: '#eb4619',
1482
+ borderColor: '#eb4619'
1483
+ },
1484
+ variant: 'outlined',
1485
+ onClick: () => handleDeleteAll(item),
1486
+ className: "d-flex toolbar-button"
1487
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
1488
+ }
1489
+ };
1490
+ }
1491
+ return {
1492
+ ...item
1493
+ };
1494
+ });
1495
+ }
1496
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
1497
+ if (item.key === 'ADD') {
1498
+ return {
1499
+ ...item,
1500
+ template: () => {
1501
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
1502
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1503
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown.Button, {
1504
+ overlayClassName: 'be-popup-container',
1505
+ style: {
1506
+ color: '#28c76f',
1507
+ borderColor: '#28c76f'
1508
+ },
1509
+ className: 'toolbar-button toolbar-dropdown-button',
1510
+ menu: {
1511
+ items: itemsAdd,
1512
+ onClick: e => handleAddMulti(item, Number(e.key))
1513
+ }
1514
+ }, /*#__PURE__*/_react.default.createElement("span", {
1515
+ style: {
1516
+ color: '#28c76f'
1517
+ },
1518
+ onClick: () => handleAddMulti(item, 1)
1519
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
1520
+ }
1521
+ };
1522
+ }
1523
+ if (item.key === 'DUPLICATE') {
1524
+ return {
1525
+ ...item,
1526
+ template: () => {
1527
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
1528
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1529
+ }, /*#__PURE__*/_react.default.createElement(_button.default, {
1530
+ style: {
1531
+ color: '#28c76f',
1532
+ borderColor: '#28c76f'
1533
+ },
1534
+ variant: 'outlined',
1535
+ onClick: handleDuplicate,
1536
+ className: "d-flex toolbar-button"
1537
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
1538
+ }
1539
+ };
1540
+ }
1541
+ if (item.key === 'INSERT_BEFORE') {
1542
+ return {
1543
+ ...item,
1544
+ template: () => {
1545
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1546
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1547
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown.Button, {
1548
+ overlayClassName: 'be-popup-container',
1549
+ style: {
1550
+ color: '#28c76f',
1551
+ borderColor: '#28c76f'
1552
+ },
1553
+ className: 'toolbar-button toolbar-dropdown-button',
1554
+ menu: {
1555
+ items: itemsAdd,
1556
+ onClick: e => handleInsertBefore(item, Number(e.key))
1557
+ }
1558
+ }, /*#__PURE__*/_react.default.createElement("span", {
1559
+ style: {
1560
+ color: '#28c76f'
1561
+ },
1562
+ onClick: () => handleInsertBefore(item, 1)
1563
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before'))));
1564
+ }
1565
+ };
1566
+ }
1567
+ if (item.key === 'INSERT_AFTER') {
1568
+ return {
1569
+ ...item,
1570
+ template: () => {
1571
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1572
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1573
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown.Button, {
1574
+ overlayClassName: 'be-popup-container',
1575
+ style: {
1576
+ color: '#28c76f',
1577
+ borderColor: '#28c76f'
1578
+ },
1579
+ className: 'toolbar-button toolbar-dropdown-button',
1580
+ menu: {
1581
+ items: itemsAdd,
1582
+ onClick: e => handleInsertAfter(item, Number(e.key))
1583
+ }
1584
+ }, /*#__PURE__*/_react.default.createElement("span", {
1585
+ style: {
1586
+ color: '#28c76f'
1587
+ },
1588
+ onClick: () => handleInsertAfter(item, 1)
1589
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after'))));
1590
+ }
1591
+ };
1592
+ }
1593
+ if (item.key === 'INSERT_CHILDREN') {
1594
+ return {
1595
+ ...item,
1596
+ template: () => {
1597
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1598
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1599
+ }, /*#__PURE__*/_react.default.createElement(_button.default, {
1600
+ style: {
1601
+ color: '#28c76f',
1602
+ borderColor: '#28c76f'
1603
+ },
1604
+ variant: 'outlined',
1605
+ onClick: () => handleInsertChild(item),
1606
+ className: "d-flex toolbar-button"
1607
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children')));
1608
+ }
1609
+ };
1610
+ }
1611
+ if (item.key === 'DELETE') {
1612
+ return {
1613
+ ...item,
1614
+ template: () => {
1615
+ return /*#__PURE__*/_react.default.createElement("div", {
1616
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1617
+ }, /*#__PURE__*/_react.default.createElement(_button.default, {
1618
+ style: {
1619
+ color: '#eb4619',
1620
+ borderColor: '#eb4619'
1621
+ },
1622
+ variant: 'outlined',
1623
+ onClick: handleDeleteAll,
1624
+ className: "d-flex toolbar-button"
1625
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
1626
+ }
1627
+ };
1628
+ }
1629
+ if (item.key === 'DELETE_ROWS') {
1630
+ return {
1631
+ ...item,
1632
+ template: () => {
1633
+ return /*#__PURE__*/_react.default.createElement("div", {
1634
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1635
+ }, /*#__PURE__*/_react.default.createElement(_button.default, {
1636
+ style: {
1637
+ color: '#eb4619',
1638
+ borderColor: '#eb4619'
1639
+ },
1640
+ variant: 'outlined',
1641
+ onClick: () => handleDeleteRows(item),
1642
+ className: "d-flex toolbar-button"
1643
+ }, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`));
1644
+ }
1645
+ };
1646
+ }
1647
+ return {
1648
+ ...item
1649
+ };
1650
+ });
1651
+ }, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
1652
+ const toolbarItemTopRight = _react.default.useMemo(() => {
1653
+ if (!toolbarItems) {
1654
+ return undefined;
1655
+ }
1656
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight && it.visible !== false);
1657
+ }, [toolbarItems]);
1443
1658
  const toolbarItemsBottom = _react.default.useMemo(() => {
1444
1659
  if (!rowsFocus || rowsFocus.length === 0) {
1445
1660
  return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
@@ -1908,7 +2123,7 @@ const TableContainerEdit = props => {
1908
2123
  overflow: 'hidden'
1909
2124
  }
1910
2125
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
1911
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
2126
+ items: toolbarItemsTop ?? [],
1912
2127
  mode: 'scroll'
1913
2128
  })), /*#__PURE__*/_react.default.createElement("div", {
1914
2129
  style: {
@@ -1925,7 +2140,15 @@ const TableContainerEdit = props => {
1925
2140
  showTotal: (total, range) =>
1926
2141
  // @ts-ignore
1927
2142
  `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
1928
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
2143
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/_react.default.createElement("div", {
2144
+ style: {
2145
+ flex: 1,
2146
+ overflow: 'hidden'
2147
+ }
2148
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
2149
+ items: toolbarItemTopRight,
2150
+ mode: 'responsive'
2151
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
1929
2152
  fontSize: 16,
1930
2153
  onClick: () => {
1931
2154
  setIsFullScreen(!isFullScreen);
@@ -191,16 +191,23 @@ const InternalTable = props => {
191
191
  colorLink: '#eb4619',
192
192
  colorLinkHover: '#eb4619'
193
193
  },
194
+ TableSelect: {
195
+ activeBorderColor: '#1677ff',
196
+ hoverBorderColor: '#1677ff',
197
+ zIndexPopup: 1059
198
+ },
194
199
  Select: {
195
200
  activeBorderColor: '#1677ff',
196
- hoverBorderColor: '#1677ff'
201
+ hoverBorderColor: '#1677ff',
202
+ zIndexPopup: 1059
197
203
  // colorPrimary: '#eb4619',
198
204
  // colorBgBase: 'red'
199
205
  },
200
206
  DatePicker: {
201
207
  colorPrimary: '#eb4619',
202
208
  activeBorderColor: '#1677ff',
203
- hoverBorderColor: '#1677ff'
209
+ hoverBorderColor: '#1677ff',
210
+ zIndexPopup: 1059
204
211
  },
205
212
  Pagination: {
206
213
  fontSize: 12
@@ -96,7 +96,6 @@ const TableContainer = props => {
96
96
  const [tableHeight, settableHeight] = _react.default.useState(0);
97
97
  const [focusedCell, setFocusedCell] = _react.default.useState(undefined);
98
98
  _react.default.useEffect(() => {
99
- // const totalHeight = minHeight ?? height
100
99
  const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
101
100
  if (totalHeight) {
102
101
  const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
@@ -204,6 +203,24 @@ const TableContainer = props => {
204
203
  // })
205
204
  }
206
205
  }, [columnSizingInfo]);
206
+ const toolbarItemTop = _react.default.useMemo(() => {
207
+ if (!toolbarItems) {
208
+ return undefined;
209
+ }
210
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight !== false);
211
+ }, [toolbarItems]);
212
+ const toolbarItemBottom = _react.default.useMemo(() => {
213
+ if (!toolbarItems) {
214
+ return undefined;
215
+ }
216
+ return toolbarItems.filter(it => it.position === 'Bottom');
217
+ }, [toolbarItems]);
218
+ const toolbarItemTopRight = _react.default.useMemo(() => {
219
+ if (!toolbarItems) {
220
+ return undefined;
221
+ }
222
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
223
+ }, [toolbarItems]);
207
224
  const triggerCommandClick = args => {
208
225
  // const { id: idCommand, rowId, rowData, index } = args
209
226
 
@@ -226,7 +243,8 @@ const TableContainer = props => {
226
243
  style: {
227
244
  display: 'flex',
228
245
  justifyContent: 'space-between',
229
- alignItems: 'center'
246
+ alignItems: 'center',
247
+ gap: '1rem'
230
248
  }
231
249
  }, /*#__PURE__*/_react.default.createElement("div", {
232
250
  style: {
@@ -234,7 +252,7 @@ const TableContainer = props => {
234
252
  overflow: 'hidden'
235
253
  }
236
254
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
237
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom')
255
+ items: toolbarItemTop ?? []
238
256
  // mode={'scroll'}
239
257
  ,
240
258
  mode: toolbarMode
@@ -253,7 +271,15 @@ const TableContainer = props => {
253
271
  showTotal: (totalItems, range) =>
254
272
  // @ts-ignore
255
273
  `${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
256
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
274
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/_react.default.createElement("div", {
275
+ style: {
276
+ flex: 1,
277
+ overflow: 'hidden'
278
+ }
279
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
280
+ items: toolbarItemTopRight,
281
+ mode: toolbarMode
282
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
257
283
  fontSize: 16,
258
284
  onClick: () => {
259
285
  setIsFullScreen(!isFullScreen);
@@ -348,7 +374,17 @@ const TableContainer = props => {
348
374
  fixedRightColumns: fixedRightColumns
349
375
  }))), /*#__PURE__*/_react.default.createElement("div", {
350
376
  ref: bottomToolbarRef
351
- }, pagination && !infiniteScroll && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
377
+ }, /*#__PURE__*/_react.default.createElement("div", {
378
+ style: {
379
+ flex: 1,
380
+ overflow: 'hidden'
381
+ }
382
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
383
+ items: toolbarItemBottom ?? []
384
+ // mode={'scroll'}
385
+ ,
386
+ mode: toolbarMode
387
+ })), pagination && !infiniteScroll && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
352
388
  pageSizeOptions: [20, 50, 100, 1000, 10000],
353
389
  rootClassName: 'pagination-template',
354
390
  showSizeChanger: true,
@@ -27,6 +27,7 @@ var _sweetalert2ReactContent = _interopRequireDefault(require("sweetalert2-react
27
27
  var _sweetalert = _interopRequireDefault(require("sweetalert2"));
28
28
  var _locale = require("rc-master-ui/es/locale");
29
29
  var _hooks = require("../grid-component/hooks");
30
+ var _moment = _interopRequireDefault(require("moment"));
30
31
  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); }
31
32
  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; }
32
33
  const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
@@ -414,6 +415,17 @@ const TableContainerEdit = props => {
414
415
  [columnKey]: Number(val)
415
416
  };
416
417
  }
418
+ } else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
419
+ const isDate = (0, _utils.isDateValue)(cellValue.trim());
420
+ const colFormat = typeof columnOri?.format === 'function' ? columnOri?.format(record) : columnOri?.format;
421
+ const cellFormat = (0, _utils.getFormat)(colFormat, format);
422
+ const editType = (0, _utils.getEditType)(columnOri);
423
+ const dateFormat = (0, _utils.getDatepickerFormat)(editType, cellFormat);
424
+ const date = isDate && !(0, _utils.isEmpty)(cellValue.trim()) ? (0, _moment.default)(cellValue.trim(), dateFormat).format("YYYY-MM-DDTHH:mm:ssZ") : null;
425
+ newData[targetRow] = {
426
+ ...newData[targetRow],
427
+ [columnKey]: date
428
+ };
417
429
  } else {
418
430
  newData[targetRow] = {
419
431
  ...newData[targetRow],
@@ -479,8 +491,6 @@ const TableContainerEdit = props => {
479
491
 
480
492
  if (isEdit) {
481
493
  const columnKey = allCols[targetCol].id;
482
-
483
- // if (columnOri.type === 'number' && isFormattedNumber(cellValue.trim())) {
484
494
  if (columnOri.type === 'number') {
485
495
  if (cellValue.trim() === '') {
486
496
  childData[targetRow] = {
@@ -510,6 +520,17 @@ const TableContainerEdit = props => {
510
520
  [columnKey]: Number(val)
511
521
  };
512
522
  }
523
+ } else if (columnOri.type === 'data' || columnOri.type === 'datatime' || columnOri.editType === 'date' || columnOri.editType === 'datetime') {
524
+ const isDate = (0, _utils.isDateValue)(cellValue.trim());
525
+ const colFormat = typeof columnOri?.format === 'function' ? columnOri?.format(record) : columnOri?.format;
526
+ const cellFormat = (0, _utils.getFormat)(colFormat, format);
527
+ const editType = (0, _utils.getEditType)(columnOri);
528
+ const dateFormat = (0, _utils.getDatepickerFormat)(editType, cellFormat);
529
+ const date = isDate && !(0, _utils.isEmpty)(cellValue.trim()) ? (0, _moment.default)(cellValue.trim(), dateFormat).format("YYYY-MM-DDTHH:mm:ssZ") : null;
530
+ childData[targetRow] = {
531
+ ...childData[targetRow],
532
+ [columnKey]: date
533
+ };
513
534
  } else {
514
535
  childData[targetRow] = {
515
536
  ...childData[targetRow],
@@ -1555,7 +1576,7 @@ const TableContainerEdit = props => {
1555
1576
  const toolbarItemsTop = _react.default.useMemo(() => {
1556
1577
  // Chưa có dòng| ô được chọn
1557
1578
  if (!rowsFocus || rowsFocus.length === 0) {
1558
- return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1579
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
1559
1580
  if (item.key === 'ADD') {
1560
1581
  return {
1561
1582
  ...item,
@@ -1616,7 +1637,7 @@ const TableContainerEdit = props => {
1616
1637
  };
1617
1638
  });
1618
1639
  }
1619
- return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false).map(item => {
1640
+ return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== false).map(item => {
1620
1641
  if (item.key === 'ADD') {
1621
1642
  return {
1622
1643
  ...item,
@@ -1804,6 +1825,12 @@ const TableContainerEdit = props => {
1804
1825
  };
1805
1826
  });
1806
1827
  }, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
1828
+ const toolbarItemTopRight = _react.default.useMemo(() => {
1829
+ if (!toolbarItems) {
1830
+ return undefined;
1831
+ }
1832
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
1833
+ }, [toolbarItems]);
1807
1834
  const triggerCommandClick = args => {
1808
1835
  const {
1809
1836
  id: idCommand,
@@ -2012,7 +2039,8 @@ const TableContainerEdit = props => {
2012
2039
  style: {
2013
2040
  display: 'flex',
2014
2041
  justifyContent: 'space-between',
2015
- alignItems: 'center'
2042
+ alignItems: 'center',
2043
+ gap: '1rem'
2016
2044
  }
2017
2045
  }, /*#__PURE__*/_react.default.createElement("div", {
2018
2046
  style: {
@@ -2047,7 +2075,15 @@ const TableContainerEdit = props => {
2047
2075
  showTotal: (total, range) =>
2048
2076
  // @ts-ignore
2049
2077
  `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
2050
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
2078
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/_react.default.createElement("div", {
2079
+ style: {
2080
+ flex: 1,
2081
+ overflow: 'hidden'
2082
+ }
2083
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
2084
+ items: toolbarItemTopRight,
2085
+ mode: toolbarMode
2086
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
2051
2087
  fontSize: 16,
2052
2088
  onClick: () => {
2053
2089
  setIsFullScreen(!isFullScreen);
@@ -29,7 +29,7 @@ const {
29
29
  } = _rcMasterUi.TreeSelect;
30
30
  const {
31
31
  TextArea
32
- } = _antd.Input;
32
+ } = _rcMasterUi.Input;
33
33
  const filterTreeNode = (input, treeNode) => {
34
34
  const {
35
35
  title,
@@ -1039,7 +1039,7 @@ const EditableCell = props => {
1039
1039
  }, numericFormatProps, {
1040
1040
  min: column.min,
1041
1041
  max: column.max,
1042
- customInput: _antd.Input
1042
+ customInput: _rcMasterUi.Input
1043
1043
  // valueIsNumericString={true}
1044
1044
  ,
1045
1045
  placeholder: t && column.placeholder ? t(column.placeholder) : tableLocal?.textPlaceholder,
@@ -189,7 +189,7 @@ const TableBodyCell = props => {
189
189
  const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
190
190
  const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
191
191
  const record = cell.row.original;
192
- const columnMeta = cell.column.columnDef.meta ?? {};
192
+ const columnMeta = _react.default.useMemo(() => cell.column.columnDef.meta ?? {}, [cell.column.columnDef.meta]);
193
193
  const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
194
194
 
195
195
  // const tooltipContent: any = (isOpenTooltip === false)
@@ -215,7 +215,9 @@ const TableBodyCell = props => {
215
215
  const parrents = cell.row.getParentRows();
216
216
  const cellValue = cell.getValue();
217
217
  const rowIndex = cell.row.index;
218
- const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
218
+ const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
219
+ const cellFormat = (0, _utils.getFormat)(colFormat, format);
220
+ const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
219
221
  const valueCellString = (0, _useColumns.getValueCellString)(columnMeta, cellValue, record, rowIndex, colIndex, format);
220
222
  const tooltipContent = _react.default.useMemo(() => {
221
223
  if (isOpenTooltip === false) {
@@ -1120,7 +1120,9 @@ const TableBodyCellEdit = props => {
1120
1120
  };
1121
1121
  const cellValue = cell.getValue();
1122
1122
  const rowIndex = cell.row.index;
1123
- const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, format, true);
1123
+ const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
1124
+ const cellFormat = (0, _utils.getFormat)(colFormat, format);
1125
+ const fomatedValue = (0, _useColumns.renderValueCell)(columnMeta, cellValue, record, rowIndex, colIndex, cellFormat, true);
1124
1126
  return /*#__PURE__*/_react.default.createElement("div", {
1125
1127
  key: cell.id,
1126
1128
  ref: el => {
@@ -191,6 +191,10 @@ const TableHeadCell2 = props => {
191
191
  onChange: val => {
192
192
  column.setFilterOperator(val);
193
193
  }
194
+ // dropdownStyle={{
195
+
196
+ // zIndex: 1059
197
+ // }}
194
198
  })), /*#__PURE__*/_react.default.createElement("div", {
195
199
  style: {
196
200
  marginBottom: 8
@@ -117,6 +117,18 @@ const TableContainer = props => {
117
117
  document.removeEventListener('mousedown', handleClickOutside);
118
118
  };
119
119
  }, []);
120
+ const toolbarItemTop = _react.default.useMemo(() => {
121
+ if (!toolbarItems) {
122
+ return undefined;
123
+ }
124
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight !== false);
125
+ }, [toolbarItems]);
126
+ const toolbarItemTopRight = _react.default.useMemo(() => {
127
+ if (!toolbarItems) {
128
+ return undefined;
129
+ }
130
+ return toolbarItems.filter(it => it.position !== 'Bottom' && it.fixedRight);
131
+ }, [toolbarItems]);
120
132
  const triggerCommandClick = args => {
121
133
  // const { id: idCommand, rowId, rowData, index } = args
122
134
 
@@ -189,7 +201,7 @@ const TableContainer = props => {
189
201
  overflow: 'hidden'
190
202
  }
191
203
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
192
- items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
204
+ items: toolbarItemTop ?? [],
193
205
  mode: toolbarMode
194
206
  })), /*#__PURE__*/_react.default.createElement("div", {
195
207
  style: {
@@ -206,7 +218,15 @@ const TableContainer = props => {
206
218
  showTotal: (totalItems, range) =>
207
219
  // @ts-ignore
208
220
  `${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
209
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
221
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, toolbarItemTopRight && /*#__PURE__*/_react.default.createElement("div", {
222
+ style: {
223
+ flex: 1,
224
+ overflow: 'hidden'
225
+ }
226
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
227
+ items: toolbarItemTopRight,
228
+ mode: toolbarMode
229
+ })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
210
230
  fontSize: 16,
211
231
  onClick: () => {
212
232
  setIsFullScreen(!isFullScreen);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.9.38",
3
+ "version": "1.9.40",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",