@planning-inspectorate/dynamic-forms 3.6.1 → 3.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/dynamic-forms",
3
- "version": "3.6.1",
3
+ "version": "3.7.0",
4
4
  "description": "This package is for building GDS forms using a configuration-based approach.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -48,8 +48,8 @@
48
48
  text: labels.start
49
49
  }
50
50
  },
51
- hint: question.hintStart and {
52
- text: question.hintStart
51
+ hint: hintStart and {
52
+ text: hintStart
53
53
  },
54
54
  errorMessage: errorSummary and {
55
55
  text: errors[question.fieldName].msg or errors[startFieldName].msg or errors[startDayFieldName].msg or errors[startMonthFieldName].msg or errors[startYearFieldName].msg
@@ -86,8 +86,8 @@
86
86
  text: labels.end
87
87
  }
88
88
  },
89
- hint: question.hintEnd and {
90
- text: question.hintEnd
89
+ hint: hintEnd and {
90
+ text: hintEnd
91
91
  },
92
92
  errorMessage: errorSummary and {
93
93
  text: errors[question.fieldName].msg or errors[endFieldName].msg or errors[endDayFieldName].msg or errors[endMonthFieldName].msg or errors[endYearFieldName].msg
@@ -118,6 +118,8 @@ export default class DatePeriodQuestion extends Question {
118
118
  */
119
119
  addCustomDataToViewModel(viewModel) {
120
120
  viewModel.labels = this.labels;
121
+ viewModel.hintStart = this.hintStart;
122
+ viewModel.hintEnd = this.hintEnd;
121
123
  }
122
124
 
123
125
  /**
@@ -29,9 +29,9 @@
29
29
  <div class="govuk-grid-row">
30
30
  <div class="govuk-grid-column-full">
31
31
  {% if summaryListData.sections | length > 1 %}
32
- {{ multiTaskList(summaryListData.sections, journeyComplete, beforeSubmitButton) }}
32
+ {{ multiTaskList(summaryListData.sections, journeyComplete, beforeSubmitButton, submitButtonText) }}
33
33
  {% elif summaryListData.sections | length == 1 %}
34
- {{ singleTaskList(summaryListData.sections | first, journeyComplete, beforeSubmitButton) }}
34
+ {{ singleTaskList(summaryListData.sections | first, journeyComplete, beforeSubmitButton, submitButtonText) }}
35
35
  {% endif %}
36
36
  </div>
37
37
  </div>
@@ -2,7 +2,7 @@
2
2
  {% from "govuk/components/tag/macro.njk" import govukTag %}
3
3
  {% from "govuk/components/button/macro.njk" import govukButton %}
4
4
 
5
- {% macro multiTaskList(sections, journeyComplete, beforeSubmitButton) %}
5
+ {% macro multiTaskList(sections, journeyComplete, beforeSubmitButton, submitButtonText) %}
6
6
  <ol class="app-task-list">
7
7
  {% for section in sections %}
8
8
  <li class="govuk-body govuk-!-margin-bottom-9">
@@ -46,7 +46,7 @@
46
46
  <form action method="post">
47
47
  <input type="hidden" name="_csrf" value="{{_csrf}}">
48
48
  {{ govukButton({
49
- text: "Accept & Submit",
49
+ text: submitButtonText | default("Accept & Submit", true),
50
50
  type: "submit"
51
51
  }) }}
52
52
  </form>
@@ -3,7 +3,7 @@
3
3
  {% from "govuk/components/button/macro.njk" import govukButton %}
4
4
  {% from "govuk/components/warning-text/macro.njk" import govukWarningText %}
5
5
 
6
- {% macro singleTaskList(section, journeyComplete, beforeSubmitButton) %}
6
+ {% macro singleTaskList(section, journeyComplete, beforeSubmitButton, submitButtonText) %}
7
7
  {% if section.list.rows.length %}
8
8
  {{ govukSummaryList(section.list) }}
9
9
  {% endif %}
@@ -15,7 +15,7 @@
15
15
  <form action method="post">
16
16
  <input type="hidden" name="_csrf" value="{{_csrf}}">
17
17
  {{ govukButton({
18
- text: "Accept & Submit",
18
+ text: submitButtonText | default("Accept & Submit", true),
19
19
  type: "submit"
20
20
  }) }}
21
21
  </form>
@@ -1,18 +1,18 @@
1
1
  export const COMPONENT_TYPES = Object.freeze({
2
- CHECKBOX: 'checkbox',
2
+ ADDRESS: 'site-address',
3
3
  BOOLEAN: 'boolean',
4
- RADIO: 'radio',
4
+ CHECKBOX: 'checkbox',
5
5
  DATE: 'date',
6
6
  DATE_PERIOD: 'date-period',
7
7
  DATE_TIME: 'date-time',
8
- TEXT_ENTRY: 'text-entry',
9
- TEXT_ENTRY_REDACT: 'text-entry-redact',
10
- SELECT: 'select',
11
- SINGLE_LINE_INPUT: 'single-line-input',
8
+ EMAIL: 'email',
9
+ MANAGE_LIST: 'manage-list',
12
10
  MULTI_FIELD_INPUT: 'multi-field-input',
13
11
  NUMBER: 'number',
14
- ADDRESS: 'site-address',
15
- UNIT_OPTION: 'unit-option',
16
- EMAIL: 'email',
17
- MANAGE_LIST: 'manage-list'
12
+ RADIO: 'radio',
13
+ SELECT: 'select',
14
+ SINGLE_LINE_INPUT: 'single-line-input',
15
+ TEXT_ENTRY: 'text-entry',
16
+ TEXT_ENTRY_REDACT: 'text-entry-redact',
17
+ UNIT_OPTION: 'unit-option'
18
18
  });
@@ -1,40 +1,27 @@
1
1
  import { DocType } from '@pins/common/src/document-types';
2
- import { JourneyResponse } from '../journey/journey-response';
3
- import BaseValidator from '../validator/base-validator';
2
+ import { QuestionParameters } from '#question-types';
4
3
 
5
4
  type QuestionTypes =
6
- | 'checkbox'
7
- | 'multi-file-upload'
8
5
  | 'boolean'
9
- | 'radio'
6
+ | 'checkbox'
10
7
  | 'date'
11
8
  | 'date-period'
12
- | 'text-entry'
13
- | 'text-entry-redact'
14
- | 'select'
15
- | 'single-line-input'
9
+ | 'date-time'
10
+ | 'email'
11
+ | 'manage-list'
16
12
  | 'multi-field-input'
17
13
  | 'number'
14
+ | 'radio'
15
+ | 'select'
16
+ | 'single-line-input'
18
17
  | 'site-address'
19
- | 'unit-option'
20
- | 'manage-list';
18
+ | 'text-entry'
19
+ | 'text-entry-redact'
20
+ | 'unit-option';
21
21
 
22
- interface CommonQuestionProps {
22
+ type CommonQuestionProps = QuestionParameters & {
23
23
  type: QuestionTypes;
24
- title: string;
25
- question: string;
26
- viewFolder?: string;
27
- fieldName: string;
28
- url?: string;
29
- pageTitle?: string;
30
- description?: string;
31
- label?: string;
32
- validators?: BaseValidator[];
33
- html?: string;
34
- hint?: string;
35
- shouldDisplay?: (response: JourneyResponse) => boolean;
36
- autocomplete?: string;
37
- }
24
+ };
38
25
 
39
26
  type Option =
40
27
  | {
@@ -92,24 +79,14 @@ interface UnitOption {
92
79
  };
93
80
  }
94
81
 
95
- type CheckboxQuestionProps = CommonQuestionProps & {
96
- type: 'checkbox';
97
- options: Option[];
98
- };
99
-
100
- type MultiFileUploadQuestionProps = CommonQuestionProps & {
101
- type: 'multi-file-upload';
102
- documentType: DocType;
103
- };
104
-
105
82
  type BooleanQuestionProps = CommonQuestionProps & {
106
83
  type: 'boolean';
107
84
  options?: Option[];
108
85
  interfaceType?: 'checkbox' | 'radio';
109
86
  };
110
87
 
111
- type RadioQuestionProps = CommonQuestionProps & {
112
- type: 'radio';
88
+ type CheckboxQuestionProps = CommonQuestionProps & {
89
+ type: 'checkbox';
113
90
  options: Option[];
114
91
  };
115
92
 
@@ -117,51 +94,86 @@ type DateQuestionProps = CommonQuestionProps & {
117
94
  type: 'date';
118
95
  };
119
96
 
120
- type TextEntryQuestionProps = CommonQuestionProps & {
121
- type: 'text-entry';
122
- label?: string;
97
+ type DatePeriodQuestionProps = CommonQuestionProps & {
98
+ type: 'date-period';
123
99
  };
124
100
 
125
- type SingleLineInputQuestionProps = CommonQuestionProps & {
126
- type: 'single-line-input';
127
- label?: string;
128
- inputAttributes?: Record<string, string>;
101
+ type DateTimeQuestionProps = CommonQuestionProps & {
102
+ type: 'date-time';
103
+ };
104
+
105
+ type ManageListQuestionProps = CommonQuestionProps & {
106
+ type: 'manage-list';
107
+ };
108
+
109
+ type EmailQuestionProps = CommonQuestionProps & {
110
+ type: 'email';
129
111
  };
130
112
 
131
113
  type MultiFieldInputQuestionProps = CommonQuestionProps & {
132
114
  type: 'multi-field-input';
133
- label?: string;
134
115
  inputAttributes?: Record<string, string>;
135
116
  inputFields: InputField[];
136
117
  formatType?: 'contactDetails' | 'standard';
137
118
  };
138
119
 
120
+ type MultiFileUploadQuestionProps = CommonQuestionProps & {
121
+ type: 'multi-file-upload';
122
+ documentType: DocType;
123
+ };
124
+
139
125
  type NumberEntryQuestionProps = CommonQuestionProps & {
140
126
  type: 'number';
141
- label?: string;
142
127
  suffix?: string;
143
128
  };
144
129
 
130
+ type RadioQuestionProps = CommonQuestionProps & {
131
+ type: 'radio';
132
+ options: Option[];
133
+ };
134
+
135
+ type SelectQuestionProps = CommonQuestionProps & {
136
+ type: 'select';
137
+ options: Option[];
138
+ };
139
+
140
+ type SingleLineInputQuestionProps = CommonQuestionProps & {
141
+ type: 'single-line-input';
142
+ inputAttributes?: Record<string, string>;
143
+ };
144
+
145
145
  type SiteAddressQuestionProps = CommonQuestionProps & {
146
146
  type: 'site-address';
147
147
  };
148
148
 
149
+ type TextEntryQuestionProps = CommonQuestionProps & {
150
+ type: 'text-entry';
151
+ };
152
+
153
+ type TextEntryRedactQuestionProps = CommonQuestionProps & {
154
+ type: 'text-entry-redact';
155
+ };
156
+
149
157
  type UnitOptionEntryQuestionProps = CommonQuestionProps & {
150
158
  type: 'unit-option';
151
159
  conditionalFieldName: string;
152
160
  options: UnitOption[];
153
- label?: string;
154
161
  };
155
162
 
156
163
  export type QuestionProps =
157
- | CheckboxQuestionProps
158
- | MultiFileUploadQuestionProps
159
164
  | BooleanQuestionProps
160
- | RadioQuestionProps
165
+ | CheckboxQuestionProps
161
166
  | DateQuestionProps
162
- | TextEntryQuestionProps
163
- | SingleLineInputQuestionProps
167
+ | DatePeriodQuestionProps
168
+ | DateTimeQuestionProps
169
+ | ManageListQuestionProps
170
+ | EmailQuestionProps
164
171
  | MultiFieldInputQuestionProps
165
172
  | NumberEntryQuestionProps
173
+ | RadioQuestionProps
174
+ | SelectQuestionProps
175
+ | SingleLineInputQuestionProps
166
176
  | SiteAddressQuestionProps
177
+ | TextEntryQuestionProps
178
+ | TextEntryRedactQuestionProps
167
179
  | UnitOptionEntryQuestionProps;
@@ -1 +1 @@
1
- {"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;OASG;IACH,6FATW,OAAO,iBAAiB,EAAE,kBAAkB,EAqBtD;IAPA,gBAA4B;IAC5B,YAAsD;IAEtD,eAA0B;IAC1B,aAAsB;IACtB,eAA+D;IAC/D,aAA2D;IAG5D;;;;;OAKG,CACH,yCAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAgC5B;IAED;;MAuCC;CAuCD;yBAvJwB,WAAW"}
1
+ {"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;OASG;IACH,6FATW,OAAO,iBAAiB,EAAE,kBAAkB,EAqBtD;IAPA,gBAA4B;IAC5B,YAAsD;IAEtD,eAA0B;IAC1B,aAAsB;IACtB,eAA+D;IAC/D,aAA2D;IAG5D;;;;;OAKG,CACH,yCAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAgC5B;IAED;;MAuCC;CAyCD;yBAzJwB,WAAW"}
@@ -1,19 +1,19 @@
1
1
  export const COMPONENT_TYPES: Readonly<{
2
- CHECKBOX: "checkbox";
2
+ ADDRESS: "site-address";
3
3
  BOOLEAN: "boolean";
4
- RADIO: "radio";
4
+ CHECKBOX: "checkbox";
5
5
  DATE: "date";
6
6
  DATE_PERIOD: "date-period";
7
7
  DATE_TIME: "date-time";
8
- TEXT_ENTRY: "text-entry";
9
- TEXT_ENTRY_REDACT: "text-entry-redact";
10
- SELECT: "select";
11
- SINGLE_LINE_INPUT: "single-line-input";
8
+ EMAIL: "email";
9
+ MANAGE_LIST: "manage-list";
12
10
  MULTI_FIELD_INPUT: "multi-field-input";
13
11
  NUMBER: "number";
14
- ADDRESS: "site-address";
12
+ RADIO: "radio";
13
+ SELECT: "select";
14
+ SINGLE_LINE_INPUT: "single-line-input";
15
+ TEXT_ENTRY: "text-entry";
16
+ TEXT_ENTRY_REDACT: "text-entry-redact";
15
17
  UNIT_OPTION: "unit-option";
16
- EMAIL: "email";
17
- MANAGE_LIST: "manage-list";
18
18
  }>;
19
19
  //# sourceMappingURL=component-types.d.ts.map