@tap-payments/os-micro-frontend-shared 0.1.431 → 0.1.433

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.
@@ -47,7 +47,7 @@ export const ViewWrapper = styled(Box)(({ theme }) => ({
47
47
  },
48
48
  '& > *:last-child': {
49
49
  marginRight: 0,
50
- paddingRight: 0,
50
+ paddingRight: '6px',
51
51
  },
52
52
  }));
53
53
  export const ListStyled = styled(Box)(({ theme }) => ({
@@ -80,23 +80,32 @@ export const convertTemplateToColumnsView = (template, tableMode) => {
80
80
  if (layoutForMode && layoutForMode.columns && layoutForMode.columns.length > 0) {
81
81
  const templateColumnsView = layoutForMode.columns
82
82
  .map((templateCol) => {
83
- var _a, _b;
84
- return ({
83
+ var _a, _b, _c, _d;
84
+ const hasFields = !!((_a = templateCol.fields) === null || _a === void 0 ? void 0 : _a.length);
85
+ const anyFieldDefault = hasFields && templateCol.fields.some((f) => { var _a; return (_a = f.default) !== null && _a !== void 0 ? _a : false; });
86
+ const parentSelected = ((_b = templateCol.default) !== null && _b !== void 0 ? _b : false) || anyFieldDefault;
87
+ return {
88
+ code: templateCol.code,
85
89
  name: templateCol.name && templateCol.name.length > 0 ? templateCol.name : [{ text: templateCol.code, lang: 'en' }],
86
- selected: (_a = templateCol.default) !== null && _a !== void 0 ? _a : false,
90
+ selected: parentSelected,
87
91
  sort_order: getColumnOrder(templateCol),
88
- fields: ((_b = templateCol.fields) === null || _b === void 0 ? void 0 : _b.map((field) => ({
89
- code: field.code,
90
- type: 'single',
91
- parameters: [{ parameter: field.code, code: field.code }],
92
- }))) || [
92
+ fields: ((_c = templateCol.fields) === null || _c === void 0 ? void 0 : _c.map((field) => {
93
+ var _a;
94
+ return ({
95
+ code: field.code.toLowerCase(),
96
+ type: 'single',
97
+ parameters: [{ parameter: field.code.toLowerCase(), code: field.code.toLowerCase(), selected: (_a = field.default) !== null && _a !== void 0 ? _a : false }],
98
+ });
99
+ })) || [
93
100
  {
94
- code: templateCol.code,
101
+ code: templateCol.code.toLowerCase(),
95
102
  type: 'single',
96
- parameters: [{ parameter: templateCol.code, code: templateCol.code }],
103
+ parameters: [
104
+ { parameter: templateCol.code.toLowerCase(), code: templateCol.code.toLowerCase(), selected: (_d = templateCol.default) !== null && _d !== void 0 ? _d : false },
105
+ ],
97
106
  },
98
107
  ],
99
- });
108
+ };
100
109
  })
101
110
  .sort((a, b) => { var _a, _b; return ((_a = a.sort_order) !== null && _a !== void 0 ? _a : 999) - ((_b = b.sort_order) !== null && _b !== void 0 ? _b : 999); });
102
111
  return templateColumnsView;
@@ -120,6 +129,7 @@ export const convertTemplateToColumnsView = (template, tableMode) => {
120
129
  : [{ parameter: columnCode, code: columnCode }];
121
130
  const fieldType = selectedMenuItems.length > 1 ? 'combined' : 'single';
122
131
  const result = {
132
+ code: submenuItem.name,
123
133
  name: [{ text: submenuItem.label || submenuItem.name, lang: 'en' }],
124
134
  selected: submenuItem.selected,
125
135
  sort_order: index + 1,
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
2
2
  import { TextAndLang } from './common';
3
3
  import { SxProps, Theme } from '@mui/material/styles';
4
4
  export interface ColumnsView {
5
+ code?: string;
5
6
  name: TextAndLang[];
6
7
  sorting?: 'ascending' | 'descending';
7
8
  sort_order: number;
@@ -30,6 +31,7 @@ export interface ColumnsView {
30
31
  }>;
31
32
  }
32
33
  export interface ColumnViewProps {
34
+ code?: string;
33
35
  label?: string | null | ReactNode;
34
36
  name: string;
35
37
  icon?: ReactNode;
@@ -3,11 +3,17 @@ import { getNameText } from './index.js';
3
3
  export function filterShownColumns(columns, tableViews) {
4
4
  return columns.filter((column) => {
5
5
  var _a, _b, _c, _d, _e;
6
- const selectedColumn = tableViews.find((view) => { var _a; return ((_a = view.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (column === null || column === void 0 ? void 0 : column.id) && view.selected; });
7
- const isColumnWithMenuItems = !!column.tableViewId && (((_a = selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.menuItems) === null || _a === void 0 ? void 0 : _a.length) || 0) > 1;
8
- const isMenuItemSelected = (_c = (_b = selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.menuItems) === null || _b === void 0 ? void 0 : _b.find((item) => item.name === column.tableViewId)) === null || _c === void 0 ? void 0 : _c.selected;
6
+ const columnId = (_a = column === null || column === void 0 ? void 0 : column.id) === null || _a === void 0 ? void 0 : _a.toString();
7
+ const selectedColumn = tableViews.find((view) => {
8
+ var _a, _b;
9
+ const codeMatch = ((_a = view.code) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (columnId === null || columnId === void 0 ? void 0 : columnId.toLowerCase());
10
+ const nameMatch = ((_b = view.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === (columnId === null || columnId === void 0 ? void 0 : columnId.toLowerCase());
11
+ return (codeMatch || nameMatch) && view.selected;
12
+ });
13
+ const isColumnWithMenuItems = !!column.tableViewId && (((_b = selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.menuItems) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0;
14
+ const isMenuItemSelected = (_d = (_c = selectedColumn === null || selectedColumn === void 0 ? void 0 : selectedColumn.menuItems) === null || _c === void 0 ? void 0 : _c.find((item) => { var _a, _b, _c; return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_c = (_b = column.tableViewId) === null || _b === void 0 ? void 0 : _b.toString()) === null || _c === void 0 ? void 0 : _c.toLowerCase()); })) === null || _d === void 0 ? void 0 : _d.selected;
9
15
  const isColumnSelected = !!selectedColumn && (isMenuItemSelected || !isColumnWithMenuItems);
10
- const isBasicColumn = ['actions', 'action_icon'].includes((_e = (_d = column.id) === null || _d === void 0 ? void 0 : _d.toString()) === null || _e === void 0 ? void 0 : _e.toLowerCase());
16
+ const isBasicColumn = ['actions', 'action_icon'].includes((_e = columnId === null || columnId === void 0 ? void 0 : columnId.toLowerCase()) !== null && _e !== void 0 ? _e : '');
11
17
  if (isColumnSelected || isBasicColumn) {
12
18
  return true;
13
19
  }
@@ -16,13 +22,19 @@ export function filterShownColumns(columns, tableViews) {
16
22
  }
17
23
  export function isParameterSelected(columns, columnId, parameter) {
18
24
  var _a, _b, _c;
19
- return (((_c = (_b = (_a = columns === null || columns === void 0 ? void 0 : columns.find((view) => { var _a; return ((_a = view.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === columnId.toLowerCase(); })) === null || _a === void 0 ? void 0 : _a.menuItems) === null || _b === void 0 ? void 0 : _b.find((item) => { var _a; return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === parameter.toLowerCase() && item.selected; })) === null || _c === void 0 ? void 0 : _c.selected) || false);
25
+ return (((_c = (_b = (_a = columns === null || columns === void 0 ? void 0 : columns.find((view) => {
26
+ var _a, _b;
27
+ const codeMatch = ((_a = view.code) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === columnId.toLowerCase();
28
+ const nameMatch = ((_b = view.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === columnId.toLowerCase();
29
+ return codeMatch || nameMatch;
30
+ })) === null || _a === void 0 ? void 0 : _a.menuItems) === null || _b === void 0 ? void 0 : _b.find((item) => { var _a; return ((_a = item.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === parameter.toLowerCase() && item.selected; })) === null || _c === void 0 ? void 0 : _c.selected) || false);
20
31
  }
21
32
  export function mapDataToViews(columnData, language) {
22
33
  var _a;
23
34
  return (((_a = columnData === null || columnData === void 0 ? void 0 : columnData.filter((c) => { var _a, _b; return !!((_b = (_a = c.name) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text); })) === null || _a === void 0 ? void 0 : _a.map((column) => {
24
35
  var _a;
25
36
  return ({
37
+ code: column.code,
26
38
  label: getNameText(column.name, language),
27
39
  name: getNameText(column.name, language) || '',
28
40
  selected: (column === null || column === void 0 ? void 0 : column.selected) !== false,
@@ -33,7 +45,7 @@ export function mapDataToViews(columnData, language) {
33
45
  return {
34
46
  label: startCase(param.code),
35
47
  name: `${param.code}`,
36
- selected: (column === null || column === void 0 ? void 0 : column.selected) !== false && (param === null || param === void 0 ? void 0 : param.selected) !== false,
48
+ selected: (param === null || param === void 0 ? void 0 : param.selected) !== false,
37
49
  };
38
50
  });
39
51
  })
@@ -44,12 +56,7 @@ export function mapDataToViews(columnData, language) {
44
56
  export function mapViewsToData(columns) {
45
57
  return columns.map((column) => {
46
58
  var _a;
47
- return {
48
- name: [{ text: column.name, lang: 'en' }],
49
- selected: column.selected,
50
- sort_order: 1,
51
- sorting: 'descending',
52
- fields: ((_a = column.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => {
59
+ return Object.assign(Object.assign({}, (column.code ? { code: column.code } : {})), { name: [{ text: column.name, lang: 'en' }], selected: column.selected, sort_order: 1, sorting: 'descending', fields: ((_a = column.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => {
53
60
  return {
54
61
  code: item.name,
55
62
  type: 'single',
@@ -61,8 +68,7 @@ export function mapViewsToData(columns) {
61
68
  },
62
69
  ],
63
70
  };
64
- })) || [],
65
- };
71
+ })) || [] });
66
72
  });
67
73
  }
68
74
  export const updateColumnSelection = ({ columnsViewData, columnsName, selected, }) => {
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.431",
4
+ "version": "0.1.433",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",