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.
@@ -973,7 +973,7 @@ const GridEdit = props => {
973
973
  // const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
974
974
  const container = document.querySelector(".be-popup-container");
975
975
  const containerContextMenu = document.querySelector(".popup-context-menu");
976
- const tableBody = document.querySelector(`#${id} .ui-rc-table-tbody`);
976
+ const tableBody = document.querySelector(`#${id} .ui-rc-table-tbody .ui-rc-table-tbody-virtual-holder`);
977
977
  // const containerHidden = document.querySelector(".be-popup-container.ant-picker-dropdown-hidden")
978
978
 
979
979
  // const toolbarContainer = document.getElementsByClassName("ui-rc-toolbar");
@@ -53,6 +53,8 @@ export type IEditSelectSettings = {
53
53
  fieldValue?: string;
54
54
  /** get label form other field **/
55
55
  fieldLabel?: string;
56
+ /** cho phép nhập giá trị - onBlur: giá trị search được set thành value **/
57
+ searchTextAsValue?: boolean;
56
58
  inputKey?: string;
57
59
  filterKey?: string[];
58
60
  selectMode?: SelectMode;
@@ -23,7 +23,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
23
23
  const BoxAction = _styledComponents.default.div.withConfig({
24
24
  displayName: "BoxAction",
25
25
  componentId: "es-grid-template__sc-1uj3tyy-0"
26
- })(["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;}}"]);
26
+ })(["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;}}"]);
27
27
  const ColumnsGroup = props => {
28
28
  const {
29
29
  columns,
@@ -399,6 +399,31 @@ const EditableCell = props => {
399
399
  value: keySelect,
400
400
  label: inputKey ?? 'label'
401
401
  },
402
+ onBlur: event => {
403
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
404
+ const val = event.inputValue;
405
+ onChange(val ?? '');
406
+ const formState = getValues();
407
+ // const itemState = getValues(dataIndex)
408
+ // @ts-ignore
409
+ const prevState = record[dataIndex];
410
+ const newState = val;
411
+ handleCellChange?.({
412
+ key: getRowKey?.(record, index),
413
+ field: column.field ?? column.dataIndex,
414
+ record: formState,
415
+ prevState,
416
+ newState,
417
+ option: {
418
+ value: val,
419
+ label: val
420
+ },
421
+ indexCol,
422
+ indexRow,
423
+ type: 'blur'
424
+ });
425
+ }
426
+ },
402
427
  "data-tooltip-content": message,
403
428
  "data-tooltip-id": `${id}-tooltip-form-error`
404
429
  });
@@ -457,6 +482,31 @@ const EditableCell = props => {
457
482
  value: keySelect,
458
483
  label: inputKey ?? 'label'
459
484
  },
485
+ onBlur: event => {
486
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
487
+ const val = event.inputValue;
488
+ onChange(val ?? '');
489
+ const formState = getValues();
490
+ // const itemState = getValues(dataIndex)
491
+ // @ts-ignore
492
+ const prevState = record[dataIndex];
493
+ const newState = val;
494
+ handleCellChange?.({
495
+ key: getRowKey?.(record, index),
496
+ field: column.field ?? column.dataIndex,
497
+ record: formState,
498
+ prevState,
499
+ newState,
500
+ option: {
501
+ value: val,
502
+ label: val
503
+ },
504
+ indexCol,
505
+ indexRow,
506
+ type: 'blur'
507
+ });
508
+ }
509
+ },
460
510
  "data-tooltip-content": message,
461
511
  "data-tooltip-id": `${id}-tooltip-form-error`
462
512
  });
@@ -554,6 +604,31 @@ const EditableCell = props => {
554
604
  value: keySelect,
555
605
  label: inputKey ?? 'label'
556
606
  },
607
+ onBlur: event => {
608
+ if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
609
+ const val = event.inputValue;
610
+ onChange(val ?? '');
611
+ const formState = getValues();
612
+ // const itemState = getValues(dataIndex)
613
+ // @ts-ignore
614
+ const prevState = record[dataIndex];
615
+ const newState = val;
616
+ handleCellChange?.({
617
+ key: getRowKey?.(record, index),
618
+ field: column.field ?? column.dataIndex,
619
+ record: formState,
620
+ prevState,
621
+ newState,
622
+ option: {
623
+ value: val,
624
+ label: val
625
+ },
626
+ indexCol,
627
+ indexRow,
628
+ type: 'blur'
629
+ });
630
+ }
631
+ },
557
632
  "data-tooltip-content": message,
558
633
  "data-tooltip-id": `${id}-tooltip-form-error`
559
634
  });
