@efa-one/sdk 1.14.1 → 1.15.0
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/README.md +1 -0
- package/frontend/format.d.ts +14 -0
- package/frontend/format.js +64 -0
- package/frontend/index.d.ts +1 -0
- package/frontend/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ sub-paths — this keeps `express` out of the frontend and `react` out of the ba
|
|
|
15
15
|
| `@efa-one/sdk/backend` | Node/Express | Auth + token exchange (`requireAuth`, `createExchangeRouter`, `requireInternalOrAuth` …), health router, service discovery + gateway client (`serviceClient`, `resolveService`), clients for audit/reporting/mail/notifications, permission resolution/registration (`getUserPermissions`, `registerPermissions`, `checkPermission`), capability registry (`registerApiMetadata`), backend i18n |
|
|
16
16
|
| `@efa-one/sdk/frontend` | Browser/React | postMessage IPC (`registerAppInfo`, `sendAtStart`, `navigateToApp`, `notifyRouteChange` …), react-i18next factory (`initI18n`), `DevHeader` |
|
|
17
17
|
| `@efa-one/sdk/frontend/ui` | Browser/React | The efa-one design-system kit: `Button`, `Input`, `Badge`, `Alert`, `Dialog`, `DropdownMenu`, `Tooltip`, `EmptyState`, `Skeleton`, `RecordDialog`, and the **`DataTable`** (sortable/filterable/groupable list with per-user persisted view; reflows to stacked cards below 640px). Also exports `useIsMobile` — the platform-wide 640px breakpoint hook. Ship its companion CSS once: `import '@efa-one/sdk/frontend/ui/styles.css'` |
|
|
18
|
+
| `@efa-one/sdk/frontend/format` | Browser | Platform-wide date/time display — `formatDate` (`01.09.2026`), `formatDateTime` (`01.09.2026, 11:05`), `formatTime`, `formatFileStamp`, `localeForLanguage`. Always use these instead of `toLocaleDateString`/`toLocaleString`: without an options object those render `1.9.2026`, and without a locale argument they follow the browser language (`9/1/2026`) |
|
|
18
19
|
| `@efa-one/sdk/frontend/viewPreferences` | Browser/React | Persistence seam for `DataTable` — `createViewPreferencesClient()` (standard `/api/view-preferences/:listId` adapter) + `useViewPreferences()` |
|
|
19
20
|
|
|
20
21
|
Every individual module is also reachable directly, e.g.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DateInput = Date | string | number | null | undefined;
|
|
2
|
+
export interface DateFormatOptions {
|
|
3
|
+
locale?: string;
|
|
4
|
+
timeZone?: string;
|
|
5
|
+
fallback?: string;
|
|
6
|
+
withSeconds?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_DATE_LOCALE = "de-DE";
|
|
9
|
+
export declare const DEFAULT_DATE_FALLBACK = "\u2014";
|
|
10
|
+
export declare function localeForLanguage(language?: string | null): string;
|
|
11
|
+
export declare function formatDate(value: DateInput, opts?: DateFormatOptions): string;
|
|
12
|
+
export declare function formatTime(value: DateInput, opts?: DateFormatOptions): string;
|
|
13
|
+
export declare function formatDateTime(value: DateInput, opts?: DateFormatOptions): string;
|
|
14
|
+
export declare function formatFileStamp(value: DateInput, opts?: Pick<DateFormatOptions, 'timeZone'>): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const DEFAULT_DATE_LOCALE = 'de-DE';
|
|
2
|
+
export const DEFAULT_DATE_FALLBACK = '—';
|
|
3
|
+
export function localeForLanguage(language) {
|
|
4
|
+
const lang = (language ?? '').trim().toLowerCase();
|
|
5
|
+
if (!lang)
|
|
6
|
+
return DEFAULT_DATE_LOCALE;
|
|
7
|
+
if (lang === 'de' || lang.startsWith('de-'))
|
|
8
|
+
return DEFAULT_DATE_LOCALE;
|
|
9
|
+
if (lang === 'en' || lang.startsWith('en-'))
|
|
10
|
+
return 'en-US';
|
|
11
|
+
return language;
|
|
12
|
+
}
|
|
13
|
+
function toDate(value) {
|
|
14
|
+
if (value === null || value === undefined || value === '')
|
|
15
|
+
return null;
|
|
16
|
+
const d = value instanceof Date ? value : new Date(value);
|
|
17
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
18
|
+
}
|
|
19
|
+
function base(opts) {
|
|
20
|
+
return opts?.timeZone ? { timeZone: opts.timeZone } : {};
|
|
21
|
+
}
|
|
22
|
+
function run(value, opts, fmt) {
|
|
23
|
+
const d = toDate(value);
|
|
24
|
+
if (!d)
|
|
25
|
+
return opts?.fallback ?? DEFAULT_DATE_FALLBACK;
|
|
26
|
+
return new Intl.DateTimeFormat(opts?.locale ?? DEFAULT_DATE_LOCALE, { ...base(opts), ...fmt }).format(d);
|
|
27
|
+
}
|
|
28
|
+
export function formatDate(value, opts) {
|
|
29
|
+
return run(value, opts, { day: '2-digit', month: '2-digit', year: 'numeric' });
|
|
30
|
+
}
|
|
31
|
+
export function formatTime(value, opts) {
|
|
32
|
+
return run(value, opts, {
|
|
33
|
+
hour: '2-digit',
|
|
34
|
+
minute: '2-digit',
|
|
35
|
+
...(opts?.withSeconds ? { second: '2-digit' } : {}),
|
|
36
|
+
hourCycle: 'h23',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function formatDateTime(value, opts) {
|
|
40
|
+
return run(value, opts, {
|
|
41
|
+
day: '2-digit',
|
|
42
|
+
month: '2-digit',
|
|
43
|
+
year: 'numeric',
|
|
44
|
+
hour: '2-digit',
|
|
45
|
+
minute: '2-digit',
|
|
46
|
+
...(opts?.withSeconds ? { second: '2-digit' } : {}),
|
|
47
|
+
hourCycle: 'h23',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function formatFileStamp(value, opts) {
|
|
51
|
+
const d = toDate(value) ?? new Date();
|
|
52
|
+
const parts = new Intl.DateTimeFormat('en-CA', {
|
|
53
|
+
...(opts?.timeZone ? { timeZone: opts.timeZone } : {}),
|
|
54
|
+
year: 'numeric',
|
|
55
|
+
month: '2-digit',
|
|
56
|
+
day: '2-digit',
|
|
57
|
+
hour: '2-digit',
|
|
58
|
+
minute: '2-digit',
|
|
59
|
+
second: '2-digit',
|
|
60
|
+
hourCycle: 'h23',
|
|
61
|
+
}).formatToParts(d);
|
|
62
|
+
const p = (type) => parts.find((x) => x.type === type)?.value ?? '';
|
|
63
|
+
return `${p('year')}-${p('month')}-${p('day')}_${p('hour')}-${p('minute')}-${p('second')}`;
|
|
64
|
+
}
|
package/frontend/index.d.ts
CHANGED
package/frontend/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efa-one/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Offizielles SDK für efa-one-Apps: Auth/Session, Service-Discovery, Gateway-Client, Audit/Reporting/Mail/Notifications, Permission- und Capability-Registrierung sowie das Frontend-IPC-/i18n-Toolkit.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|