@moh-sso/utils 0.0.0-stage → 1.4.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 +20 -2
- package/dist/_types/packages/types/src/index.d.ts +6 -0
- package/dist/_types/packages/types/src/types/announcement-summary.types.d.ts +16 -0
- package/dist/_types/packages/types/src/types/client-role.types.d.ts +6 -0
- package/dist/_types/packages/types/src/types/client.types.d.ts +46 -0
- package/dist/_types/packages/types/src/types/document-processing.types.d.ts +1 -0
- package/dist/_types/packages/types/src/types/notifications.types.d.ts +96 -0
- package/dist/_types/packages/types/src/types/system-navigation.types.d.ts +18 -0
- package/dist/_types/packages/ui/src/accessibility/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/accessibility/useFocusTrap.d.ts +10 -0
- package/dist/_types/packages/ui/src/branding/BuildMeta.d.ts +6 -0
- package/dist/_types/packages/ui/src/branding/PublicFooter.d.ts +6 -0
- package/dist/_types/packages/ui/src/branding/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/data-display/DataTablePagination.d.ts +12 -0
- package/dist/_types/packages/ui/src/data-display/DataTableShell.d.ts +35 -0
- package/dist/_types/packages/ui/src/data-display/RowActionsCell.d.ts +7 -0
- package/dist/_types/packages/ui/src/data-display/TableEmptyState.d.ts +8 -0
- package/dist/_types/packages/ui/src/data-display/TableStatusTag.d.ts +8 -0
- package/dist/_types/packages/ui/src/data-display/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/feedback/comingsoon/ComingSoon.d.ts +7 -0
- package/dist/_types/packages/ui/src/feedback/emptystate/EmptyState.d.ts +15 -0
- package/dist/_types/packages/ui/src/feedback/errorstate/ErrorState.d.ts +14 -0
- package/dist/_types/packages/ui/src/feedback/errorstate/MicrofrontendErrorBoundary.d.ts +16 -0
- package/dist/_types/packages/ui/src/feedback/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/feedback/loadingstate/LoadingState.d.ts +5 -0
- package/dist/_types/packages/ui/src/forms/CaseFormsGrid.d.ts +1 -0
- package/dist/_types/packages/ui/src/forms/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/index.d.ts +16 -0
- package/dist/_types/packages/ui/src/layout/PageShell/PageShell.d.ts +9 -0
- package/dist/_types/packages/ui/src/layout/SectionCard/SectionCard.d.ts +11 -0
- package/dist/_types/packages/ui/src/layout/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppGridContent.d.ts +12 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppMenu.component.d.ts +6 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/AppMenuItem.component.d.ts +13 -0
- package/dist/_types/packages/ui/src/navigation/appmenu/appMenuGroups.d.ts +11 -0
- package/dist/_types/packages/ui/src/navigation/breadcrumbs/AppBreadcrumbs.d.ts +12 -0
- package/dist/_types/packages/ui/src/navigation/breadcrumbs/BreadcrumbBar.d.ts +10 -0
- package/dist/_types/packages/ui/src/navigation/index.d.ts +2 -0
- package/dist/_types/packages/ui/src/navigation/sidenav/ClientSideNav.d.ts +14 -0
- package/dist/_types/packages/ui/src/notifications/FormInlineAlert.d.ts +7 -0
- package/dist/_types/packages/ui/src/notifications/NotificationsPanel.d.ts +14 -0
- package/dist/_types/packages/ui/src/notifications/index.d.ts +4 -0
- package/dist/_types/packages/ui/src/notifications/toast/ToastProvider.d.ts +20 -0
- package/dist/_types/packages/ui/src/notifications/toast/useToast.d.ts +20 -0
- package/dist/_types/packages/ui/src/overlays/header-panel/ReusableHeaderPanel.d.ts +17 -0
- package/dist/_types/packages/ui/src/overlays/header-panel/header-panel.context.d.ts +23 -0
- package/dist/_types/packages/ui/src/overlays/index.d.ts +4 -0
- package/dist/_types/packages/ui/src/overlays/modal/ReusableModal.d.ts +20 -0
- package/dist/_types/packages/ui/src/overlays/modal/modal.context.d.ts +14 -0
- package/dist/_types/packages/ui/src/shell/ExternalAppHeader.d.ts +22 -0
- package/dist/_types/packages/ui/src/shell/PublicHeader.component.d.ts +8 -0
- package/dist/_types/packages/ui/src/shell/UserHeader.component.d.ts +17 -0
- package/dist/_types/packages/ui/src/shell/index.d.ts +5 -0
- package/dist/_types/packages/ui/src/theme/ThemeProvider.d.ts +8 -0
- package/dist/_types/packages/ui/src/theme/index.d.ts +1 -0
- package/dist/_types/packages/ui/src/utils/severity.d.ts +22 -0
- package/dist/_types/packages/ui/src/utils/status.d.ts +1 -0
- package/dist/_types/packages/utils/src/index.d.ts +1 -0
- package/dist/_types/packages/utils/src/utils/utils.d.ts +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -0
- package/package.json +33 -4
package/README.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Utils Package
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@moh-sso/utils` contains small shared utility functions used by frontend apps and packages.
|
|
4
|
+
|
|
5
|
+
## Responsibilities
|
|
6
|
+
|
|
7
|
+
- Provide generic reusable helpers.
|
|
8
|
+
- Avoid large feature-specific utility dumping.
|
|
9
|
+
- Keep feature-owned helpers inside their app when they are not truly shared.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { formatDateTime } from "@moh-sso/utils";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Development
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm run build -w @moh-sso/utils
|
|
21
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types/announcement-summary.types";
|
|
2
|
+
export * from "./types/client-role.types";
|
|
3
|
+
export * from "./types/client.types";
|
|
4
|
+
export * from "./types/document-processing.types";
|
|
5
|
+
export * from "./types/notifications.types";
|
|
6
|
+
export * from "./types/system-navigation.types";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AnnouncementLevel = "INFO" | "SUCCESS" | "WARNING" | "CRITICAL";
|
|
2
|
+
export type AnnouncementStatus = "DRAFT" | "SCHEDULED" | "PUBLISHED" | "ARCHIVED";
|
|
3
|
+
export type Announcement = {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
message: string;
|
|
7
|
+
summary: string | null;
|
|
8
|
+
level: AnnouncementLevel;
|
|
9
|
+
tag: string | null;
|
|
10
|
+
link_url?: string | null;
|
|
11
|
+
link_label?: string | null;
|
|
12
|
+
status: AnnouncementStatus;
|
|
13
|
+
publish_at: string | null;
|
|
14
|
+
expires_at: string | null;
|
|
15
|
+
is_pinned?: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ClientRole } from "./client-role.types";
|
|
2
|
+
export interface Client {
|
|
3
|
+
id: string;
|
|
4
|
+
clientId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
publicClient: boolean;
|
|
10
|
+
rootUrl?: string;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
redirectUris: string[];
|
|
13
|
+
webOrigins?: string[];
|
|
14
|
+
roles?: ClientRole[];
|
|
15
|
+
attributes?: ClientAttributes;
|
|
16
|
+
createdAt?: string;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
}
|
|
19
|
+
export type ClientAttributes = Record<string, string | undefined>;
|
|
20
|
+
export interface CreateClientPayload {
|
|
21
|
+
clientId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
icon?: string;
|
|
25
|
+
publicClient?: boolean;
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
rootUrl?: string;
|
|
28
|
+
baseUrl?: string;
|
|
29
|
+
redirectUris?: string[];
|
|
30
|
+
webOrigins?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateClientPayload {
|
|
33
|
+
name?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
icon?: string;
|
|
36
|
+
publicClient?: boolean;
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
rootUrl?: string;
|
|
39
|
+
baseUrl?: string;
|
|
40
|
+
redirectUris?: string[];
|
|
41
|
+
webOrigins?: string[];
|
|
42
|
+
}
|
|
43
|
+
export type ClientsState = {
|
|
44
|
+
items: Client[];
|
|
45
|
+
activeClientId: string | null;
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DocumentProcessType = "SURVEILLANCE_CSV_IMPORT" | "CSV_IMPORT" | "EXCEL_IMPORT" | "FHIR_IMPORT" | "USER_BULK_IMPORT" | "SURVEILLANCE_EXCEL_IMPORT" | "FACILITY_IMPORT" | "LAB_RESULT_IMPORT" | "INVENTORY_IMPORT" | "HISTORICAL_BACKFILL_IMPORT" | "DRY_RUN_IMPORT" | "ETL_IMPORT" | "ARCHIVE_IMPORT" | "IMAGE_PROCESSING" | "DOCUMENT_EXTRACTION" | "NO_OP_UPLOAD";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Severity } from "../../../ui/src/index.js";
|
|
2
|
+
export type Notification = {
|
|
3
|
+
id: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
title: string;
|
|
6
|
+
message: string;
|
|
7
|
+
severity: Severity;
|
|
8
|
+
target_role?: string;
|
|
9
|
+
client_id?: string;
|
|
10
|
+
user_id?: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
created_at: string;
|
|
13
|
+
read: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type GetNotificationsParams = {
|
|
16
|
+
unread?: boolean;
|
|
17
|
+
limit?: number;
|
|
18
|
+
offset?: number;
|
|
19
|
+
};
|
|
20
|
+
export type NotificationDeliveryStatus = "PENDING" | "PROCESSING" | "SENT" | "FAILED" | "RETRY" | "CANCELLED";
|
|
21
|
+
export type NotificationDelivery = {
|
|
22
|
+
id: string;
|
|
23
|
+
notification_id: string;
|
|
24
|
+
channel: string;
|
|
25
|
+
status: NotificationDeliveryStatus | string;
|
|
26
|
+
recipient?: Record<string, unknown>;
|
|
27
|
+
template_name?: string;
|
|
28
|
+
template_data?: Record<string, unknown>;
|
|
29
|
+
payload?: Record<string, unknown>;
|
|
30
|
+
scheduled_at?: string;
|
|
31
|
+
locked_at?: string;
|
|
32
|
+
sent_at?: string;
|
|
33
|
+
attempts: number;
|
|
34
|
+
max_attempts: number;
|
|
35
|
+
last_error?: string;
|
|
36
|
+
provider?: string;
|
|
37
|
+
provider_message_id?: string;
|
|
38
|
+
provider_status?: string;
|
|
39
|
+
provider_metadata?: Record<string, unknown>;
|
|
40
|
+
created_at: string;
|
|
41
|
+
updated_at: string;
|
|
42
|
+
};
|
|
43
|
+
export type NotificationDeliveryListParams = {
|
|
44
|
+
channel?: "in_app" | "email" | "sms" | "webhook" | string;
|
|
45
|
+
status?: NotificationDeliveryStatus | string;
|
|
46
|
+
search?: string;
|
|
47
|
+
limit?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
};
|
|
50
|
+
export type NotificationDeliveryList = {
|
|
51
|
+
items: NotificationDelivery[];
|
|
52
|
+
total: number;
|
|
53
|
+
limit: number;
|
|
54
|
+
offset: number;
|
|
55
|
+
};
|
|
56
|
+
export type NotificationDeliveryMetric = {
|
|
57
|
+
channel: string;
|
|
58
|
+
provider?: string;
|
|
59
|
+
total: number;
|
|
60
|
+
pending: number;
|
|
61
|
+
processing: number;
|
|
62
|
+
sent: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
retry: number;
|
|
65
|
+
cancelled: number;
|
|
66
|
+
avg_processing_seconds: number;
|
|
67
|
+
};
|
|
68
|
+
export type NotificationDeliveryMetrics = {
|
|
69
|
+
items: NotificationDeliveryMetric[];
|
|
70
|
+
};
|
|
71
|
+
export type TestSMSRequest = {
|
|
72
|
+
to: string;
|
|
73
|
+
message: string;
|
|
74
|
+
};
|
|
75
|
+
export type TestSMSResponse = {
|
|
76
|
+
notification_id: string;
|
|
77
|
+
status: string;
|
|
78
|
+
};
|
|
79
|
+
export type NotificationPreferences = {
|
|
80
|
+
user_id: string;
|
|
81
|
+
email_enabled: boolean;
|
|
82
|
+
sms_enabled: boolean;
|
|
83
|
+
phone_number?: string;
|
|
84
|
+
phone_verified: boolean;
|
|
85
|
+
quiet_hours_start?: string;
|
|
86
|
+
quiet_hours_end?: string;
|
|
87
|
+
created_at?: string;
|
|
88
|
+
updated_at?: string;
|
|
89
|
+
};
|
|
90
|
+
export type UpdateNotificationPreferencesRequest = {
|
|
91
|
+
email_enabled?: boolean;
|
|
92
|
+
sms_enabled?: boolean;
|
|
93
|
+
phone_number?: string;
|
|
94
|
+
quiet_hours_start?: string;
|
|
95
|
+
quiet_hours_end?: string;
|
|
96
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type NavigationLaunchMode = "internal" | "new_tab" | "same_tab";
|
|
2
|
+
export interface SystemNavigationItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
permission?: string;
|
|
7
|
+
requiredPermissions?: string[];
|
|
8
|
+
requiredAnyPermissions?: string[];
|
|
9
|
+
order?: number;
|
|
10
|
+
icon?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Optional launcher category; otherwise inherits the system category. */
|
|
13
|
+
category?: string;
|
|
14
|
+
displayInLauncher?: boolean;
|
|
15
|
+
displayInSideNav?: boolean;
|
|
16
|
+
launchMode?: NavigationLaunchMode;
|
|
17
|
+
children?: SystemNavigationItem[];
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFocusTrap } from "./useFocusTrap";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
type FocusTrapOptions = {
|
|
3
|
+
active: boolean;
|
|
4
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
5
|
+
restoreFocus?: boolean;
|
|
6
|
+
initialFocusRef?: RefObject<HTMLElement | HTMLButtonElement | null>;
|
|
7
|
+
initialFocusSelector?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function useFocusTrap({ active, containerRef, restoreFocus, initialFocusRef, initialFocusSelector, }: FocusTrapOptions): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type FooterVersionInfo = {
|
|
2
|
+
frontendVersion?: string;
|
|
3
|
+
backendVersion?: string;
|
|
4
|
+
backendUnavailable?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function PublicFooter({ frontendVersion, backendVersion, backendUnavailable, }?: FooterVersionInfo): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type DataTablePaginationProps = {
|
|
2
|
+
page: number;
|
|
3
|
+
pageSize: number;
|
|
4
|
+
totalItems: number;
|
|
5
|
+
pageSizes?: number[];
|
|
6
|
+
onChange: (pagination: {
|
|
7
|
+
page: number;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function DataTablePagination({ page, pageSize, totalItems, pageSizes, onChange, }: DataTablePaginationProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableHeader = {
|
|
3
|
+
key: string;
|
|
4
|
+
header: string;
|
|
5
|
+
};
|
|
6
|
+
type DataTableShellProps<T> = {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
rows: T[];
|
|
10
|
+
headers: DataTableHeader[];
|
|
11
|
+
getRowId: (row: T) => string;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
isFetching?: boolean;
|
|
14
|
+
loadingDescription?: string;
|
|
15
|
+
tableState?: ReactNode;
|
|
16
|
+
emptyTitle?: string;
|
|
17
|
+
emptyDescription?: string;
|
|
18
|
+
emptyActions?: ReactNode;
|
|
19
|
+
searchValue?: string;
|
|
20
|
+
resultsDescription?: string;
|
|
21
|
+
searchPlaceholder?: string;
|
|
22
|
+
onSearch?: (value: string) => void;
|
|
23
|
+
toolbarActions?: ReactNode;
|
|
24
|
+
topContent?: ReactNode;
|
|
25
|
+
filters?: ReactNode;
|
|
26
|
+
bulkActions?: ReactNode;
|
|
27
|
+
children: (args: {
|
|
28
|
+
rows: Array<T & {
|
|
29
|
+
id: string;
|
|
30
|
+
}>;
|
|
31
|
+
headers: DataTableHeader[];
|
|
32
|
+
}) => ReactNode;
|
|
33
|
+
};
|
|
34
|
+
export declare function DataTableShell<T extends object>({ title, description, rows, headers, getRowId, isLoading, isFetching, searchValue, searchPlaceholder, onSearch, resultsDescription, toolbarActions, loadingDescription, tableState, emptyTitle, emptyDescription, emptyActions, filters, topContent, bulkActions, children, }: DataTableShellProps<T>): import("react").JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type TableEmptyStateProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function TableEmptyState({ title, description, actions }: TableEmptyStateProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type TagKind = "red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast" | "outline";
|
|
2
|
+
type TableStatusTagProps = {
|
|
3
|
+
status: string;
|
|
4
|
+
kind?: TagKind;
|
|
5
|
+
mapStatusToKind?: (status: string) => TagKind;
|
|
6
|
+
};
|
|
7
|
+
export declare function TableStatusTag({ status, kind, mapStatusToKind }: TableStatusTagProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DataTableShell, type DataTableHeader } from "./DataTableShell";
|
|
2
|
+
export { DataTablePagination } from "./DataTablePagination";
|
|
3
|
+
export { RowActionsCell } from "./RowActionsCell";
|
|
4
|
+
export { TableEmptyState } from "./TableEmptyState";
|
|
5
|
+
export { TableStatusTag } from "./TableStatusTag";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface EmptyStateProps {
|
|
2
|
+
title: string;
|
|
3
|
+
description: string;
|
|
4
|
+
primaryAction?: {
|
|
5
|
+
label: string;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
icon?: React.ElementType;
|
|
8
|
+
};
|
|
9
|
+
secondaryAction?: {
|
|
10
|
+
label: string;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function EmptyState({ title, description, primaryAction, secondaryAction, }: EmptyStateProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ErrorStateProps {
|
|
2
|
+
title?: string;
|
|
3
|
+
description: string;
|
|
4
|
+
primaryAction?: {
|
|
5
|
+
label: string;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
};
|
|
8
|
+
secondaryAction?: {
|
|
9
|
+
label: string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function ErrorState({ title, description, primaryAction, secondaryAction, }: ErrorStateProps): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
appName: string;
|
|
5
|
+
}
|
|
6
|
+
interface State {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
}
|
|
10
|
+
export declare class MicrofrontendErrorBoundary extends Component<Props, State> {
|
|
11
|
+
state: State;
|
|
12
|
+
static getDerivedStateFromError(error: Error): State;
|
|
13
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
14
|
+
render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ComingSoon } from "./comingsoon/ComingSoon";
|
|
2
|
+
export { EmptyState } from "./emptystate/EmptyState";
|
|
3
|
+
export { ErrorState } from "./errorstate/ErrorState";
|
|
4
|
+
export { MicrofrontendErrorBoundary } from "./errorstate/MicrofrontendErrorBoundary";
|
|
5
|
+
export { LoadingState } from "./loadingstate/LoadingState";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CaseFormsGrid(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CaseFormsGrid } from "./CaseFormsGrid";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./forms";
|
|
2
|
+
export * from "./feedback";
|
|
3
|
+
export * from "./layout";
|
|
4
|
+
export * from "./data-display";
|
|
5
|
+
export * from "./branding";
|
|
6
|
+
export * from "./shell";
|
|
7
|
+
export * from "./overlays";
|
|
8
|
+
export * from "./notifications";
|
|
9
|
+
export * from "./accessibility";
|
|
10
|
+
export { default as AppGridContent } from "./navigation/appmenu/AppGridContent";
|
|
11
|
+
export { default as AppMenu } from "./navigation/appmenu/AppMenu.component";
|
|
12
|
+
export { ClientSideNav, hasVisibleClientSideNav } from "./navigation/sidenav/ClientSideNav";
|
|
13
|
+
export * from "./utils/severity";
|
|
14
|
+
export * from "./utils/status";
|
|
15
|
+
export * from "./theme";
|
|
16
|
+
export * from "./navigation";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type PageShellProps = {
|
|
3
|
+
title?: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function PageShell({ title, subtitle, actions, children }: PageShellProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type SectionCardProps = {
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
icon?: React.ElementType;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function SectionCard({ title, description, icon: Icon, actions, children, className, }: SectionCardProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Client } from "../../../../types/src/index.js";
|
|
3
|
+
type AppGridContentProps = {
|
|
4
|
+
clients?: Client[];
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
onSelect?: () => void;
|
|
8
|
+
onRetry?: () => void;
|
|
9
|
+
onOpenClient?: (href: string, clientId?: string) => void;
|
|
10
|
+
};
|
|
11
|
+
declare const AppGridContent: React.FC<AppGridContentProps>;
|
|
12
|
+
export default AppGridContent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface AppTileProps {
|
|
3
|
+
icon: React.ElementType;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
href: string;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
onSelect?: () => void;
|
|
9
|
+
onOpen?: (href: string, clientId?: string) => void;
|
|
10
|
+
launchMode?: "internal" | "new_tab" | "same_tab";
|
|
11
|
+
}
|
|
12
|
+
declare const AppTile: React.FC<AppTileProps>;
|
|
13
|
+
export default AppTile;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Client } from "../../../../types/src/index.js";
|
|
2
|
+
type Category = {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export type AppMenuGroup = Category & {
|
|
7
|
+
clients: Client[];
|
|
8
|
+
};
|
|
9
|
+
export declare function getAppMenuCategory(client: Client): Category;
|
|
10
|
+
export declare function groupAppMenuClients(clients: Client[]): AppMenuGroup[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AppBreadcrumbItem = {
|
|
2
|
+
label: string;
|
|
3
|
+
href?: string;
|
|
4
|
+
current?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type AppBreadcrumbsProps = {
|
|
7
|
+
items: AppBreadcrumbItem[];
|
|
8
|
+
className?: string;
|
|
9
|
+
separator?: string;
|
|
10
|
+
onNavigate?: (href: string) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function AppBreadcrumbs({ items, className, separator, onNavigate, }: AppBreadcrumbsProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type AppBreadcrumbItem } from "./AppBreadcrumbs";
|
|
2
|
+
type BreadcrumbBarProps = {
|
|
3
|
+
items: AppBreadcrumbItem[];
|
|
4
|
+
onNavigate?: (href: string) => void;
|
|
5
|
+
onBack?: () => void;
|
|
6
|
+
showBackButton?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function BreadcrumbBar({ items, onNavigate, onBack, showBackButton, className, }: BreadcrumbBarProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Client } from "../../../../types/src/index.js";
|
|
2
|
+
type ClientSideNavProps = {
|
|
3
|
+
clients?: Client[];
|
|
4
|
+
activeClient?: Client | null;
|
|
5
|
+
currentPath: string;
|
|
6
|
+
onNavigate: (path: string) => void;
|
|
7
|
+
hrefPrefix?: string;
|
|
8
|
+
hasPermission?: (permission: string) => boolean;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
onToggleVisibility?: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function ClientSideNav({ clients, activeClient, currentPath, onNavigate, hasPermission, visible, onToggleVisibility, hrefPrefix, }: ClientSideNavProps): import("react").JSX.Element | null;
|
|
13
|
+
export declare function hasVisibleClientSideNav(clients: Client[], hasPermission?: (permission: string) => boolean): boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Notification } from "../../../types/src/index.js";
|
|
2
|
+
type Props = {
|
|
3
|
+
notifications: Notification[];
|
|
4
|
+
unreadCount?: number;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
showHeading?: boolean;
|
|
8
|
+
onRetry?: () => void;
|
|
9
|
+
onMarkRead?: (id: string) => void | Promise<void>;
|
|
10
|
+
onDelete?: (id: string) => void | Promise<void>;
|
|
11
|
+
onView?: (notification: Notification) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function NotificationsPanel({ notifications, unreadCount, isLoading, isError, showHeading, onRetry, onMarkRead, onDelete, onView, }: Props): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ToastAction } from "./useToast";
|
|
3
|
+
export type ToastKind = "success" | "error" | "info" | "warning";
|
|
4
|
+
export type Toast = {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: ToastKind;
|
|
7
|
+
title: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
timeout: number;
|
|
10
|
+
dismissible: boolean;
|
|
11
|
+
actions?: ToastAction[];
|
|
12
|
+
};
|
|
13
|
+
type ToastContextType = {
|
|
14
|
+
push: (toast: Omit<Toast, "id">) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function ToastProvider({ children }: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
export declare function useToastContext(): ToastContextType;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ToastKind = "success" | "error" | "info" | "warning";
|
|
2
|
+
export type ToastAction = {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type ToastOptions = {
|
|
7
|
+
title: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
kind?: ToastKind;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
dismissible?: boolean;
|
|
12
|
+
actions?: ToastAction[];
|
|
13
|
+
};
|
|
14
|
+
export declare function useToast(): {
|
|
15
|
+
show: (options: ToastOptions) => void;
|
|
16
|
+
success: (options: Omit<ToastOptions, "kind"> | string, subtitle?: string) => void;
|
|
17
|
+
error: (options: Omit<ToastOptions, "kind"> | string, subtitle?: string) => void;
|
|
18
|
+
info: (options: Omit<ToastOptions, "kind"> | string, subtitle?: string) => void;
|
|
19
|
+
warning: (options: Omit<ToastOptions, "kind"> | string, subtitle?: string) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PanelSize } from "./header-panel.context";
|
|
2
|
+
type Props = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
title?: string;
|
|
5
|
+
content?: React.ReactNode;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
size: PanelSize;
|
|
8
|
+
primaryActionLabel?: string;
|
|
9
|
+
secondaryActionLabel?: string;
|
|
10
|
+
onPrimaryAction?: () => void;
|
|
11
|
+
onSecondaryAction?: () => void;
|
|
12
|
+
disablePrimaryAction?: boolean;
|
|
13
|
+
maximizable?: boolean;
|
|
14
|
+
defaultMaximized?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function ReusableHeaderPanel({ isOpen, title, content, onClose, size, primaryActionLabel, secondaryActionLabel, onPrimaryAction, onSecondaryAction, disablePrimaryAction, maximizable, defaultMaximized, }: Props): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type PanelSize = "sm" | "md" | "lg";
|
|
3
|
+
type OpenPanelOptions = {
|
|
4
|
+
title?: string;
|
|
5
|
+
content: React.ReactNode;
|
|
6
|
+
size?: PanelSize;
|
|
7
|
+
primaryActionLabel?: string;
|
|
8
|
+
secondaryActionLabel?: string;
|
|
9
|
+
onPrimaryAction?: () => void;
|
|
10
|
+
onSecondaryAction?: () => void;
|
|
11
|
+
disablePrimaryAction?: boolean;
|
|
12
|
+
maximizable?: boolean;
|
|
13
|
+
defaultMaximized?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type HeaderPanelContextType = {
|
|
16
|
+
openPanel: (opts: OpenPanelOptions) => void;
|
|
17
|
+
closePanel: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare function HeaderPanelProvider({ children }: {
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
export declare function useHeaderPanel(): HeaderPanelContextType;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ReusableHeaderPanel } from "./header-panel/ReusableHeaderPanel";
|
|
2
|
+
export { HeaderPanelProvider, useHeaderPanel, } from "./header-panel/header-panel.context";
|
|
3
|
+
export { ReusableModal } from "./modal/ReusableModal";
|
|
4
|
+
export { ModalProvider, useModal } from "./modal/modal.context";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type ModalSize = "sm" | "md" | "lg";
|
|
3
|
+
export type ReusableModalProps = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
content: React.ReactNode;
|
|
7
|
+
primaryAction?: {
|
|
8
|
+
label: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
kind?: "primary" | "danger";
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
secondaryAction?: {
|
|
14
|
+
label: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
};
|
|
17
|
+
size?: ModalSize;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare const ReusableModal: React.FC<ReusableModalProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type ReusableModalProps } from "./ReusableModal";
|
|
3
|
+
type ModalState = Omit<ReusableModalProps, "open"> & {
|
|
4
|
+
open: boolean;
|
|
5
|
+
};
|
|
6
|
+
type ModalContextType = {
|
|
7
|
+
openModal: (config: Omit<ModalState, "open">) => void;
|
|
8
|
+
closeModal: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function ModalProvider({ children }: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}): React.JSX.Element;
|
|
13
|
+
export declare function useModal(): ModalContextType;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ExternalAppLink = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
/** Absolute HTTP(S) launch URL approved by the application's backend. */
|
|
5
|
+
href: string;
|
|
6
|
+
};
|
|
7
|
+
export type ExternalAppHeaderProps = {
|
|
8
|
+
appName: string;
|
|
9
|
+
username: string;
|
|
10
|
+
/** Absolute portal launcher URL, including its deployment base path. */
|
|
11
|
+
portalUrl: string;
|
|
12
|
+
/** Supply only applications this user may launch. No portal API is called here. */
|
|
13
|
+
applications?: ExternalAppLink[];
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
isError?: boolean;
|
|
16
|
+
onRetry?: () => void;
|
|
17
|
+
onProfile: () => void;
|
|
18
|
+
/** End the local application session and initiate the application's OIDC logout. */
|
|
19
|
+
onLogout: () => void;
|
|
20
|
+
};
|
|
21
|
+
/** Shared MOH chrome for independently hosted React apps. Requires no portal auth/store/router. */
|
|
22
|
+
export declare function ExternalAppHeader({ appName, username, portalUrl, applications, isLoading, isError, onRetry, onProfile, onLogout, }: ExternalAppHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type UserHeaderProps = {
|
|
4
|
+
appName?: string;
|
|
5
|
+
homeHref?: string;
|
|
6
|
+
username?: string | null;
|
|
7
|
+
appMenu?: ReactNode;
|
|
8
|
+
contextSelector?: ReactNode;
|
|
9
|
+
onNavigateHome?: () => void;
|
|
10
|
+
onLogout?: () => void;
|
|
11
|
+
onProfile?: () => void;
|
|
12
|
+
navigationExpanded?: boolean;
|
|
13
|
+
onToggleNavigation?: () => void;
|
|
14
|
+
onGlobalAction?: () => void;
|
|
15
|
+
};
|
|
16
|
+
declare const UserHeader: React.FC<UserHeaderProps>;
|
|
17
|
+
export default UserHeader;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as PublicHeader } from "./PublicHeader.component";
|
|
2
|
+
export { default as UserHeader } from "./UserHeader.component";
|
|
3
|
+
export type { UserHeaderProps } from "./UserHeader.component";
|
|
4
|
+
export { ExternalAppHeader } from "./ExternalAppHeader";
|
|
5
|
+
export type { ExternalAppHeaderProps, ExternalAppLink } from "./ExternalAppHeader";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type MohTheme = "white" | "g10" | "g90" | "g100";
|
|
3
|
+
type MohThemeProviderProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
theme?: MohTheme;
|
|
6
|
+
};
|
|
7
|
+
export declare function MohThemeProvider({ children, theme }: MohThemeProviderProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MohThemeProvider } from "./ThemeProvider";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ---------------------------------------------------
|
|
3
|
+
* Domain Severity (Business Layer)
|
|
4
|
+
* ---------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
export type Severity = "info" | "success" | "warning" | "critical" | "danger";
|
|
7
|
+
/**
|
|
8
|
+
* ---------------------------------------------------
|
|
9
|
+
* Carbon Tag Type
|
|
10
|
+
* ---------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
export type CarbonTagType = "red" | "magenta" | "purple" | "blue" | "cyan" | "teal" | "green" | "gray" | "cool-gray" | "warm-gray" | "high-contrast" | "outline";
|
|
13
|
+
export declare function isSeverity(value: unknown): value is Severity;
|
|
14
|
+
export declare function normalizeSeverity(value?: string | null): Severity;
|
|
15
|
+
/**
|
|
16
|
+
* ---------------------------------------------------
|
|
17
|
+
* Public Helpers
|
|
18
|
+
* ---------------------------------------------------
|
|
19
|
+
*/
|
|
20
|
+
export declare const getSeverityTagType: (severity?: string | null) => CarbonTagType;
|
|
21
|
+
export declare const getSeverityLabel: (severity?: string | null) => string;
|
|
22
|
+
export declare const getSeverityRank: (severity?: string | null) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utils/utils";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Announcement, AnnouncementLevel, AnnouncementStatus, DocumentProcessType } from "../../../types/src/index.js";
|
|
2
|
+
export declare function getTagType(level: AnnouncementLevel): "blue" | "green" | "red" | "purple" | "warm-gray";
|
|
3
|
+
export declare function getStatusTagType(status: AnnouncementStatus): "blue" | "green" | "red" | "purple" | "warm-gray";
|
|
4
|
+
export declare function formatRelativeTime(dateString: string): string;
|
|
5
|
+
export declare function formatDateTime(dateString?: string | null): string;
|
|
6
|
+
export declare function truncateText(text: string, limit?: number): string;
|
|
7
|
+
export declare function isAnnouncementActive(item: Announcement): boolean;
|
|
8
|
+
export declare function isPdfFile(file: File): boolean;
|
|
9
|
+
export declare function requiresProcessing(file: File): boolean;
|
|
10
|
+
export declare function validateProcessTypeAgainstFile(file: File, processType: DocumentProcessType): string | null;
|
|
11
|
+
export declare function getSuggestedProcessType(file: File): DocumentProcessType | "";
|
|
12
|
+
export declare function formatFileSize(size: number): string;
|
|
13
|
+
export declare const ACCEPTED_EXTENSIONS: readonly [".pdf", ".csv", ".xlsx", ".xls"];
|
|
14
|
+
export declare const ACCEPTED_MIME_TYPES: readonly ["application/pdf", "text/csv", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
|
|
15
|
+
export declare function getExtension(name: string): string;
|
|
16
|
+
export declare function isAcceptedFile(file: File): boolean;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./_types/packages/utils/src/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
function d(e) {
|
|
2
|
+
switch (e) {
|
|
3
|
+
case "SUCCESS":
|
|
4
|
+
return "green";
|
|
5
|
+
case "WARNING":
|
|
6
|
+
return "purple";
|
|
7
|
+
case "CRITICAL":
|
|
8
|
+
return "red";
|
|
9
|
+
default:
|
|
10
|
+
return "blue";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function m(e) {
|
|
14
|
+
switch (e) {
|
|
15
|
+
case "PUBLISHED":
|
|
16
|
+
return "green";
|
|
17
|
+
case "DRAFT":
|
|
18
|
+
return "warm-gray";
|
|
19
|
+
case "SCHEDULED":
|
|
20
|
+
return "purple";
|
|
21
|
+
case "ARCHIVED":
|
|
22
|
+
return "warm-gray";
|
|
23
|
+
default:
|
|
24
|
+
return "blue";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function p(e) {
|
|
28
|
+
const t = new Date(e), r = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), i = Math.floor(r / (1e3 * 60)), s = Math.floor(r / (1e3 * 60 * 60)), a = Math.floor(r / (1e3 * 60 * 60 * 24));
|
|
29
|
+
return i < 1 ? "Just now" : i < 60 ? `${i} min ago` : s < 24 ? `${s} hr ago` : a === 1 ? "Yesterday" : `${a} days ago`;
|
|
30
|
+
}
|
|
31
|
+
function x(e) {
|
|
32
|
+
if (!e) return "—";
|
|
33
|
+
const t = new Date(e);
|
|
34
|
+
return Number.isNaN(t.getTime()) ? "—" : new Intl.DateTimeFormat(void 0, {
|
|
35
|
+
dateStyle: "medium",
|
|
36
|
+
timeStyle: "short"
|
|
37
|
+
}).format(t);
|
|
38
|
+
}
|
|
39
|
+
function E(e, t = 110) {
|
|
40
|
+
return e ? e.length > t ? `${e.slice(0, t)}...` : e : "";
|
|
41
|
+
}
|
|
42
|
+
function h(e) {
|
|
43
|
+
if (e.status !== "PUBLISHED") return !1;
|
|
44
|
+
const t = Date.now(), n = e.publish_at ? new Date(e.publish_at).getTime() : null, r = e.expires_at ? new Date(e.expires_at).getTime() : null;
|
|
45
|
+
return !(n && n > t || r && r <= t);
|
|
46
|
+
}
|
|
47
|
+
function o(e) {
|
|
48
|
+
const t = e.name.toLowerCase(), n = e.type?.toLowerCase().trim();
|
|
49
|
+
return t.endsWith(".pdf") || n === "application/pdf";
|
|
50
|
+
}
|
|
51
|
+
function u(e) {
|
|
52
|
+
return !o(e);
|
|
53
|
+
}
|
|
54
|
+
function T(e, t) {
|
|
55
|
+
if (!u(e))
|
|
56
|
+
return null;
|
|
57
|
+
const n = e.name.toLowerCase();
|
|
58
|
+
return t === "SURVEILLANCE_CSV_IMPORT" && !n.endsWith(".csv") ? "Surveillance CSV import requires a .csv file." : t === "SURVEILLANCE_EXCEL_IMPORT" && !(n.endsWith(".xlsx") || n.endsWith(".xls")) ? "Surveillance Excel import requires an .xlsx or .xls file." : t === "EXCEL_IMPORT" && !(n.endsWith(".xlsx") || n.endsWith(".xls")) ? "Excel import requires an .xlsx or .xls file." : t === "CSV_IMPORT" && !n.endsWith(".csv") ? "CSV import requires a .csv file." : null;
|
|
59
|
+
}
|
|
60
|
+
function C(e) {
|
|
61
|
+
const t = e.name.toLowerCase();
|
|
62
|
+
return t.endsWith(".xlsx") || t.endsWith(".xls") ? "EXCEL_IMPORT" : t.endsWith(".csv") ? "CSV_IMPORT" : "";
|
|
63
|
+
}
|
|
64
|
+
function g(e) {
|
|
65
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${Math.round(e / 1024)} KB` : `${(e / (1024 * 1024)).toFixed(2)} MB`;
|
|
66
|
+
}
|
|
67
|
+
const c = [".pdf", ".csv", ".xlsx", ".xls"], l = [
|
|
68
|
+
"application/pdf",
|
|
69
|
+
"text/csv",
|
|
70
|
+
"application/vnd.ms-excel",
|
|
71
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
72
|
+
];
|
|
73
|
+
function f(e) {
|
|
74
|
+
const t = e.lastIndexOf(".");
|
|
75
|
+
return t >= 0 ? e.slice(t).toLowerCase() : "";
|
|
76
|
+
}
|
|
77
|
+
function S(e) {
|
|
78
|
+
const t = f(e.name), n = e.type?.toLowerCase().trim(), r = c.includes(
|
|
79
|
+
t
|
|
80
|
+
), i = l.includes(
|
|
81
|
+
n
|
|
82
|
+
);
|
|
83
|
+
return r || i;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
c as ACCEPTED_EXTENSIONS,
|
|
87
|
+
l as ACCEPTED_MIME_TYPES,
|
|
88
|
+
x as formatDateTime,
|
|
89
|
+
g as formatFileSize,
|
|
90
|
+
p as formatRelativeTime,
|
|
91
|
+
f as getExtension,
|
|
92
|
+
m as getStatusTagType,
|
|
93
|
+
C as getSuggestedProcessType,
|
|
94
|
+
d as getTagType,
|
|
95
|
+
S as isAcceptedFile,
|
|
96
|
+
h as isAnnouncementActive,
|
|
97
|
+
o as isPdfFile,
|
|
98
|
+
u as requiresProcessing,
|
|
99
|
+
E as truncateText,
|
|
100
|
+
T as validateProcessTypeAgainstFile
|
|
101
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moh-sso/utils",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"version": "1.4.0",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"package.json"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "vite build --config vite.config.ts && node ../../scripts/write-package-declarations.mjs package utils"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@moh-sso/types": "^1.4.0"
|
|
28
|
+
},
|
|
29
|
+
"private": false,
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/mohuganda/moh-sso-dashboard.git",
|
|
33
|
+
"directory": "frontend/packages/utils"
|
|
34
|
+
}
|
|
35
|
+
}
|