@planning-inspectorate/dynamic-forms 3.15.6 → 3.17.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 (264) hide show
  1. package/.gitattributes +3 -0
  2. package/.prettierrc +1 -0
  3. package/README.md +123 -4
  4. package/package.json +6 -4
  5. package/{types/src → src}/components/address/question.d.ts +6 -2
  6. package/src/components/address/question.d.ts.map +1 -0
  7. package/src/components/address/question.js +7 -19
  8. package/{types/src → src}/components/boolean/question.d.ts +2 -2
  9. package/src/components/boolean/question.d.ts.map +1 -0
  10. package/src/components/boolean/question.js +1 -1
  11. package/src/components/checkbox/question.d.ts +9 -0
  12. package/src/components/checkbox/question.d.ts.map +1 -0
  13. package/src/components/checkbox/question.js +37 -54
  14. package/src/components/checkbox/question.test.js +170 -27
  15. package/{types/src → src}/components/date/question.d.ts +2 -2
  16. package/src/components/date/question.d.ts.map +1 -0
  17. package/src/components/date/question.js +7 -16
  18. package/{types/src → src}/components/date-period/question.d.ts +12 -4
  19. package/src/components/date-period/question.d.ts.map +1 -0
  20. package/src/components/date-period/question.js +2 -3
  21. package/{types/src → src}/components/date-time/question.d.ts +2 -2
  22. package/src/components/date-time/question.d.ts.map +1 -0
  23. package/src/components/date-time/question.js +5 -14
  24. package/src/components/email/question.d.ts +23 -0
  25. package/src/components/email/question.d.ts.map +1 -0
  26. package/src/components/email/question.js +1 -9
  27. package/src/components/manage-list/answer-summary-list.njk +1 -1
  28. package/src/components/manage-list/manage-list-actions.d.ts.map +1 -0
  29. package/src/components/manage-list/manage-list-section.d.ts.map +1 -0
  30. package/{types/src → src}/components/manage-list/question.d.ts +6 -3
  31. package/src/components/manage-list/question.d.ts.map +1 -0
  32. package/src/components/manage-list/question.js +5 -2
  33. package/{types/src → src}/components/manage-list/utils.d.ts +3 -3
  34. package/src/components/manage-list/utils.d.ts.map +1 -0
  35. package/src/components/manage-list/utils.js +2 -2
  36. package/src/components/multi-field-input/question.d.ts +52 -0
  37. package/src/components/multi-field-input/question.d.ts.map +1 -0
  38. package/src/components/multi-field-input/question.js +5 -13
  39. package/src/components/number-entry/question.d.ts +12 -0
  40. package/src/components/number-entry/question.d.ts.map +1 -0
  41. package/src/components/number-entry/question.js +4 -22
  42. package/src/components/radio/question.d.ts +11 -0
  43. package/src/components/radio/question.d.ts.map +1 -0
  44. package/src/components/radio/question.js +30 -51
  45. package/src/components/radio/question.test.js +139 -60
  46. package/src/components/select/question.d.ts +12 -0
  47. package/src/components/select/question.d.ts.map +1 -0
  48. package/src/components/select/question.js +5 -48
  49. package/{types/src → src}/components/single-line-input/question.d.ts +2 -2
  50. package/src/components/single-line-input/question.d.ts.map +1 -0
  51. package/src/components/single-line-input/question.js +2 -2
  52. package/{types/src → src}/components/text-entry/question.d.ts +3 -3
  53. package/src/components/text-entry/question.d.ts.map +1 -0
  54. package/src/components/text-entry/question.js +2 -2
  55. package/{types/src → src}/components/text-entry-redact/question.d.ts +8 -9
  56. package/src/components/text-entry-redact/question.d.ts.map +1 -0
  57. package/src/components/text-entry-redact/question.js +5 -2
  58. package/{types/src → src}/components/unit-option-entry/question.d.ts +12 -8
  59. package/src/components/unit-option-entry/question.d.ts.map +1 -0
  60. package/src/components/unit-option-entry/question.js +5 -6
  61. package/src/components/utils/component-types.d.ts.map +1 -0
  62. package/src/components/utils/persisted-number-answer.d.ts.map +1 -0
  63. package/src/components/utils/question-has-answer.d.ts.map +1 -0
  64. package/src/components/utils/question-has-answer.js +1 -1
  65. package/src/components/utils/question-utils.d.ts +33 -0
  66. package/src/components/utils/question-utils.d.ts.map +1 -0
  67. package/src/components/utils/question-utils.js +31 -2
  68. package/src/components/utils/question-utils.test.js +89 -2
  69. package/{types/src → src}/controller.d.ts +2 -7
  70. package/src/controller.d.ts.map +1 -0
  71. package/src/controller.js +3 -10
  72. package/{types/src → src}/index.d.ts +4 -3
  73. package/src/index.d.ts.map +1 -0
  74. package/src/index.js +6 -4
  75. package/src/journey/journey-response.d.ts +28 -0
  76. package/src/journey/journey-response.d.ts.map +1 -0
  77. package/src/journey/journey-response.js +4 -8
  78. package/{types/src → src}/journey/journey.d.ts +8 -8
  79. package/src/journey/journey.d.ts.map +1 -0
  80. package/src/journey/journey.js +6 -6
  81. package/src/lib/address-utils.d.ts.map +1 -0
  82. package/src/lib/address.d.ts.map +1 -0
  83. package/src/lib/date-utils.d.ts.map +1 -0
  84. package/src/lib/session-answer-store.d.ts.map +1 -0
  85. package/src/lib/utils.d.ts.map +1 -0
  86. package/src/lib/uuid.d.ts.map +1 -0
  87. package/src/middleware/build-get-journey.d.ts.map +1 -0
  88. package/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
  89. package/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
  90. package/src/middleware/redirect-to-unanswered-question.js +1 -1
  91. package/src/questions/create-questions.d.ts +18 -0
  92. package/src/questions/create-questions.d.ts.map +1 -0
  93. package/src/questions/create-questions.js +3 -3
  94. package/{types/src → src}/questions/options-question.d.ts +7 -7
  95. package/src/questions/options-question.d.ts.map +1 -0
  96. package/src/questions/options-question.js +29 -4
  97. package/src/questions/options-question.test.js +106 -0
  98. package/{types/src → src}/questions/question.d.ts +48 -79
  99. package/src/questions/question.d.ts.map +1 -0
  100. package/src/questions/question.js +83 -60
  101. package/src/questions/question.test.js +86 -0
  102. package/src/questions/questions.d.ts +3 -0
  103. package/src/questions/questions.d.ts.map +1 -0
  104. package/src/questions/questions.js +1 -1
  105. package/{types/src → src}/section.d.ts +16 -15
  106. package/src/section.d.ts.map +1 -0
  107. package/src/section.js +12 -14
  108. package/src/validator/address-validator.d.ts.map +1 -0
  109. package/src/validator/base-validator.d.ts.map +1 -0
  110. package/src/validator/conditional-required-validator.d.ts.map +1 -0
  111. package/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
  112. package/src/validator/coordinates-validator.d.ts.map +1 -0
  113. package/src/validator/cross-question-validator.d.ts.map +1 -0
  114. package/src/validator/date-period-validator.d.ts.map +1 -0
  115. package/src/validator/date-time-validator.d.ts.map +1 -0
  116. package/src/validator/date-validator.d.ts.map +1 -0
  117. package/src/validator/document-upload-validator.d.ts.map +1 -0
  118. package/src/validator/email-validator.d.ts.map +1 -0
  119. package/{types/src → src}/validator/multi-field-input-validator.d.ts +3 -3
  120. package/src/validator/multi-field-input-validator.d.ts.map +1 -0
  121. package/src/validator/multi-field-input-validator.js +3 -3
  122. package/{types/src → src}/validator/numeric-validator.d.ts +2 -2
  123. package/src/validator/numeric-validator.d.ts.map +1 -0
  124. package/src/validator/numeric-validator.js +2 -2
  125. package/src/validator/required-validator.d.ts.map +1 -0
  126. package/src/validator/same-answer-validator.d.ts.map +1 -0
  127. package/{types/src → src}/validator/string-validator.d.ts +3 -3
  128. package/src/validator/string-validator.d.ts.map +1 -0
  129. package/src/validator/string-validator.js +3 -3
  130. package/src/validator/unit-option-entry-validator.d.ts.map +1 -0
  131. package/src/validator/valid-option-validator.d.ts.map +1 -0
  132. package/src/validator/validation-error-handler.d.ts.map +1 -0
  133. package/src/validator/validator.d.ts.map +1 -0
  134. package/test/journey.js +2 -0
  135. package/test/questions.js +51 -1
  136. package/test/secondary-actions.test.js +1 -1
  137. package/test/snapshots/check-your-answers-not-started.html +22 -0
  138. package/test/snapshots/check-your-answers-with-answers.html +22 -0
  139. package/test/snapshots/favourite-activity-reason.html +54 -0
  140. package/test/snapshots/travel-requirements.html +48 -0
  141. package/test/utils/question-test-utils.js +36 -6
  142. package/tsconfig.json +11 -4
  143. package/{types/src/questions → typedefs}/question-props.d.ts +28 -26
  144. package/typedefs/question-types.d.ts +141 -0
  145. package/{src → typedefs}/section-types.d.ts +1 -1
  146. package/typedefs/section-types.js +1 -0
  147. package/move-types.js +0 -12
  148. package/src/questions/question-props.d.ts +0 -295
  149. package/src/questions/question-types.d.ts +0 -86
  150. package/types/commitlint.config.d.ts +0 -7
  151. package/types/commitlint.config.d.ts.map +0 -1
  152. package/types/eslint.config.d.ts +0 -97
  153. package/types/eslint.config.d.ts.map +0 -1
  154. package/types/move-types.d.ts +0 -2
  155. package/types/move-types.d.ts.map +0 -1
  156. package/types/src/components/address/question.d.ts.map +0 -1
  157. package/types/src/components/boolean/question.d.ts.map +0 -1
  158. package/types/src/components/checkbox/question.d.ts +0 -33
  159. package/types/src/components/checkbox/question.d.ts.map +0 -1
  160. package/types/src/components/date/question.d.ts.map +0 -1
  161. package/types/src/components/date-period/question.d.ts.map +0 -1
  162. package/types/src/components/date-time/question.d.ts.map +0 -1
  163. package/types/src/components/email/question.d.ts +0 -35
  164. package/types/src/components/email/question.d.ts.map +0 -1
  165. package/types/src/components/manage-list/manage-list-actions.d.ts.map +0 -1
  166. package/types/src/components/manage-list/manage-list-section.d.ts.map +0 -1
  167. package/types/src/components/manage-list/question.d.ts.map +0 -1
  168. package/types/src/components/manage-list/utils.d.ts.map +0 -1
  169. package/types/src/components/multi-field-input/question.d.ts +0 -64
  170. package/types/src/components/multi-field-input/question.d.ts.map +0 -1
  171. package/types/src/components/number-entry/question.d.ts +0 -36
  172. package/types/src/components/number-entry/question.d.ts.map +0 -1
  173. package/types/src/components/radio/question.d.ts +0 -23
  174. package/types/src/components/radio/question.d.ts.map +0 -1
  175. package/types/src/components/select/question.d.ts +0 -22
  176. package/types/src/components/select/question.d.ts.map +0 -1
  177. package/types/src/components/single-line-input/question.d.ts.map +0 -1
  178. package/types/src/components/text-entry/question.d.ts.map +0 -1
  179. package/types/src/components/text-entry-redact/question.d.ts.map +0 -1
  180. package/types/src/components/unit-option-entry/question.d.ts.map +0 -1
  181. package/types/src/components/utils/component-types.d.ts.map +0 -1
  182. package/types/src/components/utils/persisted-number-answer.d.ts.map +0 -1
  183. package/types/src/components/utils/question-has-answer.d.ts.map +0 -1
  184. package/types/src/components/utils/question-utils.d.ts +0 -15
  185. package/types/src/components/utils/question-utils.d.ts.map +0 -1
  186. package/types/src/controller.d.ts.map +0 -1
  187. package/types/src/index.d.ts.map +0 -1
  188. package/types/src/journey/journey-response.d.ts +0 -32
  189. package/types/src/journey/journey-response.d.ts.map +0 -1
  190. package/types/src/journey/journey-types.d.ts +0 -28
  191. package/types/src/journey/journey-types.d.ts.map +0 -1
  192. package/types/src/journey/journey.d.ts.map +0 -1
  193. package/types/src/lib/address-utils.d.ts.map +0 -1
  194. package/types/src/lib/address.d.ts.map +0 -1
  195. package/types/src/lib/date-utils.d.ts.map +0 -1
  196. package/types/src/lib/session-answer-store.d.ts.map +0 -1
  197. package/types/src/lib/utils.d.ts.map +0 -1
  198. package/types/src/lib/uuid.d.ts.map +0 -1
  199. package/types/src/middleware/build-get-journey.d.ts.map +0 -1
  200. package/types/src/middleware/redirect-to-unanswered-question.d.ts +0 -12
  201. package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +0 -1
  202. package/types/src/questions/create-questions.d.ts +0 -18
  203. package/types/src/questions/create-questions.d.ts.map +0 -1
  204. package/types/src/questions/options-question.d.ts.map +0 -1
  205. package/types/src/questions/question-props.d.ts.map +0 -1
  206. package/types/src/questions/question-types.d.ts +0 -86
  207. package/types/src/questions/question-types.d.ts.map +0 -1
  208. package/types/src/questions/question.d.ts.map +0 -1
  209. package/types/src/questions/questions.d.ts +0 -3
  210. package/types/src/questions/questions.d.ts.map +0 -1
  211. package/types/src/section.d.ts.map +0 -1
  212. package/types/src/validator/address-validator.d.ts.map +0 -1
  213. package/types/src/validator/base-validator.d.ts.map +0 -1
  214. package/types/src/validator/conditional-required-validator.d.ts.map +0 -1
  215. package/types/src/validator/confirmation-checkbox-validator.d.ts.map +0 -1
  216. package/types/src/validator/coordinates-validator.d.ts.map +0 -1
  217. package/types/src/validator/cross-question-validator.d.ts.map +0 -1
  218. package/types/src/validator/date-period-validator.d.ts.map +0 -1
  219. package/types/src/validator/date-time-validator.d.ts.map +0 -1
  220. package/types/src/validator/date-validator.d.ts.map +0 -1
  221. package/types/src/validator/document-upload-validator.d.ts.map +0 -1
  222. package/types/src/validator/email-validator.d.ts.map +0 -1
  223. package/types/src/validator/multi-field-input-validator.d.ts.map +0 -1
  224. package/types/src/validator/numeric-validator.d.ts.map +0 -1
  225. package/types/src/validator/required-validator.d.ts.map +0 -1
  226. package/types/src/validator/same-answer-validator.d.ts.map +0 -1
  227. package/types/src/validator/string-validator.d.ts.map +0 -1
  228. package/types/src/validator/unit-option-entry-validator.d.ts.map +0 -1
  229. package/types/src/validator/valid-option-validator.d.ts.map +0 -1
  230. package/types/src/validator/validation-error-handler.d.ts.map +0 -1
  231. package/types/src/validator/validator.d.ts.map +0 -1
  232. /package/{types/src → src}/components/manage-list/manage-list-actions.d.ts +0 -0
  233. /package/{types/src → src}/components/manage-list/manage-list-section.d.ts +0 -0
  234. /package/{types/src → src}/components/utils/component-types.d.ts +0 -0
  235. /package/{types/src → src}/components/utils/persisted-number-answer.d.ts +0 -0
  236. /package/{types/src → src}/components/utils/question-has-answer.d.ts +0 -0
  237. /package/{types/src → src}/lib/address-utils.d.ts +0 -0
  238. /package/{types/src → src}/lib/address.d.ts +0 -0
  239. /package/{types/src → src}/lib/date-utils.d.ts +0 -0
  240. /package/{types/src → src}/lib/session-answer-store.d.ts +0 -0
  241. /package/{types/src → src}/lib/utils.d.ts +0 -0
  242. /package/{types/src → src}/lib/uuid.d.ts +0 -0
  243. /package/{types/src → src}/middleware/build-get-journey.d.ts +0 -0
  244. /package/{types/src → src}/validator/address-validator.d.ts +0 -0
  245. /package/{types/src → src}/validator/base-validator.d.ts +0 -0
  246. /package/{types/src → src}/validator/conditional-required-validator.d.ts +0 -0
  247. /package/{types/src → src}/validator/confirmation-checkbox-validator.d.ts +0 -0
  248. /package/{types/src → src}/validator/coordinates-validator.d.ts +0 -0
  249. /package/{types/src → src}/validator/cross-question-validator.d.ts +0 -0
  250. /package/{types/src → src}/validator/date-period-validator.d.ts +0 -0
  251. /package/{types/src → src}/validator/date-time-validator.d.ts +0 -0
  252. /package/{types/src → src}/validator/date-validator.d.ts +0 -0
  253. /package/{types/src → src}/validator/document-upload-validator.d.ts +0 -0
  254. /package/{types/src → src}/validator/email-validator.d.ts +0 -0
  255. /package/{types/src → src}/validator/required-validator.d.ts +0 -0
  256. /package/{types/src → src}/validator/same-answer-validator.d.ts +0 -0
  257. /package/{types/src → src}/validator/unit-option-entry-validator.d.ts +0 -0
  258. /package/{types/src → src}/validator/valid-option-validator.d.ts +0 -0
  259. /package/{types/src → src}/validator/validation-error-handler.d.ts +0 -0
  260. /package/{types/src → src}/validator/validator.d.ts +0 -0
  261. /package/{src/journey → typedefs}/journey-types.d.ts +0 -0
  262. /package/{src/journey → typedefs}/journey-types.js +0 -0
  263. /package/{src/questions → typedefs}/question-props.js +0 -0
  264. /package/{src/questions → typedefs}/question-types.js +0 -0
