es-grid-template 1.9.19 → 1.9.21

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.
@@ -135,95 +135,175 @@ export interface SpanRect {
135
135
  right: number;
136
136
  }
137
137
  export type ColumnTable<RecordType = AnyObject> = {
138
+ /** Field key dùng để mapping dữ liệu */
138
139
  field: string;
140
+ /** Text hiển thị ở header */
141
+ headerText?: string;
142
+ /** Field gốc trước khi transform */
139
143
  fieldOriginal?: string;
144
+ /** Độ rộng column */
140
145
  width?: number;
146
+ /** Độ rộng tối đa */
141
147
  maxWidth?: number;
148
+ /** Độ rộng tối thiểu */
142
149
  minWidth?: number;
150
+ /** Hiển thị trong popup chọn column */
151
+ showInColumnChoose?: boolean;
152
+ /** Kiểu dữ liệu của column */
143
153
  type?: IColumnType;
154
+ /** Format hiển thị dữ liệu column type = number */
155
+ format?: IFormat | ((rowData: any) => IFormat);
156
+ /**
157
+ * @deprecated Please use `isSummary` instead.
158
+ * @since 1.7.25
159
+ */
144
160
  haveSum?: boolean;
161
+ /** Có tính tổng column type = number hay không
162
+ *
163
+ * Mặc định = true
164
+ */
145
165
  isSummary?: boolean;
166
+ /** Có tính tổng theo group */
167
+ sumGroup?: boolean;
168
+ /** Template custom cho ô summary */
146
169
  summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
147
- /** Custom method to get cell props */
148
- format?: IFormat | ((rowData: any) => IFormat);
149
- allowFiltering?: boolean;
150
170
  /**
151
171
  * @deprecated Please use `allowSortering` instead.
152
172
  * @since 1.7.25
153
173
  */
154
174
  sorter?: boolean;
175
+ /** Cho phép filter
176
+ *
177
+ * Mặc định = true
178
+ */
179
+ allowFiltering?: boolean;
180
+ /** Cho phép sort dữ liệu
181
+ *
182
+ * Mặc định = true
183
+ * */
155
184
  allowSortering?: boolean;
185
+ /** Kiểu filter */
186
+ typeFilter?: TypeFilter;
187
+ /** Toán tử filter mặc định */
156
188
  operator?: FilterOperator;
189
+ /** Ẩn phần chọn toán tử filter
190
+ * mặc đinh = false
191
+ */
157
192
  hideOperator?: boolean;
193
+ /** Custom Placeholder cho input/ Select/ Date.... filter */
158
194
  placeholder?: string;
159
- showInColumnChoose?: boolean;
160
- typeFilter?: TypeFilter;
195
+ /** Data source cho select/filter */
161
196
  source?: any[];
197
+ /** Hiển thị ô search trong select filter */
162
198
  showFilterSearch?: boolean;
163
- headerText?: string;
164
199
  /**
165
200
  * @deprecated Please use `visible` instead.
166
201
  * @since 1.7.33
167
202
  */
168
203
  hidden?: boolean;
204
+ /** Hiển thị / ẩn column
205
+ * mặc định = true
206
+ * */
169
207
  visible?: boolean;
208
+ /** Tooltip cho header */
170
209
  headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
210
+ /** Tên group header */
171
211
  columnGroupText?: string;
172
- /**
173
- * @deprecated Please use `textAlign` instead.
174
- * @since 1.7.34
175
- */
176
- align?: ITextAlign;
177
- textAlign?: ITextAlign;
212
+ /** Canh lề nội dung header */
178
213
  headerTextAlign?: ITextAlign;
179
- template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
180
- showTooltip?: boolean;
181
- tooltipDescription?: string | ((args: {
182
- value: any;
183
- rowData: RecordType;
184
- }) => ReactNode | ReactElement);
214
+ /** Template custom render header */
185
215
  headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
186
- commandItems?: CommandItem[];
187
- children?: ColumnTable<RecordType>[];
188
- editType?: EditType | ((rowData?: RecordType) => EditType);
189
- disable?: boolean | ((rowData: any) => boolean);
190
- editEnable?: boolean | ((rowData: any) => boolean);
191
- isClearable?: boolean;
192
- maxDate?: any;
193
- minDate?: any;
194
- maxTime?: any;
195
- minTime?: any;
196
- max?: number;
197
- min?: number;
198
- editSelectSettings?: IEditSelectSettings;
199
- editFromSettings?: IEditFromSettings;
200
216
  /**
201
217
  * @deprecated Please use `fixed` instead.
202
218
  * @since 1.7.25
203
219
  */
204
220
  fixedType?: FixedType;
221
+ /** Fixed column trái/phải */
205
222
  fixed?: FixedType;
206
223
  /**
207
- * @deprecated Please use `wrapSettings` instead.
224
+ * @deprecated Please use `wrapSettings` on Table instead.
208
225
  * @since 1.7.34
209
226
  */
210
227
  headerTextWrap?: boolean;
228
+ /** Hiển thị dấu ... khi text overflow */
211
229
  ellipsis?: boolean;
230
+ /** Cho phép resize column
231
+ *
232
+ * Mặc định = true
233
+ */
212
234
  allowResizing?: boolean;
213
- allowSelection?: boolean | ((rowData: RecordType) => boolean);
235
+ /**
236
+ * @deprecated Please use `textAlign` instead.
237
+ * @since 1.7.34
238
+ */
239
+ align?: ITextAlign;
240
+ /** Canh lề nội dung cell */
241
+ textAlign?: ITextAlign;
242
+ /** Template custom render cell */
243
+ template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
244
+ /** Hiển thị tooltip cell */
245
+ showTooltip?: boolean;
246
+ /** Nội dung tooltip của cell */
247
+ tooltipDescription?: string | ((args: {
248
+ value: any;
249
+ rowData: RecordType;
250
+ }) => ReactNode | ReactElement);
251
+ /**
252
+ * @deprecated Please use `getCellProps` instead.
253
+ * @since 1.7.34
254
+ */
214
255
  onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
256
+ /**
257
+ * @deprecated Please use `headerCellProps` instead.
258
+ * @since 1.7.34
259
+ */
215
260
  onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
261
+ /**
262
+ * @deprecated Please use `getCellProps` instead.
263
+ * @since 1.7.34
264
+ */
265
+ onCell?: (rowData: RecordType, index: number) => React.TdHTMLAttributes<HTMLTableCellElement>;
216
266
  onCellFooterStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
217
- sumGroup?: boolean;
218
267
  /** Custom data retrieval method */
268
+ /** Custom method lấy value cell */
219
269
  getValue?: (row: any, rowIndex: number) => any;
220
- /** Custom render method */
221
270
  /** Custom method to get cell props */
222
271
  getCellProps?: (value: any, row: any, rowIndex: number) => CellProps;
223
272
  /** Props for the header cell */
224
273
  headerCellProps?: CellProps;
225
274
  /** Custom method to get cell SpanRect */
275
+ /** Custom merge cell */
226
276
  getSpanRect?: (value: any, row: any, rowIndex: number) => SpanRect;
277
+ /** Kiểu editor khi edit cell */
278
+ editType?: EditType | ((rowData?: RecordType) => EditType);
279
+ /** Disable editor */
280
+ disable?: boolean | ((rowData: any) => boolean);
281
+ /** Cho phép edit */
282
+ editEnable?: boolean | ((rowData: any) => boolean);
283
+ /** Cho phép clear value khi edit */
284
+ isClearable?: boolean;
285
+ /** Ngày lớn nhất cho date picker */
286
+ maxDate?: any;
287
+ /** Ngày nhỏ nhất cho date picker */
288
+ minDate?: any;
289
+ /** Thời gian lớn nhất */
290
+ maxTime?: any;
291
+ /** Thời gian nhỏ nhất */
292
+ minTime?: any;
293
+ /** Giá trị số lớn nhất khi editType : number */
294
+ max?: number;
295
+ /** Giá trị số nhỏ nhất khi editType : number */
296
+ min?: number;
297
+ /** Config select editor */
298
+ editSelectSettings?: IEditSelectSettings;
299
+ /** Config form editor */
300
+ editFromSettings?: IEditFromSettings;
301
+ /** Cho phép select column */
302
+ allowSelection?: boolean | ((rowData: RecordType) => boolean);
303
+ /** Danh sách command/action trong column type = command */
304
+ commandItems?: CommandItem[];
305
+ /** Column con (multi header/group column) */
306
+ children?: ColumnTable<RecordType>[];
227
307
  };
