es-grid-template 1.5.0 → 1.5.2

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.
Files changed (39) hide show
  1. package/es/grid-component/ColumnsChoose.js +1 -1
  2. package/es/grid-component/EditableCell.js +14 -12
  3. package/es/grid-component/GridStyle.js +1 -1
  4. package/es/grid-component/InternalTable.js +15 -4
  5. package/es/grid-component/TableGrid.js +1 -1
  6. package/es/grid-component/async-select/index.d.ts +4 -2
  7. package/es/grid-component/async-select/index.js +3 -0
  8. package/es/grid-component/async-table-select/index.d.ts +4 -2
  9. package/es/grid-component/async-table-select/index.js +4 -1
  10. package/es/grid-component/hooks/columns/index.d.ts +1 -1
  11. package/es/grid-component/hooks/columns/index.js +19 -31
  12. package/es/grid-component/hooks/utils.d.ts +3 -0
  13. package/es/grid-component/hooks/utils.js +85 -2
  14. package/es/grid-component/styles.scss +4 -0
  15. package/es/grid-component/table/GridEdit.js +93 -76
  16. package/es/grid-component/table/Group.js +11 -1
  17. package/es/grid-component/type.d.ts +9 -0
  18. package/es/grid-component/useContext.d.ts +1 -0
  19. package/es/grid-component/useContext.js +2 -1
  20. package/lib/grid-component/ColumnsChoose.js +1 -1
  21. package/lib/grid-component/EditableCell.js +14 -12
  22. package/lib/grid-component/GridStyle.js +1 -1
  23. package/lib/grid-component/InternalTable.js +14 -3
  24. package/lib/grid-component/TableGrid.js +1 -1
  25. package/lib/grid-component/async-select/index.d.ts +4 -2
  26. package/lib/grid-component/async-select/index.js +3 -0
  27. package/lib/grid-component/async-table-select/index.d.ts +4 -2
  28. package/lib/grid-component/async-table-select/index.js +4 -1
  29. package/lib/grid-component/hooks/columns/index.d.ts +1 -1
  30. package/lib/grid-component/hooks/columns/index.js +17 -29
  31. package/lib/grid-component/hooks/utils.d.ts +3 -0
  32. package/lib/grid-component/hooks/utils.js +96 -7
  33. package/lib/grid-component/styles.scss +4 -0
  34. package/lib/grid-component/table/GridEdit.js +93 -76
  35. package/lib/grid-component/table/Group.js +11 -1
  36. package/lib/grid-component/type.d.ts +9 -0
  37. package/lib/grid-component/useContext.d.ts +1 -0
  38. package/lib/grid-component/useContext.js +2 -1
  39. package/package.json +110 -110
@@ -17,6 +17,8 @@ var _GridEdit = _interopRequireDefault(require("./table/GridEdit"));
17
17
  var _Grid = _interopRequireDefault(require("./table/Grid"));
18
18
  var _en_US = _interopRequireDefault(require("rc-master-ui/es/date-picker/locale/en_US"));
19
19
  var _vi_VN = _interopRequireDefault(require("rc-master-ui/es/date-picker/locale/vi_VN"));
20
+ var _en_US2 = _interopRequireDefault(require("rc-master-ui/es/locales/en_US"));
21
+ var _vi_VN2 = _interopRequireDefault(require("rc-master-ui/es/locales/vi_VN"));
20
22
  require("./styles.scss");
21
23
  var _columns = require("./hooks/columns");
22
24
  var _Group = _interopRequireDefault(require("./table/Group"));
@@ -40,6 +42,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
40
42
 
41
43
  // import useColumns from "./hooks/useColumns";
42
44
 
45
+ // import 'rc-master-ui/assets/index.css'
46
+
43
47
  // import {CSS} from "@dnd-kit/utilities";
44
48
 
45
49
  _dayjs.default.extend(_customParseFormat.default);
