react-table-edit 1.5.34 → 1.5.36

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.
@@ -45,12 +45,12 @@ type IFProps = {
45
45
  * API cập nhật cấu hình import
46
46
  * @param params - Tham số cập nhật
47
47
  */
48
- updateGeneralSettingApi: (params: IFDataMapExcel[]) => void;
48
+ updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
49
49
  /**
50
50
  * API lấy cấu hình in
51
51
  * @returns Promise trả về kết quả in
52
52
  */
53
- getGeneralSettingApi: () => Promise<any>;
53
+ getGeneralSettingApi?: () => Promise<any>;
54
54
  };
55
55
  declare const ModalImportComponent: (props: IFProps) => import("react/jsx-runtime").JSX.Element;
56
56
  export { ModalImportComponent };
@@ -41,6 +41,7 @@ type TableViewProps = {
41
41
  contextMenuItems?: IContextItem[];
42
42
  handleContextMenuClick?: (context: IContextItem, data: any) => void;
43
43
  isMulti?: boolean;
44
+ haveSum?: boolean;
44
45
  handleSelect?: (data: any) => void;
45
46
  };
46
47
  declare const TableView: React.FC<TableViewProps>;
package/dist/index.d.ts CHANGED
@@ -583,12 +583,12 @@ type IFProps$1 = {
583
583
  * API cập nhật cấu hình import
584
584
  * @param params - Tham số cập nhật
585
585
  */
586
- updateGeneralSettingApi: (params: IFDataMapExcel[]) => void;
586
+ updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
587
587
  /**
588
588
  * API lấy cấu hình in
589
589
  * @returns Promise trả về kết quả in
590
590
  */
591
- getGeneralSettingApi: () => Promise<any>;
591
+ getGeneralSettingApi?: () => Promise<any>;
592
592
  };
593
593
  declare const ModalImportComponent: (props: IFProps$1) => react_jsx_runtime.JSX.Element;
594
594
 
@@ -743,6 +743,7 @@ type TableViewProps = {
743
743
  contextMenuItems?: IContextItem[];
744
744
  handleContextMenuClick?: (context: IContextItem, data: any) => void;
745
745
  isMulti?: boolean;
746
+ haveSum?: boolean;
746
747
  handleSelect?: (data: any) => void;
747
748
  };
748
749
  declare const TableView: React__default.FC<TableViewProps>;
