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.
package/dist/index.mjs CHANGED
@@ -7,8 +7,6 @@ import { useTranslation } from 'react-i18next';
7
7
  import { createRoot } from 'react-dom/client';
8
8
  import toast from 'react-hot-toast';
9
9
  import { useNavigate, Link } from 'react-router-dom';
10
- import { renderLabel as renderLabel$1 } from '@components/select';
11
- import { InputStyleComponent as InputStyleComponent$1 } from 'react-table-edit';
12
10
 
13
11
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
14
12
 
@@ -21097,7 +21095,6 @@ const renderLabel = (props) => {
21097
21095
  };
21098
21096
 
21099
21097
  const TextInput = (props) => {
21100
- useTranslation();
21101
21098
  const { control, id, name, min, max, type, label, labelSize, required, errors, height, disabled, row, isLabel, placeholder, autoFocus, inLine, callback, readOnly, classes, ...rest } = props;
21102
21099
  const renderInput = () => {
21103
21100
  return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => (jsx(Input$1, { id: id, value: !isNullOrUndefined$1(value) ? value : '', onChange: (val) => {
@@ -22355,7 +22352,6 @@ function NumericFormat(props) {
22355
22352
 
22356
22353
  const NumberInput = (props) => {
22357
22354
  const { id, control, fractionCurrency, name, min, max, label, labelSize, required, errors, disabled, isLabel, fixedDecimalScale, placeholder, inLine, callback, decimalSeparator = ',', thousandSeparator = '.', classes, width, allowNegative } = props;
22358
- useTranslation();
22359
22355
  const renderInput = () => {
22360
22356
  return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
22361
22357
  let floatValue = parseFloat(value);
@@ -41866,7 +41862,7 @@ const DateInput = (props) => {
41866
41862
  if (onChange) {
41867
41863
  onChange(date);
41868
41864
  }
41869
- }, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat }), onKeyDown: (e) => {
41865
+ }, dateFormat: dateFormat, locale: "vi", showMonthDropdown: true, showYearDropdown: true, dropdownMode: "select", isClearable: true, onCalendarClose: () => setOpen(false), onCalendarOpen: () => setOpen(true), customInput: jsx(InputMask, { mask: "99/99/9999", placeholder: dateFormat }), onKeyDown: (e) => {
41870
41866
  if (e.code === 'Space') {
41871
41867
  setOpen(!open);
41872
41868
  setTimeout(() => {
@@ -41889,7 +41885,7 @@ const DateInput = (props) => {
41889
41885
 
41890
41886
  const TableEdit = forwardRef((props, ref) => {
41891
41887
  const { t } = useTranslation();
41892
- 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;
41888
+ 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;
41893
41889
  useImperativeHandle(ref, () => {
41894
41890
  return {
41895
41891
  refeshFocusRow: handleRefeshRow
@@ -42482,19 +42478,23 @@ const TableEdit = forwardRef((props, ref) => {
42482
42478
  focusNewElement(columnFistEdit, lengthData + 1, true);
42483
42479
  }
42484
42480
  };
42485
- const handleDuplicate = (data, index) => {
42481
+ const handleDuplicate = async (data, index) => {
42482
+ const newData = { ...data };
42486
42483
  if (toolbarSetting?.showBottomToolbar && !buttonSetting?.duplicateDisable && !editDisable && !addDisable) {
42487
42484
  if (fieldKey && defaultValue) {
42488
42485
  fieldUniKey.forEach((item) => {
42489
- data[item] = defaultValue[item];
42486
+ newData[item] = defaultValue[item];
42490
42487
  });
42491
- data[fieldKey] = defaultValue[fieldKey];
42488
+ newData[fieldKey] = defaultValue[fieldKey];
42489
+ }
42490
+ if (onDuplicate) {
42491
+ await onDuplicate(newData, index);
42492
42492
  }
42493
42493
  if (pagingClient) {
42494
- dataSource.splice((((pagingSetting?.currentPage ?? 1) - 1) * (pagingSetting?.pageSize ?? 0) + index), 0, { ...data });
42494
+ dataSource.splice((((pagingSetting?.currentPage ?? 1) - 1) * (pagingSetting?.pageSize ?? 0) + index) + 1, 0, newData);
42495
42495
  }
42496
42496
  else {
42497
- dataSource.splice(index, 0, data);
42497
+ dataSource.splice(index + 1, 0, newData);
42498
42498
  }
42499
42499
  changeDataSource(dataSource);
42500
42500
  if (tableElement && index === totalCount) {
@@ -45484,17 +45484,17 @@ const defaultStyleExportSetting = {
45484
45484
  };
45485
45485
 
45486
45486
  const StyleInput = (props) => {
45487
- const { classLabel, control, name, label, labelSize, required, errors, desciptionLabel, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
45487
+ const { control, name, label, labelSize, required, errors, height, disabled, isLabel, inLine, classes, disabledBackgroundColor, disabledFontFamily, disabledFontSize, disabledBold, disabledItalic, disabledUnderline } = props;
45488
45488
  const renderInput = () => {
45489
45489
  return (jsxs(Fragment, { children: [jsx(Controller, { name: name, control: control, render: ({ field: { value, onChange } }) => {
45490
- return (jsx(InputStyleComponent$1, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
45490
+ return (jsx(InputStyleComponent, { disabledBackgroundColor: disabledBackgroundColor, disabledFontFamily: disabledFontFamily, disabledFontSize: disabledFontSize, disabledBold: disabledBold, disabledItalic: disabledItalic, disabledUnderline: disabledUnderline, disabled: disabled, value: value, onChange: onChange }));
45491
45491
  } }), errors && jsx(FormFeedback$1, { children: errors?.message })] }));
45492
45492
  };
45493
45493
  return (jsx(Fragment, { children: jsxs("div", { className: classnames(' align', {
45494
45494
  [labelSize ? labelSize : '']: labelSize,
45495
45495
  [classes ? classes : '']: classes,
45496
45496
  'form-row-inline-error': errors
45497
- }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel$1({ isLabel, desciptionLabel, classLabel, name, label, required }), jsx("div", { style: { height: `${height}px` }, className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
45497
+ }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'), children: [renderLabel({ isLabel, name, label, required }), jsx("div", { style: { height: `${height}px` }, className: classnames('form-input-content', { 'hidden-label': isLabel === false }), children: renderInput() })] }) }));
45498
45498
  };
45499
45499
 
45500
45500
  const ExportExcelComponent = ({ openModal, typeModal, handleModal, windowSize, dataItem, columns, columnGroups }) => {