@@ -213,6 +217,7 @@ const InternalTable = props => {
213
217
  // }, [height, id])
214
218
 
215
219
  const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
220
+ const dateRangeLocale = lang && lang === 'en' ? _en_US2.default : _vi_VN2.default;
216
221
  const buddhistLocale = {
217
222
  ...local,
218
223
  lang: {
@@ -230,8 +235,13 @@ const InternalTable = props => {
230
235
  });
231
236
  const [tooltipContent, setTooltipContent] = (0, _react.useState)('');
232
237
  const mergedData = _react.default.useMemo(() => {
238
+ // return addRowIdArray(dataSource)
239
+
240
+ if (groupSetting && groupSetting.client !== false) {
241
+ return (0, _hooks.groupArrayByColumns)(dataSource, groupColumns);
242
+ }
233
243
  return (0, _hooks.addRowIdArray)(dataSource);
234
- }, [dataSource]);
244
+ }, [dataSource, groupColumns, groupSetting]);
235
245
  const [columns, setColumns] = _react.default.useState([]);
236
246
  _react.default.useEffect(() => {
237
247
  if (propsHeight) {
@@ -330,7 +340,7 @@ const InternalTable = props => {
330
340
  style: {
331
341
  marginBottom: 8
332
342
  }
333
- }, (0, _columns.renderFilter)(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, propDataSourceFilter ?? [], buddhistLocale, locale, t)), /*#__PURE__*/_react.default.createElement(_antd.Space, {
343
+ }, (0, _columns.renderFilter)(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, propDataSourceFilter ?? [], buddhistLocale, locale, t, format, dateRangeLocale)), /*#__PURE__*/_react.default.createElement(_antd.Space, {
334
344
  style: {
335
345
  justifyContent: 'end',
336
346
  width: '100%'
@@ -502,7 +512,8 @@ const InternalTable = props => {
502
512
  'cell-group': groupColumns && data.children,
503
513
  'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
504
514
  }),
505
- 'data-tooltip-id': "tooltip-cell-content"
515
+ // 'data-tooltip-id': "tooltip-cell-content"
516
+ 'data-tooltip-id': `${id}-tooltip-cell-content`
506
517
  };
507
518
  },
508
519
  render: (value, record, rowIndex) => {
@@ -485,7 +485,7 @@ const TableGrid = props => {
485
485
 
486
486
  // const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
487
487
  const dec = cellFormat?.decimalScale;
488
- const sumValue = col.type === 'number' ? (0, _hooks.sumDataByField)(dataSource, col?.key) : 0;
488
+ const sumValue = col.type === 'number' ? (0, _hooks.sumDataByField)((0, _hooks.filterDataByColumns4)(dataSource, filterStates), col?.key) : 0;
489
489
  const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
490
490
  const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
491
491
  const numericFormatProps = {
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
3
  import type { SelectProps } from "rc-master-ui/es/select";
4
+ import type { LoadOptionsArgs } from "../type";
4
5
  export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
5
- loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
6
7
  debounceTimeout?: number;
7
8
  defaultOptions?: OptionType[];
9
+ rowData?: any;
8
10
  }
9
- export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
11
+ export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -15,6 +15,7 @@ function AsyncSelect({
15
15
  loadOptions,
16
16
  debounceTimeout = 500,
17
17
  defaultOptions,
18
+ rowData,
18
19
  ...props
19
20
  }) {
20
21
  const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
@@ -27,6 +28,8 @@ function AsyncSelect({
27
28
  if (loadOptions) {
28
29
  loadOptions(value, newOptions => {
29
30
  setOptions(newOptions);
31
+ }, {
32
+ rowData
30
33
  });
31
34
  }
32
35
  };
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
3
  import type { TableSelectProps } from "rc-master-ui/es/table-select";
4
+ import type { LoadOptionsArgs } from "../type";
4
5
  export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
5
- loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
6
7
  debounceTimeout?: number;
7
8
  defaultOptions?: OptionType[];
9
+ rowData?: any;
8
10
  }
9
- export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
11
+ export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -16,6 +16,7 @@ function AsyncTableSelect({
16
16
  debounceTimeout = 500,
17
17
  defaultOptions,
18
18
  columns,
19
+ rowData,
19
20
  ...props
20
21
  }) {
21
22
  const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
@@ -28,11 +29,13 @@ function AsyncTableSelect({
28
29
  if (loadOptions) {
29
30
  loadOptions(value, newOptions => {
30
31
  setOptions(newOptions);
32
+ }, {
33
+ rowData
31
34
  });
32
35
  }
33
36
  };
34
37
  return (0, _debounce.default)(fetchOptions, debounceTimeout);
35
- }, [loadOptions, debounceTimeout]);
38
+ }, [debounceTimeout, loadOptions, defaultOptions, rowData]);
36
39
  (0, _react.useEffect)(() => {
37
40
  setOptions(defaultOptions ?? []);
38
41
  }, [defaultOptions]);
@@ -6,4 +6,4 @@ export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType
6
6
  export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
7
7
  export declare const getValueCell: <T>(column: ColumnTable<T>, value: any, 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
- 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) => React.JSX.Element;
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;
@@ -19,9 +19,7 @@ var _number = _interopRequireDefault(require("../../number"));
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  // import {Typography} from "antd";
22
- const {
23
- RangePicker
24
- } = _rcMasterUi.DatePicker;
22
+ // const {RangePicker} = DatePicker
25
23
 
26
24
  // const { Text } = Typography;
27
25
 
@@ -138,11 +136,11 @@ const renderContent = (column, value, record, index, format) => {
138
136
  }) : column.template : content);
139
137
  };
