@protobase/ui 0.50.1 → 0.51.1
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/live/model-helpers.js +1 -22
- package/dist/live/naming.js +1 -5
- package/dist/package.js +1 -1
- package/dist/shell/assets/app-Ba0a36m3.js +9 -0
- package/dist/shell/assets/{export-worker-IJWS5-Wc.js → export-worker-3e4Zsv0a.js} +3 -3
- package/dist/shell/assets/{index-DguZxa40.js → index-DTfBTlEE.js} +2 -2
- package/dist/shell/assets/{records-map-DAT69z7P.js → records-map-Ca6O4PGF.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui--qDr5Xxl.js → shared-protobase-ui-D1cTNPWD.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/app-Ba0a36m3.js.map +1 -0
- package/dist/shell-source-maps/assets/{export-worker-IJWS5-Wc.js.map → export-worker-3e4Zsv0a.js.map} +1 -1
- package/dist/shell-source-maps/assets/{index-DguZxa40.js.map → index-DTfBTlEE.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-DAT69z7P.js.map → records-map-Ca6O4PGF.js.map} +1 -1
- package/dist/shell-source-maps/assets/{shared-protobase-ui--qDr5Xxl.js.map → shared-protobase-ui-D1cTNPWD.js.map} +1 -1
- package/package.json +4 -4
- package/dist/shell/assets/app-BErWVtb0.js +0 -9
- package/dist/shell-source-maps/assets/app-BErWVtb0.js.map +0 -1
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { labelFieldOf, recordTitle, recordTitleField } from "@protobase/schema/internal";
|
|
2
2
|
//#region src/live/model-helpers.ts
|
|
3
|
-
const labelCandidates = [
|
|
4
|
-
"name",
|
|
5
|
-
"title",
|
|
6
|
-
"number",
|
|
7
|
-
"sku",
|
|
8
|
-
"email",
|
|
9
|
-
"code",
|
|
10
|
-
"description"
|
|
11
|
-
];
|
|
12
|
-
const namesRecords = (field) => field?.type === "text" && !field.sensitive;
|
|
13
|
-
/** The field that names a record when another record points at it. */
|
|
14
|
-
const labelFieldOf = (model, view) => view?.title ?? labelCandidates.find((name) => namesRecords(model.fields[name])) ?? Object.values(model.fields).find(namesRecords)?.name ?? model.primaryKey[0];
|
|
15
|
-
/** What names a record: the view's `title`, else the first text column of its list, else `labelFieldOf`. */
|
|
16
|
-
const recordTitleField = (model, view) => view?.title ?? view?.list?.columns.find((name) => model.fields[name]?.type === "text") ?? labelFieldOf(model);
|
|
17
|
-
/** A record's name as shown: its title field's value, an enum's by its label, else `fallback` when the value is missing. */
|
|
18
|
-
const recordTitle = (model, view, record, fallback) => {
|
|
19
|
-
const name = recordTitleField(model, view);
|
|
20
|
-
const value = record[name];
|
|
21
|
-
if (value === null || value === void 0) return fallback;
|
|
22
|
-
return model.fields[name]?.type === "enum" ? enumLabel(String(value), view?.fields[name]?.valueLabels) : String(value);
|
|
23
|
-
};
|
|
24
3
|
const keyPart = (model, record, name) => {
|
|
25
4
|
const value = record[name];
|
|
26
5
|
return model.fields[name]?.type === "relation" && typeof value === "object" && value !== null && "id" in value ? value.id : value;
|
package/dist/live/naming.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
+
import { humanize } from "@protobase/schema/internal";
|
|
1
2
|
//#region src/live/naming.ts
|
|
2
3
|
const capitalise = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
3
|
-
/** `companyId` and `company_id` become "Company", `discountPercent` and `discount_percent` become "Discount percent". */
|
|
4
|
-
const humanize = (name) => {
|
|
5
|
-
const words = name.replace(/(Id|Code|_id|_code)$/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/_+/g, " ").trim().toLowerCase();
|
|
6
|
-
return capitalise(words || name);
|
|
7
|
-
};
|
|
8
4
|
//#endregion
|
|
9
5
|
export { capitalise, humanize };
|
package/dist/package.js
CHANGED