@tap-payments/os-micro-frontend-shared 0.1.376 → 0.1.377-test.1

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 (100) hide show
  1. package/build/components/AnimatedSpinnerIcon/style.d.ts +0 -1
  2. package/build/components/Chip/style.d.ts +0 -1
  3. package/build/components/CountBadge/style.d.ts +0 -1
  4. package/build/components/Dialog/style.d.ts +0 -1
  5. package/build/components/FlippingCard/style.d.ts +0 -1
  6. package/build/components/ImageWrapper/ImageWrapper.d.ts +0 -1
  7. package/build/components/JSONViewer/style.d.ts +0 -1
  8. package/build/components/LeftPeekRightExpandingChip/style.d.ts +0 -1
  9. package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -1
  10. package/build/components/SearchButton/styles.d.ts +0 -1
  11. package/build/components/StatusIcons/AuthIcons/style.d.ts +0 -1
  12. package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +0 -1
  13. package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +0 -1
  14. package/build/components/StatusIcons/SourceIcons/style.d.ts +0 -1
  15. package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +0 -1
  16. package/build/components/TableCells/CustomCells/AgreementCell/style.d.ts +0 -1
  17. package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +0 -1
  18. package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +0 -1
  19. package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +0 -1
  20. package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +0 -1
  21. package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +0 -1
  22. package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +0 -1
  23. package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +0 -1
  24. package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +0 -1
  25. package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +0 -1
  26. package/build/components/TableCells/CustomCells/IDButton/style.d.ts +0 -1
  27. package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +0 -1
  28. package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +0 -1
  29. package/build/components/TableCells/CustomCells/PayoutReportCell/style.d.ts +0 -1
  30. package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +0 -1
  31. package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +0 -1
  32. package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +0 -1
  33. package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +0 -1
  34. package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +0 -1
  35. package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +0 -1
  36. package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +0 -1
  37. package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +0 -1
  38. package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +0 -1
  39. package/build/components/TableCells/CustomCells/style.d.ts +0 -1
  40. package/build/components/TableHeader/FiltersRow.d.ts +1 -1
  41. package/build/components/TableHeader/FiltersRow.js +4 -2
  42. package/build/components/TableHeader/TableHeader.d.ts +1 -1
  43. package/build/components/TableHeader/TableHeader.js +2 -2
  44. package/build/components/TableHeader/TableView/CreateViewDialog.d.ts +3 -0
  45. package/build/components/TableHeader/TableView/CreateViewDialog.js +91 -0
  46. package/build/components/TableHeader/TableView/CustomViews.js +1 -1
  47. package/build/components/TableHeader/TableView/TableView.js +0 -1
  48. package/build/components/TableHeader/TableView/ViewsDropdown.d.ts +5 -0
  49. package/build/components/TableHeader/TableView/ViewsDropdown.js +189 -0
  50. package/build/components/TableHeader/TableView/ViewsMenu.d.ts +5 -0
  51. package/build/components/TableHeader/TableView/ViewsMenu.js +76 -0
  52. package/build/components/TableHeader/TableView/components/ColumnList.d.ts +3 -0
  53. package/build/components/TableHeader/TableView/components/ColumnList.js +70 -0
  54. package/build/components/TableHeader/TableView/components/ViewsSubmenu.d.ts +3 -0
  55. package/build/components/TableHeader/TableView/components/ViewsSubmenu.js +75 -0
  56. package/build/components/TableHeader/TableView/components/index.d.ts +2 -0
  57. package/build/components/TableHeader/TableView/components/index.js +2 -0
  58. package/build/components/TableHeader/TableView/constants.d.ts +10 -0
  59. package/build/components/TableHeader/TableView/constants.js +10 -0
  60. package/build/components/TableHeader/TableView/data.d.ts +5 -0
  61. package/build/components/TableHeader/TableView/data.js +48 -0
  62. package/build/components/TableHeader/TableView/hooks/index.d.ts +6 -0
  63. package/build/components/TableHeader/TableView/hooks/index.js +6 -0
  64. package/build/components/TableHeader/TableView/hooks/useCreateViewDialog.d.ts +22 -0
  65. package/build/components/TableHeader/TableView/hooks/useCreateViewDialog.js +86 -0
  66. package/build/components/TableHeader/TableView/hooks/useDialogPosition.d.ts +8 -0
  67. package/build/components/TableHeader/TableView/hooks/useDialogPosition.js +16 -0
  68. package/build/components/TableHeader/TableView/hooks/useNestedSubmenu.d.ts +7 -0
  69. package/build/components/TableHeader/TableView/hooks/useNestedSubmenu.js +27 -0
  70. package/build/components/TableHeader/TableView/hooks/useOriginalColumns.d.ts +6 -0
  71. package/build/components/TableHeader/TableView/hooks/useOriginalColumns.js +18 -0
  72. package/build/components/TableHeader/TableView/hooks/useSubmenuHover.d.ts +8 -0
  73. package/build/components/TableHeader/TableView/hooks/useSubmenuHover.js +43 -0
  74. package/build/components/TableHeader/TableView/hooks/useViewsManager.d.ts +9 -0
  75. package/build/components/TableHeader/TableView/hooks/useViewsManager.js +62 -0
  76. package/build/components/TableHeader/TableView/hooks/useViewsMenu.d.ts +44 -0
  77. package/build/components/TableHeader/TableView/hooks/useViewsMenu.js +177 -0
  78. package/build/components/TableHeader/TableView/index.d.ts +12 -3
  79. package/build/components/TableHeader/TableView/index.js +11 -3
  80. package/build/components/TableHeader/TableView/styles.d.ts +127 -0
  81. package/build/components/TableHeader/TableView/styles.js +426 -0
  82. package/build/components/TableHeader/TableView/types.d.ts +182 -0
  83. package/build/components/TableHeader/TableView/types.js +1 -0
  84. package/build/components/TableHeader/TableView/utils.d.ts +121 -0
  85. package/build/components/TableHeader/TableView/utils.js +469 -0
  86. package/build/components/TableHeader/index.d.ts +1 -0
  87. package/build/components/TableHeader/type.d.ts +15 -1
  88. package/build/components/TableReports/components/DownloadButton/style.d.ts +0 -1
  89. package/build/components/TableReports/style.d.ts +0 -1
  90. package/build/components/VirtualTables/VirtualTable/VirtualTable.d.ts +1 -1
  91. package/build/components/VirtualTables/VirtualTable/VirtualTable.js +4 -3
  92. package/build/components/VirtualTables/components/style.d.ts +0 -1
  93. package/build/constants/assets.d.ts +1 -0
  94. package/build/constants/assets.js +1 -0
  95. package/build/types/table.d.ts +1 -0
  96. package/build/utils/index.d.ts +1 -0
  97. package/build/utils/index.js +1 -0
  98. package/build/utils/skeletonColumns.d.ts +4 -0
  99. package/build/utils/skeletonColumns.js +17 -0
  100. package/package.json +4 -3
