@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.
- package/.gitattributes +3 -0
- package/.prettierrc +1 -0
- package/README.md +123 -4
- package/package.json +6 -4
- package/{types/src → src}/components/address/question.d.ts +6 -2
- package/src/components/address/question.d.ts.map +1 -0
- package/src/components/address/question.js +7 -19
- package/{types/src → src}/components/boolean/question.d.ts +2 -2
- package/src/components/boolean/question.d.ts.map +1 -0
- package/src/components/boolean/question.js +1 -1
- package/src/components/checkbox/question.d.ts +9 -0
- package/src/components/checkbox/question.d.ts.map +1 -0
- package/src/components/checkbox/question.js +37 -54
- package/src/components/checkbox/question.test.js +170 -27
- package/{types/src → src}/components/date/question.d.ts +2 -2
- package/src/components/date/question.d.ts.map +1 -0
- package/src/components/date/question.js +7 -16
- package/{types/src → src}/components/date-period/question.d.ts +12 -4
- package/src/components/date-period/question.d.ts.map +1 -0
- package/src/components/date-period/question.js +2 -3
- package/{types/src → src}/components/date-time/question.d.ts +2 -2
- package/src/components/date-time/question.d.ts.map +1 -0
- package/src/components/date-time/question.js +5 -14
- package/src/components/email/question.d.ts +23 -0
- package/src/components/email/question.d.ts.map +1 -0
- package/src/components/email/question.js +1 -9
- package/src/components/manage-list/answer-summary-list.njk +1 -1
- package/src/components/manage-list/manage-list-actions.d.ts.map +1 -0
- package/src/components/manage-list/manage-list-section.d.ts.map +1 -0
- package/{types/src → src}/components/manage-list/question.d.ts +6 -3
- package/src/components/manage-list/question.d.ts.map +1 -0
- package/src/components/manage-list/question.js +5 -2
- package/{types/src → src}/components/manage-list/utils.d.ts +3 -3
- package/src/components/manage-list/utils.d.ts.map +1 -0
- package/src/components/manage-list/utils.js +2 -2
- package/src/components/multi-field-input/question.d.ts +52 -0
- package/src/components/multi-field-input/question.d.ts.map +1 -0
- package/src/components/multi-field-input/question.js +5 -13
- package/src/components/number-entry/question.d.ts +12 -0
- package/src/components/number-entry/question.d.ts.map +1 -0
- package/src/components/number-entry/question.js +4 -22
- package/src/components/radio/question.d.ts +11 -0
- package/src/components/radio/question.d.ts.map +1 -0
- package/src/components/radio/question.js +30 -51
- package/src/components/radio/question.test.js +139 -60
- package/src/components/select/question.d.ts +12 -0
- package/src/components/select/question.d.ts.map +1 -0
- package/src/components/select/question.js +5 -48
- package/{types/src → src}/components/single-line-input/question.d.ts +2 -2
- package/src/components/single-line-input/question.d.ts.map +1 -0
- package/src/components/single-line-input/question.js +2 -2
- package/{types/src → src}/components/text-entry/question.d.ts +3 -3
- package/src/components/text-entry/question.d.ts.map +1 -0
- package/src/components/text-entry/question.js +2 -2
- package/{types/src → src}/components/text-entry-redact/question.d.ts +8 -9
- package/src/components/text-entry-redact/question.d.ts.map +1 -0
- package/src/components/text-entry-redact/question.js +5 -2
- package/{types/src → src}/components/unit-option-entry/question.d.ts +12 -8
- package/src/components/unit-option-entry/question.d.ts.map +1 -0
- package/src/components/unit-option-entry/question.js +5 -6
- package/src/components/utils/component-types.d.ts.map +1 -0
- package/src/components/utils/persisted-number-answer.d.ts.map +1 -0
- package/src/components/utils/question-has-answer.d.ts.map +1 -0
- package/src/components/utils/question-has-answer.js +1 -1
- package/src/components/utils/question-utils.d.ts +33 -0
- package/src/components/utils/question-utils.d.ts.map +1 -0
- package/src/components/utils/question-utils.js +31 -2
- package/src/components/utils/question-utils.test.js +89 -2
- package/{types/src → src}/controller.d.ts +2 -7
- package/src/controller.d.ts.map +1 -0
- package/src/controller.js +3 -10
- package/{types/src → src}/index.d.ts +4 -3
- package/src/index.d.ts.map +1 -0
- package/src/index.js +6 -4
- package/src/journey/journey-response.d.ts +28 -0
- package/src/journey/journey-response.d.ts.map +1 -0
- package/src/journey/journey-response.js +4 -8
- package/{types/src → src}/journey/journey.d.ts +8 -8
- package/src/journey/journey.d.ts.map +1 -0
- package/src/journey/journey.js +6 -6
- package/src/lib/address-utils.d.ts.map +1 -0
- package/src/lib/address.d.ts.map +1 -0
- package/src/lib/date-utils.d.ts.map +1 -0
- package/src/lib/session-answer-store.d.ts.map +1 -0
- package/src/lib/utils.d.ts.map +1 -0
- package/src/lib/uuid.d.ts.map +1 -0
- package/src/middleware/build-get-journey.d.ts.map +1 -0
- package/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
- package/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
- package/src/middleware/redirect-to-unanswered-question.js +1 -1
- package/src/questions/create-questions.d.ts +18 -0
- package/src/questions/create-questions.d.ts.map +1 -0
- package/src/questions/create-questions.js +3 -3
- package/{types/src → src}/questions/options-question.d.ts +7 -7
- package/src/questions/options-question.d.ts.map +1 -0
- package/src/questions/options-question.js +29 -4
- package/src/questions/options-question.test.js +106 -0
- package/{types/src → src}/questions/question.d.ts +48 -79
- package/src/questions/question.d.ts.map +1 -0
- package/src/questions/question.js +83 -60
- package/src/questions/question.test.js +86 -0
- package/src/questions/questions.d.ts +3 -0
- package/src/questions/questions.d.ts.map +1 -0
- package/src/questions/questions.js +1 -1
- package/{types/src → src}/section.d.ts +16 -15
- package/src/section.d.ts.map +1 -0
- package/src/section.js +12 -14
- package/src/validator/address-validator.d.ts.map +1 -0
- package/src/validator/base-validator.d.ts.map +1 -0
- package/src/validator/conditional-required-validator.d.ts.map +1 -0
- package/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
- package/src/validator/coordinates-validator.d.ts.map +1 -0
- package/src/validator/cross-question-validator.d.ts.map +1 -0
- package/src/validator/date-period-validator.d.ts.map +1 -0
- package/src/validator/date-time-validator.d.ts.map +1 -0
- package/src/validator/date-validator.d.ts.map +1 -0
- package/src/validator/document-upload-validator.d.ts.map +1 -0
- package/src/validator/email-validator.d.ts.map +1 -0
- package/{types/src → src}/validator/multi-field-input-validator.d.ts +3 -3
- package/src/validator/multi-field-input-validator.d.ts.map +1 -0
- package/src/validator/multi-field-input-validator.js +3 -3
- package/{types/src → src}/validator/numeric-validator.d.ts +2 -2
- package/src/validator/numeric-validator.d.ts.map +1 -0
- package/src/validator/numeric-validator.js +2 -2
- package/src/validator/required-validator.d.ts.map +1 -0
- package/src/validator/same-answer-validator.d.ts.map +1 -0
- package/{types/src → src}/validator/string-validator.d.ts +3 -3
- package/src/validator/string-validator.d.ts.map +1 -0
- package/src/validator/string-validator.js +3 -3
- package/src/validator/unit-option-entry-validator.d.ts.map +1 -0
- package/src/validator/valid-option-validator.d.ts.map +1 -0
- package/src/validator/validation-error-handler.d.ts.map +1 -0
- package/src/validator/validator.d.ts.map +1 -0
- package/test/journey.js +2 -0
- package/test/questions.js +51 -1
- package/test/secondary-actions.test.js +1 -1
- package/test/snapshots/check-your-answers-not-started.html +22 -0
- package/test/snapshots/check-your-answers-with-answers.html +22 -0
- package/test/snapshots/favourite-activity-reason.html +54 -0
- package/test/snapshots/travel-requirements.html +48 -0
- package/test/utils/question-test-utils.js +36 -6
- package/tsconfig.json +11 -4
- package/{types/src/questions → typedefs}/question-props.d.ts +28 -26
- package/typedefs/question-types.d.ts +141 -0
- package/{src → typedefs}/section-types.d.ts +1 -1
- package/typedefs/section-types.js +1 -0
- package/move-types.js +0 -12
- package/src/questions/question-props.d.ts +0 -295
- package/src/questions/question-types.d.ts +0 -86
- package/types/commitlint.config.d.ts +0 -7
- package/types/commitlint.config.d.ts.map +0 -1
- package/types/eslint.config.d.ts +0 -97
- package/types/eslint.config.d.ts.map +0 -1
- package/types/move-types.d.ts +0 -2
- package/types/move-types.d.ts.map +0 -1
- package/types/src/components/address/question.d.ts.map +0 -1
- package/types/src/components/boolean/question.d.ts.map +0 -1
- package/types/src/components/checkbox/question.d.ts +0 -33
- package/types/src/components/checkbox/question.d.ts.map +0 -1
- package/types/src/components/date/question.d.ts.map +0 -1
- package/types/src/components/date-period/question.d.ts.map +0 -1
- package/types/src/components/date-time/question.d.ts.map +0 -1
- package/types/src/components/email/question.d.ts +0 -35
- package/types/src/components/email/question.d.ts.map +0 -1
- package/types/src/components/manage-list/manage-list-actions.d.ts.map +0 -1
- package/types/src/components/manage-list/manage-list-section.d.ts.map +0 -1
- package/types/src/components/manage-list/question.d.ts.map +0 -1
- package/types/src/components/manage-list/utils.d.ts.map +0 -1
- package/types/src/components/multi-field-input/question.d.ts +0 -64
- package/types/src/components/multi-field-input/question.d.ts.map +0 -1
- package/types/src/components/number-entry/question.d.ts +0 -36
- package/types/src/components/number-entry/question.d.ts.map +0 -1
- package/types/src/components/radio/question.d.ts +0 -23
- package/types/src/components/radio/question.d.ts.map +0 -1
- package/types/src/components/select/question.d.ts +0 -22
- package/types/src/components/select/question.d.ts.map +0 -1
- package/types/src/components/single-line-input/question.d.ts.map +0 -1
- package/types/src/components/text-entry/question.d.ts.map +0 -1
- package/types/src/components/text-entry-redact/question.d.ts.map +0 -1
- package/types/src/components/unit-option-entry/question.d.ts.map +0 -1
- package/types/src/components/utils/component-types.d.ts.map +0 -1
- package/types/src/components/utils/persisted-number-answer.d.ts.map +0 -1
- package/types/src/components/utils/question-has-answer.d.ts.map +0 -1
- package/types/src/components/utils/question-utils.d.ts +0 -15
- package/types/src/components/utils/question-utils.d.ts.map +0 -1
- package/types/src/controller.d.ts.map +0 -1
- package/types/src/index.d.ts.map +0 -1
- package/types/src/journey/journey-response.d.ts +0 -32
- package/types/src/journey/journey-response.d.ts.map +0 -1
- package/types/src/journey/journey-types.d.ts +0 -28
- package/types/src/journey/journey-types.d.ts.map +0 -1
- package/types/src/journey/journey.d.ts.map +0 -1
- package/types/src/lib/address-utils.d.ts.map +0 -1
- package/types/src/lib/address.d.ts.map +0 -1
- package/types/src/lib/date-utils.d.ts.map +0 -1
- package/types/src/lib/session-answer-store.d.ts.map +0 -1
- package/types/src/lib/utils.d.ts.map +0 -1
- package/types/src/lib/uuid.d.ts.map +0 -1
- package/types/src/middleware/build-get-journey.d.ts.map +0 -1
- package/types/src/middleware/redirect-to-unanswered-question.d.ts +0 -12
- package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +0 -1
- package/types/src/questions/create-questions.d.ts +0 -18
- package/types/src/questions/create-questions.d.ts.map +0 -1
- package/types/src/questions/options-question.d.ts.map +0 -1
- package/types/src/questions/question-props.d.ts.map +0 -1
- package/types/src/questions/question-types.d.ts +0 -86
- package/types/src/questions/question-types.d.ts.map +0 -1
- package/types/src/questions/question.d.ts.map +0 -1
- package/types/src/questions/questions.d.ts +0 -3
- package/types/src/questions/questions.d.ts.map +0 -1
- package/types/src/section.d.ts.map +0 -1
- package/types/src/validator/address-validator.d.ts.map +0 -1
- package/types/src/validator/base-validator.d.ts.map +0 -1
- package/types/src/validator/conditional-required-validator.d.ts.map +0 -1
- package/types/src/validator/confirmation-checkbox-validator.d.ts.map +0 -1
- package/types/src/validator/coordinates-validator.d.ts.map +0 -1
- package/types/src/validator/cross-question-validator.d.ts.map +0 -1
- package/types/src/validator/date-period-validator.d.ts.map +0 -1
- package/types/src/validator/date-time-validator.d.ts.map +0 -1
- package/types/src/validator/date-validator.d.ts.map +0 -1
- package/types/src/validator/document-upload-validator.d.ts.map +0 -1
- package/types/src/validator/email-validator.d.ts.map +0 -1
- package/types/src/validator/multi-field-input-validator.d.ts.map +0 -1
- package/types/src/validator/numeric-validator.d.ts.map +0 -1
- package/types/src/validator/required-validator.d.ts.map +0 -1
- package/types/src/validator/same-answer-validator.d.ts.map +0 -1
- package/types/src/validator/string-validator.d.ts.map +0 -1
- package/types/src/validator/unit-option-entry-validator.d.ts.map +0 -1
- package/types/src/validator/valid-option-validator.d.ts.map +0 -1
- package/types/src/validator/validation-error-handler.d.ts.map +0 -1
- package/types/src/validator/validator.d.ts.map +0 -1
- /package/{types/src → src}/components/manage-list/manage-list-actions.d.ts +0 -0
- /package/{types/src → src}/components/manage-list/manage-list-section.d.ts +0 -0
- /package/{types/src → src}/components/utils/component-types.d.ts +0 -0
- /package/{types/src → src}/components/utils/persisted-number-answer.d.ts +0 -0
- /package/{types/src → src}/components/utils/question-has-answer.d.ts +0 -0
- /package/{types/src → src}/lib/address-utils.d.ts +0 -0
- /package/{types/src → src}/lib/address.d.ts +0 -0
- /package/{types/src → src}/lib/date-utils.d.ts +0 -0
- /package/{types/src → src}/lib/session-answer-store.d.ts +0 -0
- /package/{types/src → src}/lib/utils.d.ts +0 -0
- /package/{types/src → src}/lib/uuid.d.ts +0 -0
- /package/{types/src → src}/middleware/build-get-journey.d.ts +0 -0
- /package/{types/src → src}/validator/address-validator.d.ts +0 -0
- /package/{types/src → src}/validator/base-validator.d.ts +0 -0
- /package/{types/src → src}/validator/conditional-required-validator.d.ts +0 -0
- /package/{types/src → src}/validator/confirmation-checkbox-validator.d.ts +0 -0
- /package/{types/src → src}/validator/coordinates-validator.d.ts +0 -0
- /package/{types/src → src}/validator/cross-question-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-period-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-time-validator.d.ts +0 -0
- /package/{types/src → src}/validator/date-validator.d.ts +0 -0
- /package/{types/src → src}/validator/document-upload-validator.d.ts +0 -0
- /package/{types/src → src}/validator/email-validator.d.ts +0 -0
- /package/{types/src → src}/validator/required-validator.d.ts +0 -0
- /package/{types/src → src}/validator/same-answer-validator.d.ts +0 -0
- /package/{types/src → src}/validator/unit-option-entry-validator.d.ts +0 -0
- /package/{types/src → src}/validator/valid-option-validator.d.ts +0 -0
- /package/{types/src → src}/validator/validation-error-handler.d.ts +0 -0
- /package/{types/src → src}/validator/validator.d.ts +0 -0
- /package/{src/journey → typedefs}/journey-types.d.ts +0 -0
- /package/{src/journey → typedefs}/journey-types.js +0 -0
- /package/{src/questions → typedefs}/question-props.js +0 -0
- /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 @@
|
|
|
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('
|
|
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("
|
|
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('
|
|
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("
|
|
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
|
|
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 {
|
|
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('
|
|
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('
|
|
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 {
|
|
4
|
+
* @property {string} regexMessage
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} MinLength
|
|
8
8
|
* @property {Number} minLength
|
|
9
|
-
* @property {
|
|
9
|
+
* @property {string} minLengthMessage
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {Object} MaxLength
|
|
13
13
|
* @property {Number} maxLength
|
|
14
|
-
* @property {
|
|
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 {
|
|
7
|
+
* @property {string} regexMessage
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {Object} MinLength
|
|
12
12
|
* @property {Number} minLength
|
|
13
|
-
* @property {
|
|
13
|
+
* @property {string} minLengthMessage
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @typedef {Object} MaxLength
|
|
18
18
|
* @property {Number} maxLength
|
|
19
|
-
* @property {
|
|
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 {
|
|
4
|
+
* @property {string} minMessage
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} MaxValue
|
|
8
8
|
* @property {Number} max
|
|
9
|
-
* @property {
|
|
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 {
|
|
8
|
+
* @property {string} minMessage
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {Object} MaxValue
|
|
13
13
|
* @property {Number} max
|
|
14
|
-
* @property {
|
|
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 {
|
|
4
|
+
* @property {string} [minLengthMessage]
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} MaxLength
|
|
8
8
|
* @property {Number} maxLength
|
|
9
|
-
* @property {
|
|
9
|
+
* @property {string} [maxLengthMessage]
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {Object} Regex
|
|
13
13
|
* @property {String | RegExp} regex
|
|
14
|
-
* @property {
|
|
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 {
|
|
7
|
+
* @property {string} [minLengthMessage]
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {Object} MaxLength
|
|
12
12
|
* @property {Number} maxLength
|
|
13
|
-
* @property {
|
|
13
|
+
* @property {string} [maxLengthMessage]
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @typedef {Object} Regex
|
|
18
18
|
* @property {String | RegExp} regex
|
|
19
|
-
* @property {
|
|
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('
|
|
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('
|
|
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
|