react-table-edit 1.5.39 → 1.5.41

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.
@@ -1,9 +1,8 @@
1
- import { CSSProperties } from 'react';
2
1
  import { IColumnTable } from '../type';
3
2
  import { IFDataMapExcel, IFNumberFormat } from './type';
4
3
  type IFProps = {
5
4
  /** custom style */
6
- style?: CSSProperties | undefined;
5
+ zIndex?: number;
7
6
  /** Kích thước cửa sổ hiện tại (width, height) */
8
7
  windowSize: any;
9
8
  /** Trạng thái mở/đóng modal import */
@@ -49,9 +48,21 @@ type IFProps = {
49
48
  * @param params - Tham số cập nhật
50
49
  */
51
50
  updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
51
+ /**
52
+ * API lấy mẫu Excel
53
+ */
54
+ getExcelTemplate?: (params: string) => Promise<any>;
55
+ /**
56
+ * Mã code chức năng để lấy mẫu nhập excel
57
+ */
58
+ templateCode?: string;
59
+ /**
60
+ * Tên chức năng đang import Excel
61
+ */
62
+ resourceName?: string;
52
63
  /**
53
64
  * API lấy cấu hình in
54
- * @returns Promise trả về kết quả in
65
+ * @returns Promise trả về cấu hình map cột
55
66
  */
56
67
  getGeneralSettingApi?: () => Promise<any>;
57
68
  };
@@ -7,6 +7,15 @@ export interface IFPropsDetail {
7
7
  setValue: UseFormSetValue<IFDataExcel>;
8
8
  getValues: UseFormGetValues<IFDataExcel>;
9
9
  templateUrl?: string;
10
+ resourceName?: string;
11
+ /**
12
+ * API lấy mẫu Excel
13
+ */
14
+ getExcelTemplate?: (params: string) => Promise<any>;
15
+ /**
16
+ * Mã code chức năng để lấy mẫu nhập excel
17
+ */
18
+ templateCode?: string;
10
19
  }
11
20
  declare const TabSelectFileImportExcel: (props: IFPropsDetail) => import("react/jsx-runtime").JSX.Element;
12
21
  export default TabSelectFileImportExcel;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { ReactNode, JSX, Dispatch, SetStateAction, CSSProperties } from 'react';
2
+ import React__default, { ReactNode, JSX, Dispatch, SetStateAction } from 'react';
3
3
  import { UseFormSetValue, UseFormGetValues, UseFormReset } from 'react-hook-form';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { TFunction } from 'react-i18next';
@@ -540,7 +540,7 @@ type IFNumberFormat = {
540
540
 
541
541
  type IFProps$1 = {
542
542
  /** custom style */
543
- style?: CSSProperties | undefined;
543
+ zIndex?: number;
544
544
  /** Kích thước cửa sổ hiện tại (width, height) */
545
545
  windowSize: any;
546
546
  /** Trạng thái mở/đóng modal import */
@@ -586,9 +586,21 @@ type IFProps$1 = {
586
586
  * @param params - Tham số cập nhật
587
587
  */
588
588
  updateGeneralSettingApi?: (params: IFDataMapExcel[]) => void;
589
+ /**
590
+ * API lấy mẫu Excel
591
+ */
592
+ getExcelTemplate?: (params: string) => Promise<any>;
593
+ /**
594
+ * Mã code chức năng để lấy mẫu nhập excel
595
+ */
596
+ templateCode?: string;
597
+ /**
598
+ * Tên chức năng đang import Excel
599
+ */
600
+ resourceName?: string;
589
601
  /**
590
602
  * API lấy cấu hình in
591
- * @returns Promise trả về kết quả in
603
+ * @returns Promise trả về cấu hình map cột
592
604
  */
593
605
  getGeneralSettingApi?: () => Promise<any>;
594
606
  };
package/dist/index.js CHANGED
@@ -68331,38 +68331,48 @@ const connectString = (t, props) => {
68331
68331
  };
68332
68332
 
68333
68333
  const TabSelectFileImportExcel = (props) => {
68334
- const { templateUrl, setValue, getValues, control, errors } = props;
68334
+ const { templateUrl, getExcelTemplate, templateCode, resourceName, setValue, getValues, control, errors, } = props;
68335
68335
  const [isDragging, setIsDragging] = React$5.useState(false);
68336
68336
  const [optionSheetName, setOptionSheetName] = React$5.useState([]);
68337
68337
  const { t } = reactI18next.useTranslation();
68338
68338
  const hanldDrag = (e) => {
68339
68339
  e.preventDefault();
68340
68340
  e.stopPropagation();
68341
- if (e.type === "dragenter" || e.type === "dragover") {
68341
+ if (e.type === 'dragenter' || e.type === 'dragover') {
68342
68342
  setIsDragging(true);
68343
68343
  }
68344
- else if (e.type === "dragleave") {
68344
+ else if (e.type === 'dragleave') {
68345
68345
  setIsDragging(false);
68346
68346
  }
68347
68347
  };
68348
- return (jsxRuntime.jsxs("div", { className: 'box form-box__border', children: [templateUrl && jsxRuntime.jsxs(Button$1$1, { color: "link", onClick: () => {
68349
- const link = document.createElement("a");
68348
+ return (jsxRuntime.jsxs("div", { className: "box form-box__border", children: [templateUrl && (!templateCode || !getExcelTemplate) && (jsxRuntime.jsxs(Button$1$1, { color: "link", onClick: () => {
68349
+ const link = document.createElement('a');
68350
68350
  link.href = `${templateUrl}`; // URL file
68351
68351
  document.body.appendChild(link);
68352
68352
  link.click();
68353
68353
  document.body.removeChild(link);
68354
- }, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className: 'me-50' }), t('Download the sample file')] }), jsxRuntime.jsx("h5", { className: 'm-0 form-box__border--title', children: t('Upload file') }), jsxRuntime.jsx("div", { className: `m-1 rounded d-flex flex-column align-items-center justify-content-center ${isDragging ? 'dragging-file' : 'no-dragging-file'}`, style: { minHeight: '220px' }, draggable: true, onDragEnter: hanldDrag, onDragLeave: hanldDrag, onDragOver: hanldDrag, onDrop: (e) => {
68354
+ }, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className: "me-50" }), t('Download the sample file')] })), templateCode && getExcelTemplate && (jsxRuntime.jsxs(Button$1$1, { color: "link", onClick: () => {
68355
+ getExcelTemplate(templateCode).then((rs) => {
68356
+ const url = window.URL.createObjectURL(new Blob([rs]));
68357
+ const link = document.createElement('a');
68358
+ link.href = url;
68359
+ link.download = `${resourceName ? `${resourceName}_` : ''}${t('Sample File')}.xlsx`;
68360
+ document.body.appendChild(link);
68361
+ link.click();
68362
+ document.body.removeChild(link);
68363
+ });
68364
+ }, children: [jsxRuntime.jsx(SvgDownload, { fontSize: 14, className: "me-50" }), t('Download the sample file')] })), jsxRuntime.jsx("h5", { className: "m-0 form-box__border--title", children: t('Upload file') }), jsxRuntime.jsx("div", { className: `m-1 rounded d-flex flex-column align-items-center justify-content-center ${isDragging ? 'dragging-file' : 'no-dragging-file'}`, style: { minHeight: '220px' }, draggable: true, onDragEnter: hanldDrag, onDragLeave: hanldDrag, onDragOver: hanldDrag, onDrop: (e) => {
68355
68365
  e.preventDefault();
68356
68366
  e.stopPropagation();
68357
68367
  setIsDragging(false);
68358
68368
  if (e.dataTransfer.files && e.dataTransfer.files[0]) {
68359
68369
  getSheetsExcel(e.dataTransfer.files[0], setValue, setOptionSheetName);
68360
68370
  }
68361
- }, children: getValues('file') ? jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'mb-1 fs-5', children: getValues('file')?.name }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: 'me-75', size: 'md', color: 'primary', children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: 'me-50' }), t('Select other file'), jsxRuntime.jsx(Input$1, { type: 'file', onChange: (e) => {
68371
+ }, children: getValues('file') ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "mb-1 fs-5", children: getValues('file')?.name }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: "me-75", size: "md", color: "primary", children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: "me-50" }), t('Select other file'), jsxRuntime.jsx(Input$1, { type: "file", onChange: (e) => {
68362
68372
  getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
68363
- }, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] })] }) : jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'fs-4 bolder', children: t('Drag and drop files here') }), jsxRuntime.jsx("div", { className: 'my-50', children: t('or') }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: 'me-75', size: 'md', color: 'primary', children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: 'me-50' }), t('Select file'), jsxRuntime.jsx(Input$1, { type: 'file', onChange: (e) => {
68373
+ }, hidden: true, accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" })] })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "fs-4 bolder", children: t('Drag and drop files here') }), jsxRuntime.jsx("div", { className: "my-50", children: t('or') }), jsxRuntime.jsxs(Button$1$1, { tag: Label$1, outline: true, className: "me-75", size: "md", color: "primary", children: [jsxRuntime.jsx(SvgArrowLeftCircle, { fontSize: 18, className: "me-50" }), t('Select file'), jsxRuntime.jsx(Input$1, { type: "file", onChange: (e) => {
68364
68374
  getSheetsExcel(e.target.files[0], setValue, setOptionSheetName);
68365
- }, hidden: true, accept: '.csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel' })] }), jsxRuntime.jsx("div", { className: 'mt-1', children: t('Accepts .xls, .xlsx, .csv files') })] }) }), jsxRuntime.jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(SelectTableBox$1, { labelSize: "d-flex form-row-inline label-medium", control: control, name: "sheetId", label: t("Sheet name"), required: true, errors: errors.sheetId, placeholder: t("Select"), options: optionSheetName }) }), jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t("Header row"), errors: errors.headerRow }) })] })] }));
68375
+ }, hidden: true, accept: ".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" })] }), jsxRuntime.jsx("div", { className: "mt-1", children: t('Accepts .xls, .xlsx, .csv files') })] })) }), jsxRuntime.jsxs(Row$1, { className: `${getValues('file') ? '' : 'd-none'} m-0 gy-1`, children: [jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(SelectTableBox$1, { labelSize: "d-flex form-row-inline label-medium", control: control, name: "sheetId", label: t('Sheet name'), required: true, errors: errors.sheetId, placeholder: t('Select'), options: optionSheetName }) }), jsxRuntime.jsx(Col$1, { lg: 6, md: 12, xs: 12, children: jsxRuntime.jsx(NumberInput, { control: control, name: "headerRow", labelSize: "d-flex form-row-inline label-medium", label: t('Header row'), errors: errors.headerRow }) })] })] }));
68366
68376
  };
