blob: 5b0899e9410f163b09620361835a4b9169909817 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import {inspect} from 'node:util';
import {colors} from '#cli';
import {V} from '#composite';
import Thing from '#thing';
import {exposeConstant} from '#composite/control-flow';
import {soupyFind, thing} from '#composite/wiki-properties';
export class HomepageLayoutRow extends Thing {
static [Thing.friendlyName] = `Homepage Row`;
static [Thing.getPropertyDescriptors] = ({HomepageLayoutSection}) => ({
// Update & expose
section: thing(V(HomepageLayoutSection)),
// Update only
find: soupyFind(),
// Expose only
isHomepageLayoutRow: exposeConstant(V(true)),
type: {
flags: {expose: true},
expose: {
compute() {
throw new Error(`'type' property validator must be overridden`);
},
},
},
});
static [Thing.yamlDocumentSpec] = {
fields: {
'Row': {ignore: true},
},
};
[inspect.custom](depth) {
const parts = [];
parts.push(Thing.prototype[inspect.custom].apply(this));
if (depth >= 0 && this.section) {
const sectionName = this.section.name;
const index = this.section.rows.indexOf(this);
const rowNum =
(index === -1
? 'indeterminate position'
: `#${index + 1}`);
parts.push(` (${colors.yellow(rowNum)} in ${colors.green(sectionName)})`);
}
return parts.join('');
}
}
|