@sprucelabs/heartwood-view-controllers 116.0.29 → 116.0.30

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,6 +43,8 @@ export default class ActiveRecordCardViewController extends AbstractViewControll
43
43
  private clearFooter;
44
44
  private dropInErrorRow;
45
45
  protected rebuildSlidesForPaging(): void;
46
+ private updatePager;
47
+ private optionallyDropInNoResultsRow;
46
48
  private clear;
47
49
  private get pageSize();
48
50
  private addList;
@@ -103,7 +103,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
103
103
  else {
104
104
  this.records = (_b = this.allRecords) !== null && _b !== void 0 ? _b : [];
105
105
  }
106
- (_c = this.listVc) === null || _c === void 0 ? void 0 : _c.setRecords(this.records);
106
+ (_c = this.listVc) === null || _c === void 0 ? void 0 : _c.setRecords(this.records.map((r) => r.values));
107
107
  this.rebuildSlidesForPaging();
108
108
  }
109
109
  filterRecords(search) {
@@ -117,7 +117,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
117
117
  this.records = matches;
118
118
  }
119
119
  doesRecordMatch(record, search) {
120
- const searchable = Object.values(record).join('').toLowerCase();
120
+ const searchable = Object.values(record.values).join('').toLowerCase();
121
121
  const doesMatch = searchable.includes(search.toLowerCase());
122
122
  return doesMatch;
123
123
  }
@@ -199,7 +199,9 @@ class ActiveRecordCardViewController extends AbstractViewController {
199
199
  }
200
200
  if (this.listVc) {
201
201
  yield ((_b = this.listVc) === null || _b === void 0 ? void 0 : _b.load());
202
- this.allRecords = this.listVc.getRecords();
202
+ this.allRecords = this.listVc.getRecords().map((r) => ({
203
+ values: r,
204
+ }));
203
205
  }
204
206
  this.cardVc.setIsBusy(false);
205
207
  });
@@ -208,7 +210,8 @@ class ActiveRecordCardViewController extends AbstractViewController {
208
210
  return __awaiter(this, void 0, void 0, function* () {
209
211
  var _a, _b;
210
212
  try {
211
- this.records = yield this.fetcher.fetchRecords();
213
+ const records = yield this.fetcher.fetchRecords();
214
+ this.records = records.map((record) => ({ values: record }));
212
215
  this.allRecords = [...this.records];
213
216
  this.rebuildSlidesForPaging();
214
217
  }
@@ -249,7 +252,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
249
252
  });
250
253
  }
251
254
  rebuildSlidesForPaging() {
252
- var _a, _b, _c, _d;
255
+ var _a;
253
256
  if (!this.pagerVc) {
254
257
  return;
255
258
  }
@@ -259,20 +262,31 @@ class ActiveRecordCardViewController extends AbstractViewController {
259
262
  for (let i = 0; i < totalPages; i++) {
260
263
  const records = (_a = chunkedRecords[i]) !== null && _a !== void 0 ? _a : [];
261
264
  const listVc = this.addList(i);
262
- listVc.setRows(records.map((record) => this.rowTransformer(record)));
263
- }
264
- if (this.records.length === 0) {
265
- this.listVcs[0].addRow(Object.assign({ id: 'no-results' }, this.noResultsRow));
265
+ listVc.setRows(records.map((record, id) => {
266
+ const row = this.rowTransformer(record.values);
267
+ records[id].rowId = row.id;
268
+ return row;
269
+ }));
266
270
  }
271
+ this.optionallyDropInNoResultsRow();
272
+ this.updatePager(totalPages);
273
+ this.setFooter(Object.assign({}, this.footer));
274
+ }
275
+ updatePager(totalPages) {
276
+ var _a, _b, _c;
267
277
  if (totalPages === 1) {
268
- (_b = this.pagerVc) === null || _b === void 0 ? void 0 : _b.clear();
278
+ (_a = this.pagerVc) === null || _a === void 0 ? void 0 : _a.clear();
269
279
  }
270
280
  else {
271
- (_c = this.pagerVc) === null || _c === void 0 ? void 0 : _c.setTotalPages(totalPages);
281
+ (_b = this.pagerVc) === null || _b === void 0 ? void 0 : _b.setTotalPages(totalPages);
272
282
  const currentPage = this.pagerVc.getCurrentPage();
273
- (_d = this.pagerVc) === null || _d === void 0 ? void 0 : _d.setCurrentPage(currentPage === -1 ? 0 : currentPage);
283
+ (_c = this.pagerVc) === null || _c === void 0 ? void 0 : _c.setCurrentPage(currentPage === -1 ? 0 : currentPage);
284
+ }
285
+ }
286
+ optionallyDropInNoResultsRow() {
287
+ if (this.records.length === 0) {
288
+ this.listVcs[0].addRow(Object.assign({ id: 'no-results' }, this.noResultsRow));
274
289
  }
275
- this.setFooter(Object.assign({}, this.footer));
276
290
  }
277
291
  clear() {
278
292
  var _a;
@@ -306,7 +320,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
306
320
  if (!this.getIsLoaded()) {
307
321
  throw new Error(`You have to load your activeRecordCard before you can get records from it.`);
308
322
  }
309
- return (_b = (_a = this.listVc) === null || _a === void 0 ? void 0 : _a.getRecords()) !== null && _b !== void 0 ? _b : this.records;
323
+ return (_b = (_a = this.listVc) === null || _a === void 0 ? void 0 : _a.getRecords()) !== null && _b !== void 0 ? _b : this.records.map((r) => r.values);
310
324
  }
311
325
  upsertRow(id, row) {
312
326
  var _a, _b;
@@ -339,7 +353,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
339
353
  deleteRow(id) {
340
354
  var _a, _b;
341
355
  (_a = this.listVc) === null || _a === void 0 ? void 0 : _a.deleteRow(id);
342
- this.records = this.records.filter((r) => r.id !== id);
356
+ this.records = this.records.filter((r) => r.rowId !== id && r.values.id !== id);
343
357
  (_b = this.swipeVc) === null || _b === void 0 ? void 0 : _b.renderOnceSync(() => this.rebuildSlidesForPaging());
344
358
  }
345
359
  setIsBusy(isBusy) {
@@ -43,6 +43,8 @@ export default class ActiveRecordCardViewController extends AbstractViewControll
43
43
  private clearFooter;
44
44
  private dropInErrorRow;
45
45
  protected rebuildSlidesForPaging(): void;
46
+ private updatePager;
47
+ private optionallyDropInNoResultsRow;
46
48
  private clear;
47
49
  private get pageSize();
48
50
  private addList;
@@ -85,7 +85,7 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
85
85
  else {
86
86
  this.records = this.allRecords ?? [];
87
87
  }
88
- this.listVc?.setRecords(this.records);
88
+ this.listVc?.setRecords(this.records.map((r) => r.values));
89
89
  this.rebuildSlidesForPaging();
90
90
  }
91
91
  filterRecords(search) {
@@ -99,7 +99,7 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
99
99
  this.records = matches;
100
100
  }
101
101
  doesRecordMatch(record, search) {
102
- const searchable = Object.values(record).join('').toLowerCase();
102
+ const searchable = Object.values(record.values).join('').toLowerCase();
103
103
  const doesMatch = searchable.includes(search.toLowerCase());
104
104
  return doesMatch;
105
105
  }
@@ -189,13 +189,16 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
189
189
  }
190
190
  if (this.listVc) {
191
191
  await this.listVc?.load();
192
- this.allRecords = this.listVc.getRecords();
192
+ this.allRecords = this.listVc.getRecords().map((r) => ({
193
+ values: r,
194
+ }));
193
195
  }
194
196
  this.cardVc.setIsBusy(false);
195
197
  }
