@tap-payments/os-micro-frontend-shared 0.1.376-test.1-test.2 → 0.1.376-test.10
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.
- package/build/components/TableCells/CustomCells/BalanceCell/BalanceCell.js +2 -13
- package/build/components/TableHeader/FiltersRow.d.ts +1 -1
- package/build/components/TableHeader/FiltersRow.js +2 -4
- package/build/components/TableHeader/TableHeader.d.ts +1 -1
- package/build/components/TableHeader/TableHeader.js +2 -2
- package/build/components/TableHeader/TableView/CustomViews.js +1 -1
- package/build/components/TableHeader/TableView/TableView.js +1 -0
- package/build/components/TableHeader/TableView/hooks/index.d.ts +0 -6
- package/build/components/TableHeader/TableView/hooks/index.js +0 -6
- package/build/components/TableHeader/TableView/index.d.ts +3 -12
- package/build/components/TableHeader/TableView/index.js +3 -13
- package/build/components/TableHeader/index.d.ts +0 -1
- package/build/components/TableHeader/type.d.ts +1 -15
- package/build/constants/assets.d.ts +0 -1
- package/build/constants/assets.js +0 -1
- package/package.json +2 -3
- package/build/components/TableHeader/TableView/CreateViewDialog.d.ts +0 -3
- package/build/components/TableHeader/TableView/CreateViewDialog.js +0 -91
- package/build/components/TableHeader/TableView/ViewSelector.d.ts +0 -5
- package/build/components/TableHeader/TableView/ViewSelector.js +0 -81
- package/build/components/TableHeader/TableView/ViewsDropdown.d.ts +0 -5
- package/build/components/TableHeader/TableView/ViewsDropdown.js +0 -198
- package/build/components/TableHeader/TableView/components/ColumnList.d.ts +0 -3
- package/build/components/TableHeader/TableView/components/ColumnList.js +0 -70
- package/build/components/TableHeader/TableView/components/ViewsSubmenu.d.ts +0 -3
- package/build/components/TableHeader/TableView/components/ViewsSubmenu.js +0 -71
- package/build/components/TableHeader/TableView/components/index.d.ts +0 -2
- package/build/components/TableHeader/TableView/components/index.js +0 -2
- package/build/components/TableHeader/TableView/constants.d.ts +0 -10
- package/build/components/TableHeader/TableView/constants.js +0 -10
- package/build/components/TableHeader/TableView/data.d.ts +0 -5
- package/build/components/TableHeader/TableView/data.js +0 -48
- package/build/components/TableHeader/TableView/hooks/useCreateViewDialog.d.ts +0 -22
- package/build/components/TableHeader/TableView/hooks/useCreateViewDialog.js +0 -86
- package/build/components/TableHeader/TableView/hooks/useDialogPosition.d.ts +0 -8
- package/build/components/TableHeader/TableView/hooks/useDialogPosition.js +0 -16
- package/build/components/TableHeader/TableView/hooks/useNestedSubmenu.d.ts +0 -7
- package/build/components/TableHeader/TableView/hooks/useNestedSubmenu.js +0 -34
- package/build/components/TableHeader/TableView/hooks/useOriginalColumns.d.ts +0 -6
- package/build/components/TableHeader/TableView/hooks/useOriginalColumns.js +0 -18
- package/build/components/TableHeader/TableView/hooks/useSubmenuHover.d.ts +0 -8
- package/build/components/TableHeader/TableView/hooks/useSubmenuHover.js +0 -43
- package/build/components/TableHeader/TableView/hooks/useViewSelector.d.ts +0 -50
- package/build/components/TableHeader/TableView/hooks/useViewSelector.js +0 -239
- package/build/components/TableHeader/TableView/hooks/useViewsManager.d.ts +0 -20
- package/build/components/TableHeader/TableView/hooks/useViewsManager.js +0 -96
- package/build/components/TableHeader/TableView/styles.d.ts +0 -127
- package/build/components/TableHeader/TableView/styles.js +0 -426
- package/build/components/TableHeader/TableView/types.d.ts +0 -183
- package/build/components/TableHeader/TableView/types.js +0 -1
- package/build/components/TableHeader/TableView/utils.d.ts +0 -121
- package/build/components/TableHeader/TableView/utils.js +0 -463
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { ColumnViewProps, TableMode } from '../../../types/index.js';
|
|
2
|
-
import type { LayoutSection, ViewMenuItem, ColumnCheckState } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Transform API layout response to internal ColumnViewProps format
|
|
5
|
-
*/
|
|
6
|
-
export declare const transformLayoutToColumns: (layout: LayoutSection[], lang?: string) => ColumnViewProps[];
|
|
7
|
-
export declare const getColumnsByMode: (mode: TableMode, layoutData?: LayoutSection[]) => ColumnViewProps[];
|
|
8
|
-
export declare const isDateColumn: (name: string) => boolean;
|
|
9
|
-
export declare const getColumnCheckState: (column: ColumnViewProps) => ColumnCheckState;
|
|
10
|
-
export declare const createCustomViewMenuItem: (name: string, selectedColumns: ColumnViewProps[], isDefault?: boolean) => ViewMenuItem;
|
|
11
|
-
/**
|
|
12
|
-
* Extract layout data from templates (combine all sections from all templates)
|
|
13
|
-
* This is used for the built-in "Default" view's layoutData prop
|
|
14
|
-
*/
|
|
15
|
-
export declare const getLayoutDataFromTemplates: (templates: Array<{
|
|
16
|
-
layout: LayoutSection[];
|
|
17
|
-
}>) => LayoutSection[];
|
|
18
|
-
/**
|
|
19
|
-
* Set a view as default and ensure only one view is default at a time
|
|
20
|
-
*/
|
|
21
|
-
export declare const setViewAsDefault: (views: ViewMenuItem[], viewId: string) => ViewMenuItem[];
|
|
22
|
-
/**
|
|
23
|
-
* Transform API templates response to ViewMenuItem array
|
|
24
|
-
* Filters templates by mode and only shows the section matching the current mode
|
|
25
|
-
* Separates default templates (to be merged into built-in Default view) from custom views
|
|
26
|
-
*/
|
|
27
|
-
export declare const transformTemplatesToViewMenuItems: (templates: Array<{
|
|
28
|
-
id: string | {
|
|
29
|
-
timestamp: number;
|
|
30
|
-
date: string;
|
|
31
|
-
};
|
|
32
|
-
name: string;
|
|
33
|
-
default: boolean;
|
|
34
|
-
layout: LayoutSection[];
|
|
35
|
-
templateId: string;
|
|
36
|
-
}>, mode?: TableMode, lang?: string) => {
|
|
37
|
-
customViews: ViewMenuItem[];
|
|
38
|
-
defaultTemplateColumns?: ColumnViewProps[] | undefined;
|
|
39
|
-
defaultTemplate?: ViewMenuItem | undefined;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Convert ColumnViewProps back to LayoutSection format for API requests
|
|
43
|
-
*/
|
|
44
|
-
export declare const convertColumnsToLayoutSection: (columns: ColumnViewProps[], mode: TableMode, lang?: string) => LayoutSection;
|
|
45
|
-
/**
|
|
46
|
-
* Initialize columns for editing mode
|
|
47
|
-
*/
|
|
48
|
-
export declare const initializeEditingColumns: (editingColumns: ColumnViewProps[], availableColumns: ColumnViewProps[]) => ColumnViewProps[];
|
|
49
|
-
/**
|
|
50
|
-
* Initialize columns for create mode (all unchecked except date)
|
|
51
|
-
*/
|
|
52
|
-
export declare const initializeCreateColumns: (availableColumns: ColumnViewProps[]) => ColumnViewProps[];
|
|
53
|
-
/**
|
|
54
|
-
* Initialize columns for create mode with current tableViews state (preserves checked/unchecked values)
|
|
55
|
-
*/
|
|
56
|
-
export declare const initializeCreateColumnsWithCurrentState: (availableColumns: ColumnViewProps[], currentTableViews: ColumnViewProps[]) => ColumnViewProps[];
|
|
57
|
-
/**
|
|
58
|
-
* Reset columns to their default selection state
|
|
59
|
-
*/
|
|
60
|
-
export declare const resetColumnsToDefault: (columns: ColumnViewProps[]) => ColumnViewProps[];
|
|
61
|
-
/**
|
|
62
|
-
* Toggle a column's selection (including all children if present)
|
|
63
|
-
*/
|
|
64
|
-
export declare const toggleColumn: (columns: ColumnViewProps[], columnName: string) => ColumnViewProps[];
|
|
65
|
-
/**
|
|
66
|
-
* Toggle a sub-item's selection and update parent state
|
|
67
|
-
*/
|
|
68
|
-
export declare const toggleSubItem: (columns: ColumnViewProps[], columnName: string, subItemName: string) => ColumnViewProps[];
|
|
69
|
-
/**
|
|
70
|
-
* Select or deselect all columns (except date)
|
|
71
|
-
*/
|
|
72
|
-
export declare const toggleAllColumns: (columns: ColumnViewProps[], selectAll: boolean) => ColumnViewProps[];
|
|
73
|
-
/**
|
|
74
|
-
* Check if all non-date columns are selected
|
|
75
|
-
*/
|
|
76
|
-
export declare const areAllColumnsSelected: (columns: ColumnViewProps[]) => boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Check if some (but not all) non-date columns are selected
|
|
79
|
-
*/
|
|
80
|
-
export declare const areSomeColumnsSelected: (columns: ColumnViewProps[], allSelected: boolean) => boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Validate template name
|
|
83
|
-
*/
|
|
84
|
-
export declare const isValidTemplateName: (name: string, maxLength: number) => boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Deep clone columns array with all nested properties
|
|
87
|
-
*/
|
|
88
|
-
export declare const deepCloneColumns: (columns: ColumnViewProps[]) => ColumnViewProps[];
|
|
89
|
-
/**
|
|
90
|
-
* Toggle a single column's selection state
|
|
91
|
-
*/
|
|
92
|
-
export declare const toggleSingleColumn: (columns: ColumnViewProps[], columnName: string) => ColumnViewProps[];
|
|
93
|
-
/**
|
|
94
|
-
* Get submenu items for a view menu item
|
|
95
|
-
* Always includes the date column at the beginning
|
|
96
|
-
*/
|
|
97
|
-
export declare const getSubmenuItems: (item: ViewMenuItem, defaultColumns: ColumnViewProps[]) => ColumnViewProps[];
|
|
98
|
-
/**
|
|
99
|
-
* Check if a view menu item has submenu
|
|
100
|
-
*/
|
|
101
|
-
export declare const hasSubmenu: (item: ViewMenuItem, defaultColumns: ColumnViewProps[]) => boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Check if all columns in current state are selected
|
|
104
|
-
*/
|
|
105
|
-
export declare const areAllCurrentColumnsSelected: (columns: ColumnViewProps[]) => boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Check if some (but not all) columns in current state are selected
|
|
108
|
-
*/
|
|
109
|
-
export declare const areSomeCurrentColumnsSelected: (columns: ColumnViewProps[], allSelected: boolean) => boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Toggle all columns selection (select all or unselect all)
|
|
112
|
-
*/
|
|
113
|
-
export declare const toggleAllCurrentColumns: (columns: ColumnViewProps[], shouldSelect: boolean) => ColumnViewProps[];
|
|
114
|
-
/**
|
|
115
|
-
* Normalize columns by converting undefined selected values to false for consistent comparison
|
|
116
|
-
*/
|
|
117
|
-
export declare const normalizeColumnsSelected: (columns: ColumnViewProps[]) => ColumnViewProps[];
|
|
118
|
-
/**
|
|
119
|
-
* Compare two columns arrays to check if they are equal (same order, same selection states)
|
|
120
|
-
*/
|
|
121
|
-
export declare const areColumnsEqual: (cols1: ColumnViewProps[], cols2: ColumnViewProps[]) => boolean;
|
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
import { DATE_COLUMN_CONFIG } from './constants';
|
|
2
|
-
// Note: advancedColumns and sheetColumns are only used in demo - not imported here to avoid default data
|
|
3
|
-
/**
|
|
4
|
-
* Transform API layout response to internal ColumnViewProps format
|
|
5
|
-
*/
|
|
6
|
-
export const transformLayoutToColumns = (layout, lang = 'en') => {
|
|
7
|
-
const columns = [];
|
|
8
|
-
layout.forEach((section) => {
|
|
9
|
-
section.columns.forEach((col) => {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
const label = ((_a = col.name.find((n) => n.lang === lang)) === null || _a === void 0 ? void 0 : _a.text) || ((_b = col.name[0]) === null || _b === void 0 ? void 0 : _b.text) || col.code;
|
|
12
|
-
const menuItems = ((_c = col.fields) === null || _c === void 0 ? void 0 : _c.length)
|
|
13
|
-
? col.fields.map((field) => {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
return ({
|
|
16
|
-
name: field.code,
|
|
17
|
-
label: ((_a = field.name.find((n) => n.lang === lang || n.lang === '')) === null || _a === void 0 ? void 0 : _a.text) || field.code,
|
|
18
|
-
selected: (_b = field.default) !== null && _b !== void 0 ? _b : false,
|
|
19
|
-
});
|
|
20
|
-
})
|
|
21
|
-
: undefined;
|
|
22
|
-
columns.push({
|
|
23
|
-
name: col.code,
|
|
24
|
-
label,
|
|
25
|
-
selected: (_d = col.default) !== null && _d !== void 0 ? _d : false,
|
|
26
|
-
menuItems: (menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) ? menuItems : undefined,
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return columns;
|
|
31
|
-
};
|
|
32
|
-
export const getColumnsByMode = (mode, layoutData) => {
|
|
33
|
-
if (layoutData && layoutData.length > 0) {
|
|
34
|
-
// Map TableMode to layout section code: 'default' → 'Advanced', 'sheet' → 'Sheet'
|
|
35
|
-
const sectionCode = mode === 'sheet' ? 'sheet' : 'advanced';
|
|
36
|
-
const section = layoutData.find((s) => s.code.toLowerCase() === sectionCode);
|
|
37
|
-
if (section) {
|
|
38
|
-
return transformLayoutToColumns([section]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Return empty array - all data should come from API
|
|
42
|
-
return [];
|
|
43
|
-
};
|
|
44
|
-
export const isDateColumn = (name) => {
|
|
45
|
-
return name.toLowerCase() === 'date';
|
|
46
|
-
};
|
|
47
|
-
export const getColumnCheckState = (column) => {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
if (!((_a = column.menuItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
50
|
-
return { checked: (_b = column.selected) !== null && _b !== void 0 ? _b : false, indeterminate: false };
|
|
51
|
-
}
|
|
52
|
-
const selectedCount = column.menuItems.filter((item) => item.selected).length;
|
|
53
|
-
return {
|
|
54
|
-
checked: selectedCount > 0,
|
|
55
|
-
indeterminate: selectedCount > 0 && selectedCount < column.menuItems.length,
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export const createCustomViewMenuItem = (name, selectedColumns, isDefault = false) => ({
|
|
59
|
-
label: name,
|
|
60
|
-
id: `custom_${Date.now()}`,
|
|
61
|
-
columns: selectedColumns.map((col) => col.name),
|
|
62
|
-
submenu: selectedColumns,
|
|
63
|
-
isCustom: true,
|
|
64
|
-
default: isDefault,
|
|
65
|
-
});
|
|
66
|
-
/**
|
|
67
|
-
* Extract layout data from templates (combine all sections from all templates)
|
|
68
|
-
* This is used for the built-in "Default" view's layoutData prop
|
|
69
|
-
*/
|
|
70
|
-
export const getLayoutDataFromTemplates = (templates) => {
|
|
71
|
-
const sectionsMap = new Map();
|
|
72
|
-
templates.forEach((template) => {
|
|
73
|
-
template.layout.forEach((section) => {
|
|
74
|
-
const existingSection = sectionsMap.get(section.code);
|
|
75
|
-
if (existingSection) {
|
|
76
|
-
// Merge columns, avoiding duplicates
|
|
77
|
-
const existingCodes = new Set(existingSection.columns.map((col) => col.code));
|
|
78
|
-
section.columns.forEach((col) => {
|
|
79
|
-
if (!existingCodes.has(col.code)) {
|
|
80
|
-
existingSection.columns.push(col);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
sectionsMap.set(section.code, Object.assign(Object.assign({}, section), { columns: [...section.columns] }));
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
return Array.from(sectionsMap.values());
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Set a view as default and ensure only one view is default at a time
|
|
93
|
-
*/
|
|
94
|
-
export const setViewAsDefault = (views, viewId) => {
|
|
95
|
-
return views.map((view) => (Object.assign(Object.assign({}, view), { default: view.id === viewId })));
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Transform API templates response to ViewMenuItem array
|
|
99
|
-
* Filters templates by mode and only shows the section matching the current mode
|
|
100
|
-
* Separates default templates (to be merged into built-in Default view) from custom views
|
|
101
|
-
*/
|
|
102
|
-
export const transformTemplatesToViewMenuItems = (templates, mode = 'sheet', lang = 'en') => {
|
|
103
|
-
const customViews = [];
|
|
104
|
-
let defaultTemplateColumns;
|
|
105
|
-
let defaultTemplate;
|
|
106
|
-
templates.forEach((template) => {
|
|
107
|
-
// Get columns for the specified mode
|
|
108
|
-
// Map TableMode to layout section code: 'default' → 'Advanced', 'sheet' → 'Sheet'
|
|
109
|
-
const sectionCode = mode === 'sheet' ? 'sheet' : 'advanced';
|
|
110
|
-
const section = template.layout.find((s) => s.code.toLowerCase() === sectionCode);
|
|
111
|
-
const columns = section ? transformLayoutToColumns([section], lang) : [];
|
|
112
|
-
// Handle id as either string or object
|
|
113
|
-
const templateIdString = typeof template.id === 'string' ? template.id : template.templateId;
|
|
114
|
-
const viewId = typeof template.id === 'string' ? template.id : template.templateId;
|
|
115
|
-
// Always include date column at the beginning
|
|
116
|
-
const dateColumn = DATE_COLUMN_CONFIG;
|
|
117
|
-
const columnsWithDate = columns.some((col) => col.name.toLowerCase() === 'date') ? columns : [dateColumn, ...columns];
|
|
118
|
-
// Ensure date column is first
|
|
119
|
-
const dateColumnIndex = columnsWithDate.findIndex((col) => col.name.toLowerCase() === 'date');
|
|
120
|
-
const finalColumns = dateColumnIndex > 0
|
|
121
|
-
? [columnsWithDate[dateColumnIndex], ...columnsWithDate.filter((col) => col.name.toLowerCase() !== 'date')]
|
|
122
|
-
: columnsWithDate;
|
|
123
|
-
if (template.default) {
|
|
124
|
-
// Store default template columns to merge into built-in Default view
|
|
125
|
-
defaultTemplateColumns = finalColumns;
|
|
126
|
-
// Also create a ViewMenuItem for the default template
|
|
127
|
-
defaultTemplate = {
|
|
128
|
-
id: 'default',
|
|
129
|
-
templateId: template.templateId,
|
|
130
|
-
label: template.name,
|
|
131
|
-
isCustom: false,
|
|
132
|
-
default: true,
|
|
133
|
-
columns: finalColumns.map((col) => col.name),
|
|
134
|
-
submenu: finalColumns,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Add non-default templates as custom views
|
|
139
|
-
customViews.push({
|
|
140
|
-
id: viewId,
|
|
141
|
-
templateId: template.templateId,
|
|
142
|
-
label: template.name,
|
|
143
|
-
isCustom: true,
|
|
144
|
-
default: false,
|
|
145
|
-
columns: finalColumns.map((col) => col.name),
|
|
146
|
-
submenu: finalColumns,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
return { customViews, defaultTemplateColumns, defaultTemplate };
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Convert ColumnViewProps back to LayoutSection format for API requests
|
|
154
|
-
*/
|
|
155
|
-
export const convertColumnsToLayoutSection = (columns, mode, lang = 'en') => {
|
|
156
|
-
const columnItems = columns.map((col, index) => {
|
|
157
|
-
var _a, _b;
|
|
158
|
-
const fieldItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((field) => {
|
|
159
|
-
var _a;
|
|
160
|
-
return ({
|
|
161
|
-
code: field.name,
|
|
162
|
-
name: [
|
|
163
|
-
{
|
|
164
|
-
text: typeof field.label === 'string' ? field.label : field.name,
|
|
165
|
-
lang: lang || '',
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
default: (_a = field.selected) !== null && _a !== void 0 ? _a : false,
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
const columnLabel = typeof col.label === 'string' ? col.label : col.name;
|
|
172
|
-
return Object.assign({ code: col.name, name: [
|
|
173
|
-
{
|
|
174
|
-
text: columnLabel,
|
|
175
|
-
lang,
|
|
176
|
-
},
|
|
177
|
-
], order: index + 1, default: (_b = col.selected) !== null && _b !== void 0 ? _b : false }, (fieldItems && fieldItems.length > 0 && { fields: fieldItems }));
|
|
178
|
-
});
|
|
179
|
-
// Map TableMode to layout section code: 'default' → 'Advanced', 'sheet' → 'Sheet'
|
|
180
|
-
const sectionCode = mode === 'sheet' ? 'Sheet' : 'Advanced';
|
|
181
|
-
return {
|
|
182
|
-
code: sectionCode,
|
|
183
|
-
columns: columnItems,
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Initialize columns for editing mode
|
|
188
|
-
*/
|
|
189
|
-
export const initializeEditingColumns = (editingColumns, availableColumns) => {
|
|
190
|
-
return availableColumns
|
|
191
|
-
.filter((col) => !isDateColumn(col.name))
|
|
192
|
-
.map((col) => {
|
|
193
|
-
var _a;
|
|
194
|
-
const savedCol = editingColumns.find((ec) => ec.name === col.name);
|
|
195
|
-
return (savedCol || Object.assign(Object.assign({}, col), { selected: false, menuItems: (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Initialize columns for create mode (all unchecked except date)
|
|
200
|
-
*/
|
|
201
|
-
export const initializeCreateColumns = (availableColumns) => {
|
|
202
|
-
return availableColumns
|
|
203
|
-
.filter((col) => !isDateColumn(col.name))
|
|
204
|
-
.map((col) => {
|
|
205
|
-
var _a;
|
|
206
|
-
return (Object.assign(Object.assign({}, col), { selected: false, menuItems: (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Initialize columns for create mode with current tableViews state (preserves checked/unchecked values)
|
|
211
|
-
*/
|
|
212
|
-
export const initializeCreateColumnsWithCurrentState = (availableColumns, currentTableViews) => {
|
|
213
|
-
return availableColumns
|
|
214
|
-
.filter((col) => !isDateColumn(col.name))
|
|
215
|
-
.map((col) => {
|
|
216
|
-
var _a, _b, _c;
|
|
217
|
-
const currentCol = currentTableViews.find((tc) => tc.name === col.name);
|
|
218
|
-
if (currentCol) {
|
|
219
|
-
return Object.assign(Object.assign({}, col), { selected: (_a = currentCol.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
220
|
-
var _a, _b;
|
|
221
|
-
const currentMenuItem = (_a = currentCol.menuItems) === null || _a === void 0 ? void 0 : _a.find((mi) => mi.name === item.name);
|
|
222
|
-
return Object.assign(Object.assign({}, item), { selected: (_b = currentMenuItem === null || currentMenuItem === void 0 ? void 0 : currentMenuItem.selected) !== null && _b !== void 0 ? _b : false });
|
|
223
|
-
}) });
|
|
224
|
-
}
|
|
225
|
-
return Object.assign(Object.assign({}, col), { selected: false, menuItems: (_c = col.menuItems) === null || _c === void 0 ? void 0 : _c.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) });
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* Reset columns to their default selection state
|
|
230
|
-
*/
|
|
231
|
-
export const resetColumnsToDefault = (columns) => {
|
|
232
|
-
return columns
|
|
233
|
-
.filter((col) => !isDateColumn(col.name))
|
|
234
|
-
.map((col) => {
|
|
235
|
-
var _a, _b;
|
|
236
|
-
return (Object.assign(Object.assign({}, col), { selected: (_a = col.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => { var _a; return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false })); }) }));
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Toggle a column's selection (including all children if present)
|
|
241
|
-
*/
|
|
242
|
-
export const toggleColumn = (columns, columnName) => {
|
|
243
|
-
return columns.map((col) => {
|
|
244
|
-
var _a;
|
|
245
|
-
if (col.name !== columnName)
|
|
246
|
-
return col;
|
|
247
|
-
const newSelected = !col.selected;
|
|
248
|
-
const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: newSelected })));
|
|
249
|
-
return Object.assign(Object.assign({}, col), { selected: newSelected, menuItems: updatedMenuItems });
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Toggle a sub-item's selection and update parent state
|
|
254
|
-
*/
|
|
255
|
-
export const toggleSubItem = (columns, columnName, subItemName) => {
|
|
256
|
-
return columns.map((col) => {
|
|
257
|
-
var _a, _b;
|
|
258
|
-
if (col.name !== columnName)
|
|
259
|
-
return col;
|
|
260
|
-
const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (item.name === subItemName ? Object.assign(Object.assign({}, item), { selected: !item.selected }) : item));
|
|
261
|
-
const hasSelectedChildren = (_b = updatedMenuItems === null || updatedMenuItems === void 0 ? void 0 : updatedMenuItems.some((item) => item.selected)) !== null && _b !== void 0 ? _b : false;
|
|
262
|
-
return Object.assign(Object.assign({}, col), { menuItems: updatedMenuItems, selected: hasSelectedChildren });
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Select or deselect all columns (except date)
|
|
267
|
-
*/
|
|
268
|
-
export const toggleAllColumns = (columns, selectAll) => {
|
|
269
|
-
return columns.map((col) => {
|
|
270
|
-
var _a;
|
|
271
|
-
if (isDateColumn(col.name))
|
|
272
|
-
return col;
|
|
273
|
-
const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: selectAll })));
|
|
274
|
-
return Object.assign(Object.assign({}, col), { selected: selectAll, menuItems: updatedMenuItems });
|
|
275
|
-
});
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Check if all non-date columns are selected
|
|
279
|
-
*/
|
|
280
|
-
export const areAllColumnsSelected = (columns) => {
|
|
281
|
-
const nonDateColumns = columns.filter((col) => !isDateColumn(col.name));
|
|
282
|
-
return (nonDateColumns.length > 0 &&
|
|
283
|
-
nonDateColumns.every((col) => {
|
|
284
|
-
var _a;
|
|
285
|
-
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
286
|
-
// For columns with menuItems, all items must be selected
|
|
287
|
-
return col.menuItems.every((item) => item.selected);
|
|
288
|
-
}
|
|
289
|
-
return col.selected;
|
|
290
|
-
}));
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* Check if some (but not all) non-date columns are selected
|
|
294
|
-
*/
|
|
295
|
-
export const areSomeColumnsSelected = (columns, allSelected) => {
|
|
296
|
-
const nonDateColumns = columns.filter((col) => !isDateColumn(col.name));
|
|
297
|
-
const hasAnySelected = nonDateColumns.some((col) => {
|
|
298
|
-
var _a;
|
|
299
|
-
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
300
|
-
return col.menuItems.some((item) => item.selected);
|
|
301
|
-
}
|
|
302
|
-
return col.selected;
|
|
303
|
-
});
|
|
304
|
-
return hasAnySelected && !allSelected;
|
|
305
|
-
};
|
|
306
|
-
/**
|
|
307
|
-
* Validate template name
|
|
308
|
-
*/
|
|
309
|
-
export const isValidTemplateName = (name, maxLength) => {
|
|
310
|
-
return name.trim().length > 0 && name.length <= maxLength;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Deep clone columns array with all nested properties
|
|
314
|
-
*/
|
|
315
|
-
export const deepCloneColumns = (columns) => {
|
|
316
|
-
return columns.map((col) => {
|
|
317
|
-
var _a, _b;
|
|
318
|
-
return (Object.assign(Object.assign({}, col), { selected: (_a = col.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
319
|
-
var _a;
|
|
320
|
-
return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false }));
|
|
321
|
-
}) }));
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
/**
|
|
325
|
-
* Toggle a single column's selection state
|
|
326
|
-
*/
|
|
327
|
-
export const toggleSingleColumn = (columns, columnName) => {
|
|
328
|
-
return columns.map((col) => {
|
|
329
|
-
var _a;
|
|
330
|
-
if (col.name !== columnName)
|
|
331
|
-
return col;
|
|
332
|
-
const newSelected = !col.selected;
|
|
333
|
-
const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: newSelected })));
|
|
334
|
-
return Object.assign(Object.assign({}, col), { selected: newSelected, menuItems: updatedMenuItems });
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* Get submenu items for a view menu item
|
|
339
|
-
* Always includes the date column at the beginning
|
|
340
|
-
*/
|
|
341
|
-
export const getSubmenuItems = (item, defaultColumns) => {
|
|
342
|
-
var _a;
|
|
343
|
-
let columns = [];
|
|
344
|
-
if (item.isCustom && ((_a = item.submenu) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
345
|
-
columns = item.submenu;
|
|
346
|
-
}
|
|
347
|
-
else if (item.id === 'default') {
|
|
348
|
-
columns = defaultColumns;
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
columns = item.submenu || [];
|
|
352
|
-
}
|
|
353
|
-
// Always include date column at the beginning if it's not already present
|
|
354
|
-
const hasDateColumn = columns.some((col) => col.name.toLowerCase() === 'date');
|
|
355
|
-
if (!hasDateColumn) {
|
|
356
|
-
const dateColumn = {
|
|
357
|
-
name: 'date',
|
|
358
|
-
label: 'Date',
|
|
359
|
-
selected: true,
|
|
360
|
-
};
|
|
361
|
-
return [dateColumn, ...columns];
|
|
362
|
-
}
|
|
363
|
-
// Ensure date column is first
|
|
364
|
-
const dateColumnIndex = columns.findIndex((col) => col.name.toLowerCase() === 'date');
|
|
365
|
-
if (dateColumnIndex > 0) {
|
|
366
|
-
const dateColumn = columns[dateColumnIndex];
|
|
367
|
-
const otherColumns = columns.filter((col) => col.name.toLowerCase() !== 'date');
|
|
368
|
-
return [dateColumn, ...otherColumns];
|
|
369
|
-
}
|
|
370
|
-
return columns;
|
|
371
|
-
};
|
|
372
|
-
/**
|
|
373
|
-
* Check if a view menu item has submenu
|
|
374
|
-
*/
|
|
375
|
-
export const hasSubmenu = (item, defaultColumns) => {
|
|
376
|
-
return getSubmenuItems(item, defaultColumns).length > 0;
|
|
377
|
-
};
|
|
378
|
-
/**
|
|
379
|
-
* Check if all columns in current state are selected
|
|
380
|
-
*/
|
|
381
|
-
export const areAllCurrentColumnsSelected = (columns) => {
|
|
382
|
-
if (columns.length === 0)
|
|
383
|
-
return false;
|
|
384
|
-
return columns.every((col) => {
|
|
385
|
-
var _a;
|
|
386
|
-
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
387
|
-
// For columns with menuItems, all items must be selected
|
|
388
|
-
return col.menuItems.every((item) => item.selected);
|
|
389
|
-
}
|
|
390
|
-
return col.selected;
|
|
391
|
-
});
|
|
392
|
-
};
|
|
393
|
-
/**
|
|
394
|
-
* Check if some (but not all) columns in current state are selected
|
|
395
|
-
*/
|
|
396
|
-
export const areSomeCurrentColumnsSelected = (columns, allSelected) => {
|
|
397
|
-
if (columns.length === 0)
|
|
398
|
-
return false;
|
|
399
|
-
const hasAny = columns.some((col) => {
|
|
400
|
-
var _a;
|
|
401
|
-
if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
402
|
-
return col.menuItems.some((item) => item.selected);
|
|
403
|
-
}
|
|
404
|
-
return col.selected;
|
|
405
|
-
});
|
|
406
|
-
return hasAny && !allSelected;
|
|
407
|
-
};
|
|
408
|
-
/**
|
|
409
|
-
* Toggle all columns selection (select all or unselect all)
|
|
410
|
-
*/
|
|
411
|
-
export const toggleAllCurrentColumns = (columns, shouldSelect) => {
|
|
412
|
-
return columns.map((col) => {
|
|
413
|
-
var _a;
|
|
414
|
-
const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: shouldSelect })));
|
|
415
|
-
return Object.assign(Object.assign({}, col), { selected: shouldSelect, menuItems: updatedMenuItems });
|
|
416
|
-
});
|
|
417
|
-
};
|
|
418
|
-
/**
|
|
419
|
-
* Normalize columns by converting undefined selected values to false for consistent comparison
|
|
420
|
-
*/
|
|
421
|
-
export const normalizeColumnsSelected = (columns) => {
|
|
422
|
-
return columns.map((col) => {
|
|
423
|
-
var _a, _b;
|
|
424
|
-
return (Object.assign(Object.assign({}, col), { selected: (_a = col.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
425
|
-
var _a;
|
|
426
|
-
return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false }));
|
|
427
|
-
}) }));
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
/**
|
|
431
|
-
* Compare two columns arrays to check if they are equal (same order, same selection states)
|
|
432
|
-
*/
|
|
433
|
-
export const areColumnsEqual = (cols1, cols2) => {
|
|
434
|
-
if (cols1.length !== cols2.length)
|
|
435
|
-
return false;
|
|
436
|
-
const normalizedCols1 = normalizeColumnsSelected(cols1);
|
|
437
|
-
const normalizedCols2 = normalizeColumnsSelected(cols2);
|
|
438
|
-
for (let i = 0; i < normalizedCols1.length; i++) {
|
|
439
|
-
const col1 = normalizedCols1[i];
|
|
440
|
-
const col2 = normalizedCols2[i];
|
|
441
|
-
if (col1.name !== col2.name)
|
|
442
|
-
return false;
|
|
443
|
-
if (col1.selected !== col2.selected)
|
|
444
|
-
return false;
|
|
445
|
-
if (col1.menuItems && col2.menuItems) {
|
|
446
|
-
if (col1.menuItems.length !== col2.menuItems.length)
|
|
447
|
-
return false;
|
|
448
|
-
for (let j = 0; j < col1.menuItems.length; j++) {
|
|
449
|
-
const item1 = col1.menuItems[j];
|
|
450
|
-
const item2 = col2.menuItems[j];
|
|
451
|
-
if (item1.name !== item2.name)
|
|
452
|
-
return false;
|
|
453
|
-
if (item1.selected !== item2.selected) {
|
|
454
|
-
return false;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
else if (col1.menuItems || col2.menuItems) {
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return true;
|
|
463
|
-
};
|