@aehrc/smart-forms-renderer 1.0.0-alpha.37 → 1.0.0-alpha.38
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/lib/hooks/useParseXhtml.js +48 -3
- package/lib/hooks/useParseXhtml.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useParseXhtml.tsx +61 -3
- package/src/stories/assets/questionnaires/QAdvancedTextApperance.ts +88 -2
- package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +14 -6
- package/src/stories/sdc/BehaviorOther.stories.tsx +1 -8
- package/src/stories/storybookWrappers/BuildFormWrapperForStorybook.tsx +2 -1
- package/src/stories/storybookWrappers/TestCssSheet.css +17 -0
|
@@ -39,6 +39,17 @@ export function useParseXhtml(qItem) {
|
|
|
39
39
|
return _jsx(_Fragment, {});
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
// Extract external CSS styles from class attributes
|
|
43
|
+
// To use this, define your stylesheet where you are calling <BaseRenderer/> in your app
|
|
44
|
+
if (domNode.name === 'div' && domNode.attribs.class) {
|
|
45
|
+
const classNames = domNode.attribs.class.split(/\s+/);
|
|
46
|
+
classNames.forEach((className) => {
|
|
47
|
+
const classStyles = getStylesFromClass(className);
|
|
48
|
+
if (classStyles) {
|
|
49
|
+
extractedStyles = Object.assign(Object.assign({}, extractedStyles), classStyles);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
// Extract styles from the root div for group-level styling
|
|
43
54
|
if (domNode.name === 'div' &&
|
|
44
55
|
!domNode.attribs.class &&
|
|
@@ -53,9 +64,7 @@ export function useParseXhtml(qItem) {
|
|
|
53
64
|
const [property, value] = style.split(':');
|
|
54
65
|
if (property && value) {
|
|
55
66
|
// Convert kebab-case to camelCase for React
|
|
56
|
-
const propName = property
|
|
57
|
-
.trim()
|
|
58
|
-
.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
67
|
+
const propName = convertKebabToCamelCase(property);
|
|
59
68
|
styleObj[propName] = value.trim();
|
|
60
69
|
}
|
|
61
70
|
}
|
|
@@ -103,4 +112,40 @@ export function useParseXhtml(qItem) {
|
|
|
103
112
|
};
|
|
104
113
|
}, [qItem]);
|
|
105
114
|
}
|
|
115
|
+
function getStylesFromClass(className) {
|
|
116
|
+
if (!className) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const selector = className.startsWith('.') ? className : `.${className}`;
|
|
120
|
+
for (const sheet of document.styleSheets) {
|
|
121
|
+
try {
|
|
122
|
+
const rules = sheet.cssRules;
|
|
123
|
+
for (const rule of rules) {
|
|
124
|
+
if (rule instanceof CSSStyleRule && rule.selectorText === selector) {
|
|
125
|
+
const computedStyles = {};
|
|
126
|
+
const style = rule.style;
|
|
127
|
+
for (let i = 0; i < style.length; i++) {
|
|
128
|
+
const property = style[i];
|
|
129
|
+
// Convert propertyName from kebab-case to camelCase for React
|
|
130
|
+
const propNameCamelCase = convertKebabToCamelCase(property);
|
|
131
|
+
computedStyles[propNameCamelCase] = style.getPropertyValue(property);
|
|
132
|
+
}
|
|
133
|
+
return computedStyles;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof DOMException && error.name === 'SecurityError') {
|
|
139
|
+
console.warn(`Unable to access stylesheet due to CORS restrictions: Skipping sheet ${sheet.href}. Add crossorigin="anonymous" to the stylesheet link if you want to bypass this warning.`, sheet.href);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
console.warn(`Error accessing stylesheet ${sheet.href}`, error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
// Convert kebab-case to camelCase for React
|
|
148
|
+
function convertKebabToCamelCase(property) {
|
|
149
|
+
return property.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
150
|
+
}
|
|
106
151
|
//# sourceMappingURL=useParseXht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oBAEzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;wBACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;wBAE1B,8DAA8D;wBAC9D,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;wBAE5D,cAAc,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBACvE,CAAC;oBAED,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBACpE,OAAO,CAAC,IAAI,CACV,wEAAwE,KAAK,CAAC,IAAI,0FAA0F,EAC5K,KAAK,CAAC,IAAI,CACX,CAAC;gBACF,SAAS;YACX,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,8BAA8B,KAAK,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,4CAA4C;AAC5C,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACnF,CAAC"}
|
package/package.json
CHANGED
|
@@ -52,6 +52,18 @@ export function useParseXhtml(qItem: QuestionnaireItem): ParsedXhtml | null {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Extract external CSS styles from class attributes
|
|
56
|
+
// To use this, define your stylesheet where you are calling <BaseRenderer/> in your app
|
|
57
|
+
if (domNode.name === 'div' && domNode.attribs.class) {
|
|
58
|
+
const classNames = domNode.attribs.class.split(/\s+/);
|
|
59
|
+
classNames.forEach((className) => {
|
|
60
|
+
const classStyles = getStylesFromClass(className);
|
|
61
|
+
if (classStyles) {
|
|
62
|
+
extractedStyles = { ...extractedStyles, ...classStyles };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
55
67
|
// Extract styles from the root div for group-level styling
|
|
56
68
|
if (
|
|
57
69
|
domNode.name === 'div' &&
|
|
@@ -68,9 +80,7 @@ export function useParseXhtml(qItem: QuestionnaireItem): ParsedXhtml | null {
|
|
|
68
80
|
const [property, value] = style.split(':');
|
|
69
81
|
if (property && value) {
|
|
70
82
|
// Convert kebab-case to camelCase for React
|
|
71
|
-
const propName = property
|
|
72
|
-
.trim()
|
|
73
|
-
.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
83
|
+
const propName = convertKebabToCamelCase(property);
|
|
74
84
|
styleObj[propName] = value.trim();
|
|
75
85
|
}
|
|
76
86
|
}
|
|
@@ -127,3 +137,51 @@ export function useParseXhtml(qItem: QuestionnaireItem): ParsedXhtml | null {
|
|
|
127
137
|
};
|
|
128
138
|
}, [qItem]);
|
|
129
139
|
}
|
|
140
|
+
|
|
141
|
+
function getStylesFromClass(className: string): Record<string, string> | null {
|
|
142
|
+
if (!className) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const selector = className.startsWith('.') ? className : `.${className}`;
|
|
147
|
+
|
|
148
|
+
for (const sheet of document.styleSheets) {
|
|
149
|
+
try {
|
|
150
|
+
const rules = sheet.cssRules;
|
|
151
|
+
for (const rule of rules) {
|
|
152
|
+
if (rule instanceof CSSStyleRule && rule.selectorText === selector) {
|
|
153
|
+
const computedStyles: Record<string, string> = {};
|
|
154
|
+
const style = rule.style;
|
|
155
|
+
|
|
156
|
+
for (let i = 0; i < style.length; i++) {
|
|
157
|
+
const property = style[i];
|
|
158
|
+
|
|
159
|
+
// Convert propertyName from kebab-case to camelCase for React
|
|
160
|
+
const propNameCamelCase = convertKebabToCamelCase(property);
|
|
161
|
+
|
|
162
|
+
computedStyles[propNameCamelCase] = style.getPropertyValue(property);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return computedStyles;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error instanceof DOMException && error.name === 'SecurityError') {
|
|
170
|
+
console.warn(
|
|
171
|
+
`Unable to access stylesheet due to CORS restrictions: Skipping sheet ${sheet.href}. Add crossorigin="anonymous" to the stylesheet link if you want to bypass this warning.`,
|
|
172
|
+
sheet.href
|
|
173
|
+
);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
console.warn(`Error accessing stylesheet ${sheet.href}`, error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Convert kebab-case to camelCase for React
|
|
185
|
+
function convertKebabToCamelCase(property: string): string {
|
|
186
|
+
return property.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
187
|
+
}
|
|
@@ -244,7 +244,7 @@ export const qHidden: Questionnaire = {
|
|
|
244
244
|
]
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
export const
|
|
247
|
+
export const qRenderingXhtmlGroupPropagationNested: Questionnaire = {
|
|
248
248
|
resourceType: 'Questionnaire',
|
|
249
249
|
id: 'RenderingXhtmlGroupPropagation',
|
|
250
250
|
name: 'RenderingXhtmlGroupPropagation',
|
|
@@ -330,7 +330,7 @@ export const qRenderingXhtmlGroupPropagation: Questionnaire = {
|
|
|
330
330
|
]
|
|
331
331
|
};
|
|
332
332
|
|
|
333
|
-
export const
|
|
333
|
+
export const qRenderingXhtmlGroupPropagationInlineStyles: Questionnaire = {
|
|
334
334
|
resourceType: 'Questionnaire',
|
|
335
335
|
id: 'RenderingXhtmlGroupPropagationCalcExpression',
|
|
336
336
|
name: 'RenderingXhtmlGroupPropagationCalcExpression',
|
|
@@ -415,3 +415,89 @@ export const qRenderingXhtmlGroupPropagationCalcExpression: Questionnaire = {
|
|
|
415
415
|
}
|
|
416
416
|
]
|
|
417
417
|
};
|
|
418
|
+
|
|
419
|
+
export const qRenderingXhtmlGroupPropagationClassStyles: Questionnaire = {
|
|
420
|
+
resourceType: 'Questionnaire',
|
|
421
|
+
id: 'RenderingXhtmlGroupPropagationCalcExpression',
|
|
422
|
+
name: 'RenderingXhtmlGroupPropagationCalcExpression',
|
|
423
|
+
title: 'RenderingXhtmlGroupPropagationCalcExpression',
|
|
424
|
+
version: '0.1.0',
|
|
425
|
+
status: 'draft',
|
|
426
|
+
publisher: 'AEHRC CSIRO',
|
|
427
|
+
date: '2024-05-01',
|
|
428
|
+
url: 'https://smartforms.csiro.au/docs/advanced/text/rendering-xhtml-4',
|
|
429
|
+
extension: [
|
|
430
|
+
{
|
|
431
|
+
url: 'http://hl7.org/fhir/StructureDefinition/variable',
|
|
432
|
+
valueExpression: {
|
|
433
|
+
name: 'patientToRefer',
|
|
434
|
+
language: 'text/fhirpath',
|
|
435
|
+
expression:
|
|
436
|
+
"%resource.item.where(linkId='referral-group').item.where(linkId='referral-patient-picker').answer.value"
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
],
|
|
440
|
+
item: [
|
|
441
|
+
{
|
|
442
|
+
linkId: 'referral-group',
|
|
443
|
+
text: 'Referral',
|
|
444
|
+
type: 'group',
|
|
445
|
+
item: [
|
|
446
|
+
{
|
|
447
|
+
linkId: 'referral-patient-picker',
|
|
448
|
+
text: 'Select patient to refer',
|
|
449
|
+
type: 'choice',
|
|
450
|
+
answerOption: [
|
|
451
|
+
{
|
|
452
|
+
valueString: 'Adam'
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
valueString: 'Alan'
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
{
|
|
459
|
+
valueString: 'Ben'
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
linkId: 'referral-group-info',
|
|
465
|
+
type: 'group',
|
|
466
|
+
extension: [
|
|
467
|
+
{
|
|
468
|
+
url: 'http://hl7.org/fhir/StructureDefinition/rendering-xhtml',
|
|
469
|
+
valueString:
|
|
470
|
+
'<div class="group-custom-bg bold" role="status" xmlns="http://www.w3.org/1999/xhtml"><img alt="Information" src="https://www.digitalhealth.gov.au/chap/info.svg" /><div><h2>Consider a referral</h2></div></div>'
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
item: [
|
|
474
|
+
{
|
|
475
|
+
linkId: '3-BasicExaminations-visiontest-Infopanel-referral4',
|
|
476
|
+
_text: {
|
|
477
|
+
extension: [
|
|
478
|
+
{
|
|
479
|
+
url: 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression',
|
|
480
|
+
valueExpression: {
|
|
481
|
+
description: "Display the patient's first name",
|
|
482
|
+
language: 'text/fhirpath',
|
|
483
|
+
expression:
|
|
484
|
+
"'You may need a referral if ' + %patientToRefer + '\\'s screening result is abnormal, or you\\'re uncertain, and unable to test.'"
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
]
|
|
488
|
+
},
|
|
489
|
+
type: 'display'
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
enableWhen: [
|
|
493
|
+
{
|
|
494
|
+
question: 'referral-patient-picker',
|
|
495
|
+
operator: 'exists',
|
|
496
|
+
answerBoolean: true
|
|
497
|
+
}
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
]
|
|
503
|
+
};
|
|
@@ -25,8 +25,9 @@ import {
|
|
|
25
25
|
qRenderingXhtmlBooleanItem,
|
|
26
26
|
qRenderingXhtmlDisplayBase64ImageItem,
|
|
27
27
|
qRenderingXhtmlDisplayListItem,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
qRenderingXhtmlGroupPropagationClassStyles,
|
|
29
|
+
qRenderingXhtmlGroupPropagationInlineStyles,
|
|
30
|
+
qRenderingXhtmlGroupPropagationNested
|
|
30
31
|
} from '../assets/questionnaires';
|
|
31
32
|
|
|
32
33
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
@@ -66,14 +67,21 @@ export const RenderingXHTMLDisplayBase64Image: Story = {
|
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
export const
|
|
70
|
+
export const RenderingXHTMLGroupPropagationNested: Story = {
|
|
70
71
|
args: {
|
|
71
|
-
questionnaire:
|
|
72
|
+
questionnaire: qRenderingXhtmlGroupPropagationNested
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
|
|
76
|
+
export const RenderingXHTMLGroupPropagationInlineStyles: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
questionnaire: qRenderingXhtmlGroupPropagationInlineStyles
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const RenderingXHTMLGroupPropagationClassStyles: Story = {
|
|
75
83
|
args: {
|
|
76
|
-
questionnaire:
|
|
84
|
+
questionnaire: qRenderingXhtmlGroupPropagationClassStyles
|
|
77
85
|
}
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -26,8 +26,7 @@ import {
|
|
|
26
26
|
qEnableWhenMultiCheckbox,
|
|
27
27
|
qInitialRepeats,
|
|
28
28
|
qInitialSingle,
|
|
29
|
-
qText
|
|
30
|
-
qRenderingXhtmlGroupPropagation
|
|
29
|
+
qText
|
|
31
30
|
} from '../assets/questionnaires'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
32
31
|
|
|
33
32
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
@@ -96,9 +95,3 @@ export const Text: Story = {
|
|
|
96
95
|
questionnaire: qText
|
|
97
96
|
}
|
|
98
97
|
};
|
|
99
|
-
|
|
100
|
-
export const RenderingXhtmlGroupPropagation: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
questionnaire: qRenderingXhtmlGroupPropagation
|
|
103
|
-
}
|
|
104
|
-
};
|
|
@@ -23,7 +23,8 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|
|
23
23
|
import { useBuildForm } from '../../hooks';
|
|
24
24
|
import useRendererQueryClient from '../../hooks/useRendererQueryClient';
|
|
25
25
|
import { STORYBOOK_TERMINOLOGY_SERVER_URL } from './globals';
|
|
26
|
-
|
|
26
|
+
// This stylesheet is using for testing the RenderingXhtmlGroupPropagationClassStyles story
|
|
27
|
+
import './TestCssSheet.css';
|
|
27
28
|
// iframeResizerChild.js needs to be called at least once in the used storybook wrappers to be included in storybook-static
|
|
28
29
|
import './iframeResizerChild';
|
|
29
30
|
import RendererThemeProvider from '../../theme/RendererThemeProvider';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* This stylesheet is using for testing the RenderingXhtmlGroupPropagationClassStyles story, it has no other use outside of this.
|
|
2
|
+
* It works by having a class defined in the XHTML, where the class references external styles from a stylesheet.
|
|
3
|
+
* Please import the stylesheet where you call the <BaseRenderer/> component.
|
|
4
|
+
*
|
|
5
|
+
* NOTE before using:
|
|
6
|
+
* The renderer support this, but it is recommended to define the styles inline in the XHTML.
|
|
7
|
+
* Using external styles means that the Questionnaire itself is not self-contained and the stylings are almost guaranteed to not work in other SDC implementations.
|
|
8
|
+
* For accurate guidance, see https://hl7.org/fhir/R4/narrative.html#:~:text=Authoring%20systems%20may,approach%20with%20care.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
.group-custom-bg {
|
|
12
|
+
background-color: #E9F2FF;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.bold {
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
}
|