@@ -0,0 +1,469 @@
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: isDateColumn(col.code) ? true : (_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
+ if (isDateColumn(col.name)) {
333
+ return Object.assign(Object.assign({}, col), { selected: true });
334
+ }
335
+ const newSelected = !col.selected;
336
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: newSelected })));
337
+ return Object.assign(Object.assign({}, col), { selected: newSelected, menuItems: updatedMenuItems });
338
+ });
339
+ };
340
+ /**
341
+ * Get submenu items for a view menu item
342
+ * Always includes the date column at the beginning
343
+ */
344
+ export const getSubmenuItems = (item, defaultColumns) => {
345
+ var _a;
346
+ let columns = [];
347
+ if (item.isCustom && ((_a = item.submenu) === null || _a === void 0 ? void 0 : _a.length)) {
348
+ columns = item.submenu;
349
+ }
350
+ else if (item.id === 'default') {
351
+ columns = defaultColumns;
352
+ }
353
+ else {
354
+ columns = item.submenu || [];
355
+ }
356
+ // Always include date column at the beginning if it's not already present
357
+ const hasDateColumn = columns.some((col) => col.name.toLowerCase() === 'date');
358
+ if (!hasDateColumn) {
359
+ const dateColumn = {
360
+ name: 'date',
361
+ label: 'Date',
362
+ selected: true,
363
+ };
364
+ return [dateColumn, ...columns];
365
+ }
366
+ // Ensure date column is first
367
+ const dateColumnIndex = columns.findIndex((col) => col.name.toLowerCase() === 'date');
368
+ if (dateColumnIndex > 0) {
369
+ const dateColumn = columns[dateColumnIndex];
370
+ const otherColumns = columns.filter((col) => col.name.toLowerCase() !== 'date');
371
+ return [dateColumn, ...otherColumns];
372
+ }
373
+ return columns;
374
+ };
375
+ /**
376
+ * Check if a view menu item has submenu
377
+ */
378
+ export const hasSubmenu = (item, defaultColumns) => {
379
+ return getSubmenuItems(item, defaultColumns).length > 0;
380
+ };
381
+ /**
382
+ * Check if all columns in current state are selected
383
+ */
384
+ export const areAllCurrentColumnsSelected = (columns) => {
385
+ if (columns.length === 0)
386
+ return false;
387
+ return columns.every((col) => {
388
+ var _a;
389
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
390
+ // For columns with menuItems, all items must be selected
391
+ return col.menuItems.every((item) => item.selected);
392
+ }
393
+ return col.selected;
394
+ });
395
+ };
396
+ /**
397
+ * Check if some (but not all) columns in current state are selected
398
+ */
399
+ export const areSomeCurrentColumnsSelected = (columns, allSelected) => {
400
+ if (columns.length === 0)
401
+ return false;
402
+ const hasAny = columns.some((col) => {
403
+ var _a;
404
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
405
+ return col.menuItems.some((item) => item.selected);
406
+ }
407
+ return col.selected;
408
+ });
409
+ return hasAny && !allSelected;
410
+ };
411
+ /**
412
+ * Toggle all columns selection (select all or unselect all)
413
+ */
414
+ export const toggleAllCurrentColumns = (columns, shouldSelect) => {
415
+ return columns.map((col) => {
416
+ var _a;
417
+ if (isDateColumn(col.name)) {
418
+ return Object.assign(Object.assign({}, col), { selected: true });
419
+ }
420
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: shouldSelect })));
421
+ return Object.assign(Object.assign({}, col), { selected: shouldSelect, menuItems: updatedMenuItems });
422
+ });
423
+ };
424
+ /**
425
+ * Normalize columns by converting undefined selected values to false for consistent comparison
426
+ */
427
+ export const normalizeColumnsSelected = (columns) => {
428
+ return columns.map((col) => {
429
+ var _a, _b;
430
+ 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) => {
431
+ var _a;
432
+ return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false }));
433
+ }) }));
434
+ });
435
+ };
436
+ /**
437
+ * Compare two columns arrays to check if they are equal (same order, same selection states)
438
+ */
439
+ export const areColumnsEqual = (cols1, cols2) => {
440
+ if (cols1.length !== cols2.length)
441
+ return false;
442
+ const normalizedCols1 = normalizeColumnsSelected(cols1);
443
+ const normalizedCols2 = normalizeColumnsSelected(cols2);
444
+ for (let i = 0; i < normalizedCols1.length; i++) {
445
+ const col1 = normalizedCols1[i];
446
+ const col2 = normalizedCols2[i];
447
+ if (col1.name !== col2.name)
448
+ return false;
449
+ if (col1.selected !== col2.selected)
450
+ return false;
451
+ if (col1.menuItems && col2.menuItems) {
452
+ if (col1.menuItems.length !== col2.menuItems.length)
453
+ return false;
454
+ for (let j = 0; j < col1.menuItems.length; j++) {
455
+ const item1 = col1.menuItems[j];
456
+ const item2 = col2.menuItems[j];
457
+ if (item1.name !== item2.name)
458
+ return false;
459
+ if (item1.selected !== item2.selected) {
460
+ return false;
461
+ }
462
+ }
463
+ }
464
+ else if (col1.menuItems || col2.menuItems) {
465
+ return false;
466
+ }
467
+ }
468
+ return true;
469
+ };
@@ -6,3 +6,4 @@ export { default as FiltersRowWrapper } from './FiltersRowWrapper';
6
6
  export { default as FiltersRow } from './FiltersRow';
