@protobase/schema 0.12.20 → 0.12.22
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/dist/model.d.ts +14 -2
- package/dist/view-displays.d.ts +18 -3
- package/dist/view-displays.js +35 -11
- package/package.json +1 -1
package/dist/model.d.ts
CHANGED
|
@@ -140,8 +140,10 @@ export type FieldWidgetModel = {
|
|
|
140
140
|
};
|
|
141
141
|
/**
|
|
142
142
|
* A way to show a list besides its table: a card per record, its content the built-in one or a component's (`card`),
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* a map of the records at their `latitude` and `longitude`, each opening the card of the cards display named `cards`
|
|
144
|
+
* (`map`), or a project component (`custom`) drawing the rows the list page loads. A card's `amount` is the first of its fields with
|
|
145
|
+
* a value, `footer` its fields with a value joined by bullets, and `flags` boolean fields shown as small badges of their
|
|
146
|
+
* labels when true. `name` is what the address names (`?display=cards`); `label` and `icon` are its switch's.
|
|
145
147
|
*/
|
|
146
148
|
export type ListDisplayModel = {
|
|
147
149
|
kind: 'cards';
|
|
@@ -151,11 +153,21 @@ export type ListDisplayModel = {
|
|
|
151
153
|
image?: string;
|
|
152
154
|
title?: string;
|
|
153
155
|
subtitle?: string;
|
|
156
|
+
amount?: string[];
|
|
154
157
|
badge?: string;
|
|
155
158
|
meta?: string[];
|
|
159
|
+
footer?: string[];
|
|
156
160
|
flags?: string[];
|
|
157
161
|
card?: string;
|
|
158
162
|
photos?: CardPhotosModel;
|
|
163
|
+
} | {
|
|
164
|
+
kind: 'map';
|
|
165
|
+
name: string;
|
|
166
|
+
label?: string;
|
|
167
|
+
icon?: string;
|
|
168
|
+
latitude: string;
|
|
169
|
+
longitude: string;
|
|
170
|
+
cards?: string;
|
|
159
171
|
} | {
|
|
160
172
|
kind: 'custom';
|
|
161
173
|
name: string;
|
package/dist/view-displays.d.ts
CHANGED
|
@@ -18,8 +18,9 @@ export declare const tableDisplay = "table";
|
|
|
18
18
|
export declare const displays: {
|
|
19
19
|
/**
|
|
20
20
|
* A card per record: `image`, a file field shown as a picture across the card's top, then `title` (default: the
|
|
21
|
-
* view's title) over `subtitle`, `badge` drawn as a badge with its value labels,
|
|
22
|
-
*
|
|
21
|
+
* view's title) over `subtitle`, `badge` drawn as a badge with its value labels, `amount` the first of its fields with a
|
|
22
|
+
* value in bold, such as a purchase price or a rent, and a few small `meta` fields such as dates. `footer` is a line at
|
|
23
|
+
* the card's bottom of its fields with a value, joined by bullets. `flags` are boolean fields shown as small badges of their labels when true, such as a garden or parking.
|
|
23
24
|
* With `card`, a component of the project or a plugin draws each card's content instead, from the row of those
|
|
24
25
|
* fields (`{ row }`); without it, or when it throws, the card is the built-in one. With `photos`, the built-in card's
|
|
25
26
|
* picture gets arrows through the `image` of the records of another resource that point at the card's record, after
|
|
@@ -29,13 +30,27 @@ export declare const displays: {
|
|
|
29
30
|
image?: Ref;
|
|
30
31
|
title?: Ref;
|
|
31
32
|
subtitle?: Ref;
|
|
33
|
+
amount?: Ref[];
|
|
32
34
|
badge?: Ref;
|
|
33
35
|
meta?: Ref[];
|
|
36
|
+
footer?: Ref[];
|
|
34
37
|
flags?: Ref[];
|
|
35
38
|
}, o?: Naming & {
|
|
36
39
|
card?: ComponentRef<never>;
|
|
37
40
|
photos?: CardPhotosModel;
|
|
38
41
|
}) => ListDisplayModel;
|
|
42
|
+
/**
|
|
43
|
+
* A map of the records at their `latitude` and `longitude`, in decimal degrees, drawn with the app's map style. A
|
|
44
|
+
* marker stands for the records that lie close together at the zoom; choosing it shows their card at the map's bottom,
|
|
45
|
+
* with arrows through them. The card is the one of the cards display named `cards`, the list's first cards display
|
|
46
|
+
* when it names none, or the record's title alone without one. Named `map` unless `name` says otherwise.
|
|
47
|
+
*/
|
|
48
|
+
map: (fields: {
|
|
49
|
+
latitude: Ref;
|
|
50
|
+
longitude: Ref;
|
|
51
|
+
}, o?: Naming & {
|
|
52
|
+
cards?: string;
|
|
53
|
+
}) => ListDisplayModel;
|
|
39
54
|
/**
|
|
40
55
|
* The list drawn by a component of the project, registered in `protobase.ui.tsx` under its name. It gets `props` and
|
|
41
56
|
* reads the rows with `useListDisplay()`; `fields` are the fields it shows, fetched with relation names.
|
|
@@ -47,6 +62,6 @@ export declare const displays: {
|
|
|
47
62
|
props?: ViewProps<P>;
|
|
48
63
|
}) => ListDisplayModel;
|
|
49
64
|
};
|
|
50
|
-
/** Every field a display names: what it shows, and the field references in a custom display's props. */
|
|
65
|
+
/** Every field a display names: what it shows, a map's position, and the field references in a custom display's props. */
|
|
51
66
|
export declare const displayFields: (display: ListDisplayModel) => string[];
|
|
52
67
|
//#endregion
|
package/dist/view-displays.js
CHANGED
|
@@ -14,8 +14,9 @@ const customComponent = (component, where) => {
|
|
|
14
14
|
const displays = {
|
|
15
15
|
/**
|
|
16
16
|
* A card per record: `image`, a file field shown as a picture across the card's top, then `title` (default: the
|
|
17
|
-
* view's title) over `subtitle`, `badge` drawn as a badge with its value labels,
|
|
18
|
-
*
|
|
17
|
+
* view's title) over `subtitle`, `badge` drawn as a badge with its value labels, `amount` the first of its fields with a
|
|
18
|
+
* value in bold, such as a purchase price or a rent, and a few small `meta` fields such as dates. `footer` is a line at
|
|
19
|
+
* the card's bottom of its fields with a value, joined by bullets. `flags` are boolean fields shown as small badges of their labels when true, such as a garden or parking.
|
|
19
20
|
* With `card`, a component of the project or a plugin draws each card's content instead, from the row of those
|
|
20
21
|
* fields (`{ row }`); without it, or when it throws, the card is the built-in one. With `photos`, the built-in card's
|
|
21
22
|
* picture gets arrows through the `image` of the records of another resource that point at the card's record, after
|
|
@@ -28,13 +29,29 @@ const displays = {
|
|
|
28
29
|
...fields.image && { image: fields.image.name },
|
|
29
30
|
...fields.title && { title: fields.title.name },
|
|
30
31
|
...fields.subtitle && { subtitle: fields.subtitle.name },
|
|
32
|
+
...fields.amount && { amount: fields.amount.map((ref) => ref.name) },
|
|
31
33
|
...fields.badge && { badge: fields.badge.name },
|
|
32
34
|
...fields.meta && { meta: fields.meta.map((ref) => ref.name) },
|
|
35
|
+
...fields.footer && { footer: fields.footer.map((ref) => ref.name) },
|
|
33
36
|
...fields.flags && { flags: fields.flags.map((ref) => ref.name) },
|
|
34
37
|
...o.card && { card: customComponent(o.card, "d.cards card") },
|
|
35
38
|
...o.photos && { photos: { ...o.photos } }
|
|
36
39
|
}),
|
|
37
40
|
/**
|
|
41
|
+
* A map of the records at their `latitude` and `longitude`, in decimal degrees, drawn with the app's map style. A
|
|
42
|
+
* marker stands for the records that lie close together at the zoom; choosing it shows their card at the map's bottom,
|
|
43
|
+
* with arrows through them. The card is the one of the cards display named `cards`, the list's first cards display
|
|
44
|
+
* when it names none, or the record's title alone without one. Named `map` unless `name` says otherwise.
|
|
45
|
+
*/
|
|
46
|
+
map: (fields, o = {}) => ({
|
|
47
|
+
kind: "map",
|
|
48
|
+
name: o.name ?? "map",
|
|
49
|
+
...naming(o),
|
|
50
|
+
latitude: fields.latitude.name,
|
|
51
|
+
longitude: fields.longitude.name,
|
|
52
|
+
...o.cards !== void 0 && { cards: o.cards }
|
|
53
|
+
}),
|
|
54
|
+
/**
|
|
38
55
|
* The list drawn by a component of the project, registered in `protobase.ui.tsx` under its name. It gets `props` and
|
|
39
56
|
* reads the rows with `useListDisplay()`; `fields` are the fields it shows, fetched with relation names.
|
|
40
57
|
*/
|
|
@@ -56,17 +73,24 @@ const displayErrors = (list) => {
|
|
|
56
73
|
...names.filter((name) => !displayName.test(name)).map((name) => `display name "${name}" must start with a lowercase letter and hold only letters, digits and dashes`),
|
|
57
74
|
...names.filter((name) => name === tableDisplay).map(() => `"${tableDisplay}" is the list's own display; give the display another name`),
|
|
58
75
|
...names.filter((name, index) => names.indexOf(name) !== index).map((name) => `display "${name}" is defined twice`),
|
|
76
|
+
...(list.displays ?? []).flatMap((display) => display.kind === "map" && display.cards !== void 0 && !list.displays.some((other) => other.kind === "cards" && other.name === display.cards) ? [`display "${display.name}" names cards "${display.cards}", which is not a cards display of the list`] : []),
|
|
59
77
|
...list.default === void 0 || list.default === "table" || names.includes(list.default) ? [] : [`default "${list.default}" is not one of the displays (${[tableDisplay, ...names].join(", ")})`]
|
|
60
78
|
];
|
|
61
79
|
};
|
|
62
|
-
/** Every field a display names: what it shows, and the field references in a custom display's props. */
|
|
63
|
-
const displayFields = (display) =>
|
|
64
|
-
display.
|
|
65
|
-
display.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
/** Every field a display names: what it shows, a map's position, and the field references in a custom display's props. */
|
|
81
|
+
const displayFields = (display) => {
|
|
82
|
+
if (display.kind === "map") return [display.latitude, display.longitude];
|
|
83
|
+
if (display.kind === "custom") return [...display.fields, ...fieldRefsIn(display.props)];
|
|
84
|
+
return [
|
|
85
|
+
display.image,
|
|
86
|
+
display.title,
|
|
87
|
+
display.subtitle,
|
|
88
|
+
...display.amount ?? [],
|
|
89
|
+
display.badge,
|
|
90
|
+
...display.meta ?? [],
|
|
91
|
+
...display.footer ?? [],
|
|
92
|
+
...display.flags ?? []
|
|
93
|
+
].filter((name) => name !== void 0);
|
|
94
|
+
};
|
|
71
95
|
//#endregion
|
|
72
96
|
export { customComponent, displayErrors, displayFields, displays, tableDisplay };
|