140
138
  exports.renderContent = renderContent;
141
- const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t, format) => {
139
+ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t, format, dateRangeLocale) => {
142
140
  const cellFormat = column.format ? typeof column.format === 'function' ? column.format({}) : column.format : format;
143
141
  const type = (0, _utils.getTypeFilter)(column);
144
142
  const dateFormat = (0, _utils.getDatepickerFormat)(column?.typeFilter ?? column?.type, cellFormat) ?? 'DD/MM/YYYY';
145
- const dateRangeFormat = (0, _utils.getDatepickerFormat)(column?.type, cellFormat) ?? 'DD/MM/YYYY';
143
+ const dateRangeFormat = (0, _utils.convertFormat)((0, _utils.getDatepickerFormat)(column?.type, cellFormat) ?? 'DD/MM/YYYY');
146
144
  const find = dataSourceFilter?.find(it => it.key === column?.field);
147
145
  const options = find ? find.data : [];
148
146
  switch (type) {
@@ -189,35 +187,25 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
189
187
  }
190
188
  }))));
191
189
  case 'DateRange':
192
- const dateRangeValue = [selectedKeys[0] ? (0, _utils.convertDateToDayjs)(new Date(selectedKeys[0]), dateRangeFormat) : '', selectedKeys[1] ? (0, _utils.convertDateToDayjs)(new Date(selectedKeys[1]), dateRangeFormat) : ''];
190
+ // const dateRangeValue: any = [selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateRangeFormat) : '', selectedKeys[1] ? convertDateToDayjs(new Date(selectedKeys[1]), dateRangeFormat) : '']
191
+ const dateRangeValue = selectedKeys && selectedKeys.length > 0 ? [selectedKeys[0] ? new Date(selectedKeys[0]) : '', selectedKeys[1] ? new Date(selectedKeys[1]) : ''] : null;
193
192
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
194
193
  className: 'mb-1'
195
- }, /*#__PURE__*/_react.default.createElement(RangePicker, {
196
- format: {
197
- format: dateRangeFormat,
198
- type: 'mask'
199
- }
200
- // defaultValue={dateRangeValue}
201
- ,
202
- value: dateRangeValue,
203
- locale: buddhistLocale
204
- // placeholder={['Ngày bắt đầu', 'Ngày kết thúc']}
205
- ,
206
- popupStyle: {
207
- zIndex: 9999
194
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.CustomProvider, {
195
+ locale: dateRangeLocale
196
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.DateRangePicker
197
+ // placeholder={['Ngày bắt đầu', 'Ngày bắt đầu']}
198
+ , {
199
+ style: {
200
+ width: 300
208
201
  },
209
- onChange: (value, dateString) => {
210
- const newDateRangeValue = dateString[0] ? [dateString[0] ? (0, _moment.default)((0, _utils.convertDayjsToDate)(dateString[0], dateRangeFormat)).format() : '', dateString[1] ? (0, _moment.default)((0, _utils.convertDayjsToDate)(dateString[1], dateRangeFormat)).format() : ''] : '';
211
-
212
- // setSelectedKeys(newDateValue ? [newDateValue] : [])
202
+ format: dateRangeFormat,
203
+ value: dateRangeValue,
204
+ onChange: value => {
205
+ const newDateRangeValue = value ? [value[0] ? (0, _moment.default)(value[0]).format() : '', value[1] ? (0, _moment.default)(value[1]).format() : ''] : [];
213
206
  setSelectedKeys(newDateRangeValue);
214
- },
215
- style: {
216
- width: '100%'
217
207
  }
218
- // popupClassName={'adv-popup-container'}
219
- // getPopupContainer={() => menuRef.current}
220
- }))));
208
+ })))));
221
209
  case 'Week':