@@ -457,4 +457,90 @@ describe('./src/dynamic-forms/question.js', () => {
457
457
  assert.strictEqual(q.isRequired(), true);
458
458
  });
459
459
  });
460
+
461
+ describe('formatSummaryValue', () => {
462
+ it('should default to undefined', () => {
463
+ const question = getTestQuestion();
464
+ assert.strictEqual(question.formatSummaryValue, undefined);
465
+ });
466
+
467
+ it('should accept formatSummaryValue in constructor', () => {
468
+ const formatter = ({ formattedAnswer }) => `<em>${formattedAnswer}</em>`;
469
+ const question = new Question({
470
+ title: TITLE,
471
+ question: QUESTION_STRING,
472
+ viewFolder: TYPE,
473
+ fieldName: FIELDNAME,
474
+ formatSummaryValue: formatter
475
+ });
476
+ assert.strictEqual(question.formatSummaryValue, formatter);
477
+ });
478
+
479
+ it('should apply custom formatting in formatAnswerForSummary when provided', () => {
480
+ const journey = {
481
+ getCurrentQuestionUrl: () => 'current'
482
+ };
483
+ const question = new Question({
484
+ title: TITLE,
485
+ question: QUESTION_STRING,
486
+ viewFolder: TYPE,
487
+ fieldName: FIELDNAME,
488
+ formatSummaryValue: ({ formattedAnswer }) => `<strong>${formattedAnswer}</strong>`
489
+ });
490
+ const result = question.formatAnswerForSummary('segment', journey, 'test answer');
491
+ assert.strictEqual(result[0].value, '<strong>Test answer</strong>');
492
+ });
493
+
494
+ it('should use default formatting when formatSummaryValue is not provided', () => {
495
+ const journey = {
496
+ getCurrentQuestionUrl: () => 'current'
497
+ };
498
+ const question = getTestQuestion();
499
+ const result = question.formatAnswerForSummary('segment', journey, 'test answer');
500
+ assert.strictEqual(result[0].value, 'Test answer');
501
+ });
502
+
503
+ it('should allow access to journey in formatter', () => {
504
+ const journey = {
505
+ getCurrentQuestionUrl: () => 'current',
506
+ response: { answers: { otherField: 'other value' } }
507
+ };
508
+ const question = new Question({
509
+ title: TITLE,
510
+ question: QUESTION_STRING,
511
+ viewFolder: TYPE,
512
+ fieldName: FIELDNAME,
513
+ formatSummaryValue: ({ formattedAnswer, journey }) => {
514
+ const extra = journey.response.answers.otherField;
515
+ return `${formattedAnswer} (${extra})`;
516
+ }
517
+ });
518
+ const result = question.formatAnswerForSummary('segment', journey, 'test');
519
+ assert.strictEqual(result[0].value, 'Test (other value)');
520
+ });
521
+
522
+ it('should pass all context properties to formatSummaryValue', () => {
523
+ const formatSummaryValue = mock.fn((ctx) => ctx.formattedAnswer);
524
+ const journey = {
525
+ id: 'test-journey',
526
+ getCurrentQuestionUrl: () => 'current'
527
+ };
528
+ const question = new Question({
529
+ title: TITLE,
530
+ question: QUESTION_STRING,
531
+ viewFolder: TYPE,
532
+ fieldName: FIELDNAME,
533
+ formatSummaryValue
534
+ });
535
+ question.formatAnswerForSummary('my-segment', journey, 'my-answer');
536
+
537
+ assert.strictEqual(formatSummaryValue.mock.callCount(), 1);
538
+ const receivedContext = formatSummaryValue.mock.calls[0].arguments[0];
539
+ assert.strictEqual(receivedContext.answer, 'my-answer');
540
+ assert.strictEqual(receivedContext.formattedAnswer, 'My-answer');
541
+ assert.strictEqual(receivedContext.question, question);
542
+ assert.strictEqual(receivedContext.journey, journey);
543
+ assert.strictEqual(receivedContext.sectionSegment, 'my-segment');
544
+ });
545
+ });
460
546
  });