68367
68377
 
68368
68378
  const TabValidateImportExcel = (props) => {
@@ -68391,7 +68401,7 @@ const TabValidateImportExcel = (props) => {
68391
68401
 
68392
68402
  const ModalImportComponent = (props) => {
68393
68403
  const { t } = reactI18next.useTranslation();
68394
- const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns, style, } = props;
68404
+ const { windowSize, openModal, handleModal, handleValidate, importExcelApi, validateExcelApi, getGeneralSettingApi, updateGeneralSettingApi, headerErrorExcelColumns, templateUrl, defaultHeaderRow, formatNumber, mapColumn, headerValidateExcelColumns, getExcelTemplate, templateCode, resourceName, zIndex, } = props;
68395
68405
  const [optionField, setOptionField] = React$5.useState([]);
68396
68406
  const [dataMerge, setDataMerge] = React$5.useState([]);
68397
68407
  const [dataValidate, setDataValidate] = React$5.useState([]);
@@ -68589,11 +68599,11 @@ const ModalImportComponent = (props) => {
68589
68599
  setValue('step', 2);
68590
68600
  }
68591
68601
  };
68592
- return (jsxRuntime.jsx(Modal$1, { isOpen: openModal, style: style, toggle: handleModal, backdrop: "static", className: "modal-dialog-centered modal-xl", contentClassName: "p-0", onOpened: handleFormOpened, onClosed: handleModalClosed, children: jsxRuntime.jsxs(Form$1, { id: "form-modal-globalzone", className: "todo-modal modal-form-content", children: [jsxRuntime.jsx(ModalHeader, { typeModal: 'Import', handleModal: handleModal, title: "Import Excel" }), jsxRuntime.jsx(Scrollbars, { autoHide: true, autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, children: jsxRuntime.jsx(ModalBody$1, { children: jsxRuntime.jsx("div", { style: { marginTop: '-25px' }, className: "modern-horizontal-wizard", children: jsxRuntime.jsx(Wizard, { activeStep: watch('step'), type: "modern-horizontal", steps: [
68602
+ return (jsxRuntime.jsx(Modal$1, { isOpen: openModal, zIndex: zIndex, toggle: handleModal, backdrop: "static", className: "modal-dialog-centered modal-xl", contentClassName: "p-0", onOpened: handleFormOpened, onClosed: handleModalClosed, children: jsxRuntime.jsxs(Form$1, { id: "form-modal-globalzone", className: "todo-modal modal-form-content", children: [jsxRuntime.jsx(ModalHeader, { typeModal: 'Import', handleModal: handleModal, title: "Import Excel" }), jsxRuntime.jsx(Scrollbars, { autoHide: true, autoHeight: true, autoHeightMax: windowSize.innerHeight - 120, children: jsxRuntime.jsx(ModalBody$1, { children: jsxRuntime.jsx("div", { style: { marginTop: '-25px' }, className: "modern-horizontal-wizard", children: jsxRuntime.jsx(Wizard, { activeStep: watch('step'), type: "modern-horizontal", steps: [
68593
68603
  {
68594
68604
  id: 'upload-file',
68595
68605
  title: t('Upload file'),
68596
- content: (jsxRuntime.jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl })),
68606
+ content: (jsxRuntime.jsx(TabSelectFileImportExcel, { control: control, errors: errors, getValues: getValues, setValue: setValue, watch: watch, templateUrl: templateUrl, resourceName: resourceName, templateCode: templateCode, getExcelTemplate: getExcelTemplate })),
68597
68607
  },
68598
68608
  {
68599
68609
  id: 'merge-data',