@openmrs/esm-globals 6.3.1-pre.2961 → 6.3.1-pre.2986
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/.swcrc +16 -0
- package/.turbo/turbo-build.log +3 -5
- package/dist/events.d.ts +64 -0
- package/dist/events.js +77 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/public.d.ts +2 -0
- package/dist/public.js +2 -0
- package/dist/types.d.ts +393 -0
- package/dist/types.js +3 -0
- package/package.json +21 -7
- package/src/events.ts +4 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +3 -23
- package/dist/openmrs-esm-globals.js +0 -2
- package/dist/openmrs-esm-globals.js.map +0 -1
- package/webpack.config.js +0 -42
package/.swcrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://swc.rs/schema.json",
|
|
3
|
+
"exclude": [".*\\.test\\..*", "setup-tests\\..*"],
|
|
4
|
+
"module": {
|
|
5
|
+
"type": "es6",
|
|
6
|
+
"resolveFully": true
|
|
7
|
+
},
|
|
8
|
+
"jsc": {
|
|
9
|
+
"parser": {
|
|
10
|
+
"syntax": "typescript",
|
|
11
|
+
"tsx": false
|
|
12
|
+
},
|
|
13
|
+
"target": "es2020",
|
|
14
|
+
"baseUrl": "src"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
./src/index.ts + 1 modules 3.56 KiB [built] [code generated]
|
|
5
|
-
webpack 5.88.0 compiled successfully in 9271 ms
|
|
1
|
+
[0] Successfully compiled: 4 files with swc (316.42ms)
|
|
2
|
+
[0] swc --strip-leading-paths src -d dist exited with code 0
|
|
3
|
+
[1] tsc --project tsconfig.build.json exited with code 0
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface ConnectivityChangedEvent {
|
|
2
|
+
online: boolean;
|
|
3
|
+
}
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare function dispatchConnectivityChanged(online: boolean): void;
|
|
6
|
+
/** @category Offline */
|
|
7
|
+
export declare function subscribeConnectivityChanged(cb: (ev: ConnectivityChangedEvent) => void): () => void;
|
|
8
|
+
/** @category Offline */
|
|
9
|
+
export declare function subscribeConnectivity(cb: (ev: ConnectivityChangedEvent) => void): () => void;
|
|
10
|
+
export interface PrecacheStaticDependenciesEvent {
|
|
11
|
+
}
|
|
12
|
+
export declare function dispatchPrecacheStaticDependencies(data?: PrecacheStaticDependenciesEvent): void;
|
|
13
|
+
/** @category Offline */
|
|
14
|
+
export declare function subscribePrecacheStaticDependencies(cb: (data: PrecacheStaticDependenciesEvent) => void): () => void;
|
|
15
|
+
/** @category UI */
|
|
16
|
+
export interface ShowNotificationEvent {
|
|
17
|
+
description: any;
|
|
18
|
+
kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
19
|
+
title?: string;
|
|
20
|
+
action?: any;
|
|
21
|
+
millis?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ShowActionableNotificationEvent {
|
|
24
|
+
subtitle: any;
|
|
25
|
+
kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
26
|
+
title?: string;
|
|
27
|
+
actionButtonLabel: string | any;
|
|
28
|
+
onActionButtonClick: () => void;
|
|
29
|
+
progressActionLabel?: string;
|
|
30
|
+
}
|
|
31
|
+
/** @category UI */
|
|
32
|
+
export interface ShowToastEvent {
|
|
33
|
+
description: any;
|
|
34
|
+
kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
35
|
+
title?: string;
|
|
36
|
+
actionButtonLabel?: string | any;
|
|
37
|
+
onActionButtonClick?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/** @category UI */
|
|
40
|
+
export interface ShowSnackbarEvent {
|
|
41
|
+
subtitle?: any;
|
|
42
|
+
kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
43
|
+
title: string;
|
|
44
|
+
actionButtonLabel?: string | any;
|
|
45
|
+
onActionButtonClick?: () => void;
|
|
46
|
+
progressActionLabel?: string;
|
|
47
|
+
isLowContrast?: boolean;
|
|
48
|
+
timeoutInMs?: number;
|
|
49
|
+
}
|
|
50
|
+
export declare function dispatchNotificationShown(data: ShowNotificationEvent): void;
|
|
51
|
+
/** @internal */
|
|
52
|
+
export declare function dispatchActionableNotificationShown(data: ShowActionableNotificationEvent): void;
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare function dispatchSnackbarShown(data: ShowSnackbarEvent): void;
|
|
55
|
+
/** @internal */
|
|
56
|
+
export declare function dispatchToastShown(data: ShowToastEvent): void;
|
|
57
|
+
/** @category UI */
|
|
58
|
+
export declare function subscribeNotificationShown(cb: (data: ShowNotificationEvent) => void): () => void;
|
|
59
|
+
/** @category UI */
|
|
60
|
+
export declare function subscribeActionableNotificationShown(cb: (data: ShowActionableNotificationEvent) => void): () => void;
|
|
61
|
+
/** @category UI */
|
|
62
|
+
export declare function subscribeToastShown(cb: (data: ShowToastEvent) => void): () => void;
|
|
63
|
+
/** @category UI */
|
|
64
|
+
export declare function subscribeSnackbarShown(cb: (data: ShowSnackbarEvent) => void): () => void;
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const connectivityChangedEventName = 'openmrs:connectivity-changed';
|
|
2
|
+
/** @internal */ export function dispatchConnectivityChanged(online) {
|
|
3
|
+
window.dispatchEvent(new CustomEvent(connectivityChangedEventName, {
|
|
4
|
+
detail: {
|
|
5
|
+
online
|
|
6
|
+
}
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
/** @category Offline */ export function subscribeConnectivityChanged(cb) {
|
|
10
|
+
if (!window.offlineEnabled) {
|
|
11
|
+
return ()=>{};
|
|
12
|
+
}
|
|
13
|
+
const handler = (ev)=>cb(ev.detail);
|
|
14
|
+
window.addEventListener(connectivityChangedEventName, handler);
|
|
15
|
+
return ()=>window.removeEventListener(connectivityChangedEventName, handler);
|
|
16
|
+
}
|
|
17
|
+
/** @category Offline */ export function subscribeConnectivity(cb) {
|
|
18
|
+
cb({
|
|
19
|
+
online: window.offlineEnabled ? navigator.onLine : true
|
|
20
|
+
});
|
|
21
|
+
return subscribeConnectivityChanged(cb);
|
|
22
|
+
}
|
|
23
|
+
const precacheStaticDependenciesEventName = 'openmrs:precache-static-dependencies';
|
|
24
|
+
export function dispatchPrecacheStaticDependencies(data = {}) {
|
|
25
|
+
window.dispatchEvent(new CustomEvent(precacheStaticDependenciesEventName, {
|
|
26
|
+
detail: data
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/** @category Offline */ export function subscribePrecacheStaticDependencies(cb) {
|
|
30
|
+
const handler = (ev)=>cb(ev.detail);
|
|
31
|
+
window.addEventListener(precacheStaticDependenciesEventName, handler);
|
|
32
|
+
return ()=>window.removeEventListener(precacheStaticDependenciesEventName, handler);
|
|
33
|
+
}
|
|
34
|
+
const notificationShownName = 'openmrs:notification-shown';
|
|
35
|
+
const actionableNotificationShownName = 'openmrs:actionable-notification-shown';
|
|
36
|
+
const toastShownName = 'openmrs:toast-shown';
|
|
37
|
+
const snackbarShownName = 'openmrs:snack-bar-shown';
|
|
38
|
+
export function dispatchNotificationShown(data) {
|
|
39
|
+
window.dispatchEvent(new CustomEvent(notificationShownName, {
|
|
40
|
+
detail: data
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/** @internal */ export function dispatchActionableNotificationShown(data) {
|
|
44
|
+
window.dispatchEvent(new CustomEvent(actionableNotificationShownName, {
|
|
45
|
+
detail: data
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
/** @internal */ export function dispatchSnackbarShown(data) {
|
|
49
|
+
window.dispatchEvent(new CustomEvent(snackbarShownName, {
|
|
50
|
+
detail: data
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
/** @internal */ export function dispatchToastShown(data) {
|
|
54
|
+
window.dispatchEvent(new CustomEvent(toastShownName, {
|
|
55
|
+
detail: data
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/** @category UI */ export function subscribeNotificationShown(cb) {
|
|
59
|
+
const handler = (ev)=>cb(ev.detail);
|
|
60
|
+
window.addEventListener(notificationShownName, handler);
|
|
61
|
+
return ()=>window.removeEventListener(notificationShownName, handler);
|
|
62
|
+
}
|
|
63
|
+
/** @category UI */ export function subscribeActionableNotificationShown(cb) {
|
|
64
|
+
const handler = (ev)=>cb(ev.detail);
|
|
65
|
+
window.addEventListener(actionableNotificationShownName, handler);
|
|
66
|
+
return ()=>window.removeEventListener(actionableNotificationShownName, handler);
|
|
67
|
+
}
|
|
68
|
+
/** @category UI */ export function subscribeToastShown(cb) {
|
|
69
|
+
const handler = (ev)=>cb(ev.detail);
|
|
70
|
+
window.addEventListener(toastShownName, handler);
|
|
71
|
+
return ()=>window.removeEventListener(toastShownName, handler);
|
|
72
|
+
}
|
|
73
|
+
/** @category UI */ export function subscribeSnackbarShown(cb) {
|
|
74
|
+
const handler = (ev)=>cb(ev.detail);
|
|
75
|
+
window.addEventListener(snackbarShownName, handler);
|
|
76
|
+
return ()=>window.removeEventListener(snackbarShownName, handler);
|
|
77
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type ConnectivityChangedEvent, type PrecacheStaticDependenciesEvent, type ShowNotificationEvent, type ShowActionableNotificationEvent, type ShowToastEvent, type ShowSnackbarEvent, subscribeConnectivity, subscribeConnectivityChanged, subscribePrecacheStaticDependencies, subscribeNotificationShown, subscribeActionableNotificationShown, subscribeToastShown, subscribeSnackbarShown, } from './events';
|
|
2
|
+
export * from './types';
|
package/dist/public.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import type { LifeCycles } from 'single-spa';
|
|
2
|
+
import type { i18n } from 'i18next';
|
|
3
|
+
declare global {
|
|
4
|
+
const __webpack_share_scopes__: Record<string, Record<string, {
|
|
5
|
+
loaded?: 1;
|
|
6
|
+
get: () => Promise<unknown>;
|
|
7
|
+
from: string;
|
|
8
|
+
eager: boolean;
|
|
9
|
+
}>>;
|
|
10
|
+
var __webpack_init_sharing__: (scope: string) => Promise<void>;
|
|
11
|
+
interface Window {
|
|
12
|
+
/**
|
|
13
|
+
* Easily copies a text from an element.
|
|
14
|
+
* @param source The source element carrying the text.
|
|
15
|
+
*/
|
|
16
|
+
copyText(source: HTMLElement): void;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the OpenMRS SPA base path with a trailing slash.
|
|
19
|
+
*/
|
|
20
|
+
getOpenmrsSpaBase(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Starts the OpenMRS SPA application.
|
|
23
|
+
* @param config The configuration to use for running.
|
|
24
|
+
*/
|
|
25
|
+
initializeSpa(config: SpaConfig): void;
|
|
26
|
+
/**
|
|
27
|
+
* Indicates whether offline mode is enabled in this install or not.
|
|
28
|
+
* This is used to determine whether offline functionality is present or not.
|
|
29
|
+
*/
|
|
30
|
+
offlineEnabled: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the API base path, e.g. /openmrs
|
|
33
|
+
*/
|
|
34
|
+
openmrsBase: string;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the SPA base path, e.g. /openmrs/spa
|
|
37
|
+
*/
|
|
38
|
+
spaBase: string;
|
|
39
|
+
/**
|
|
40
|
+
* Set by the app shell. Indicates whether the app shell is running in production, development, or test mode.
|
|
41
|
+
*/
|
|
42
|
+
spaEnv: SpaEnvironment;
|
|
43
|
+
/**
|
|
44
|
+
* The build number of the app shell. Set when the app shell is built by webpack.
|
|
45
|
+
*/
|
|
46
|
+
spaVersion: string;
|
|
47
|
+
/**
|
|
48
|
+
* Gets a set of options from the import-map-overrides package.
|
|
49
|
+
*/
|
|
50
|
+
importMapOverrides: {
|
|
51
|
+
addOverride(moduleName: string, url: string): void;
|
|
52
|
+
enableOverride(moduleName: string): void;
|
|
53
|
+
getCurrentPageMap(): Promise<ImportMap>;
|
|
54
|
+
getDefaultMap(): Promise<ImportMap>;
|
|
55
|
+
getNextPageMap(): Promise<ImportMap>;
|
|
56
|
+
addOverride(moduleName: string, url: string): void;
|
|
57
|
+
getOverrideMap(includeDisabled?: boolean): ImportMap;
|
|
58
|
+
getDisabledOverrides(): Array<string>;
|
|
59
|
+
isDisabled(moduleName: string): boolean;
|
|
60
|
+
removeOverride(moduleName: string): void;
|
|
61
|
+
resetOverrides(): void;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Gets the installed modules, which are tuples consisting of the module's name and exports.
|
|
65
|
+
*/
|
|
66
|
+
installedModules: Array<[string, OpenmrsAppRoutes]>;
|
|
67
|
+
/**
|
|
68
|
+
* The i18next instance for the app.
|
|
69
|
+
*/
|
|
70
|
+
i18next: i18n;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export type SpaEnvironment = 'production' | 'development' | 'test';
|
|
74
|
+
export interface ImportMap {
|
|
75
|
+
imports: Record<string, string>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The configuration passed to the app shell initialization function
|
|
79
|
+
*/
|
|
80
|
+
export interface SpaConfig {
|
|
81
|
+
/**
|
|
82
|
+
* The base path or URL for the OpenMRS API / endpoints.
|
|
83
|
+
*/
|
|
84
|
+
apiUrl: string;
|
|
85
|
+
/**
|
|
86
|
+
* The base path for the SPA root path.
|
|
87
|
+
*/
|
|
88
|
+
spaPath: string;
|
|
89
|
+
/**
|
|
90
|
+
* The environment to use.
|
|
91
|
+
* @default production
|
|
92
|
+
*/
|
|
93
|
+
env?: SpaEnvironment;
|
|
94
|
+
/**
|
|
95
|
+
* URLs of configurations to load in the system.
|
|
96
|
+
*/
|
|
97
|
+
configUrls?: Array<string>;
|
|
98
|
+
/**
|
|
99
|
+
* Defines if offline should be supported by installing a service worker.
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
offline?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/** @internal */
|
|
105
|
+
export type RouteDefinition = RegExp | string | boolean;
|
|
106
|
+
/** @internal */
|
|
107
|
+
type AppComponent = {
|
|
108
|
+
appName: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* A definition of a page extracted from an app's routes.json
|
|
112
|
+
*/
|
|
113
|
+
export type PageDefinition = {
|
|
114
|
+
/**
|
|
115
|
+
* The name of the component exported by this frontend module.
|
|
116
|
+
*/
|
|
117
|
+
component: string;
|
|
118
|
+
/**
|
|
119
|
+
* If supplied, the page will only be rendered when this feature flag is enabled.
|
|
120
|
+
*/
|
|
121
|
+
featureFlag?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Determines whether the component renders while the browser is connected to the internet. If false, this page will never render while online.
|
|
124
|
+
*/
|
|
125
|
+
online?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Determines whether the component renders while the browser is not connected to the internet. If false, this page will never render while offline.
|
|
128
|
+
*/
|
|
129
|
+
offline?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Determines the order in which this page is rendered in the app-shell, which is useful for situations where DOM ordering matters.
|
|
132
|
+
*/
|
|
133
|
+
order?: number;
|
|
134
|
+
} & ({
|
|
135
|
+
/**
|
|
136
|
+
* Either a string or a boolean.
|
|
137
|
+
*
|
|
138
|
+
* If a string value, this is used to indicate that this page should be rendered. For example, \"name\" will match when the current page is ${window.spaBase}/name.
|
|
139
|
+
*
|
|
140
|
+
* If a boolean, this either indicates that the component should always be rendered or should never be rendered.
|
|
141
|
+
*/
|
|
142
|
+
route: string | boolean;
|
|
143
|
+
/**
|
|
144
|
+
* A regular expression used to match against the current route to determine whether this page should be rendered. Note that ${window.spaBase} will be removed before attempting to match, so setting this to \"^name.+\" will match any route that starts with ${window.spaBase}/name.
|
|
145
|
+
*/
|
|
146
|
+
routeRegex?: never;
|
|
147
|
+
} | {
|
|
148
|
+
/**
|
|
149
|
+
* Either a string or a boolean.
|
|
150
|
+
*
|
|
151
|
+
* If a string value, this is used to indicate that this page should be rendered. For example, \"name\" will match when the current page is ${window.spaBase}/name.
|
|
152
|
+
*
|
|
153
|
+
* If a boolean, this either indicates that the component should always be rendered or should never be rendered.
|
|
154
|
+
*/
|
|
155
|
+
route?: never;
|
|
156
|
+
/**
|
|
157
|
+
* A regular expression used to match against the current route to determine whether this page should be rendered. Note that ${window.spaBase} will be removed before attempting to match, so setting this to \"^name.+\" will match any route that starts with ${window.spaBase}/name.
|
|
158
|
+
*/
|
|
159
|
+
routeRegex: string;
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* @internal
|
|
163
|
+
* A definition of a page after the app has been registered.
|
|
164
|
+
*/
|
|
165
|
+
export type RegisteredPageDefinition = Omit<PageDefinition, 'order'> & AppComponent & {
|
|
166
|
+
order: number;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* A definition of an extension as extracted from an app's routes.json
|
|
170
|
+
*/
|
|
171
|
+
export type ExtensionDefinition = {
|
|
172
|
+
/**
|
|
173
|
+
* The name of this extension. This is used to refer to the extension in configuration.
|
|
174
|
+
*/
|
|
175
|
+
name: string;
|
|
176
|
+
/**
|
|
177
|
+
* If supplied, the slot that this extension is rendered into by default.
|
|
178
|
+
*/
|
|
179
|
+
slot?: string;
|
|
180
|
+
/**
|
|
181
|
+
* If supplied, the slots that this extension is rendered into by default.
|
|
182
|
+
*/
|
|
183
|
+
slots?: Array<string>;
|
|
184
|
+
/**
|
|
185
|
+
* Determines whether the component renders while the browser is connected to the internet. If false, this page will never render while online.
|
|
186
|
+
*/
|
|
187
|
+
online?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Determines whether the component renders while the browser is not connected to the internet. If false, this page will never render while offline.
|
|
190
|
+
*/
|
|
191
|
+
offline?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Determines the order in which this component renders in its default extension slot. Note that this can be overridden by configuration.
|
|
194
|
+
*/
|
|
195
|
+
order?: number;
|
|
196
|
+
/**
|
|
197
|
+
* The user must have ANY of these privileges to see this extension.
|
|
198
|
+
*/
|
|
199
|
+
privileges?: string | Array<string>;
|
|
200
|
+
/**
|
|
201
|
+
* If supplied, the extension will only be rendered when this feature flag is enabled.
|
|
202
|
+
*/
|
|
203
|
+
featureFlag?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Meta describes any properties that are passed down to the extension when it is loaded
|
|
206
|
+
*/
|
|
207
|
+
meta?: {
|
|
208
|
+
[k: string]: unknown;
|
|
209
|
+
};
|
|
210
|
+
} & ({
|
|
211
|
+
/**
|
|
212
|
+
* The name of the component exported by this frontend module.
|
|
213
|
+
*/
|
|
214
|
+
component: string;
|
|
215
|
+
/**
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
load?: never;
|
|
219
|
+
} | {
|
|
220
|
+
/**
|
|
221
|
+
* The name of the component exported by this frontend module.
|
|
222
|
+
*/
|
|
223
|
+
component?: never;
|
|
224
|
+
/**
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
227
|
+
load: () => Promise<{
|
|
228
|
+
default?: LifeCycles;
|
|
229
|
+
} & LifeCycles>;
|
|
230
|
+
});
|
|
231
|
+
/**
|
|
232
|
+
* A definition of a modal as extracted from an app's routes.json
|
|
233
|
+
*/
|
|
234
|
+
export type ModalDefinition = {
|
|
235
|
+
/**
|
|
236
|
+
* The name of this modal. This is used to launch the modal.
|
|
237
|
+
*/
|
|
238
|
+
name: string;
|
|
239
|
+
} & ({
|
|
240
|
+
/**
|
|
241
|
+
* The name of the component exported by this frontend module.
|
|
242
|
+
*/
|
|
243
|
+
component: string;
|
|
244
|
+
/**
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
load?: never;
|
|
248
|
+
} | {
|
|
249
|
+
/**
|
|
250
|
+
* The name of the component exported by this frontend module.
|
|
251
|
+
*/
|
|
252
|
+
component?: never;
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
load: () => Promise<{
|
|
257
|
+
default?: LifeCycles;
|
|
258
|
+
} & LifeCycles>;
|
|
259
|
+
});
|
|
260
|
+
export type WorkspaceWindowState = 'maximized' | 'hidden' | 'normal';
|
|
261
|
+
/**
|
|
262
|
+
* A definition of a workspace as extracted from an app's routes.json
|
|
263
|
+
*/
|
|
264
|
+
export type WorkspaceDefinition = {
|
|
265
|
+
/**
|
|
266
|
+
* The name of this workspace. This is used to launch the workspace.
|
|
267
|
+
*/
|
|
268
|
+
name: string;
|
|
269
|
+
/**
|
|
270
|
+
* The title of the workspace. This will be looked up as a key in the translations of the module
|
|
271
|
+
* defining the workspace.
|
|
272
|
+
*/
|
|
273
|
+
title: string;
|
|
274
|
+
/**
|
|
275
|
+
* The type of the workspace. Only one of each "type" of workspace is allowed to be open at a
|
|
276
|
+
* time. The default is "form". If the right sidebar is in use, then the type determines which
|
|
277
|
+
* right sidebar icon corresponds to the workspace.
|
|
278
|
+
*/
|
|
279
|
+
type: string;
|
|
280
|
+
canHide?: boolean;
|
|
281
|
+
canMaximize?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Controls the width of the workspace. The default is "narrow" and this should only be
|
|
284
|
+
* changed to "wider" if the workspace itself has internal navigation, like the form editor.
|
|
285
|
+
* The width "extra-wide" is for workspaces that contain their own sidebar.
|
|
286
|
+
*/
|
|
287
|
+
width?: 'narrow' | 'wider' | 'extra-wide';
|
|
288
|
+
/**
|
|
289
|
+
* Launches the workspace in the preferred size, it defaults to the 'narrow' width
|
|
290
|
+
*/
|
|
291
|
+
preferredWindowSize?: WorkspaceWindowState;
|
|
292
|
+
/**
|
|
293
|
+
* Workspaces can open either independently or as part of a "workspace group". A
|
|
294
|
+
* "workspace group" groups related workspaces together, so that only one is visible
|
|
295
|
+
* at a time. For example,
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
*
|
|
299
|
+
* {
|
|
300
|
+
* name: 'order-basket',
|
|
301
|
+
* type: 'order',
|
|
302
|
+
* groups: ['ward-patient']
|
|
303
|
+
* }
|
|
304
|
+
*
|
|
305
|
+
* This means that the 'order-basket' workspace can be opened independently, or only
|
|
306
|
+
* in the 'ward-patient'.
|
|
307
|
+
* If a workspace group is already open and a new workspace is launched, and the
|
|
308
|
+
* groups in the newly launched workspace do not include the currently open group’s
|
|
309
|
+
* name, the entire workspace group will close, and the new workspace will launch independently.
|
|
310
|
+
*
|
|
311
|
+
*/
|
|
312
|
+
groups: Array<string>;
|
|
313
|
+
} & ({
|
|
314
|
+
/**
|
|
315
|
+
* The name of the component exported by this frontend module.
|
|
316
|
+
*/
|
|
317
|
+
component: string;
|
|
318
|
+
/**
|
|
319
|
+
* @internal
|
|
320
|
+
*/
|
|
321
|
+
load?: never;
|
|
322
|
+
} | {
|
|
323
|
+
/**
|
|
324
|
+
* The name of the component exported by this frontend module.
|
|
325
|
+
*/
|
|
326
|
+
component?: never;
|
|
327
|
+
/**
|
|
328
|
+
* @internal
|
|
329
|
+
*/
|
|
330
|
+
load: () => Promise<{
|
|
331
|
+
default?: LifeCycles;
|
|
332
|
+
} & LifeCycles>;
|
|
333
|
+
});
|
|
334
|
+
export interface WorkspaceGroupDefinition {
|
|
335
|
+
/**
|
|
336
|
+
* Name of the workspace group. This is used to launch the workspace group
|
|
337
|
+
*/
|
|
338
|
+
name: string;
|
|
339
|
+
/**
|
|
340
|
+
* List of workspace names which are part of the workspace group.
|
|
341
|
+
*/
|
|
342
|
+
members?: Array<string>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A definition of a feature flag extracted from the routes.json
|
|
346
|
+
*/
|
|
347
|
+
export interface FeatureFlagDefinition {
|
|
348
|
+
/** A code-friendly name for the flag, which will be used to reference it in code */
|
|
349
|
+
flagName: string;
|
|
350
|
+
/** A human-friendly name which will be displayed in the Implementer Tools */
|
|
351
|
+
label: string;
|
|
352
|
+
/** An explanation of what the flag does, which will be displayed in the Implementer Tools */
|
|
353
|
+
description: string;
|
|
354
|
+
}
|
|
355
|
+
/** This interface describes the format of the routes provided by an app */
|
|
356
|
+
export interface OpenmrsAppRoutes {
|
|
357
|
+
/** The version of this frontend module. */
|
|
358
|
+
version?: string;
|
|
359
|
+
/** A list of backend modules necessary for this frontend module and the corresponding required versions. */
|
|
360
|
+
backendDependencies?: Record<string, string>;
|
|
361
|
+
/** A list of backend modules that may enable optional functionality in this frontend module if available and the corresponding required versions. */
|
|
362
|
+
optionalBackendDependencies?: {
|
|
363
|
+
/** The name of the backend dependency and either the required version or an object describing the required version */
|
|
364
|
+
[key: string]: string | {
|
|
365
|
+
/** The minimum version of this optional dependency that must be present. */
|
|
366
|
+
version: string;
|
|
367
|
+
/** The feature flag to enable if this backend dependency is present */
|
|
368
|
+
feature?: FeatureFlagDefinition;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
/** An array of all pages supported by this frontend module. Pages are automatically mounted based on a route. */
|
|
372
|
+
pages?: Array<PageDefinition>;
|
|
373
|
+
/** An array of all extensions supported by this frontend module. Extensions can be mounted in extension slots, either via declarations in this file or configuration. */
|
|
374
|
+
extensions?: Array<ExtensionDefinition>;
|
|
375
|
+
/** An array of all feature flags for any beta-stage features this module provides. */
|
|
376
|
+
featureFlags?: Array<FeatureFlagDefinition>;
|
|
377
|
+
/** An array of all modals supported by this frontend module. Modals can be launched by name. */
|
|
378
|
+
modals?: Array<ModalDefinition>;
|
|
379
|
+
/** An array of all workspaces supported by this frontend module. Workspaces can be launched by name. */
|
|
380
|
+
workspaces?: Array<WorkspaceDefinition>;
|
|
381
|
+
/** An array of all workspace groups supported by this frontend module. */
|
|
382
|
+
workspaceGroups?: Array<WorkspaceGroupDefinition>;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* This interfaces describes the format of the overall rotues.json loaded by the app shell.
|
|
386
|
+
* Basically, this is the same as the app routes, with each routes definition keyed by the app's name
|
|
387
|
+
*/
|
|
388
|
+
export type OpenmrsRoutes = Record<string, OpenmrsAppRoutes>;
|
|
389
|
+
export interface ResourceLoader<T = any> {
|
|
390
|
+
(): Promise<T>;
|
|
391
|
+
}
|
|
392
|
+
export type NameUse = 'usual' | 'official' | 'temp' | 'nickname' | 'anonymous' | 'old' | 'maiden';
|
|
393
|
+
export {};
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-globals",
|
|
3
|
-
"version": "6.3.1-pre.
|
|
3
|
+
"version": "6.3.1-pre.2986",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./src/public": {
|
|
14
|
+
"types": "./src/public.ts",
|
|
15
|
+
"default": "./dist/public.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
7
18
|
"source": true,
|
|
8
19
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"build:development": "
|
|
11
|
-
"
|
|
12
|
-
"typescript": "tsc",
|
|
20
|
+
"build": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
21
|
+
"build:development": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
22
|
+
"typescript": "tsc --project tsconfig.build.json",
|
|
13
23
|
"lint": "eslint src --ext ts,tsx"
|
|
14
24
|
},
|
|
15
25
|
"keywords": [
|
|
@@ -40,6 +50,10 @@
|
|
|
40
50
|
"single-spa": "6.x"
|
|
41
51
|
},
|
|
42
52
|
"devDependencies": {
|
|
53
|
+
"@swc/cli": "^0.7.7",
|
|
54
|
+
"@swc/core": "^1.11.29",
|
|
55
|
+
"concurrently": "^9.1.2",
|
|
56
|
+
"rimraf": "^6.0.1",
|
|
43
57
|
"single-spa": "^6.0.3"
|
|
44
58
|
},
|
|
45
59
|
"stableVersion": "6.3.0"
|
package/src/events.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface ConnectivityChangedEvent {
|
|
|
4
4
|
|
|
5
5
|
const connectivityChangedEventName = 'openmrs:connectivity-changed';
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export function dispatchConnectivityChanged(online: boolean) {
|
|
8
9
|
window.dispatchEvent(new CustomEvent(connectivityChangedEventName, { detail: { online } }));
|
|
9
10
|
}
|
|
@@ -88,14 +89,17 @@ export function dispatchNotificationShown(data: ShowNotificationEvent) {
|
|
|
88
89
|
window.dispatchEvent(new CustomEvent(notificationShownName, { detail: data }));
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
/** @internal */
|
|
91
93
|
export function dispatchActionableNotificationShown(data: ShowActionableNotificationEvent) {
|
|
92
94
|
window.dispatchEvent(new CustomEvent(actionableNotificationShownName, { detail: data }));
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
/** @internal */
|
|
95
98
|
export function dispatchSnackbarShown(data: ShowSnackbarEvent) {
|
|
96
99
|
window.dispatchEvent(new CustomEvent(snackbarShownName, { detail: data }));
|
|
97
100
|
}
|
|
98
101
|
|
|
102
|
+
/** @internal */
|
|
99
103
|
export function dispatchToastShown(data: ShowToastEvent) {
|
|
100
104
|
window.dispatchEvent(new CustomEvent(toastShownName, { detail: data }));
|
|
101
105
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"target": "es2015",
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"strictNullChecks": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationDir": "dist",
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
"lib": [
|
|
14
|
-
"dom",
|
|
15
|
-
"es5",
|
|
16
|
-
"scripthost",
|
|
17
|
-
"es2015",
|
|
18
|
-
"es2015.promise",
|
|
19
|
-
"es2016.array.include",
|
|
20
|
-
"es2018",
|
|
21
|
-
"esnext"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
|
-
"include": ["src/**/*"]
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"extends": "../tsconfig.json",
|
|
4
|
+
"include": ["src/**/*.ts*"]
|
|
25
5
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
System.register([],(function(n,e){return{execute:function(){n((()=>{"use strict";var n={d:(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},e={};n.r(e),n.d(e,{dispatchActionableNotificationShown:()=>h,dispatchConnectivityChanged:()=>i,dispatchNotificationShown:()=>f,dispatchPrecacheStaticDependencies:()=>a,dispatchSnackbarShown:()=>l,dispatchToastShown:()=>b,subscribeActionableNotificationShown:()=>E,subscribeConnectivity:()=>r,subscribeConnectivityChanged:()=>o,subscribeNotificationShown:()=>p,subscribePrecacheStaticDependencies:()=>d,subscribeSnackbarShown:()=>S,subscribeToastShown:()=>m});var t="openmrs:connectivity-changed";function i(n){window.dispatchEvent(new CustomEvent(t,{detail:{online:n}}))}function o(n){if(!window.offlineEnabled)return function(){};var e=function(e){return n(e.detail)};return window.addEventListener(t,e),function(){return window.removeEventListener(t,e)}}function r(n){return n({online:!window.offlineEnabled||navigator.onLine}),o(n)}var c="openmrs:precache-static-dependencies";function a(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};window.dispatchEvent(new CustomEvent(c,{detail:n}))}function d(n){var e=function(e){return n(e.detail)};return window.addEventListener(c,e),function(){return window.removeEventListener(c,e)}}var u="openmrs:notification-shown",s="openmrs:actionable-notification-shown",w="openmrs:toast-shown",v="openmrs:snack-bar-shown";function f(n){window.dispatchEvent(new CustomEvent(u,{detail:n}))}function h(n){window.dispatchEvent(new CustomEvent(s,{detail:n}))}function l(n){window.dispatchEvent(new CustomEvent(v,{detail:n}))}function b(n){window.dispatchEvent(new CustomEvent(w,{detail:n}))}function p(n){var e=function(e){return n(e.detail)};return window.addEventListener(u,e),function(){return window.removeEventListener(u,e)}}function E(n){var e=function(e){return n(e.detail)};return window.addEventListener(s,e),function(){return window.removeEventListener(s,e)}}function m(n){var e=function(e){return n(e.detail)};return window.addEventListener(w,e),function(){return window.removeEventListener(w,e)}}function S(n){var e=function(e){return n(e.detail)};return window.addEventListener(v,e),function(){return window.removeEventListener(v,e)}}return e})())}}}));
|
|
2
|
-
//# sourceMappingURL=openmrs-esm-globals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openmrs-esm-globals.js","mappings":"iFACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,2cCD9D,IAAMC,EAA+B,+BAE9B,SAASC,EAA4BC,GAC1CC,OAAOC,cAAc,IAAIC,YAAYL,EAA8B,CAAEM,OAAQ,CAAEJ,OAAAA,KACjF,CAGO,SAASK,EAA6BC,GAC3C,IAAKL,OAAOM,eACV,OAAO,WAAO,EAGhB,IAAMC,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBZ,EAA8BU,GAC/C,W,OAAMP,OAAOU,oBAAoBb,EAA8BU,E,CACxE,CAGO,SAASI,EAAsBN,GAEpC,OADAA,EAAG,CAAEN,QAAQC,OAAOM,gBAAiBM,UAAUC,SACxCT,EAA6BC,EACtC,CAIA,IAAMS,EAAsC,uCAErC,SAASC,I,IAAmCC,EAAAA,UAAAA,OAAAA,QAAAA,IAAAA,UAAAA,GAAAA,UAAAA,GAAwC,CAAC,EAC1FhB,OAAOC,cAAc,IAAIC,YAAYY,EAAqC,CAAEX,OAAQa,IACtF,CAGO,SAASC,EAAoCZ,GAClD,IAAME,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBK,EAAqCP,GACtD,W,OAAMP,OAAOU,oBAAoBI,EAAqCP,E,CAC/E,CAyCA,IAAMW,EAAwB,6BACxBC,EAAkC,wCAClCC,EAAiB,sBACjBC,EAAoB,0BAEnB,SAASC,EAA0BN,GACxChB,OAAOC,cAAc,IAAIC,YAAYgB,EAAuB,CAAEf,OAAQa,IACxE,CAEO,SAASO,EAAoCP,GAClDhB,OAAOC,cAAc,IAAIC,YAAYiB,EAAiC,CAAEhB,OAAQa,IAClF,CAEO,SAASQ,EAAsBR,GACpChB,OAAOC,cAAc,IAAIC,YAAYmB,EAAmB,CAAElB,OAAQa,IACpE,CAEO,SAASS,EAAmBT,GACjChB,OAAOC,cAAc,IAAIC,YAAYkB,EAAgB,CAAEjB,OAAQa,IACjE,CAGO,SAASU,EAA2BrB,GACzC,IAAME,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBS,EAAuBX,GACxC,W,OAAMP,OAAOU,oBAAoBQ,EAAuBX,E,CACjE,CAGO,SAASoB,EAAqCtB,GACnD,IAAME,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBU,EAAiCZ,GAClD,W,OAAMP,OAAOU,oBAAoBS,EAAiCZ,E,CAC3E,CAGO,SAASqB,EAAoBvB,GAClC,IAAME,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBW,EAAgBb,GACjC,W,OAAMP,OAAOU,oBAAoBU,EAAgBb,E,CAC1D,CAGO,SAASsB,EAAuBxB,GACrC,IAAME,EAAU,SAACC,G,OAAoBH,EAAGG,EAAGL,O,EAE3C,OADAH,OAAOS,iBAAiBY,EAAmBd,GACpC,W,OAAMP,OAAOU,oBAAoBW,EAAmBd,E,CAC7D,C","sources":["webpack://@openmrs/esm-globals/webpack/bootstrap","webpack://@openmrs/esm-globals/webpack/runtime/define property getters","webpack://@openmrs/esm-globals/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-globals/webpack/runtime/make namespace object","webpack://@openmrs/esm-globals/./src/events.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export interface ConnectivityChangedEvent {\n online: boolean;\n}\n\nconst connectivityChangedEventName = 'openmrs:connectivity-changed';\n\nexport function dispatchConnectivityChanged(online: boolean) {\n window.dispatchEvent(new CustomEvent(connectivityChangedEventName, { detail: { online } }));\n}\n\n/** @category Offline */\nexport function subscribeConnectivityChanged(cb: (ev: ConnectivityChangedEvent) => void) {\n if (!window.offlineEnabled) {\n return () => {};\n }\n\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(connectivityChangedEventName, handler);\n return () => window.removeEventListener(connectivityChangedEventName, handler);\n}\n\n/** @category Offline */\nexport function subscribeConnectivity(cb: (ev: ConnectivityChangedEvent) => void) {\n cb({ online: window.offlineEnabled ? navigator.onLine : true });\n return subscribeConnectivityChanged(cb);\n}\n\nexport interface PrecacheStaticDependenciesEvent {}\n\nconst precacheStaticDependenciesEventName = 'openmrs:precache-static-dependencies';\n\nexport function dispatchPrecacheStaticDependencies(data: PrecacheStaticDependenciesEvent = {}) {\n window.dispatchEvent(new CustomEvent(precacheStaticDependenciesEventName, { detail: data }));\n}\n\n/** @category Offline */\nexport function subscribePrecacheStaticDependencies(cb: (data: PrecacheStaticDependenciesEvent) => void) {\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(precacheStaticDependenciesEventName, handler);\n return () => window.removeEventListener(precacheStaticDependenciesEventName, handler);\n}\n\n/** @category UI */\nexport interface ShowNotificationEvent {\n description: any;\n kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';\n title?: string;\n action?: any;\n millis?: number;\n}\n\nexport interface ShowActionableNotificationEvent {\n subtitle: any;\n kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';\n title?: string;\n actionButtonLabel: string | any;\n onActionButtonClick: () => void;\n progressActionLabel?: string;\n}\n\n/** @category UI */\nexport interface ShowToastEvent {\n description: any;\n kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';\n title?: string;\n actionButtonLabel?: string | any;\n onActionButtonClick?: () => void;\n}\n\n/** @category UI */\nexport interface ShowSnackbarEvent {\n subtitle?: any;\n kind?: 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';\n title: string;\n actionButtonLabel?: string | any;\n onActionButtonClick?: () => void;\n progressActionLabel?: string;\n isLowContrast?: boolean;\n timeoutInMs?: number;\n}\n\nconst notificationShownName = 'openmrs:notification-shown';\nconst actionableNotificationShownName = 'openmrs:actionable-notification-shown';\nconst toastShownName = 'openmrs:toast-shown';\nconst snackbarShownName = 'openmrs:snack-bar-shown';\n\nexport function dispatchNotificationShown(data: ShowNotificationEvent) {\n window.dispatchEvent(new CustomEvent(notificationShownName, { detail: data }));\n}\n\nexport function dispatchActionableNotificationShown(data: ShowActionableNotificationEvent) {\n window.dispatchEvent(new CustomEvent(actionableNotificationShownName, { detail: data }));\n}\n\nexport function dispatchSnackbarShown(data: ShowSnackbarEvent) {\n window.dispatchEvent(new CustomEvent(snackbarShownName, { detail: data }));\n}\n\nexport function dispatchToastShown(data: ShowToastEvent) {\n window.dispatchEvent(new CustomEvent(toastShownName, { detail: data }));\n}\n\n/** @category UI */\nexport function subscribeNotificationShown(cb: (data: ShowNotificationEvent) => void) {\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(notificationShownName, handler);\n return () => window.removeEventListener(notificationShownName, handler);\n}\n\n/** @category UI */\nexport function subscribeActionableNotificationShown(cb: (data: ShowActionableNotificationEvent) => void) {\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(actionableNotificationShownName, handler);\n return () => window.removeEventListener(actionableNotificationShownName, handler);\n}\n\n/** @category UI */\nexport function subscribeToastShown(cb: (data: ShowToastEvent) => void) {\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(toastShownName, handler);\n return () => window.removeEventListener(toastShownName, handler);\n}\n\n/** @category UI */\nexport function subscribeSnackbarShown(cb: (data: ShowSnackbarEvent) => void) {\n const handler = (ev: CustomEvent) => cb(ev.detail);\n window.addEventListener(snackbarShownName, handler);\n return () => window.removeEventListener(snackbarShownName, handler);\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","connectivityChangedEventName","dispatchConnectivityChanged","online","window","dispatchEvent","CustomEvent","detail","subscribeConnectivityChanged","cb","offlineEnabled","handler","ev","addEventListener","removeEventListener","subscribeConnectivity","navigator","onLine","precacheStaticDependenciesEventName","dispatchPrecacheStaticDependencies","data","subscribePrecacheStaticDependencies","notificationShownName","actionableNotificationShownName","toastShownName","snackbarShownName","dispatchNotificationShown","dispatchActionableNotificationShown","dispatchSnackbarShown","dispatchToastShown","subscribeNotificationShown","subscribeActionableNotificationShown","subscribeToastShown","subscribeSnackbarShown"],"sourceRoot":""}
|
package/webpack.config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
2
|
-
const { resolve } = require('path');
|
|
3
|
-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
4
|
-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
5
|
-
|
|
6
|
-
const { peerDependencies } = require('./package.json');
|
|
7
|
-
|
|
8
|
-
module.exports = (env) => ({
|
|
9
|
-
entry: [resolve(__dirname, 'src/index.ts')],
|
|
10
|
-
output: {
|
|
11
|
-
filename: 'openmrs-esm-globals.js',
|
|
12
|
-
path: resolve(__dirname, 'dist'),
|
|
13
|
-
library: { type: 'system' },
|
|
14
|
-
},
|
|
15
|
-
devtool: 'source-map',
|
|
16
|
-
module: {
|
|
17
|
-
rules: [
|
|
18
|
-
{
|
|
19
|
-
test: /\.m?(js|ts|tsx)$/,
|
|
20
|
-
exclude: /node_modules/,
|
|
21
|
-
use: 'swc-loader',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
externals: Object.keys(peerDependencies || {}),
|
|
26
|
-
resolve: {
|
|
27
|
-
extensions: ['.ts', '.js', '.tsx', '.jsx'],
|
|
28
|
-
},
|
|
29
|
-
plugins: [
|
|
30
|
-
new CleanWebpackPlugin(),
|
|
31
|
-
new ForkTsCheckerWebpackPlugin(),
|
|
32
|
-
new BundleAnalyzerPlugin({
|
|
33
|
-
analyzerMode: env && env.analyze ? 'static' : 'disabled',
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
36
|
-
devServer: {
|
|
37
|
-
disableHostCheck: true,
|
|
38
|
-
headers: {
|
|
39
|
-
'Access-Control-Allow-Origin': '*',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|