@aehrc/smart-forms-renderer 0.12.1 → 0.13.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/Box.styles.d.ts +6 -0
- package/lib/components/Box.styles.js +29 -1
- package/lib/components/Box.styles.js.map +1 -1
- package/lib/components/FormComponents/BooleanItem/BooleanItem.js +2 -2
- package/lib/components/FormComponents/BooleanItem/BooleanItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +4 -10
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +4 -9
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +4 -9
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +4 -10
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +4 -10
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +4 -10
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +4 -10
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js +2 -2
- package/lib/components/FormComponents/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateItem/DateItem.js +2 -2
- package/lib/components/FormComponents/DateItem/DateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js +2 -2
- package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +4 -4
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerField.js +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerField.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +4 -4
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.d.ts +7 -0
- package/lib/components/FormComponents/{DateItem/DatePickerField.js → ItemParts/ItemExtensionLabels.js} +12 -6
- package/lib/components/FormComponents/ItemParts/ItemExtensionLabels.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.d.ts +1 -0
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +10 -7
- package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +4 -10
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +4 -9
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +4 -10
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +4 -10
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +4 -10
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.d.ts +1 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +2 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/SliderItem/SliderItem.js +2 -2
- package/lib/components/FormComponents/SliderItem/SliderItem.js.map +1 -1
- package/lib/components/FormComponents/StringItem/StringItem.js +4 -4
- package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
- package/lib/components/FormComponents/TextItem/TextItem.js +4 -4
- package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
- package/lib/components/FormComponents/TimeItem/TimeItem.js +2 -2
- package/lib/components/FormComponents/TimeItem/TimeItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +4 -4
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +7 -0
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/hooks/useRenderingExtensions.d.ts +2 -0
- package/lib/hooks/useRenderingExtensions.js +16 -11
- package/lib/hooks/useRenderingExtensions.js.map +1 -1
- package/lib/hooks/useValidationFeedback.d.ts +3 -0
- package/lib/hooks/useValidationFeedback.js +37 -0
- package/lib/hooks/useValidationFeedback.js.map +1 -0
- package/lib/stores/questionnaireResponseStore.d.ts +8 -1
- package/lib/stores/questionnaireResponseStore.js +22 -0
- package/lib/stores/questionnaireResponseStore.js.map +1 -1
- package/lib/utils/itemControl.d.ts +1 -27
- package/lib/utils/itemControl.js +0 -49
- package/lib/utils/itemControl.js.map +1 -1
- package/lib/utils/mapItem.d.ts +2 -0
- package/lib/utils/mapItem.js +2 -0
- package/lib/utils/mapItem.js.map +1 -1
- package/lib/utils/validateQuestionnaire.d.ts +23 -0
- package/lib/utils/validateQuestionnaire.js +183 -0
- package/lib/utils/validateQuestionnaire.js.map +1 -0
- package/package.json +1 -1
- package/src/components/Box.styles.ts +31 -1
- package/src/components/FormComponents/BooleanItem/BooleanItem.tsx +6 -2
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +19 -23
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +15 -18
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +16 -19
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +15 -19
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +17 -21
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +15 -19
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +17 -21
- package/src/components/FormComponents/CustomDateItem/CustomDateItem.tsx +7 -2
- package/src/components/FormComponents/DateItem/DateItem.tsx +7 -2
- package/src/components/FormComponents/DateTimeItem/DateTimeItem.tsx +7 -2
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +9 -3
- package/src/components/FormComponents/IntegerItem/IntegerField.tsx +1 -0
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +9 -3
- package/{lib/components/BackToTopButton/BackToTopButton.js → src/components/FormComponents/ItemParts/ItemExtensionLabels.tsx} +23 -15
- package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +14 -9
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +21 -25
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +20 -23
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +18 -22
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +16 -20
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +17 -21
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +8 -4
- package/src/components/FormComponents/SliderItem/SliderItem.tsx +6 -2
- package/src/components/FormComponents/StringItem/StringItem.tsx +9 -3
- package/src/components/FormComponents/TextItem/TextItem.tsx +9 -3
- package/src/components/FormComponents/TimeItem/TimeItem.tsx +7 -2
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +9 -3
- package/src/components/Renderer/BaseRenderer.tsx +9 -0
- package/src/hooks/useRenderingExtensions.ts +17 -11
- package/src/hooks/{useValidationError.ts → useValidationFeedback.ts} +23 -21
- package/src/stores/questionnaireResponseStore.ts +36 -1
- package/src/utils/itemControl.ts +1 -67
- package/src/utils/mapItem.ts +2 -0
- package/src/utils/validateQuestionnaire.ts +273 -0
- package/lib/components/BackToTopButton/BackToTopButton.d.ts +0 -7
- package/lib/components/BackToTopButton/BackToTopButton.js.map +0 -1
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.d.ts +0 -18
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js +0 -31
- package/lib/components/FormComponents/CustomDateItem/CustomDateField2.js.map +0 -1
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.d.ts +0 -9
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js +0 -75
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimeField.js.map +0 -1
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.d.ts +0 -9
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js +0 -75
- package/lib/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.js.map +0 -1
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.d.ts +0 -5
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js +0 -27
- package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js.map +0 -1
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.d.ts +0 -9
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js +0 -71
- package/lib/components/FormComponents/CustomDateItem/customDateTimePickerText.js.map +0 -1
- package/lib/components/FormComponents/DateItem/DatePicker.d.ts +0 -2
- package/lib/components/FormComponents/DateItem/DatePicker.js +0 -42
- package/lib/components/FormComponents/DateItem/DatePicker.js.map +0 -1
- package/lib/components/FormComponents/DateItem/DatePickerField.d.ts +0 -8
- package/lib/components/FormComponents/DateItem/DatePickerField.js.map +0 -1
- package/lib/components/FormComponents/DisplayItem/DisplayBox.d.ts +0 -0
- package/lib/components/FormComponents/DisplayItem/DisplayBox.js +0 -2
- package/lib/components/FormComponents/DisplayItem/DisplayBox.js.map +0 -1
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.d.ts +0 -4
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js +0 -35
- package/lib/components/FormComponents/DisplayItem/DisplayBox.styles.js.map +0 -1
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.d.ts +0 -10
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js +0 -73
- package/lib/components/FormComponents/GroupItem/GroupChildItemSwitcher.js.map +0 -1
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.d.ts +0 -10
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.js +0 -81
- package/lib/components/FormComponents/GroupItem/ItemSwitcher.js.map +0 -1
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.d.ts +0 -10
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js +0 -45
- package/lib/components/FormComponents/GroupItem/TopLevelGroupItemSwitcher.js.map +0 -1
- package/lib/components/FormComponents/IntegerItem/SliderItem.d.ts +0 -9
- package/lib/components/FormComponents/IntegerItem/SliderItem.js +0 -75
- package/lib/components/FormComponents/IntegerItem/SliderItem.js.map +0 -1
- package/lib/components/FormComponents/ItemParts/RadioButtons.d.ts +0 -8
- package/lib/components/FormComponents/ItemParts/RadioButtons.js +0 -37
- package/lib/components/FormComponents/ItemParts/RadioButtons.js.map +0 -1
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.d.ts +0 -8
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js +0 -37
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js.map +0 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js +0 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js.map +0 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js +0 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js.map +0 -1
- package/lib/components/FormComponents/RepeatItem/DeleteItemButton.d.ts +0 -10
- package/lib/components/FormComponents/RepeatItem/DeleteItemButton.js +0 -30
- package/lib/components/FormComponents/RepeatItem/DeleteItemButton.js.map +0 -1
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.d.ts +0 -4
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js +0 -35
- package/lib/components/FormComponents/SliderItem/DisplayBox.styles.js.map +0 -1
- package/lib/components/FormComponents/Tables/AddItemButton.d.ts +0 -8
- package/lib/components/FormComponents/Tables/AddItemButton.js +0 -28
- package/lib/components/FormComponents/Tables/AddItemButton.js.map +0 -1
- package/lib/components/FormComponents/Tables/DeleteRowButton.d.ts +0 -10
- package/lib/components/FormComponents/Tables/DeleteRowButton.js +0 -32
- package/lib/components/FormComponents/Tables/DeleteRowButton.js.map +0 -1
- package/lib/components/FormComponents/Tables/GroupTableRows.d.ts +0 -17
- package/lib/components/FormComponents/Tables/GroupTableRows.js +0 -45
- package/lib/components/FormComponents/Tables/GroupTableRows.js.map +0 -1
- package/lib/components/FormComponents/Tables/GroupTableTestRow.d.ts +0 -22
- package/lib/components/FormComponents/Tables/GroupTableTestRow.js +0 -43
- package/lib/components/FormComponents/Tables/GroupTableTestRow.js.map +0 -1
- package/lib/components/FormComponents/Tables/QItemGroupTable.d.ts +0 -10
- package/lib/components/FormComponents/Tables/QItemGroupTable.js +0 -109
- package/lib/components/FormComponents/Tables/QItemGroupTable.js.map +0 -1
- package/lib/components/FormComponents/Tables/QItemGroupTableRow.d.ts +0 -10
- package/lib/components/FormComponents/Tables/QItemGroupTableRow.js +0 -46
- package/lib/components/FormComponents/Tables/QItemGroupTableRow.js.map +0 -1
- package/lib/components/FormComponents/Typography.styles.d.ts +0 -6
- package/lib/components/FormComponents/Typography.styles.js +0 -24
- package/lib/components/FormComponents/Typography.styles.js.map +0 -1
- package/lib/hooks/useBackToTop.d.ts +0 -2
- package/lib/hooks/useBackToTop.js +0 -26
- package/lib/hooks/useBackToTop.js.map +0 -1
- package/lib/hooks/useDateSeparatorValidation.d.ts +0 -2
- package/lib/hooks/useDateSeparatorValidation.js +0 -25
- package/lib/hooks/useDateSeparatorValidation.js.map +0 -1
- package/lib/hooks/useDecimalUpdateFromProp.d.ts +0 -2
- package/lib/hooks/useDecimalUpdateFromProp.js +0 -29
- package/lib/hooks/useDecimalUpdateFromProp.js.map +0 -1
- package/lib/hooks/useIntegerUpdateFromProp.d.ts +0 -2
- package/lib/hooks/useIntegerUpdateFromProp.js +0 -29
- package/lib/hooks/useIntegerUpdateFromProp.js.map +0 -1
- package/lib/hooks/useMinimalStringCalculatedExpression.d.ts +0 -11
- package/lib/hooks/useMinimalStringCalculatedExpression.js +0 -49
- package/lib/hooks/useMinimalStringCalculatedExpression.js.map +0 -1
- package/lib/hooks/useNumberUpdateFromProp.d.ts +0 -2
- package/lib/hooks/useNumberUpdateFromProp.js +0 -29
- package/lib/hooks/useNumberUpdateFromProp.js.map +0 -1
- package/lib/hooks/useRepeatItemState.d.ts +0 -5
- package/lib/hooks/useRepeatItemState.js +0 -35
- package/lib/hooks/useRepeatItemState.js.map +0 -1
- package/lib/hooks/useRepeatItemUpdateFromProp.d.ts +0 -2
- package/lib/hooks/useRepeatItemUpdateFromProp.js +0 -29
- package/lib/hooks/useRepeatItemUpdateFromProp.js.map +0 -1
- package/lib/hooks/useStringField.d.ts +0 -2
- package/lib/hooks/useStringField.js +0 -29
- package/lib/hooks/useStringField.js.map +0 -1
- package/lib/hooks/useStringUpdateFromProp.d.ts +0 -2
- package/lib/hooks/useStringUpdateFromProp.js +0 -29
- package/lib/hooks/useStringUpdateFromProp.js.map +0 -1
- package/lib/hooks/useValidationError.d.ts +0 -3
- package/lib/hooks/useValidationError.js +0 -38
- package/lib/hooks/useValidationError.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -2
- package/lib/interfaces/index.js +0 -18
- package/lib/interfaces/index.js.map +0 -1
- package/lib/setup-jest.js +0 -1
- package/lib/setup-jest.js.map +0 -1
- package/lib/stores/useQuestionnaireResponseStore.d.ts +0 -27
- package/lib/stores/useQuestionnaireResponseStore.js +0 -49
- package/lib/stores/useQuestionnaireResponseStore.js.map +0 -1
- package/lib/stores/useQuestionnaireStore.d.ts +0 -64
- package/lib/stores/useQuestionnaireStore.js +0 -173
- package/lib/stores/useQuestionnaireStore.js.map +0 -1
- package/lib/stores/useSmartConfigStore.d.ts +0 -14
- package/lib/stores/useSmartConfigStore.js +0 -13
- package/lib/stores/useSmartConfigStore.js.map +0 -1
- package/lib/stores/useTerminologyServerStore.d.ts +0 -7
- package/lib/stores/useTerminologyServerStore.js +0 -25
- package/lib/stores/useTerminologyServerStore.js.map +0 -1
- package/lib/stories/MedicalHistoryTable.stories.js +0 -45
- package/lib/stories/MedicalHistoryTable.stories.js.map +0 -1
- package/lib/stories/SmartFormsRenderer.stories.js +0 -103
- package/lib/stories/SmartFormsRenderer.stories.js.map +0 -1
- package/lib/test.d.ts +0 -4
- package/lib/test.js +0 -18
- package/lib/test.js.map +0 -1
- package/lib/theme/overrides/Backdrop.d.ts +0 -13
- package/lib/theme/overrides/Backdrop.js +0 -32
- package/lib/theme/overrides/Backdrop.js.map +0 -1
- package/lib/theme/overrides/Typography.d.ts +0 -13
- package/lib/theme/overrides/Typography.js +0 -31
- package/lib/theme/overrides/Typography.js.map +0 -1
- package/lib/utils/formChangesOld.d.ts +0 -18
- package/lib/utils/formChangesOld.js +0 -91
- package/lib/utils/formChangesOld.js.map +0 -1
- package/lib/utils/initialiseForm.d.ts +0 -22
- package/lib/utils/initialiseForm.js +0 -53
- package/lib/utils/initialiseForm.js.map +0 -1
- package/lib/utils/launchContext.d.ts +0 -0
- package/lib/utils/launchContext.js +0 -2
- package/lib/utils/launchContext.js.map +0 -1
- package/lib/utils/populateInputParams.d.ts +0 -8
- package/lib/utils/populateInputParams.js +0 -193
- package/lib/utils/populateInputParams.js.map +0 -1
- package/lib/utils/removeHidden.d.ts +0 -16
- package/lib/utils/removeHidden.js +0 -105
- package/lib/utils/removeHidden.js.map +0 -1
- package/lib/utils/repopulate.d.ts +0 -9
- package/lib/utils/repopulate.js +0 -133
- package/lib/utils/repopulate.js.map +0 -1
- package/lib/utils/repopulateGenerateItems.d.ts +0 -9
- package/lib/utils/repopulateGenerateItems.js +0 -133
- package/lib/utils/repopulateGenerateItems.js.map +0 -1
- package/lib/utils/repopulateRepeatGroup.d.ts +0 -4
- package/lib/utils/repopulateRepeatGroup.js +0 -62
- package/lib/utils/repopulateRepeatGroup.js.map +0 -1
|
@@ -0,0 +1,273 @@
|
|
|
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 type { QuestionnaireResponse, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
19
|
+
import { Questionnaire, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
20
|
+
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
21
|
+
import { EnableWhenExpression, EnableWhenItems } from '../interfaces/enableWhen.interface';
|
|
22
|
+
import { isHidden } from './qItem';
|
|
23
|
+
import { getRegexValidation } from './itemControl';
|
|
24
|
+
import { structuredDataCapture } from 'fhir-sdc-helpers';
|
|
25
|
+
import { RegexValidation } from '../interfaces/regex.interface';
|
|
26
|
+
|
|
27
|
+
export type InvalidType = 'regex' | 'minLength' | 'maxLength' | 'required';
|
|
28
|
+
|
|
29
|
+
interface ValidateQuestionnaireParams {
|
|
30
|
+
questionnaire: Questionnaire;
|
|
31
|
+
questionnaireResponse: QuestionnaireResponse;
|
|
32
|
+
invalidItems: Record<string, InvalidType>;
|
|
33
|
+
enableWhenIsActivated: boolean;
|
|
34
|
+
enableWhenItems: EnableWhenItems;
|
|
35
|
+
enableWhenExpressions: Record<string, EnableWhenExpression>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Recursively go through the questionnaireResponse and check for un-filled required qItems
|
|
40
|
+
* At the moment item.required for group items are not checked
|
|
41
|
+
* FIXME will eventually be renamed to validate questionnaire
|
|
42
|
+
*
|
|
43
|
+
* @author Sean Fong
|
|
44
|
+
*/
|
|
45
|
+
export function validateQuestionnaire(
|
|
46
|
+
params: ValidateQuestionnaireParams
|
|
47
|
+
): Record<string, InvalidType> {
|
|
48
|
+
const {
|
|
49
|
+
questionnaire,
|
|
50
|
+
questionnaireResponse,
|
|
51
|
+
invalidItems,
|
|
52
|
+
enableWhenIsActivated,
|
|
53
|
+
enableWhenItems,
|
|
54
|
+
enableWhenExpressions
|
|
55
|
+
} = params;
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
!questionnaire.item ||
|
|
59
|
+
questionnaire.item.length === 0 ||
|
|
60
|
+
!questionnaireResponse.item ||
|
|
61
|
+
questionnaireResponse.item.length === 0
|
|
62
|
+
) {
|
|
63
|
+
return invalidItems;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const qItemsIndexMap = mapQItemsIndex(questionnaire);
|
|
67
|
+
const topLevelQRItemsByIndex = getQrItemsIndex(
|
|
68
|
+
questionnaire.item,
|
|
69
|
+
questionnaireResponse.item,
|
|
70
|
+
qItemsIndexMap
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
for (const [index, topLevelQItem] of questionnaire.item.entries()) {
|
|
74
|
+
let topLevelQRItem = topLevelQRItemsByIndex[index] ?? {
|
|
75
|
+
linkId: topLevelQItem.linkId,
|
|
76
|
+
text: topLevelQItem.text
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (Array.isArray(topLevelQRItem)) {
|
|
80
|
+
topLevelQRItem = {
|
|
81
|
+
linkId: topLevelQItem.linkId,
|
|
82
|
+
text: topLevelQItem.text,
|
|
83
|
+
item: topLevelQRItem
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
validateItemRecursive({
|
|
88
|
+
qItem: topLevelQItem,
|
|
89
|
+
qrItem: topLevelQRItem,
|
|
90
|
+
invalidItems: invalidItems,
|
|
91
|
+
enableWhenIsActivated,
|
|
92
|
+
enableWhenItems,
|
|
93
|
+
enableWhenExpressions
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return invalidItems;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface ValidateItemRecursiveParams {
|
|
101
|
+
qItem: QuestionnaireItem;
|
|
102
|
+
qrItem: QuestionnaireResponseItem;
|
|
103
|
+
invalidItems: Record<string, InvalidType>;
|
|
104
|
+
enableWhenIsActivated: boolean;
|
|
105
|
+
enableWhenItems: EnableWhenItems;
|
|
106
|
+
enableWhenExpressions: Record<string, EnableWhenExpression>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function validateItemRecursive(params: ValidateItemRecursiveParams) {
|
|
110
|
+
const {
|
|
111
|
+
qItem,
|
|
112
|
+
qrItem,
|
|
113
|
+
invalidItems,
|
|
114
|
+
enableWhenIsActivated,
|
|
115
|
+
enableWhenItems,
|
|
116
|
+
enableWhenExpressions
|
|
117
|
+
} = params;
|
|
118
|
+
|
|
119
|
+
if (
|
|
120
|
+
isHidden({
|
|
121
|
+
questionnaireItem: qItem,
|
|
122
|
+
enableWhenIsActivated,
|
|
123
|
+
enableWhenItems,
|
|
124
|
+
enableWhenExpressions
|
|
125
|
+
})
|
|
126
|
+
) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// FIXME repeat groups not working
|
|
131
|
+
if (qItem.type === 'group' && qItem.repeats) {
|
|
132
|
+
return validateRepeatGroup(qItem, qrItem, invalidItems);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const childQItems = qItem.item;
|
|
136
|
+
if (childQItems && childQItems.length > 0) {
|
|
137
|
+
const childQrItems = qrItem?.item ?? [];
|
|
138
|
+
|
|
139
|
+
const indexMap = mapQItemsIndex(qItem);
|
|
140
|
+
const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);
|
|
141
|
+
|
|
142
|
+
if (qItem.type === 'group' && qItem.required) {
|
|
143
|
+
if (!qrItem || qrItemsByIndex.length === 0) {
|
|
144
|
+
invalidItems[qItem.linkId] = 'required';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (const [index, childQItem] of childQItems.entries()) {
|
|
149
|
+
let childQRItem = qrItemsByIndex[index] ?? {
|
|
150
|
+
linkId: childQItem.linkId,
|
|
151
|
+
text: childQItem.text
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
if (Array.isArray(childQRItem)) {
|
|
155
|
+
childQRItem = {
|
|
156
|
+
linkId: childQItem.linkId,
|
|
157
|
+
text: childQItem.text,
|
|
158
|
+
item: childQRItem
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
validateItemRecursive({
|
|
163
|
+
qItem: childQItem,
|
|
164
|
+
qrItem: childQRItem,
|
|
165
|
+
invalidItems: invalidItems,
|
|
166
|
+
enableWhenIsActivated,
|
|
167
|
+
enableWhenItems,
|
|
168
|
+
enableWhenExpressions
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
validateSingleItem(qItem, qrItem, invalidItems);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function validateSingleItem(
|
|
177
|
+
qItem: QuestionnaireItem,
|
|
178
|
+
qrItem: QuestionnaireResponseItem,
|
|
179
|
+
invalidItems: Record<string, InvalidType>
|
|
180
|
+
) {
|
|
181
|
+
// Validate item.required
|
|
182
|
+
if (qItem.type !== 'display') {
|
|
183
|
+
if (qItem.required && !qrItem.answer) {
|
|
184
|
+
invalidItems[qItem.linkId] = 'required';
|
|
185
|
+
return invalidItems;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Validate regex, maxLength and minLength
|
|
190
|
+
if (qrItem.answer) {
|
|
191
|
+
for (const answer of qrItem.answer) {
|
|
192
|
+
if (answer.valueString || answer.valueInteger || answer.valueDecimal || answer.valueUri) {
|
|
193
|
+
const invalidInputType = getInputInvalidType(
|
|
194
|
+
getInputInString(answer),
|
|
195
|
+
getRegexValidation(qItem),
|
|
196
|
+
structuredDataCapture.getMinLength(qItem) ?? null,
|
|
197
|
+
qItem.maxLength ?? null
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
if (!invalidInputType) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Assign invalid type and break - stop checking other answers if is a repeat item
|
|
205
|
+
switch (invalidInputType) {
|
|
206
|
+
case 'regex':
|
|
207
|
+
invalidItems[qItem.linkId] = 'regex';
|
|
208
|
+
break;
|
|
209
|
+
case 'minLength':
|
|
210
|
+
invalidItems[qItem.linkId] = 'minLength';
|
|
211
|
+
break;
|
|
212
|
+
case 'maxLength':
|
|
213
|
+
invalidItems[qItem.linkId] = 'maxLength';
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Reached the end of the loop and no invalid input type found
|
|
221
|
+
// If a required item is filled, remove the required invalid type
|
|
222
|
+
if (qItem.required && invalidItems[qItem.linkId] && invalidItems[qItem.linkId] === 'required') {
|
|
223
|
+
delete invalidItems[qItem.linkId];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return invalidItems;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function validateRepeatGroup(
|
|
231
|
+
qItem: QuestionnaireItem,
|
|
232
|
+
qrItems: QuestionnaireResponseItem,
|
|
233
|
+
invalidLinkIds: Record<string, InvalidType>
|
|
234
|
+
) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function getInputInString(answer: QuestionnaireResponseItemAnswer) {
|
|
239
|
+
if (answer.valueString) {
|
|
240
|
+
return answer.valueString;
|
|
241
|
+
} else if (answer.valueInteger) {
|
|
242
|
+
return answer.valueInteger.toString();
|
|
243
|
+
} else if (answer.valueDecimal) {
|
|
244
|
+
return answer.valueDecimal.toString();
|
|
245
|
+
} else if (answer.valueUri) {
|
|
246
|
+
return answer.valueUri;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function getInputInvalidType(
|
|
253
|
+
input: string,
|
|
254
|
+
regexValidation: RegexValidation | null,
|
|
255
|
+
minLength: number | null,
|
|
256
|
+
maxLength: number | null
|
|
257
|
+
): InvalidType | null {
|
|
258
|
+
if (input) {
|
|
259
|
+
if (regexValidation && !regexValidation.expression.test(input)) {
|
|
260
|
+
return 'regex';
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (minLength && input.length < minLength) {
|
|
264
|
+
return 'minLength';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (maxLength && input.length > maxLength) {
|
|
268
|
+
return 'maxLength';
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BackToTopButton.js","sourceRoot":"","sources":["../../../src/components/BackToTopButton/BackToTopButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAM9D,SAAS,eAAe,CAAC,KAAY;IACnC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,MAAM,OAAO,GAAG,gBAAgB,CAAC;QAC/B,iBAAiB,EAAE,IAAI;QACvB,SAAS,EAAE,GAAG;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,IAAI,IAAC,EAAE,EAAE,OAAO;QACf,oBAAC,GAAG,IAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,IACxE,QAAQ,CACL,CACD,CACR,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
4
|
-
interface CustomDateField2Props extends PropsWithIsTabledAttribute {
|
|
5
|
-
linkId: string;
|
|
6
|
-
valueDate: string;
|
|
7
|
-
input: string;
|
|
8
|
-
feedback: string;
|
|
9
|
-
isFocused: boolean;
|
|
10
|
-
displayPrompt: string;
|
|
11
|
-
entryFormat: string;
|
|
12
|
-
readOnly: boolean;
|
|
13
|
-
setFocused: Dispatch<SetStateAction<boolean>>;
|
|
14
|
-
onInputChange: (newInput: string) => void;
|
|
15
|
-
onSelectDate: (newDateValue: string) => void;
|
|
16
|
-
}
|
|
17
|
-
declare function CustomDateField2(props: CustomDateField2Props): React.JSX.Element;
|
|
18
|
-
export default CustomDateField2;
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
import React, { useRef } from 'react';
|
|
18
|
-
import { StandardTextField } from '../Textfield.styles';
|
|
19
|
-
import DatePicker from './customDateTimePicker/DatePicker';
|
|
20
|
-
function CustomDateField2(props) {
|
|
21
|
-
const { linkId, valueDate, input, feedback, isFocused, displayPrompt, entryFormat, readOnly, isTabled, setFocused, onInputChange, onSelectDate } = props;
|
|
22
|
-
const anchorRef = useRef(null);
|
|
23
|
-
return (React.createElement(StandardTextField, { id: linkId, ref: anchorRef, fullWidth: true, isTabled: isTabled, value: input, error: !!feedback, onChange: (e) => onInputChange(e.target.value), label: displayPrompt, placeholder: entryFormat !== '' ? entryFormat : 'DD/MM/YYYY', disabled: readOnly, size: "small", focused: isFocused, onFocus: () => setFocused(true), onBlur: () => setFocused(false), InputProps: {
|
|
24
|
-
endAdornment: (React.createElement(React.Fragment, null,
|
|
25
|
-
React.createElement(DatePicker, { valueString: valueDate, anchorEl: anchorRef.current, onSelectDate: (valueDayjs) => {
|
|
26
|
-
onSelectDate(valueDayjs.format('DD/MM/YYYY'));
|
|
27
|
-
}, onFocus: (focus) => setFocused(focus) })))
|
|
28
|
-
}, helperText: feedback }));
|
|
29
|
-
}
|
|
30
|
-
export default CustomDateField2;
|
|
31
|
-
//# sourceMappingURL=CustomDateField2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateField2.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/CustomDateItem/CustomDateField2.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAgB3D,SAAS,gBAAgB,CAAC,KAA4B;IACpD,MAAM,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,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rItemChangeHandler } from '../../../interfaces/renderProps.interface';
|
|
3
|
-
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
4
|
-
interface CustomDateTimePickerTextProps extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>, PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
5
|
-
qItem: QuestionnaireItem;
|
|
6
|
-
qrItem: QuestionnaireResponseItem;
|
|
7
|
-
}
|
|
8
|
-
declare function CustomDateTimePickerText(props: CustomDateTimePickerTextProps): React.JSX.Element;
|
|
9
|
-
export default CustomDateTimePickerText;
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
import React, { useState } from 'react';
|
|
18
|
-
import useReadOnly from '../../../hooks/useReadOnly';
|
|
19
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
20
|
-
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
21
|
-
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
22
|
-
import useParseDates from './customDateTimePicker/hooks/useParseDates';
|
|
23
|
-
import CustomDateField from './customDateTimePicker/CustomDateField';
|
|
24
|
-
import { parseDisplayDateToFhirDate, parseFhirDateToDisplayDate, replaceMonthNameWithNumber } from './customDateTimePicker/utils/parseDates';
|
|
25
|
-
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
26
|
-
function CustomDateTimePickerText(props) {
|
|
27
|
-
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
28
|
-
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
29
|
-
const { displayPrompt, displayInstructions, entryFormat } = useRenderingExtensions(qItem);
|
|
30
|
-
const qrDate = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
|
|
31
|
-
// Init input value
|
|
32
|
-
let valueDate = '';
|
|
33
|
-
if (qrDate.answer) {
|
|
34
|
-
if (qrDate.answer[0].valueDate) {
|
|
35
|
-
valueDate = qrDate.answer[0].valueDate;
|
|
36
|
-
}
|
|
37
|
-
else if (qrDate.answer[0].valueDateTime) {
|
|
38
|
-
valueDate = qrDate.answer[0].valueDateTime;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
valueDate = parseFhirDateToDisplayDate(valueDate);
|
|
42
|
-
const selectedDateToDisplay = valueDate.length === 0 ? 'N/A' : valueDate;
|
|
43
|
-
const [input, setInput] = useState(valueDate);
|
|
44
|
-
const [focused, setFocused] = useState(false);
|
|
45
|
-
let options = [];
|
|
46
|
-
const { dateOptions, seperator } = useParseDates(input);
|
|
47
|
-
if (dateOptions) {
|
|
48
|
-
options = dateOptions;
|
|
49
|
-
}
|
|
50
|
-
function handleValueChange(newDateString) {
|
|
51
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
|
|
52
|
-
}
|
|
53
|
-
function handleUnfocus() {
|
|
54
|
-
// set answer to current input when text field is unfocused
|
|
55
|
-
if (!valueDate && input !== '') {
|
|
56
|
-
const replacedInput = replaceMonthNameWithNumber(input);
|
|
57
|
-
const matchedOption = options.find((option) => replacedInput === option);
|
|
58
|
-
if (matchedOption) {
|
|
59
|
-
const newDateString = matchedOption.split(seperator).join('/');
|
|
60
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
setFocused(false);
|
|
64
|
-
}
|
|
65
|
-
if (isRepeated) {
|
|
66
|
-
return (React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }));
|
|
67
|
-
}
|
|
68
|
-
return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-date-box" },
|
|
69
|
-
React.createElement(ItemFieldGrid, { qItem: qItem, displayInstructions: displayInstructions.length > 0 ? (displayInstructions) : (React.createElement(React.Fragment, null,
|
|
70
|
-
"Selected date: ",
|
|
71
|
-
React.createElement("b", null, selectedDateToDisplay))), readOnly: readOnly },
|
|
72
|
-
React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }))));
|
|
73
|
-
}
|
|
74
|
-
export default CustomDateTimePickerText;
|
|
75
|
-
//# sourceMappingURL=CustomDateTimeField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateTimeField.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/CustomDateItem/CustomDateTimeField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAA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AAO,CACL,oBAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACH,CAAC;KACH;IAED,OAAO,CACL,oBAAC,yBAAyB,iBAAW,iBAAiB;QACpD,oBAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,mBAAmB,EACjB,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,mBAAmB,CACpB,CAAC,CAAC,CAAC,CACF;;gBACiB,+BAAI,qBAAqB,CAAK,CAC5C,CACJ,EAEH,QAAQ,EAAE,QAAQ;YAClB,oBAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler } from '../../../interfaces/renderProps.interface';
|
|
3
|
-
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
4
|
-
interface CustomDateTimePickerTextProps extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>, PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
5
|
-
qItem: QuestionnaireItem;
|
|
6
|
-
qrItem: QuestionnaireResponseItem;
|
|
7
|
-
}
|
|
8
|
-
declare function CustomDateTimePickerText(props: CustomDateTimePickerTextProps): React.JSX.Element;
|
|
9
|
-
export default CustomDateTimePickerText;
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
import React, { useState } from 'react';
|
|
18
|
-
import useReadOnly from '../../../hooks/useReadOnly';
|
|
19
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
20
|
-
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
21
|
-
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
22
|
-
import useParseDates from './customDateTimePicker/hooks/useParseDates';
|
|
23
|
-
import CustomDateField from './customDateTimePicker/CustomDateField';
|
|
24
|
-
import { parseDisplayDateToFhirDate, parseFhirDateToDisplayDate, replaceMonthNameWithNumber } from './customDateTimePicker/utils/parseDates';
|
|
25
|
-
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
26
|
-
function CustomDateTimePickerText(props) {
|
|
27
|
-
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
28
|
-
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
29
|
-
const { displayPrompt, displayInstructions, entryFormat } = useRenderingExtensions(qItem);
|
|
30
|
-
const qrDate = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
|
|
31
|
-
// Init input value
|
|
32
|
-
let valueDate = '';
|
|
33
|
-
if (qrDate.answer) {
|
|
34
|
-
if (qrDate.answer[0].valueDate) {
|
|
35
|
-
valueDate = qrDate.answer[0].valueDate;
|
|
36
|
-
}
|
|
37
|
-
else if (qrDate.answer[0].valueDateTime) {
|
|
38
|
-
valueDate = qrDate.answer[0].valueDateTime;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
valueDate = parseFhirDateToDisplayDate(valueDate);
|
|
42
|
-
const selectedDateToDisplay = valueDate.length === 0 ? 'N/A' : valueDate;
|
|
43
|
-
const [input, setInput] = useState(valueDate);
|
|
44
|
-
const [focused, setFocused] = useState(false);
|
|
45
|
-
let options = [];
|
|
46
|
-
const { dateOptions, seperator } = useParseDates(input);
|
|
47
|
-
if (dateOptions) {
|
|
48
|
-
options = dateOptions;
|
|
49
|
-
}
|
|
50
|
-
function handleValueChange(newDateString) {
|
|
51
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
|
|
52
|
-
}
|
|
53
|
-
function handleUnfocus() {
|
|
54
|
-
// set answer to current input when text field is unfocused
|
|
55
|
-
if (!valueDate && input !== '') {
|
|
56
|
-
const replacedInput = replaceMonthNameWithNumber(input);
|
|
57
|
-
const matchedOption = options.find((option) => replacedInput === option);
|
|
58
|
-
if (matchedOption) {
|
|
59
|
-
const newDateString = matchedOption.split(seperator).join('/');
|
|
60
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseDisplayDateToFhirDate(newDateString, seperator) }] }));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
setFocused(false);
|
|
64
|
-
}
|
|
65
|
-
if (isRepeated) {
|
|
66
|
-
return (React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }));
|
|
67
|
-
}
|
|
68
|
-
return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-date-box" },
|
|
69
|
-
React.createElement(ItemFieldGrid, { qItem: qItem, displayInstructions: displayInstructions.length > 0 ? (displayInstructions) : (React.createElement(React.Fragment, null,
|
|
70
|
-
"Selected date: ",
|
|
71
|
-
React.createElement("b", null, selectedDateToDisplay))), readOnly: readOnly },
|
|
72
|
-
React.createElement(CustomDateField, { valueDate: valueDate, input: input, isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: (newInput) => setInput(newInput), onValueChange: handleValueChange, onUnfocus: handleUnfocus }))));
|
|
73
|
-
}
|
|
74
|
-
export default CustomDateTimePickerText;
|
|
75
|
-
//# sourceMappingURL=CustomDateTimePickerText2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateTimePickerText2.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/CustomDateItem/CustomDateTimePickerText2.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,s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AS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACH,CAAC;KACH;IAED,OAAO,CACL,oBAAC,yBAAyB,iBAAW,iBAAiB;QACpD,oBAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,mBAAmB,EACjB,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,mBAAmB,CACpB,CAAC,CAAC,CAAC,CACF;;gBACiB,+BAAI,qBAAqB,CAAK,CAC5C,CACJ,EAEH,QAAQ,EAAE,QAAQ;YAClB,oBAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC/C,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAE,aAAa,GACxB,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
import { parseInputToDateOptions } from '../utils/parseDates';
|
|
18
|
-
function useParseDates(input) {
|
|
19
|
-
// No options displayed when input is empty or search term is less than 2 characters
|
|
20
|
-
if (input.length === 0 || (input.length < 2 && input.length > 0)) {
|
|
21
|
-
return { dateOptions: [], seperator: '' };
|
|
22
|
-
}
|
|
23
|
-
const { dateOptions, seperator } = parseInputToDateOptions(input);
|
|
24
|
-
return { dateOptions, seperator };
|
|
25
|
-
}
|
|
26
|
-
export default useParseDates;
|
|
27
|
-
//# sourceMappingURL=useParseDates.js.map
|
package/lib/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useParseDates.js","sourceRoot":"","sources":["../../../../../../src/components/FormComponents/CustomDateItem/customDateTimePicker/hooks/useParseDates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,SAAS,aAAa,CAAC,KAAa;IAIlC,oFAAoF;IACpF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;QAChE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;KAC3C;IAED,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAElE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler } from '../../../interfaces/renderProps.interface';
|
|
3
|
-
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
4
|
-
interface CustomDateTimePickerTextProps extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>, PropsWithIsRepeatedAttribute, PropsWithIsTabledAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
5
|
-
qItem: QuestionnaireItem;
|
|
6
|
-
qrItem: QuestionnaireResponseItem;
|
|
7
|
-
}
|
|
8
|
-
declare function CustomDateTimePickerText(props: CustomDateTimePickerTextProps): React.JSX.Element;
|
|
9
|
-
export default CustomDateTimePickerText;
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
import React, { useState } from 'react';
|
|
18
|
-
import useReadOnly from '../../../hooks/useReadOnly';
|
|
19
|
-
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
20
|
-
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
21
|
-
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
22
|
-
import { parseFhirDateToDisplayDate, parseInputDateToFhirDate, validateInput } from './customDateTimePicker/utils/parseDates';
|
|
23
|
-
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
24
|
-
import useDateValidation from '../../../hooks/useDateValidation';
|
|
25
|
-
import CustomDateField2 from './CustomDateField2';
|
|
26
|
-
function CustomDateTimePickerText(props) {
|
|
27
|
-
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
28
|
-
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
29
|
-
const { displayPrompt, displayInstructions, entryFormat } = useRenderingExtensions(qItem);
|
|
30
|
-
const qrDate = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
|
|
31
|
-
// Init input value
|
|
32
|
-
let valueDate = '';
|
|
33
|
-
if (qrDate.answer) {
|
|
34
|
-
if (qrDate.answer[0].valueDate) {
|
|
35
|
-
valueDate = qrDate.answer[0].valueDate;
|
|
36
|
-
}
|
|
37
|
-
else if (qrDate.answer[0].valueDateTime) {
|
|
38
|
-
valueDate = qrDate.answer[0].valueDateTime;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const { displayDate, parseFail } = parseFhirDateToDisplayDate(valueDate);
|
|
42
|
-
const [input, setInput] = useState(displayDate);
|
|
43
|
-
const [focused, setFocused] = useState(false);
|
|
44
|
-
// Perform validation checks
|
|
45
|
-
const errorFeedback = useDateValidation(input, parseFail);
|
|
46
|
-
function handleSelectDate(selectedDate) {
|
|
47
|
-
setInput(selectedDate);
|
|
48
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseInputDateToFhirDate(selectedDate) }] }));
|
|
49
|
-
}
|
|
50
|
-
function handleInputChange(newInput) {
|
|
51
|
-
setInput(newInput);
|
|
52
|
-
if (newInput === '') {
|
|
53
|
-
onQrItemChange(createEmptyQrItem(qItem));
|
|
54
|
-
}
|
|
55
|
-
if (!validateInput(newInput)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueDate: parseInputDateToFhirDate(newInput) }] }));
|
|
59
|
-
}
|
|
60
|
-
if (isRepeated) {
|
|
61
|
-
return (React.createElement(CustomDateField2, { linkId: qItem.linkId, valueDate: displayDate, input: input, feedback: errorFeedback !== null && errorFeedback !== void 0 ? errorFeedback : '', isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: handleInputChange, onSelectDate: handleSelectDate }));
|
|
62
|
-
}
|
|
63
|
-
return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-date-box" },
|
|
64
|
-
React.createElement(ItemFieldGrid, { qItem: qItem, displayInstructions: displayInstructions, readOnly: readOnly },
|
|
65
|
-
React.createElement(CustomDateField2, { linkId: qItem.linkId, valueDate: displayDate, input: input, feedback: errorFeedback !== null && errorFeedback !== void 0 ? errorFeedback : '', isFocused: focused, displayPrompt: displayPrompt, entryFormat: entryFormat, readOnly: readOnly, isTabled: isTabled, setFocused: setFocused, onInputChange: handleInputChange, onSelectDate: handleSelectDate }),
|
|
66
|
-
React.createElement(React.Fragment, null,
|
|
67
|
-
"Verify date: ",
|
|
68
|
-
displayDate))));
|
|
69
|
-
}
|
|
70
|
-
export default CustomDateTimePickerText;
|
|
71
|
-
//# sourceMappingURL=CustomDateTimePickerText.js.map
|