react-table-edit 1.2.77 → 1.2.88

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.
@@ -12,8 +12,6 @@ interface IFFormInput {
12
12
  inLine?: boolean;
13
13
  placeholder?: string;
14
14
  callback?: any;
15
- classLabel?: string;
16
- desciptionLabel?: string;
17
15
  tooltipText?: string;
18
16
  disabledBackgroundColor?: boolean;
19
17
  disabledFontFamily?: boolean;
@@ -151,6 +151,7 @@ export type IFTableEditProps = {
151
151
  buttonSetting?: IFTableEditButton;
152
152
  toolbarSetting?: IFTableEditToolbar;
153
153
  searchSetting?: IFTableEditSearchSetting;
154
+ onDuplicate?: any;
154
155
  };
155
156
  export type IFPageSize = {
156
157
  pageSize: number;
package/dist/index.d.ts CHANGED
@@ -211,6 +211,7 @@ type IFTableEditProps = {
211
211
  buttonSetting?: IFTableEditButton;
212
212
  toolbarSetting?: IFTableEditToolbar;
213
213
  searchSetting?: IFTableEditSearchSetting;
214
+ onDuplicate?: any;
214
215
  };
215
216
  type IFPageSize = {
216
217
  pageSize: number;
package/dist/index.js CHANGED
@@ -9,8 +9,6 @@ var reactI18next = require('react-i18next');
9
9
  var client = require('react-dom/client');
10
10
  var toast = require('react-hot-toast');
11
11
  var reactRouterDom = require('react-router-dom');
12
- var select = require('@components/select');
13
- var reactTableEdit = require('react-table-edit');
14
12
 
15
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
14
 
@@ -21125,7 +21123,6 @@ const renderLabel = (props) => {
21125
21123
  };
21126
21124
 
21127
21125
  const TextInput = (props) => {
21128
- reactI18next.useTranslation();
21129
21126
  const { control, id, name, min, max, type, label, labelSize, required, errors, height, disabled, row, isLabel, placeholder, autoFocus, inLine, callback, readOnly, classes, ...rest } = props;
21130
21127
  const renderInput = () => {
21131
21128
  return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => (jsxRuntime.jsx(Input$1, { id: id, value: !isNullOrUndefined$1(value) ? value : '', onChange: (val) => {
@@ -22383,7 +22380,6 @@ function NumericFormat(props) {
22383
22380
 
22384
22381
  const NumberInput = (props) => {
22385
22382
  const { id, control, fractionCurrency, name, min, max, label, labelSize, required, errors, disabled, isLabel, fixedDecimalScale, placeholder, inLine, callback, decimalSeparator = ',', thousandSeparator = '.', classes, width, allowNegative } = props;
22386
- reactI18next.useTranslation();
22387
22383
  const renderInput = () => {
22388
22384
  return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
22389
22385
  let floatValue = parseFloat(value);
@@ -41894,7 +41890,7 @@ const DateInput = (props) => {
41894
41890
  if (onChange) {
41895
41891
  onChange(date);
41896
41892
  }
41897
- }, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsxRuntime.jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat }), onKeyDown: (e) => {
41893
+ }, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", isClearable: true, onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsxRuntime.jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat }), onKeyDown: (e) => {
41898
41894
  if (e.code === 'Space') {
41899
41895
  setOpen(!open);
41900
41896
  setTimeout(() => {
@@ -41917,7 +41913,7 @@ const DateInput = (props) => {
41917
41913
 
41918
41914
  const TableEdit = React$5.forwardRef((props, ref) => {
41919
41915
  const { t } = reactI18next.useTranslation();
41920
- const { idTable, dataSource, columns, commandClick, dataSourceChange, rowChange, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, setSelectedItem, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, handleSelect, haveSum, isMulti, disableAutoKey } = props;
41916
+ const { idTable, dataSource, columns, commandClick, dataSourceChange, rowChange, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, setSelectedItem, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, handleSelect, haveSum, isMulti, disableAutoKey, onDuplicate } = props;
41921
41917
  React$5.useImperativeHandle(ref, () => {
41922
41918
  return {
41923
41919
  refeshFocusRow: handleRefeshRow
@@ -42510,19 +42506,23 @@ const TableEdit = React$5.forwardRef((props, ref) => {
42510
42506
  focusNewElement(columnFistEdit, lengthData + 1, true);
42511
42507
  }
42512
42508
  };
42513
- const handleDuplicate = (data, index) => {
42509
+ const handleDuplicate = async (data, index) => {
42510
+ const newData = { ...data };
42514
42511
  if (toolbarSetting?.showBottomToolbar && !buttonSetting?.duplicateDisable && !editDisable && !addDisable) {
42515
42512
  if (fieldKey && defaultValue) {
42516
42513
  fieldUniKey.forEach((item) => {
42517
- data[item] = defaultValue[item];
42514
+ newData[item] = defaultValue[item];
42518
42515
  });
42519
- data[fieldKey] = defaultValue[fieldKey];
42516
+ newData[fieldKey] = defaultValue[fieldKey];
42517
+ }
42518
+ if (onDuplicate) {
42519
+ await onDuplicate(newData, index);
42520
42520
  }
42521
42521
  if (pagingClient) {
42522
- dataSource.splice((((pagingSetting?.currentPage ?? 1) - 1) * (pagingSetting?.pageSize ?? 0) + index), 0, { ...data });
42522
+ dataSource.splice((((pagingSetting?.currentPage ?? 1) - 1) * (pagingSetting?.pageSize ?? 0) + index) + 1, 0, newData);
42523
42523
  }
42524
42524
  else {
42525
- dataSource.splice(index, 0, data);
42525
+ dataSource.splice(index + 1, 0, newData);
42526
42526
  }
42527
42527
  changeDataSource(dataSource);
42528
42528
  if (tableElement && index === totalCount) {
@@ -45512,17 +45512,17 @@ const defaultStyleExportSetting = {
45512
45512
  };
45513
45513
 
45514
45514
  const StyleInput = (props) => {
45515
- const { classLabel, control, name, label, labelSize, required, errors, desciptionLabel, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
45515
+ const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
45516
45516
  const renderInput = () => {
45517
45517
  return (jsxRuntime.jsxs(React$5.Fragment, { children: [jsxRuntime.jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
45518
- return (jsxRuntime.jsx(reactTableEdit.InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
45518
+ return (jsxRuntime.jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
45519
45519
  } }), errors && jsxRuntime.jsx(FormFeedback$1, { children: errors?.message })] }));
45520
45520
  };
45521
45521
  return (jsxRuntime.jsx(React$5.Fragment, { children: jsxRuntime.jsxs("div", { className: classnames(' align', {
45522
45522
  [labelSize ? labelSize : '']: labelSize,
45523
45523
  [classes ? classes : '']: classes,
45524
45524
  'form-row-inline-error': errors
45525
- }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [select.renderLabel({ isLabel, desciptionLabel, classLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
45525
+ }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsxRuntime.jsx("div", { style: { height: `${height}px` }, className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
45526
45526
  };
45527
45527
 
45528
45528
  const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {