@tap-payments/os-micro-frontend-shared 0.1.442 → 0.1.443

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.
@@ -16,9 +16,5 @@ export default function FiltersRow({ date, calendarMode, onDateChange, onCalenda
16
16
  onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange([startDate, endDate]);
17
17
  }
18
18
  }, mode: calendarMode, onCalendarModeSwitch: onCalendarModeSwitch, maxDateRange: maxDateRange, groupBy: calendarGroupBy, onCalendarGroupChange: onCalendarGroupChange, browserTimezone: browserTimezone, defaultCountryTimezone: defaultCountryTimezone, timezone: timezone, onChangeTimezone: onChangeTimezone, timezoneCountriesCodes: timezoneCountriesCodes })), isReportsButtonVisible && tableReportsComponent, onToggleTextButtonClick && isAcceptance && tableModeButton] })), onToggleViewButtonClick && (_jsx(StyledButton, { children: _jsx(Icon, { src: viewIcon, alt: "view", sx: { width: 14, height: 14 } }) })), onViewChange &&
19
- (customViews ? (_jsx(ViewsMenu
20
- // @todo to be moved to grouping
21
- , Object.assign({
22
- // @todo to be moved to grouping
23
- onViewChange: onViewChange, tableMode: tableMode, lang: lang }, customViews))) : (_jsx(TableView, { onViewChange: onViewChange, setIsViewVisible: setIsViewVisible, tableViews: tableViews, setTableViews: setTableViews, resetTableViews: resetTableViews }))), rightActions && !isViewVisible && rightActions] }));
19
+ (customViews ? (_jsx(ViewsMenu, Object.assign({ onViewChange: onViewChange, tableMode: tableMode, lang: lang }, customViews))) : (_jsx(TableView, { onViewChange: onViewChange, setIsViewVisible: setIsViewVisible, tableViews: tableViews, setTableViews: setTableViews, resetTableViews: resetTableViews }))), rightActions && !isViewVisible && rightActions] }));
24
20
  }
@@ -4,6 +4,6 @@ export type { ColumnModifier, UseTableViewsProps, CustomViewsConfigResult } from
4
4
  export declare function useCustomTableViews({ templates, setTemplates, createTemplate, updateTemplate, deleteTemplate, tableMode, lang, columnModifiers, }: UseTableViewsProps): {
5
5
  customViews: CustomViewsConfigResult;
6
6
  onViewChange: (view?: ViewMenuItem) => void;
7
- columnsViewData: ColumnsView[];
7
+ columnsView: ColumnsView[];
8
8
  selectedViewId: string | undefined;
9
9
  };
@@ -73,7 +73,7 @@ export function useCustomTableViews({ templates, setTemplates, createTemplate, u
73
73
  const matchingTemplate = templates.find((t) => t.id === view.id);
74
74
  setSelectedTemplateId((_a = matchingTemplate === null || matchingTemplate === void 0 ? void 0 : matchingTemplate.id) !== null && _a !== void 0 ? _a : defaultTemplate.id);
75
75
  }, [templates, defaultTemplate]);
76
- const columnsViewData = useMemo(() => {
76
+ const columnsView = useMemo(() => {
77
77
  var _a;
78
78
  const selectedTemplate = (_a = templates.find((t) => (selectedTemplateId ? t.id === selectedTemplateId : false))) !== null && _a !== void 0 ? _a : defaultTemplate;
79
79
  let templateColumnsView = [];
@@ -87,8 +87,8 @@ export function useCustomTableViews({ templates, setTemplates, createTemplate, u
87
87
  let result = templateColumnsView;
88
88
  for (const mod of columnModifiers) {
89
89
  result = updateColumnSelection({
90
- columnsViewData: result,
91
- columnsName: mod.columnsName,
90
+ columnsView: result,
91
+ columnsIds: mod.columnsIds,
92
92
  selected: mod.selected,
93
93
  });
94
94
  }
@@ -99,7 +99,7 @@ export function useCustomTableViews({ templates, setTemplates, createTemplate, u
99
99
  return {
100
100
  customViews,
101
101
  onViewChange,
102
- columnsViewData,
102
+ columnsView,
103
103
  selectedViewId: selectedTemplateId,
104
104
  };
105
105
  }
@@ -181,7 +181,7 @@ export interface UseViewsManagerProps {
181
181
  lang?: string;
182
182
  }
183
183
  export interface ColumnModifier {
184
- columnsName: string[];
184
+ columnsIds: string[];
185
185
  selected: boolean;
186
186
  }
187
187
  export interface UseTableViewsProps {
@@ -3,8 +3,8 @@ export declare function filterShownColumns(columns: IColumnProps[], tableViews:
3
3
  export declare function isParameterSelected(columns: ColumnViewProps[], columnId: string, parameter: string): boolean;
4
4
  export declare function mapDataToViews(columnData?: ColumnsView[], language?: string): ColumnViewProps[];
5
5
  export declare function mapViewsToData(columns: ColumnViewProps[]): ColumnsView[];
6
- export declare const updateColumnSelection: ({ columnsViewData, columnsName, selected, }: {
7
- columnsViewData: ColumnsView[];
8
- columnsName: string[];
6
+ export declare const updateColumnSelection: ({ columnsView, columnsIds, selected, }: {
7
+ columnsView: ColumnsView[];
8
+ columnsIds: string[];
9
9
  selected: boolean;
10
10
  }) => ColumnsView[];
@@ -70,12 +70,14 @@ export function mapViewsToData(columns) {
70
70
  })) || [] });
71
71
  });
72
72
  }
73
- export const updateColumnSelection = ({ columnsViewData, columnsName, selected, }) => {
74
- return columnsViewData.map((column) => {
73
+ export const updateColumnSelection = ({ columnsView, columnsIds, selected, }) => {
74
+ const ids = new Set(columnsIds.map((id) => id === null || id === void 0 ? void 0 : id.toLowerCase()));
75
+ const withSelected = (col) => {
75
76
  var _a;
76
- if (columnsName.includes((_a = column.name[0]) === null || _a === void 0 ? void 0 : _a.text)) {
77
- return Object.assign(Object.assign({}, column), { selected });
78
- }
79
- return column;
80
- });
77
+ return (Object.assign(Object.assign({}, col), { selected, fields: (_a = col.fields) === null || _a === void 0 ? void 0 : _a.map((field) => {
78
+ var _a, _b;
79
+ return (Object.assign(Object.assign({}, field), { parameters: (_b = (_a = field.parameters) === null || _a === void 0 ? void 0 : _a.map((p) => (Object.assign(Object.assign({}, p), { selected })))) !== null && _b !== void 0 ? _b : [] }));
80
+ }) }));
81
+ };
82
+ return columnsView.map((column) => { var _a, _b; return (ids.has((_b = (_a = column.code) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '') ? withSelected(column) : column); });
81
83
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.442",
4
+ "version": "0.1.443",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",