@protobase/ui 0.23.4 → 0.23.6
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.d.ts +4 -1
- package/dist/app/app.js +22 -18
- package/dist/app/charts/chart-groups.js +3 -2
- package/dist/app/charts/period-chart.js +3 -2
- package/dist/app/create/create-values.js +1 -1
- package/dist/app/custom-section.js +1 -1
- package/dist/app/displays/board-column.js +2 -1
- package/dist/app/displays/custom-display.js +1 -1
- package/dist/app/displays/display-frame.js +3 -2
- package/dist/app/displays/map-display.js +4 -3
- package/dist/app/embedded-list/cut-off-note.js +2 -1
- package/dist/app/hand-order/hand-sorted-list.js +2 -1
- package/dist/app/hand-order/use-hand-order.js +1 -1
- package/dist/app/import/import-check-step.js +3 -2
- package/dist/app/import/import-counts.js +2 -1
- package/dist/app/import/import-dialog.js +2 -1
- package/dist/app/import/import-result-step.js +2 -1
- package/dist/app/incoming-relations.js +1 -1
- package/dist/app/list-edit/use-list-edits.js +1 -1
- package/dist/app/list-page.js +1 -1
- package/dist/app/main.js +3 -1
- package/dist/app/map/records-map.js +4 -3
- package/dist/app/meta-gate-messages.js +16 -0
- package/dist/app/meta-gate.js +13 -4
- package/dist/app/nav-recent.js +1 -1
- package/dist/app/pages/blocks/link.js +1 -1
- package/dist/app/pages/blocks/progress.js +3 -2
- package/dist/app/pages/blocks/stat.js +2 -1
- package/dist/app/pages/render-node.js +1 -1
- package/dist/app/pages/use-layout-data.js +1 -1
- package/dist/app/record-preview.js +1 -1
- package/dist/app/record-row/record-row-body.js +2 -1
- package/dist/app/saved/saved-records.js +1 -1
- package/dist/app/search/messages.js +18 -0
- package/dist/app/search/search-model.js +6 -5
- package/dist/app/searches/saved-search-rows.js +1 -1
- package/dist/app/searches/saved-searches.js +1 -1
- package/dist/app/searches/update-search-dialog.js +1 -1
- package/dist/app/searches/use-save-search.js +1 -1
- package/dist/app-shell/bottom-bar.js +3 -2
- package/dist/app-shell/breadcrumb.js +2 -1
- package/dist/app-shell/drawer.js +2 -1
- package/dist/app-shell/global-search.js +5 -4
- package/dist/app-shell/messages.js +64 -0
- package/dist/app-shell/profile-menu.js +5 -4
- package/dist/app-shell/sidebar-group.js +6 -5
- package/dist/app-shell/sidebar.js +4 -3
- package/dist/app-shell/theme-switch.js +8 -7
- package/dist/app-shell/top-bar.js +5 -4
- package/dist/data/meta-data.d.ts +3 -0
- package/dist/data/use-meta.js +1 -0
- package/dist/data/use-record.js +1 -1
- package/dist/data/use-update-record.js +1 -1
- package/dist/format/date.js +42 -50
- package/dist/format/intl-cache.js +12 -0
- package/dist/format/messages.js +24 -0
- package/dist/format/money.js +9 -16
- package/dist/format/number-text.js +3 -2
- package/dist/format/number.js +7 -5
- package/dist/format/zone.js +3 -5
- package/dist/invitations/pending-invitation-row.js +2 -1
- package/dist/live/display-value.js +2 -1
- package/dist/locale/active-locale.js +24 -0
- package/dist/locale/app-locale.js +18 -0
- package/dist/locale/messages.js +12 -0
- package/dist/organizations/organizations-page.js +2 -1
- package/dist/package.js +1 -1
- package/dist/shell/assets/app-ByxJ0Flo.js +69 -0
- package/dist/shell/assets/export-worker-O1HF9R4j.js +2 -0
- package/dist/shell/assets/{index-Dxk5GdSQ.js → index-CY5B9PIg.js} +2 -2
- package/dist/shell/assets/{maplibre-CzKsADHj.js → maplibre-D4ace4wn.js} +2 -2
- package/dist/shell/assets/{markdown-content-pV-6NJbB.js → markdown-content-JU2jw1Kr.js} +1 -1
- package/dist/shell/assets/{record-map-CVhzR4LM.js → record-map-B8GB--Ku.js} +1 -1
- package/dist/shell/assets/records-map-BUfPiD0T.js +1 -0
- package/dist/shell/assets/{shared-protobase-ui-BxPtBpOH.js → shared-protobase-ui-C0Ld98uO.js} +1 -1
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/package.json +4 -4
- package/dist/shell/assets/app-CZR9_391.js +0 -69
- package/dist/shell/assets/export-worker-C1djGgjD.js +0 -2
- package/dist/shell/assets/records-map-CJLKyY62.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { formatTag } from "../locale/active-locale.js";
|
|
1
2
|
//#region src/format/number-text.ts
|
|
2
|
-
/** The decimal separator `locale` writes, the
|
|
3
|
-
const localeDecimal = (locale) => new Intl.NumberFormat(locale).formatToParts(1.5).find((part) => part.type === "decimal")?.value === "," ? "," : ".";
|
|
3
|
+
/** The decimal separator `locale` writes, the screens' unless given: `,` for nl-NL and de-DE, `.` for en-GB. */
|
|
4
|
+
const localeDecimal = (locale = formatTag()) => new Intl.NumberFormat(locale).formatToParts(1.5).find((part) => part.type === "decimal")?.value === "," ? "," : ".";
|
|
4
5
|
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
6
|
/**
|
|
6
7
|
* A number written as text, as a plain decimal (`-1234.5`): digits grouped by thousands with the other separator or
|
package/dist/format/number.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { cachedFormat } from "./intl-cache.js";
|
|
2
|
+
import { text } from "./messages.js";
|
|
1
3
|
//#region src/format/number.ts
|
|
2
|
-
const grouped = new Intl.NumberFormat(
|
|
3
|
-
const formatInt = (value) => grouped.format(value);
|
|
4
|
-
const formatSigned = (value) => value > 0 ? `+${grouped.format(value)}` : grouped.format(value).replace("-", "−");
|
|
4
|
+
const grouped = () => cachedFormat("grouped", (tag) => new Intl.NumberFormat(tag));
|
|
5
|
+
const formatInt = (value) => grouped().format(value);
|
|
6
|
+
const formatSigned = (value) => value > 0 ? `+${grouped().format(value)}` : grouped().format(value).replace("-", "−");
|
|
5
7
|
const formatPercent = (value) => `${value}%`;
|
|
6
8
|
const formatApproxRows = (count) => {
|
|
7
|
-
if (count < 1e4) return
|
|
9
|
+
if (count < 1e4) return text("rows", formatInt(count));
|
|
8
10
|
const magnitude = 10 ** (Math.floor(Math.log10(count)) - 3);
|
|
9
|
-
return
|
|
11
|
+
return text("aboutRows", formatInt(Math.round(count / magnitude) * magnitude));
|
|
10
12
|
};
|
|
11
13
|
//#endregion
|
|
12
14
|
export { formatApproxRows, formatInt, formatPercent, formatSigned };
|
package/dist/format/zone.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cachedFormat } from "./intl-cache.js";
|
|
1
2
|
//#region src/format/zone.ts
|
|
2
3
|
/** The viewer's IANA time zone, such as `Europe/Amsterdam`. */
|
|
3
4
|
const viewerZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -47,15 +48,12 @@ const instantAt = (wall, zone) => {
|
|
|
47
48
|
};
|
|
48
49
|
/** The instant `day` (`YYYY-MM-DD`) starts in `zone`: its local midnight. */
|
|
49
50
|
const startOfDayIn = (day, zone) => instantAt(Date.parse(`${day}T00:00:00Z`), zone);
|
|
50
|
-
const zoneNames = /* @__PURE__ */ new Map();
|
|
51
51
|
/** The zone a time is shown in, as its hover label says: "Europe/Amsterdam (GMT+2)", or "UTC". */
|
|
52
52
|
const zoneLabel = (ms, zone) => {
|
|
53
|
-
const
|
|
53
|
+
const name = cachedFormat(`zoneName:${zone}`, (tag) => new Intl.DateTimeFormat(tag, {
|
|
54
54
|
timeZone: zone,
|
|
55
55
|
timeZoneName: "shortOffset"
|
|
56
|
-
});
|
|
57
|
-
zoneNames.set(zone, known);
|
|
58
|
-
const name = known.formatToParts(ms).find((part) => part.type === "timeZoneName")?.value ?? zone;
|
|
56
|
+
})).formatToParts(ms).find((part) => part.type === "timeZoneName")?.value ?? zone;
|
|
59
57
|
return zone === "UTC" || zone === "Etc/UTC" ? "UTC" : `${zone} (${name})`;
|
|
60
58
|
};
|
|
61
59
|
//#endregion
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatTag } from "../locale/active-locale.js";
|
|
1
2
|
import { Button } from "../primitives/button.js";
|
|
2
3
|
import { SectionError } from "../account/account-section.js";
|
|
3
4
|
import { useAction } from "../organizations/use-action.js";
|
|
@@ -26,7 +27,7 @@ const PendingInvitationRow = ({ email, gives, expiresAt, onResend, onRevoke }) =
|
|
|
26
27
|
children: [
|
|
27
28
|
gives,
|
|
28
29
|
" · ",
|
|
29
|
-
expired ? "Expired" : `Until ${new Date(expiresAt).toLocaleDateString()}`
|
|
30
|
+
expired ? "Expired" : `Until ${new Date(expiresAt).toLocaleDateString(formatTag())}`
|
|
30
31
|
]
|
|
31
32
|
})]
|
|
32
33
|
}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatTag } from "../locale/active-locale.js";
|
|
1
2
|
import { viewerZone, zoneLabel } from "../format/zone.js";
|
|
2
3
|
import { formatDate, formatDateTime, formatRelativeTime } from "../format/date.js";
|
|
3
4
|
import { fileShown } from "./file-values.js";
|
|
@@ -22,7 +23,7 @@ const displayValue = (field, value, hints = {}, zone = viewerZone(), now = Date.
|
|
|
22
23
|
case "decimal": {
|
|
23
24
|
const text = hints.decimals === void 0 ? String(value) : Number(value).toFixed(hints.decimals);
|
|
24
25
|
if (hints.format === "percent") return `${Number(value)}%`;
|
|
25
|
-
return affixed(Number(text).toLocaleString(
|
|
26
|
+
return affixed(Number(text).toLocaleString(formatTag(), {
|
|
26
27
|
minimumFractionDigits: hints.decimals ?? 0,
|
|
27
28
|
maximumFractionDigits: hints.decimals ?? 20
|
|
28
29
|
}), hints);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { pickLocale } from "@protobase/schema/internal";
|
|
2
|
+
//#region src/locale/active-locale.ts
|
|
3
|
+
let fallback = "en";
|
|
4
|
+
let app;
|
|
5
|
+
/** The language the screens are in now. */
|
|
6
|
+
const activeLocale = () => app ?? fallback;
|
|
7
|
+
/** The language the screens are in when the app sets none: the browser's, or the one the app was given. */
|
|
8
|
+
const setFallbackLocale = (locale) => {
|
|
9
|
+
fallback = locale;
|
|
10
|
+
};
|
|
11
|
+
/** The language the app sets for everyone, from its `/meta`; undefined when it sets none. */
|
|
12
|
+
const setAppLocale = (locale) => {
|
|
13
|
+
app = locale;
|
|
14
|
+
};
|
|
15
|
+
/** The browser's language when the screens come in it, else English. */
|
|
16
|
+
const browserLocale = (languages = globalThis.navigator?.languages ?? []) => pickLocale(languages);
|
|
17
|
+
const formatTags = {
|
|
18
|
+
en: "en-GB",
|
|
19
|
+
nl: "nl-NL"
|
|
20
|
+
};
|
|
21
|
+
/** The language tag `Intl` formats numbers and dates with, for the active locale. */
|
|
22
|
+
const formatTag = () => formatTags[activeLocale()];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { activeLocale, browserLocale, formatTag, setAppLocale, setFallbackLocale };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { activeLocale, setAppLocale } from "./active-locale.js";
|
|
2
|
+
import { Fragment, useEffect } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/locale/app-locale.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Puts the screens below in the language the app sets for everyone, from its `/meta`, or in the fallback when it sets
|
|
7
|
+
* none; draws them anew when that changes, and tells the page which language it is in.
|
|
8
|
+
*/
|
|
9
|
+
const AppLocale = ({ locale, children }) => {
|
|
10
|
+
setAppLocale(locale);
|
|
11
|
+
const active = activeLocale();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
document.documentElement.lang = active;
|
|
14
|
+
}, [active]);
|
|
15
|
+
return /* @__PURE__ */ jsx(Fragment, { children }, active);
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { AppLocale };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { activeLocale } from "./active-locale.js";
|
|
2
|
+
//#region src/locale/messages.ts
|
|
3
|
+
/**
|
|
4
|
+
* An area's built-in texts in every language the screens come in, keyed by id: the lookup returns the one for the
|
|
5
|
+
* active locale, `text('search')` or `text('rows', 3)`. Dutch must translate every English text, which the types check.
|
|
6
|
+
*/
|
|
7
|
+
const defineMessages = (catalogue) => (id, ...values) => {
|
|
8
|
+
const message = catalogue[activeLocale()][id];
|
|
9
|
+
return typeof message === "function" ? message(...values) : message;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { defineMessages };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatTag } from "../locale/active-locale.js";
|
|
1
2
|
import { Input } from "../primitives/input.js";
|
|
2
3
|
import { PageHeader } from "../app-shell/page-header.js";
|
|
3
4
|
import { useAuth } from "../auth/auth-provider.js";
|
|
@@ -85,7 +86,7 @@ const YourInvitations = () => {
|
|
|
85
86
|
invitation.appRoles.map((name) => roleLabel(roles, name)).join(", ") || "no app roles",
|
|
86
87
|
/* @__PURE__ */ jsxs("span", {
|
|
87
88
|
className: "block text-xs text-muted-foreground",
|
|
88
|
-
children: ["Until ", new Date(invitation.expiresAt).toLocaleDateString()]
|
|
89
|
+
children: ["Until ", new Date(invitation.expiresAt).toLocaleDateString(formatTag())]
|
|
89
90
|
})
|
|
90
91
|
]
|
|
91
92
|
}, invitation.id))
|
package/dist/package.js
CHANGED