package/dist/index.js CHANGED
@@ -49176,13 +49176,13 @@ const TabHandleErrorImportExcel = (props) => {
49176
49176
  const TabMergeImportExcel = (props) => {
49177
49177
  const { setValue, watch, windowSize, optionField, formatNumber } = props;
49178
49178
  const { t } = reactI18next.useTranslation();
49179
- return (jsxRuntime.jsxs("div", { className: 'box form-box__border', children: [jsxRuntime.jsx("h5", { className: 'm-0 form-box__border--title', children: t('Merge data fields') }), jsxRuntime.jsx(TableEdit, { formatSetting: {
49179
+ return (jsxRuntime.jsxs("div", { className: "box form-box__border", children: [jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t('Merge data fields') }), jsxRuntime.jsx(TableEdit, { formatSetting: {
49180
49180
  decimalSeparator: formatNumber?.decimalSeparator,
49181
49181
  thousandSeparator: formatNumber?.thousandSeparator,
49182
49182
  colorNegative: formatNumber?.colorNegative,
49183
49183
  prefixNegative: formatNumber?.prefixNegative,
49184
49184
  suffixNegative: formatNumber?.suffixNegative
49185
- }, idTable: 'MapColumnImportExcel', columns: [
49185
+ }, idTable: "MapColumnImportExcel", columns: [
49186
49186
  {
49187
49187
  headerText: 'Required Information',
49188
49188
  field: 'isRequired',
@@ -49190,7 +49190,7 @@ const TabMergeImportExcel = (props) => {
49190
49190
  editEnable: true,
49191
49191
  textAlign: 'center',
49192
49192
  template: (data) => {
49193
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: data.isRequired ? jsxRuntime.jsx(SvgCheckSquare, { color: 'green', fontSize: 18 }) : jsxRuntime.jsx(SvgXSquare, { color: 'red', fontSize: 18 }) });
49193
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: data.isRequired ? jsxRuntime.jsx(SvgCheckSquare, { color: "green", fontSize: 18 }) : jsxRuntime.jsx(SvgXSquare, { color: "red", fontSize: 18 }) });
49194
49194
  },
49195
49195
  disabledCondition: (row) => {
49196
49196
  return row.disableEdit ?? false;
@@ -49212,15 +49212,18 @@ const TabMergeImportExcel = (props) => {
49212
49212
  type: 'select',
49213
49213
  editEnable: true,
49214
49214
  selectSettings: {
49215
- options: optionField
49215
+ options: optionField,
49216
+ isClearable: true
49216
49217
  },
49217
49218
  callback(value, indexRow, item) {
49218
- if (!item.headerDefault.includes(value.label)) {
49219
- item.headerDefault.push(value.label ? value.label?.trim() : '');
49219
+ if (!item.headerDefault.includes(value?.label)) {
49220
+ item.headerDefault.push(value?.label ? value?.label?.trim() : '');
49220
49221
  }
49221
49222
  },
49222
49223
  visible: watch('dataMap').length > 0,
49223
- template: (row) => { return optionField.find((e) => e.value === row.column)?.label; },
49224
+ template: (row) => {
49225
+ return optionField.find((e) => e.value === row.column)?.label;
49226
+ },
49224
49227
  width: 300,
49225
49228
  minWidth: 250,
49226
49229
  maxWidth: 350
@@ -68398,7 +68401,7 @@ const ModalImportComponent = (props) => {
68398
68401
  const [checkInitValidate, setCheckInitValidate] = React$5.useState(false);
68399
68402
  const [validateExcelColumns, setValidateExcelColumns] = React$5.useState(mapColumn);
68400
68403
  const [dataError, setDataError] = React$5.useState([]);
68401
- const [isSaveSetting, setIsSaveSetting] = React$5.useState(true);
68404
+ const [isSaveSetting, setIsSaveSetting] = React$5.useState(!!getGeneralSettingApi && !!updateGeneralSettingApi);
68402
68405
  const formSchema = create().shape({
68403
68406
  step: create$1(),
68404
68407
  sheetId: create$2().when('step', {
@@ -68451,7 +68454,7 @@ const ModalImportComponent = (props) => {
68451
68454
  mapDataImportExcel(dataMerge, getValues('headerRow') ?? 0, data.dataMap, handleValidate).then((arr) => {
68452
68455
  setCheckInitValidate(true);
68453
68456
  if (isSaveSetting) {
68454
- updateGeneralSettingApi(data.dataMap.map((x) => ({ ...x, column: undefined })));
68457
+ updateGeneralSettingApi?.(data.dataMap.map((x) => ({ ...x, column: undefined })));
68455
68458
  }
68456
68459
  validateExcelApi(arr)
68457
68460
  .then((rs) => {
@@ -68462,7 +68465,8 @@ const ModalImportComponent = (props) => {
68462
68465
  setDataValid(list.filter((x) => x.error || x.errors?.length === 0));
68463
68466
  setValue('step', 3);
68464
68467
  })
68465
- .catch(() => {
68468
+ .catch((ex) => {
68469
+ console.log(ex);
68466
68470
  notificationError(t('GetFail'));
68467
68471
  setCheckInitValidate(false);
68468
68472
  });
@@ -68528,24 +68532,26 @@ const ModalImportComponent = (props) => {
68528
68532
  }
68529
68533
  }
68530
68534
  ];
68531
- React$5.useEffect(() => {
68532
- console.log(watch('dataMap'));
68533
- }, [watch('dataMap')]);
68534
68535
  const handleFormOpened = () => {
68535
- getGeneralSettingApi()
68536
- .then((rs) => {
68537
- const arr = rs?.value ? JSON.parse(rs.value) : [];
68538
- setValue('dataMap', [...mapColumn].map((x) => {
68539
- const ele = arr.find((y) => x.field === y.field);
68540
- if (ele) {
68541
- x.headerDefault = ele.headerDefault;
68542
- }
68543
- return x;
68544
- }));
68545
- })
68546
- .catch(() => {
68536
+ if (getGeneralSettingApi) {
68537
+ getGeneralSettingApi()
68538
+ .then((rs) => {
68539
+ const arr = rs?.value ? JSON.parse(rs.value) : [];
68540
+ setValue('dataMap', [...mapColumn].map((x) => {
68541
+ const ele = arr.find((y) => x.field === y.field);
68542
+ if (ele) {
68543
+ x.headerDefault = ele.headerDefault;
68544
+ }
68545
+ return x;
68546
+ }));
68547
+ })
68548
+ .catch(() => {
68549
+ setValue('dataMap', [...mapColumn]);
68550
+ });
68551
+ }
68552
+ else {
68547
68553
  setValue('dataMap', [...mapColumn]);
68548
- });
68554
+ }
68549
68555
  if (headerValidateExcelColumns && headerValidateExcelColumns.length > 0) {
68550
68556
  setValidateExcelColumns(headerValidateExcelColumns);
68551
68557
  }
@@ -68596,7 +68602,7 @@ const ModalImportComponent = (props) => {
68596
68602
  visible: !!headerErrorExcelColumns,
68597
68603
  content: jsxRuntime.jsx(TabHandleErrorImportExcel, { formatNumber: formatNumber, dataError: dataError, headerHandleErrorExcelColumns: headerErrorExcelColumns ?? [], windowSize: windowSize })
68598
68604
  }
68599
- ] }) }) }) }), jsxRuntime.jsxs("div", { className: "d-flex justify-content-between align-items-center p-1", style: { boxShadow: '0 4px 24px 0 rgb(34 41 47 / 10%)' }, children: [jsxRuntime.jsx("div", { className: "d-flex align-items-center", children: watch('step') === 2 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Input$1, { checked: isSaveSetting, type: "checkbox", className: "me-50", onChange: (val) => {
68605
+ ] }) }) }) }), jsxRuntime.jsxs("div", { className: "d-flex justify-content-between align-items-center p-1", style: { boxShadow: '0 4px 24px 0 rgb(34 41 47 / 10%)' }, children: [jsxRuntime.jsx("div", { className: "d-flex align-items-center", children: watch('step') === 2 && getGeneralSettingApi && updateGeneralSettingApi && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Input$1, { checked: isSaveSetting, type: "checkbox", className: "me-50", onChange: (val) => {
68600
68606
  setIsSaveSetting(val.target.checked);
68601
68607
  } }), jsxRuntime.jsx("span", { children: "L\u01B0u th\u00F4ng tin gh\u00E9p tr\u01B0\u1EDDng d\u1EEF li\u1EC7u" })] })) }), jsxRuntime.jsxs("div", { className: "d-flex align-items-center", children: [jsxRuntime.jsx(Button$1$1, { disabled: !getValues('file'), color: "primary", outline: true, className: `update-btn update-todo-item me-1 ${watch('step') !== 1 ? '' : 'd-none'}`, onClick: handleBackStep, children: t('Back') }), jsxRuntime.jsx(Button$1$1, { className: `update-btn update-todo-item me-1 ${watch('step') !== 3 ? '' : 'd-none'}`, disabled: !watch('file') || checkInitValidate, color: "primary", onClick: handleSubmit(onSubmit), children: t('Next') }), jsxRuntime.jsx(Button$1$1, { className: `update-btn update-todo-item me-1 ${watch('step') === 3 ? '' : 'd-none'}`, disabled: dataValid.length === 0 || !getValues('file') || checkInit, color: "primary", onClick: handleSubmit(onSubmit), children: t('Import') }), jsxRuntime.jsx(Button$1$1, { color: "secondary", onClick: handleModal, outline: true, children: t('Close') })] })] })] }) }));
68602
68608
  };
@@ -68738,7 +68744,17 @@ const RenderContentCol = (props) => {
68738
68744
  return element && element.scrollWidth > element.clientWidth;
68739
68745
  };
68740
68746
  const RenderElement = () => {
68741
- if (col.type === 'checkbox' || col.field === 'checkbox') {
68747
+ if (col.field === '#' || col.type === '#') {
68748
+ return (jsxRuntime.jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer text-center', { 'r-active-cell': isSelected }), style: {
68749
+ fontWeight: row.sortOrder < 0 || row.sortOrder > 100000 || row.haveBoldType ? 600 : 400,
68750
+ fontStyle: row.haveItalicType ? 'italic' : 'normal'
68751
+ }, onDoubleClick: (e) => {
68752
+ e.preventDefault();
68753
+ handleCloseContext();
68754
+ handleDoubleClick?.(row, col);
68755
+ }, children: indexRow + 1 }));
68756
+ }
68757
+ else if (col.type === 'checkbox' || col.field === 'checkbox') {
68742
68758
  return (jsxRuntime.jsx("div", { className: classNames$1('r-rowcell-div cursor-pointer', { 'r-active-cell': isSelected }), style: { display: 'flex', justifyContent: col.textAlign === 'center' ? 'center' : col.textAlign === 'right' ? 'flex-end' : 'flex-start', alignItems: 'center' }, onClick: (e) => {
68743
68759
  const index = selectedRows?.findIndex((x) => x[fieldKey] === row[fieldKey]);
68744
68760
  if (index > -1) {
@@ -68801,7 +68817,10 @@ const RenderContentCol = (props) => {
68801
68817
  textOverflow: 'ellipsis',
68802
68818
  whiteSpace: 'pre',
68803
68819
  maxWidth: '100%'
68804
- }, children: displayText }) }), checkOverflow() && (jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: cellId, placement: "top", children: jsxRuntime.jsx("div", { style: { color: textColor }, children: displayText }) }))] }));
68820
+ }, children: displayText }) }), checkOverflow() && (jsxRuntime.jsx(UncontrolledTooltip, { className: "r-tooltip", autohide: false, target: cellId, placement: "top", children: jsxRuntime.jsx("div", { style: { color: textColor }, onClick: (e) => {
68821
+ e.stopPropagation();
68822
+ e.preventDefault();
68823
+ }, children: displayText }) }))] }));
68805
68824
  }