196
198
  async fetchRecordsAndDropInRows() {
197
199
  try {
198
- this.records = await this.fetcher.fetchRecords();
200
+ const records = await this.fetcher.fetchRecords();
201
+ this.records = records.map((record) => ({ values: record }));
199
202
  this.allRecords = [...this.records];
200
203
  this.rebuildSlidesForPaging();
201
204
  }
@@ -242,14 +245,19 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
242
245
  for (let i = 0; i < totalPages; i++) {
243
246
  const records = chunkedRecords[i] ?? [];
244
247
  const listVc = this.addList(i);
245
- listVc.setRows(records.map((record) => this.rowTransformer(record)));
246
- }
247
- if (this.records.length === 0) {
248
- this.listVcs[0].addRow({
249
- id: 'no-results',
250
- ...this.noResultsRow,
251
- });
252
- }
248
+ listVc.setRows(records.map((record, id) => {
249
+ const row = this.rowTransformer(record.values);
250
+ records[id].rowId = row.id;
251
+ return row;
252
+ }));
253
+ }
254
+ this.optionallyDropInNoResultsRow();
255
+ this.updatePager(totalPages);
256
+ this.setFooter({
257
+ ...this.footer,
258
+ });
259
+ }
260
+ updatePager(totalPages) {
253
261
  if (totalPages === 1) {
254
262
  this.pagerVc?.clear();
255
263
  }
@@ -258,9 +266,14 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
258
266
  const currentPage = this.pagerVc.getCurrentPage();
259
267
  this.pagerVc?.setCurrentPage(currentPage === -1 ? 0 : currentPage);
260
268
  }
261
- this.setFooter({
262
- ...this.footer,
263
- });
269
+ }
270
+ optionallyDropInNoResultsRow() {
271
+ if (this.records.length === 0) {
272
+ this.listVcs[0].addRow({
273
+ id: 'no-results',
274
+ ...this.noResultsRow,
275
+ });
276
+ }
264
277
  }
265
278
  clear() {
266
279
  this.swipeVc?.setSections([]);
@@ -290,7 +303,7 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
290
303
  if (!this.getIsLoaded()) {
291
304
  throw new Error(`You have to load your activeRecordCard before you can get records from it.`);
292
305
  }
293
- return this.listVc?.getRecords() ?? this.records;
306
+ return this.listVc?.getRecords() ?? this.records.map((r) => r.values);
294
307
  }
295
308
  upsertRow(id, row) {
296
309
  if (!this.getIsLoaded()) {
@@ -321,7 +334,7 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
321
334
  }
322
335
  deleteRow(id) {
323
336
  this.listVc?.deleteRow(id);
324
- this.records = this.records.filter((r) => r.id !== id);
337
+ this.records = this.records.filter((r) => r.rowId !== id && r.values.id !== id);
325
338
  this.swipeVc?.renderOnceSync(() => this.rebuildSlidesForPaging());
326
339
  }
327
340
  setIsBusy(isBusy) {
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "sideEffects": false,
14
14
  "license": "MIT",
15
15
  "description": "All the power of Heartwood in one, convenient package.",
16
- "version": "116.0.29",
16
+ "version": "116.0.30",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {