@planning-inspectorate/dynamic-forms 3.15.1 → 3.15.3

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 (53) hide show
  1. package/package.json +1 -1
  2. package/src/components/address/question.js +1 -1
  3. package/src/components/boolean/question.js +1 -14
  4. package/src/components/checkbox/question.js +1 -10
  5. package/src/components/date/question.js +3 -4
  6. package/src/components/date-period/question.js +12 -10
  7. package/src/components/date-time/question.js +3 -5
  8. package/src/components/email/question.js +1 -5
  9. package/src/components/manage-list/question.js +1 -1
  10. package/src/components/multi-field-input/question.js +3 -3
  11. package/src/components/number-entry/question.js +3 -5
  12. package/src/components/radio/question.js +1 -17
  13. package/src/components/select/question.js +1 -16
  14. package/src/components/single-line-input/question.js +1 -4
  15. package/src/components/text-entry/question.js +3 -5
  16. package/src/components/text-entry-redact/question.js +3 -10
  17. package/src/components/unit-option-entry/question.js +3 -6
  18. package/src/questions/question-props.d.ts +131 -28
  19. package/src/validator/validator.js +5 -1
  20. package/src/validator/validator.test.js +48 -0
  21. package/types/src/components/address/question.d.ts +2 -2
  22. package/types/src/components/address/question.d.ts.map +1 -1
  23. package/types/src/components/boolean/question.d.ts +3 -30
  24. package/types/src/components/boolean/question.d.ts.map +1 -1
  25. package/types/src/components/checkbox/question.d.ts +2 -21
  26. package/types/src/components/checkbox/question.d.ts.map +1 -1
  27. package/types/src/components/date/question.d.ts +3 -4
  28. package/types/src/components/date/question.d.ts.map +1 -1
  29. package/types/src/components/date-period/question.d.ts +11 -15
  30. package/types/src/components/date-period/question.d.ts.map +1 -1
  31. package/types/src/components/date-time/question.d.ts +4 -6
  32. package/types/src/components/date-time/question.d.ts.map +1 -1
  33. package/types/src/components/email/question.d.ts +4 -0
  34. package/types/src/components/email/question.d.ts.map +1 -1
  35. package/types/src/components/manage-list/question.d.ts +2 -2
  36. package/types/src/components/manage-list/question.d.ts.map +1 -1
  37. package/types/src/components/multi-field-input/question.d.ts +5 -5
  38. package/types/src/components/multi-field-input/question.d.ts.map +1 -1
  39. package/types/src/components/number-entry/question.d.ts +4 -6
  40. package/types/src/components/number-entry/question.d.ts.map +1 -1
  41. package/types/src/components/radio/question.d.ts +2 -37
  42. package/types/src/components/radio/question.d.ts.map +1 -1
  43. package/types/src/components/select/question.d.ts +2 -35
  44. package/types/src/components/select/question.d.ts.map +1 -1
  45. package/types/src/components/single-line-input/question.d.ts +4 -7
  46. package/types/src/components/single-line-input/question.d.ts.map +1 -1
  47. package/types/src/components/text-entry/question.d.ts +4 -6
  48. package/types/src/components/text-entry/question.d.ts.map +1 -1
  49. package/types/src/components/text-entry-redact/question.d.ts +9 -16
  50. package/types/src/components/text-entry-redact/question.d.ts.map +1 -1
  51. package/types/src/components/unit-option-entry/question.d.ts +7 -2
  52. package/types/src/components/unit-option-entry/question.d.ts.map +1 -1
  53. package/types/src/questions/question-props.d.ts +131 -28
@@ -18,14 +18,22 @@ type QuestionTypes =
18
18
  | 'text-entry-redact'
19
19
  | 'unit-option';
20
20
 
21
- type CommonQuestionProps = Omit<QuestionParameters, 'viewFolder'> & {
21
+ /**
22
+ * Base params that question classes need to function (NO type - that's routing metadata)
23
+ */
24
+ export type CommonQuestionParams = Omit<QuestionParameters, 'viewFolder'>;
25
+
26
+ /**
27
+ * Full props including type for routing/factory layer
28
+ */
29
+ type CommonQuestionProps = CommonQuestionParams & {
22
30
  type: QuestionTypes;
23
31
  };
24
32
 
25
33
  /**
26
34
  * Generic question props type so that custom components can be used without having to define a new type for each one.
27
35
  */
28
- export type BaseQuestionProps = Omit<CommonQuestionProps, 'type'> & {
36
+ export type BaseQuestionProps = CommonQuestionParams & {
29
37
  type: string;
30
38
  };
31
39
 
@@ -96,79 +104,174 @@ interface UnitOption {
96
104
  };
97
105
  }
98
106
 
99
- type BooleanQuestionProps = CommonQuestionProps & {
100
- type: 'boolean';
107
+ /**
108
+ * Internal base params for questions with options - not exported
109
+ */
110
+ type OptionsQuestionParams = CommonQuestionParams & {
111
+ options: Option[];
112
+ };
113
+
114
+ export type BooleanQuestionParams = Omit<RadioQuestionParams, 'options'> & {
101
115
  options?: Option[];
102
116
  interfaceType?: 'checkbox' | 'radio';
103
117
  };
104
118
 
105
- type CheckboxQuestionProps = CommonQuestionProps & {
119
+ type BooleanQuestionProps = BooleanQuestionParams & {
120
+ type: 'boolean';
121
+ };
122
+
123
+ export type CheckboxQuestionParams = OptionsQuestionParams;
124
+
125
+ type CheckboxQuestionProps = CheckboxQuestionParams & {
106
126
  type: 'checkbox';
107
- options: Option[];
108
127
  };
109
128
 
110
- type DateQuestionProps = CommonQuestionProps & {
129
+ export type DateQuestionParams = CommonQuestionParams & {
130
+ dateFormat?: string;
131
+ };
132
+
133
+ type DateQuestionProps = DateQuestionParams & {
111
134
  type: 'date';
112
135
  };
113
136
 
114
- type DatePeriodQuestionProps = CommonQuestionProps & {
137
+ // Minute and second will default to 0 if not provided
138
+ interface TimeComponents {
139
+ hour: number;
140
+ minute?: number;
141
+ second?: number;
142
+ }
143
+
144
+ export type DatePeriodQuestionParams = CommonQuestionParams & {
145
+ dateFormat?: string;
146
+ labels?: { start: string; end: string };
147
+ hintStart?: string;
148
+ hintEnd?: string;
149
+ startTime?: TimeComponents;
150
+ endTime?: TimeComponents;
151
+ };
152
+
153
+ type DatePeriodQuestionProps = DatePeriodQuestionParams & {
115
154
  type: 'date-period';
116
155
  };
117
156
 
118
- type DateTimeQuestionProps = CommonQuestionProps & {
157
+ export type DateTimeQuestionParams = CommonQuestionParams & {
158
+ dateFormat?: string;
159
+ timeFormat?: string;
160
+ };
161
+
162
+ type DateTimeQuestionProps = DateTimeQuestionParams & {
119
163
  type: 'date-time';
120
164
  };
121
165
 
122
- type ManageListQuestionProps = CommonQuestionProps & {
166
+ export type ManageListQuestionParams = CommonQuestionParams & {
167
+ titleSingular?: string;
168
+ showManageListQuestions?: boolean;
169
+ showAnswersInSummary?: boolean;
170
+ confirmationQuestion?: string;
171
+ };
172
+
173
+ type ManageListQuestionProps = ManageListQuestionParams & {
123
174
  type: 'manage-list';
124
175
  };
125
176
 
126
- type EmailQuestionProps = CommonQuestionProps & {
177
+ export type EmailQuestionParams = SingleLineInputQuestionParams & {
178
+ autocomplete?: string; // autocomplete attribute value (defaults to 'email')
179
+ };
180
+
181
+ type EmailQuestionProps = EmailQuestionParams & {
127
182
  type: 'email';
128
183
  };
129
184
 
130
- export type MultiFieldInputQuestionProps = CommonQuestionProps & {
131
- type: 'multi-field-input';
185
+ export type MultiFieldInputQuestionParams = CommonQuestionParams & {
132
186
  inputFields: InputField[];
133
187
  };
134
188
 
135
- type NumberEntryQuestionProps = CommonQuestionProps & {
136
- type: 'number';
189
+ export type MultiFieldInputQuestionProps = MultiFieldInputQuestionParams & {
190
+ type: 'multi-field-input';
191
+ };
192
+
193
+ export type NumberEntryQuestionParams = CommonQuestionParams & {
137
194
  suffix?: string;
195
+ label?: string;
138
196
  };
139
197
 
140
- type RadioQuestionProps = CommonQuestionProps & {
198
+ type NumberEntryQuestionProps = NumberEntryQuestionParams & {
199
+ type: 'number';
200
+ };
201
+
202
+ export type RadioQuestionParams = OptionsQuestionParams & {
203
+ label?: string;
204
+ legend?: string;
205
+ };
206
+
207
+ type RadioQuestionProps = RadioQuestionParams & {
141
208
  type: 'radio';
142
- options: Option[];
143
209
  };
144
210
 
145
- type SelectQuestionProps = CommonQuestionProps & {
146
- type: 'select';
147
- options: Option[];
211
+ export type SelectQuestionParams = OptionsQuestionParams & {
148
212
  disableAccessibleAutocomplete?: boolean;
213
+ label?: string;
214
+ legend?: string;
215
+ };
216
+
217
+ type SelectQuestionProps = SelectQuestionParams & {
218
+ type: 'select';
149
219
  };
150
220
 
151
- type SingleLineInputQuestionProps = CommonQuestionProps & {
221
+ export type SingleLineInputQuestionParams = CommonQuestionParams & {
222
+ inputAttributes?: Record<string, string>; // HTML attributes to add to the input
223
+ label?: string; // if defined this will show as a label for the input and the question will just be a standard h1
224
+ classes?: string; // HTML classes to add to the input
225
+ };
226
+
227
+ type SingleLineInputQuestionProps = SingleLineInputQuestionParams & {
152
228
  type: 'single-line-input';
153
- inputAttributes?: Record<string, string>;
154
229
  };
155
230
 
156
- type SiteAddressQuestionProps = CommonQuestionProps & {
231
+ export type SiteAddressQuestionParams = CommonQuestionParams;
232
+
233
+ type SiteAddressQuestionProps = SiteAddressQuestionParams & {
157
234
  type: 'site-address';
158
235
  };
159
236
 
160
- type TextEntryQuestionProps = CommonQuestionProps & {
237
+ type TextEntryCheckbox = {
238
+ header: string;
239
+ text: string;
240
+ name: string;
241
+ errorMessage?: string;
242
+ };
243
+
244
+ export type TextEntryQuestionParams = CommonQuestionParams & {
245
+ textEntryCheckbox?: TextEntryCheckbox;
246
+ label?: string; // if defined this will show as a label for the input and the question will just be a standard h1
247
+ };
248
+
249
+ type TextEntryQuestionProps = TextEntryQuestionParams & {
161
250
  type: 'text-entry';
162
251
  };
163
252
 
164
- type TextEntryRedactQuestionProps = CommonQuestionProps & {
253
+ export type TextEntryRedactQuestionParams = CommonQuestionParams & {
254
+ textEntryCheckbox?: TextEntryCheckbox;
255
+ label?: string; // if defined this will show as a label for the input and the question will just be a standard h1
256
+ onlyShowRedactedValueForSummary?: boolean;
257
+ useRedactedFieldNameForSave?: boolean;
258
+ showSuggestionsUi?: boolean;
259
+ summaryText?: string; // summaryText to use with the details component
260
+ shouldTruncateSummary?: boolean; // determines whether redacted comment is truncated in summary view
261
+ };
262
+
263
+ type TextEntryRedactQuestionProps = TextEntryRedactQuestionParams & {
165
264
  type: 'text-entry-redact';
166
265
  };
167
266
 
168
- type UnitOptionEntryQuestionProps = CommonQuestionProps & {
169
- type: 'unit-option';
170
- conditionalFieldName: string;
267
+ export type UnitOptionEntryQuestionParams = CommonQuestionParams & {
268
+ conditionalFieldName: string; // will be the quantity and is captured by the conditional in the options
171
269
  options: UnitOption[];
270
+ label?: string;
271
+ };
272
+
273
+ type UnitOptionEntryQuestionProps = UnitOptionEntryQuestionParams & {
274
+ type: 'unit-option';
172
275
  };
173
276
 
174
277
  export type QuestionProps =