es-grid-template 1.5.7 → 1.5.9

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.
@@ -883,6 +883,8 @@ const EditableCell = props => {
883
883
  };
884
884
  return /*#__PURE__*/React.createElement(NumericFormat, _extends({
885
885
  id: `col${indexCol}-record${indexRow}`
886
+ // value={value ? numericFormatter(value.toString(), numericFormatProps) : ''}
887
+ // value={value}
886
888
  }, numericFormatProps, {
887
889
  min: column.min,
888
890
  max: column.max,
@@ -898,7 +900,7 @@ const EditableCell = props => {
898
900
  'be-cell-edit-align-right': !column.align || column.align === 'right'
899
901
  }),
900
902
  onValueChange: values => {
901
- onChange(values?.floatValue);
903
+ onChange(values?.floatValue || 0);
902
904
  },
903
905
  onBlur: () => {
904
906
  const formState = getValues();
@@ -36,6 +36,7 @@ import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable
36
36
  // import {CSS} from "@dnd-kit/utilities";
37
37
  import { Resizable } from "react-resizable";
38
38
  import { faker } from "@faker-js/faker";
39
+ import InfiniteTable from "./table/InfiniteTable";
39
40
  dayjs.extend(customParseFormat);
40
41
  const MySwal = withReactContent(Swal);
41
42
  const ASCEND = 'ascend';
@@ -177,6 +178,7 @@ const InternalTable = props => {
177
178
  pagination,
178
179
  height: propsHeight,
179
180
  summary,
181
+ infiniteScroll,
180
182
  ...rest
181
183
  } = props;
182
184
  const id = React.useMemo(() => {
@@ -807,7 +809,7 @@ const InternalTable = props => {
807
809
  triggerChangeData(newData);
808
810
  }
809
811
  };
810
- const TableComponent = groupAble ? Group : editAble ? GridEdit : Grid;
812
+ const TableComponent = infiniteScroll ? InfiniteTable : groupAble ? Group : editAble ? GridEdit : Grid;
811
813
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DndContext, {
812
814
  sensors: sensors,
813
815
  modifiers: [restrictToHorizontalAxis],
@@ -4,6 +4,6 @@ import type { TableLocale } from "rc-master-ui/lib/table/interface";
4
4
  import type { ColumnsTable } from "../../type";
5
5
  export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
6
6
  export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
7
- export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, format?: IFormat) => any;
7
+ export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, record: T, format?: IFormat) => any;
8
8
  export declare const renderContent: <T>(column: ColumnTable<T>, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
9
9
  export declare const renderFilter: <RecordType>(column: ColumnTable<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any, format?: IFormat, dateRangeLocale?: any) => React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, convertFormat, getDatepickerFormat, getDateString, getTypeFilter, isColor, isEmpty } from "../utils";
1
+ import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, convertFormat, getDatepickerFormat, getDateRangeFormat, getDateString, getFormat, getTypeFilter, isColor, isEmpty } from "../utils";
2
2
  import { numericFormatter } from "react-numeric-component";
3
3
  import dayjs from "dayjs";
4
4
  import moment from "moment/moment";
@@ -55,25 +55,29 @@ export const flatColumns2 = columns => {
55
55
  }];
56
56
  }, []);
57
57
  };