@@ -799,7 +874,7 @@ const EditableCell = props => {
799
874
  // let floatValue = value
800
875
 
801
876
  const numericFormatProps = {
802
- value,
877
+ // value,
803
878
  thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
804
879
  decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
805
880
  decimalScale: cellFormat?.decimalScale ?? undefined,
@@ -809,7 +884,9 @@ const EditableCell = props => {
809
884
  suffix: cellFormat?.suffix ?? undefined
810
885
  };
811
886
  return /*#__PURE__*/_react.default.createElement(_reactNumericComponent.NumericFormat, (0, _extends2.default)({
812
- id: `col${indexCol}-record${indexRow}`
887
+ id: `col${indexCol}-record${indexRow}`,
888
+ value: value ? (0, _reactNumericComponent.numericFormatter)(value.toString(), numericFormatProps) : ''
889
+ // value={value}
813
890
  }, numericFormatProps, {
814
891
  min: column.min,
815
892
  max: column.max,
@@ -825,7 +902,7 @@ const EditableCell = props => {
825
902
  'be-cell-edit-align-right': !column.align || column.align === 'right'
826
903
  }),
827
904
  onValueChange: values => {
828
- onChange(values?.floatValue);
905
+ onChange(values?.floatValue || 0);
829
906
  },
830
907
  onBlur: () => {
831
908
  const formState = getValues();
@@ -76,7 +76,9 @@ const getValueCell = (column, value, format) => {
76
76
  // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
77
77
 
78
78
  const tmpval = typeof value === 'string' ? Number(value) : value;
79
- const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
79
+
80
+ // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString()) : '0'
81
+ const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? tmpval.toString() : tmpval.toString() : '0';
80
82
  const numericFormatProps = {
81
83
  thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
82
84
  decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
@@ -1756,34 +1756,20 @@ const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
1756
1756
  if (cellsFilter && cellsFilter.length > 0) {
1757
1757
  cellsFilter.forEach(cell => {
1758
1758
  cell.classList.add(className);
1759
- if (nextCellRight) {
1760
- cell.style.zIndex = 1;
1759
+
1760
+ // if (nextCellRight) {
1761
+ // // cell.style.zIndex = 1
1762
+ // }
1763
+
1764
+ if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1765
+ cell.style.zIndex = 3;
1766
+ } else {
1767
+ if (cell) {
1768
+ cell.style.zIndex = nextCellRight ? 3 : 1;
1769
+ }
1761
1770
  }
1762
1771
  });
1763
1772
  }
1764
-
1765
- // ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
1766
-
1767
- // if (type === 'left') {
1768
- //
1769
- // const selectorsCells2 = typeCells.map((pos: any) => {
1770
- // const [row, col] = pos.split('-');
1771
- // return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
1772
- // });
1773
- //
1774
- // const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
1775
- //
1776
- // const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
1777
- //
1778
- // if (cellsFilter2 && cellsFilter2.length > 0) {
1779
- //
1780
- // cellsFilter2.forEach(cell => {
1781
- // // cell.classList.add('has-before');
1782
- // cell.classList.add('cell-border-left');
1783
- // });
1784
- // }
1785
- //
1786
- // }
1787
1773
  };
1788
1774
  exports.addBorderClass = addBorderClass;
1789
1775
  const removeBorderClass = (selectedCells, type, className, id) => {
@@ -1986,18 +1972,26 @@ exports.onRemoveBgCellIndex = onRemoveBgCellIndex;
1986
1972
  const onAddBorderSelectedCell = (selectedCells, id) => {
1987
1973
  const table = document.querySelector(`#${id}`);
1988
1974
 
1989
- // tăng z-index để hiển thị round point paste
1975
+ // // tăng z-index để hiển thị round point paste
1990
1976
  const row = getLastSelectCell(selectedCells).row;
1991
1977
  const col = getLastSelectCell(selectedCells).col;
1992
- const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1993
- const nextCellLeft = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1978
+ // const cell: any = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`)
1979
+ //
1980
+ // const nextCellLeft: any = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`)
1994
1981
  const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1995
- if (cell) {
1996
- cell.style.zIndex = nextCellLeft ? 3 : 1;
1997
- }
1998
- if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1999
- cell.style.zIndex = 3;
2000
- }
1982
+ //
1983
+ // // if (cell) {
1984
+ // // // cell.style.zIndex = nextCellLeft ? 3 : 1
1985
+ // // }
1986
+ //
1987
+ // if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1988
+ // cell.style.zIndex = 3
1989
+ // } else {
1990
+ // if (cell) {
1991
+ // cell.style.zIndex = nextCellLeft ? 3 : 3
1992
+ // }
1993
+ // }
1994
+
2001
1995
  removeBorderClass2('cell-border-bottom', id);
2002
1996
  removeBorderClass2('cell-border-top', id);
2003
1997
  removeBorderClass2('cell-border-right', id);