@protobase/schema 0.22.2 → 0.22.4
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 +4 -2
- 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. */
|
|
@@ -560,8 +562,8 @@ export type RelatedColumnModel = {
|
|
|
560
562
|
/** The enum field of `resource` whose value colours each dot, by its view's `valueColors`. */
|
|
561
563
|
status: string;
|
|
562
564
|
};
|
|
563
|
-
/** A button of a date range filter: today, yesterday, the last 7, 30 or 90 days, or this month, quarter or year. */
|
|
564
|
-
export type DatePreset = 'today' | 'yesterday' | '7d' | '30d' | '90d' | 'month' | 'quarter' | 'year';
|
|
565
|
+
/** A button of a date range filter: today, yesterday, the last 24 hours, 7, 30 or 90 days, or this month, quarter or year. */
|
|
566
|
+
export type DatePreset = 'today' | 'yesterday' | '24h' | '7d' | '30d' | '90d' | 'month' | 'quarter' | 'year';
|
|
565
567
|
/**
|
|
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).
|
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 }
|