58
- export const getValueCell = (column, value, format) => {
58
+ export const getValueCell = (column, value, record, format) => {
59
59
  switch (column?.type) {
60
60
  case 'number':
61
- const thousandSeparator = format?.thousandSeparator;
62
- const decimalSeparator = format?.decimalSeparator;
63
- const dec = format?.decimalScale;
61
+ const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
62
+ const cellFormat = getFormat(colFormat, format);
63
+ const thousandSeparator = cellFormat?.thousandSeparator;
64
+ const decimalSeparator = cellFormat?.decimalSeparator;
65
+ const dec = cellFormat?.decimalScale;
64
66
 
65
67
  // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
66
68
 
67
69
  const tmpval = typeof value === 'string' ? Number(value) : value;
68
70
  const contentNumber = !isEmpty(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
71
+ // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? tmpval.toString() : tmpval.toString()) : '0'
72
+
69
73
  const numericFormatProps = {
70
74
  thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
71
75
  decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
72
- allowNegative: format?.allowNegative ?? true,
73
- prefix: format?.prefix,
74
- suffix: format?.suffix,
76
+ allowNegative: cellFormat?.allowNegative ?? true,
77
+ prefix: cellFormat?.prefix,
78
+ suffix: cellFormat?.suffix,
75
79
  decimalScale: dec,
76
- fixedDecimalScale: format?.fixedDecimalScale ?? false
80
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
77
81
  };
78
82
  return !isEmpty(contentNumber) ? numericFormatter(contentNumber, numericFormatProps) : '';
79
83
  case 'date':
@@ -115,7 +119,7 @@ export const getValueCell = (column, value, format) => {
115
119
  };
116
120
  export const renderContent = (column, value, record, index, format) => {
117
121
  const cellValue = value instanceof Date ? getDateString(column, value) : value;
118
- const content = getValueCell(column, cellValue, format);
122
+ const content = getValueCell(column, cellValue, record, format);
119
123
  return /*#__PURE__*/React.createElement(Fragment, null, column?.template ? typeof column.template === "function" ? column.template({
120
124
  value,
121
125
  index,
@@ -127,7 +131,7 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
127
131
  const cellFormat = column.format ? typeof column.format === 'function' ? column.format({}) : column.format : format;
128
132
  const type = getTypeFilter(column);
129
133
  const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, cellFormat) ?? 'DD/MM/YYYY';
130
- const dateRangeFormat = convertFormat(getDatepickerFormat(column?.type, cellFormat) ?? 'DD/MM/YYYY');
134
+ const dateRangeFormat = convertFormat(getDateRangeFormat(column?.type, cellFormat) ?? 'dd/MM/yyyy');
131
135
  const find = dataSourceFilter?.find(it => it.key === column?.field);
132
136
  const options = find ? find.data : [];
133
137
  switch (type) {
@@ -16,7 +16,7 @@ const HeaderContent = props => {
16
16
  return columnGroupText ?? headerText;
17
17
  }, [columnGroupText, headerText]);
18
18
  const tooltip = React.useMemo(() => {
19
- return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
19
+ return headerTooltip ?? t ? t?.(columnGroupText ?? headerText) : columnGroupText ?? headerText;
20
20
  }, [columnGroupText, headerText, headerTooltip, t]);
21
21
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
22
22
  className: classnames('', {}),
@@ -175,7 +175,7 @@ export const getFormat = (colFormat, format) => {
175
175
  return {
176
176
  thousandSeparator: colFormat?.thousandSeparator ?? format?.thousandSeparator,
177
177
  decimalSeparator: colFormat?.decimalSeparator ?? format?.decimalSeparator,
178
- decimalScale: colFormat?.decimalScale ?? format?.decimalScale,
178
+ decimalScale: colFormat?.decimalScale ?? format?.decimalScale ? Number(colFormat?.decimalScale ?? format?.decimalScale) : colFormat?.decimalScale ?? format?.decimalScale,
179
179
  allowNegative: colFormat?.allowNegative ?? format?.allowNegative,
180
180
  // check nhập số âm
181
181
  prefix: colFormat?.prefix ?? format?.prefix,
@@ -217,21 +217,21 @@ export const getDatepickerFormat = (type, format) => {
217
217
  switch (typeFormat) {
218
218
  case "date":
219
219
  case "daterange":
220
- return format?.dateFormat ?? 'dd/MM/YYYY';
220
+ return format?.dateFormat ?? 'DD/MM/YYYY';
221
221
  case "datetime":
222
- return format?.datetimeFormat ?? 'dd/MM/YYYY HH:mm';
222
+ return format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm';
223
223
  case "week":
224
- return format?.weekFormat ?? 'dd/MM';
224
+ return format?.weekFormat ?? 'DD/MM';
225
225
  case "month":
226
226
  return format?.monthFormat ?? 'MM/YYYY';
227
227
  case "quarter":
228
- return format?.dateFormat ?? 'dd/MM/YYYY';
228
+ return format?.dateFormat ?? 'DD/MM/YYYY';
229
229
  case "year":
230
230
  return format?.yearFormat ?? 'YYYY';
231
231
  case "time":
232
232
  return format?.timeFormat ?? 'HH:mm';
233
233
  default:
234
- return 'dd/MM/YYYY';
234
+ return 'DD/MM/YYYY';
235
235
  }
236
236
  };
237
237
  export const getDateRangeFormat = (type, format) => {
@@ -239,21 +239,21 @@ export const getDateRangeFormat = (type, format) => {
239
239
  switch (typeFormat) {
240
240
  case "date":
241
241
  case "daterange":
242
- return convertFormat(format?.dateFormat ?? 'DD/MM/YYYY');
242
+ return convertFormat(format?.dateFormat ?? 'dd/MM/yyyy');
243
243
  case "datetime":
244
- return format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm';
244
+ return format?.datetimeFormat ?? 'dd/MM/yyyy HH:mm';
245
245
  case "week":
246
- return format?.weekFormat ?? 'DD/MM';
246
+ return format?.weekFormat ?? 'dd/MM';
247
247
  case "month":
248
- return format?.monthFormat ?? 'MM/YYYY';
248
+ return format?.monthFormat ?? 'MM/yyyy';
249
249
  case "quarter":
250
- return format?.dateFormat ?? 'DD/MM/YYYY';
250
+ return format?.dateFormat ?? 'dd/MM/yyyy';
251
251
  case "year":
252
- return format?.yearFormat ?? 'YYYY';
252
+ return format?.yearFormat ?? 'yyyy';
253
253
  case "time":
254
254
  return format?.timeFormat ?? 'HH:mm';
255
255
  default:
256
- return 'DD/MM/YYYY';
256
+ return 'dd/MM/yyyy';
257
257
  }
258
258
  };
259
259
  export const customWeekStartEndFormat = (value, weekFormat) => {