@aehrc/smart-forms-renderer 0.33.0 → 0.34.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.
Files changed (61) hide show
  1. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.d.ts +20 -0
  2. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.js +12 -0
  3. package/lib/components/FormComponents/GroupItem/GroupAccordion.styles.js.map +1 -0
  4. package/lib/components/FormComponents/GroupItem/GroupHeading.js +3 -2
  5. package/lib/components/FormComponents/GroupItem/GroupHeading.js.map +1 -1
  6. package/lib/components/FormComponents/GroupItem/GroupItem.js +2 -15
  7. package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -1
  8. package/lib/components/FormComponents/GroupItem/GroupItem.styles.d.ts +1 -1
  9. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.d.ts +1 -2
  10. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +1 -1
  11. package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
  12. package/lib/components/FormComponents/GroupItem/GroupItemView.d.ts +16 -0
  13. package/lib/components/FormComponents/GroupItem/GroupItemView.js +62 -0
  14. package/lib/components/FormComponents/GroupItem/GroupItemView.js.map +1 -0
  15. package/lib/components/FormComponents/ItemParts/ItemLabelText.js +20 -6
  16. package/lib/components/FormComponents/ItemParts/ItemLabelText.js.map +1 -1
  17. package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js +4 -2
  18. package/lib/components/FormComponents/ItemParts/ItemLabelWrapper.js.map +1 -1
  19. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +2 -37
  20. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
  21. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.d.ts +20 -0
  22. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js +91 -0
  23. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js.map +1 -0
  24. package/lib/components/FormComponents/SingleItem/SingleItem.js +13 -4
  25. package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
  26. package/lib/components/FormComponents/SingleItem/SingleNestedItems.js +11 -7
  27. package/lib/components/FormComponents/SingleItem/SingleNestedItems.js.map +1 -1
  28. package/lib/components/Renderer/FormBodySingleCollapsible.js +5 -4
  29. package/lib/components/Renderer/FormBodySingleCollapsible.js.map +1 -1
  30. package/lib/theme/overrides/Accordion.js +1 -1
  31. package/lib/theme/overrides/Accordion.js.map +1 -1
  32. package/lib/utils/itemControl.d.ts +1 -0
  33. package/lib/utils/itemControl.js +9 -0
  34. package/lib/utils/itemControl.js.map +1 -1
  35. package/lib/utils/qItem.d.ts +2 -0
  36. package/lib/utils/qItem.js +14 -0
  37. package/lib/utils/qItem.js.map +1 -1
  38. package/package.json +3 -2
  39. package/src/components/FormComponents/GroupItem/GroupAccordion.styles.ts +12 -0
  40. package/src/components/FormComponents/GroupItem/GroupHeading.tsx +3 -3
  41. package/src/components/FormComponents/GroupItem/GroupItem.tsx +15 -39
  42. package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +2 -2
  43. package/src/components/FormComponents/GroupItem/GroupItemView.tsx +163 -0
  44. package/src/components/FormComponents/ItemParts/ItemLabelText.tsx +22 -11
  45. package/src/components/FormComponents/ItemParts/ItemLabelWrapper.tsx +8 -1
  46. package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +11 -82
  47. package/src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx +202 -0
  48. package/src/components/FormComponents/SingleItem/SingleItem.tsx +40 -11
  49. package/src/components/FormComponents/SingleItem/SingleNestedItems.tsx +24 -19
  50. package/src/components/Renderer/FormBodySingleCollapsible.tsx +7 -9
  51. package/src/stories/assets/questionnaires/QAdvancedControlAppearance.ts +333 -3
  52. package/src/stories/assets/questionnaires/QAdvancedTextApperance.ts +29 -0
  53. package/src/stories/assets/questionnaires/QDisplay.ts +82 -0
  54. package/src/stories/assets/questionnaires/QMbs715Tester.ts +32888 -0
  55. package/src/stories/itemTypes/Display.stories.tsx +11 -1
  56. package/src/stories/sdc/AdvancedControlAppearance.stories.tsx +26 -1
  57. package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +7 -0
  58. package/src/stories/testing/Mbs715Tester.stories.tsx +57 -0
  59. package/src/theme/overrides/Accordion.ts +1 -1
  60. package/src/utils/itemControl.ts +14 -0
  61. package/src/utils/qItem.ts +24 -0
