@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.0-alpha
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 +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- 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 +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- 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 +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- 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 +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- 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 +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- 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 +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- 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.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- 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 +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- 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/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -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 +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- 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 +0 -7
- 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 -4
- 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 +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
|
|
10
8
|
var _getSourceData = _interopRequireDefault(require("./getSourceData"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
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; }
|
|
15
|
-
|
|
16
11
|
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; }
|
|
17
|
-
|
|
18
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
13
|
var setDefaultDateValue = function setDefaultDateValue(date, data) {
|
|
21
14
|
if (date.defaultValue === 'today') {
|
|
22
15
|
data[date.fieldId] = (0, _dayjs.default)().format('DD-MM-YYYY');
|
|
@@ -24,24 +17,21 @@ var setDefaultDateValue = function setDefaultDateValue(date, data) {
|
|
|
24
17
|
data[date.fieldId] = date.defaultValue;
|
|
25
18
|
}
|
|
26
19
|
};
|
|
20
|
+
|
|
27
21
|
/**
|
|
28
22
|
* This currently will not work for collections or containers.
|
|
29
23
|
* If support is required it will need to be added.
|
|
30
24
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
25
|
var setupDefaultValue = function setupDefaultValue(component, data) {
|
|
34
26
|
if (component.defaultValue && !data[component.fieldId]) {
|
|
35
27
|
switch (component.type) {
|
|
36
28
|
case 'date':
|
|
37
29
|
setDefaultDateValue(component, data);
|
|
38
30
|
break;
|
|
39
|
-
|
|
40
31
|
default:
|
|
41
32
|
data[component.fieldId] = component.defaultValue;
|
|
42
33
|
}
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
if (component.defaultValue) {
|
|
46
36
|
// Some components will throw warnings when having
|
|
47
37
|
// both a 'value' and 'defaultValue' prop set.
|
|
@@ -50,13 +40,11 @@ var setupDefaultValue = function setupDefaultValue(component, data) {
|
|
|
50
40
|
delete component.defaultValue;
|
|
51
41
|
}
|
|
52
42
|
};
|
|
53
|
-
|
|
54
43
|
var setupDefaultValuesForComponents = function setupDefaultValuesForComponents(components, data) {
|
|
55
44
|
components.forEach(function (component) {
|
|
56
45
|
return setupDefaultValue(component, data);
|
|
57
46
|
});
|
|
58
47
|
};
|
|
59
|
-
|
|
60
48
|
var setupPageDefaultValues = function setupPageDefaultValues(pages, data) {
|
|
61
49
|
pages.forEach(function (page) {
|
|
62
50
|
page.components.filter(function (c) {
|
|
@@ -66,19 +54,16 @@ var setupPageDefaultValues = function setupPageDefaultValues(pages, data) {
|
|
|
66
54
|
});
|
|
67
55
|
});
|
|
68
56
|
};
|
|
69
|
-
|
|
70
57
|
var setupComponentSourceData = function setupComponentSourceData(component, data) {
|
|
71
58
|
if (component.source) {
|
|
72
59
|
data[component.fieldId] = (0, _getSourceData.default)(data, component.source.field);
|
|
73
60
|
}
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
var setupSourceDataForComponents = function setupSourceDataForComponents(components, data) {
|
|
77
63
|
components.forEach(function (component) {
|
|
78
64
|
return setupComponentSourceData(component, data);
|
|
79
65
|
});
|
|
80
66
|
};
|
|
81
|
-
|
|
82
67
|
var setupPageSourceData = function setupPageSourceData(pages, data) {
|
|
83
68
|
pages.forEach(function (page) {
|
|
84
69
|
page.components.filter(function (c) {
|
|
@@ -88,6 +73,7 @@ var setupPageSourceData = function setupPageSourceData(pages, data) {
|
|
|
88
73
|
});
|
|
89
74
|
});
|
|
90
75
|
};
|
|
76
|
+
|
|
91
77
|
/**
|
|
92
78
|
* This populates an object with data either from a specified default
|
|
93
79
|
* value or from a source field. If both are specified, data from a
|
|
@@ -104,17 +90,13 @@ var setupPageSourceData = function setupPageSourceData(pages, data) {
|
|
|
104
90
|
* @param {object} baseData
|
|
105
91
|
* @returns
|
|
106
92
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
93
|
var setupFormData = function setupFormData(pages, components, baseData) {
|
|
110
94
|
var data = _objectSpread({}, baseData);
|
|
111
|
-
|
|
112
95
|
setupDefaultValuesForComponents(components, data);
|
|
113
96
|
setupPageDefaultValues(pages, data);
|
|
114
97
|
setupSourceDataForComponents(components, data);
|
|
115
98
|
setupPageSourceData(pages, data);
|
|
116
99
|
return data;
|
|
117
100
|
};
|
|
118
|
-
|
|
119
101
|
var _default = setupFormData;
|
|
120
102
|
exports.default = _default;
|
|
@@ -4,49 +4,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
12
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; }
|
|
13
|
-
|
|
14
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; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
var setupRefDataForContainer = function setupRefDataForContainer(container, data) {
|
|
19
13
|
return _objectSpread(_objectSpread({}, container), {}, {
|
|
20
14
|
components: setupRefDataUrlForComponents(container.components, data)
|
|
21
15
|
});
|
|
22
16
|
};
|
|
23
|
-
|
|
24
17
|
var setupRefDataForCollection = function setupRefDataForCollection(collection, data) {
|
|
25
18
|
return _objectSpread(_objectSpread({}, collection), {}, {
|
|
26
19
|
item: setupRefDataUrlForComponents(collection.item, data)
|
|
27
20
|
});
|
|
28
21
|
};
|
|
29
|
-
|
|
30
22
|
var setupRefDataUrlForComponents = function setupRefDataUrlForComponents(components, data) {
|
|
31
23
|
return components.map(function (component) {
|
|
32
24
|
return setupRefDataUrlForComponent(component, data);
|
|
33
25
|
});
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
var setupRefDataUrlForComponent = function setupRefDataUrlForComponent(component, data) {
|
|
37
28
|
if (component) {
|
|
38
29
|
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
39
30
|
return setupRefDataForContainer(component, data);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
if (component.type === _models.ComponentTypes.COLLECTION) {
|
|
43
33
|
return setupRefDataForCollection(component, data);
|
|
44
34
|
}
|
|
45
|
-
|
|
46
35
|
if (component.type === _models.ComponentTypes.SELECT) {
|
|
47
36
|
return component;
|
|
48
37
|
}
|
|
49
|
-
|
|
50
38
|
if (component.data && component.data.url) {
|
|
51
39
|
return _objectSpread(_objectSpread({}, component), {}, {
|
|
52
40
|
data: _objectSpread(_objectSpread({}, component.data), {}, {
|
|
@@ -55,9 +43,7 @@ var setupRefDataUrlForComponent = function setupRefDataUrlForComponent(component
|
|
|
55
43
|
});
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
|
-
|
|
59
46
|
return component;
|
|
60
47
|
};
|
|
61
|
-
|
|
62
48
|
var _default = setupRefDataUrlForComponent;
|
|
63
49
|
exports.default = _default;
|
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _Container = _interopRequireDefault(require("../Container"));
|
|
9
|
-
|
|
10
8
|
var _Data = _interopRequireDefault(require("../Data"));
|
|
11
|
-
|
|
12
9
|
var _getPageActions = _interopRequireDefault(require("./getPageActions"));
|
|
13
|
-
|
|
14
10
|
var _getParagraphFromText = _interopRequireDefault(require("./getParagraphFromText"));
|
|
15
|
-
|
|
16
11
|
var _useComponent = _interopRequireDefault(require("./useComponent"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
* Converts a page object defined in the JSON to a page object for rendering.
|
|
28
18
|
* @param {object} pageOptions The JSON page.
|
|
@@ -34,20 +24,16 @@ var getFormPage = function getFormPage(pageOptions, formComponents, formData) {
|
|
|
34
24
|
if (!pageOptions) {
|
|
35
25
|
return null;
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
var components = pageOptions.components.map(function (componentOptions) {
|
|
39
28
|
if (typeof componentOptions === 'string') {
|
|
40
29
|
return (0, _getParagraphFromText.default)(componentOptions);
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
var ret = undefined;
|
|
44
|
-
|
|
45
32
|
if (componentOptions.use) {
|
|
46
33
|
ret = (0, _useComponent.default)(componentOptions, formComponents);
|
|
47
34
|
} else {
|
|
48
35
|
ret = _objectSpread({}, componentOptions);
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
return formData ? _Data.default.refData.setupUrl(ret, formData) : ret;
|
|
52
38
|
});
|
|
53
39
|
var actions = (0, _getPageActions.default)(pageOptions);
|
|
@@ -57,6 +43,5 @@ var getFormPage = function getFormPage(pageOptions, formComponents, formData) {
|
|
|
57
43
|
actions: actions
|
|
58
44
|
}));
|
|
59
45
|
};
|
|
60
|
-
|
|
61
46
|
var _default = getFormPage;
|
|
62
47
|
exports.default = _default;
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getFormPage = _interopRequireDefault(require("./getFormPage"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
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; }
|
|
13
|
-
|
|
14
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; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* Converts pages objects defined in the JSON to page objects for rendering.
|
|
20
14
|
* @param {Array} pages The JSON pages.
|
|
@@ -30,9 +24,7 @@ var getFormPages = function getFormPages(pages, components, formData) {
|
|
|
30
24
|
});
|
|
31
25
|
});
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
return [];
|
|
35
28
|
};
|
|
36
|
-
|
|
37
29
|
var _default = getFormPages;
|
|
38
30
|
exports.default = _default;
|
|
@@ -4,21 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
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); }
|
|
11
|
-
|
|
12
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; }
|
|
13
|
-
|
|
14
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; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
var standardiseAction = function standardiseAction(obj) {
|
|
19
|
-
var action = _objectSpread({}, obj);
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
var action = _objectSpread({}, obj);
|
|
14
|
+
// This is in place for backwards compatibility with version 1.
|
|
22
15
|
if (!action.page) {
|
|
23
16
|
if (action.href) {
|
|
24
17
|
action.page = action.href.split('/').pop();
|
|
@@ -26,9 +19,9 @@ var standardiseAction = function standardiseAction(obj) {
|
|
|
26
19
|
action.page = action.url.split('/').pop();
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
return action;
|
|
31
23
|
};
|
|
24
|
+
|
|
32
25
|
/**
|
|
33
26
|
* Gets an array of standardised action objects for a page.
|
|
34
27
|
* @param {object} page The page to get the actions for.
|
|
@@ -40,33 +33,25 @@ var standardiseAction = function standardiseAction(obj) {
|
|
|
40
33
|
* will convert both by taking the final part of the relative path:
|
|
41
34
|
* - `href: '/bravo'` => `page: 'bravo'`
|
|
42
35
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
36
|
var getPageActions = function getPageActions(page) {
|
|
46
37
|
if (page && Array.isArray(page.actions)) {
|
|
47
38
|
return page.actions.map(function (a) {
|
|
48
39
|
if (typeof a === 'string') {
|
|
49
40
|
return _models.PageAction.DEFAULTS[a];
|
|
50
41
|
}
|
|
51
|
-
|
|
52
42
|
if (a && _typeof(a) === 'object') {
|
|
53
43
|
var _PageAction$DEFAULTS$;
|
|
54
|
-
|
|
55
44
|
if ((_PageAction$DEFAULTS$ = _models.PageAction.DEFAULTS[a.type]) !== null && _PageAction$DEFAULTS$ !== void 0 && _PageAction$DEFAULTS$.validate) {
|
|
56
45
|
a.validate = true;
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
return standardiseAction(a);
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
return undefined;
|
|
63
50
|
}).filter(function (a) {
|
|
64
51
|
return !!a;
|
|
65
52
|
});
|
|
66
53
|
}
|
|
67
|
-
|
|
68
54
|
return undefined;
|
|
69
55
|
};
|
|
70
|
-
|
|
71
56
|
var _default = getPageActions;
|
|
72
57
|
exports.default = _default;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
8
|
// Local imports
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -21,6 +19,5 @@ var getParagraphFromText = function getParagraphFromText(content) {
|
|
|
21
19
|
content: content
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
var _default = getParagraphFromText;
|
|
26
23
|
exports.default = _default;
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getFormPage = _interopRequireDefault(require("./getFormPage"));
|
|
9
|
-
|
|
10
8
|
var _getFormPages = _interopRequireDefault(require("./getFormPages"));
|
|
11
|
-
|
|
12
9
|
var _showFormPage = _interopRequireDefault(require("./showFormPage"));
|
|
13
|
-
|
|
14
10
|
var _showFormPageCYA = _interopRequireDefault(require("./showFormPageCYA"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
var FormPage = {
|
|
19
13
|
get: _getFormPage.default,
|
|
20
14
|
getAll: _getFormPages.default,
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _Component = _interopRequireDefault(require("../Component"));
|
|
9
|
-
|
|
10
8
|
var _Condition = _interopRequireDefault(require("../Condition"));
|
|
11
|
-
|
|
12
9
|
var _Container = _interopRequireDefault(require("../Container"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
// Local imports
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -26,40 +21,36 @@ var showEditableComponent = function showEditableComponent(editableComponents, d
|
|
|
26
21
|
return _Component.default.show(component, data);
|
|
27
22
|
});
|
|
28
23
|
};
|
|
24
|
+
|
|
29
25
|
/**
|
|
30
26
|
* Indicates whether or not a page should be shown.
|
|
31
27
|
* @param {object} page The page to consider.
|
|
32
28
|
* @param {object} data The top-level form data.
|
|
33
29
|
* @returns Boolean true if the page should be shown; false if not.
|
|
34
30
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
31
|
var showFormPage = function showFormPage(page, data) {
|
|
38
32
|
if (!page) {
|
|
39
33
|
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
34
|
+
}
|
|
42
35
|
|
|
36
|
+
// If the page has a show_when condition, we should evaluate that.
|
|
43
37
|
if (page.show_when) {
|
|
44
38
|
if (page.show_when.type === "or") {
|
|
45
39
|
return _Condition.default.meetsOne(page, data);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
return _Condition.default.meetsAll(page, data);
|
|
49
|
-
}
|
|
50
|
-
// contains ANY editable components, at least one of them is shown.
|
|
51
|
-
|
|
42
|
+
}
|
|
52
43
|
|
|
44
|
+
// If the page itself doesn't have a show_when, we need to make sure that if it
|
|
45
|
+
// contains ANY editable components, at least one of them is shown.
|
|
53
46
|
var editableComponents = _Container.default.editableComponents(page);
|
|
54
|
-
|
|
55
47
|
if (editableComponents.length > 0) {
|
|
56
48
|
return showEditableComponent(editableComponents, data);
|
|
57
|
-
}
|
|
58
|
-
// the page has no editable components. In either case, it should be shown.
|
|
59
|
-
|
|
49
|
+
}
|
|
60
50
|
|
|
51
|
+
// At this point, either the page has no show_when condition of its own, or
|
|
52
|
+
// the page has no editable components. In either case, it should be shown.
|
|
61
53
|
return true;
|
|
62
54
|
};
|
|
63
|
-
|
|
64
55
|
var _default = showFormPage;
|
|
65
56
|
exports.default = _default;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _showFormPage = _interopRequireDefault(require("./showFormPage"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Indicates whether or not a page should be shown on the CYA screen.
|
|
14
11
|
* @param {object} page The page to consider.
|
|
@@ -19,9 +16,7 @@ var showFormPageCYA = function showFormPageCYA(page, data) {
|
|
|
19
16
|
if (page !== null && page !== void 0 && page.hasOwnProperty('show_on_cya') && !page.show_on_cya) {
|
|
20
17
|
return false;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
return (0, _showFormPage.default)(page, data);
|
|
24
20
|
};
|
|
25
|
-
|
|
26
21
|
var _default = showFormPageCYA;
|
|
27
22
|
exports.default = _default;
|
|
@@ -4,33 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
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; }
|
|
9
|
-
|
|
10
8
|
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; }
|
|
11
|
-
|
|
12
9
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
|
|
14
10
|
var getComponentToUse = function getComponentToUse(toUse, formComponents) {
|
|
15
11
|
var path = toUse.use.split('.');
|
|
16
12
|
var firstId = path.shift();
|
|
17
|
-
|
|
18
13
|
var wrapper = _objectSpread({}, formComponents.find(function (fc) {
|
|
19
14
|
return fc.id === firstId;
|
|
20
15
|
}));
|
|
21
|
-
|
|
22
16
|
var parent = wrapper;
|
|
23
|
-
|
|
24
17
|
var _loop = function _loop() {
|
|
25
18
|
var id = path.shift();
|
|
26
|
-
|
|
27
19
|
if (Array.isArray(parent.components)) {
|
|
28
20
|
// Filter the parent components down to just the one referenced
|
|
29
21
|
// by the current id.
|
|
30
22
|
parent.components = parent.components.filter(function (c) {
|
|
31
23
|
return c.id === id;
|
|
32
24
|
});
|
|
33
|
-
|
|
34
25
|
if (parent.components.length > 0) {
|
|
35
26
|
// Make the found child the parent so we can iterate.
|
|
36
27
|
parent = parent.components[0];
|
|
@@ -44,14 +35,13 @@ var getComponentToUse = function getComponentToUse(toUse, formComponents) {
|
|
|
44
35
|
parent = undefined;
|
|
45
36
|
}
|
|
46
37
|
};
|
|
47
|
-
|
|
48
38
|
while (parent && path.length > 0) {
|
|
49
39
|
_loop();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
}
|
|
41
|
+
// If we missed a nested reference along the way, don't return the wrapper.
|
|
53
42
|
return parent ? wrapper : undefined;
|
|
54
43
|
};
|
|
44
|
+
|
|
55
45
|
/**
|
|
56
46
|
* Use an existing component from the formComponents, overriding any properties
|
|
57
47
|
* where appropriate.
|
|
@@ -59,12 +49,9 @@ var getComponentToUse = function getComponentToUse(toUse, formComponents) {
|
|
|
59
49
|
* @param {Array} formComponents An array of existing components on the form.
|
|
60
50
|
* @returns A component configuration object.
|
|
61
51
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
52
|
var useComponent = function useComponent(toUse, formComponents) {
|
|
65
53
|
if (toUse) {
|
|
66
54
|
var component = getComponentToUse(toUse, formComponents);
|
|
67
|
-
|
|
68
55
|
if (component) {
|
|
69
56
|
var fieldId = toUse.fieldId || component.fieldId;
|
|
70
57
|
return _objectSpread(_objectSpread(_objectSpread({}, component), toUse), {}, {
|
|
@@ -73,9 +60,7 @@ var useComponent = function useComponent(toUse, formComponents) {
|
|
|
73
60
|
});
|
|
74
61
|
}
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
return _objectSpread({}, toUse);
|
|
78
64
|
};
|
|
79
|
-
|
|
80
65
|
var _default = useComponent;
|
|
81
66
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Formats a string according to a format configuration object.
|
|
10
9
|
* @param {object} format The format configuration object.
|
|
@@ -16,17 +15,13 @@ var formatData = function formatData(format, value) {
|
|
|
16
15
|
switch (format.type) {
|
|
17
16
|
case 'lowercase':
|
|
18
17
|
return value.toLowerCase();
|
|
19
|
-
|
|
20
18
|
case 'uppercase':
|
|
21
19
|
return value.toUpperCase();
|
|
22
|
-
|
|
23
20
|
default:
|
|
24
21
|
return value;
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return value;
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
var _default = formatData;
|
|
32
27
|
exports.default = _default;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatDataForComponents = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _formatData = _interopRequireDefault(require("./formatData"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
// Local imports
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -22,20 +19,18 @@ var formatDataForComponent = function formatDataForComponent(component, data, ev
|
|
|
22
19
|
data[component.fieldId] = (0, _formatData.default)(component.format, data[component.fieldId]);
|
|
23
20
|
}
|
|
24
21
|
};
|
|
22
|
+
|
|
25
23
|
/**
|
|
26
24
|
* Formats the data for an array of components, according to each component's format configuration.
|
|
27
25
|
* @param {Array} components The array of components to format.
|
|
28
26
|
* @param {object} data The top-level form data.
|
|
29
27
|
* @param {string} eventType What type of event initiated this call.
|
|
30
28
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
29
|
var formatDataForComponents = function formatDataForComponents(components, data, eventType) {
|
|
34
30
|
components.forEach(function (component) {
|
|
35
31
|
return formatDataForComponent(component, data, eventType);
|
|
36
32
|
});
|
|
37
33
|
};
|
|
38
|
-
|
|
39
34
|
exports.formatDataForComponents = formatDataForComponents;
|
|
40
35
|
var _default = formatDataForComponent;
|
|
41
36
|
exports.default = _default;
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _formatDataForComponent = require("./formatDataForComponent");
|
|
9
|
-
|
|
10
8
|
var _formatDataForPage = require("./formatDataForPage");
|
|
11
|
-
|
|
12
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; }
|
|
13
|
-
|
|
14
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; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* Formats the data for all components on a form, according to each component's format configuration.
|
|
20
14
|
* @param {object} form The form to format the components for.
|
|
@@ -23,11 +17,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
23
17
|
*/
|
|
24
18
|
var formatDataForForm = function formatDataForForm(form, baseData, eventType) {
|
|
25
19
|
var data = _objectSpread({}, baseData);
|
|
26
|
-
|
|
27
20
|
(0, _formatDataForComponent.formatDataForComponents)(form.components, data, eventType);
|
|
28
21
|
(0, _formatDataForPage.formatDataForPages)(form.pages, data, eventType);
|
|
29
22
|
return data;
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
var _default = formatDataForForm;
|
|
33
25
|
exports.default = _default;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatDataForPages = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _formatDataForComponent = require("./formatDataForComponent");
|
|
9
|
-
|
|
10
8
|
// Local imports
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -18,20 +16,18 @@ var _formatDataForComponent = require("./formatDataForComponent");
|
|
|
18
16
|
var formatDataForPage = function formatDataForPage(page, data, eventType) {
|
|
19
17
|
(0, _formatDataForComponent.formatDataForComponents)(page.components, data, eventType);
|
|
20
18
|
};
|
|
19
|
+
|
|
21
20
|
/**
|
|
22
21
|
* Formats the data for all components on a page, according to each component's format configuration.
|
|
23
22
|
* @param {Array} pages The pages to format the components for.
|
|
24
23
|
* @param {object} data The top-level form data.
|
|
25
24
|
* @param {string} eventType What type of event initiated this call.
|
|
26
25
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
26
|
var formatDataForPages = function formatDataForPages(pages, data, eventType) {
|
|
30
27
|
pages.forEach(function (page) {
|
|
31
28
|
return formatDataForPage(page, data, eventType);
|
|
32
29
|
});
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
exports.formatDataForPages = formatDataForPages;
|
|
36
32
|
var _default = formatDataForPage;
|
|
37
33
|
exports.default = _default;
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _formatData = _interopRequireDefault(require("./formatData"));
|
|
9
|
-
|
|
10
8
|
var _formatDataForComponent = _interopRequireDefault(require("./formatDataForComponent"));
|
|
11
|
-
|
|
12
9
|
var _formatDataForForm = _interopRequireDefault(require("./formatDataForForm"));
|
|
13
|
-
|
|
14
10
|
var _formatDataForPage = _interopRequireDefault(require("./formatDataForPage"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
// Local imports
|
|
13
|
+
|
|
19
14
|
var Format = {
|
|
20
15
|
component: _formatDataForComponent.default,
|
|
21
16
|
data: _formatData.default,
|