@protobase/ui 0.12.11 → 0.12.12
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/filter-panel/combobox-options.js +12 -0
- package/dist/filter-panel/facet-combobox.js +131 -0
- package/dist/filter-panel/facet-group.js +1 -1
- package/dist/filter-panel/filter-menu.js +7 -2
- package/dist/filter-panel/filter-panel.js +33 -24
- package/dist/filter-panel/filter-state.js +23 -11
- package/dist/filter-panel/range-filter.js +3 -3
- package/dist/index.js +1 -1
- package/dist/live/filter-string.js +18 -9
- package/dist/live/reference-options.js +14 -0
- package/dist/live/use-filter-config.js +64 -37
- package/dist/live/use-reference-search.js +53 -0
- package/dist/live/view-fields.js +31 -14
- package/dist/package.js +1 -1
- package/dist/shell/assets/app-BKltU-WD.js +65 -0
- package/dist/shell/assets/index-CP0s3cFI.css +2 -0
- package/dist/shell/assets/{index-B7XSEKuk.js → index-D1ngvDop.js} +1 -1
- package/dist/shell/assets/{shared-protobase-ui-DhQ8wFhe.js → shared-protobase-ui-Cv4rF2fz.js} +1 -1
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +1 -1
- package/package.json +4 -4
- package/dist/shell/assets/app-B2rZN97s.js +0 -65
- package/dist/shell/assets/index-otHceRXj.css +0 -2
package/dist/live/view-fields.js
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
//#region src/live/view-fields.ts
|
|
2
|
-
|
|
2
|
+
const numberTypes = [
|
|
3
|
+
"integer",
|
|
4
|
+
"bigint",
|
|
5
|
+
"decimal"
|
|
6
|
+
];
|
|
7
|
+
const isNumber = (model, field) => {
|
|
8
|
+
const type = model?.fields[field]?.type;
|
|
9
|
+
return type !== void 0 && numberTypes.includes(type);
|
|
10
|
+
};
|
|
11
|
+
/** A filter on a number field is a range slider, whichever widget the view asked for. */
|
|
12
|
+
const rangeOf = (widget, model) => widget.kind === "range" || widget.kind === "facets" && isNumber(model, widget.field);
|
|
13
|
+
const emptyRange = (field) => ({
|
|
14
|
+
id: field,
|
|
15
|
+
label: field,
|
|
16
|
+
min: 0,
|
|
17
|
+
max: 0,
|
|
18
|
+
step: 1,
|
|
19
|
+
histogram: [],
|
|
20
|
+
format: String
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* The widgets of a view in the shape `filter-string` talks to; options and counts are filled in later. Facets on a
|
|
24
|
+
* reference to another resource's records are a combobox, which searches those records.
|
|
25
|
+
*/
|
|
3
26
|
const widgetFields = (view, model) => {
|
|
4
27
|
const widgets = view?.filters ?? [];
|
|
5
|
-
const range = widgets.find((widget) => widget.kind === "range");
|
|
6
28
|
const date = widgets.find((widget) => widget.kind === "dateRange");
|
|
7
29
|
return {
|
|
8
|
-
facets: widgets.flatMap((widget) => widget.kind === "facets" ? [{
|
|
30
|
+
facets: widgets.flatMap((widget) => widget.kind === "facets" && !rangeOf(widget, model) ? [{
|
|
9
31
|
id: widget.field,
|
|
10
32
|
label: widget.field,
|
|
11
33
|
options: [],
|
|
12
|
-
searchable: widget.search
|
|
34
|
+
searchable: widget.search,
|
|
35
|
+
...model?.fields[widget.field]?.type === "relation" && { combobox: true }
|
|
13
36
|
}] : []),
|
|
14
|
-
|
|
15
|
-
id: range.field,
|
|
16
|
-
label: range.field,
|
|
17
|
-
min: 0,
|
|
18
|
-
max: 0,
|
|
19
|
-
step: 1,
|
|
20
|
-
histogram: [],
|
|
21
|
-
format: String
|
|
22
|
-
} },
|
|
37
|
+
ranges: widgets.flatMap((widget) => rangeOf(widget, model) ? [emptyRange(widget.field)] : []),
|
|
23
38
|
...date && {
|
|
24
39
|
dateField: date.field,
|
|
25
40
|
dateKind: model?.fields[date.field]?.type === "date" ? "date" : "timestamp",
|
|
@@ -31,5 +46,7 @@ const widgetFields = (view, model) => {
|
|
|
31
46
|
}] : [])
|
|
32
47
|
};
|
|
33
48
|
};
|
|
49
|
+
/** Whether a range draws its histogram: only a `range` widget that asks for one. */
|
|
50
|
+
const rangeHistogram = (view, field) => (view?.filters ?? []).some((widget) => widget.kind === "range" && widget.field === field && widget.histogram);
|
|
34
51
|
//#endregion
|
|
35
|
-
export { widgetFields };
|
|
52
|
+
export { rangeHistogram, widgetFields };
|
package/dist/package.js
CHANGED