@@ -17,7 +17,11 @@
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
19
  import BuildFormWrapperForStorybook from '../storybookWrappers/BuildFormWrapperForStorybook';
20
- import { qDisplayBasic, qDisplayCalculation } from '../assets/questionnaires/QDisplay';
20
+ import {
21
+ qDisplayBasic,
22
+ qDisplayCalculation,
23
+ qDisplayCalculationStyled
24
+ } from '../assets/questionnaires/QDisplay';
21
25
 
22
26
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
27
  const meta = {
@@ -43,3 +47,9 @@ export const DisplayCalculation: Story = {
43
47
  questionnaire: qDisplayCalculation
44
48
  }
45
49
  };
50
+
51
+ export const DisplayCalculationStyled: Story = {
52
+ args: {
53
+ questionnaire: qDisplayCalculationStyled
54
+ }
55
+ };
@@ -17,7 +17,14 @@
17
17
 
18
18
  import type { Meta, StoryObj } from '@storybook/react';
19
19
  import BuildFormWrapperForStorybook from '../storybookWrappers/BuildFormWrapperForStorybook';
20
- import { qChoiceOrientation, qItemControl, qSliderStepValue } from '../assets/questionnaires';
20
+ import {
21
+ qChoiceOrientation,
22
+ qCollapsibleDefaultClosed,
23
+ qCollapsibleDefaultOpen,
24
+ qCollapsibleNested,
25
+ qItemControl,
26
+ qSliderStepValue
27
+ } from '../assets/questionnaires';
21
28
 
22
29
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
30
  const meta = {
@@ -49,3 +56,21 @@ export const SliderStepValue: Story = {
49
56
  questionnaire: qSliderStepValue
50
57
  }
51
58
  };