228
308
  export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
229
309
  export type IFTheme = {
@@ -155,42 +155,53 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
155
155
  export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordType>[], fixedFields: string[]) => {
156
156
  fixed: string;
157
157
  field: string;
158
+ headerText?: string;
158
159
  fieldOriginal?: string;
159
160
  width?: number;
160
161
  maxWidth?: number;
161
162
  minWidth?: number;
163
+ showInColumnChoose?: boolean;
162
164
  type?: IColumnType;
165
+ format?: IFormat | ((rowData: any) => IFormat);
163
166
  haveSum?: boolean;
164
167
  isSummary?: boolean;
168
+ sumGroup?: boolean;
165
169
  summaryTemplate?: (data: number, key: string) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode;
166
- format?: IFormat | ((rowData: any) => IFormat);
167
- allowFiltering?: boolean;
168
170
  sorter?: boolean;
171
+ allowFiltering?: boolean;
169
172
  allowSortering?: boolean;
173
+ typeFilter?: TypeFilter;
170
174
  operator?: FilterOperator;
171
175
  hideOperator?: boolean;
172
176
  placeholder?: string;
173
- showInColumnChoose?: boolean;
174
- typeFilter?: TypeFilter;
175
177
  source?: any[];
176
178
  showFilterSearch?: boolean;
177
- headerText?: string;
178
179
  hidden?: boolean;
179
180
  visible?: boolean;
180
181
  headerTooltip?: string | boolean | (() => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
181
182
  columnGroupText?: string;
183
+ headerTextAlign?: import("./../../grid-component/type").ITextAlign;
184
+ headerTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((column: ColumnTable<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
185
+ fixedType?: import("./../../grid-component/type").FixedType;
186
+ headerTextWrap?: boolean;
187
+ ellipsis?: boolean;
188
+ allowResizing?: boolean;
182
189
  align?: import("./../../grid-component/type").ITextAlign;
183
190
  textAlign?: import("./../../grid-component/type").ITextAlign;
184
- headerTextAlign?: import("./../../grid-component/type").ITextAlign;
185
191
  template?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
186
192
  showTooltip?: boolean;
187
193
  tooltipDescription?: string | ((args: {
188
194
  value: any;
189
195
  rowData: RecordType;
190
196
  }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
191
- headerTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((column: ColumnTable<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
192
- commandItems?: import("./../../grid-component/type").CommandItem[];
193
- children?: ColumnTable<RecordType>[];
197
+ onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
198
+ onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
199
+ onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
200
+ onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "display" | "position">);
201
+ getValue?: (row: any, rowIndex: number) => any;
202
+ getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
203
+ headerCellProps?: import("./../../grid-component/type").CellProps;
204
+ getSpanRect?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").SpanRect;
194
205
  editType?: EditType | ((rowData?: RecordType) => EditType);
195
206
  disable?: boolean | ((rowData: any) => boolean);
196
207
  editEnable?: boolean | ((rowData: any) => boolean);
@@ -203,18 +214,8 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
203
214
  min?: number;
204
215
  editSelectSettings?: import("./../../grid-component/type").IEditSelectSettings;
205
216
  editFromSettings?: import("./../../grid-component/type").IEditFromSettings;
206
- fixedType?: import("./../../grid-component/type").FixedType;
207
- headerTextWrap?: boolean;
208
- ellipsis?: boolean;
209
- allowResizing?: boolean;
210
217
  allowSelection?: boolean | ((rowData: RecordType) => boolean);
211
- onCellStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
212
- onCellHeaderStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
213
- onCellFooterStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
214
- sumGroup?: boolean;
215
- getValue?: (row: any, rowIndex: number) => any;
216
- getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
217
- headerCellProps?: import("./../../grid-component/type").CellProps;
218
- getSpanRect?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").SpanRect;
218
+ commandItems?: import("./../../grid-component/type").CommandItem[];
219
+ children?: ColumnTable<RecordType>[];
219
220
  }[];
220
221
  export declare function sortColumnsByField<T extends ColumnTable>(columns: T[], priorityFields: string[]): T[];
@@ -525,9 +525,8 @@ const EditableCell = props => {
525
525
  placeholder: t && column.placeholder ? t(column.placeholder) : tableLocal?.selectPlaceholder,
526
526
  allowClear: column.isClearable ?? false,
527
527
  maxTagCount: 'responsive',
528
- popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined
529
- // optionFilterProp="label"
530
- ,
528
+ popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
529
+ optionFilterProp: "label",
531
530
  popupClassName: 'be-popup-container',
532
531
  status: isInvalid ? 'error' : undefined,
533
532
  filterOption: filterKey ? (input, option) => {
@@ -664,9 +663,8 @@ const EditableCell = props => {
664
663
  placeholder: t && column.placeholder ? t(column.placeholder) : tableLocal?.selectPlaceholder,
665
664
  allowClear: column.isClearable ?? false,
666
665
  maxTagCount: 'responsive',
667
- popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined
668
- // optionFilterProp="label"
669
- ,
666
+ popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
667
+ optionFilterProp: "label",
670
668
  popupClassName: 'be-popup-container',
671
669
  loadOptions: loadOptions,
672
670
  status: isInvalid ? 'error' : undefined,
@@ -5,7 +5,7 @@ import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
5
5
  import classNames from "classnames";
6
6
  import React from "react";
7
7
  import { TableContext } from "../useContext";
8
- import { renderValueCell, toggleRowSelection } from "../hook/useColumns";
8
+ import { getValueCellString, renderValueCell, toggleRowSelection } from "../hook/useColumns";
9
9
  const renderCellIndex = props => {
10
10
  const {
11
11
  parrents,
@@ -184,17 +184,6 @@ const TableBodyCell = props => {
184
184
  const record = cell.row.original;
185
185
  const columnMeta = cell.column.columnDef.meta ?? {};
186
186
  const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
187
- const tooltipContent = React.useMemo(() => {
188
- if (isOpenTooltip === false) {
189
- return '';
190
- } else {
191
- const abc = columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
192
- value: cell.getValue(),
193
- rowData: record
194
- }) : columnMeta.tooltipDescription : cell.getValue();
195
- return abc;
196
- }
197
- }, [cell, columnMeta, isOpenTooltip, record]);
198
187
 
199
188
  // const tooltipContent: any = (isOpenTooltip === false)
200
189
  // ? ''
@@ -220,6 +209,18 @@ const TableBodyCell = props => {
220
209
  const cellValue = cell.getValue();
221
210
  const rowIndex = cell.row.index;
222
211
  const fomatedValue = renderValueCell(columnMeta, cellValue, record, rowIndex, colIndex, format, false);
212
+ const valueCellString = getValueCellString(columnMeta, cellValue, record, rowIndex, colIndex, format);
213
+ const tooltipContent = React.useMemo(() => {
214
+ if (isOpenTooltip === false) {
215
+ return '';
216
+ } else {
217
+ const abc = columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
218
+ value: cell.getValue(),
219
+ rowData: record
220
+ }) : columnMeta.tooltipDescription : valueCellString;
221
+ return abc;
222
+ }
223
+ }, [cell, columnMeta, isOpenTooltip, record, valueCellString]);
223
224
  if (cell.column.id === "#") {
224
225
  return /*#__PURE__*/React.createElement("div", {
225
226
  key: cell.id,
@@ -7,7 +7,7 @@ import React from "react";
7
7
  import { TableContext } from "../useContext";
8
8
  import EditableCell from "./EditableCell";
9
9
  import { nonActionColumn } from "../../grid-component/hooks";
10
- import { renderValueCell, toggleRowSelection } from "../hook/useColumns";
10
+ import { getValueCellString, renderValueCell, toggleRowSelection } from "../hook/useColumns";
11
11
  const renderCellIndex = props => {
12
12
  const {
13
13
  parrents,
@@ -237,10 +237,13 @@ const TableBodyCellEdit = props => {
237
237
  const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
238
238
  const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
239
239
  const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
240
- const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
241
- value: cell.getValue(),
242
- rowData: record
243
- }) : columnMeta.tooltipDescription : cell.getValue();
240
+
241
+ // const tooltipContent = (isOpenTooltip === false)
242
+ // ? ''
243
+ // : columnMeta?.tooltipDescription
244
+ // ? (typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({ value: cell.getValue(), rowData: record }) : columnMeta.tooltipDescription)
245
+ // : cell.getValue()
246
+
244
247
  const canEdit = isEditable(cell.column.columnDef.meta, record) && isRowEditable !== false;
245
248
 
246
249
  // const allRows = table.getRowModel().rows;
@@ -292,6 +295,19 @@ const TableBodyCellEdit = props => {
292
295
  const isLeftPaste = colIdxPaste === pasteRangeState.startColIndex;
293
296
  const isRightPaste = colIdxPaste === pasteRangeState.endColIndex;
294
297
  const parrents = cell.row.getParentRows();
298
+ const valeOfCell = cell.getValue();
299
+ const valueCellString = getValueCellString(columnMeta, valeOfCell, record, rowNumber, colIndex, format);
300
+ const tooltipContent = React.useMemo(() => {
301
+ if (isOpenTooltip === false) {
302
+ return '';
303
+ } else {
304
+ const abc = columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
305
+ value: cell.getValue(),
306
+ rowData: record
307
+ }) : columnMeta.tooltipDescription : valueCellString;
308
+ return abc;
309
+ }
310
+ }, [cell, columnMeta, isOpenTooltip, record, valueCellString]);
295
311
  const triggerDragPaste = (pasteState, ctrlKey) => {
296
312
  const tmpCols = table.getVisibleLeafColumns();
297
313
  const rowPasteIds = getRowIdsBetween(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
@@ -194,7 +194,9 @@ const TableHeadCell2 = props => {
194
194
  doFilter,
195
195
  format,
196
196
  dataSourceFilter,
197
- tableLocal
197
+ tableLocal,
198
+ prevFilterValue: column.getFilterValue(),
199
+ triggerVisible
198
200
  })), /*#__PURE__*/React.createElement(Space, {
199
201
  style: {
200
202
  justifyContent: 'end',
@@ -16,6 +16,8 @@ type RenderFilterProps<RecordType> = {
16
16
  dateRangeLocale?: any;
17
17
  doFilter?: (type: boolean) => void;
18
18
  tableLocal: any;
19
+ prevFilterValue?: string[];
20
+ triggerVisible?: (visible: boolean) => void;
19
21
  };
20
22
  export declare const renderFilter: <RecordType>(args: RenderFilterProps<RecordType>) => React.JSX.Element;
21
23
  export {};
@@ -10,6 +10,16 @@ import { convertDateToDayjs, convertDayjsToDate, convertFormat, getDatepickerFor
10
10
  import NumberInput from "../components/number";
11
11
  import NumberRange from "../components/number-range";
12
12
  import CheckboxFilter from "../components/checkbox-filter/CheckboxFilter";
13
+ const isEqualDateArray = (arr1, arr2) => {
14
+ if (arr1?.length !== arr2?.length) {
15
+ return false;
16
+ }
17
+ return arr1?.every((item, index) => {
18
+ const date1 = new Date(item).getTime();
19
+ const date2 = new Date(arr2?.[index]).getTime();
20
+ return date1 === date2;
21
+ });
22
+ };
13
23
  export const renderFilter = args => {
14
24
  const {
15
25
  column,
@@ -20,7 +30,9 @@ export const renderFilter = args => {
20
30
  dataSourceFilter,
21
31
  format,
22
32
  doFilter,
23
- tableLocal
33
+ tableLocal,
34
+ prevFilterValue,
35
+ triggerVisible
24
36
  } = args;
25
37
  const {
26
38
  format: columnFormat,
@@ -97,10 +109,26 @@ export const renderFilter = args => {
97
109
  onChange: value => {
98
110
  const newDateRangeValue = value ? [value[0] ? moment(value[0]).format() : '', value[1] ? moment(value[1]).format() : ''] : [];
99
111
  setSelectedKeys(newDateRangeValue);
100
- }
112
+ },
113
+ onOk: value => {
114
+ const newDateRangeValue = value ? [value[0] ? moment(value[0]).format() : '', value[1] ? moment(value[1]).format() : ''] : [];
115
+ setSelectedKeys(newDateRangeValue);
116
+ },
117
+ onExit: () => {
118
+ // clear nhưng chưa ấn OK
119
+ if (!dateRangeValue) {
120
+ return;
121
+ }
101
122
 
102
- // onSelect={(val) => {
103
- // }}
123
+ // Click ok
124
+ if (!isEqualDateArray(dateRangeValue, prevFilterValue)) {
125
+ // giá trị khác nhau
126
+ doFilter?.(true);
127
+ } else {
128
+ // giá trị = nhau
129
+ triggerVisible?.(false);
130
+ }
131
+ }
104
132
 
105
133
  // menuClassName="rc-menu-popup"
106
134
  ,
@@ -2,6 +2,7 @@ import type { Dispatch, SetStateAction } from "react";
2
2
  import type { ColumnsTable, ColumnTable, IFormat, SelectionSettings } from '../../grid-component/type';
3
3
  import type { Cell, ColumnDef } from '@tanstack/react-table';
4
4
  export declare const renderValueCell: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat, editAble?: boolean) => any;
5
+ export declare const getValueCellString: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat) => any;
5
6
  export declare function convertToTanStackColumns<T>({ t, columns, format, editAble }: {
6
7
  t?: any;
7
8
  columns: ColumnsTable<T>;
@@ -41,7 +41,7 @@ export const renderValueCell = (column, value, record, rowIndex, colIndex, forma
41
41
  return value ? value : '';
42
42
  case 'year':
43
43
  const year = value ? moment(value).format('yyyy') : '';
44
- return /*#__PURE__*/React.createElement(Fragment, null, year);
44
+ return year;
45
45
  case 'datetime':
46
46
  return value ? moment(value).format(format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
47
47
  case 'boolean':
@@ -76,6 +76,61 @@ export const renderValueCell = (column, value, record, rowIndex, colIndex, forma
76
76
  return value;
77
77
  }
78
78
  };
79
+ export const getValueCellString = (column, value, record, rowIndex, colIndex, format) => {
80
+ const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
81
+ const cellFormat = getFormat(colFormat, format);
82
+ switch (column?.type) {
83
+ case 'number':
84
+ // const colFormat = typeof column.format === 'function' ? column.format(record) : column.format
85
+
86
+ // const cellFormat = getFormat(colFormat, format)
87
+
88
+ const thousandSeparator = cellFormat?.thousandSeparator;
89
+ const decimalSeparator = cellFormat?.decimalSeparator;
90
+ const dec = cellFormat?.decimalScale;
91
+
92
+ // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
93
+
94
+ const tmpval = typeof value === 'string' ? Number(value) : value;
95
+ const numericFormatProps = {
96
+ thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
97
+ decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
98
+ allowNegative: cellFormat?.allowNegative ?? true,
99
+ prefix: cellFormat?.prefix,
100
+ suffix: cellFormat?.suffix,
101
+ decimalScale: dec,
102
+ fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
103
+ };
104
+
105
+ // if ( typeof value === "string") {
106
+ // const ttt = removeNumericFormat(value, undefined, numericFormatProps )
107
+ //
108
+ // }
109
+
110
+ const contentNumber = !isEmpty(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
111
+ // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? tmpval.toString() : tmpval.toString()) : '0'
112
+
113
+ return !isEmpty(contentNumber) ? numericFormatter(contentNumber, numericFormatProps) : '';
114
+ case 'date':
115
+ return value ? dayjs(value).format(cellFormat?.dateFormat ?? 'DD/MM/YYYY') : '';
116
+ case 'time':
117
+ return value ? value : '';
118
+ case 'year':
119
+ const year = value ? moment(value).format('yyyy') : '';
120
+ return year;
121
+ case 'datetime':
122
+ return value ? moment(value).format(cellFormat?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
123
+ case 'boolean':
124
+ return value ? 'true' : 'false';
125
+ const nameFile = typeof value === 'object' && !Array.isArray(value) ? value.name : Array.isArray(value) ? value.map(it => typeof it === 'object' ? it.name : it).filter(Boolean).join(", ") : '';
126
+ return value ? nameFile : '';
127
+ default:
128
+ if (Array.isArray(value)) {
129
+ return value.join(', ');
130
+ }
131
+ return value;
132
+ }
133
+ };
79
134
  export function convertToTanStackColumns({
80
135
  t,
81
136
  columns,
@@ -67,6 +67,8 @@ export declare const detectSeparators: (str: string) => {
67
67
  thousandSeparator: string;
68
68
  decimalSeparator: string;
69
69
  };
70
+ export declare const isDateValue: (value: any) => boolean;
71
+ export declare const convertFomatedDateToDate: (value: string) => Date | null;
70
72
  export declare function isDateString(str: any): boolean;
71
73
  export declare function compareDates(date1: any, date2: any): boolean;
72
74
  export declare function compareDate(itemValue: any, value: any): boolean;