@openmrs/esm-styleguide 9.0.3-pre.4473 → 9.0.3-pre.4514
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/.turbo/turbo-build.log +1 -1
- package/dist/index.js +3 -1
- package/dist/svg-utils.d.ts +5 -0
- package/dist/svg-utils.d.ts.map +1 -1
- package/dist/svg-utils.js +33 -0
- package/package.json +20 -20
- package/src/index.ts +3 -1
- package/src/svg-utils.ts +39 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
[0] Successfully compiled: 123 files, copied 164 files with swc (
|
|
1
|
+
[0] Successfully compiled: 123 files, copied 164 files with swc (238.97ms)
|
|
2
2
|
[0] swc --strip-leading-paths --copy-files src -d dist && svgo -rf dist --quiet exited with code 0
|
|
3
3
|
[1] tsc --project tsconfig.build.json exited with code 0
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { defineConfigSchema } from "@openmrs/esm-config";
|
|
2
2
|
import { registerModal } from "@openmrs/esm-extensions";
|
|
3
|
+
import { getSyncLifecycle } from "@openmrs/esm-react-utils";
|
|
3
4
|
import { setupBranding } from "./brand.js";
|
|
4
5
|
import { esmStyleGuideSchema } from "./config-schema.js";
|
|
5
6
|
import { setupEmptyCard } from "./empty-card/empty-card-registration.js";
|
|
6
7
|
import { setupIcons } from "./icons/icon-registration.js";
|
|
7
8
|
import { setupLogo } from "./logo/index.js";
|
|
8
9
|
import { setupPictograms } from "./pictograms/pictogram-registration.js";
|
|
9
|
-
import {
|
|
10
|
+
import { flushSvgs } from "./svg-utils.js";
|
|
10
11
|
import Workspace2ClosePromptModal from "./workspaces2/workspace2-close-prompt.modal.js";
|
|
11
12
|
defineConfigSchema('@openmrs/esm-styleguide', esmStyleGuideSchema);
|
|
12
13
|
setupBranding();
|
|
@@ -14,6 +15,7 @@ setupLogo();
|
|
|
14
15
|
setupIcons();
|
|
15
16
|
setupPictograms();
|
|
16
17
|
setupEmptyCard();
|
|
18
|
+
flushSvgs();
|
|
17
19
|
registerModal({
|
|
18
20
|
name: 'workspace2-close-prompt',
|
|
19
21
|
moduleName: '@openmrs/esm-styleguide',
|
package/dist/svg-utils.d.ts
CHANGED
|
@@ -9,4 +9,9 @@
|
|
|
9
9
|
* @category UI
|
|
10
10
|
*/
|
|
11
11
|
export declare function addSvg(htmlId: string, svgString: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Parses all queued SVGs in a single DOMParser call and appends them to the
|
|
14
|
+
* sprite container. Must be called once after all setup*() registration calls.
|
|
15
|
+
*/
|
|
16
|
+
export declare function flushSvgs(): void;
|
|
12
17
|
//# sourceMappingURL=svg-utils.d.ts.map
|
package/dist/svg-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg-utils.d.ts","sourceRoot":"","sources":["../src/svg-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"svg-utils.d.ts","sourceRoot":"","sources":["../src/svg-utils.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAevD;AAED;;;GAGG;AACH,wBAAgB,SAAS,SAwBxB"}
|
package/dist/svg-utils.js
CHANGED
|
@@ -16,6 +16,8 @@ if (document.readyState === 'complete') {
|
|
|
16
16
|
} else {
|
|
17
17
|
window.addEventListener('load', appendContainer);
|
|
18
18
|
}
|
|
19
|
+
const queue = [];
|
|
20
|
+
let flushed = false;
|
|
19
21
|
/**
|
|
20
22
|
* Adds an SVG to the global SVG sprite container, making it available for use
|
|
21
23
|
* throughout the application via SVG use references.
|
|
@@ -26,6 +28,14 @@ if (document.readyState === 'complete') {
|
|
|
26
28
|
*
|
|
27
29
|
* @category UI
|
|
28
30
|
*/ export function addSvg(htmlId, svgString) {
|
|
31
|
+
if (!flushed) {
|
|
32
|
+
queue.push({
|
|
33
|
+
id: htmlId,
|
|
34
|
+
svg: svgString
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Late additions after flush: parse individually
|
|
29
39
|
const domParser = new DOMParser();
|
|
30
40
|
const dom = domParser.parseFromString(svgString, 'image/svg+xml');
|
|
31
41
|
const svgElement = dom.querySelector('svg');
|
|
@@ -34,3 +44,26 @@ if (document.readyState === 'complete') {
|
|
|
34
44
|
svgContainer.appendChild(svgElement);
|
|
35
45
|
}
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Parses all queued SVGs in a single DOMParser call and appends them to the
|
|
49
|
+
* sprite container. Must be called once after all setup*() registration calls.
|
|
50
|
+
*/ export function flushSvgs() {
|
|
51
|
+
if (flushed) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
flushed = true;
|
|
55
|
+
if (queue.length === 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Concatenate all SVG strings and parse in a single DOMParser call
|
|
59
|
+
const html = queue.map(({ svg })=>svg).join('');
|
|
60
|
+
const domParser = new DOMParser();
|
|
61
|
+
const doc = domParser.parseFromString(`<body>${html}</body>`, 'text/html');
|
|
62
|
+
const svgs = doc.body.querySelectorAll(':scope > svg');
|
|
63
|
+
// Assign IDs by matching queue order to parsed element order
|
|
64
|
+
for(let i = 0; i < svgs.length; i++){
|
|
65
|
+
svgs[i].id = queue[i].id;
|
|
66
|
+
svgContainer.appendChild(svgContainer.ownerDocument.importNode(svgs[i], true));
|
|
67
|
+
}
|
|
68
|
+
queue.length = 0;
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-styleguide",
|
|
3
|
-
"version": "9.0.3-pre.
|
|
3
|
+
"version": "9.0.3-pre.4514",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "The styleguide for OpenMRS SPA",
|
|
6
6
|
"module": "dist/internal.js",
|
|
@@ -97,34 +97,34 @@
|
|
|
97
97
|
"swr": "2.x"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@openmrs/esm-api": "9.0.3-pre.
|
|
101
|
-
"@openmrs/esm-config": "9.0.3-pre.
|
|
102
|
-
"@openmrs/esm-emr-api": "9.0.3-pre.
|
|
103
|
-
"@openmrs/esm-error-handling": "9.0.3-pre.
|
|
104
|
-
"@openmrs/esm-extensions": "9.0.3-pre.
|
|
105
|
-
"@openmrs/esm-globals": "9.0.3-pre.
|
|
106
|
-
"@openmrs/esm-navigation": "9.0.3-pre.
|
|
107
|
-
"@openmrs/esm-react-utils": "9.0.3-pre.
|
|
108
|
-
"@openmrs/esm-routes": "9.0.3-pre.
|
|
109
|
-
"@openmrs/esm-state": "9.0.3-pre.
|
|
110
|
-
"@openmrs/esm-translations": "9.0.3-pre.
|
|
111
|
-
"@openmrs/esm-utils": "9.0.3-pre.
|
|
112
|
-
"@swc/cli": "0.8.
|
|
113
|
-
"@swc/core": "1.15.
|
|
100
|
+
"@openmrs/esm-api": "9.0.3-pre.4514",
|
|
101
|
+
"@openmrs/esm-config": "9.0.3-pre.4514",
|
|
102
|
+
"@openmrs/esm-emr-api": "9.0.3-pre.4514",
|
|
103
|
+
"@openmrs/esm-error-handling": "9.0.3-pre.4514",
|
|
104
|
+
"@openmrs/esm-extensions": "9.0.3-pre.4514",
|
|
105
|
+
"@openmrs/esm-globals": "9.0.3-pre.4514",
|
|
106
|
+
"@openmrs/esm-navigation": "9.0.3-pre.4514",
|
|
107
|
+
"@openmrs/esm-react-utils": "9.0.3-pre.4514",
|
|
108
|
+
"@openmrs/esm-routes": "9.0.3-pre.4514",
|
|
109
|
+
"@openmrs/esm-state": "9.0.3-pre.4514",
|
|
110
|
+
"@openmrs/esm-translations": "9.0.3-pre.4514",
|
|
111
|
+
"@openmrs/esm-utils": "9.0.3-pre.4514",
|
|
112
|
+
"@swc/cli": "0.8.1",
|
|
113
|
+
"@swc/core": "1.15.21",
|
|
114
114
|
"@types/geopattern": "^1.2.9",
|
|
115
|
-
"@vitest/coverage-v8": "^4.
|
|
116
|
-
"concurrently": "^9.1
|
|
117
|
-
"cross-env": "^
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
116
|
+
"concurrently": "^9.2.1",
|
|
117
|
+
"cross-env": "^10.1.0",
|
|
118
118
|
"happy-dom": "^20.6.0",
|
|
119
119
|
"i18next": "^25.5.3",
|
|
120
120
|
"react": "^18.3.1",
|
|
121
121
|
"react-dom": "^18.3.1",
|
|
122
|
-
"rimraf": "^6.
|
|
122
|
+
"rimraf": "^6.1.3",
|
|
123
123
|
"rxjs": "^6.5.3",
|
|
124
124
|
"svgo": "^3.3.2",
|
|
125
125
|
"swr": "2.2.5",
|
|
126
126
|
"typescript": "^5.8.3",
|
|
127
|
-
"vitest": "^4.
|
|
127
|
+
"vitest": "^4.1.2"
|
|
128
128
|
},
|
|
129
129
|
"stableVersion": "9.0.2"
|
|
130
130
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { defineConfigSchema } from '@openmrs/esm-config';
|
|
2
2
|
import { registerModal } from '@openmrs/esm-extensions';
|
|
3
|
+
import { getSyncLifecycle } from '@openmrs/esm-react-utils';
|
|
3
4
|
import { setupBranding } from './brand';
|
|
4
5
|
import { esmStyleGuideSchema } from './config-schema';
|
|
5
6
|
import { setupEmptyCard } from './empty-card/empty-card-registration';
|
|
6
7
|
import { setupIcons } from './icons/icon-registration';
|
|
7
8
|
import { setupLogo } from './logo';
|
|
8
9
|
import { setupPictograms } from './pictograms/pictogram-registration';
|
|
9
|
-
import {
|
|
10
|
+
import { flushSvgs } from './svg-utils';
|
|
10
11
|
import Workspace2ClosePromptModal from './workspaces2/workspace2-close-prompt.modal';
|
|
11
12
|
|
|
12
13
|
defineConfigSchema('@openmrs/esm-styleguide', esmStyleGuideSchema);
|
|
@@ -15,6 +16,7 @@ setupLogo();
|
|
|
15
16
|
setupIcons();
|
|
16
17
|
setupPictograms();
|
|
17
18
|
setupEmptyCard();
|
|
19
|
+
flushSvgs();
|
|
18
20
|
|
|
19
21
|
registerModal({
|
|
20
22
|
name: 'workspace2-close-prompt',
|
package/src/svg-utils.ts
CHANGED
|
@@ -19,6 +19,9 @@ if (document.readyState === 'complete') {
|
|
|
19
19
|
window.addEventListener('load', appendContainer);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const queue: Array<{ id: string; svg: string }> = [];
|
|
23
|
+
let flushed = false;
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
26
|
* Adds an SVG to the global SVG sprite container, making it available for use
|
|
24
27
|
* throughout the application via SVG use references.
|
|
@@ -30,6 +33,12 @@ if (document.readyState === 'complete') {
|
|
|
30
33
|
* @category UI
|
|
31
34
|
*/
|
|
32
35
|
export function addSvg(htmlId: string, svgString: string) {
|
|
36
|
+
if (!flushed) {
|
|
37
|
+
queue.push({ id: htmlId, svg: svgString });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Late additions after flush: parse individually
|
|
33
42
|
const domParser = new DOMParser();
|
|
34
43
|
const dom = domParser.parseFromString(svgString, 'image/svg+xml');
|
|
35
44
|
const svgElement = dom.querySelector('svg');
|
|
@@ -39,3 +48,33 @@ export function addSvg(htmlId: string, svgString: string) {
|
|
|
39
48
|
svgContainer.appendChild(svgElement);
|
|
40
49
|
}
|
|
41
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Parses all queued SVGs in a single DOMParser call and appends them to the
|
|
54
|
+
* sprite container. Must be called once after all setup*() registration calls.
|
|
55
|
+
*/
|
|
56
|
+
export function flushSvgs() {
|
|
57
|
+
if (flushed) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
flushed = true;
|
|
62
|
+
|
|
63
|
+
if (queue.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Concatenate all SVG strings and parse in a single DOMParser call
|
|
68
|
+
const html = queue.map(({ svg }) => svg).join('');
|
|
69
|
+
const domParser = new DOMParser();
|
|
70
|
+
const doc = domParser.parseFromString(`<body>${html}</body>`, 'text/html');
|
|
71
|
+
const svgs = doc.body.querySelectorAll(':scope > svg');
|
|
72
|
+
|
|
73
|
+
// Assign IDs by matching queue order to parsed element order
|
|
74
|
+
for (let i = 0; i < svgs.length; i++) {
|
|
75
|
+
svgs[i].id = queue[i].id;
|
|
76
|
+
svgContainer.appendChild(svgContainer.ownerDocument.importNode(svgs[i], true));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
queue.length = 0;
|
|
80
|
+
}
|