59
+
60
+ export const CollapsibleDefaultOpen: Story = {
61
+ args: {
62
+ questionnaire: qCollapsibleDefaultOpen
63
+ }
64
+ };
65
+
66
+ export const CollapsibleDefaultClosed: Story = {
67
+ args: {
68
+ questionnaire: qCollapsibleDefaultClosed
69
+ }
70
+ };
71
+
72
+ export const CollapsibleNested: Story = {
73
+ args: {
74
+ questionnaire: qCollapsibleNested
75
+ }
76
+ };
@@ -21,6 +21,7 @@ import {
21
21
  qDisplayCategoryInstructions,
22
22
  qHidden,
23
23
  qOpenLabel,
24
+ qRenderingStyleBooleanCheckboxItem,
24
25
  qRenderingXhtmlBooleanCheckboxItem,
25
26
  qRenderingXhtmlDisplayBase64ImageItem,
26
27
  qRenderingXhtmlDisplayListItem
@@ -39,6 +40,12 @@ type Story = StoryObj<typeof meta>;
39
40
 
40
41
  // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
41
42
 
43
+ export const RenderingStyleBooleanCheckbox: Story = {
44
+ args: {
45
+ questionnaire: qRenderingStyleBooleanCheckboxItem
46
+ }
47
+ };
48
+
42
49
  export const RenderingXHTMLBooleanCheckbox: Story = {
43
50
  args: {
44
51
  questionnaire: qRenderingXhtmlBooleanCheckboxItem
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2024 Commonwealth Scientific and Industrial Research
3
+ * Organisation (CSIRO) ABN 41 687 119 230.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import type { Meta, StoryObj } from '@storybook/react';
19
+ import PrePopWrapperForStorybook from '../storybookWrappers/PrePopWrapperForStorybook';
20
+ import {
21
+ qBasicMbs715,
22
+ qModifiedMbs715WithCollapsible
23
+ } from '../assets/questionnaires/QMbs715Tester';
24
+ import { mockFhirClient } from '../assets/fhirClient/mockFhirClient';
25
+ import { patSmartForm } from '../assets/patients/PatSmartForm';
26
+ import { pracPrimaryPeter } from '../assets/practitioners/PracPrimaryPeter';
27
+
28
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
29
+ const meta = {
30
+ title: 'Component/Testing/MBS 715 Tester',
31
+ component: PrePopWrapperForStorybook,
32
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
33
+ tags: []
34
+ } satisfies Meta<typeof PrePopWrapperForStorybook>;
35
+
36
+ export default meta;
37
+ type Story = StoryObj<typeof meta>;
38
+
39
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
40
+
41
+ export const BasicMBS715: Story = {
42
+ args: {
43
+ questionnaire: qBasicMbs715,
44
+ fhirClient: mockFhirClient,
45
+ patient: patSmartForm,
46
+ user: pracPrimaryPeter
47
+ }
48
+ };
49
+
50
+ export const ModifiedMBS715WithCollapsible: Story = {
51
+ args: {
52
+ questionnaire: qModifiedMbs715WithCollapsible,
53
+ fhirClient: mockFhirClient,
54
+ patient: patSmartForm,
55
+ user: pracPrimaryPeter
56
+ }
57
+ };
@@ -22,7 +22,7 @@ export default function Accordion(theme: Theme) {
22
22
  MuiAccordion: {
23
23
  styleOverrides: {
24
24
  root: {
25
- boxShadow: theme.customShadows.z1,
25
+ boxShadow: theme.customShadows.card,
26
26
  borderRadius: Number(theme.shape.borderRadius) * 2,
27
27
  '&:before': {
28
28
  display: 'none'
@@ -19,6 +19,20 @@ import type { Coding, Extension, QuestionnaireItem } from 'fhir/r4';
19
19
  import type { RegexValidation } from '../interfaces/regex.interface';
20
20
  import { structuredDataCapture } from 'fhir-sdc-helpers';
21
21
 
22
+ function hasItemControl(qItem: QuestionnaireItem): boolean {
23
+ return !!qItem.extension?.some(
24
+ (extension: Extension) =>
25
+ extension.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl'
26
+ );
27
+ }
28
+
29
+ // If all nested items are of type display and have itemControl, then they should not be rendered
30
+ export function shouldRenderNestedItems(qItem: QuestionnaireItem): boolean {
31
+ return !qItem.item?.every(
32
+ (childItem) => childItem.type === 'display' && hasItemControl(childItem)
33
+ );
34
+ }
35
+
22
36
  /**
23
37
  * Check if the extension has an itemControl code equal to the given itemControlCode
24
38
  *
@@ -123,3 +123,27 @@ export function getLinkIdTypeTuplesFromItemRecursive(qItem: QuestionnaireItem):
123
123
 
124
124
  return linkIds;
125
125
  }
126
+
127
+ export type CollapsibleType = 'default-open' | 'default-closed';
128
+
129
+ function valueCodeIsCollapsibleType(valueCode: string): valueCode is CollapsibleType {
130
+ return valueCode === 'default-open' || valueCode === 'default-closed';
131
+ }
132
+
133
+ export function getGroupCollapsible(qItem: QuestionnaireItem): CollapsibleType | null {
134
+ const collapsibleExtension = qItem.extension?.find(
135
+ (ext) =>
136
+ ext.url === 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-collapsible'
137
+ );
138
+
139
+ if (collapsibleExtension) {
140
+ if (
141
+ collapsibleExtension.valueCode &&
142
+ valueCodeIsCollapsibleType(collapsibleExtension.valueCode)
143
+ ) {
144
+ return collapsibleExtension.valueCode;
145
+ }
146
+ }
147
+
148
+ return null;
149
+ }