@protobase/ui 0.55.0 → 0.55.2
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/app.js +1 -1
- package/dist/app/displays/record-card.js +8 -0
- package/dist/app/displays/virtual-cards.js +1 -1
- package/dist/app/embedded-list/embedded-columns.js +2 -1
- package/dist/app/embedded-list/use-embedded-rows.js +6 -2
- package/dist/app/list-page.js +6 -2
- package/dist/app/pages/field-value.js +3 -14
- package/dist/app/record-page.js +1 -1
- package/dist/app/related-cards/related-card.js +1 -1
- package/dist/app/relation-picker.js +12 -4
- package/dist/app/titles/record-titles.js +1 -1
- package/dist/app/titles/relation-title-cells.js +28 -0
- package/dist/app/titles/relation-title-text.js +7 -0
- package/dist/app/titles/relation-title.js +3 -11
- package/dist/app/titles/use-relation-title.js +25 -0
- package/dist/app/use-related-records.js +1 -1
- package/dist/data-grid/use-virtual-rows.js +5 -2
- package/dist/index.js +2 -2
- package/dist/live/grid-loader.js +5 -3
- package/dist/live/relation-labels.js +5 -2
- package/dist/live/title-rows.js +47 -0
- package/dist/live/use-filter-config.js +27 -6
- package/dist/live/use-reference-search.js +14 -7
- package/dist/package.js +1 -1
- package/dist/shell/assets/app-CTbX0_B2.js +9 -0
- package/dist/shell/assets/{index-BX1N2n2W.css → index-BRYcNA4H.css} +1 -1
- package/dist/shell/assets/{index-DvCa5s54.js → index-CY05Rf2z.js} +2 -2
- package/dist/shell/assets/{records-map-BWSeQRmm.js → records-map-DA9Zv2ST.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-Br4XDldp.js → shared-protobase-ui-DjAPl6MN.js} +2 -2
- package/dist/shell/index.html +4 -4
- package/dist/shell/protobase.shell.json +1 -1
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/app-CTbX0_B2.js.map +1 -0
- package/dist/shell-source-maps/assets/{index-DvCa5s54.js.map → index-CY05Rf2z.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-BWSeQRmm.js.map → records-map-DA9Zv2ST.js.map} +1 -1
- package/dist/shell-source-maps/assets/{shared-protobase-ui-Br4XDldp.js.map → shared-protobase-ui-DjAPl6MN.js.map} +1 -1
- package/package.json +4 -4
- package/dist/shell/assets/app-tBBnYXLP.js +0 -9
- package/dist/shell-source-maps/assets/app-tBBnYXLP.js.map +0 -1
|
@@ -8,12 +8,21 @@ const where$1 = createWhere();
|
|
|
8
8
|
/**
|
|
9
9
|
* The search text typed into each facet's combobox and the records of its target resource that match it. A facet
|
|
10
10
|
* without a target, or whose target has no search fields or a composite key, gets nothing: its options are filtered
|
|
11
|
-
* by name instead.
|
|
11
|
+
* by name instead. A target whose view derives its titles names its records by `titleOf`, for the reader.
|
|
12
12
|
*/
|
|
13
|
-
const useReferenceSearch = (targets, views) => {
|
|
13
|
+
const useReferenceSearch = (targets, views, titleOf) => {
|
|
14
14
|
const client = useClient();
|
|
15
15
|
const [texts, setTexts] = useState({});
|
|
16
16
|
const searchable = (target) => Boolean(target?.search?.length) && target.primaryKey.length === 1;
|
|
17
|
+
const nameFields = (target) => {
|
|
18
|
+
const view = views[target.name];
|
|
19
|
+
return [target.primaryKey[0], ...view?.titleFrom ? view.titleFrom.fields : [labelFieldOf(target, view)]];
|
|
20
|
+
};
|
|
21
|
+
const named = (target, item) => {
|
|
22
|
+
const view = views[target.name];
|
|
23
|
+
const key = String(item[target.primaryKey[0]]);
|
|
24
|
+
return [key, view?.titleFrom ? titleOf(target, view, item, key) : String(item[labelFieldOf(target, view)])];
|
|
25
|
+
};
|
|
17
26
|
const results = useQueries({ queries: targets.map(({ id, target }) => {
|
|
18
27
|
const text = (texts[id] ?? "").trim();
|
|
19
28
|
return {
|
|
@@ -26,13 +35,11 @@ const useReferenceSearch = (targets, views) => {
|
|
|
26
35
|
enabled: searchable(target) && text !== "",
|
|
27
36
|
placeholderData: keepPreviousData,
|
|
28
37
|
queryFn: async () => {
|
|
29
|
-
const keyField = target.primaryKey[0];
|
|
30
|
-
const labelField = labelFieldOf(target, views[target.name]);
|
|
31
38
|
return (await client.list(target.name, {
|
|
32
39
|
filter: printFilter(where$1.search(text)),
|
|
33
|
-
fields:
|
|
40
|
+
fields: nameFields(target),
|
|
34
41
|
pageSize: 20
|
|
35
|
-
})).items
|
|
42
|
+
})).items;
|
|
36
43
|
}
|
|
37
44
|
};
|
|
38
45
|
}) });
|
|
@@ -45,7 +52,7 @@ const useReferenceSearch = (targets, views) => {
|
|
|
45
52
|
if ((texts[id] ?? "").trim() === "") return { onSearch };
|
|
46
53
|
return {
|
|
47
54
|
onSearch,
|
|
48
|
-
matches: results[index]?.data ?? []
|
|
55
|
+
matches: (results[index]?.data ?? []).map((item) => named(target, item))
|
|
49
56
|
};
|
|
50
57
|
});
|
|
51
58
|
};
|
package/dist/package.js
CHANGED