@ukhomeoffice/cop-react-form-renderer 4.67.0 → 4.68.1
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/dist/components/CheckYourAnswers/Answer.js +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +4 -12
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +8 -23
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -15
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +1 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +7 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -3
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +2 -39
- package/dist/utils/Validate/validateComponent.test.js +4 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
10
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
14
|
/**
|
|
17
15
|
* Call a callback on a component and all of its child/nested components.
|
|
18
16
|
* At each stage, the value of the component is set to the returned value
|
|
@@ -28,56 +26,44 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
28
26
|
*/
|
|
29
27
|
var applyToComponentTree = function applyToComponentTree(root, callback) {
|
|
30
28
|
var _root$data;
|
|
31
|
-
|
|
32
29
|
if (!root) {
|
|
33
30
|
return null;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
if (!callback) {
|
|
37
33
|
return root;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
var result = _objectSpread({}, root);
|
|
41
|
-
|
|
42
36
|
switch (root.type) {
|
|
43
37
|
case _models.ComponentTypes.CONTAINER:
|
|
44
38
|
result.components.forEach(function (c, index, array) {
|
|
45
39
|
array[index] = applyToComponentTree(c, callback);
|
|
46
40
|
});
|
|
47
41
|
break;
|
|
48
|
-
|
|
49
42
|
case _models.ComponentTypes.COLLECTION:
|
|
50
43
|
result.item.forEach(function (c, index, array) {
|
|
51
44
|
array[index] = applyToComponentTree(c, callback);
|
|
52
45
|
});
|
|
53
46
|
break;
|
|
54
|
-
|
|
55
47
|
case _models.ComponentTypes.CHECKBOXES:
|
|
56
48
|
case _models.ComponentTypes.RADIOS:
|
|
57
49
|
if (!((_root$data = root.data) !== null && _root$data !== void 0 && _root$data.options)) {
|
|
58
50
|
break;
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
result.data = _objectSpread({}, root.data);
|
|
62
53
|
result.data.options = root.data.options.map(function (option) {
|
|
63
54
|
var newOption = _objectSpread({}, option);
|
|
64
|
-
|
|
65
55
|
if (option.nested) {
|
|
66
56
|
newOption.nested = option.nested.map(function (c) {
|
|
67
57
|
return applyToComponentTree(c, callback);
|
|
68
58
|
});
|
|
69
59
|
}
|
|
70
|
-
|
|
71
60
|
return newOption;
|
|
72
61
|
});
|
|
73
62
|
break;
|
|
74
|
-
|
|
75
63
|
default:
|
|
76
64
|
break;
|
|
77
65
|
}
|
|
78
|
-
|
|
79
66
|
return callback(result);
|
|
80
67
|
};
|
|
81
|
-
|
|
82
68
|
var _default = applyToComponentTree;
|
|
83
69
|
exports.default = _default;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _applyToComponentTree = _interopRequireDefault(require("./applyToComponentTree"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
5
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
11
|
describe('utils.Component.applyToComponentTree', function () {
|
|
14
12
|
var SINGLE_COMP = {
|
|
15
13
|
type: 'text',
|
|
@@ -48,13 +46,11 @@ describe('utils.Component.applyToComponentTree', function () {
|
|
|
48
46
|
}]
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
|
-
|
|
52
49
|
var CALLBACK = function CALLBACK(component) {
|
|
53
50
|
return _objectSpread(_objectSpread({}, component), {}, {
|
|
54
51
|
label: component.label.toUpperCase()
|
|
55
52
|
});
|
|
56
53
|
};
|
|
57
|
-
|
|
58
54
|
it('should return null when root is undefined', function () {
|
|
59
55
|
var result = (0, _applyToComponentTree.default)(undefined, CALLBACK);
|
|
60
56
|
expect(result).toEqual(null);
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.JSON_ONLY_PROPERTIES = void 0;
|
|
7
|
-
|
|
8
7
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
9
|
-
|
|
10
8
|
var JSON_ONLY_PROPERTIES = ['source', 'use', 'show_when', 'options', 'additionalValidation', 'full_path', 'formData'];
|
|
9
|
+
|
|
11
10
|
/**
|
|
12
11
|
* This method removes and properties that are entirely specific to the JSON
|
|
13
12
|
* configuration and that should not be used as HTML attributes.
|
|
@@ -19,25 +18,19 @@ var JSON_ONLY_PROPERTIES = ['source', 'use', 'show_when', 'options', 'additional
|
|
|
19
18
|
* @param {Array} alsoRemove An array of additional properties to remove.
|
|
20
19
|
* @returns A clean(er) JSON object.
|
|
21
20
|
*/
|
|
22
|
-
|
|
23
21
|
exports.JSON_ONLY_PROPERTIES = JSON_ONLY_PROPERTIES;
|
|
24
|
-
|
|
25
22
|
var cleanAttributes = function cleanAttributes(options) {
|
|
26
23
|
var alsoRemove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
27
24
|
var removeKeys = Array.isArray(alsoRemove) ? [].concat(JSON_ONLY_PROPERTIES, alsoRemove) : JSON_ONLY_PROPERTIES;
|
|
28
|
-
|
|
29
25
|
if (options && _typeof(options) === 'object') {
|
|
30
26
|
return Object.keys(options).reduce(function (obj, key) {
|
|
31
27
|
if (!removeKeys.includes(key)) {
|
|
32
28
|
obj[key] = options[key];
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
return obj;
|
|
36
31
|
}, {});
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
return {};
|
|
40
34
|
};
|
|
41
|
-
|
|
42
35
|
var _default = cleanAttributes;
|
|
43
36
|
exports.default = _default;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
var _cleanAttributes = _interopRequireWildcard(require("./cleanAttributes"));
|
|
6
|
-
|
|
7
5
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
-
|
|
9
6
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
|
|
11
7
|
// Local imports
|
|
8
|
+
|
|
12
9
|
describe('utils', function () {
|
|
13
10
|
describe('Component', function () {
|
|
14
11
|
describe('clean', function () {
|
|
@@ -27,18 +24,19 @@ describe('utils', function () {
|
|
|
27
24
|
it('should only remove properties specific to JSON', function () {
|
|
28
25
|
var OPTIONS = {
|
|
29
26
|
id: 'bob'
|
|
30
|
-
};
|
|
31
|
-
|
|
27
|
+
};
|
|
28
|
+
// Add a bunch of properties we know will need to be removed.
|
|
32
29
|
_cleanAttributes.JSON_ONLY_PROPERTIES.forEach(function (p) {
|
|
33
30
|
return OPTIONS[p] = 'value';
|
|
34
31
|
});
|
|
32
|
+
var RESULT = (0, _cleanAttributes.default)(OPTIONS);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
// The original options should remain untouched.
|
|
38
35
|
expect(OPTIONS.id).toEqual('bob');
|
|
39
|
-
expect(OPTIONS['source']).toEqual('value');
|
|
40
|
-
// which means it should simply have an id of 'bob'.
|
|
36
|
+
expect(OPTIONS['source']).toEqual('value');
|
|
41
37
|
|
|
38
|
+
// But those values should have been removed from the result,
|
|
39
|
+
// which means it should simply have an id of 'bob'.
|
|
42
40
|
expect(RESULT).toEqual({
|
|
43
41
|
id: 'bob'
|
|
44
42
|
});
|
|
@@ -47,19 +45,20 @@ describe('utils', function () {
|
|
|
47
45
|
var OPTIONS = {
|
|
48
46
|
id: 'bob',
|
|
49
47
|
fieldId: 'bobField'
|
|
50
|
-
};
|
|
51
|
-
|
|
48
|
+
};
|
|
49
|
+
// Add a bunch of properties we know will need to be removed.
|
|
52
50
|
_cleanAttributes.JSON_ONLY_PROPERTIES.forEach(function (p) {
|
|
53
51
|
return OPTIONS[p] = 'value';
|
|
54
52
|
});
|
|
53
|
+
var RESULT = (0, _cleanAttributes.default)(OPTIONS, ['fieldId']);
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
// The original options should remain untouched.
|
|
58
56
|
expect(OPTIONS.id).toEqual('bob');
|
|
59
57
|
expect(OPTIONS.fieldId).toEqual('bobField');
|
|
60
|
-
expect(OPTIONS['source']).toEqual('value');
|
|
61
|
-
// which means it should simply have an id of 'bob'.
|
|
58
|
+
expect(OPTIONS['source']).toEqual('value');
|
|
62
59
|
|
|
60
|
+
// But those values should have been removed from the result,
|
|
61
|
+
// which means it should simply have an id of 'bob'.
|
|
63
62
|
expect(RESULT).toEqual({
|
|
64
63
|
id: 'bob'
|
|
65
64
|
});
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _Data = _interopRequireDefault(require("../Data"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Iterates over an array of components and brings any nested
|
|
14
11
|
* components that should be visible into the top level array.
|
|
@@ -39,13 +36,11 @@ var elevateNestedComponents = function elevateNestedComponents(components, data)
|
|
|
39
36
|
var allComponents = [];
|
|
40
37
|
components === null || components === void 0 ? void 0 : components.forEach(function (component) {
|
|
41
38
|
var _component$data, _component$data$optio;
|
|
42
|
-
|
|
43
39
|
allComponents.push(component);
|
|
44
40
|
(_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
|
|
45
41
|
// If this option has nested components and is
|
|
46
42
|
// selected, then add its nested components to the array.
|
|
47
43
|
var sourceData = (data === null || data === void 0 ? void 0 : data[component.id]) || _Data.default.getSource(data, component.full_path);
|
|
48
|
-
|
|
49
44
|
if (Array.isArray(option.nested) && sourceData === option.value) {
|
|
50
45
|
allComponents = allComponents.concat(option.nested);
|
|
51
46
|
}
|
|
@@ -53,6 +48,5 @@ var elevateNestedComponents = function elevateNestedComponents(components, data)
|
|
|
53
48
|
});
|
|
54
49
|
return allComponents;
|
|
55
50
|
};
|
|
56
|
-
|
|
57
51
|
var _default = elevateNestedComponents;
|
|
58
52
|
exports.default = _default;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _elevateNestedComponents = _interopRequireDefault(require("./elevateNestedComponents"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
describe('utils.Component.elevateNestedComponents', function () {
|
|
8
6
|
it('should return an empty array if components is undefined', function () {
|
|
9
7
|
var DATA = {
|
|
@@ -1,38 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getChildrenJsx = exports.default = void 0;
|
|
7
|
-
|
|
8
8
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
10
|
var _models = require("../../models");
|
|
13
|
-
|
|
14
11
|
var _Data = _interopRequireDefault(require("../Data"));
|
|
15
|
-
|
|
16
12
|
var _cleanAttributes = _interopRequireDefault(require("./cleanAttributes"));
|
|
17
|
-
|
|
18
13
|
var _isEditable = _interopRequireDefault(require("./isEditable"));
|
|
19
|
-
|
|
20
14
|
var _FormComponent = _interopRequireDefault(require("../../components/FormComponent"));
|
|
21
|
-
|
|
22
15
|
var _wrapInFormGroup = _interopRequireDefault(require("./wrapInFormGroup"));
|
|
23
|
-
|
|
24
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
19
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
32
22
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
|
-
|
|
34
23
|
var LIST_CLASS = 'govuk-list';
|
|
35
24
|
var BODY_CLASS = 'govuk-body';
|
|
25
|
+
|
|
36
26
|
/**
|
|
37
27
|
* Separate function for each component type for the sake of
|
|
38
28
|
* code clarity - having the additional bits and pieces in the
|
|
@@ -42,43 +32,32 @@ var BODY_CLASS = 'govuk-body';
|
|
|
42
32
|
|
|
43
33
|
var getAlert = function getAlert(config) {
|
|
44
34
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
45
|
-
|
|
46
35
|
var heading = _copReactComponents.Utils.interpolateString(config.heading, config.formData);
|
|
47
|
-
|
|
48
36
|
var children = _copReactComponents.Utils.interpolateString(config.text, config.formData);
|
|
49
|
-
|
|
50
37
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Alert, _extends({}, attrs, {
|
|
51
38
|
heading: heading,
|
|
52
39
|
children: children
|
|
53
40
|
}));
|
|
54
41
|
};
|
|
55
|
-
|
|
56
42
|
var getAutocomplete = function getAutocomplete(config) {
|
|
57
43
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
58
|
-
|
|
59
44
|
var source = _Data.default.getAutocompleteSource(config);
|
|
60
|
-
|
|
61
45
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Autocomplete, _extends({}, attrs, {
|
|
62
46
|
source: source
|
|
63
47
|
}));
|
|
64
48
|
};
|
|
65
|
-
|
|
66
49
|
var getCheckboxes = function getCheckboxes(config) {
|
|
67
50
|
var options = [];
|
|
68
|
-
|
|
69
51
|
_Data.default.getOptions(config, function (val) {
|
|
70
52
|
options = val;
|
|
71
53
|
});
|
|
72
|
-
|
|
73
54
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
74
55
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Checkboxes, _extends({}, attrs, {
|
|
75
56
|
options: options
|
|
76
57
|
}));
|
|
77
58
|
};
|
|
78
|
-
|
|
79
59
|
var getCalculation = function getCalculation(config) {
|
|
80
60
|
var value = _Data.default.applyFormula(config);
|
|
81
|
-
|
|
82
61
|
if (typeof config.onChange === 'function') {
|
|
83
62
|
if (value !== config.value) {
|
|
84
63
|
config.onChange({
|
|
@@ -89,58 +68,46 @@ var getCalculation = function getCalculation(config) {
|
|
|
89
68
|
});
|
|
90
69
|
}
|
|
91
70
|
}
|
|
92
|
-
|
|
93
71
|
var attrs = (0, _cleanAttributes.default)(config, ['formula']);
|
|
94
72
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.TextInput, _extends({}, attrs, {
|
|
95
73
|
readonly: true
|
|
96
74
|
}));
|
|
97
75
|
};
|
|
98
|
-
|
|
99
76
|
var getDate = function getDate(config) {
|
|
100
77
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
101
78
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.DateInput, attrs);
|
|
102
79
|
};
|
|
103
|
-
|
|
104
80
|
var getDetails = function getDetails(config) {
|
|
105
81
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
106
82
|
var html = getHTML(config);
|
|
107
83
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Details, attrs, html);
|
|
108
84
|
};
|
|
109
|
-
|
|
110
85
|
var getFileUpload = function getFileUpload(config) {
|
|
111
86
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
112
87
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.FileUpload, attrs);
|
|
113
88
|
};
|
|
114
|
-
|
|
115
89
|
var getMultiFileUpload = function getMultiFileUpload(config) {
|
|
116
90
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
117
91
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.MultiFileUpload, attrs);
|
|
118
92
|
};
|
|
119
|
-
|
|
120
93
|
var getHeading = function getHeading(config) {
|
|
121
94
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
122
95
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Heading, attrs, config.content);
|
|
123
96
|
};
|
|
124
|
-
|
|
125
97
|
var getHTML = function getHTML(config) {
|
|
126
98
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
127
99
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Markup, attrs);
|
|
128
100
|
};
|
|
129
|
-
|
|
130
101
|
var getInsetText = function getInsetText(config) {
|
|
131
102
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
132
103
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.InsetText, attrs, config.content);
|
|
133
104
|
};
|
|
134
|
-
|
|
135
105
|
var getList = function getList(config) {
|
|
136
106
|
var _attrs$items;
|
|
137
|
-
|
|
138
107
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
139
108
|
var tagName = attrs.ordered ? 'ol' : 'ul';
|
|
140
109
|
var bullet = attrs.ordered ? 'number' : 'bullet';
|
|
141
|
-
|
|
142
110
|
var classes = _copReactComponents.Utils.classBuilder(LIST_CLASS, bullet);
|
|
143
|
-
|
|
144
111
|
var content = (_attrs$items = attrs.items) === null || _attrs$items === void 0 ? void 0 : _attrs$items.map(function (item) {
|
|
145
112
|
return "<li>".concat(item, "</li>");
|
|
146
113
|
}).join('');
|
|
@@ -151,7 +118,6 @@ var getList = function getList(config) {
|
|
|
151
118
|
type: _models.ComponentTypes.HTML
|
|
152
119
|
}));
|
|
153
120
|
};
|
|
154
|
-
|
|
155
121
|
var getParagraph = function getParagraph(config) {
|
|
156
122
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
157
123
|
return getHTML(_objectSpread(_objectSpread({
|
|
@@ -161,19 +127,15 @@ var getParagraph = function getParagraph(config) {
|
|
|
161
127
|
type: _models.ComponentTypes.HTML
|
|
162
128
|
}));
|
|
163
129
|
};
|
|
164
|
-
|
|
165
130
|
var getRadios = function getRadios(config) {
|
|
166
131
|
var options = [];
|
|
167
|
-
|
|
168
132
|
_Data.default.getOptions(config, function (val) {
|
|
169
133
|
options = val;
|
|
170
134
|
});
|
|
171
|
-
|
|
172
135
|
options.forEach(function (option) {
|
|
173
136
|
if (!Array.isArray(option.nested)) {
|
|
174
137
|
return;
|
|
175
138
|
}
|
|
176
|
-
|
|
177
139
|
option.children = getChildrenJsx(config, option.nested);
|
|
178
140
|
});
|
|
179
141
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
@@ -181,114 +143,86 @@ var getRadios = function getRadios(config) {
|
|
|
181
143
|
options: options
|
|
182
144
|
}));
|
|
183
145
|
};
|
|
184
|
-
|
|
185
146
|
var getTextArea = function getTextArea(config) {
|
|
186
147
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
187
148
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.TextArea, attrs);
|
|
188
149
|
};
|
|
189
|
-
|
|
190
150
|
var getTextInput = function getTextInput(config) {
|
|
191
151
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
192
152
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.TextInput, attrs);
|
|
193
153
|
};
|
|
194
|
-
|
|
195
154
|
var getTime = function getTime(config) {
|
|
196
155
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
197
156
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.TimeInput, attrs);
|
|
198
157
|
};
|
|
199
|
-
|
|
200
158
|
var getSelect = function getSelect(config) {
|
|
201
159
|
var options = [];
|
|
202
|
-
|
|
203
160
|
_Data.default.getOptions(config, function (val) {
|
|
204
161
|
options = val;
|
|
205
162
|
});
|
|
206
|
-
|
|
207
163
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
208
164
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Select, _extends({}, attrs, {
|
|
209
165
|
options: options
|
|
210
166
|
}));
|
|
211
167
|
};
|
|
212
|
-
|
|
213
168
|
var getWarningText = function getWarningText(config) {
|
|
214
169
|
var attrs = (0, _cleanAttributes.default)(config);
|
|
215
170
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.WarningText, attrs, config.content);
|
|
216
171
|
};
|
|
217
|
-
|
|
218
172
|
var getComponentByType = function getComponentByType(config) {
|
|
219
173
|
switch (config.type) {
|
|
220
174
|
case _models.ComponentTypes.HTML:
|
|
221
175
|
return getHTML(config);
|
|
222
|
-
|
|
223
176
|
case _models.ComponentTypes.HEADING:
|
|
224
177
|
return getHeading(config);
|
|
225
|
-
|
|
226
178
|
case _models.ComponentTypes.INSET_TEXT:
|
|
227
179
|
return getInsetText(config);
|
|
228
|
-
|
|
229
180
|
case _models.ComponentTypes.TEXT:
|
|
230
181
|
case _models.ComponentTypes.EMAIL:
|
|
231
182
|
case _models.ComponentTypes.PHONE_NUMBER:
|
|
232
183
|
return getTextInput(config);
|
|
233
|
-
|
|
234
184
|
case _models.ComponentTypes.TEXT_AREA:
|
|
235
185
|
return getTextArea(config);
|
|
236
|
-
|
|
237
186
|
case _models.ComponentTypes.AUTOCOMPLETE:
|
|
238
187
|
return getAutocomplete(config);
|
|
239
|
-
|
|
240
188
|
case _models.ComponentTypes.RADIOS:
|
|
241
189
|
return getRadios(config);
|
|
242
|
-
|
|
243
190
|
case _models.ComponentTypes.CHECKBOXES:
|
|
244
191
|
return getCheckboxes(config);
|
|
245
|
-
|
|
246
192
|
case _models.ComponentTypes.DATE:
|
|
247
193
|
return getDate(config);
|
|
248
|
-
|
|
249
194
|
case _models.ComponentTypes.TIME:
|
|
250
195
|
return getTime(config);
|
|
251
|
-
|
|
252
196
|
case _models.ComponentTypes.FILE:
|
|
253
197
|
return getFileUpload(config);
|
|
254
|
-
|
|
255
198
|
case _models.ComponentTypes.MULTI_FILE:
|
|
256
199
|
return getMultiFileUpload(config);
|
|
257
|
-
|
|
258
200
|
case _models.ComponentTypes.WARNING:
|
|
259
201
|
return getWarningText(config);
|
|
260
|
-
|
|
261
202
|
case _models.ComponentTypes.SELECT:
|
|
262
203
|
return getSelect(config);
|
|
263
|
-
|
|
264
204
|
case _models.ComponentTypes.DETAILS:
|
|
265
205
|
return getDetails(config);
|
|
266
|
-
|
|
267
206
|
case _models.ComponentTypes.CALCULATION:
|
|
268
207
|
return getCalculation(config);
|
|
269
|
-
|
|
270
208
|
case _models.ComponentTypes.ALERT:
|
|
271
209
|
return getAlert(config);
|
|
272
|
-
|
|
273
210
|
case _models.ComponentTypes.PARAGRAPH:
|
|
274
211
|
return getParagraph(config);
|
|
275
|
-
|
|
276
212
|
case _models.ComponentTypes.LIST:
|
|
277
213
|
return getList(config);
|
|
278
|
-
|
|
279
214
|
default:
|
|
280
215
|
{
|
|
281
216
|
return null;
|
|
282
217
|
}
|
|
283
218
|
}
|
|
284
219
|
};
|
|
220
|
+
|
|
285
221
|
/**
|
|
286
222
|
* Get single child component for a parent
|
|
287
223
|
* @param {*} parent the parent configuration
|
|
288
224
|
* @param {*} child the child configuration
|
|
289
225
|
*/
|
|
290
|
-
|
|
291
|
-
|
|
292
226
|
var getChildJsx = function getChildJsx(parent, child) {
|
|
293
227
|
if (parent.full_path) {
|
|
294
228
|
var pathParts = parent.full_path.split('.');
|
|
@@ -296,18 +230,14 @@ var getChildJsx = function getChildJsx(parent, child) {
|
|
|
296
230
|
pathParts.push(child.fieldId);
|
|
297
231
|
child.full_path = pathParts.join('.');
|
|
298
232
|
}
|
|
299
|
-
|
|
300
233
|
if (parent.formData) {
|
|
301
234
|
child.value = parent.formData[child.fieldId] || _Data.default.getSource(parent.formData, child.full_path) || '';
|
|
302
235
|
}
|
|
303
|
-
|
|
304
236
|
if ('readonly' in child) delete child.readonly;
|
|
305
|
-
|
|
306
237
|
if (parent.readonly) {
|
|
307
238
|
child.readonly = parent.readonly;
|
|
308
239
|
return /*#__PURE__*/_react.default.createElement("div", null, getComponent(child, false));
|
|
309
240
|
}
|
|
310
|
-
|
|
311
241
|
return /*#__PURE__*/_react.default.createElement(_FormComponent.default, {
|
|
312
242
|
component: child,
|
|
313
243
|
value: child.value,
|
|
@@ -316,13 +246,12 @@ var getChildJsx = function getChildJsx(parent, child) {
|
|
|
316
246
|
formData: parent.formData
|
|
317
247
|
});
|
|
318
248
|
};
|
|
249
|
+
|
|
319
250
|
/**
|
|
320
251
|
* Convert chidlrenConfigs into components
|
|
321
252
|
* @param {*} parentConfig parent component which the childrenConfigs will be under
|
|
322
253
|
* @param {*} childrenConfigs array of configurations for the child components
|
|
323
254
|
*/
|
|
324
|
-
|
|
325
|
-
|
|
326
255
|
var getChildrenJsx = function getChildrenJsx(parentConfig, childrenConfigs) {
|
|
327
256
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, childrenConfigs.map(function (config) {
|
|
328
257
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
@@ -330,9 +259,7 @@ var getChildrenJsx = function getChildrenJsx(parentConfig, childrenConfigs) {
|
|
|
330
259
|
}, getChildJsx(parentConfig, config));
|
|
331
260
|
}));
|
|
332
261
|
};
|
|
333
|
-
|
|
334
262
|
exports.getChildrenJsx = getChildrenJsx;
|
|
335
|
-
|
|
336
263
|
/**
|
|
337
264
|
* Get a renderable component, based on a configuration object.
|
|
338
265
|
* @param {object} config The configuration object for the component.
|
|
@@ -343,23 +270,17 @@ exports.getChildrenJsx = getChildrenJsx;
|
|
|
343
270
|
var getComponent = function getComponent(config) {
|
|
344
271
|
var wrap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
345
272
|
var fnOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
346
|
-
|
|
347
273
|
if (typeof fnOverride === 'function') {
|
|
348
274
|
var overrideComponent = fnOverride(config, wrap);
|
|
349
|
-
|
|
350
275
|
if (overrideComponent) {
|
|
351
276
|
return overrideComponent;
|
|
352
277
|
}
|
|
353
278
|
}
|
|
354
|
-
|
|
355
279
|
var component = getComponentByType(config);
|
|
356
|
-
|
|
357
280
|
if (component && wrap && (0, _isEditable.default)(config)) {
|
|
358
281
|
return (0, _wrapInFormGroup.default)(config, component);
|
|
359
282
|
}
|
|
360
|
-
|
|
361
283
|
return component;
|
|
362
284
|
};
|
|
363
|
-
|
|
364
285
|
var _default = getComponent;
|
|
365
286
|
exports.default = _default;
|