@sprucelabs/heartwood-view-controllers 126.8.0 → 126.8.2
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/esm/tests/utilities/buttonAssert.js +4 -0
- package/build/esm/tests/utilities/listAssert.d.ts +12 -0
- package/build/esm/tests/utilities/listAssert.js +22 -0
- package/build/esm/viewControllers/LoginCard.vc.js +7 -7
- package/build/esm/viewControllers/list/List.vc.d.ts +3 -1
- package/build/esm/viewControllers/list/List.vc.js +15 -3
- package/build/tests/utilities/buttonAssert.js +3 -0
- package/build/tests/utilities/listAssert.d.ts +12 -0
- package/build/tests/utilities/listAssert.js +22 -0
- package/build/viewControllers/LoginCard.vc.js +7 -7
- package/build/viewControllers/list/List.vc.d.ts +3 -1
- package/build/viewControllers/list/List.vc.js +12 -2
- package/package.json +1 -1
|
@@ -154,6 +154,10 @@ function pluckButtonsFromViewModel(model, ids) {
|
|
|
154
154
|
var _a, _b;
|
|
155
155
|
buttons.push(...((_b = (_a = f === null || f === void 0 ? void 0 : f.footer) === null || _a === void 0 ? void 0 : _a.buttons) !== null && _b !== void 0 ? _b : []));
|
|
156
156
|
});
|
|
157
|
+
pluckAllFromView(model, 'bigForm').forEach((f) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
buttons.push(...((_b = (_a = f === null || f === void 0 ? void 0 : f.footer) === null || _a === void 0 ? void 0 : _a.buttons) !== null && _b !== void 0 ? _b : []));
|
|
160
|
+
});
|
|
157
161
|
pluckAllFromView(model, 'buttonBar').forEach((f) => {
|
|
158
162
|
var _a;
|
|
159
163
|
buttons.push(...((_a = f === null || f === void 0 ? void 0 : f.buttons) !== null && _a !== void 0 ? _a : []));
|
|
@@ -41,5 +41,17 @@ declare const listAssert: {
|
|
|
41
41
|
rowRendersRatings(listVc: ViewController<List>, row: string | number): void;
|
|
42
42
|
checkboxTogglesRowEnabled(listVc: ViewController<List>, row: string | number): Promise<void>;
|
|
43
43
|
rowIsStyle(vc: ViewController<List>, row: string | number, style: RowStyle): void;
|
|
44
|
+
valueEquals(options: {
|
|
45
|
+
listVc: ViewController<List>;
|
|
46
|
+
row: string | number;
|
|
47
|
+
name: string;
|
|
48
|
+
value: any;
|
|
49
|
+
}): void;
|
|
50
|
+
valueDoesNotEqual(options: {
|
|
51
|
+
listVc: ViewController<List>;
|
|
52
|
+
row: string | number;
|
|
53
|
+
name: string;
|
|
54
|
+
value: any;
|
|
55
|
+
}): void;
|
|
44
56
|
};
|
|
45
57
|
export default listAssert;
|
|
@@ -394,6 +394,28 @@ const listAssert = {
|
|
|
394
394
|
const actual = (_a = view.style) !== null && _a !== void 0 ? _a : 'standard';
|
|
395
395
|
assert.isEqual(actual, style, `You row is the wrong style! I expected it to be '${style}', but found '${actual}'!`);
|
|
396
396
|
},
|
|
397
|
+
valueEquals(options) {
|
|
398
|
+
const { listVc, row, name, value } = assertOptions(options, [
|
|
399
|
+
'listVc',
|
|
400
|
+
'row',
|
|
401
|
+
'name',
|
|
402
|
+
'value',
|
|
403
|
+
]);
|
|
404
|
+
const rowVc = getListVc(listVc).getRowVc(row);
|
|
405
|
+
const actual = rowVc.getValue(name);
|
|
406
|
+
assert.isEqual(actual, value, `The value of '${name}' in row '${row}' does not equal the expected value.`);
|
|
407
|
+
},
|
|
408
|
+
valueDoesNotEqual(options) {
|
|
409
|
+
const { listVc, row, name, value } = assertOptions(options, [
|
|
410
|
+
'listVc',
|
|
411
|
+
'row',
|
|
412
|
+
'name',
|
|
413
|
+
'value',
|
|
414
|
+
]);
|
|
415
|
+
const rowVc = getListVc(listVc).getRowVc(row);
|
|
416
|
+
const actual = rowVc.getValue(name);
|
|
417
|
+
assert.isNotEqual(actual, value, `The value of '${name}' in row '${row}' equals the expected value when it should not.`);
|
|
418
|
+
},
|
|
397
419
|
};
|
|
398
420
|
export default listAssert;
|
|
399
421
|
function findList(vc, id) {
|
|
@@ -40,11 +40,6 @@ class LoginCardViewController extends AbstractViewController {
|
|
|
40
40
|
},
|
|
41
41
|
],
|
|
42
42
|
},
|
|
43
|
-
footer: this.shouldAllowEmailLogin
|
|
44
|
-
? {
|
|
45
|
-
buttons: [this.renderLoginWithEmailButton()],
|
|
46
|
-
}
|
|
47
|
-
: null,
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
renderLoginWithEmailButton() {
|
|
@@ -61,7 +56,7 @@ class LoginCardViewController extends AbstractViewController {
|
|
|
61
56
|
title: this.renderEmailSlideTitle(),
|
|
62
57
|
fields: ['email'],
|
|
63
58
|
});
|
|
64
|
-
this.
|
|
59
|
+
this.bigFormVc.setFooter({
|
|
65
60
|
buttons: [this.renderLoginWithPhoneButton()],
|
|
66
61
|
});
|
|
67
62
|
});
|
|
@@ -77,7 +72,7 @@ class LoginCardViewController extends AbstractViewController {
|
|
|
77
72
|
handleClickLoginWithPhone() {
|
|
78
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
74
|
this.bigFormVc.updateSection(0, this.renderPhoneSection());
|
|
80
|
-
this.
|
|
75
|
+
this.bigFormVc.setFooter({
|
|
81
76
|
buttons: [this.renderLoginWithEmailButton()],
|
|
82
77
|
});
|
|
83
78
|
});
|
|
@@ -122,6 +117,11 @@ class LoginCardViewController extends AbstractViewController {
|
|
|
122
117
|
fields: [{ name: 'code', renderAs: 'number' }],
|
|
123
118
|
},
|
|
124
119
|
],
|
|
120
|
+
footer: this.shouldAllowEmailLogin
|
|
121
|
+
? {
|
|
122
|
+
buttons: [this.renderLoginWithEmailButton()],
|
|
123
|
+
}
|
|
124
|
+
: null,
|
|
125
125
|
}));
|
|
126
126
|
}
|
|
127
127
|
renderPhoneSection() {
|
|
@@ -17,9 +17,11 @@ export default class ListViewController extends AbstractViewController<SpruceSch
|
|
|
17
17
|
private assertValidRowIdx;
|
|
18
18
|
getTotalRows(): number;
|
|
19
19
|
private getRowValues;
|
|
20
|
-
private
|
|
20
|
+
private _setValue;
|
|
21
21
|
getRowVcs(): ListRowViewController[];
|
|
22
22
|
getValues(): import("../../types/heartwood.types").RowValues[];
|
|
23
|
+
setValue(row: string | number, name: string, value: any): Promise<void>;
|
|
24
|
+
getValue(row: string | number, name: string): any;
|
|
23
25
|
setRows(rows: ListRow[]): void;
|
|
24
26
|
deleteRow(rowIdx: number | string): void;
|
|
25
27
|
private getRowVcById;
|
|
@@ -18,7 +18,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
-
import { SchemaError } from '@sprucelabs/schema';
|
|
21
|
+
import { assertOptions, SchemaError } from '@sprucelabs/schema';
|
|
22
22
|
import SpruceError from '../../errors/SpruceError.js';
|
|
23
23
|
import AbstractViewController from '../Abstract.vc.js';
|
|
24
24
|
import listUtil from './list.utility.js';
|
|
@@ -113,7 +113,7 @@ export default class ListViewController extends AbstractViewController {
|
|
|
113
113
|
this.model.rows[idx].isEnabled = is;
|
|
114
114
|
}, setValue: (name, value) => __awaiter(this, void 0, void 0, function* () {
|
|
115
115
|
const idx = this.getIdxForId(id);
|
|
116
|
-
yield this.
|
|
116
|
+
yield this._setValue({ rowIdx: idx, name, value });
|
|
117
117
|
}), getValues: () => {
|
|
118
118
|
const idx = this.getIdxForId(id);
|
|
119
119
|
return this.getRowValues(idx);
|
|
@@ -152,7 +152,7 @@ export default class ListViewController extends AbstractViewController {
|
|
|
152
152
|
}
|
|
153
153
|
return values;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
_setValue(options) {
|
|
156
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
157
|
var _a;
|
|
158
158
|
const { rowIdx, name, value } = options;
|
|
@@ -190,6 +190,18 @@ export default class ListViewController extends AbstractViewController {
|
|
|
190
190
|
}
|
|
191
191
|
return values;
|
|
192
192
|
}
|
|
193
|
+
setValue(row, name, value) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
assertOptions({ row, name, value }, ['row', 'name', 'value']);
|
|
196
|
+
const rowVc = this.getRowVc(row);
|
|
197
|
+
yield rowVc.setValue(name, value);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
getValue(row, name) {
|
|
201
|
+
assertOptions({ row, name }, ['row', 'name']);
|
|
202
|
+
const rowVc = this.getRowVc(row);
|
|
203
|
+
return rowVc.getValue(name);
|
|
204
|
+
}
|
|
193
205
|
setRows(rows) {
|
|
194
206
|
this.model.rows = rows;
|
|
195
207
|
this._rowVcs = [];
|
|
@@ -151,6 +151,9 @@ function pluckButtonsFromViewModel(model, ids) {
|
|
|
151
151
|
(0, assertSupport_1.pluckAllFromView)(model, 'form').forEach((f) => {
|
|
152
152
|
buttons.push(...(f?.footer?.buttons ?? []));
|
|
153
153
|
});
|
|
154
|
+
(0, assertSupport_1.pluckAllFromView)(model, 'bigForm').forEach((f) => {
|
|
155
|
+
buttons.push(...(f?.footer?.buttons ?? []));
|
|
156
|
+
});
|
|
154
157
|
(0, assertSupport_1.pluckAllFromView)(model, 'buttonBar').forEach((f) => {
|
|
155
158
|
buttons.push(...(f?.buttons ?? []));
|
|
156
159
|
});
|
|
@@ -41,5 +41,17 @@ declare const listAssert: {
|
|
|
41
41
|
rowRendersRatings(listVc: ViewController<List>, row: string | number): void;
|
|
42
42
|
checkboxTogglesRowEnabled(listVc: ViewController<List>, row: string | number): Promise<void>;
|
|
43
43
|
rowIsStyle(vc: ViewController<List>, row: string | number, style: RowStyle): void;
|
|
44
|
+
valueEquals(options: {
|
|
45
|
+
listVc: ViewController<List>;
|
|
46
|
+
row: string | number;
|
|
47
|
+
name: string;
|
|
48
|
+
value: any;
|
|
49
|
+
}): void;
|
|
50
|
+
valueDoesNotEqual(options: {
|
|
51
|
+
listVc: ViewController<List>;
|
|
52
|
+
row: string | number;
|
|
53
|
+
name: string;
|
|
54
|
+
value: any;
|
|
55
|
+
}): void;
|
|
44
56
|
};
|
|
45
57
|
export default listAssert;
|
|
@@ -373,6 +373,28 @@ const listAssert = {
|
|
|
373
373
|
const actual = view.style ?? 'standard';
|
|
374
374
|
test_utils_1.assert.isEqual(actual, style, `You row is the wrong style! I expected it to be '${style}', but found '${actual}'!`);
|
|
375
375
|
},
|
|
376
|
+
valueEquals(options) {
|
|
377
|
+
const { listVc, row, name, value } = (0, schema_1.assertOptions)(options, [
|
|
378
|
+
'listVc',
|
|
379
|
+
'row',
|
|
380
|
+
'name',
|
|
381
|
+
'value',
|
|
382
|
+
]);
|
|
383
|
+
const rowVc = getListVc(listVc).getRowVc(row);
|
|
384
|
+
const actual = rowVc.getValue(name);
|
|
385
|
+
test_utils_1.assert.isEqual(actual, value, `The value of '${name}' in row '${row}' does not equal the expected value.`);
|
|
386
|
+
},
|
|
387
|
+
valueDoesNotEqual(options) {
|
|
388
|
+
const { listVc, row, name, value } = (0, schema_1.assertOptions)(options, [
|
|
389
|
+
'listVc',
|
|
390
|
+
'row',
|
|
391
|
+
'name',
|
|
392
|
+
'value',
|
|
393
|
+
]);
|
|
394
|
+
const rowVc = getListVc(listVc).getRowVc(row);
|
|
395
|
+
const actual = rowVc.getValue(name);
|
|
396
|
+
test_utils_1.assert.isNotEqual(actual, value, `The value of '${name}' in row '${row}' equals the expected value when it should not.`);
|
|
397
|
+
},
|
|
376
398
|
};
|
|
377
399
|
exports.default = listAssert;
|
|
378
400
|
function findList(vc, id) {
|
|
@@ -36,11 +36,6 @@ class LoginCardViewController extends Abstract_vc_1.default {
|
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
},
|
|
39
|
-
footer: this.shouldAllowEmailLogin
|
|
40
|
-
? {
|
|
41
|
-
buttons: [this.renderLoginWithEmailButton()],
|
|
42
|
-
}
|
|
43
|
-
: null,
|
|
44
39
|
});
|
|
45
40
|
}
|
|
46
41
|
renderLoginWithEmailButton() {
|
|
@@ -56,7 +51,7 @@ class LoginCardViewController extends Abstract_vc_1.default {
|
|
|
56
51
|
title: this.renderEmailSlideTitle(),
|
|
57
52
|
fields: ['email'],
|
|
58
53
|
});
|
|
59
|
-
this.
|
|
54
|
+
this.bigFormVc.setFooter({
|
|
60
55
|
buttons: [this.renderLoginWithPhoneButton()],
|
|
61
56
|
});
|
|
62
57
|
}
|
|
@@ -70,7 +65,7 @@ class LoginCardViewController extends Abstract_vc_1.default {
|
|
|
70
65
|
}
|
|
71
66
|
async handleClickLoginWithPhone() {
|
|
72
67
|
this.bigFormVc.updateSection(0, this.renderPhoneSection());
|
|
73
|
-
this.
|
|
68
|
+
this.bigFormVc.setFooter({
|
|
74
69
|
buttons: [this.renderLoginWithEmailButton()],
|
|
75
70
|
});
|
|
76
71
|
}
|
|
@@ -114,6 +109,11 @@ class LoginCardViewController extends Abstract_vc_1.default {
|
|
|
114
109
|
fields: [{ name: 'code', renderAs: 'number' }],
|
|
115
110
|
},
|
|
116
111
|
],
|
|
112
|
+
footer: this.shouldAllowEmailLogin
|
|
113
|
+
? {
|
|
114
|
+
buttons: [this.renderLoginWithEmailButton()],
|
|
115
|
+
}
|
|
116
|
+
: null,
|
|
117
117
|
}));
|
|
118
118
|
}
|
|
119
119
|
renderPhoneSection() {
|
|
@@ -17,9 +17,11 @@ export default class ListViewController extends AbstractViewController<SpruceSch
|
|
|
17
17
|
private assertValidRowIdx;
|
|
18
18
|
getTotalRows(): number;
|
|
19
19
|
private getRowValues;
|
|
20
|
-
private
|
|
20
|
+
private _setValue;
|
|
21
21
|
getRowVcs(): ListRowViewController[];
|
|
22
22
|
getValues(): import("../../types/heartwood.types").RowValues[];
|
|
23
|
+
setValue(row: string | number, name: string, value: any): Promise<void>;
|
|
24
|
+
getValue(row: string | number, name: string): any;
|
|
23
25
|
setRows(rows: ListRow[]): void;
|
|
24
26
|
deleteRow(rowIdx: number | string): void;
|
|
25
27
|
private getRowVcById;
|
|
@@ -102,7 +102,7 @@ class ListViewController extends Abstract_vc_1.default {
|
|
|
102
102
|
},
|
|
103
103
|
setValue: async (name, value) => {
|
|
104
104
|
const idx = this.getIdxForId(id);
|
|
105
|
-
await this.
|
|
105
|
+
await this._setValue({ rowIdx: idx, name, value });
|
|
106
106
|
},
|
|
107
107
|
getValues: () => {
|
|
108
108
|
const idx = this.getIdxForId(id);
|
|
@@ -146,7 +146,7 @@ class ListViewController extends Abstract_vc_1.default {
|
|
|
146
146
|
}
|
|
147
147
|
return values;
|
|
148
148
|
}
|
|
149
|
-
async
|
|
149
|
+
async _setValue(options) {
|
|
150
150
|
const { rowIdx, name, value } = options;
|
|
151
151
|
for (const cell of this.model.rows[rowIdx].cells) {
|
|
152
152
|
const input = list_utility_1.default.getInputFromCell(cell);
|
|
@@ -181,6 +181,16 @@ class ListViewController extends Abstract_vc_1.default {
|
|
|
181
181
|
}
|
|
182
182
|
return values;
|
|
183
183
|
}
|
|
184
|
+
async setValue(row, name, value) {
|
|
185
|
+
(0, schema_1.assertOptions)({ row, name, value }, ['row', 'name', 'value']);
|
|
186
|
+
const rowVc = this.getRowVc(row);
|
|
187
|
+
await rowVc.setValue(name, value);
|
|
188
|
+
}
|
|
189
|
+
getValue(row, name) {
|
|
190
|
+
(0, schema_1.assertOptions)({ row, name }, ['row', 'name']);
|
|
191
|
+
const rowVc = this.getRowVc(row);
|
|
192
|
+
return rowVc.getValue(name);
|
|
193
|
+
}
|
|
184
194
|
setRows(rows) {
|
|
185
195
|
this.model.rows = rows;
|
|
186
196
|
this._rowVcs = [];
|
package/package.json
CHANGED