es-grid-template 1.5.6 → 1.5.8

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.
@@ -13,7 +13,7 @@ import styled from "styled-components";
13
13
  const BoxAction = styled.div.withConfig({
14
14
  displayName: "BoxAction",
15
15
  componentId: "es-grid-template__sc-1uj3tyy-0"
16
- })(["border-top:1px solid #c4c4c4;padding-top:.75rem;display:flex;justify-content:end;gap:10px;.btn-action{background:none !important;border:none !important;&.btn-action-submit{color:#df4318;&:disabled{background-color:#f0f0f0 !important;}&:hover{color:#df4318 !important;}}&:hover{background-color:#f0f0f0 !important;}}"]);
16
+ })(["padding-top:.75rem;display:flex;justify-content:end;gap:10px;.btn-action{background:none !important;border:none !important;&.btn-action-submit{color:#df4318;&:disabled{background-color:#f0f0f0 !important;}&:hover{color:#df4318 !important;}}&:hover{background-color:#f0f0f0 !important;}}"]);
17
17
  export const ColumnsGroup = props => {
18
18
  const {
19
19
  columns,
@@ -13,7 +13,7 @@ getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customW
13
13
  // import dayjs from "dayjs";
14
14
  // import {TreeSelect} from "antd";
15
15
  import classNames from "classnames";
16
- import { NumericFormat } from "react-numeric-component";
16
+ import { NumericFormat, numericFormatter } from "react-numeric-component";
17
17
  import { TableContext } from "./useContext";
18
18
  import dayjs from "dayjs";
19
19
  import moment from "moment";
@@ -397,6 +397,31 @@ const EditableCell = props => {
397
397
  value: keySelect,
398
398
  label: inputKey ?? 'label'
399
399
  },
400
+ onBlur: event => {
401
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
402
+ const val = event.inputValue;
403
+ onChange(val ?? '');
404
+ const formState = getValues();
405
+ // const itemState = getValues(dataIndex)
406
+ // @ts-ignore
407
+ const prevState = record[dataIndex];
408
+ const newState = val;
409
+ handleCellChange?.({
410
+ key: getRowKey?.(record, index),
411
+ field: column.field ?? column.dataIndex,
412
+ record: formState,
413
+ prevState,
414
+ newState,
415
+ option: {
416
+ value: val,
417
+ label: val
418
+ },
419
+ indexCol,
420
+ indexRow,
421
+ type: 'blur'
422
+ });
423
+ }
424
+ },
400
425
  "data-tooltip-content": message,
401
426
  "data-tooltip-id": `${id}-tooltip-form-error`
402
427
  });
@@ -455,6 +480,31 @@ const EditableCell = props => {
455
480
  value: keySelect,
456
481
  label: inputKey ?? 'label'
457
482
  },
483
+ onBlur: event => {
484
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
485
+ const val = event.inputValue;
486
+ onChange(val ?? '');
487
+ const formState = getValues();
488
+ // const itemState = getValues(dataIndex)
489
+ // @ts-ignore
490
+ const prevState = record[dataIndex];
491
+ const newState = val;
492
+ handleCellChange?.({
493
+ key: getRowKey?.(record, index),
494
+ field: column.field ?? column.dataIndex,
495
+ record: formState,
496
+ prevState,
497
+ newState,
498
+ option: {
499
+ value: val,
500
+ label: val
501
+ },
502
+ indexCol,
503
+ indexRow,
504
+ type: 'blur'
505
+ });
506
+ }
507
+ },
458
508
  "data-tooltip-content": message,
459
509
  "data-tooltip-id": `${id}-tooltip-form-error`
460
510
  });
@@ -552,6 +602,31 @@ const EditableCell = props => {
552
602
  value: keySelect,
553
603
  label: inputKey ?? 'label'
554
604
  },
605
+ onBlur: event => {
606
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
607
+ const val = event.inputValue;
608
+ onChange(val ?? '');
609
+ const formState = getValues();
610
+ // const itemState = getValues(dataIndex)
611
+ // @ts-ignore
612
+ const prevState = record[dataIndex];
613
+ const newState = val;
614
+ handleCellChange?.({
615
+ key: getRowKey?.(record, index),
616
+ field: column.field ?? column.dataIndex,
617
+ record: formState,
618
+ prevState,
619
+ newState,
620
+ option: {
621
+ value: val,
622
+ label: val
623
+ },
624
+ indexCol,
625
+ indexRow,
626
+ type: 'blur'
627
+ });
628
+ }
629
+ },
555
630
  "data-tooltip-content": message,
556
631
  "data-tooltip-id": `${id}-tooltip-form-error`
557
632
  });