222
210
  const weekValue = !(0, _utils.isEmpty)(selectedKeys[0]) ? (0, _dayjs.default)(selectedKeys[0], dateFormat) : null;
223
211
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
@@ -36,7 +36,9 @@ export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
36
36
  monthFormat: string;
37
37
  yearFormat: string;
38
38
  };
39
+ export declare function convertFormat(formatStr: string): string;
39
40
  export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
41
+ export declare const getDateRangeFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
40
42
  export declare const customWeekStartEndFormat: (value: any, weekFormat: string) => string;
41
43
  export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
42
44
  export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
@@ -141,3 +143,4 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
141
143
  export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
142
144
  export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
143
145
  export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
146
+ export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
@@ -10,16 +10,20 @@ exports.addRowsUp = addRowsUp;
10
10
  exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
11
11
  exports.compareDate = compareDate;
12
12
  exports.compareDates = compareDates;
13
- exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = void 0;
13
+ exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = void 0;
14
+ exports.convertFormat = convertFormat;
15
+ exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = void 0;
14
16
  exports.filterDataByColumns4 = filterDataByColumns4;
15
17
  exports.findAllChildrenKeys = findAllChildrenKeys;
16
18
  exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
17
19
  exports.getBottomRowCells = getBottomRowCells;
18
20
  exports.getCellsByPosition = getCellsByPosition;
19
21
  exports.getCellsByPosition2 = getCellsByPosition2;
20
- exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
22
+ exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getDateRangeFormat = exports.getColumnsVisible = void 0;
21
23
  exports.getHiddenParentKeys = getHiddenParentKeys;
22
- exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
24
+ exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
25
+ exports.groupArrayByColumns = groupArrayByColumns;
26
+ exports.hideDraggingPoint = void 0;
23
27
  exports.invalidDate = invalidDate;
24
28
  exports.isArraysEqual = void 0;
25
29
  exports.isBottomMostInRanges = isBottomMostInRanges;
@@ -29,7 +33,8 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
29
33
  exports.isEqualSet = isEqualSet;
30
34
  exports.isRangeCell = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
31
35
  exports.isRightMostInRegion = isRightMostInRegion;
32
- exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderPasteClass = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
36
+ exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderPasteClass = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
37
+ exports.updateData = exports.updateColumnsByGroup = void 0;
33
38
  var _dayjs = _interopRequireDefault(require("dayjs"));
34
39
  var _moment = _interopRequireDefault(require("moment/moment"));
35
40
  var _uuid = require("uuid");
@@ -237,12 +242,57 @@ const getFormat = (colFormat, format) => {
237
242
  };
238
243
  };
239
244
  exports.getFormat = getFormat;
