@aehrc/smart-forms-renderer 0.8.1 → 0.9.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/lib/components/FormComponents/BooleanItem/BooleanItem.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +12 -12
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +12 -12
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +3 -4
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.d.ts +2 -2
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.d.ts +18 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js +31 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js +68 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js +75 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js +75 -0
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.d.ts +18 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.js +33 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.d.ts +11 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.js +55 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.js +13 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.d.ts +5 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.js +20 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.d.ts +5 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js +27 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.d.ts +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.js +18 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/index.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.d.ts +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.js +18 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.js +121 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.d.ts +9 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js +71 -0
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js.map +1 -0
- package/lib/components/FormComponents/CustomDateItem/index.d.ts +1 -0
- package/lib/components/FormComponents/CustomDateItem/index.js +18 -0
- package/lib/components/FormComponents/CustomDateItem/index.js.map +1 -0
- package/lib/components/FormComponents/DateItem/DateItem.d.ts +3 -4
- package/lib/components/FormComponents/DateTimeItem/DateTimeItem.d.ts +2 -2
- package/lib/components/FormComponents/DecimalItem/DecimalItem.d.ts +2 -2
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +2 -3
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/DisplayItem/DisplayBox.d.ts +0 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.js +2 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.js.map +1 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.d.ts +4 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js +35 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js.map +1 -0
- package/lib/components/FormComponents/DisplayItem/DisplayInstructions.d.ts +2 -1
- package/lib/components/FormComponents/DisplayItem/DisplayInstructions.js.map +1 -1
- package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js +0 -1
- package/lib/components/FormComponents/DisplayItem/DisplayInstructions.styles.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridGroup.d.ts +3 -3
- package/lib/components/FormComponents/GridGroup/GridGroup.js +13 -8
- package/lib/components/FormComponents/GridGroup/GridGroup.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridRow.d.ts +3 -4
- package/lib/components/FormComponents/GridGroup/GridRow.js +3 -3
- package/lib/components/FormComponents/GridGroup/GridRow.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/GridTable.d.ts +3 -3
- package/lib/components/FormComponents/GridGroup/GridTable.js +9 -4
- package/lib/components/FormComponents/GridGroup/GridTable.js.map +1 -1
- package/lib/components/FormComponents/GridGroup/index.d.ts +1 -0
- package/lib/components/FormComponents/GridGroup/index.js +18 -0
- package/lib/components/FormComponents/GridGroup/index.js.map +1 -0
- package/lib/components/FormComponents/GroupItem/GroupItem.d.ts +2 -2
- package/lib/components/FormComponents/GroupItem/GroupItem.js +2 -2
- package/lib/components/FormComponents/GroupItem/GroupItem.js.map +1 -1
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +5 -6
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerItem.d.ts +2 -2
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +2 -3
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/SliderItem.d.ts +9 -0
- package/lib/components/FormComponents/IntegerItem/SliderItem.js +75 -0
- package/lib/components/FormComponents/IntegerItem/SliderItem.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js +2 -2
- package/lib/components/FormComponents/ItemParts/FadingCheckIcon.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +12 -12
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.d.ts +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.d.ts +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +15 -4
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.d.ts +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatField.d.ts +3 -3
- package/lib/components/FormComponents/RepeatItem/RepeatField.js +3 -3
- package/lib/components/FormComponents/RepeatItem/RepeatField.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +3 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +11 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/index.d.ts +1 -0
- package/lib/components/FormComponents/RepeatItem/index.js +18 -0
- package/lib/components/FormComponents/RepeatItem/index.js.map +1 -0
- package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +3 -3
- package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +3 -3
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +12 -7
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.d.ts +4 -0
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js +35 -0
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js.map +1 -0
- package/lib/components/FormComponents/SliderItem/Slider.styles.d.ts +6 -0
- package/lib/components/FormComponents/SliderItem/Slider.styles.js +33 -0
- package/lib/components/FormComponents/SliderItem/Slider.styles.js.map +1 -0
- package/lib/components/FormComponents/SliderItem/SliderDisplayValue.d.ts +8 -0
- package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js +28 -0
- package/lib/components/FormComponents/SliderItem/SliderDisplayValue.js.map +1 -0
- package/lib/components/FormComponents/SliderItem/SliderField.d.ts +16 -0
- package/lib/components/FormComponents/SliderItem/SliderField.js +41 -0
- package/lib/components/FormComponents/SliderItem/SliderField.js.map +1 -0
- package/lib/components/FormComponents/SliderItem/SliderItem.d.ts +9 -0
- package/lib/components/FormComponents/SliderItem/SliderItem.js +56 -0
- package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -0
- package/lib/components/FormComponents/SliderItem/SliderLabels.d.ts +7 -0
- package/lib/components/FormComponents/SliderItem/SliderLabels.js +32 -0
- package/lib/components/FormComponents/SliderItem/SliderLabels.js.map +1 -0
- package/lib/components/FormComponents/StringItem/StringItem.d.ts +2 -2
- package/lib/components/FormComponents/Tables/GroupTable.d.ts +3 -2
- package/lib/components/FormComponents/Tables/GroupTable.js +18 -1
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +3 -4
- package/lib/components/FormComponents/Tables/GroupTableRow.js +3 -3
- package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
- package/lib/components/FormComponents/TextItem/TextItem.d.ts +2 -2
- package/lib/components/FormComponents/TimeItem/TimeItem.d.ts +2 -2
- package/lib/components/FormComponents/UrlItem/UrlItem.d.ts +2 -2
- package/lib/components/FormComponents/index.d.ts +3 -0
- package/lib/components/FormComponents/index.js +3 -0
- package/lib/components/FormComponents/index.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +3 -5
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/components/Renderer/FormBodyCollapsible.d.ts +2 -2
- package/lib/components/Renderer/FormBodyCollapsible.js +6 -5
- package/lib/components/Renderer/FormBodyCollapsible.js.map +1 -1
- package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.d.ts +2 -2
- package/lib/components/Renderer/FormBodySingleCollapsibleWrapper.js.map +1 -1
- package/lib/components/Renderer/FormBodyTabbed.d.ts +2 -2
- package/lib/components/Renderer/FormBodyTabbed.js +6 -5
- package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
- package/lib/components/Renderer/FormTopLevelItem.d.ts +2 -2
- package/lib/components/Renderer/FormTopLevelItem.js +3 -1
- package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
- package/lib/hooks/useDateSeparatorValidation.d.ts +2 -0
- package/lib/hooks/useDateSeparatorValidation.js +25 -0
- package/lib/hooks/useDateSeparatorValidation.js.map +1 -0
- package/lib/hooks/useDateValidation.d.ts +2 -0
- package/lib/hooks/useDateValidation.js +61 -0
- package/lib/hooks/useDateValidation.js.map +1 -0
- package/lib/hooks/useDecimalCalculatedExpression.d.ts +0 -1
- package/lib/hooks/useDecimalCalculatedExpression.js +3 -3
- package/lib/hooks/useDecimalCalculatedExpression.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.d.ts +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
- package/lib/hooks/useIntegerCalculatedExpression.d.ts +0 -1
- package/lib/hooks/useIntegerCalculatedExpression.js +3 -3
- package/lib/hooks/useIntegerCalculatedExpression.js.map +1 -1
- package/lib/hooks/useSliderExtensions.d.ts +10 -0
- package/lib/hooks/useSliderExtensions.js +37 -0
- package/lib/hooks/useSliderExtensions.js.map +1 -0
- package/lib/hooks/useTerminologyServerQuery.js +0 -1
- package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +15 -6
- package/lib/index.js.map +1 -1
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.js +18 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/questionnaireStore.interface.d.ts +1 -0
- package/lib/interfaces/renderProps.interface.d.ts +4 -3
- package/lib/stores/useQuestionnaireStore.d.ts +1 -0
- package/lib/stores/useQuestionnaireStore.js +28 -12
- package/lib/stores/useQuestionnaireStore.js.map +1 -1
- package/lib/test.d.ts +4 -0
- package/lib/test.js +18 -0
- package/lib/test.js.map +1 -0
- package/lib/theme/customGlobalStyles.js +0 -4
- package/lib/theme/customGlobalStyles.js.map +1 -1
- package/lib/utils/calculatedExpression.d.ts +5 -1
- package/lib/utils/calculatedExpression.js +21 -16
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/lib/utils/dayjsExtend.d.ts +1 -0
- package/lib/utils/dayjsExtend.js +22 -0
- package/lib/utils/dayjsExtend.js.map +1 -0
- package/lib/utils/enableWhenExpression.d.ts +5 -1
- package/lib/utils/enableWhenExpression.js +26 -21
- package/lib/utils/enableWhenExpression.js.map +1 -1
- package/lib/utils/fhirpath.d.ts +3 -1
- package/lib/utils/fhirpath.js +25 -15
- package/lib/utils/fhirpath.js.map +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/initialiseForm.d.ts +2 -0
- package/lib/utils/initialiseForm.js +13 -5
- package/lib/utils/initialiseForm.js.map +1 -1
- package/lib/utils/itemControl.d.ts +12 -0
- package/lib/utils/itemControl.js +30 -0
- package/lib/utils/itemControl.js.map +1 -1
- package/lib/utils/launchContext.d.ts +0 -0
- package/lib/utils/launchContext.js +2 -0
- package/lib/utils/launchContext.js.map +1 -0
- package/lib/utils/mapItem.d.ts +1 -1
- package/lib/utils/qrItem.d.ts +1 -7
- package/lib/utils/qrItem.js +1 -12
- package/lib/utils/qrItem.js.map +1 -1
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js +4 -2
- package/lib/utils/questionnaireStoreUtils/createQuestionaireModel.js.map +1 -1
- package/lib/utils/removeHidden.js +2 -1
- package/lib/utils/removeHidden.js.map +1 -1
- package/lib/utils/repopulateIntoResponse.js +90 -29
- package/lib/utils/repopulateIntoResponse.js.map +1 -1
- package/lib/utils/repopulateItems.d.ts +14 -1
- package/lib/utils/repopulateItems.js +251 -70
- package/lib/utils/repopulateItems.js.map +1 -1
- package/lib/utils/repopulateRepeatGroup.js +9 -1
- package/lib/utils/repopulateRepeatGroup.js.map +1 -1
- package/lib/utils/slider.d.ts +28 -0
- package/lib/utils/slider.js +89 -0
- package/lib/utils/slider.js.map +1 -0
- package/package.json +11 -9
- package/src/components/FormComponents/BooleanItem/BooleanItem.tsx +2 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +2 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +33 -33
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +35 -35
- package/src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx +8 -8
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +2 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +2 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +2 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +2 -2
- package/src/components/FormComponents/CustomDateItem/CustomDateItem.tsx +140 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/CustomDateField.tsx +96 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePicker.tsx +81 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.tsx +33 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/MuiDatePicker.ts +22 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/index.ts +18 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/index.ts +18 -0
- package/src/components/FormComponents/CustomDateItem/customDateTimePicker/utils/parseDates.ts +154 -0
- package/src/components/FormComponents/CustomDateItem/index.ts +18 -0
- package/src/components/FormComponents/DateItem/DateItem.tsx +3 -3
- package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +2 -2
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +4 -5
- package/src/components/FormComponents/DisplayItem/DisplayInstructions.styles.ts +0 -1
- package/src/components/FormComponents/DisplayItem/DisplayInstructions.tsx +2 -1
- package/src/components/FormComponents/GridGroup/GridGroup.tsx +41 -15
- package/src/components/FormComponents/GridGroup/GridRow.tsx +10 -9
- package/src/components/FormComponents/GridGroup/GridTable.tsx +29 -9
- package/src/components/FormComponents/GridGroup/index.ts +18 -0
- package/src/components/FormComponents/GroupItem/GroupItem.tsx +5 -6
- package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +7 -8
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +4 -5
- package/src/components/FormComponents/ItemParts/FadingCheckIcon.tsx +2 -2
- package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +43 -43
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +6 -6
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +2 -2
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +2 -2
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +49 -6
- package/src/components/FormComponents/RepeatGroup/RepeatGroupItem.tsx +13 -8
- package/src/components/FormComponents/RepeatItem/RepeatField.tsx +15 -9
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +33 -3
- package/src/components/FormComponents/RepeatItem/index.ts +18 -0
- package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -6
- package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +27 -11
- package/src/components/FormComponents/SliderItem/Slider.styles.ts +34 -0
- package/src/components/FormComponents/SliderItem/SliderDisplayValue.tsx +43 -0
- package/src/components/FormComponents/SliderItem/SliderField.tsx +88 -0
- package/src/components/FormComponents/SliderItem/SliderItem.tsx +115 -0
- package/src/components/FormComponents/SliderItem/SliderLabels.tsx +53 -0
- package/src/components/FormComponents/StringItem/StringItem.tsx +2 -2
- package/src/components/FormComponents/Tables/GroupTable.tsx +55 -3
- package/src/components/FormComponents/Tables/GroupTableRow.tsx +10 -9
- package/src/components/FormComponents/TextItem/TextItem.tsx +2 -2
- package/src/components/FormComponents/TimeItem/TimeItem.tsx +2 -2
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +2 -2
- package/src/components/FormComponents/index.ts +3 -0
- package/src/components/Renderer/BaseRenderer.tsx +5 -12
- package/src/components/Renderer/FormBodyCollapsible.tsx +9 -7
- package/src/components/Renderer/FormBodySingleCollapsibleWrapper.tsx +2 -3
- package/src/components/Renderer/FormBodyTabbed.tsx +9 -7
- package/src/components/Renderer/FormTopLevelItem.tsx +14 -11
- package/src/hooks/useDateValidation.tsx +79 -0
- package/src/hooks/useDecimalCalculatedExpression.ts +3 -4
- package/src/hooks/useInitialiseRepeatAnswers.ts +1 -1
- package/src/hooks/useIntegerCalculatedExpression.ts +3 -4
- package/src/hooks/useSliderExtensions.ts +50 -0
- package/src/hooks/useTerminologyServerQuery.ts +0 -2
- package/src/index.ts +12 -9
- package/src/interfaces/questionnaireStore.interface.ts +1 -0
- package/src/interfaces/renderProps.interface.ts +4 -3
- package/src/stores/useQuestionnaireStore.ts +39 -16
- package/src/theme/customGlobalStyles.tsx +0 -4
- package/src/utils/calculatedExpression.ts +41 -28
- package/src/utils/dayjsExtend.ts +23 -0
- package/src/utils/enableWhenExpression.ts +49 -34
- package/src/utils/fhirpath.ts +50 -31
- package/src/utils/index.ts +1 -0
- package/src/utils/initialiseForm.ts +15 -5
- package/src/utils/itemControl.ts +32 -0
- package/src/utils/mapItem.ts +1 -1
- package/src/utils/qrItem.ts +1 -16
- package/src/utils/questionnaireStoreUtils/createQuestionaireModel.ts +4 -2
- package/src/utils/removeHidden.ts +2 -1
- package/src/utils/repopulateIntoResponse.ts +134 -43
- package/src/utils/repopulateItems.ts +379 -101
- package/src/utils/slider.ts +112 -0
- package/src/utils/repopulateRepeatGroup.ts +0 -68
package/src/components/FormComponents/CustomDateItem/customDateTimePicker/DatePickerButton.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
BaseSingleInputFieldProps,
|
|
4
|
+
DateValidationError,
|
|
5
|
+
FieldSection
|
|
6
|
+
} from '@mui/x-date-pickers/models';
|
|
7
|
+
import type { Dayjs } from 'dayjs';
|
|
8
|
+
import IconButton from '@mui/material/IconButton';
|
|
9
|
+
import EventIcon from '@mui/icons-material/Event';
|
|
10
|
+
|
|
11
|
+
interface DatePickerButtonProps
|
|
12
|
+
extends BaseSingleInputFieldProps<Dayjs | null, Dayjs, FieldSection, DateValidationError> {
|
|
13
|
+
onOpen?: () => void;
|
|
14
|
+
readOnly?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function DatePickerButton(props: DatePickerButtonProps) {
|
|
18
|
+
const { onOpen, readOnly } = props;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<IconButton
|
|
22
|
+
sx={{ height: 24, width: 24 }}
|
|
23
|
+
disabled={readOnly}
|
|
24
|
+
onClick={(e) => {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
onOpen?.();
|
|
27
|
+
}}>
|
|
28
|
+
<EventIcon fontSize="small" />
|
|
29
|
+
</IconButton>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default DatePickerButton;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
19
|
+
|
|
20
|
+
const MuiDatePicker = DatePicker;
|
|
21
|
+
|
|
22
|
+
export default MuiDatePicker;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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
|
+
export * from './utils';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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
|
+
export { parseFhirDateToDisplayDate } from './parseDates';
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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 dayjs from 'dayjs';
|
|
19
|
+
|
|
20
|
+
const inputMatchRegex = /(\d{4}|\d{3}|\d{2})/g;
|
|
21
|
+
|
|
22
|
+
export function validateInput(input: string) {
|
|
23
|
+
const matches = input.match(inputMatchRegex);
|
|
24
|
+
|
|
25
|
+
if (!matches) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const seperator = input.includes('/') ? '/' : null;
|
|
30
|
+
|
|
31
|
+
if (matches.length === 1) {
|
|
32
|
+
// seperator not supposed to be present if only one match present
|
|
33
|
+
if (seperator) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return matches[0].length === 4;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Invalid if seperator is not present
|
|
41
|
+
if (!seperator) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Invalid if num of slots don't match the number of regex matches
|
|
46
|
+
const slotsMatched = input.split(seperator);
|
|
47
|
+
if (slotsMatched.length != matches.length) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Handle MM/YYYY format
|
|
52
|
+
if (matches.length === 2) {
|
|
53
|
+
return validateTwoMatches(matches[0], matches[1]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Handle DD/MM/YYYY format
|
|
57
|
+
if (matches.length === 3) {
|
|
58
|
+
return validateThreeMatches(matches[0], matches[1], matches[2]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function validateTwoMatches(monthInput: string, yearInput: string) {
|
|
65
|
+
const monthNum = parseInt(monthInput, 10);
|
|
66
|
+
if (monthNum < 1 || monthNum > 12) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (monthInput.length === 1 || monthInput.length === 2) && yearInput.length === 4;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function validateThreeMatches(dayInput: string, monthInput: string, yearInput: string) {
|
|
74
|
+
const dayNum = parseInt(dayInput, 10);
|
|
75
|
+
if (dayNum < 1 || dayNum > 31) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const monthNum = parseInt(monthInput, 10);
|
|
80
|
+
if (monthNum < 1 || monthNum > 12) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
(dayInput.length === 1 || dayInput.length === 2) &&
|
|
86
|
+
(monthInput.length === 1 || monthInput.length === 2) &&
|
|
87
|
+
yearInput.length === 4
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function getNumOfSeparators(valueDate: string, seperator: string) {
|
|
92
|
+
const regex = new RegExp(seperator, 'g');
|
|
93
|
+
return [...valueDate.matchAll(regex)].length;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function parseFhirDateToDisplayDate(fhirDate: string): {
|
|
97
|
+
displayDate: string;
|
|
98
|
+
parseFail?: boolean;
|
|
99
|
+
} {
|
|
100
|
+
if (fhirDate.length === 0) {
|
|
101
|
+
return { displayDate: '' };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const numOfSeparators = getNumOfSeparators(fhirDate, '-');
|
|
105
|
+
|
|
106
|
+
if (numOfSeparators === 2) {
|
|
107
|
+
const threeMatchesDate = dayjs(fhirDate, `YYYY-MM-DD`);
|
|
108
|
+
if (threeMatchesDate.isValid()) {
|
|
109
|
+
return { displayDate: threeMatchesDate.format('DD/MM/YYYY') };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (numOfSeparators === 1) {
|
|
114
|
+
const twoMatchesDate = dayjs(fhirDate, `YYYY-MM`);
|
|
115
|
+
if (twoMatchesDate.isValid()) {
|
|
116
|
+
return { displayDate: twoMatchesDate.format('MM/YYYY') };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const oneMatchDate = dayjs(fhirDate, `YYYY`);
|
|
121
|
+
if (oneMatchDate.isValid()) {
|
|
122
|
+
return { displayDate: oneMatchDate.format('YYYY') };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return { displayDate: fhirDate, parseFail: true };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function parseInputDateToFhirDate(displayDate: string) {
|
|
129
|
+
const numOfSeparators = getNumOfSeparators(displayDate, '/');
|
|
130
|
+
|
|
131
|
+
if (numOfSeparators === 2) {
|
|
132
|
+
const threeMatchesDate = dayjs(displayDate, `DD/MM/YYYY`);
|
|
133
|
+
if (threeMatchesDate.isValid()) {
|
|
134
|
+
return threeMatchesDate.format('YYYY-MM-DD');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (numOfSeparators === 1) {
|
|
139
|
+
const twoMatchesDate = dayjs(displayDate, `MM/YYYY`);
|
|
140
|
+
if (twoMatchesDate.isValid()) {
|
|
141
|
+
return twoMatchesDate.format('YYYY-MM');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (displayDate.length === 4) {
|
|
146
|
+
const oneMatchDate = dayjs(displayDate, 'YYYY');
|
|
147
|
+
if (oneMatchDate.isValid()) {
|
|
148
|
+
return displayDate;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Default to YYYY-MM-DD format if all else fails
|
|
153
|
+
return dayjs(displayDate).format('YYYY-MM-DD');
|
|
154
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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
|
+
export * from './customDateTimePicker';
|
|
@@ -19,9 +19,9 @@ import React from 'react';
|
|
|
19
19
|
import type {
|
|
20
20
|
PropsWithIsRepeatedAttribute,
|
|
21
21
|
PropsWithIsTabledAttribute,
|
|
22
|
+
PropsWithParentIsReadOnlyAttribute,
|
|
22
23
|
PropsWithQrItemChangeHandler
|
|
23
24
|
} from '../../../interfaces/renderProps.interface';
|
|
24
|
-
import type { PropsWithParentIsReadOnlyAttribute } from '../../../interfaces/renderProps.interface';
|
|
25
25
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
26
26
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
27
27
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
@@ -33,12 +33,12 @@ import dayjs from 'dayjs';
|
|
|
33
33
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
34
34
|
|
|
35
35
|
interface DateItemProps
|
|
36
|
-
extends PropsWithQrItemChangeHandler
|
|
36
|
+
extends PropsWithQrItemChangeHandler,
|
|
37
37
|
PropsWithIsRepeatedAttribute,
|
|
38
38
|
PropsWithIsTabledAttribute,
|
|
39
39
|
PropsWithParentIsReadOnlyAttribute {
|
|
40
40
|
qItem: QuestionnaireItem;
|
|
41
|
-
qrItem: QuestionnaireResponseItem;
|
|
41
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function DateItem(props: DateItemProps) {
|
|
@@ -33,12 +33,12 @@ import dayjs from 'dayjs';
|
|
|
33
33
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
34
34
|
|
|
35
35
|
interface DateTimeItemProps
|
|
36
|
-
extends PropsWithQrItemChangeHandler
|
|
36
|
+
extends PropsWithQrItemChangeHandler,
|
|
37
37
|
PropsWithIsRepeatedAttribute,
|
|
38
38
|
PropsWithIsTabledAttribute,
|
|
39
39
|
PropsWithParentIsReadOnlyAttribute {
|
|
40
40
|
qItem: QuestionnaireItem;
|
|
41
|
-
qrItem: QuestionnaireResponseItem;
|
|
41
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function DateTimeItem(props: DateTimeItemProps) {
|
|
@@ -28,7 +28,7 @@ import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
|
28
28
|
import useValidationError from '../../../hooks/useValidationError';
|
|
29
29
|
import debounce from 'lodash.debounce';
|
|
30
30
|
import { DEBOUNCE_DURATION } from '../../../utils/debounce';
|
|
31
|
-
import {
|
|
31
|
+
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
32
32
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
33
33
|
import DecimalField from './DecimalField';
|
|
34
34
|
import {
|
|
@@ -41,12 +41,12 @@ import useStringInput from '../../../hooks/useStringInput';
|
|
|
41
41
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
42
42
|
|
|
43
43
|
interface DecimalItemProps
|
|
44
|
-
extends PropsWithQrItemChangeHandler
|
|
44
|
+
extends PropsWithQrItemChangeHandler,
|
|
45
45
|
PropsWithIsRepeatedAttribute,
|
|
46
46
|
PropsWithIsTabledAttribute,
|
|
47
47
|
PropsWithParentIsReadOnlyAttribute {
|
|
48
48
|
qItem: QuestionnaireItem;
|
|
49
|
-
qrItem: QuestionnaireResponseItem;
|
|
49
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function DecimalItem(props: DecimalItemProps) {
|
|
@@ -86,7 +86,6 @@ function DecimalItem(props: DecimalItemProps) {
|
|
|
86
86
|
const { calcExpUpdated } = useDecimalCalculatedExpression({
|
|
87
87
|
qItem: qItem,
|
|
88
88
|
inputValue: input,
|
|
89
|
-
displayUnit: displayUnit,
|
|
90
89
|
precision: precision,
|
|
91
90
|
setInputValue: (newInput) => {
|
|
92
91
|
setInput(newInput);
|
|
@@ -106,7 +105,7 @@ function DecimalItem(props: DecimalItemProps) {
|
|
|
106
105
|
const updateQrItemWithDebounce = useCallback(
|
|
107
106
|
debounce((parsedNewInput: string) => {
|
|
108
107
|
onQrItemChange({
|
|
109
|
-
...
|
|
108
|
+
...createEmptyQrItem(qItem),
|
|
110
109
|
answer: precision
|
|
111
110
|
? [{ valueDecimal: parseDecimalStringToFloat(parsedNewInput, precision) }]
|
|
112
111
|
: [{ valueDecimal: parseFloat(parsedNewInput) }]
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
import type { ReactElement } from 'react';
|
|
18
19
|
import React, { memo } from 'react';
|
|
19
20
|
import Typography from '@mui/material/Typography';
|
|
20
21
|
import { DisplayInstructionsWrapper } from './DisplayInstructions.styles';
|
|
21
22
|
|
|
22
23
|
interface DisplayInstructionsProps {
|
|
23
|
-
displayInstructions: string;
|
|
24
|
+
displayInstructions: string | ReactElement;
|
|
24
25
|
readOnly: boolean;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -19,9 +19,10 @@ import React, { useMemo } from 'react';
|
|
|
19
19
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
20
20
|
import type {
|
|
21
21
|
PropsWithParentIsReadOnlyAttribute,
|
|
22
|
-
PropsWithQrItemChangeHandler
|
|
22
|
+
PropsWithQrItemChangeHandler,
|
|
23
|
+
PropsWithShowMinimalViewAttribute
|
|
23
24
|
} from '../../../interfaces/renderProps.interface';
|
|
24
|
-
import {
|
|
25
|
+
import { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';
|
|
25
26
|
import useHidden from '../../../hooks/useHidden';
|
|
26
27
|
import { QGroupContainerBox } from '../../Box.styles';
|
|
27
28
|
import Divider from '@mui/material/Divider';
|
|
@@ -34,18 +35,20 @@ import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
|
34
35
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
35
36
|
|
|
36
37
|
interface GridGroupProps
|
|
37
|
-
extends PropsWithQrItemChangeHandler
|
|
38
|
+
extends PropsWithQrItemChangeHandler,
|
|
39
|
+
PropsWithShowMinimalViewAttribute,
|
|
38
40
|
PropsWithParentIsReadOnlyAttribute {
|
|
39
41
|
qItem: QuestionnaireItem;
|
|
40
|
-
qrItem: QuestionnaireResponseItem;
|
|
42
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
41
43
|
groupCardElevation: number;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
function GridGroup(props: GridGroupProps) {
|
|
45
|
-
const { qItem, qrItem, groupCardElevation, parentIsReadOnly, onQrItemChange } =
|
|
47
|
+
const { qItem, qrItem, groupCardElevation, showMinimalView, parentIsReadOnly, onQrItemChange } =
|
|
48
|
+
props;
|
|
46
49
|
|
|
47
50
|
const qRowItems = qItem.item;
|
|
48
|
-
const qrGroup = qrItem && qrItem.item ? qrItem :
|
|
51
|
+
const qrGroup = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);
|
|
49
52
|
const qrRowItems = qrGroup.item;
|
|
50
53
|
|
|
51
54
|
const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);
|
|
@@ -77,26 +80,49 @@ function GridGroup(props: GridGroupProps) {
|
|
|
77
80
|
onQrItemChange(updatedQrGroup);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<QGroupContainerBox cardElevation={groupCardElevation} isRepeated={false} py={
|
|
83
|
-
<Typography fontSize={13} variant="h6" color={readOnly ? 'text.secondary' : 'text.primary'}>
|
|
84
|
-
<LabelWrapper qItem={qItem} readOnly={readOnly} />
|
|
85
|
-
</Typography>
|
|
86
|
-
<Divider sx={{ my: 1 }} light />
|
|
87
|
-
|
|
83
|
+
if (showMinimalView) {
|
|
84
|
+
return (
|
|
85
|
+
<QGroupContainerBox cardElevation={groupCardElevation} isRepeated={false} py={1}>
|
|
88
86
|
<TableContainer component={Paper} elevation={groupCardElevation}>
|
|
89
87
|
<GridTable
|
|
90
88
|
qItems={qRowItems}
|
|
91
89
|
qrItems={qrRowItems}
|
|
92
90
|
qItemsIndexMap={qItemsIndexMap}
|
|
93
91
|
columnLabels={columnLabels}
|
|
92
|
+
showMinimalView={showMinimalView}
|
|
94
93
|
parentIsReadOnly={parentIsReadOnly}
|
|
95
94
|
onQrItemChange={handleRowChange}
|
|
96
95
|
/>
|
|
97
96
|
</TableContainer>
|
|
98
97
|
</QGroupContainerBox>
|
|
99
|
-
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<QGroupContainerBox cardElevation={groupCardElevation} isRepeated={false} py={3}>
|
|
103
|
+
{qItem.text ? (
|
|
104
|
+
<>
|
|
105
|
+
<Typography
|
|
106
|
+
fontSize={13}
|
|
107
|
+
variant="h6"
|
|
108
|
+
color={readOnly ? 'text.secondary' : 'text.primary'}>
|
|
109
|
+
<LabelWrapper qItem={qItem} readOnly={readOnly} />
|
|
110
|
+
</Typography>
|
|
111
|
+
<Divider sx={{ my: 1 }} light />
|
|
112
|
+
</>
|
|
113
|
+
) : null}
|
|
114
|
+
|
|
115
|
+
<TableContainer component={Paper} elevation={groupCardElevation}>
|
|
116
|
+
<GridTable
|
|
117
|
+
qItems={qRowItems}
|
|
118
|
+
qrItems={qrRowItems}
|
|
119
|
+
qItemsIndexMap={qItemsIndexMap}
|
|
120
|
+
columnLabels={columnLabels}
|
|
121
|
+
parentIsReadOnly={parentIsReadOnly}
|
|
122
|
+
onQrItemChange={handleRowChange}
|
|
123
|
+
/>
|
|
124
|
+
</TableContainer>
|
|
125
|
+
</QGroupContainerBox>
|
|
100
126
|
);
|
|
101
127
|
}
|
|
102
128
|
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
import React, { useMemo } from 'react';
|
|
19
19
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
20
|
-
import type {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import type {
|
|
21
|
+
PropsWithParentIsReadOnlyAttribute,
|
|
22
|
+
PropsWithQrItemChangeHandler
|
|
23
|
+
} from '../../../interfaces/renderProps.interface';
|
|
24
|
+
import { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';
|
|
23
25
|
import { GridAnswerTableCell, GridTextTableCell } from '../Tables/Table.styles';
|
|
24
26
|
import SingleItem from '../SingleItem/SingleItem';
|
|
25
27
|
import { getQrItemsIndex, mapQItemsIndex } from '../../../utils/mapItem';
|
|
26
28
|
import Typography from '@mui/material/Typography';
|
|
27
29
|
import useHidden from '../../../hooks/useHidden';
|
|
28
30
|
|
|
29
|
-
interface GridRowProps
|
|
30
|
-
extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>,
|
|
31
|
-
PropsWithParentIsReadOnlyAttribute {
|
|
31
|
+
interface GridRowProps extends PropsWithQrItemChangeHandler, PropsWithParentIsReadOnlyAttribute {
|
|
32
32
|
qItem: QuestionnaireItem;
|
|
33
|
-
qrItem: QuestionnaireResponseItem;
|
|
33
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
34
34
|
columnLabels: string[];
|
|
35
35
|
numOfColumns: number;
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ function GridRow(props: GridRowProps) {
|
|
|
39
39
|
const { qItem, qrItem, columnLabels, numOfColumns, parentIsReadOnly, onQrItemChange } = props;
|
|
40
40
|
|
|
41
41
|
const rowQItems = qItem.item;
|
|
42
|
-
const row = qrItem && qrItem.item ? qrItem :
|
|
42
|
+
const row = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);
|
|
43
43
|
const rowQrItems = row.item;
|
|
44
44
|
|
|
45
45
|
const qItemsIndexMap = useMemo(() => mapQItemsIndex(qItem), [qItem]);
|
|
@@ -82,9 +82,10 @@ function GridRow(props: GridRowProps) {
|
|
|
82
82
|
<GridAnswerTableCell key={index} numOfColumns={numOfColumns}>
|
|
83
83
|
<SingleItem
|
|
84
84
|
qItem={cellQItem}
|
|
85
|
-
qrItem={cellQrItem}
|
|
85
|
+
qrItem={cellQrItem ?? null}
|
|
86
86
|
isRepeated={true}
|
|
87
87
|
isTabled={true}
|
|
88
|
+
showMinimalView={true}
|
|
88
89
|
parentIsReadOnly={parentIsReadOnly}
|
|
89
90
|
onQrItemChange={handleQrRowItemChange}
|
|
90
91
|
/>
|
|
@@ -25,11 +25,15 @@ import { HeaderTableCell } from '../Tables/Table.styles';
|
|
|
25
25
|
import GridRow from './GridRow';
|
|
26
26
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
27
27
|
import { getQrItemsIndex } from '../../../utils/mapItem';
|
|
28
|
-
import type {
|
|
29
|
-
|
|
28
|
+
import type {
|
|
29
|
+
PropsWithParentIsReadOnlyAttribute,
|
|
30
|
+
PropsWithQrItemChangeHandler
|
|
31
|
+
} from '../../../interfaces/renderProps.interface';
|
|
32
|
+
import type { PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
30
33
|
|
|
31
34
|
interface GridTableProps
|
|
32
|
-
extends PropsWithQrItemChangeHandler
|
|
35
|
+
extends PropsWithQrItemChangeHandler,
|
|
36
|
+
PropsWithShowMinimalViewAttribute,
|
|
33
37
|
PropsWithParentIsReadOnlyAttribute {
|
|
34
38
|
qItems: QuestionnaireItem[];
|
|
35
39
|
qrItems: QuestionnaireResponseItem[];
|
|
@@ -38,20 +42,31 @@ interface GridTableProps
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
function GridTable(props: GridTableProps) {
|
|
41
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
qItems,
|
|
47
|
+
qrItems,
|
|
48
|
+
qItemsIndexMap,
|
|
49
|
+
columnLabels,
|
|
50
|
+
showMinimalView,
|
|
51
|
+
parentIsReadOnly,
|
|
52
|
+
onQrItemChange
|
|
53
|
+
} = props;
|
|
42
54
|
|
|
43
|
-
const qrItemsByIndex
|
|
44
|
-
getQrItemsIndex(qItems, qrItems, qItemsIndexMap);
|
|
55
|
+
const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, qItemsIndexMap);
|
|
45
56
|
|
|
46
57
|
const numOfColumns = columnLabels.length;
|
|
47
58
|
|
|
59
|
+
const minimalViewHeaderCellSx = showMinimalView ? { py: 2 } : null;
|
|
60
|
+
|
|
48
61
|
return (
|
|
49
|
-
<Table>
|
|
62
|
+
<Table size={showMinimalView ? 'small' : 'medium'}>
|
|
50
63
|
<TableHead>
|
|
51
64
|
<TableRow>
|
|
52
65
|
<HeaderTableCell />
|
|
53
66
|
{columnLabels.map((label) => (
|
|
54
|
-
<HeaderTableCell key={label}
|
|
67
|
+
<HeaderTableCell key={label} size="medium" sx={{ ...minimalViewHeaderCellSx }}>
|
|
68
|
+
{label}
|
|
69
|
+
</HeaderTableCell>
|
|
55
70
|
))}
|
|
56
71
|
<TableCell />
|
|
57
72
|
</TableRow>
|
|
@@ -64,11 +79,16 @@ function GridTable(props: GridTableProps) {
|
|
|
64
79
|
return null;
|
|
65
80
|
}
|
|
66
81
|
|
|
82
|
+
// In minimal view, don't display items with no answers
|
|
83
|
+
if (showMinimalView && !qrItem) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
67
87
|
return (
|
|
68
88
|
<TableRow key={qItem.linkId}>
|
|
69
89
|
<GridRow
|
|
70
90
|
qItem={qItem}
|
|
71
|
-
qrItem={qrItem}
|
|
91
|
+
qrItem={qrItem ?? null}
|
|
72
92
|
columnLabels={columnLabels}
|
|
73
93
|
numOfColumns={numOfColumns}
|
|
74
94
|
parentIsReadOnly={parentIsReadOnly}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 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
|
+
export { default as GridGroup } from './GridGroup';
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import React, { useMemo } from 'react';
|
|
19
19
|
import { getQrItemsIndex, mapQItemsIndex } from '../../../utils/mapItem';
|
|
20
20
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
21
|
-
import {
|
|
21
|
+
import { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';
|
|
22
22
|
import { QGroupContainerBox } from '../../Box.styles';
|
|
23
23
|
import type {
|
|
24
24
|
PropsWithIsRepeatedAttribute,
|
|
@@ -35,11 +35,11 @@ import GroupItemSwitcher from './GroupItemSwitcher';
|
|
|
35
35
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
36
36
|
|
|
37
37
|
interface GroupItemProps
|
|
38
|
-
extends PropsWithQrItemChangeHandler
|
|
38
|
+
extends PropsWithQrItemChangeHandler,
|
|
39
39
|
PropsWithIsRepeatedAttribute,
|
|
40
40
|
PropsWithParentIsReadOnlyAttribute {
|
|
41
41
|
qItem: QuestionnaireItem;
|
|
42
|
-
qrItem: QuestionnaireResponseItem;
|
|
42
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
43
43
|
groupCardElevation: number;
|
|
44
44
|
tabIsMarkedAsComplete?: boolean;
|
|
45
45
|
tabs?: Tabs;
|
|
@@ -68,7 +68,7 @@ function GroupItem(props: GroupItemProps) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const qItems = qItem.item;
|
|
71
|
-
const qrGroup = qrItem && qrItem.item ? qrItem :
|
|
71
|
+
const qrGroup = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);
|
|
72
72
|
const qrItems = qrGroup.item;
|
|
73
73
|
|
|
74
74
|
// Event Handlers
|
|
@@ -89,8 +89,7 @@ function GroupItem(props: GroupItemProps) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// If an item has multiple answers, it is a repeat group
|
|
92
|
-
const qrItemsByIndex
|
|
93
|
-
getQrItemsIndex(qItems, qrItems, qItemsIndexMap);
|
|
92
|
+
const qrItemsByIndex = getQrItemsIndex(qItems, qrItems, qItemsIndexMap);
|
|
94
93
|
|
|
95
94
|
return (
|
|
96
95
|
<QGroupContainerBox
|