68806
68825
  };
68807
68826
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: col.visible !== false && col.isGroup !== true && (jsxRuntime.jsx("td", { className: classNames$1(`r-rowcell fix-${col.fixedType}`, { 'cell-fixed': col.fixedType }, { 'fixed-last': (col.fixedType === 'left' && indexCol === lastObjWidthFixLeft) || (col.fixedType === 'right' && indexCol === fisrtObjWidthFixRight) }, { 'r-active': isSelected }), style: {
@@ -68832,7 +68851,7 @@ const RenderContentCol = (props) => {
68832
68851
  }, children: RenderElement() }, `col-${indexRow}-${indexCol}`)) }));
68833
68852
  };
68834
68853
 
68835
- const TableView = ({ idTable, dataSource, height = 400, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick }) => {
68854
+ const TableView = ({ idTable, dataSource, height = 400, haveSum, columns, isLoading, formatSetting, querySetting, pagingSetting, searchSetting, columnsAggregate, toolbarSetting, selectedItem, setSelectedItem, handleSelect, saveSettingColumn, resetDefaultColumns, settingColumns, headerComponent, groupSetting, zeroVisiable, isMulti, handleDoubleClick, contextMenuItems, handleContextMenuClick }) => {
68836
68855
  const { t } = reactI18next.useTranslation();
68837
68856
  const gridRef = React$5.useRef(null);
68838
68857
  const [openPopupSetupColumn, setOpenPopupSetupColumn] = React$5.useState(false);
@@ -69181,7 +69200,7 @@ const TableView = ({ idTable, dataSource, height = 400, columns, isLoading, form
69181
69200
  querySetting.changeOrder(val);
69182
69201
  }
69183
69202
  }, columns: contentColumns, setContentColumns: setContentColumns, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: dataSource?.length ?? 0 }, `header-${indexParent}-${index}`))) }, `header-${-indexParent}`));
69184
- }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: jsxRuntime.jsx(RenderContent, { datas: viewData }) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: (columnsAggregate?.length ?? 0) > 0 && (jsxRuntime.jsx("tr", { className: "r-row", children: contentColumns.map((col, indexCol) => {
69203
+ }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: jsxRuntime.jsx(RenderContent, { datas: viewData }) }), jsxRuntime.jsx("tfoot", { className: "r-gridfoot", children: ((columnsAggregate?.length ?? 0) > 0 || haveSum) && (jsxRuntime.jsx("tr", { className: "r-row", children: contentColumns.map((col, indexCol) => {
69185
69204
  if (col.visible === false || col.isGroup === true) {
69186
69205
  return;
69187
69206
  }