245
+ function convertFormat(formatStr) {
246
+ // return formatStr.split('').map((char, i) => {
247
+ // if (char === 'D' || char === 'd') {
248
+ // return 'd'; // ngày: lowercase
249
+ // }
250
+ // if (char === 'Y' || char === 'y') {
251
+ // return 'y'; // năm: lowercase
252
+ // }
253
+ // if (char === 'M' || char === 'm') {
254
+ // return char; // tháng: giữ nguyên
255
+ // }
256
+ // return char; // separator
257
+ // }).join('');
258
+
259
+ return formatStr.split('').map(char => {
260
+ if (char === 'D' || char === 'd') return 'd';
261
+ if (char === 'Y' || char === 'y') return 'y';
262
+ if ('Hhmsa'.includes(char)) return char; // giờ, phút, giây, am/pm
263
+ if (char === 'M' || char === 'm') return char; // tháng: giữ nguyên
264
+ return char; // dấu phân cách
265
+ }).join('');
266
+ }
240
267
  const getDatepickerFormat = (type, format) => {
241
268
  const typeFormat = type ? type.toLowerCase() : '';
242
269
  switch (typeFormat) {
243
270
  case "date":
244
271
  case "daterange":
245
- return format?.dateFormat ?? 'DD/MM/YYYY';
272
+ return format?.dateFormat ?? 'dd/MM/YYYY';
273
+ case "datetime":
274
+ return format?.datetimeFormat ?? 'dd/MM/YYYY HH:mm';
275
+ case "week":
276
+ return format?.weekFormat ?? 'dd/MM';
277
+ case "month":
278
+ return format?.monthFormat ?? 'MM/YYYY';
279
+ case "quarter":
280
+ return format?.dateFormat ?? 'dd/MM/YYYY';
281
+ case "year":
282
+ return format?.yearFormat ?? 'YYYY';
283
+ case "time":
284
+ return format?.timeFormat ?? 'HH:mm';
285
+ default:
286
+ return 'dd/MM/YYYY';
287
+ }
288
+ };
289
+ exports.getDatepickerFormat = getDatepickerFormat;
290
+ const getDateRangeFormat = (type, format) => {
291
+ const typeFormat = type ? type.toLowerCase() : '';
292
+ switch (typeFormat) {
293
+ case "date":
294
+ case "daterange":
295
+ return convertFormat(format?.dateFormat ?? 'DD/MM/YYYY');
246
296
  case "datetime":
247
297
  return format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm';
248
298
  case "week":
@@ -259,7 +309,7 @@ const getDatepickerFormat = (type, format) => {
259
309
  return 'DD/MM/YYYY';
260
310
  }
261
311
  };
262
- exports.getDatepickerFormat = getDatepickerFormat;
312
+ exports.getDateRangeFormat = getDateRangeFormat;
263
313
  const customWeekStartEndFormat = (value, weekFormat) => {
264
314
  return `${(0, _dayjs.default)(value).startOf('week').format(weekFormat)} ~ ${(0, _dayjs.default)(value).endOf('week').format(weekFormat)}`;
265
315
  };
@@ -2101,4 +2151,43 @@ const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
2101
2151
  const key = `${rowIndex}-${colIndex}`;
2102
2152
  return selectedCells.has(key);
2103
2153
  };
2104
- exports.isSelectedCell = isSelectedCell;
2154
+ exports.isSelectedCell = isSelectedCell;
2155
+ function groupArrayByColumns(arr, columns) {
2156
+ const result = [];
2157
+ if (columns) {
2158
+ arr.forEach(item => {
2159
+ let currentLevel = result;
2160
+ columns.forEach((column, index) => {
2161
+ const value = item[column];
2162
+ const existingItem = currentLevel.find(i => i[column] === value);
2163
+ if (existingItem) {
2164
+ currentLevel = existingItem.children;
2165
+ } else {
2166
+ // const newItem = {[column]: value, field: column, rowId: !isEmpty(value) ? (value) : newGuid(), parentId: !isEmpty(item[columns[index - 1]]) ? (item[columns[index - 1]]) : null, indent: index, children: [] }
2167
+ const newItem = {
2168
+ [column]: value,
2169
+ field: column,
2170
+ rowId: newGuid(),
2171
+ // rowId: item[column],
2172
+ parentId: !isEmpty(item[columns[index - 1]]) ? item[columns[index - 1]] : null,
2173
+ // parentId: item.rowId[index - 1],
2174
+ // indent: index,
2175
+ children: []
2176
+ };
2177
+ currentLevel.push(newItem);
2178
+ currentLevel = newItem.children;
2179
+ }
2180
+ });
2181
+ currentLevel.push({
2182
+ ...item,
2183
+ rowId: item.id ?? item.rowId,
2184
+ parentId: !isEmpty(columns[columns.length - 1]) ? item[columns[columns.length - 1]] : null,
2185
+ // parentId: item.rowId[columns.length - 1],
2186
+ indent: columns.length
2187
+ });
2188
+ });
2189
+ return result;
2190
+ } else {
2191
+ return arr;
2192
+ }
2193
+ }
@@ -1341,3 +1341,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
1341
1341
  display: none;
1342
1342
  }
1343
1343
  }
1344
+
1345
+ .rs-picker-popup {
1346
+ z-index: 1660;
1347
+ }