@wssto2/vue-core 0.12.1 → 0.13.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/CHANGELOG.md +33 -0
- package/README.md +4 -2
- package/dist/{AccessGate.vue_vue_type_script_setup_true_lang-CzQbD2Pc.js → AccessGate.vue_vue_type_script_setup_true_lang-DEzXovsY.js} +1 -1
- package/dist/{Activity-CdkJW68R.js → Activity-ChfxdvXf.js} +24 -23
- package/dist/{AdaptivePageShell.vue_vue_type_script_setup_true_lang-D5i77H6S.js → AdaptivePageShell.vue_vue_type_script_setup_true_lang-lPj9hPqV.js} +33 -33
- package/dist/{Changes-DxK_QfiB.js → Changes-BCa43_mO.js} +18 -17
- package/dist/{CollectionPage.vue_vue_type_script_setup_true_lang-x0jyJ01f.js → CollectionPage.vue_vue_type_script_setup_true_lang-C1GCvyZx.js} +6 -6
- package/dist/{DataTable.vue_vue_type_script_setup_true_lang-C_ZytnW-.js → DataTable.vue_vue_type_script_setup_true_lang-B9r9M5Gt.js} +1 -1
- package/dist/{DateField.vue_vue_type_script_setup_true_lang-CeNwBbJT.js → DateField.vue_vue_type_script_setup_true_lang-B5UUY1OO.js} +2 -2
- package/dist/{DeadLetters-DnA7LP1w.js → DeadLetters-wFTqhISU.js} +5 -5
- package/dist/{General-2matxl2Y.js → General-jW7u4MjH.js} +16 -15
- package/dist/{IncidentRecord-Bt3G4HlX.js → IncidentRecord-zTemLz2R.js} +6 -6
- package/dist/{IncidentsList-2iwgqp9J.js → IncidentsList-yu0xSMrH.js} +6 -6
- package/dist/{NewRolePage-DhGFwvk3.js → NewRolePage-CQ5UVaHs.js} +3 -3
- package/dist/{NumberField.vue_vue_type_script_setup_true_lang-B3UrXNqH.js → NumberField.vue_vue_type_script_setup_true_lang-YVgf5CP6.js} +1 -1
- package/dist/{PersonAccess.vue_vue_type_script_setup_true_lang-DbGZSNQc.js → PersonAccess.vue_vue_type_script_setup_true_lang-CWCt9_dM.js} +2 -2
- package/dist/{ProfilePage-CpuyDBAv.js → ProfilePage-Ca3x3UAH.js} +79 -77
- package/dist/{RecordHeader.vue_vue_type_script_setup_true_lang-DqGc3Jyo.js → RecordHeader.vue_vue_type_script_setup_true_lang-Do_ATJwT.js} +1 -1
- package/dist/{ResourcePage.vue_vue_type_script_setup_true_lang-DljhsTU4.js → ResourcePage.vue_vue_type_script_setup_true_lang-Coz91xht.js} +1 -1
- package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-C0FIotFA.js → RoleEditor.vue_vue_type_script_setup_true_lang-d_aaeXTT.js} +2 -2
- package/dist/{RolePage-DaNv049g.js → RolePage-BUj1w1m1.js} +5 -5
- package/dist/{RolesPage-6hlzJes_.js → RolesPage-NKzBUsrM.js} +3 -3
- package/dist/{SectionNavigator.vue_vue_type_script_setup_true_lang-Dh3sXUt_.js → SectionNavigator.vue_vue_type_script_setup_true_lang-DfKEhTFv.js} +2 -2
- package/dist/{ServiceAccountDialog.vue_vue_type_script_setup_true_lang-FJbWxME_.js → ServiceAccountDialog.vue_vue_type_script_setup_true_lang-4nbhEpv_.js} +10 -9
- package/dist/{ServiceAccountRecord-0-JF5lRx.js → ServiceAccountRecord-ClbyeLhL.js} +8 -8
- package/dist/{ServiceAccountsList-DcsnOcf-.js → ServiceAccountsList-B2VDnYxD.js} +5 -5
- package/dist/{Sessions-DgWhpk-i.js → Sessions-BjkciyHH.js} +23 -21
- package/dist/{SettingsPage-BXPWATYU.js → SettingsPage-Csb14qsx.js} +7 -7
- package/dist/{SignIn-DPoUwHZd.js → SignIn-DPFMv4C7.js} +14 -12
- package/dist/{SignInPage-OyrVemro.js → SignInPage-DukoFqkt.js} +2 -2
- package/dist/{SignIns-BMDrZVVp.js → SignIns-DvdpNkiS.js} +23 -22
- package/dist/{TimeField.vue_vue_type_script_setup_true_lang-D-Em4glH.js → TimeField.vue_vue_type_script_setup_true_lang-DpDXHH7u.js} +2 -2
- package/dist/{Timestamp.vue_vue_type_script_setup_true_lang-ClZAAUMd.js → Timestamp.vue_vue_type_script_setup_true_lang-DlEUKWra.js} +1 -1
- package/dist/{UserRecord-BW-gdCqi.js → UserRecord-B9SeSWQh.js} +57 -55
- package/dist/{UsersList-B3ZF_1Dj.js → UsersList-CREG8q3l.js} +4 -4
- package/dist/access/index.js +4 -4
- package/dist/app/application.d.ts +14 -6
- package/dist/app/current.d.ts +11 -0
- package/dist/app/environment.d.ts +8 -0
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +14 -12
- package/dist/application-DomS6sbx.js +435 -0
- package/dist/collection/http.d.ts +16 -1
- package/dist/collection/index.d.ts +1 -1
- package/dist/collection/index.js +34 -32
- package/dist/content/Money.vue.d.ts +1 -1
- package/dist/content/index.js +151 -158
- package/dist/{contributions-CeG4bszd.js → contributions-obnyn03x.js} +1 -1
- package/dist/current-B0lHKTWr.js +17 -0
- package/dist/form/DateField.vue.d.ts +2 -2
- package/dist/form/DateTimeField.vue.d.ts +2 -2
- package/dist/form/MoneyField.vue.d.ts +1 -1
- package/dist/form/NumberField.vue.d.ts +1 -1
- package/dist/form/date/MonthYearPanel.vue.d.ts +1 -1
- package/dist/form/date/days.d.ts +3 -3
- package/dist/form/index.d.ts +2 -0
- package/dist/form/index.js +1111 -1081
- package/dist/form/zodErrorMap.d.ts +35 -0
- package/dist/format/format.d.ts +51 -6
- package/dist/format/index.d.ts +1 -1
- package/dist/format/index.js +1 -1
- package/dist/format-DoKs29bZ.js +118 -0
- package/dist/{guards-Biv_SlGn.js → guards-DGcSfTEh.js} +1 -1
- package/dist/http-DOEfFCDA.js +107 -0
- package/dist/i18n/index.js +15 -15
- package/dist/identity/index.d.ts +2 -0
- package/dist/identity/index.js +43 -40
- package/dist/identity/usePreferences.d.ts +19 -0
- package/dist/incidents/clientErrorReporter.d.ts +2 -1
- package/dist/incidents/index.js +1 -1
- package/dist/{index-kEHY7hcG.js → index-Be9Q1PB_.js} +78 -76
- package/dist/{index-Cq9TuOqH.js → index-DZikGJ8L.js} +457 -511
- package/dist/{index-ClJeyW3F.js → index-D_yyd4C2.js} +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/intlLocale.d.ts +5 -2
- package/dist/modules/identity/entities.d.ts +4 -0
- package/dist/modules/identity/routes.d.ts +5 -2
- package/dist/modules/identity/schemas.d.ts +6 -2
- package/dist/modules/incident/routes.d.ts +2 -0
- package/dist/modules/incident/schemas.d.ts +2 -0
- package/dist/{navigation-TnVFYRaX.js → navigation-CctcxT51.js} +1 -1
- package/dist/{neighbors-OyvGi233.js → neighbors-Csfan8Ho.js} +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/onboarding/Tip.vue.d.ts +41 -0
- package/dist/onboarding/index.d.ts +1 -0
- package/dist/onboarding/index.js +145 -0
- package/dist/onboarding/tips.d.ts +5 -0
- package/dist/page/index.js +3 -3
- package/dist/phone/index.js +74 -74
- package/dist/phone/phone.d.ts +3 -3
- package/dist/platform/httpSession.d.ts +1 -1
- package/dist/platform/index.d.ts +2 -0
- package/dist/platform/index.js +16 -13
- package/dist/platform/preferences.d.ts +35 -0
- package/dist/platform/session.d.ts +6 -1
- package/dist/platform-DtISOEt7.js +284 -0
- package/dist/playwright/session.d.ts +2 -0
- package/dist/preferences-hYhrw8Uy.js +91 -0
- package/dist/resource/index.d.ts +1 -0
- package/dist/resource/index.js +24 -8
- package/dist/resource/read.d.ts +16 -0
- package/dist/router/index.js +3 -3
- package/dist/{rowLayout-BsKEzEME.js → rowLayout-y1IB_h2r.js} +2 -2
- package/dist/{sections-CvUwZ-S1.js → sections-fkW_IJLc.js} +1 -1
- package/dist/{serverMessages-B6GHgi40.js → serverMessages-Ddghrewh.js} +1 -1
- package/dist/shell/darkMode.d.ts +13 -8
- package/dist/shell/index.js +396 -384
- package/dist/{state-6KSYsVw0.js → state-CXMexi0l.js} +1 -1
- package/dist/styles.css +1 -1
- package/dist/testing/app.d.ts +11 -0
- package/dist/testing/format.d.ts +4 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +96 -89
- package/dist/testing/platform.d.ts +2 -0
- package/dist/usePreferences-B8LIZp_f.js +47 -0
- package/dist/{useTypedEntry-C_Bk4sI0.js → useTypedEntry-DKs8I1yP.js} +279 -280
- package/package.json +6 -2
- package/src/styles/components.css +17 -0
- package/dist/application-CuzT-0vW.js +0 -420
- package/dist/format-D8KUBmbS.js +0 -87
- package/dist/http-Dm0uXY9O.js +0 -95
- package/dist/intlLocale-CeRU44qJ.js +0 -4
- package/dist/platform-BQOX_Ntw.js +0 -283
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Formatting } from "../format";
|
|
2
|
+
/** What a Zod issue (`$ZodRawIssue`) is read for. Structural, so the library needs no Zod: the map is handed to `z.config({ customError })`. */
|
|
3
|
+
export interface ZodIssueLike {
|
|
4
|
+
readonly code?: string;
|
|
5
|
+
readonly origin?: string;
|
|
6
|
+
readonly minimum?: number | bigint;
|
|
7
|
+
readonly maximum?: number | bigint;
|
|
8
|
+
readonly format?: string;
|
|
9
|
+
readonly params?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/** The parts of an application the map reads: its vue-i18n instance (`createApplication`'s `application`) and its formatting. */
|
|
12
|
+
export interface ZodErrorMapEnvironment {
|
|
13
|
+
readonly i18n: {
|
|
14
|
+
readonly global: {
|
|
15
|
+
t(key: string, params?: Record<string, unknown>): string;
|
|
16
|
+
te(key: string): boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly format: Pick<Formatting, "number">;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A Zod error map onto the `validation_errors.*` texts, so a schema's own failures ("Required", "at least 3 characters", a bound,
|
|
23
|
+
* an e-mail address) read in the active language and the application's wording. Zod 4's `customError`; register it once:
|
|
24
|
+
*
|
|
25
|
+
* z.config({ customError: zodErrorMap(application) });
|
|
26
|
+
*
|
|
27
|
+
* Each text is looked up as the application's `validation_errors.<key>` first, then the library's `core.validation_errors.<key>`
|
|
28
|
+
* (`required`, `min`, `max`, `min_value`, `max_value`, `email`, `url`, `date`, `datetime`), so an application overrides any of them
|
|
29
|
+
* by defining the key. A `refine` or `superRefine` names its own text with `params: { code: "deadline_before_opening" }`, which reads
|
|
30
|
+
* `validation_errors.deadline_before_opening` (`code: "required"` is the generated schemas' "zero is missing"). An issue it has no text
|
|
31
|
+
* for returns `undefined`, so Zod's own sentence stands, and a message a schema carries itself is never asked for.
|
|
32
|
+
*/
|
|
33
|
+
export declare function zodErrorMap({ i18n, format }: ZodErrorMapEnvironment): (issue: ZodIssueLike) => {
|
|
34
|
+
message: string;
|
|
35
|
+
} | undefined;
|
package/dist/format/format.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { App } from "vue";
|
|
|
3
3
|
export type DateInput = Date | string | number | null | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* Normalizes a value to a `Date`, or null when there is nothing to show: no value, one that is not a
|
|
6
|
-
* date, or an unset one (a
|
|
7
|
-
*
|
|
6
|
+
* date, or an unset one (a string that starts with a zero date, `0000-00-00`, `0001-01-01` or `1970-01-01`, in any
|
|
7
|
+
* form; a Date or a number at or before the epoch): none of them is a date anybody meant.
|
|
8
|
+
* Reads `YYYY-MM-DD HH:mm[:ss]` (space-separated) as local time, and a civil `YYYY-MM-DD` as that day at local midnight.
|
|
8
9
|
*/
|
|
9
10
|
export declare function toDate(value: DateInput): Date | null;
|
|
10
11
|
/**
|
|
@@ -22,6 +23,19 @@ export interface Formatters {
|
|
|
22
23
|
/** `now` is the moment to count from. */
|
|
23
24
|
relative(value: Date, locale: string, now: Date): string;
|
|
24
25
|
}
|
|
26
|
+
/** The symbols an application writes numbers with. */
|
|
27
|
+
export interface NumberSymbols {
|
|
28
|
+
/** Between the thousands: ".". */
|
|
29
|
+
group: string;
|
|
30
|
+
/** Before the fraction: ",". */
|
|
31
|
+
decimal: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DayOptions {
|
|
34
|
+
/** The lower-case word for a day inside a sentence ("Otvoren jučer"); the date is unchanged. */
|
|
35
|
+
inSentence?: boolean;
|
|
36
|
+
/** The moment "today" is counted from (default: now). */
|
|
37
|
+
now?: Date;
|
|
38
|
+
}
|
|
25
39
|
export interface MoneyOptions {
|
|
26
40
|
/** An ISO code ("EUR"): `Intl`'s currency style instead of the application's `currencySymbol`. */
|
|
27
41
|
currency?: string;
|
|
@@ -55,17 +69,48 @@ export interface Formatting {
|
|
|
55
69
|
readonly currencySymbol: string;
|
|
56
70
|
/** "3 days ago", "in 2 hours", "now": the largest whole unit. */
|
|
57
71
|
relative(value: DateInput, now?: Date): string;
|
|
72
|
+
/**
|
|
73
|
+
* "Today" and "Yesterday" (the `core.activity.today` / `yesterday` texts of the active language) for those two days, the `date` for any other:
|
|
74
|
+
* what people scan for in recent activity. Without a `translate` in the options it is always the `date`.
|
|
75
|
+
*/
|
|
76
|
+
day(value: DateInput, options?: DayOptions): string;
|
|
77
|
+
/** `day` and the time, "Today · 12:57" / "13.09.2026. · 12:57". */
|
|
78
|
+
dayTime(value: DateInput, options?: DayOptions): string;
|
|
79
|
+
/** The BCP 47 tag the active locale is given to `Intl` as (the application's `intlLocale` map over the library's), for a caller that uses `Intl` itself. */
|
|
80
|
+
readonly intlLocale: string;
|
|
81
|
+
}
|
|
82
|
+
/** What the library's own formatters can be told; `createFormatting` passes its options through. */
|
|
83
|
+
export interface FormatterSettings {
|
|
84
|
+
/** Language code → the BCP 47 tag `Intl` is given (`{ en: "en-GB", sl: "sl-SI" }`), over the library's own (`bs` → `sr-Latn-BA`: Chromium has no Bosnian data). Time and relative text use it too. */
|
|
85
|
+
intlLocale?: Readonly<Record<string, string>>;
|
|
86
|
+
/**
|
|
87
|
+
* Language code → the numeric date, written with `DD`, `MM`, `YYYY` ("DD.MM.YYYY." is `30.09.2026.`, "DD/MM/YYYY" is `30/09/2026`).
|
|
88
|
+
* The date-time is the same pattern, a space and the 24-hour time. A language not listed keeps `Intl`'s date.
|
|
89
|
+
*/
|
|
90
|
+
datePattern?: Readonly<Record<string, string>>;
|
|
91
|
+
/**
|
|
92
|
+
* Writes every number with these symbols, in every language: grouped from four digits (`1.234`), the fraction digits rounded like
|
|
93
|
+
* `toFixed` (so `1.005` at two digits is `1,00`, not `Intl`'s `1,01`), and `useGrouping: false` honoured. A `style` other than decimal
|
|
94
|
+
* (`percent`, `unit`) stays `Intl`'s. Money in an ISO currency is then this number and the currency's symbol ("12,50 €").
|
|
95
|
+
*/
|
|
96
|
+
numberSymbols?: NumberSymbols;
|
|
58
97
|
}
|
|
59
|
-
/** The `Intl
|
|
60
|
-
export declare function intlFormatters(): Formatters;
|
|
61
|
-
export interface FormattingOptions {
|
|
98
|
+
/** The library's formatters: `Intl`'s, unless the settings say otherwise. Instances are cached per locale and options because a table formats thousands of cells. */
|
|
99
|
+
export declare function intlFormatters(settings?: FormatterSettings): Formatters;
|
|
100
|
+
export interface FormattingOptions extends FormatterSettings {
|
|
62
101
|
/** The active locale, read on every call (pass `() => i18n.global.locale.value` so it stays reactive). */
|
|
63
102
|
locale: () => string;
|
|
64
|
-
/** Replaces any of the
|
|
103
|
+
/** Replaces any of the library's formatters. */
|
|
65
104
|
formatters?: Partial<Formatters>;
|
|
66
105
|
/** The symbol shown after an amount when no ISO currency is passed: "€", "KM". It is text, not a currency code. */
|
|
67
106
|
currencySymbol?: string;
|
|
107
|
+
/** What `number` returns for a value with nothing to show (null, undefined, NaN): `"0"`. Default: the empty string, like the other functions. */
|
|
108
|
+
emptyNumber?: string;
|
|
109
|
+
/** A message in the active language, for the words of `day` ("core.activity.today"). Without it `day` is `date`. */
|
|
110
|
+
translate?: (key: string) => string;
|
|
68
111
|
}
|
|
112
|
+
/** The part of the options an application passes next to its formatters (`createApplication`'s `formatting`): the rest it already owns. */
|
|
113
|
+
export type FormattingSettings = Omit<FormattingOptions, "locale" | "formatters" | "translate">;
|
|
69
114
|
export declare function createFormatting(options: FormattingOptions): Formatting;
|
|
70
115
|
/** The formatting of the app (or of a subtree): `installFormatting(app, createFormatting(...))` once, `useFormat()` below. */
|
|
71
116
|
export declare const formattingKey: import("vue").InjectionKey<Formatting>, useFormat: () => Formatting;
|
package/dist/format/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createFormatting, formattingKey, installFormatting, intlFormatters, toDate, useFormat } from "./format";
|
|
2
|
-
export type { DateInput, Formatters, Formatting, FormattingOptions, MoneyOptions } from "./format";
|
|
2
|
+
export type { DateInput, DayOptions, FormatterSettings, Formatters, Formatting, FormattingOptions, FormattingSettings, MoneyOptions, NumberSymbols } from "./format";
|
|
3
3
|
export { slugify } from "./slug";
|
package/dist/format/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as o, f as s, i, a as l, t as n, u as g } from "../format-
|
|
1
|
+
import { c as o, f as s, i, a as l, t as n, u as g } from "../format-DoKs29bZ.js";
|
|
2
2
|
function e(a) {
|
|
3
3
|
return a.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[đĐ]/g, "d").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4
4
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { d as x } from "./context-Ch1r4fdN.js";
|
|
2
|
+
const L = { bs: "sr-Latn-BA" }, M = (e, n = {}) => n[e] ?? L[e] ?? e, S = /^(\d{4})-(\d{2})-(\d{2})$/, I = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/, Y = ["0000-00-00", "0001-01-01", "1970-01-01"];
|
|
3
|
+
function D(e) {
|
|
4
|
+
if (e == null || e === "") return null;
|
|
5
|
+
let n;
|
|
6
|
+
if (e instanceof Date) n = e;
|
|
7
|
+
else if (typeof e == "number") n = new Date(e);
|
|
8
|
+
else {
|
|
9
|
+
if (Y.some((u) => e.startsWith(u))) return null;
|
|
10
|
+
const c = S.exec(e);
|
|
11
|
+
c ? n = new Date(Number(c[1]), Number(c[2]) - 1, Number(c[3])) : n = new Date(I.test(e) ? e.replace(" ", "T") : e);
|
|
12
|
+
}
|
|
13
|
+
return Number.isNaN(n.getTime()) || n.getTime() <= 0 ? null : n;
|
|
14
|
+
}
|
|
15
|
+
const h = { year: "numeric", month: "2-digit", day: "2-digit" }, T = { hour: "2-digit", minute: "2-digit" }, b = [
|
|
16
|
+
["year", 31536e3],
|
|
17
|
+
["month", 2592e3],
|
|
18
|
+
["week", 604800],
|
|
19
|
+
["day", 86400],
|
|
20
|
+
["hour", 3600],
|
|
21
|
+
["minute", 60],
|
|
22
|
+
["second", 1]
|
|
23
|
+
], F = (e, n = 2) => String(e).padStart(n, "0");
|
|
24
|
+
function $(e, n, { group: c, decimal: u }) {
|
|
25
|
+
const g = n?.minimumFractionDigits ?? 0, l = Math.max(g, n?.maximumFractionDigits ?? 3), [d = "", i = ""] = e.toFixed(l).split(".");
|
|
26
|
+
let a = i;
|
|
27
|
+
for (; a.length > g && a.endsWith("0"); ) a = a.slice(0, -1);
|
|
28
|
+
const t = n?.useGrouping === !1 ? d : d.replace(/\B(?=(\d{3})+(?!\d))/g, c);
|
|
29
|
+
return a ? `${t}${u}${a}` : t;
|
|
30
|
+
}
|
|
31
|
+
function E(e = {}) {
|
|
32
|
+
const n = /* @__PURE__ */ new Map(), c = (t, r) => {
|
|
33
|
+
let m = n.get(t);
|
|
34
|
+
return m || (m = r(), n.set(t, m)), m;
|
|
35
|
+
}, u = (t) => M(t, e.intlLocale), g = (t, r) => c(`d|${t}|${JSON.stringify(r)}`, () => new Intl.DateTimeFormat(u(t), r)), l = (t, r) => c(`n|${t}|${JSON.stringify(r ?? {})}`, () => new Intl.NumberFormat(u(t), r)), { datePattern: d, numberSymbols: i } = e, a = (t, r) => r.replace(
|
|
36
|
+
/YYYY|MM|DD|HH|mm/g,
|
|
37
|
+
(m) => m === "YYYY" ? F(t.getFullYear(), 4) : F(m === "MM" ? t.getMonth() + 1 : m === "DD" ? t.getDate() : m === "HH" ? t.getHours() : t.getMinutes())
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
date: (t, r) => d?.[r] ? a(t, d[r]) : g(r, h).format(t),
|
|
41
|
+
dateTime: (t, r) => d?.[r] ? a(t, `${d[r]} HH:mm`) : g(r, { ...h, ...T }).format(t),
|
|
42
|
+
time: (t, r) => g(r, T).format(t),
|
|
43
|
+
number: (t, r, m) => i && (m?.style ?? "decimal") === "decimal" ? $(t, m, i) : l(r, m).format(t),
|
|
44
|
+
money(t, r, m, s) {
|
|
45
|
+
const o = c(`m|${m}|${r}|${JSON.stringify(s ?? {})}`, () => new Intl.NumberFormat(u(m), { ...s, style: "currency", currency: r }));
|
|
46
|
+
if (!i) return o.format(t);
|
|
47
|
+
const y = o.formatToParts(t).find((w) => w.type === "currency")?.value ?? r, f = s?.maximumFractionDigits ?? o.resolvedOptions().maximumFractionDigits ?? 2;
|
|
48
|
+
return `${$(t, { minimumFractionDigits: f, maximumFractionDigits: f }, i)} ${y}`;
|
|
49
|
+
},
|
|
50
|
+
relative(t, r, m) {
|
|
51
|
+
const s = Math.trunc((t.getTime() - m.getTime()) / 1e3), [o, y] = b.find(([, f]) => Math.abs(s) >= f) ?? b[b.length - 1];
|
|
52
|
+
return c(`r|${r}`, () => new Intl.RelativeTimeFormat(u(r), { numeric: "auto" })).format(Math.trunc(s / y), o);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const N = (e, n) => e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate();
|
|
57
|
+
function C(e) {
|
|
58
|
+
const n = { ...E(e), ...e.formatters }, c = (i) => typeof i == "number" && Number.isFinite(i), u = () => M(e.locale(), e.intlLocale), g = (i) => {
|
|
59
|
+
const a = D(i);
|
|
60
|
+
return a ? n.time(a, e.locale()) : "";
|
|
61
|
+
}, l = (i) => {
|
|
62
|
+
const a = D(i);
|
|
63
|
+
return a ? n.date(a, e.locale()) : "";
|
|
64
|
+
}, d = (i, { inSentence: a = !1, now: t = /* @__PURE__ */ new Date() } = {}) => {
|
|
65
|
+
const r = D(i);
|
|
66
|
+
if (!r || !e.translate) return l(i);
|
|
67
|
+
const m = new Date(t.getFullYear(), t.getMonth(), t.getDate() - 1), s = N(r, t) ? "core.activity.today" : N(r, m) ? "core.activity.yesterday" : null;
|
|
68
|
+
if (!s) return l(i);
|
|
69
|
+
const o = e.translate(s);
|
|
70
|
+
return a ? o.toLocaleLowerCase(u()) : o.charAt(0).toLocaleUpperCase(u()) + o.slice(1);
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
get locale() {
|
|
74
|
+
return e.locale();
|
|
75
|
+
},
|
|
76
|
+
get intlLocale() {
|
|
77
|
+
return u();
|
|
78
|
+
},
|
|
79
|
+
date: l,
|
|
80
|
+
dateTime: (i) => {
|
|
81
|
+
const a = D(i);
|
|
82
|
+
return a ? n.dateTime(a, e.locale()) : "";
|
|
83
|
+
},
|
|
84
|
+
time: g,
|
|
85
|
+
number: (i, a) => c(i) ? n.number(i, e.locale(), a) : e.emptyNumber ?? "",
|
|
86
|
+
get currencySymbol() {
|
|
87
|
+
return e.currencySymbol ?? "";
|
|
88
|
+
},
|
|
89
|
+
money: (i, { currency: a, decimals: t, whole: r, symbol: m = !0 } = {}) => {
|
|
90
|
+
if (!c(i)) return "";
|
|
91
|
+
const s = i, o = r && Number.isInteger(s) ? 0 : t, y = o === void 0 ? void 0 : { minimumFractionDigits: o, maximumFractionDigits: o };
|
|
92
|
+
if (a && m) return n.money(s, a, e.locale(), y);
|
|
93
|
+
const f = n.number(s, e.locale(), y ?? { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
94
|
+
return m && !a && e.currencySymbol ? `${f} ${e.currencySymbol}` : f;
|
|
95
|
+
},
|
|
96
|
+
relative: (i, a = /* @__PURE__ */ new Date()) => {
|
|
97
|
+
const t = D(i);
|
|
98
|
+
return t ? n.relative(t, e.locale(), a) : "";
|
|
99
|
+
},
|
|
100
|
+
day: d,
|
|
101
|
+
dayTime: (i, a) => {
|
|
102
|
+
const t = d(i, a);
|
|
103
|
+
return t ? `${t} · ${g(i)}` : "";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const [A, O] = x("vue-core.formatting");
|
|
108
|
+
function _(e, n) {
|
|
109
|
+
e.provide(A, n);
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
E as a,
|
|
113
|
+
C as c,
|
|
114
|
+
A as f,
|
|
115
|
+
_ as i,
|
|
116
|
+
D as t,
|
|
117
|
+
O as u
|
|
118
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { c as y } from "./current-B0lHKTWr.js";
|
|
2
|
+
const E = [5, 8, 10, 15, 25, 50, 100], p = 25;
|
|
3
|
+
function S(e) {
|
|
4
|
+
const r = `defineCollection("${e.id}")`;
|
|
5
|
+
if (typeof e.id != "string" || e.id.trim() === "") throw new Error("defineCollection: `id` must be a non-empty string.");
|
|
6
|
+
if (!Number.isInteger(e.stateVersion) || e.stateVersion < 1) throw new Error(`${r}: \`stateVersion\` must be a positive integer.`);
|
|
7
|
+
if (typeof e.load != "function") throw new Error(`${r}: \`load\` must be a function.`);
|
|
8
|
+
if (typeof e.key != "function") throw new Error(`${r}: \`key\` must be a function.`);
|
|
9
|
+
const t = {
|
|
10
|
+
sorts: e.query?.sorts ? [...e.query.sorts] : null,
|
|
11
|
+
filters: e.query?.filters ? [...e.query.filters] : null,
|
|
12
|
+
views: e.query?.views ? [...e.query.views] : null,
|
|
13
|
+
sensitive: [...e.query?.sensitive ?? []],
|
|
14
|
+
pageSizes: [...e.query?.pageSizes ?? E],
|
|
15
|
+
search: e.query?.search ?? !0
|
|
16
|
+
};
|
|
17
|
+
if (t.pageSizes.length === 0 || t.pageSizes.some((a) => !Number.isInteger(a) || a < 1))
|
|
18
|
+
throw new Error(`${r}: \`query.pageSizes\` must list positive integers.`);
|
|
19
|
+
for (const a of t.sensitive)
|
|
20
|
+
if (t.filters && !t.filters.includes(a)) throw new Error(`${r}: sensitive filter "${a}" is not in \`query.filters\`.`);
|
|
21
|
+
const s = e.defaults ?? {}, n = s.pageSize ?? (t.pageSizes.includes(p) ? p : t.pageSizes[0]);
|
|
22
|
+
if (!t.pageSizes.includes(n)) throw new Error(`${r}: default page size ${n} is not one of ${t.pageSizes.join(", ")}.`);
|
|
23
|
+
const o = s.sort ?? null;
|
|
24
|
+
if (o !== null && t.sorts && !t.sorts.includes(o)) throw new Error(`${r}: default sort "${o}" is not in \`query.sorts\`.`);
|
|
25
|
+
const i = s.view ?? null;
|
|
26
|
+
if (i !== null && t.views && !t.views.includes(i)) throw new Error(`${r}: default view "${i}" is not in \`query.views\`.`);
|
|
27
|
+
const f = Object.fromEntries(Object.entries(s.filters ?? {}).filter(([, a]) => a !== void 0 && a !== ""));
|
|
28
|
+
for (const a of Object.keys(f))
|
|
29
|
+
if (t.filters && !t.filters.includes(a)) throw new Error(`${r}: default filter "${a}" is not in \`query.filters\`.`);
|
|
30
|
+
const c = s.page ?? 1;
|
|
31
|
+
if (!Number.isInteger(c) || c < 1) throw new Error(`${r}: default page must be a positive integer.`);
|
|
32
|
+
const d = s.direction ?? "asc";
|
|
33
|
+
if (d !== "asc" && d !== "desc") throw new Error(`${r}: default direction must be "asc" or "desc".`);
|
|
34
|
+
return Object.freeze({
|
|
35
|
+
id: e.id,
|
|
36
|
+
stateVersion: e.stateVersion,
|
|
37
|
+
load: e.load,
|
|
38
|
+
key: e.key,
|
|
39
|
+
defaults: Object.freeze({
|
|
40
|
+
page: c,
|
|
41
|
+
pageSize: n,
|
|
42
|
+
sort: o,
|
|
43
|
+
direction: d,
|
|
44
|
+
search: s.search ?? "",
|
|
45
|
+
view: i,
|
|
46
|
+
filters: Object.freeze(f)
|
|
47
|
+
}),
|
|
48
|
+
contract: Object.freeze(t),
|
|
49
|
+
migrate: e.migrate
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const g = (e) => typeof e == "object" && e !== null && !Array.isArray(e), l = (...e) => {
|
|
53
|
+
for (const r of e) if (typeof r == "number" && Number.isFinite(r)) return r;
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
function m(e) {
|
|
57
|
+
return {
|
|
58
|
+
// Filters first: the reserved names below always win, a filter called "page" cannot break paging.
|
|
59
|
+
...e.filters,
|
|
60
|
+
page: e.page,
|
|
61
|
+
per_page: e.pageSize,
|
|
62
|
+
order_col: e.sort,
|
|
63
|
+
order_dir: e.sort ? e.direction : null,
|
|
64
|
+
search: e.search,
|
|
65
|
+
view: e.view
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function h(e, r) {
|
|
69
|
+
const t = e.data, s = g(t) && Array.isArray(t.data), n = Array.isArray(t) ? t : s ? t.data : [], o = s ? t : {}, i = g(e.meta) ? e.meta : g(o.meta) ? o.meta : {}, f = l(o.per_page, i.per_page) ?? r.pageSize, c = l(o.total, i.total) ?? n.length, d = l(o.current_page, i.page, i.current_page) ?? r.page, a = l(o.last_page, i.last_page) ?? (c === 0 ? 0 : Math.ceil(c / Math.max(1, f))), w = l(o.from, i.from) ?? (n.length === 0 ? 0 : (d - 1) * f + 1), v = l(o.to, i.to) ?? (n.length === 0 ? 0 : w + n.length - 1), b = Array.isArray(i.views) ? i.views : Array.isArray(o.views) ? o.views : void 0;
|
|
70
|
+
return {
|
|
71
|
+
rows: n,
|
|
72
|
+
total: c,
|
|
73
|
+
page: d,
|
|
74
|
+
pageSize: f,
|
|
75
|
+
lastPage: a,
|
|
76
|
+
from: w,
|
|
77
|
+
to: v,
|
|
78
|
+
views: b?.filter(g).flatMap((u) => typeof u.key == "string" ? [{ key: u.key, count: l(u.count) ?? void 0 }] : []),
|
|
79
|
+
// Like `Row`, the shape of `meta` is the caller's word, not checked.
|
|
80
|
+
meta: i,
|
|
81
|
+
requestId: e.requestId
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function z(e, r, t = {}) {
|
|
85
|
+
return async (s, { signal: n }) => {
|
|
86
|
+
const o = await e.get(r, { query: t.params ? t.params(s) : m(s), signal: n });
|
|
87
|
+
return h(o, s);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function A(e, r) {
|
|
91
|
+
return (t, s) => z(y().platform.http, e, r)(t, s);
|
|
92
|
+
}
|
|
93
|
+
function _(e, r = {}) {
|
|
94
|
+
return async (t, { signal: s }) => {
|
|
95
|
+
const n = { ...r, ...m(t) };
|
|
96
|
+
return h(await y().platform.http.request(e, n, { signal: s }), t);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
E as D,
|
|
101
|
+
m as a,
|
|
102
|
+
_ as b,
|
|
103
|
+
S as d,
|
|
104
|
+
z as h,
|
|
105
|
+
A as l,
|
|
106
|
+
h as r
|
|
107
|
+
};
|