7
7
  export * from './style';
8
8
  export * from './type';
9
+ export type { Template, LayoutSection, ViewMenuItem } from './TableView/types';
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  import type { CalenderMode, TableHeaderStatus, ColumnViewProps, TableMode, Timezone, SegmentCountry } from '../../types/index.js';
3
3
  import { AvailableStatus } from '../StatusBar/type';
4
4
  import { PartialExcept } from '../../types/index.js';
5
+ import type { ViewMenuItem, LayoutSection, Template } from './TableView/types';
5
6
  type ViewsOptions = {
6
7
  default: {};
7
8
  developer: {};
@@ -22,7 +23,7 @@ export interface TableHeaderProps<IStatus extends TableHeaderStatus | TableHeade
22
23
  calendarMode?: CalenderMode;
23
24
  onStatusChange?: <T extends IStatus>(status?: T) => void;
24
25
  onSearch?: (search: string) => void;
25
- onViewChange?: () => void;
26
+ onViewChange?: (selectedView?: ViewMenuItem) => void;
26
27
  onDateChange?: (date: Date | [Date, Date]) => void;
27
28
  tableReportsComponent?: React.ReactNode;
28
29
  tableFilterComponent?: React.ReactNode;
@@ -44,6 +45,19 @@ export interface TableHeaderProps<IStatus extends TableHeaderStatus | TableHeade
44
45
  id: string;
45
46
  label: string;
46
47
  }) => void;
