@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +18 -7
  2. package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
  6. package/dist/components/CollectionPage/CollectionPage.js +15 -10
  7. package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
  8. package/dist/components/FormComponent/Collection.js +91 -48
  9. package/dist/components/FormComponent/Collection.scss +2 -1
  10. package/dist/components/FormComponent/Collection.test.js +807 -0
  11. package/dist/components/FormComponent/Container.js +35 -16
  12. package/dist/components/FormComponent/Container.test.js +370 -0
  13. package/dist/components/FormComponent/FormComponent.js +39 -13
  14. package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
  15. package/dist/components/FormComponent/FormComponent.test.js +226 -0
  16. package/dist/components/FormComponent/helpers/addLabel.js +5 -4
  17. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
  18. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
  19. package/dist/components/FormComponent/helpers/index.js +8 -1
  20. package/dist/components/FormPage/FormPage.js +69 -30
  21. package/dist/components/FormPage/FormPage.stories.mdx +155 -0
  22. package/dist/components/FormPage/FormPage.test.js +330 -0
  23. package/dist/components/FormRenderer/FormRenderer.js +142 -228
  24. package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
  25. package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
  26. package/dist/components/FormRenderer/handlers/index.js +1 -2
  27. package/dist/components/FormRenderer/handlers/navigate.js +3 -1
  28. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
  29. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
  30. package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
  31. package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
  32. package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
  33. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
  34. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
  35. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
  36. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
  37. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
  38. package/dist/components/FormRenderer/helpers/index.js +1 -2
  39. package/dist/components/FormRenderer/onCYAAction.js +108 -0
  40. package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
  41. package/dist/components/FormRenderer/onPageAction.js +145 -0
  42. package/dist/components/FormRenderer/onPageAction.test.js +678 -0
  43. package/dist/components/FormRenderer/onTaskAction.js +48 -0
  44. package/dist/components/FormRenderer/onTaskAction.test.js +217 -0
  45. package/dist/components/PageActions/ActionButton.js +0 -3
  46. package/dist/components/PageActions/ActionButton.test.js +93 -0
  47. package/dist/components/PageActions/PageActions.js +2 -2
  48. package/dist/components/PageActions/PageActions.stories.mdx +74 -0
  49. package/dist/components/PageActions/PageActions.test.js +132 -0
  50. package/dist/components/SummaryList/GroupAction.js +2 -2
  51. package/dist/components/SummaryList/GroupAction.test.js +80 -0
  52. package/dist/components/SummaryList/RowAction.js +2 -2
  53. package/dist/components/SummaryList/RowAction.test.js +80 -0
  54. package/dist/components/SummaryList/SummaryList.js +29 -12
  55. package/dist/components/SummaryList/SummaryList.scss +19 -0
  56. package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
  57. package/dist/components/SummaryList/SummaryList.test.js +400 -0
  58. package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
  59. package/dist/components/SummaryList/SummaryListRow.js +5 -2
  60. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
  61. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
  62. package/dist/components/TaskList/Task.js +3 -3
  63. package/dist/components/TaskList/Task.test.js +167 -0
  64. package/dist/components/TaskList/TaskList.js +73 -22
  65. package/dist/components/TaskList/TaskList.stories.mdx +164 -0
  66. package/dist/components/TaskList/TaskList.test.js +389 -0
  67. package/dist/components/TaskList/TaskState.js +2 -2
  68. package/dist/components/TaskList/TaskState.test.js +86 -0
  69. package/dist/components/index.js +14 -0
  70. package/dist/context/HooksContext/HooksContext.js +72 -8
  71. package/dist/context/HooksContext/HooksContext.test.js +44 -0
  72. package/dist/context/ValidationContext/ValidationContext.js +38 -28
  73. package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
  74. package/dist/hooks/useAxios.js +10 -12
  75. package/dist/hooks/useGetRequest.js +48 -49
  76. package/dist/hooks/useRefData.js +7 -4
  77. package/dist/index.js +34 -1
  78. package/dist/json/addressDetails.json +149 -0
  79. package/dist/json/areYouACivilServant.json +7 -0
  80. package/dist/json/firstForm.json +94 -0
  81. package/dist/json/grade.json +108 -0
  82. package/dist/json/group.data.json +21 -0
  83. package/dist/json/group.json +402 -0
  84. package/dist/json/groupOfRow.json +137 -0
  85. package/dist/json/groupOfRowData.json +15 -0
  86. package/dist/json/port.json +346 -0
  87. package/dist/json/saveAndContinue.json +98 -0
  88. package/dist/json/sublocation.json +859 -0
  89. package/dist/json/taskList.json +265 -0
  90. package/dist/json/team.json +17351 -0
  91. package/dist/json/terminal.json +81 -0
  92. package/dist/json/userProfile.data.json +21 -0
  93. package/dist/json/userProfile.json +276 -0
  94. package/dist/models/ComponentTypes.js +8 -0
  95. package/dist/models/PageAction.js +4 -1
  96. package/dist/models/TaskStates.js +10 -2
  97. package/dist/models/index.js +16 -1
  98. package/dist/setupTests.js +46 -0
  99. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  100. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
  101. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
  102. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
  103. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
  104. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
  105. package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
  106. package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
  107. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
  108. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
  109. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
  110. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
  111. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
  112. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
  113. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
  114. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
  115. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
  116. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
  117. package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
  118. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
  119. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
  120. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
  121. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
  122. package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
  123. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
  124. package/dist/utils/Component/addShowWhen.js +44 -0
  125. package/dist/utils/Component/addShowWhen.test.js +216 -0
  126. package/dist/utils/Component/applyToComponentTree.js +71 -0
  127. package/dist/utils/Component/applyToComponentTree.test.js +127 -0
  128. package/dist/utils/Component/cleanAttributes.js +8 -2
  129. package/dist/utils/Component/cleanAttributes.test.js +68 -0
  130. package/dist/utils/Component/elevateNestedComponents.js +4 -1
  131. package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
  132. package/dist/utils/Component/getComponent.js +80 -11
  133. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
  134. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
  135. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
  136. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
  137. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
  138. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
  139. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
  140. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
  141. package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
  142. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
  143. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
  144. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
  145. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
  146. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
  147. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
  148. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
  149. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
  150. package/dist/utils/Component/getDefaultValue.js +4 -1
  151. package/dist/utils/Component/getDefaultValue.test.js +50 -0
  152. package/dist/utils/Component/index.js +2 -0
  153. package/dist/utils/Component/isEditable.js +2 -2
  154. package/dist/utils/Component/isEditable.test.js +43 -0
  155. package/dist/utils/Component/optionIsSelected.js +22 -0
  156. package/dist/utils/Component/optionIsSelected.test.js +42 -0
  157. package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
  158. package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
  159. package/dist/utils/Component/showComponent.test.js +156 -0
  160. package/dist/utils/Component/wrapInFormGroup.js +1 -1
  161. package/dist/utils/Condition/meetsAllConditions.js +1 -1
  162. package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
  163. package/dist/utils/Condition/meetsCondition.js +74 -4
  164. package/dist/utils/Condition/meetsCondition.test.js +763 -0
  165. package/dist/utils/Condition/meetsOneCondition.js +1 -1
  166. package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
  167. package/dist/utils/Condition/setupConditions.js +6 -3
  168. package/dist/utils/Condition/setupConditions.test.js +33 -0
  169. package/dist/utils/Container/getEditableComponents.test.js +135 -0
  170. package/dist/utils/Container/setupNesting.js +21 -2
  171. package/dist/utils/Container/setupNesting.test.js +145 -0
  172. package/dist/utils/Container/showContainer.test.js +178 -0
  173. package/dist/utils/Data/applyFormula.js +20 -11
  174. package/dist/utils/Data/applyFormula.test.js +263 -0
  175. package/dist/utils/Data/getAutocompleteSource.js +6 -2
  176. package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
  177. package/dist/utils/Data/getDataPath.test.js +48 -0
  178. package/dist/utils/Data/getOptions.js +17 -3
  179. package/dist/utils/Data/getOptions.test.js +140 -0
  180. package/dist/utils/Data/getSourceData.js +2 -2
  181. package/dist/utils/Data/getSourceData.test.js +153 -0
  182. package/dist/utils/Data/refDataToOptions.js +4 -1
  183. package/dist/utils/Data/refDataToOptions.test.js +196 -0
  184. package/dist/utils/Data/setDataItem.test.js +110 -0
  185. package/dist/utils/Data/setupFormData.js +39 -16
  186. package/dist/utils/Data/setupFormData.test.js +410 -0
  187. package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
  188. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
  189. package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
  190. package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
  191. package/dist/utils/FormPage/getFormPage.js +5 -2
  192. package/dist/utils/FormPage/getFormPage.test.js +206 -0
  193. package/dist/utils/FormPage/getFormPages.js +4 -1
  194. package/dist/utils/FormPage/getFormPages.test.js +97 -0
  195. package/dist/utils/FormPage/getPageActions.js +8 -4
  196. package/dist/utils/FormPage/getPageActions.test.js +114 -0
  197. package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
  198. package/dist/utils/FormPage/index.js +2 -0
  199. package/dist/utils/FormPage/showFormPage.js +2 -2
  200. package/dist/utils/FormPage/showFormPage.test.js +180 -0
  201. package/dist/utils/FormPage/showFormPageCYA.js +1 -0
  202. package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
  203. package/dist/utils/FormPage/useComponent.js +29 -14
  204. package/dist/utils/FormPage/useComponent.test.js +167 -0
  205. package/dist/utils/Format/formatData.test.js +45 -0
  206. package/dist/utils/Format/formatDataForComponent.js +2 -1
  207. package/dist/utils/Format/formatDataForComponent.test.js +142 -0
  208. package/dist/utils/Format/formatDataForForm.js +4 -1
  209. package/dist/utils/Format/formatDataForForm.test.js +81 -0
  210. package/dist/utils/Format/formatDataForPage.test.js +99 -0
  211. package/dist/utils/Hub/getFormHub.test.js +105 -0
  212. package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
  213. package/dist/utils/Meta/documents/index.js +2 -2
  214. package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
  215. package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
  216. package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
  217. package/dist/utils/Operate/getFirstOf.js +31 -0
  218. package/dist/utils/Operate/getFirstOf.test.js +86 -0
  219. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
  220. package/dist/utils/Operate/persistValueInFormData.js +2 -1
  221. package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
  222. package/dist/utils/Operate/runPageOperations.js +3 -1
  223. package/dist/utils/Operate/runPageOperations.test.js +105 -0
  224. package/dist/utils/Operate/setValueInFormData.test.js +44 -0
  225. package/dist/utils/Operate/shouldRun.js +16 -13
  226. package/dist/utils/Operate/shouldRun.test.js +66 -0
  227. package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
  228. package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
  229. package/dist/utils/Validate/additional/index.js +13 -4
  230. package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
  231. package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
  232. package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
  233. package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
  234. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
  235. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
  236. package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
  237. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
  238. package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
  239. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
  240. package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
  241. package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
  242. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
  243. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
  244. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
  245. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
  246. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
  247. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
  248. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
  249. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
  250. package/dist/utils/Validate/additional/utils.js +18 -18
  251. package/dist/utils/Validate/index.js +6 -0
  252. package/dist/utils/Validate/validateCollection.js +20 -5
  253. package/dist/utils/Validate/validateCollection.test.js +125 -0
  254. package/dist/utils/Validate/validateComponent.js +36 -20
  255. package/dist/utils/Validate/validateComponent.test.js +365 -0
  256. package/dist/utils/Validate/validateContainer.js +9 -3
  257. package/dist/utils/Validate/validateContainer.test.js +75 -0
  258. package/dist/utils/Validate/validateDate.js +4 -3
  259. package/dist/utils/Validate/validateDate.test.js +114 -0
  260. package/dist/utils/Validate/validateEmail.js +14 -1
  261. package/dist/utils/Validate/validateEmail.test.js +74 -0
  262. package/dist/utils/Validate/validateMultifile.js +32 -0
  263. package/dist/utils/Validate/validateMultifile.test.js +47 -0
  264. package/dist/utils/Validate/validatePage.js +12 -6
  265. package/dist/utils/Validate/validatePage.test.js +472 -0
  266. package/dist/utils/Validate/validateRegex.js +2 -5
  267. package/dist/utils/Validate/validateRegex.test.js +42 -0
  268. package/dist/utils/Validate/validateRequired.js +2 -4
  269. package/dist/utils/Validate/validateRequired.test.js +63 -0
  270. package/dist/utils/Validate/validateTextArea.js +37 -0
  271. package/dist/utils/Validate/validateTextArea.test.js +42 -0
  272. package/dist/utils/Validate/validateTime.js +2 -2
  273. package/dist/utils/Validate/validateTime.test.js +59 -0
  274. package/dist/utils/index.js +4 -1
  275. package/package.json +35 -50
  276. package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
  277. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _checkValueIsTruthy = _interopRequireDefault(require("./checkValueIsTruthy"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Operate.checkValueIsTruthy', function () {
6
+ var DATA = {
7
+ alpha: 'abc',
8
+ bravo: ''
9
+ };
10
+ it('Should return true is the value of the field is truthy', function () {
11
+ var CONFIG = {
12
+ field: 'alpha'
13
+ };
14
+ var result = (0, _checkValueIsTruthy.default)(CONFIG, DATA);
15
+ expect(result).toEqual(true);
16
+ });
17
+ it('Should return false if the value of the field is falsy', function () {
18
+ var CONFIG = {
19
+ field: 'bravo'
20
+ };
21
+ var result = (0, _checkValueIsTruthy.default)(CONFIG, DATA);
22
+ expect(result).toEqual(false);
23
+ });
24
+ it('Should return false if the field does not exist', function () {
25
+ var CONFIG = {
26
+ field: 'charlie'
27
+ };
28
+ var result = (0, _checkValueIsTruthy.default)(CONFIG, DATA);
29
+ expect(result).toEqual(false);
30
+ });
31
+ it('Should return false when an invalid config is used', function () {
32
+ var result = (0, _checkValueIsTruthy.default)(null, DATA);
33
+ expect(result).toEqual(false);
34
+ });
35
+ it('Should return false when invalid data is used', function () {
36
+ var CONFIG = {
37
+ field: 'alpha'
38
+ };
39
+ var result = (0, _checkValueIsTruthy.default)(CONFIG, null);
40
+ expect(result).toEqual(false);
41
+ });
42
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
+ var _getSourceData = _interopRequireDefault(require("../Data/getSourceData"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ // Global imports.
11
+
12
+ // Local imports.
13
+
14
+ var getFirstOf = function getFirstOf(config, data) {
15
+ if (config !== null && config !== void 0 && config.fields) {
16
+ var fieldValue;
17
+ config.fields.find(function (field) {
18
+ var fieldPath = _copReactComponents.Utils.interpolateString(field, data);
19
+ var foundValue = (0, _getSourceData.default)(data, fieldPath);
20
+ if (foundValue) {
21
+ fieldValue = foundValue;
22
+ return true;
23
+ }
24
+ return false;
25
+ });
26
+ return fieldValue || (config.fallback ? _copReactComponents.Utils.interpolateString(config.fallback, data) : '');
27
+ }
28
+ return (config === null || config === void 0 ? void 0 : config.value) || null;
29
+ };
30
+ var _default = getFirstOf;
31
+ exports.default = _default;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var _getFirstOf = _interopRequireDefault(require("./getFirstOf"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Operate.getFirstOf', function () {
6
+ var DATA = {
7
+ name: 'sam',
8
+ id: 1,
9
+ test: ['2', '3'],
10
+ idName: 'passport',
11
+ passportNumber: 123,
12
+ otherIdDoc: '',
13
+ anotherMadeUpId: 789
14
+ };
15
+ it('Should handle interpolated field strings', function () {
16
+ // eslint-disable-next-line no-template-curly-in-string
17
+ var CONFIG = {
18
+ fields: ['test[${id}]']
19
+ };
20
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
21
+ expect(result).toEqual(DATA.test[1]);
22
+ });
23
+ it('Should return the value provided in config if no field is specified', function () {
24
+ var CONFIG = {
25
+ value: '2'
26
+ };
27
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
28
+ expect(result).toEqual(CONFIG.value);
29
+ });
30
+ it('Should return the fallback if the requested fields are not found', function () {
31
+ // eslint-disable-next-line no-template-curly-in-string
32
+ var CONFIG = {
33
+ value: '2',
34
+ fields: ['nonExistent'],
35
+ fallback: "Test ${name}"
36
+ };
37
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
38
+ expect(result).toEqual("Test ".concat(DATA.name));
39
+ });
40
+ it('Should return the value of the passportNumber field given in config', function () {
41
+ var CONFIG = {
42
+ fields: ['passportNumber', 'anotherMadeUpId', 'otherIdDoc']
43
+ };
44
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
45
+ expect(result).toEqual(DATA.passportNumber);
46
+ });
47
+ it('Should return the value of the anotherMadeUpId field given in config', function () {
48
+ var CONFIG = {
49
+ fields: ['anotherMadeUpId', 'passportNumber', 'otherIdDoc']
50
+ };
51
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
52
+ expect(result).toEqual(DATA.anotherMadeUpId);
53
+ });
54
+ it('Should return the value of the otherIdDoc field given in config', function () {
55
+ var CONFIG = {
56
+ fields: ['otherIdDoc', 'passportNumber', 'anotherMadeUpId']
57
+ };
58
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
59
+ expect(result).toEqual(DATA.passportNumber);
60
+ });
61
+ it('Should return the value of the otherIdDoc field given in config, if it exists, otherwise next field next in the array', function () {
62
+ var CONFIG = {
63
+ fields: ['otherIdDoc', 'passportNumber', 'anotherMadeUpId']
64
+ };
65
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
66
+ expect(result).toEqual(DATA.passportNumber);
67
+ });
68
+ it('Should return no value if elements in config.fields are not found in data', function () {
69
+ var CONFIG = {
70
+ fields: ['otherIdDoc1', 'passportNumber1', 'anotherMadeUpId1']
71
+ };
72
+ var result = (0, _getFirstOf.default)(CONFIG, DATA);
73
+ expect(result).toEqual('');
74
+ });
75
+ it('Should return null when an invalid config is used', function () {
76
+ var result = (0, _getFirstOf.default)(null, DATA);
77
+ expect(result).toEqual(null);
78
+ });
79
+ it('Should return null when invalid data is used', function () {
80
+ var CONFIG = {
81
+ field: 'a'
82
+ };
83
+ var result = (0, _getFirstOf.default)(CONFIG, null);
84
+ expect(result).toEqual(null);
85
+ });
86
+ });
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ var _getIndexOfMatchingValueIn = _interopRequireDefault(require("./getIndexOfMatchingValueIn"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
6
+ var DATA = {
7
+ arrayOfValues: ['abc', 'bcd', 'cde', 'def', {
8
+ root: {
9
+ branch: 'leaf'
10
+ }
11
+ }],
12
+ cutoffIndex: 1,
13
+ ignoreIndex: 2,
14
+ valueToSearchFor: 'cde',
15
+ targetName: 'arrayOfValues',
16
+ fieldName: 'valueToSearchFor',
17
+ cutoffName: 'cutoffIndex',
18
+ ignoreName: 'ignoreIndex'
19
+ };
20
+ it('Should return the index of a matching value if one exists', function () {
21
+ var CONFIG = {
22
+ target: 'arrayOfValues',
23
+ value: 'cde'
24
+ };
25
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
26
+ expect(result).toEqual('2');
27
+ });
28
+ it('Should handle getting value from given field', function () {
29
+ var CONFIG = {
30
+ target: 'arrayOfValues',
31
+ field: 'valueToSearchFor'
32
+ };
33
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
34
+ expect(result).toEqual('2');
35
+ });
36
+ it('Should handle interpolated string for field', function () {
37
+ // eslint-disable-next-line no-template-curly-in-string
38
+ var CONFIG = {
39
+ target: 'arrayOfValues',
40
+ field: '${fieldName}'
41
+ };
42
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
43
+ expect(result).toEqual('2');
44
+ });
45
+ it('Should handle interpolated string for key', function () {
46
+ // eslint-disable-next-line no-template-curly-in-string
47
+ var CONFIG = {
48
+ target: 'arrayOfValues',
49
+ key: 'root.branch',
50
+ value: 'leaf'
51
+ };
52
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
53
+ expect(result).toEqual('4');
54
+ });
55
+ it('Should handle a cutoff value being specified', function () {
56
+ var CONFIG = {
57
+ target: 'arrayOfValues',
58
+ value: 'cde',
59
+ cutoff: {
60
+ value: 1
61
+ }
62
+ };
63
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
64
+ expect(result).toEqual(null); // Cutoff occurs before matching value is reached.
65
+ });
66
+
67
+ it('Should handle a cutoff field being specified', function () {
68
+ var CONFIG = {
69
+ target: 'arrayOfValues',
70
+ value: 'cde',
71
+ cutoff: {
72
+ field: 'cutoffIndex'
73
+ }
74
+ };
75
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
76
+ expect(result).toEqual(null); // Cutoff occurs before matching value is reached.
77
+ });
78
+
79
+ it('Should handle interpolated string for cutoff.field', function () {
80
+ // eslint-disable-next-line no-template-curly-in-string
81
+ var CONFIG = {
82
+ target: 'arrayOfValues',
83
+ value: 'cde',
84
+ cutoff: {
85
+ field: '${cutoffName}'
86
+ }
87
+ };
88
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
89
+ expect(result).toEqual(null); // Cutoff occurs before matching value is reached.
90
+ });
91
+
92
+ it('Should handle an ignore value being specified', function () {
93
+ var CONFIG = {
94
+ target: 'arrayOfValues',
95
+ value: 'cde',
96
+ ignore: {
97
+ value: 2
98
+ }
99
+ };
100
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
101
+ expect(result).toEqual(null); // Should ignore the matching value.
102
+ });
103
+
104
+ it('Should handle an ignore field being specified', function () {
105
+ var CONFIG = {
106
+ target: 'arrayOfValues',
107
+ value: 'cde',
108
+ ignore: {
109
+ field: 'ignoreIndex'
110
+ }
111
+ };
112
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
113
+ expect(result).toEqual(null); // Should ignore the matching value.
114
+ });
115
+
116
+ it('Should handle interpolated string for ignore.field', function () {
117
+ // eslint-disable-next-line no-template-curly-in-string
118
+ var CONFIG = {
119
+ target: 'arrayOfValues',
120
+ value: 'cde',
121
+ ignore: {
122
+ field: '${ignoreName}'
123
+ }
124
+ };
125
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
126
+ expect(result).toEqual(null); // Should ignore the matching value.
127
+ });
128
+
129
+ it('Should handle interpolated string for target', function () {
130
+ // eslint-disable-next-line no-template-curly-in-string
131
+ var CONFIG = {
132
+ target: '${targetName}',
133
+ value: 'cde'
134
+ };
135
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
136
+ expect(result).toEqual('2');
137
+ });
138
+ it('Should return null when the target does not exist', function () {
139
+ var CONFIG = {
140
+ target: 'notARealTarget',
141
+ value: 'cde'
142
+ };
143
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
144
+ expect(result).toEqual(null);
145
+ });
146
+ it('Should return null when config is missing fields', function () {
147
+ var CONFIG = {};
148
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, DATA);
149
+ expect(result).toEqual(null);
150
+ });
151
+ it('Should return null when config is invalid', function () {
152
+ var result = (0, _getIndexOfMatchingValueIn.default)(null, DATA);
153
+ expect(result).toEqual(null);
154
+ });
155
+ it('Should return null when data is invalid', function () {
156
+ var CONFIG = {
157
+ target: 'arrayOfValues',
158
+ value: 'cde'
159
+ };
160
+ var result = (0, _getIndexOfMatchingValueIn.default)(CONFIG, null);
161
+ expect(result).toEqual(null);
162
+ });
163
+ });
@@ -26,7 +26,8 @@ var persistValueInFormData = function persistValueInFormData(config, data, onCha
26
26
  } else {
27
27
  value = config === null || config === void 0 ? void 0 : config.value;
28
28
  }
29
- if (value && config.name && data[config.name] !== value) {
29
+ /* eslint-disable object-shorthand */
30
+ if (value != null && config.name && data[config.name] !== value) {
30
31
  onChange({
31
32
  target: {
32
33
  name: config.name,
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _persistValueInFormData = _interopRequireDefault(require("./persistValueInFormData"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Operate.persistValueInFormData', function () {
6
+ var DATA = {
7
+ alpha: 'abc',
8
+ beta: 'charlie',
9
+ charlie: '123'
10
+ };
11
+ var ON_CHANGE_COUNT = 0;
12
+ var ON_CHANGE = function ON_CHANGE(_ref) {
13
+ var target = _ref.target;
14
+ DATA[target.name] = target.value;
15
+ ON_CHANGE_COUNT += 1;
16
+ };
17
+ beforeEach(function () {
18
+ DATA = {
19
+ alpha: 'abc',
20
+ beta: 'charlie',
21
+ charlie: '123'
22
+ };
23
+ ON_CHANGE_COUNT = 0;
24
+ });
25
+ it('Should trigger a change correctly', function () {
26
+ var CONFIG = {
27
+ name: 'alpha',
28
+ value: 'bcd'
29
+ };
30
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
31
+ expect(DATA).toEqual({
32
+ alpha: 'bcd',
33
+ beta: 'charlie',
34
+ charlie: '123'
35
+ });
36
+ expect(ON_CHANGE_COUNT).toEqual(1);
37
+ });
38
+ it('Should trigger a change correctly with boolean false', function () {
39
+ var CONFIG = {
40
+ name: 'alpha',
41
+ value: false
42
+ };
43
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
44
+ expect(DATA).toEqual({
45
+ alpha: false,
46
+ beta: 'charlie',
47
+ charlie: '123'
48
+ });
49
+ expect(ON_CHANGE_COUNT).toEqual(1);
50
+ });
51
+ it('Should not call onChange when value is unchanged', function () {
52
+ var CONFIG = {
53
+ name: 'alpha',
54
+ value: 'abc'
55
+ };
56
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
57
+ expect(DATA).toEqual({
58
+ alpha: 'abc',
59
+ beta: 'charlie',
60
+ charlie: '123'
61
+ });
62
+ expect(ON_CHANGE_COUNT).toEqual(0);
63
+ });
64
+ it('Should not call onChange if no value or field is given', function () {
65
+ var CONFIG = {
66
+ name: 'alpha'
67
+ };
68
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
69
+ expect(DATA).toEqual({
70
+ alpha: 'abc',
71
+ beta: 'charlie',
72
+ charlie: '123'
73
+ });
74
+ expect(ON_CHANGE_COUNT).toEqual(0);
75
+ });
76
+ it('Should not call onChange if no name is given', function () {
77
+ var CONFIG = {
78
+ field: 'charlie'
79
+ };
80
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
81
+ expect(DATA).toEqual({
82
+ alpha: 'abc',
83
+ beta: 'charlie',
84
+ charlie: '123'
85
+ });
86
+ expect(ON_CHANGE_COUNT).toEqual(0);
87
+ });
88
+ it('Should not call onChange if field cannot be found', function () {
89
+ var CONFIG = {
90
+ name: 'alpha',
91
+ field: 'delta'
92
+ };
93
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
94
+ expect(DATA).toEqual({
95
+ alpha: 'abc',
96
+ beta: 'charlie',
97
+ charlie: '123'
98
+ });
99
+ expect(ON_CHANGE_COUNT).toEqual(0);
100
+ });
101
+ it('Should correctly interpolate a field value', function () {
102
+ // eslint-disable-next-line no-template-curly-in-string
103
+ var CONFIG = {
104
+ name: 'alpha',
105
+ field: '${beta}'
106
+ };
107
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
108
+ expect(DATA).toEqual({
109
+ alpha: '123',
110
+ beta: 'charlie',
111
+ charlie: '123'
112
+ });
113
+ expect(ON_CHANGE_COUNT).toEqual(1);
114
+ });
115
+ });
@@ -11,6 +11,7 @@ var _persistValueInFormData = _interopRequireDefault(require("./persistValueInFo
11
11
  var _setValueInFormData = _interopRequireDefault(require("./setValueInFormData"));
12
12
  var _shouldRun = _interopRequireDefault(require("./shouldRun"));
13
13
  var _setDataItem = _interopRequireDefault(require("../Data/setDataItem"));
14
+ var _getFirstOf = _interopRequireDefault(require("./getFirstOf"));
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  // Global imports.
16
17
 
@@ -20,7 +21,8 @@ var functions = {
20
21
  checkValueIsTruthy: _checkValueIsTruthy.default,
21
22
  getIndexOfMatchingValueIn: _getIndexOfMatchingValueIn.default,
22
23
  persistValueInFormData: _persistValueInFormData.default,
23
- setValueInFormData: _setValueInFormData.default
24
+ setValueInFormData: _setValueInFormData.default,
25
+ getFirstOf: _getFirstOf.default
24
26
  };
25
27
  var doOperation = function doOperation(config, data, onChange) {
26
28
  var fn = functions[config.function];
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ var _runPageOperations = _interopRequireDefault(require("./runPageOperations"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
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; }
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); }
11
+ describe('Utils.Operate.runPageOperations', function () {
12
+ var DATA = {
13
+ alpha: 'abc',
14
+ bravo: ['bcd', 'cde', 'charlie'],
15
+ charlie: 'def',
16
+ delta: 'root',
17
+ array: ['123', '234', '456']
18
+ };
19
+ it('Should return an empty object when no operations are specified', function () {
20
+ var PAGE = {};
21
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
22
+ expect(result).toEqual(DATA);
23
+ });
24
+ it('Should handle a single operation correctly', function () {
25
+ var PAGE = {
26
+ operations: [{
27
+ output: 'firstOpResult',
28
+ function: 'setValueInFormData',
29
+ field: 'alpha'
30
+ }]
31
+ };
32
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
33
+ expect(result).toEqual(_objectSpread(_objectSpread({}, DATA), {}, {
34
+ firstOpResult: 'abc'
35
+ }));
36
+ });
37
+ it('Should handle a multiple operations correctly', function () {
38
+ var PAGE = {
39
+ operations: [{
40
+ output: 'firstOpResult',
41
+ function: 'setValueInFormData',
42
+ field: 'alpha'
43
+ }, {
44
+ output: 'secondOpResult',
45
+ function: 'setValueInFormData',
46
+ field: 'bravo[1]'
47
+ }]
48
+ };
49
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
50
+ expect(result).toEqual(_objectSpread(_objectSpread({}, DATA), {}, {
51
+ firstOpResult: 'abc',
52
+ secondOpResult: 'cde'
53
+ }));
54
+ });
55
+ it('Should handle chained operations correctly', function () {
56
+ var PAGE = {
57
+ operations: [{
58
+ output: 'firstOpResult',
59
+ function: 'setValueInFormData',
60
+ field: 'bravo[2]'
61
+ }, {
62
+ output: 'secondOpResult',
63
+ function: 'setValueInFormData',
64
+ // eslint-disable-next-line no-template-curly-in-string
65
+ field: '${firstOpResult}'
66
+ }]
67
+ };
68
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
69
+ expect(result).toEqual(_objectSpread(_objectSpread({}, DATA), {}, {
70
+ firstOpResult: 'charlie',
71
+ secondOpResult: 'def'
72
+ }));
73
+ });
74
+ it('Should handle an interpolated output string correctly', function () {
75
+ var PAGE = {
76
+ operations: [{
77
+ function: 'setValueInFormData',
78
+ value: 'leaf',
79
+ // eslint-disable-next-line no-template-curly-in-string
80
+ output: '${delta}.trunk.branch'
81
+ }]
82
+ };
83
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
84
+ expect(result).toEqual(_objectSpread(_objectSpread({}, DATA), {}, {
85
+ root: {
86
+ trunk: {
87
+ branch: 'leaf'
88
+ }
89
+ }
90
+ }));
91
+ });
92
+ it('Should handle an output string with array indeces in', function () {
93
+ var PAGE = {
94
+ operations: [{
95
+ function: 'setValueInFormData',
96
+ value: '000',
97
+ output: 'array[1]'
98
+ }]
99
+ };
100
+ var result = (0, _runPageOperations.default)(PAGE, DATA);
101
+ expect(result).toEqual(_objectSpread(_objectSpread({}, DATA), {}, {
102
+ array: ['123', '000', '456']
103
+ }));
104
+ });
105
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _setValueInFormData = _interopRequireDefault(require("./setValueInFormData"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Operate.setValueInFormData', function () {
6
+ var DATA = {
7
+ a: '1',
8
+ b: ['2', '3'],
9
+ indexOfThree: 1
10
+ };
11
+ it('Should return the value provided in config if no field is specified', function () {
12
+ var CONFIG = {
13
+ value: '2'
14
+ };
15
+ var result = (0, _setValueInFormData.default)(CONFIG, DATA);
16
+ expect(result).toEqual(CONFIG.value);
17
+ });
18
+ it('Should return the value of the field given in config, if it exists', function () {
19
+ var CONFIG = {
20
+ field: 'a'
21
+ };
22
+ var result = (0, _setValueInFormData.default)(CONFIG, DATA);
23
+ expect(result).toEqual(DATA.a);
24
+ });
25
+ it('Should handle interpolated field strings', function () {
26
+ // eslint-disable-next-line no-template-curly-in-string
27
+ var CONFIG = {
28
+ field: 'b[${indexOfThree}]'
29
+ };
30
+ var result = (0, _setValueInFormData.default)(CONFIG, DATA);
31
+ expect(result).toEqual(DATA.b[1]);
32
+ });
33
+ it('Should return null when an invalid config is used', function () {
34
+ var result = (0, _setValueInFormData.default)(null, DATA);
35
+ expect(result).toEqual(null);
36
+ });
37
+ it('Should return null when invalid data is used', function () {
38
+ var CONFIG = {
39
+ field: 'a'
40
+ };
41
+ var result = (0, _setValueInFormData.default)(CONFIG, null);
42
+ expect(result).toEqual(null);
43
+ });
44
+ });
@@ -20,24 +20,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
20
20
  */
21
21
  var shouldRun = function shouldRun(config, data) {
22
22
  if (config !== null && config !== void 0 && config.condition) {
23
- var fieldPath = _copReactComponents.Utils.interpolateString(config.field, data);
23
+ var configuration = config;
24
+ var fieldPath = _copReactComponents.Utils.interpolateString(configuration.field, data);
24
25
  var fieldValue = (0, _getSourceData.default)(data, fieldPath);
25
- switch (config.condition) {
26
+ switch (configuration.condition) {
26
27
  // Only run the operation if a given field's value has changed.
27
28
  case 'changes':
28
- var lastPath = "".concat(fieldPath, "LastValue");
29
- var lastValue = config[lastPath] || null;
30
- if (lastValue === null) {
31
- // If there isn't a last value then we assume
32
- // that this is the first render.
33
- config[lastPath] = fieldValue;
29
+ {
30
+ var lastPath = "".concat(fieldPath, "LastValue");
31
+ var lastValue = configuration[lastPath] || null;
32
+ if (lastValue === null) {
33
+ // If there isn't a last value then we assume
34
+ // that this is the first render.
35
+ configuration[lastPath] = fieldValue;
36
+ return false;
37
+ }
38
+ if (fieldValue !== lastValue) {
39
+ configuration[lastPath] = fieldValue;
40
+ return true;
41
+ }
34
42
  return false;
35
43
  }
36
- if (fieldValue !== lastValue) {
37
- config[lastPath] = fieldValue;
38
- return true;
39
- }
40
- return false;
41
44
  // Only run the operation if a given field's value is truthy.
42
45
  case 'isTruthy':
43
46
  return !!fieldValue;