@@ -797,7 +872,7 @@ const EditableCell = props => {
797
872
  // let floatValue = value
798
873
 
799
874
  const numericFormatProps = {
800
- value,
875
+ // value,
801
876
  thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
802
877
  decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
803
878
  decimalScale: cellFormat?.decimalScale ?? undefined,
@@ -807,7 +882,9 @@ const EditableCell = props => {
807
882
  suffix: cellFormat?.suffix ?? undefined
808
883
  };
809
884
  return /*#__PURE__*/React.createElement(NumericFormat, _extends({
810
- id: `col${indexCol}-record${indexRow}`
885
+ id: `col${indexCol}-record${indexRow}`,
886
+ value: value ? numericFormatter(value.toString(), numericFormatProps) : ''
887
+ // value={value}
811
888
  }, numericFormatProps, {
812
889
  min: column.min,
813
890
  max: column.max,
@@ -823,7 +900,7 @@ const EditableCell = props => {
823
900
  'be-cell-edit-align-right': !column.align || column.align === 'right'
824
901
  }),
825
902
  onValueChange: values => {
826
- onChange(values?.floatValue);
903
+ onChange(values?.floatValue || 0);
827
904
  },
828
905
  onBlur: () => {
829
906
  const formState = getValues();
@@ -65,7 +65,9 @@ export const getValueCell = (column, value, format) => {
65
65
  // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
66
66
 
67
67
  const tmpval = typeof value === 'string' ? Number(value) : value;
68
- const contentNumber = !isEmpty(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
68
+
69
+ // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString()) : '0'
70
+ const contentNumber = !isEmpty(value) ? dec || dec === 0 ? tmpval.toString() : tmpval.toString() : '0';
69
71
  const numericFormatProps = {
70
72
  thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
71
73
  decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
@@ -1653,34 +1653,20 @@ export const addBorderClass = (selectedCells, type, className, id, nextCellRight
1653
1653
  if (cellsFilter && cellsFilter.length > 0) {
1654
1654
  cellsFilter.forEach(cell => {
1655
1655
  cell.classList.add(className);
1656
- if (nextCellRight) {
1657
- cell.style.zIndex = 1;
1656
+
1657
+ // if (nextCellRight) {
1658
+ // // cell.style.zIndex = 1
1659
+ // }
1660
+
1661
+ if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1662
+ cell.style.zIndex = 3;
1663
+ } else {
1664
+ if (cell) {
1665
+ cell.style.zIndex = nextCellRight ? 3 : 1;
1666
+ }
1658
1667
  }
1659
1668
  });
1660
1669
  }
1661
-
1662
- // ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
1663
-
1664
- // if (type === 'left') {
1665
- //
1666
- // const selectorsCells2 = typeCells.map((pos: any) => {
1667
- // const [row, col] = pos.split('-');
1668
- // return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
1669
- // });
1670
- //
1671
- // const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
1672
- //
1673
- // const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
1674
- //
1675
- // if (cellsFilter2 && cellsFilter2.length > 0) {
1676
- //
1677
- // cellsFilter2.forEach(cell => {
1678
- // // cell.classList.add('has-before');
1679
- // cell.classList.add('cell-border-left');
1680
- // });
1681
- // }
1682
- //
1683
- // }
1684
1670
  };
1685
1671
  export const removeBorderClass = (selectedCells, type, className, id) => {
1686
1672
  const table = document.querySelector(`#${id}`);
@@ -1874,18 +1860,26 @@ export const onRemoveBgCellIndex = (selectedCells, id, rowsSelected) => {
1874
1860
  export const onAddBorderSelectedCell = (selectedCells, id) => {
1875
1861
  const table = document.querySelector(`#${id}`);
1876
1862
 
1877
- // tăng z-index để hiển thị round point paste
1863
+ // // tăng z-index để hiển thị round point paste
1878
1864
  const row = getLastSelectCell(selectedCells).row;
1879
1865
  const col = getLastSelectCell(selectedCells).col;
1880
- const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1881
- const nextCellLeft = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1866
+ // const cell: any = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`)
1867
+ //
1868
+ // const nextCellLeft: any = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`)
1882
1869
  const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1883
- if (cell) {
1884
- cell.style.zIndex = nextCellLeft ? 3 : 1;
1885
- }
1886
- if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1887
- cell.style.zIndex = 3;
1888
- }
1870
+ //
1871
+ // // if (cell) {
1872
+ // // // cell.style.zIndex = nextCellLeft ? 3 : 1
1873
+ // // }
1874
+ //
1875
+ // if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1876
+ // cell.style.zIndex = 3
1877
+ // } else {
1878
+ // if (cell) {
1879
+ // cell.style.zIndex = nextCellLeft ? 3 : 3
1880
+ // }
1881
+ // }
1882
+
1889
1883
  removeBorderClass2('cell-border-bottom', id);
1890
1884
  removeBorderClass2('cell-border-top', id);
1891
1885
  removeBorderClass2('cell-border-right', id);