48
+ onCreateCustomView?: (data: {
49
+ name: string;
50
+ selectedColumns: ColumnViewProps[];
51
+ layout: LayoutSection;
52
+ }) => Promise<void>;
53
+ onEditCustomView?: (viewId: string, data: {
54
+ name: string;
55
+ selectedColumns: ColumnViewProps[];
56
+ layout: LayoutSection;
57
+ }) => Promise<void>;
58
+ onDeleteCustomView?: (viewId: string) => Promise<void>;
59
+ templates?: Template[];
60
+ lang?: string;
47
61
  onToggleTextButtonClick?: () => void;
48
62
  children?: ReactNode;
49
63
  calendarGroupBy?: string;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const Button: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  type ExportButtonProps = {
4
3
  notificationState?: {
5
4
  success: boolean;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { IVirtualTable } from '../../../types/index.js';
3
- declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, footerComponent, customNoDataComponent, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
3
+ declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, footerComponent, customNoDataComponent, defaultSkeleton, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof VirtualTable>;
5
5
  export default _default;
@@ -15,7 +15,7 @@ import AutoSizer from 'react-virtualized-auto-sizer';
15
15
  import InfiniteLoader from 'react-window-infinite-loader';
16
16
  import { TABLE_ROW_HEIGHT, TABLE_THRESHOLD, TABLE_LIST_OVER_SCAN, SHEET_VIEW_TABLE_ROW_HEIGHT } from '../../../constants/index.js';
17
17
  import { useDelayToSetValue } from '../../../hooks/index.js';
18
- import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../../utils/index.js';
18
+ import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError, getProcessedColumns } from '../../../utils/index.js';
19
19
  import TableFooter from '../components/TableFooter/TableFooter';
20
20
  import TableHeader from '../components/TableHeader';
21
21
  import TableLastItem from '../components/TableLastItem';
@@ -34,7 +34,7 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
34
34
  areAllRowsLoaded,
35
35
  isSheetView,
36
36
  }));
37
- function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, footerComponent, customNoDataComponent, }) {
37
+ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, footerComponent, customNoDataComponent, defaultSkeleton = false, }) {
38
38
  var _a;
39
39
  const theme = useTheme();
40
40
  const onPointerDown = (e) => {
@@ -58,7 +58,8 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
58
58
  const tableEmpty = !isLoading && rows.length === 0;
59
59
  const hasTimeoutError = isTimeoutError(error);
60
60
  const lastItemIndex = rows.length - 1;
61
- const shownColumns = useMemo(() => columns.filter((column) => !column.hidden), [columns]);
61
+ const processedColumns = useMemo(() => getProcessedColumns(columns, isLoading !== null && isLoading !== void 0 ? isLoading : false, defaultSkeleton), [columns, isLoading, defaultSkeleton]);
62
+ const shownColumns = useMemo(() => processedColumns.filter((column) => !column.hidden), [processedColumns]);
62
63
  const orderedColumns = useMemo(() => shownColumns.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); }), [shownColumns]);
63
64
  const areTotalRowsNotFillingHeight = isHeightNotFullyFilledByRows(rows.length) && !tableLoading;
64
65
  const itemsCount = isDelayedFetchingNextPage || (areAllRowsLoaded && !areTotalRowsNotFillingHeight) ? rows.length + 1 : rows.length;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  interface TableWrapperProps {
4
3
  showNoDataView?: boolean;
5
4
  }
