@tap-payments/os-micro-frontend-shared 0.1.373-test.3-test.4-test.5-test.6-test.7 → 0.1.373-test.3-test.4-test.5-test.6-test.7-test.8

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.
@@ -43,7 +43,8 @@ export declare const transformTemplatesToViewMenuItems: (templates: Array<{
43
43
  */
44
44
  export declare const convertColumnsToLayoutSection: (columns: ColumnViewProps[], mode: TableMode, lang?: string) => LayoutSection;
45
45
  /**
46
- * Initialize columns for editing mode
46
+ * Initialize columns for editing mode.
47
+ * Preserves the order from editingColumns (saved view), then appends any columns from availableColumns not in the saved view.
47
48
  */
48
49
  export declare const initializeEditingColumns: (editingColumns: ColumnViewProps[], availableColumns: ColumnViewProps[]) => ColumnViewProps[];
49
50
  /**
@@ -51,7 +52,8 @@ export declare const initializeEditingColumns: (editingColumns: ColumnViewProps[
51
52
  */
52
53
  export declare const initializeCreateColumns: (availableColumns: ColumnViewProps[]) => ColumnViewProps[];
53
54
  /**
54
- * Initialize columns for create mode with current tableViews state (preserves checked/unchecked values)
55
+ * Initialize columns for create mode with current tableViews state (preserves checked/unchecked values).
56
+ * Preserves the order from currentTableViews (current table columns), then appends any columns from availableColumns not in the table.
55
57
  */
56
58
  export declare const initializeCreateColumnsWithCurrentState: (availableColumns: ColumnViewProps[], currentTableViews: ColumnViewProps[]) => ColumnViewProps[];
57
59
  /**
@@ -183,16 +183,31 @@ export const convertColumnsToLayoutSection = (columns, mode, lang = 'en') => {
183
183
  };
184
184
  };
185
185
  /**
186
- * Initialize columns for editing mode
186
+ * Initialize columns for editing mode.
187
+ * Preserves the order from editingColumns (saved view), then appends any columns from availableColumns not in the saved view.
187
188
  */
188
189
  export const initializeEditingColumns = (editingColumns, availableColumns) => {
189
- return availableColumns
190
- .filter((col) => !isDateColumn(col.name))
191
- .map((col) => {
192
- var _a;
193
- const savedCol = editingColumns.find((ec) => ec.name === col.name);
194
- 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 }))) }));
195
- });
190
+ var _a, _b;
191
+ const editingOrder = editingColumns.filter((col) => !isDateColumn(col.name)).map((col) => col.name);
192
+ const availableByName = new Map(availableColumns.filter((c) => !isDateColumn(c.name)).map((c) => [c.name, c]));
193
+ const result = [];
194
+ for (const name of editingOrder) {
195
+ const savedCol = editingColumns.find((ec) => ec.name === name);
196
+ const availCol = availableByName.get(name);
197
+ if (availCol) {
198
+ result.push(savedCol !== null && savedCol !== void 0 ? savedCol : Object.assign(Object.assign({}, availCol), { selected: false, menuItems: (_a = availCol.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
199
+ }
200
+ else if (savedCol) {
201
+ result.push(savedCol);
202
+ }
203
+ }
204
+ for (const [, availCol] of availableByName) {
205
+ if (!editingOrder.includes(availCol.name)) {
206
+ const savedCol = editingColumns.find((ec) => ec.name === availCol.name);
207
+ result.push(savedCol !== null && savedCol !== void 0 ? savedCol : Object.assign(Object.assign({}, availCol), { selected: false, menuItems: (_b = availCol.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
208
+ }
209
+ }
210
+ return result;
196
211
  };
197
212
  /**
198
213
  * Initialize columns for create mode (all unchecked except date)
@@ -206,23 +221,34 @@ export const initializeCreateColumns = (availableColumns) => {
206
221
  });
207
222
  };
208
223
  /**
209
- * Initialize columns for create mode with current tableViews state (preserves checked/unchecked values)
224
+ * Initialize columns for create mode with current tableViews state (preserves checked/unchecked values).
225
+ * Preserves the order from currentTableViews (current table columns), then appends any columns from availableColumns not in the table.
210
226
  */
211
227
  export const initializeCreateColumnsWithCurrentState = (availableColumns, currentTableViews) => {
212
- return availableColumns
213
- .filter((col) => !isDateColumn(col.name))
214
- .map((col) => {
215
- var _a, _b, _c;
216
- const currentCol = currentTableViews.find((tc) => tc.name === col.name);
217
- if (currentCol) {
218
- 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) => {
228
+ var _a, _b, _c, _d;
229
+ const availableByName = new Map(availableColumns.filter((c) => !isDateColumn(c.name)).map((c) => [c.name, c]));
230
+ const currentOrder = currentTableViews.filter((c) => !isDateColumn(c.name)).map((c) => c.name);
231
+ const result = [];
232
+ for (const name of currentOrder) {
233
+ const currentCol = currentTableViews.find((tc) => tc.name === name);
234
+ const availCol = availableByName.get(name);
235
+ if (availCol && currentCol) {
236
+ result.push(Object.assign(Object.assign({}, availCol), { selected: (_a = currentCol.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = availCol.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => {
219
237
  var _a, _b;
220
238
  const currentMenuItem = (_a = currentCol.menuItems) === null || _a === void 0 ? void 0 : _a.find((mi) => mi.name === item.name);
221
239
  return Object.assign(Object.assign({}, item), { selected: (_b = currentMenuItem === null || currentMenuItem === void 0 ? void 0 : currentMenuItem.selected) !== null && _b !== void 0 ? _b : false });
222
- }) });
240
+ }) }));
223
241
  }
224
- 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 }))) });
225
- });
242
+ else if (availCol) {
243
+ result.push(Object.assign(Object.assign({}, availCol), { selected: false, menuItems: (_c = availCol.menuItems) === null || _c === void 0 ? void 0 : _c.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
244
+ }
245
+ }
246
+ for (const [, availCol] of availableByName) {
247
+ if (!currentOrder.includes(availCol.name)) {
248
+ result.push(Object.assign(Object.assign({}, availCol), { selected: false, menuItems: (_d = availCol.menuItems) === null || _d === void 0 ? void 0 : _d.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
249
+ }
250
+ }
251
+ return result;
226
252
  };
227
253
  /**
228
254
  * Reset columns to their default selection state
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.373-test.3-test.4-test.5-test.6-test.7",
5
- "testVersion": 7,
4
+ "version": "0.1.373-test.3-test.4-test.5-test.6-test.7-test.8",
5
+ "testVersion": 8,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",