@protobase/schema 0.22.3 → 0.22.5
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/app-address.d.ts +1 -1
- package/dist/app-address.js +5 -4
- package/dist/model.d.ts +6 -1
- package/dist/view-widgets.d.ts +8 -1
- package/dist/view-widgets.js +12 -6
- package/dist/view.d.ts +2 -1
- package/dist/view.js +3 -2
- package/package.json +1 -1
package/dist/app-address.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { AppAddress } from "./model.js";
|
|
|
5
5
|
* changes in this module alone.
|
|
6
6
|
*/
|
|
7
7
|
export declare const addressWords: {
|
|
8
|
-
/** A list's filter (AIP-160), as the list API takes it. */
|
|
8
|
+
/** A list's filter (AIP-160), as the list API takes it. An empty `filter=` means no filter, in place of the view's default. */
|
|
9
9
|
readonly filter: "filter";
|
|
10
10
|
/** A list's order (AIP-132). */
|
|
11
11
|
readonly orderBy: "order_by";
|
package/dist/app-address.js
CHANGED
|
@@ -5,7 +5,7 @@ import { encodeKey } from "./keys.js";
|
|
|
5
5
|
* changes in this module alone.
|
|
6
6
|
*/
|
|
7
7
|
const addressWords = {
|
|
8
|
-
/** A list's filter (AIP-160), as the list API takes it. */
|
|
8
|
+
/** A list's filter (AIP-160), as the list API takes it. An empty `filter=` means no filter, in place of the view's default. */
|
|
9
9
|
filter: "filter",
|
|
10
10
|
/** A list's order (AIP-132). */
|
|
11
11
|
orderBy: "order_by",
|
|
@@ -66,7 +66,8 @@ const listQuery = (address) => {
|
|
|
66
66
|
const query = new URLSearchParams();
|
|
67
67
|
for (const name of listWords) {
|
|
68
68
|
const value = address[name];
|
|
69
|
-
if (value
|
|
69
|
+
if (value === void 0 || value === "" && name !== "filter") continue;
|
|
70
|
+
query.set(addressWords[name], value);
|
|
70
71
|
}
|
|
71
72
|
if (address.map) query.set(addressWords.map, mapText(address.map));
|
|
72
73
|
if (address.calendar) query.set(addressWords.calendar, calendarText(address.calendar));
|
|
@@ -136,7 +137,7 @@ const readAppPath = (pathAndQuery, pages) => {
|
|
|
136
137
|
}
|
|
137
138
|
const params = url.searchParams;
|
|
138
139
|
const display = params.get(addressWords.display) || void 0;
|
|
139
|
-
const filter = params.get(addressWords.filter)
|
|
140
|
+
const filter = params.get(addressWords.filter) ?? void 0;
|
|
140
141
|
const orderBy = params.get(addressWords.orderBy) || void 0;
|
|
141
142
|
const layout = filterLayout(params.get(addressWords.filterLayout));
|
|
142
143
|
const map = readMap(params.get(addressWords.map));
|
|
@@ -146,7 +147,7 @@ const readAppPath = (pathAndQuery, pages) => {
|
|
|
146
147
|
kind: "list",
|
|
147
148
|
resource: first,
|
|
148
149
|
...display && { display },
|
|
149
|
-
...filter && { filter },
|
|
150
|
+
...filter !== void 0 && { filter },
|
|
150
151
|
...orderBy && { orderBy },
|
|
151
152
|
...layout && { filterLayout: layout },
|
|
152
153
|
...map && { map },
|
package/dist/model.d.ts
CHANGED
|
@@ -523,6 +523,8 @@ export type ListModel = {
|
|
|
523
523
|
columns: string[];
|
|
524
524
|
/** The order the list starts in. */
|
|
525
525
|
sort?: SortSpec;
|
|
526
|
+
/** An AIP-160 filter the list opens with when its address names none; the person can clear or change it, and a link's own filter replaces it. */
|
|
527
|
+
filter?: string;
|
|
526
528
|
/** Defaults for the UI's search box. `ResourceModel.search` is authoritative for what `search(...)` matches on the server. */
|
|
527
529
|
search?: string[];
|
|
528
530
|
/** Other ways to show the list besides its table, in the order the switch shows them after it. */
|
|
@@ -566,7 +568,7 @@ export type DatePreset = 'today' | 'yesterday' | '24h' | '7d' | '30d' | '90d' |
|
|
|
566
568
|
* A filter widget above a list (`.filters((r, w) => ...)`), on a filterable field; see
|
|
567
569
|
* [Filters and the chart](website/src/content/docs/reference/ui-config.mdx#filters-and-the-chart).
|
|
568
570
|
*/
|
|
569
|
-
export type FilterWidgetModel = {
|
|
571
|
+
export type FilterWidgetModel = ({
|
|
570
572
|
/** A slider between the lowest and highest value. */
|
|
571
573
|
kind: 'range';
|
|
572
574
|
/** The field it filters. */
|
|
@@ -599,6 +601,9 @@ export type FilterWidgetModel = {
|
|
|
599
601
|
fields: string[];
|
|
600
602
|
/** The menu's label. */
|
|
601
603
|
label: string;
|
|
604
|
+
}) & {
|
|
605
|
+
/** Shown behind the bar's "More filters" menu until it is picked there or set. */
|
|
606
|
+
secondary?: boolean;
|
|
602
607
|
};
|
|
603
608
|
/**
|
|
604
609
|
* Records of another resource on the record page: those whose `field` holds this record's key or, with `through`,
|
package/dist/view-widgets.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DatePreset, FilterWidgetModel } from "./model.js";
|
|
2
2
|
import { Ref } from "./refs.js";
|
|
3
3
|
//#region src/view-widgets.d.ts
|
|
4
|
+
/** Every widget also takes `secondary: true`, which puts it behind the bar's "More filters" menu until it is picked there or set. */
|
|
4
5
|
export declare const widgets: {
|
|
5
6
|
/** A slider between the field's lowest and highest value; `histogram` draws the values' histogram behind it. */
|
|
6
7
|
range: (ref: Ref, o?: {
|
|
7
8
|
histogram?: boolean;
|
|
9
|
+
secondary?: boolean;
|
|
8
10
|
}) => FilterWidgetModel;
|
|
9
11
|
/**
|
|
10
12
|
* A menu of the field's values with counts; `search` adds a search box for long lists. On a relation it searches the
|
|
@@ -12,19 +14,24 @@ export declare const widgets: {
|
|
|
12
14
|
*/
|
|
13
15
|
facets: (ref: Ref, o?: {
|
|
14
16
|
search?: boolean;
|
|
17
|
+
secondary?: boolean;
|
|
15
18
|
}) => FilterWidgetModel;
|
|
16
19
|
/** A date range with buttons for the `presets`, such as `today` and `30d`. */
|
|
17
20
|
dateRange: (ref: Ref, o?: {
|
|
18
21
|
presets?: DatePreset[];
|
|
22
|
+
secondary?: boolean;
|
|
19
23
|
}) => FilterWidgetModel;
|
|
20
24
|
/** A switch for a boolean field. */
|
|
21
|
-
toggle: (ref: Ref
|
|
25
|
+
toggle: (ref: Ref, o?: {
|
|
26
|
+
secondary?: boolean;
|
|
27
|
+
}) => FilterWidgetModel;
|
|
22
28
|
/**
|
|
23
29
|
* A menu of boolean fields under one `label`, such as "for sale" and "for rent": a record shows when any chosen field
|
|
24
30
|
* is true, so one that is both shows under each.
|
|
25
31
|
*/
|
|
26
32
|
flags: (refs: Ref<string, boolean | null>[], o: {
|
|
27
33
|
label: string;
|
|
34
|
+
secondary?: boolean;
|
|
28
35
|
}) => FilterWidgetModel;
|
|
29
36
|
};
|
|
30
37
|
//#endregion
|
package/dist/view-widgets.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
//#region src/view-widgets.ts
|
|
2
|
+
/** Every widget also takes `secondary: true`, which puts it behind the bar's "More filters" menu until it is picked there or set. */
|
|
2
3
|
const widgets = {
|
|
3
4
|
/** A slider between the field's lowest and highest value; `histogram` draws the values' histogram behind it. */
|
|
4
5
|
range: (ref, o = {}) => ({
|
|
5
6
|
kind: "range",
|
|
6
7
|
field: ref.name,
|
|
7
|
-
histogram: o.histogram ?? false
|
|
8
|
+
histogram: o.histogram ?? false,
|
|
9
|
+
...o.secondary && { secondary: true }
|
|
8
10
|
}),
|
|
9
11
|
/**
|
|
10
12
|
* A menu of the field's values with counts; `search` adds a search box for long lists. On a relation it searches the
|
|
@@ -13,18 +15,21 @@ const widgets = {
|
|
|
13
15
|
facets: (ref, o = {}) => ({
|
|
14
16
|
kind: "facets",
|
|
15
17
|
field: ref.name,
|
|
16
|
-
search: o.search ?? false
|
|
18
|
+
search: o.search ?? false,
|
|
19
|
+
...o.secondary && { secondary: true }
|
|
17
20
|
}),
|
|
18
21
|
/** A date range with buttons for the `presets`, such as `today` and `30d`. */
|
|
19
22
|
dateRange: (ref, o = {}) => ({
|
|
20
23
|
kind: "dateRange",
|
|
21
24
|
field: ref.name,
|
|
22
|
-
presets: o.presets ?? []
|
|
25
|
+
presets: o.presets ?? [],
|
|
26
|
+
...o.secondary && { secondary: true }
|
|
23
27
|
}),
|
|
24
28
|
/** A switch for a boolean field. */
|
|
25
|
-
toggle: (ref) => ({
|
|
29
|
+
toggle: (ref, o = {}) => ({
|
|
26
30
|
kind: "toggle",
|
|
27
|
-
field: ref.name
|
|
31
|
+
field: ref.name,
|
|
32
|
+
...o.secondary && { secondary: true }
|
|
28
33
|
}),
|
|
29
34
|
/**
|
|
30
35
|
* A menu of boolean fields under one `label`, such as "for sale" and "for rent": a record shows when any chosen field
|
|
@@ -33,7 +38,8 @@ const widgets = {
|
|
|
33
38
|
flags: (refs, o) => ({
|
|
34
39
|
kind: "flags",
|
|
35
40
|
fields: refs.map((ref) => ref.name),
|
|
36
|
-
label: o.label
|
|
41
|
+
label: o.label,
|
|
42
|
+
...o.secondary && { secondary: true }
|
|
37
43
|
})
|
|
38
44
|
};
|
|
39
45
|
//#endregion
|
package/dist/view.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class ViewBuilder<R extends {
|
|
|
68
68
|
/** Hints per field, such as `{ total: r.total.prefix('€').decimals(2) }`; calls add up. */
|
|
69
69
|
fields(build: (r: FieldViews<R>) => Record<string, FieldView>): ViewBuilder<R>;
|
|
70
70
|
/**
|
|
71
|
-
* The list: its table's `columns`, fields or columns of related records (`c.related`), `sort` and `
|
|
71
|
+
* The list: its table's `columns`, fields or columns of related records (`c.related`), `sort`, `search` and a `filter` it opens with, the
|
|
72
72
|
* columns that are `editable` in their cell, and other `displays` to switch to (`d.cards`, `d.map`, `d.board`, `d.calendar`, `d.custom`), one of which
|
|
73
73
|
* may be the `default` the list opens in. Throws when display or column names collide, `default` names none or an
|
|
74
74
|
* editable field is not among the columns. See
|
|
@@ -78,6 +78,7 @@ export declare class ViewBuilder<R extends {
|
|
|
78
78
|
columns: Array<Ref | ListColumn>;
|
|
79
79
|
sort?: Array<[Ref, 'asc' | 'desc']>;
|
|
80
80
|
search?: Ref[];
|
|
81
|
+
filter?: string;
|
|
81
82
|
editable?: Ref[];
|
|
82
83
|
displays?: ListDisplayModel[];
|
|
83
84
|
default?: string;
|
package/dist/view.js
CHANGED
|
@@ -75,14 +75,14 @@ var ViewBuilder = class ViewBuilder {
|
|
|
75
75
|
} });
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* The list: its table's `columns`, fields or columns of related records (`c.related`), `sort` and `
|
|
78
|
+
* The list: its table's `columns`, fields or columns of related records (`c.related`), `sort`, `search` and a `filter` it opens with, the
|
|
79
79
|
* columns that are `editable` in their cell, and other `displays` to switch to (`d.cards`, `d.map`, `d.board`, `d.calendar`, `d.custom`), one of which
|
|
80
80
|
* may be the `default` the list opens in. Throws when display or column names collide, `default` names none or an
|
|
81
81
|
* editable field is not among the columns. See
|
|
82
82
|
* [Editing in the list](website/src/content/docs/reference/ui-config.mdx#editing-in-the-list).
|
|
83
83
|
*/
|
|
84
84
|
list(build) {
|
|
85
|
-
const { columns: columns$1, sort, search, editable, displays: shown = [], default: opens } = build(this.refs(), displays, columns);
|
|
85
|
+
const { columns: columns$1, sort, search, filter, editable, displays: shown = [], default: opens } = build(this.refs(), displays, columns);
|
|
86
86
|
const related = columns$1.filter(isListColumn).map(({ kind: _, ...column }) => column);
|
|
87
87
|
const names = columns$1.map((column) => column.name);
|
|
88
88
|
const repeated = names.find((name, index) => names.indexOf(name) !== index);
|
|
@@ -94,6 +94,7 @@ var ViewBuilder = class ViewBuilder {
|
|
|
94
94
|
...related.length > 0 && { relatedColumns: related },
|
|
95
95
|
...sort && { sort: sort.map(([ref, dir]) => [ref.name, dir]) },
|
|
96
96
|
...search && { search: search.map((ref) => ref.name) },
|
|
97
|
+
...filter !== void 0 && filter !== "" && { filter },
|
|
97
98
|
...editable && editable.length > 0 && { editable: editable.map((ref) => ref.name) },
|
|
98
99
|
...shown.length > 0 && { displays: shown },
|
|
99
100
|
...opens !== void 0 && { default: opens }
|