@@ -339,6 +339,7 @@ export declare const TAP3DSPROVIDERIcon: string;
339
339
  export declare const greyPlusIcon: string;
340
340
  export declare const greyMinusIcon: string;
341
341
  export declare const noPreviewIcon: string;
342
+ export declare const editIcon: string;
342
343
  export declare const viewInvoiceIcon: string;
343
344
  export declare const checkoutStatusIcon: string;
344
345
  export declare const checkoutStatusBlueIcon: string;
@@ -345,6 +345,7 @@ export const TAP3DSPROVIDERIcon = `${lightUrl}/provider/TAP3DS.svg`;
345
345
  export const greyPlusIcon = `${lightUrl}/greyPlusIcon.svg`;
346
346
  export const greyMinusIcon = `${lightUrl}/greyMinusIcon.svg`;
347
347
  export const noPreviewIcon = `${lightUrl}/noPreviewIcon.svg`;
348
+ export const editIcon = `${lightUrl}/other/editIcon.svg`;
348
349
  export const viewInvoiceIcon = `${appBaseUrl}/viewInvoice.svg`;
349
350
  export const checkoutStatusIcon = `${appBaseUrl}/checkoutStatus.svg`;
350
351
  export const checkoutStatusBlueIcon = `${appBaseUrl}/checkStatusOutBlue.svg`;
@@ -116,6 +116,7 @@ export interface IVirtualTable<R = any> {
116
116
  headerProps?: TableHeadProps;
117
117
  isLoading?: boolean;
118
118
  isFetchingNextPage?: boolean;
119
+ defaultSkeleton?: boolean;
119
120
  rowProps?: TableRowProps & {
120
121
  onRowClick?: (row: R, index: number) => void;
121
122
  };
@@ -45,3 +45,4 @@ export * from './boolean';
45
45
  export * from './columnResizeStorage';
46
46
  export * from './timezone';
47
47
  export * from './merchantSource';
48
+ export * from './skeletonColumns';
@@ -45,3 +45,4 @@ export * from './boolean';
45
45
  export * from './columnResizeStorage';
46
46
  export * from './timezone';
47
47
  export * from './merchantSource';
48
+ export * from './skeletonColumns';
@@ -0,0 +1,4 @@
1
+ import type { IColumnProps } from '../types/index.js';
2
+ export declare const DEFAULT_SKELETON_WIDTHS: string[];
3
+ export declare const generateSkeletonColumns: (staticWidths?: string[]) => IColumnProps[];
4
+ export declare const getProcessedColumns: <T = any>(columns: readonly IColumnProps<T>[], isLoading: boolean, defaultSkeleton: boolean) => IColumnProps<T>[];
@@ -0,0 +1,17 @@
1
+ export const DEFAULT_SKELETON_WIDTHS = ['120px', '180px', '100px', '150px', '200px', '140px', '160px', '110px', '190px', '130px'];
2
+ export const generateSkeletonColumns = (staticWidths = DEFAULT_SKELETON_WIDTHS) => {
3
+ return staticWidths.map((width, index) => ({
4
+ id: `skeleton-col-${index}`,
5
+ header: '',
6
+ width,
7
+ order: index,
8
+ hidden: false,
9
+ sortable: false,
10
+ }));
11
+ };
12
+ export const getProcessedColumns = (columns, isLoading, defaultSkeleton) => {
13
+ if (defaultSkeleton && isLoading) {
14
+ return generateSkeletonColumns();
15
+ }
16
+ return [...columns];
17
+ };
package/package.json CHANGED
@@ -1,8 +1,8 @@
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.376",
5
- "testVersion": 0,
4
+ "version": "0.1.377-test.1",
5
+ "testVersion": 1,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -78,6 +78,7 @@
78
78
  "@emotion/styled": "^11.11.0",
79
79
  "@hookform/resolvers": "^3.3.1",
80
80
  "@mui/material": "^5.12.3",
81
+ "@tap-payments/os-micro-frontend-shared": "file:.yalc/@tap-payments/os-micro-frontend-shared",
81
82
  "@uiw/react-json-view": "^2.0.0-alpha.16",
82
83
  "axios": "^1.4.0",
83
84
  "color": "^5.0.0",
@@ -164,4 +165,4 @@
164
165
  "publishConfig": {
165
166
  "registry": "https://registry.npmjs.org/"
166
167
  }
167
- }
168
+ }