@@ -0,0 +1,3 @@
1
+ /** @type {Record<string, import('./question.js').Question>} */
2
+ export const questionClasses: Record<string, import("./question.js").Question>;
3
+ //# sourceMappingURL=questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["questions.js"],"names":[],"mappings":"AAsBA,+DAA+D;AAC/D,8BADW,MAAM,CAAC,MAAM,EAAE,OAAO,eAAe,EAAE,QAAQ,CAAC,CAkBxD"}
@@ -20,7 +20,7 @@ import ManageListQuestion from '../components/manage-list/question.js';
20
20
  // This looks a bit grim because so few of our
21
21
  // Questions overlap with Question correctly.
22
22
  // Maybe something to fix at some point
23
- /** @type {Record<string, import('./question').Question>} */
23
+ /** @type {Record<string, import('./question.js').Question>} */
24
24
  export const questionClasses = Object.freeze({
25
25
  [COMPONENT_TYPES.ADDRESS]: AddressQuestion,
26
26
  [COMPONENT_TYPES.CHECKBOX]: CheckboxQuestion,
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @typedef {((response: import('#journey-response').JourneyResponse) => boolean)} QuestionCondition
3
+ */
1
4
  /**
2
5
  * A value indicating the final question of a section has been reached
3
6
  *
@@ -12,10 +15,10 @@ export class Section {
12
15
  /**
13
16
  * Implementation of getNextQuestion given a list of questions
14
17
  *
15
- * @param {import('./section-types.d.ts').StaticGetNextQuestionParams} params
16
- * @returns {Question|Symbol|null}
18
+ * @param {import('#typedefs/section-types.d.ts').StaticGetNextQuestionParams} params
19
+ * @returns {import('./questions/question.js').Question|Symbol|null}
17
20
  */
18
- static getNextQuestion({ questions, questionFieldName, response, takeNextQuestion, reverse }: import("./section-types.d.ts").StaticGetNextQuestionParams): Question | Symbol | null;
21
+ static getNextQuestion({ questions, questionFieldName, response, takeNextQuestion, reverse }: import("#typedefs/section-types.d.ts").StaticGetNextQuestionParams): import("./questions/question.js").Question | Symbol | null;
19
22
  /**
20
23
  * creates an instance of a section
21
24
  * @param {string} name
@@ -31,9 +34,9 @@ export class Section {
31
34
  */
32
35
  segment: string;
33
36
  /**
34
- * @type {Array<Question>} - questions within the section
37
+ * @type {Array<import('./questions/question.js').Question>} - questions within the section
35
38
  */
36
- questions: Array<Question>;
39
+ questions: Array<import("./questions/question.js").Question>;
37
40
  /**
38
41
  * Add a condition to all questions in this section
39
42
  *
@@ -70,22 +73,22 @@ export class Section {
70
73
  endMultiQuestionCondition(conditionName: string): this;
71
74
  /**
72
75
  * Get the next question in this section given a questionParam (question fieldName)
73
- * @param {import('./section-types.d.ts').GetNextQuestionParams} params
74
- * @returns {Question|Symbol|null}
76
+ * @param {import('#typedefs/section-types.d.ts').GetNextQuestionParams} params
77
+ * @returns {import('./questions/question.js').Question|Symbol|null}
75
78
  */
76
- getNextQuestion(params: import("./section-types.d.ts").GetNextQuestionParams): Question | Symbol | null;
79
+ getNextQuestion(params: import("#typedefs/section-types.d.ts").GetNextQuestionParams): import("./questions/question.js").Question | Symbol | null;
77
80
  /**
78
81
  * checks answers on response to ensure that a answer is provided for each required question in the section
79
- * @param {JourneyResponse} journeyResponse
82
+ * @param {import('#journey-response').JourneyResponse} journeyResponse
80
83
  * @returns {SectionStatus}
81
84
  */
82
- getStatus(journeyResponse: JourneyResponse): SectionStatus;
85
+ getStatus(journeyResponse: import("#journey-response").JourneyResponse): SectionStatus;
83
86
  /**
84
87
  * checks answers on response and return true if the status of the section is complete
85
- * @param {JourneyResponse} journeyResponse
88
+ * @param {import('#journey-response').JourneyResponse} journeyResponse
86
89
  * @returns {boolean}
87
90
  */
88
- isComplete(journeyResponse: JourneyResponse): boolean;
91
+ isComplete(journeyResponse: import("#journey-response").JourneyResponse): boolean;
89
92
  #private;
90
93
  }
91
94
  export type SECTION_STATUS = SectionStatus;
@@ -100,8 +103,6 @@ export const SECTION_STATUS: Readonly<{
100
103
  IN_PROGRESS: "In progress";
101
104
  COMPLETE: "Completed";
102
105
  }>;
103
- export type Question = any;
104
- export type JourneyResponse = any;
105
- export type QuestionCondition = ((response: JourneyResponse) => boolean);
106
+ export type QuestionCondition = ((response: import("#journey-response").JourneyResponse) => boolean);
106
107
  export type SectionStatus = string;
107
108
  //# sourceMappingURL=section.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.d.ts","sourceRoot":"","sources":["section.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;GAIG;AACH,6BAFU,MAAM,CAEuC;AAEvD;;;GAGG;AACH;IAgNC;;;;;OAKG;IACH,8FAHW,OAAO,8BAA8B,EAAE,2BAA2B,GAChE,OAAO,yBAAyB,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,CAoBlE;IAvMD;;;;OAIG;IACH,kBAHW,MAAM,WACN,MAAM,EAKhB;IAxCD;;OAEG;IACH,MAFU,MAAM,CAEX;IAEL;;OAEG;IACH,SAFU,MAAM,CAER;IAER;;OAEG;IACH,WAFU,KAAK,CAAC,OAAO,yBAAyB,EAAE,QAAQ,CAAC,CAE5C;IA6Bf;;;;;OAKG;IACH,2CAHW,iBAAiB,GACf,IAAI,CAchB;IAED;;;;;OAKG;IACH,sBAJW,OAAO,yBAAyB,EAAE,QAAQ,sBAC1C,OAAO,iDAAiD,EAAE,iBAAiB,GACzE,IAAI,CAgBhB;IA8BD;;;;OAIG;IACH,qCAHW,iBAAiB,GACf,IAAI,CAahB;IAED,kFAoBC;IAED;;;;;OAKG;IACH,2CAJW,MAAM,yBACN,iBAAiB,GACf,IAAI,CAQhB;IAED;;;;OAIG;IACH,yCAHW,MAAM,GACJ,IAAI,CAQhB;IAED;;;;OAIG;IACH,wBAHW,OAAO,8BAA8B,EAAE,qBAAqB,GAC1D,OAAO,yBAAyB,EAAE,QAAQ,GAAC,MAAM,GAAC,IAAI,CAuBlE;IA4BD;;;;OAIG;IACH,2BAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,aAAa,CAoDzB;IAED;;;;OAIG;IACH,4BAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAInB;;CAKD;6BAOS,aAAa;AALvB;;GAEG;AAEH;;GAEG;AACH;;;;GAIG;gCA1UU,CAAC,CAAC,QAAQ,EAAE,OAAO,mBAAmB,EAAE,eAAe,KAAK,OAAO,CAAC;4BAgUpE,MAAM"}
package/src/section.js CHANGED
@@ -1,12 +1,10 @@
1
- /**
2
- * @typedef {import('./questions/question').Question} Question
3
- * @typedef {import('./journey/journey-response').JourneyResponse} JourneyResponse
4
- * @typedef {((response: JourneyResponse) => boolean)} QuestionCondition
5
- */
6
-
7
1
  import RequiredValidator from './validator/required-validator.js';
8
2
  import { answerObjectForManageList } from '#src/components/manage-list/utils.js';
9
3
 
4
+ /**
5
+ * @typedef {((response: import('#journey-response').JourneyResponse) => boolean)} QuestionCondition
6
+ */
7
+
10
8
  /**
11
9
  * A value indicating the final question of a section has been reached
12
10
  *
@@ -30,7 +28,7 @@ export class Section {
30
28
  segment;
31
29
 
32
30
  /**
33
- * @type {Array<Question>} - questions within the section
31
+ * @type {Array<import('./questions/question.js').Question>} - questions within the section
34
32
  */
35
33
  questions = [];
36
34
 
@@ -105,7 +103,7 @@ export class Section {
105
103
 
106
104
  /**
107
105
  * Apply conditions to the given question
108
- * @param {any} question
106
+ * @param {import('./questions/question.js').Question} question
109
107
  * @param [condition] - specific condition for this question
110
108
  */
111
109
  #applyConditions(question, condition) {
@@ -200,8 +198,8 @@ export class Section {
200
198
 
201
199
  /**
202
200
  * Get the next question in this section given a questionParam (question fieldName)
203
- * @param {import('./section-types.d.ts').GetNextQuestionParams} params
204
- * @returns {Question|Symbol|null}
201
+ * @param {import('#typedefs/section-types.d.ts').GetNextQuestionParams} params
202
+ * @returns {import('./questions/question.js').Question|Symbol|null}
205
203
  */
206
204
  getNextQuestion(params) {
207
205
  const { response, manageListQuestion, routeParams } = params;
@@ -229,8 +227,8 @@ export class Section {
229
227
  /**
230
228
  * Implementation of getNextQuestion given a list of questions
231
229
  *
232
- * @param {import('./section-types.d.ts').StaticGetNextQuestionParams} params
233
- * @returns {Question|Symbol|null}
230
+ * @param {import('#typedefs/section-types.d.ts').StaticGetNextQuestionParams} params
231
+ * @returns {import('./questions/question.js').Question|Symbol|null}
234
232
  */
235
233
  static getNextQuestion({ questions, questionFieldName, response, takeNextQuestion = false, reverse = false }) {
236
234
  const numberOfQuestions = questions.length;
@@ -254,7 +252,7 @@ export class Section {
254
252
 
255
253
  /**
256
254
  * checks answers on response to ensure that a answer is provided for each required question in the section
257
- * @param {JourneyResponse} journeyResponse
255
+ * @param {import('#journey-response').JourneyResponse} journeyResponse
258
256
  * @returns {SectionStatus}
259
257
  */
260
258
  getStatus(journeyResponse) {
@@ -311,7 +309,7 @@ export class Section {
311
309
 
312
310
  /**
313
311
  * checks answers on response and return true if the status of the section is complete
314
- * @param {JourneyResponse} journeyResponse
312
+ * @param {import('#journey-response').JourneyResponse} journeyResponse
315
313
  * @returns {boolean}
316
314
  */
317
315
  isComplete(journeyResponse) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-validator.d.ts","sourceRoot":"","sources":["address-validator.js"],"names":[],"mappings":"AAIO,4EAQN;AAGD,oCAAqC,GAAG,CAAC;AACzC,oCAAqC,CAAC,CAAC;AACvC,oCAAqC,GAAG,CAAC;AACzC,oCAAqC,CAAC,CAAC;AACvC,gCAAiC,GAAG,CAAC;AACrC,gCAAiC,CAAC,CAAC;AACnC,8BAA+B,GAAG,CAAC;AACnC,8BAA+B,CAAC,CAAC;AACjC,gCAAiC,CAAC,CAAC;AACnC,gCAAiC,CAAC,CAAC;AAEnC;;;GAGG;AACH;IACC;;;;OAIG;IACH,mBAFG;QAAqH,cAAc;0BAA5G,OAAO;0BAAgB,OAAO;sBAAY,OAAO;oBAAU,OAAO;sBAAY,OAAO;;KAAwB,EAKtI;IADA;sBAJyB,OAAO;sBAAgB,OAAO;kBAAY,OAAO;gBAAU,OAAO;kBAAY,OAAO;kBAIpE;IAG3C;;;OAGG;IACH,sBAFW,OAAO,0BAA0B,EAAE,QAAQ,iDAYrD;;CAqGD;;0BA1JyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-validator.d.ts","sourceRoot":"","sources":["base-validator.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IACC;;OAEG;IACH,cAFU,MAAM,CAEH;IAQb;;;;;;;OAOG;IAEH,sBALW;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,oBACnB,OAAO,gCAAgC,EAAE,eAAe,GACtD,OAAO,mBAAmB,EAAE,eAAe,GAAG,OAAO,mBAAmB,EAAE,eAAe,EAAE,CAKvG;IAED;;;;;OAKG;IACH,sBAEC;CACD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-required-validator.d.ts","sourceRoot":"","sources":["conditional-required-validator.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;GAGG;AACH;IAMC;;;OAGG;IACH,2BAFW,MAAM,EAQhB;IAED;;;OAGG;IACH,sBAFW,OAAO,kCAAkC,EAAE,eAAe,WAcpE;IAED,+DAEC;IAED,2FAKC;CACD;;;0BAzDyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation-checkbox-validator.d.ts","sourceRoot":"","sources":["confirmation-checkbox-validator.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH;IAMC;;;;;OAKG;IACH,4CAHG;QAAuB,YAAY,EAA3B,MAAM;QACS,YAAY,EAA3B,MAAM;KAChB,EAMA;IAFA,qBAAgC;IAIjC;;OAEG;IACH,wDAEC;CACD;;;0BAnCyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinates-validator.d.ts","sourceRoot":"","sources":["coordinates-validator.js"],"names":[],"mappings":"AAGA,uCAAwC,CAAC,CAAC;AAE1C;;;;GAIG;AACH;IACC;;;OAGG;IACH,sBAHW,eAAe,WACf,eAAe,EAMzB;IAFA,0BAAwB;IACxB,yBAAsB;IAGvB,0DAkCC;CACD;;;WAjDa,MAAM;eACN,MAAM;;0BARM,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-question-validator.d.ts","sourceRoot":"","sources":["cross-question-validator.js"],"names":[],"mappings":"AAGA;;GAEG;AACH;IAUC;;;;;;;;OAQG;IACH,kGAPG;QAAuB,mBAAmB,EAAlC,MAAM;QACyE,kBAAkB,EAAjG,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,KAAK,OAAO,CAAC,GAAE,IAAI;QACrD,aAAa;QACb,uBAAuB;KAChD,EAsBF;IArCD,qBAAqB;IACrB,qBADW,MAAM,CACG;IACpB,+EAA+E;IAC/E,oBADW,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,KAAK,OAAO,CAAC,CACxD;IACnB,sBAAsB;IACtB,eADW,OAAO,CACJ;IACd,sBAAsB;IACtB,yBADW,OAAO,CACM;IA8CxB;;;;;;;OAOG;IACH,sBAJW,OAAO,0BAA0B,EAAE,QAAQ,oBAC3C,OAAO,gCAAgC,EAAE,eAAe,GACtD,OAAO,mBAAmB,EAAE,eAAe,EAAE,CAuCzD;;CACD;;0BA1GyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-period-validator.d.ts","sourceRoot":"","sources":["date-period-validator.js"],"names":[],"mappings":"AAQA;;;;GAIG;AAEH;;;GAGG;AACH;IAIC;;;;;OAKG;IACH,wBAJW,MAAM,2BACN,sBAAsB,kBACtB,MAAM,EAgChB;IAvCD,qCAAqC;IACrC,wBADW,sBAAsB,CACV;IAoBtB,uBAAmG;IACnG,uBAAmG;IACnG,yBAAyG;IACzG,wBAAsG;IACtG,4BAAkH;IAClH,2BAA+G;IAC/G,6BACuF;IACvF,6BACuF;IACvF,8BACyF;IACzF,6BACuF;IACvF,4BAAkH;IAClH,0BAA4G;IAK7G;;;OAGG;IACH,sBAFW,OAAO,gCAAgC,EAAE,YAAY,iDAsB/D;IAED;;;;sDAuCC;IAED;;;;sDAwBC;IAED;;;;sDAuBC;;CA6BD;;;;;;0BAxMyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-time-validator.d.ts","sourceRoot":"","sources":["date-time-validator.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACC;;;;;;OAMG;IACH,4BALW,MAAM,mBACN,MAAM,2BACN,sBAAsB,sBACtB,MAAM,EAahB;IADA,uBAAoC;IAGrC;;;OAGG;IACH,sBAFW,OAAO,qCAAqC,EAAE,gBAAgB,iDAsCxE;CACD;;0BApEyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-validator.d.ts","sourceRoot":"","sources":["date-validator.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;GAGG;AACH;IAIC;;;;;OAKG;IACH,wBAJW,MAAM,2BACN,sBAAsB,kBACtB,MAAM,EAiChB;IAxCD,qCAAqC;IACrC,wBADW,sBAAsB,CACV;IAqBtB,uBAAmG;IACnG,uBAAmG;IACnG,yBAAyG;IACzG,wBAAsG;IACtG,4BAAkH;IAClH,2BAA+G;IAC/G,6BACuF;IACvF,6BACuF;IACvF,8BACyF;IACzF,6BACuF;IACvF,4BAAkH;IAClH,0BAA4G;IAS7G;;;OAGG;IACH,sBAFW,OAAO,gCAAgC,EAAE,YAAY,iDA0H/D;;CA6BD;;;;;;;0BAtNyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-upload-validator.d.ts","sourceRoot":"","sources":["document-upload-validator.js"],"names":[],"mappings":"AAGA;IACC;;;OAGG;IACH,uBAHW,MAAM,iBACN,MAAM,EAMhB;IAFA,kBAA0B;IAI3B,0DAYC;CACD;;0BA3ByB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-validator.d.ts","sourceRoot":"","sources":["email-validator.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH;IACC;;;;;OAKG;IACH,mDAJG;QAAwC,OAAO;QACvB,YAAY;QACZ,SAAS;KACnC,EAcA;IAVA;;;;;;;;;;;;;;;;;;;;;;;;;MAMC;IAGD,8BAA0B;IAG3B,wEAIC;CACD;;;;;;;;;;;;;;;;;;;;;;;;0BAtCyB,qBAAqB"}
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @typedef {Object} Regex
3
3
  * @property {String | RegExp} regex
4
- * @property {String} regexMessage
4
+ * @property {string} regexMessage
5
5
  */
6
6
  /**
7
7
  * @typedef {Object} MinLength
8
8
  * @property {Number} minLength
9
- * @property {String} minLengthMessage
9
+ * @property {string} minLengthMessage
10
10
  */
11
11
  /**
12
12
  * @typedef {Object} MaxLength
13
13
  * @property {Number} maxLength
14
- * @property {String} maxLengthMessage
14
+ * @property {string} maxLengthMessage
15
15
  */
16
16
  /**
17
17
  * @typedef {Object} FieldBase
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-field-input-validator.d.ts","sourceRoot":"","sources":["multi-field-input-validator.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;IACC;;;;OAIG;IACH,0CAHG;QAAyB,MAAM;QACP,eAAe;KAAC,EAQ1C;IAFA,gBAAoB;IACpB,wBAAwE;IAGzE;;OAEG;IAEH,0DA8BC;IAKD;;;;OAIG;IACH,gCAHW,MAAM,GACJ,OAAO,CAQnB;CACD;;;WA3Ga,SAAS,MAAM;kBACf,MAAM;;;;sBAMN,MAAM;;;;sBAMN,MAAM;;;eAKN,MAAM;;;;;4BAOP,SAAS,GAAG;IACpB,QAAQ,EAAE,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,CAAA;CACrB;4BAIS,SAAS,GAAG;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;oBAIS,aAAa,GAAG,aAAa;0BA1ChB,qBAAqB"}
@@ -4,19 +4,19 @@ import BaseValidator from './base-validator.js';
4
4
  /**
5
5
  * @typedef {Object} Regex
6
6
  * @property {String | RegExp} regex
7
- * @property {String} regexMessage
7
+ * @property {string} regexMessage
8
8
  */
9
9
 
10
10
  /**
11
11
  * @typedef {Object} MinLength
12
12
  * @property {Number} minLength
13
- * @property {String} minLengthMessage
13
+ * @property {string} minLengthMessage
14
14
  */
15
15
 
16
16
  /**
17
17
  * @typedef {Object} MaxLength
18
18
  * @property {Number} maxLength
19
- * @property {String} maxLengthMessage
19
+ * @property {string} maxLengthMessage
20
20
  */
21
21
 
22
22
  /**
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @typedef {Object} MinValue
3
3
  * @property {Number} min
4
- * @property {String} minMessage
4
+ * @property {string} minMessage
5
5
  */
6
6
  /**
7
7
  * @typedef {Object} MaxValue
8
8
  * @property {Number} max
9
- * @property {String} maxMessage
9
+ * @property {string} maxMessage
10
10
  */
11
11
  export class NumericValidator extends BaseValidator {
12
12
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-validator.d.ts","sourceRoot":"","sources":["numeric-validator.js"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH;;;;GAIG;AAEH;IACC;;;;;;;;;OASG;IACH,mFARG;QAAwB,GAAG;QACH,UAAU;QACV,GAAG;QACH,UAAU;QACV,KAAK;QACL,YAAY;QACZ,SAAS;KAAC,EAWpC;IAPA,wBAAc;IACd,mBAAmE;IACnE,wBAAc;IACd,mBAAkE;IAClE,0BAAkB;IAClB,qBAA0D;IAC1D,8BAA0B;IAG3B,wEAgBC;CACD;;;;gBAhDa,MAAM;;;;gBAMN,MAAM;;0BAXM,qBAAqB"}
@@ -5,13 +5,13 @@ import BaseValidator from './base-validator.js';
5
5
  /**
6
6
  * @typedef {Object} MinValue
7
7
  * @property {Number} min
8
- * @property {String} minMessage
8
+ * @property {string} minMessage
9
9
  */
10
10
 
11
11
  /**
12
12
  * @typedef {Object} MaxValue
13
13
  * @property {Number} max
14
- * @property {String} maxMessage
14
+ * @property {string} maxMessage
15
15
  */
16
16
 
17
17
  export class NumericValidator extends BaseValidator {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-validator.d.ts","sourceRoot":"","sources":["required-validator.js"],"names":[],"mappings":"AAIA;;;GAGG;AACH;IAMC;;;OAGG;IACH,2BAFW,MAAM,EAQhB;IAED;;;OAGG;IACH,sBAFW,OAAO,0BAA0B,EAAE,QAAQ,+CAIrD;CAKD;;0BAnCyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"same-answer-validator.d.ts","sourceRoot":"","sources":["same-answer-validator.js"],"names":[],"mappings":"AAGA;;GAEG;AACH;IACC;;;OAGG;IAEH,iCAJW,MAAM,EAAE,iBACR,MAAM,EAOhB;IAFA,8BAAoD;IAIrD;;;OAGG;IACH,wEAQC;CACD;;0BA9ByB,qBAAqB"}
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @typedef {Object} MinLength
3
3
  * @property {Number} minLength
4
- * @property {String} [minLengthMessage]
4
+ * @property {string} [minLengthMessage]
5
5
  */
6
6
  /**
7
7
  * @typedef {Object} MaxLength
8
8
  * @property {Number} maxLength
9
- * @property {String} [maxLengthMessage]
9
+ * @property {string} [maxLengthMessage]
10
10
  */
11
11
  /**
12
12
  * @typedef {Object} Regex
13
13
  * @property {String | RegExp} regex
14
- * @property {String} [regexMessage]
14
+ * @property {string} [regexMessage]
15
15
  */
16
16
  export class StringValidator extends BaseValidator {
17
17
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-validator.d.ts","sourceRoot":"","sources":["string-validator.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;IAcC;;;;;;OAMG;IACH,yDALG;QAA2B,SAAS;QACT,SAAS;QACb,KAAK;QACJ,SAAS;KAAC,EAmBpC;IArCD;;;MAGE;IACF;;;MAGE;IACF;;;MAGE;IAyBD,8BAA0B;IAG3B,wEAkBC;CACD;;;;;;;;;;;WA/Da,SAAS,MAAM;;;0BAfH,qBAAqB"}
@@ -4,19 +4,19 @@ import BaseValidator from './base-validator.js';
4
4
  /**
5
5
  * @typedef {Object} MinLength
6
6
  * @property {Number} minLength
7
- * @property {String} [minLengthMessage]
7
+ * @property {string} [minLengthMessage]
8
8
  */
9
9
 
10
10
  /**
11
11
  * @typedef {Object} MaxLength
12
12
  * @property {Number} maxLength
13
- * @property {String} [maxLengthMessage]
13
+ * @property {string} [maxLengthMessage]
14
14
  */
15
15
 
16
16
  /**
17
17
  * @typedef {Object} Regex
18
18
  * @property {String | RegExp} regex
19
- * @property {String} [regexMessage]
19
+ * @property {string} [regexMessage]
20
20
  */
21
21
 
22
22
  export class StringValidator extends BaseValidator {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-option-entry-validator.d.ts","sourceRoot":"","sources":["unit-option-entry-validator.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACC;;;;;;;;OAQG;IAEH,oEARG;QAAwB,YAAY;QACZ,IAAI;QACJ,GAAG;QACH,GAAG;QACJ,KAAK;QACJ,YAAY;KAAC,EAWvC;IALA,aAA2B;IAC3B,wBAAc;IACd,wBAAc;IACd,WAAkB;IAClB,qBAA0D;IAG3D;;;OAGG;IACH,sBAFW,OAAO,6CAA6C,EAAE,uBAAuB,WA4CvF;IAED,2FAKC;CACD;;0BAlFyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valid-option-validator.d.ts","sourceRoot":"","sources":["valid-option-validator.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACC;;;OAGG;IACH,2BAFW,MAAM,EAUhB;IAED;;;OAGG;IACH,sBAFW,OAAO,kCAAkC,EAAE,OAAO,+CAU5D;CACD;;0BAnCyB,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-error-handler.d.ts","sourceRoot":"","sources":["validation-error-handler.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;GAEG;AACH,sDAFU,cAAc,CAkBtB;AAQK,uDAJI,OAAO,mBAAmB,EAAE,aAAa,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAAC,mBACtF,cAAc,GACZ,OAAO,SAAS,EAAE,OAAO,CA2BrC;AAED,+DAAoE;6BA3DvD;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,EAAE;;;;6BAE9B,CAAC,MAAM,EAAE,uBAAuB,KAAK,cAAc"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["validator.js"],"names":[],"mappings":"AA4BA,oDACe,QAAG,EAAE,QAAG,EAAE,SAAI,kBAM5B;;AAjCD,wCAAwC;AACxC,wBADW,OAAO,SAAS,EAAE,OAAO,CAsBlC"}
package/test/journey.js CHANGED
@@ -30,6 +30,8 @@ export function createJourney(questions, response) {
30
30
  .addQuestion(questions.hotelAddress)
31
31
  .addQuestion(questions.luggageWeight)
32
32
  .addQuestion(questions.contactEmail)
33
+ .addQuestion(questions.favouriteActivityReason)
34
+ .addQuestion(questions.travelRequirements)
33
35
  .addQuestion(
34
36
  questions.travelCompanions,
35
37
  new ManageListSection().addQuestion(questions.travelCompanionName).addQuestion(questions.travelCompanionEmail)
package/test/questions.js CHANGED
@@ -4,7 +4,7 @@ import { questionClasses } from '../src/questions/questions.js';
4
4
  import EmailValidator from '../src/validator/email-validator.js';
5
5
 
6
6
  /**
7
- * @typedef {import('../src/questions/question-props.js').QuestionProps} Props
7
+ * @typedef {import('#typedefs/question-props.d.ts').QuestionProps} Props
8
8
  */
9
9
 
10
10
  /** @type {Record<string, Props>} */
@@ -195,6 +195,54 @@ export const questionProps = {
195
195
  question: 'Travel Companion Email',
196
196
  fieldName: 'travelCompanionEmail',
197
197
  url: 'travel-companion-email'
198
+ },
199
+ // Test questions for conditional reveal functionality
200
+ favouriteActivityReason: {
201
+ type: COMPONENT_TYPES.RADIO,
202
+ title: 'Favourite Activity Reason',
203
+ question: 'Why do you want to do your favourite activity?',
204
+ fieldName: 'favouriteActivityReason',
205
+ url: 'favourite-activity-reason',
206
+ label: 'Select a reason',
207
+ options: [
208
+ {
209
+ value: 'relaxation',
210
+ text: 'Relaxation',
211
+ conditional: {
212
+ question: 'How do you like to relax?',
213
+ type: 'text',
214
+ fieldName: 'relaxationDetails',
215
+ label: 'Details:'
216
+ }
217
+ },
218
+ { value: 'adventure', text: 'Adventure' },
219
+ { value: 'culture', text: 'Culture' }
220
+ ]
221
+ },
222
+ travelRequirements: {
223
+ type: COMPONENT_TYPES.CHECKBOX,
224
+ title: 'Travel Requirements',
225
+ question: 'What special requirements do you have?',
226
+ fieldName: 'travelRequirements',
227
+ url: 'travel-requirements',
228
+ label: 'Select all that apply',
229
+ options: [
230
+ {
231
+ value: 'dietary',
232
+ text: 'Dietary requirements',
233
+ conditional: {
234
+ question: 'Please describe your dietary requirements',
235
+ type: 'text',
236
+ fieldName: 'dietaryDetails',
237
+ label: 'Dietary details:'
238
+ }
239
+ },
240
+ {
241
+ value: 'mobility',
242
+ text: 'Mobility assistance'
243
+ },
244
+ { value: 'medical', text: 'Medical needs' }
245
+ ]
198
246
  }
199
247
  };
200
248
 
@@ -216,6 +264,8 @@ export const questionsInOrder = [
216
264
  questionProps.hotelAddress,
217
265
  questionProps.luggageWeight,
218
266
  questionProps.contactEmail,
267
+ questionProps.favouriteActivityReason,
268
+ questionProps.travelRequirements,
219
269
  questionProps.travelCompanions
220
270
  ];
221
271
 
@@ -10,7 +10,7 @@ import { mockRandomUUID } from '#test/mock/uuid.js';
10
10
  import { createJourney as createTestJourney, JOURNEY_ID } from '#test/journey.js';
11
11
 
12
12
  /**
13
- * @type {import('../src/questions/question-types.d.ts').SecondaryAction[]}
13
+ * @type {import('#typedefs/question-types.d.ts').SecondaryAction[]}
14
14
  */
15
15
  const testSecondaryActions = [
16
16
  {
@@ -196,6 +196,28 @@
196
196
  <a class="govuk-link" href="questions/contact-email">Answer<span class="govuk-visually-hidden"> What is your email address for booking confirmations?</span></a>
197
197
  </dd>
198
198
  </div>
199
+ <div class="govuk-summary-list__row">
200
+ <dt class="govuk-summary-list__key">
201
+ Favourite Activity Reason
202
+ </dt>
203
+ <dd class="govuk-summary-list__value">
204
+ Not started
205
+ </dd>
206
+ <dd class="govuk-summary-list__actions">
207
+ <a class="govuk-link" href="questions/favourite-activity-reason">Answer<span class="govuk-visually-hidden"> Why do you want to do your favourite activity?</span></a>
208
+ </dd>
209
+ </div>
210
+ <div class="govuk-summary-list__row">
211
+ <dt class="govuk-summary-list__key">
212
+ Travel Requirements
213
+ </dt>
214
+ <dd class="govuk-summary-list__value">
215
+ Not started
216
+ </dd>
217
+ <dd class="govuk-summary-list__actions">
218
+ <a class="govuk-link" href="questions/travel-requirements">Answer<span class="govuk-visually-hidden"> What special requirements do you have?</span></a>
219
+ </dd>
220
+ </div>
199
221
  <div class="govuk-summary-list__row">
200
222
  <dt class="govuk-summary-list__key">
201
223
  Travel Companions
@@ -196,6 +196,28 @@
196
196
  <a class="govuk-link" href="questions/contact-email">Change<span class="govuk-visually-hidden"> What is your email address for booking confirmations?</span></a>
197
197
  </dd>
198
198
  </div>
199
+ <div class="govuk-summary-list__row">
200
+ <dt class="govuk-summary-list__key">
201
+ Favourite Activity Reason
202
+ </dt>
203
+ <dd class="govuk-summary-list__value">
204
+ Relaxation<br>Details: test conditional answer
205
+ </dd>
206
+ <dd class="govuk-summary-list__actions">
207
+ <a class="govuk-link" href="questions/favourite-activity-reason">Change<span class="govuk-visually-hidden"> Why do you want to do your favourite activity?</span></a>
208
+ </dd>
209
+ </div>
210
+ <div class="govuk-summary-list__row">
211
+ <dt class="govuk-summary-list__key">
212
+ Travel Requirements
213
+ </dt>
214
+ <dd class="govuk-summary-list__value">
215
+ Dietary requirements<br>Dietary details: test conditional answer
216
+ </dd>
217
+ <dd class="govuk-summary-list__actions">
218
+ <a class="govuk-link" href="questions/travel-requirements">Change<span class="govuk-visually-hidden"> What special requirements do you have?</span></a>
219
+ </dd>
220
+ </div>
199
221
  <div class="govuk-summary-list__row">
200
222
  <dt class="govuk-summary-list__key">
201
223
  Travel Companions