@defra/forms-model 3.0.481 → 3.0.483
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/dist/module/conditions/condition-operators.js +4 -1
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/form/form-definition/index.js +0 -1
- package/dist/module/form/form-definition/index.js.map +1 -1
- package/dist/module/form/form-editor/__stubs__/preview.js +83 -4
- package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
- package/dist/module/form/form-editor/index.js +2 -2
- package/dist/module/form/form-editor/index.js.map +1 -1
- package/dist/module/form/form-editor/macros/types.js +2 -0
- package/dist/module/form/form-editor/macros/types.js.map +1 -0
- package/dist/module/form/form-editor/preview/autocomplete.js +20 -4
- package/dist/module/form/form-editor/preview/autocomplete.js.map +1 -1
- package/dist/module/form/form-editor/preview/checkbox-sortable.js +7 -2
- package/dist/module/form/form-editor/preview/checkbox-sortable.js.map +1 -1
- package/dist/module/form/form-editor/preview/checkbox.js +17 -0
- package/dist/module/form/form-editor/preview/checkbox.js.map +1 -0
- package/dist/module/form/form-editor/preview/component-elements.js +61 -0
- package/dist/module/form/form-editor/preview/component-elements.js.map +1 -0
- package/dist/module/form/form-editor/preview/constants.js +2 -0
- package/dist/module/form/form-editor/preview/constants.js.map +1 -0
- package/dist/module/form/form-editor/preview/content.js +94 -0
- package/dist/module/form/form-editor/preview/content.js.map +1 -0
- package/dist/module/form/form-editor/preview/controller/page-controller.js +260 -0
- package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -0
- package/dist/module/form/form-editor/preview/date-input.js +7 -2
- package/dist/module/form/form-editor/preview/date-input.js.map +1 -1
- package/dist/module/form/form-editor/preview/email-address.js +7 -1
- package/dist/module/form/form-editor/preview/email-address.js.map +1 -1
- package/dist/module/form/form-editor/preview/fieldset-question.js +5 -0
- package/dist/module/form/form-editor/preview/fieldset-question.js.map +1 -1
- package/dist/module/form/form-editor/preview/helpers.js +81 -0
- package/dist/module/form/form-editor/preview/helpers.js.map +1 -0
- package/dist/module/form/form-editor/preview/index.js +6 -0
- package/dist/module/form/form-editor/preview/index.js.map +1 -1
- package/dist/module/form/form-editor/preview/list.js +59 -3
- package/dist/module/form/form-editor/preview/list.js.map +1 -1
- package/dist/module/form/form-editor/preview/long-answer.js +7 -1
- package/dist/module/form/form-editor/preview/long-answer.js.map +1 -1
- package/dist/module/form/form-editor/preview/markdown.js +53 -0
- package/dist/module/form/form-editor/preview/markdown.js.map +1 -0
- package/dist/module/form/form-editor/preview/month-year.js +7 -2
- package/dist/module/form/form-editor/preview/month-year.js.map +1 -1
- package/dist/module/form/form-editor/preview/number-only.js +5 -0
- package/dist/module/form/form-editor/preview/number-only.js.map +1 -1
- package/dist/module/form/form-editor/preview/phone-number.js +7 -1
- package/dist/module/form/form-editor/preview/phone-number.js.map +1 -1
- package/dist/module/form/form-editor/preview/preview.js +212 -0
- package/dist/module/form/form-editor/preview/preview.js.map +1 -0
- package/dist/module/form/form-editor/preview/question.js +48 -138
- package/dist/module/form/form-editor/preview/question.js.map +1 -1
- package/dist/module/form/form-editor/preview/radio-sortable.js +7 -2
- package/dist/module/form/form-editor/preview/radio-sortable.js.map +1 -1
- package/dist/module/form/form-editor/preview/radio.js +7 -2
- package/dist/module/form/form-editor/preview/radio.js.map +1 -1
- package/dist/module/form/form-editor/preview/select-sortable.js +38 -0
- package/dist/module/form/form-editor/preview/select-sortable.js.map +1 -0
- package/dist/module/form/form-editor/preview/select.js +11 -0
- package/dist/module/form/form-editor/preview/select.js.map +1 -0
- package/dist/module/form/form-editor/preview/short-answer.js +7 -1
- package/dist/module/form/form-editor/preview/short-answer.js.map +1 -1
- package/dist/module/form/form-editor/preview/supporting-evidence.js +7 -1
- package/dist/module/form/form-editor/preview/supporting-evidence.js.map +1 -1
- package/dist/module/form/form-editor/preview/types.js.map +1 -1
- package/dist/module/form/form-editor/preview/uk-address.js +7 -2
- package/dist/module/form/form-editor/preview/uk-address.js.map +1 -1
- package/dist/module/form/form-editor/preview/yes-no.js +7 -2
- package/dist/module/form/form-editor/preview/yes-no.js.map +1 -1
- package/dist/module/form/form-editor/types.js.map +1 -1
- package/dist/module/form/form-metadata/index.js +1 -5
- package/dist/module/form/form-metadata/index.js.map +1 -1
- package/dist/module/form/utils/index.js +1 -0
- package/dist/module/form/utils/index.js.map +1 -1
- package/dist/module/form/utils/list.js +15 -0
- package/dist/module/form/utils/list.js.map +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/stubs.js +1 -0
- package/dist/module/stubs.js.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +0 -4
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/form/form-definition/index.d.ts.map +1 -1
- package/dist/types/form/form-editor/__stubs__/preview.d.ts +58 -11
- package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
- package/dist/types/form/form-editor/index.d.ts.map +1 -1
- package/dist/types/form/form-editor/macros/types.d.ts +62 -0
- package/dist/types/form/form-editor/macros/types.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/autocomplete.d.ts +3 -1
- package/dist/types/form/form-editor/preview/autocomplete.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/checkbox-sortable.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/checkbox.d.ts +4 -0
- package/dist/types/form/form-editor/preview/checkbox.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/component-elements.d.ts +35 -0
- package/dist/types/form/form-editor/preview/component-elements.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/constants.d.ts +2 -0
- package/dist/types/form/form-editor/preview/constants.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/content.d.ts +43 -0
- package/dist/types/form/form-editor/preview/content.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/controller/page-controller.d.ts +132 -0
- package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/date-input.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/email-address.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/fieldset-question.d.ts +2 -0
- package/dist/types/form/form-editor/preview/fieldset-question.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/helpers.d.ts +11 -0
- package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/index.d.ts +6 -0
- package/dist/types/form/form-editor/preview/list-sortable.d.ts +1 -1
- package/dist/types/form/form-editor/preview/list.d.ts +25 -0
- package/dist/types/form/form-editor/preview/list.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/long-answer.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/markdown.d.ts +9 -0
- package/dist/types/form/form-editor/preview/markdown.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/month-year.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/number-only.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/phone-number.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/preview.d.ts +126 -0
- package/dist/types/form/form-editor/preview/preview.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/question.d.ts +19 -93
- package/dist/types/form/form-editor/preview/question.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/radio-sortable.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/radio.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/select-sortable.d.ts +18 -0
- package/dist/types/form/form-editor/preview/select-sortable.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/select.d.ts +4 -0
- package/dist/types/form/form-editor/preview/select.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/short-answer.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/supporting-evidence.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/types.d.ts +13 -17
- package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/uk-address.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/yes-no.d.ts.map +1 -1
- package/dist/types/form/form-editor/types.d.ts +6 -4
- package/dist/types/form/form-editor/types.d.ts.map +1 -1
- package/dist/types/form/form-metadata/index.d.ts.map +1 -1
- package/dist/types/form/utils/index.d.ts +1 -0
- package/dist/types/form/utils/index.d.ts.map +1 -1
- package/dist/types/form/utils/list.d.ts +10 -0
- package/dist/types/form/utils/list.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/stubs.d.ts +1 -0
- package/dist/types/stubs.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/form-definition-schema.json +0 -12
- package/schemas/form-metadata-input-schema.json +1 -2
- package/schemas/form-metadata-schema.json +1 -2
- package/schemas/question-type-full-schema.json +2 -1
- package/src/conditions/condition-operators.ts +4 -1
- package/src/form/form-definition/index.ts +0 -5
- package/src/form/form-editor/__stubs__/preview.js +84 -4
- package/src/form/form-editor/index.ts +4 -2
- package/src/form/form-editor/macros/types.ts +65 -0
- package/src/form/form-editor/preview/autocomplete.js +21 -4
- package/src/form/form-editor/preview/checkbox-sortable.js +7 -2
- package/src/form/form-editor/preview/checkbox.js +17 -0
- package/src/form/form-editor/preview/component-elements.js +61 -0
- package/src/form/form-editor/preview/constants.js +1 -0
- package/src/form/form-editor/preview/content.js +93 -0
- package/src/form/form-editor/preview/controller/page-controller.js +284 -0
- package/src/form/form-editor/preview/date-input.js +8 -2
- package/src/form/form-editor/preview/email-address.js +7 -1
- package/src/form/form-editor/preview/fieldset-question.js +6 -0
- package/src/form/form-editor/preview/helpers.js +95 -0
- package/src/form/form-editor/preview/index.js +6 -0
- package/src/form/form-editor/preview/list.js +62 -3
- package/src/form/form-editor/preview/long-answer.js +7 -1
- package/src/form/form-editor/preview/markdown.js +50 -0
- package/src/form/form-editor/preview/month-year.js +7 -2
- package/src/form/form-editor/preview/number-only.js +5 -0
- package/src/form/form-editor/preview/phone-number.js +7 -1
- package/src/form/form-editor/preview/preview.js +211 -0
- package/src/form/form-editor/preview/question.js +47 -142
- package/src/form/form-editor/preview/radio-sortable.js +7 -2
- package/src/form/form-editor/preview/radio.js +7 -2
- package/src/form/form-editor/preview/select-sortable.js +43 -0
- package/src/form/form-editor/preview/select.js +11 -0
- package/src/form/form-editor/preview/short-answer.js +7 -1
- package/src/form/form-editor/preview/supporting-evidence.js +7 -1
- package/src/form/form-editor/preview/types.ts +18 -18
- package/src/form/form-editor/preview/uk-address.js +7 -2
- package/src/form/form-editor/preview/yes-no.js +7 -2
- package/src/form/form-editor/types.ts +6 -4
- package/src/form/form-metadata/index.ts +2 -5
- package/src/form/utils/index.ts +1 -0
- package/src/form/utils/list.ts +25 -0
- package/src/index.ts +1 -0
- package/src/stubs.ts +1 -0
@@ -1,10 +1,16 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
2
|
+
import { PreviewComponent } from "./preview.js";
|
1
3
|
import { Question } from "./question.js";
|
2
4
|
export class LongAnswerQuestion extends Question {
|
5
|
+
/**
|
6
|
+
* @type {ComponentType}
|
7
|
+
*/
|
8
|
+
componentType = ComponentType.MultilineTextField;
|
3
9
|
/**
|
4
10
|
* @type {string}
|
5
11
|
* @protected
|
6
12
|
*/
|
7
|
-
_questionTemplate =
|
13
|
+
_questionTemplate = PreviewComponent.PATH + 'textarea.njk';
|
8
14
|
/**
|
9
15
|
* @type {string}
|
10
16
|
* @protected
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"long-answer.js","names":["Question","LongAnswerQuestion","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class LongAnswerQuestion extends Question {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate =
|
1
|
+
{"version":3,"file":"long-answer.js","names":["ComponentType","PreviewComponent","Question","LongAnswerQuestion","componentType","MultilineTextField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class LongAnswerQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.MultilineTextField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'textarea.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'longAnswerField'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,kBAAkB,SAASD,QAAQ,CAAC;EAC/C;AACF;AACA;EACEE,aAAa,GAAGJ,aAAa,CAACK,kBAAkB;EAChD;AACF;AACA;AACA;EACEC,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,cAAc;EAC1D;AACF;AACA;AACA;EACEC,UAAU,GAAG,iBAAiB;AAChC","ignoreList":[]}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
2
|
+
import { Content } from "./content.js";
|
3
|
+
import { PreviewComponent } from "./preview.js";
|
4
|
+
import { markdownToHtml } from "../../../utils/markdown.js";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @class Markdown
|
8
|
+
* @classdesc
|
9
|
+
* Base of Content preview classes
|
10
|
+
*/
|
11
|
+
export class Markdown extends Content {
|
12
|
+
/**
|
13
|
+
* @type {string}
|
14
|
+
* @protected
|
15
|
+
*/
|
16
|
+
_fieldName = 'markdown';
|
17
|
+
/**
|
18
|
+
* @type {ComponentType}
|
19
|
+
*/
|
20
|
+
componentType = ComponentType.Markdown;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @type {string}
|
24
|
+
* @protected
|
25
|
+
*/
|
26
|
+
_questionTemplate = PreviewComponent.PATH + 'markdown.njk';
|
27
|
+
/**
|
28
|
+
* @param {QuestionElements} htmlElements
|
29
|
+
* @param {QuestionRenderer} questionRenderer
|
30
|
+
*/
|
31
|
+
constructor(htmlElements, questionRenderer) {
|
32
|
+
super(htmlElements, questionRenderer);
|
33
|
+
const {
|
34
|
+
content
|
35
|
+
} = htmlElements.values;
|
36
|
+
this._content = markdownToHtml(content);
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @param {string} value
|
41
|
+
* @protected
|
42
|
+
*/
|
43
|
+
_setContent(value) {
|
44
|
+
super._setContent(markdownToHtml(value));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
50
|
+
* @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'
|
51
|
+
* @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
|
52
|
+
*/
|
53
|
+
//# sourceMappingURL=markdown.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"markdown.js","names":["ComponentType","Content","PreviewComponent","markdownToHtml","Markdown","_fieldName","componentType","_questionTemplate","PATH","constructor","htmlElements","questionRenderer","content","values","_content","_setContent","value"],"sources":["../../../../../src/form/form-editor/preview/markdown.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { Content } from '~/src/form/form-editor/preview/content.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport { markdownToHtml } from '~/src/utils/markdown.js'\n\n/**\n * @class Markdown\n * @classdesc\n * Base of Content preview classes\n */\nexport class Markdown extends Content {\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'markdown'\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.Markdown\n\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'markdown.njk'\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n const { content } = htmlElements.values\n this._content = markdownToHtml(content)\n }\n\n /**\n * @param {string} value\n * @protected\n */\n _setContent(value) {\n super._setContent(markdownToHtml(value))\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,OAAO;AAChB,SAASC,gBAAgB;AACzB,SAASC,cAAc;;AAEvB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,SAASH,OAAO,CAAC;EACpC;AACF;AACA;AACA;EACEI,UAAU,GAAG,UAAU;EACvB;AACF;AACA;EACEC,aAAa,GAAGN,aAAa,CAACI,QAAQ;;EAEtC;AACF;AACA;AACA;EACEG,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,cAAc;EAC1D;AACF;AACA;AACA;EACEC,WAAWA,CAACC,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,MAAM;MAAEC;IAAQ,CAAC,GAAGF,YAAY,CAACG,MAAM;IACvC,IAAI,CAACC,QAAQ,GAAGX,cAAc,CAACS,OAAO,CAAC;EACzC;;EAEA;AACF;AACA;AACA;EACEG,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACD,WAAW,CAACZ,cAAc,CAACa,KAAK,CAAC,CAAC;EAC1C;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
@@ -1,11 +1,16 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
1
2
|
import { FieldsetQuestion } from "./fieldset-question.js";
|
2
|
-
import {
|
3
|
+
import { PreviewComponent } from "./preview.js";
|
3
4
|
export class MonthYearQuestion extends FieldsetQuestion {
|
5
|
+
/**
|
6
|
+
* @type {ComponentType}
|
7
|
+
*/
|
8
|
+
componentType = ComponentType.MonthYearField;
|
4
9
|
/**
|
5
10
|
* @type {string}
|
6
11
|
* @protected
|
7
12
|
*/
|
8
|
-
_questionTemplate =
|
13
|
+
_questionTemplate = PreviewComponent.PATH + 'monthyearfield.njk';
|
9
14
|
_fieldName = 'monthYear';
|
10
15
|
|
11
16
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"month-year.js","names":["FieldsetQuestion","
|
1
|
+
{"version":3,"file":"month-year.js","names":["ComponentType","FieldsetQuestion","PreviewComponent","MonthYearQuestion","componentType","MonthYearField","_questionTemplate","PATH","_fieldName","customRenderFields","items","name","classes"],"sources":["../../../../../src/form/form-editor/preview/month-year.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class MonthYearQuestion extends FieldsetQuestion {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.MonthYearField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'monthyearfield.njk'\n _fieldName = 'monthYear'\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {\n items: [\n { name: 'month', classes: 'govuk-input--width-2' },\n { name: 'year', classes: 'govuk-input--width-4' }\n ]\n }\n }\n}\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,iBAAiB,SAASF,gBAAgB,CAAC;EACtD;AACF;AACA;EACEG,aAAa,GAAGJ,aAAa,CAACK,cAAc;EAC5C;AACF;AACA;AACA;EACEC,iBAAiB,GAAGJ,gBAAgB,CAACK,IAAI,GAAG,oBAAoB;EAChEC,UAAU,GAAG,WAAW;;EAExB;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAG;IACvB,OAAO;MACLC,KAAK,EAAE,CACL;QAAEC,IAAI,EAAE,OAAO;QAAEC,OAAO,EAAE;MAAuB,CAAC,EAClD;QAAED,IAAI,EAAE,MAAM;QAAEC,OAAO,EAAE;MAAuB,CAAC;IAErD,CAAC;EACH;AACF;AACA;AACA;AACA","ignoreList":[]}
|
@@ -1,5 +1,10 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
1
2
|
import { Question } from "./question.js";
|
2
3
|
export class NumberOnlyQuestion extends Question {
|
4
|
+
/**
|
5
|
+
* @type {ComponentType}
|
6
|
+
*/
|
7
|
+
componentType = ComponentType.NumberField;
|
3
8
|
/**
|
4
9
|
* @returns {Partial<QuestionBaseModel>}
|
5
10
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"number-only.js","names":["Question","NumberOnlyQuestion","customRenderFields","type"],"sources":["../../../../../src/form/form-editor/preview/number-only.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class NumberOnlyQuestion extends Question {\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {\n type: 'number'\n }\n }\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,kBAAkB,SAASD,QAAQ,CAAC;EAC/C;AACF;AACA;EACE,
|
1
|
+
{"version":3,"file":"number-only.js","names":["ComponentType","Question","NumberOnlyQuestion","componentType","NumberField","customRenderFields","type"],"sources":["../../../../../src/form/form-editor/preview/number-only.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class NumberOnlyQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.NumberField\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {\n type: 'number'\n }\n }\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,kBAAkB,SAASD,QAAQ,CAAC;EAC/C;AACF;AACA;EACEE,aAAa,GAAGH,aAAa,CAACI,WAAW;EACzC;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAG;IACvB,OAAO;MACLC,IAAI,EAAE;IACR,CAAC;EACH;AACF;;AAEA;AACA;AACA","ignoreList":[]}
|
@@ -1,6 +1,12 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
2
|
+
import { PreviewComponent } from "./preview.js";
|
1
3
|
import { Question } from "./question.js";
|
2
4
|
export class PhoneNumberQuestion extends Question {
|
3
|
-
|
5
|
+
/**
|
6
|
+
* @type {ComponentType}
|
7
|
+
*/
|
8
|
+
componentType = ComponentType.TelephoneNumberField;
|
9
|
+
_questionTemplate = PreviewComponent.PATH + 'telephonenumberfield.njk';
|
4
10
|
_fieldName = 'phoneNumberField';
|
5
11
|
}
|
6
12
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"phone-number.js","names":["Question","PhoneNumberQuestion","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/phone-number.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class PhoneNumberQuestion extends Question {\n _questionTemplate =
|
1
|
+
{"version":3,"file":"phone-number.js","names":["ComponentType","PreviewComponent","Question","PhoneNumberQuestion","componentType","TelephoneNumberField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/phone-number.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class PhoneNumberQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.TelephoneNumberField\n _questionTemplate = PreviewComponent.PATH + 'telephonenumberfield.njk'\n _fieldName = 'phoneNumberField'\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/question.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,mBAAmB,SAASD,QAAQ,CAAC;EAChD;AACF;AACA;EACEE,aAAa,GAAGJ,aAAa,CAACK,oBAAoB;EAClDC,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,0BAA0B;EACtEC,UAAU,GAAG,kBAAkB;AACjC;;AAEA;AACA;AACA","ignoreList":[]}
|
@@ -0,0 +1,212 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
2
|
+
import { HIGHLIGHT_CLASS } from "./constants.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @abstract
|
6
|
+
*/
|
7
|
+
export class PreviewComponent {
|
8
|
+
static PATH = 'preview-components/';
|
9
|
+
/**
|
10
|
+
* @abstract
|
11
|
+
* @type {ComponentType}
|
12
|
+
*/
|
13
|
+
componentType = ComponentType.Details;
|
14
|
+
/**
|
15
|
+
* @abstract
|
16
|
+
* @type {string}
|
17
|
+
* @protected
|
18
|
+
*/
|
19
|
+
_questionTemplate = '';
|
20
|
+
/**
|
21
|
+
* @type { string|null }
|
22
|
+
* @protected
|
23
|
+
*/
|
24
|
+
_highlight = null;
|
25
|
+
/**
|
26
|
+
* @abstract
|
27
|
+
* @type {string}
|
28
|
+
* @protected
|
29
|
+
*/
|
30
|
+
_fieldName = '';
|
31
|
+
/**
|
32
|
+
* @type {QuestionRenderer}
|
33
|
+
* @protected
|
34
|
+
*/
|
35
|
+
_questionRenderer;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* @type {QuestionElements}
|
39
|
+
* @protected
|
40
|
+
*/
|
41
|
+
_htmlElements;
|
42
|
+
/**
|
43
|
+
* @type {boolean}
|
44
|
+
* @protected
|
45
|
+
*/
|
46
|
+
_highlighted = false;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @param {QuestionElements} htmlElements
|
50
|
+
* @param {QuestionRenderer} questionRenderer
|
51
|
+
*/
|
52
|
+
constructor(htmlElements, questionRenderer) {
|
53
|
+
const {
|
54
|
+
question,
|
55
|
+
optional
|
56
|
+
} = htmlElements.values;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @type {QuestionElements}
|
60
|
+
* @protected
|
61
|
+
*/
|
62
|
+
this._htmlElements = htmlElements;
|
63
|
+
/**
|
64
|
+
* @type {string}
|
65
|
+
* @private
|
66
|
+
*/
|
67
|
+
this._question = question;
|
68
|
+
/**
|
69
|
+
* @type {boolean}
|
70
|
+
* @private
|
71
|
+
*/
|
72
|
+
this._optional = optional;
|
73
|
+
/**
|
74
|
+
*
|
75
|
+
* @type {QuestionRenderer}
|
76
|
+
* @protected
|
77
|
+
*/
|
78
|
+
this._questionRenderer = questionRenderer;
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @param {string} element
|
83
|
+
* @returns {string}
|
84
|
+
* @protected
|
85
|
+
*/
|
86
|
+
getHighlight(element) {
|
87
|
+
return this._highlight === element ? ' highlight' : '';
|
88
|
+
}
|
89
|
+
get titleText() {
|
90
|
+
const optionalText = this._optional ? ' (optional)' : '';
|
91
|
+
return (!this._question ? 'Question' : this._question) + optionalText;
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* @protected
|
96
|
+
* @type {DefaultComponent}
|
97
|
+
*/
|
98
|
+
get label() {
|
99
|
+
return {
|
100
|
+
text: this.titleText,
|
101
|
+
classes: 'govuk-label--l' + this.getHighlight('question')
|
102
|
+
};
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* @protected
|
107
|
+
* @type {GovukFieldset}
|
108
|
+
*/
|
109
|
+
get fieldSet() {
|
110
|
+
return {
|
111
|
+
legend: {
|
112
|
+
text: this.titleText,
|
113
|
+
classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')
|
114
|
+
}
|
115
|
+
};
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* @returns {Partial<QuestionBaseModel>}
|
120
|
+
*/
|
121
|
+
get customRenderFields() {
|
122
|
+
return {};
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
*
|
127
|
+
* @returns {QuestionBaseModel}
|
128
|
+
* @protected
|
129
|
+
*/
|
130
|
+
_renderInput() {
|
131
|
+
return {
|
132
|
+
id: this._fieldName,
|
133
|
+
name: this._fieldName,
|
134
|
+
classes: this._highlighted ? HIGHLIGHT_CLASS : ''
|
135
|
+
};
|
136
|
+
}
|
137
|
+
|
138
|
+
/**
|
139
|
+
* @type {QuestionBaseModel}
|
140
|
+
*/
|
141
|
+
get renderInput() {
|
142
|
+
return {
|
143
|
+
...this._renderInput(),
|
144
|
+
...this.customRenderFields
|
145
|
+
};
|
146
|
+
}
|
147
|
+
render() {
|
148
|
+
this._questionRenderer.render(this._questionTemplate, this.renderInput);
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* @type {string}
|
153
|
+
*/
|
154
|
+
get question() {
|
155
|
+
return this._question;
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* @param {string} value
|
160
|
+
*/
|
161
|
+
set question(value) {
|
162
|
+
this._question = value;
|
163
|
+
this.render();
|
164
|
+
}
|
165
|
+
get optional() {
|
166
|
+
return this._optional;
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* @param {boolean} value
|
171
|
+
*/
|
172
|
+
set optional(value) {
|
173
|
+
this._optional = value;
|
174
|
+
this.render();
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* @type {string | null}
|
179
|
+
*/
|
180
|
+
get highlight() {
|
181
|
+
return this._highlight;
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* @param {string | null} value
|
186
|
+
*/
|
187
|
+
set highlight(value) {
|
188
|
+
this._highlight = value;
|
189
|
+
this.render();
|
190
|
+
}
|
191
|
+
|
192
|
+
/**
|
193
|
+
* no render
|
194
|
+
*/
|
195
|
+
highlightContent() {
|
196
|
+
this._highlighted = true;
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* no render
|
201
|
+
*/
|
202
|
+
unHighlightContent() {
|
203
|
+
this._highlighted = false;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
209
|
+
* @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'
|
210
|
+
* @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
|
211
|
+
*/
|
212
|
+
//# sourceMappingURL=preview.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"preview.js","names":["ComponentType","HIGHLIGHT_CLASS","PreviewComponent","PATH","componentType","Details","_questionTemplate","_highlight","_fieldName","_questionRenderer","_htmlElements","_highlighted","constructor","htmlElements","questionRenderer","question","optional","values","_question","_optional","getHighlight","element","titleText","optionalText","label","text","classes","fieldSet","legend","customRenderFields","_renderInput","id","name","renderInput","render","value","highlight","highlightContent","unHighlightContent"],"sources":["../../../../../src/form/form-editor/preview/preview.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\n\n/**\n * @abstract\n */\nexport class PreviewComponent {\n static PATH = 'preview-components/'\n /**\n * @abstract\n * @type {ComponentType}\n */\n componentType = ComponentType.Details\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _questionTemplate = ''\n /**\n * @type { string|null }\n * @protected\n */\n _highlight = null\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _fieldName = ''\n /**\n * @type {QuestionRenderer}\n * @protected\n */\n _questionRenderer\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n _htmlElements\n /**\n * @type {boolean}\n * @protected\n */\n _highlighted = false\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n const { question, optional } = htmlElements.values\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n this._htmlElements = htmlElements\n /**\n * @type {string}\n * @private\n */\n this._question = question\n /**\n * @type {boolean}\n * @private\n */\n this._optional = optional\n /**\n *\n * @type {QuestionRenderer}\n * @protected\n */\n this._questionRenderer = questionRenderer\n }\n\n /**\n * @param {string} element\n * @returns {string}\n * @protected\n */\n getHighlight(element) {\n return this._highlight === element ? ' highlight' : ''\n }\n\n get titleText() {\n const optionalText = this._optional ? ' (optional)' : ''\n return (!this._question ? 'Question' : this._question) + optionalText\n }\n\n /**\n * @protected\n * @type {DefaultComponent}\n */\n get label() {\n return {\n text: this.titleText,\n classes: 'govuk-label--l' + this.getHighlight('question')\n }\n }\n\n /**\n * @protected\n * @type {GovukFieldset}\n */\n get fieldSet() {\n return {\n legend: {\n text: this.titleText,\n classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')\n }\n }\n }\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {}\n }\n\n /**\n *\n * @returns {QuestionBaseModel}\n * @protected\n */\n _renderInput() {\n return {\n id: this._fieldName,\n name: this._fieldName,\n classes: this._highlighted ? HIGHLIGHT_CLASS : ''\n }\n }\n\n /**\n * @type {QuestionBaseModel}\n */\n get renderInput() {\n return {\n ...this._renderInput(),\n ...this.customRenderFields\n }\n }\n\n render() {\n this._questionRenderer.render(this._questionTemplate, this.renderInput)\n }\n\n /**\n * @type {string}\n */\n get question() {\n return this._question\n }\n\n /**\n * @param {string} value\n */\n set question(value) {\n this._question = value\n this.render()\n }\n\n get optional() {\n return this._optional\n }\n\n /**\n * @param {boolean} value\n */\n set optional(value) {\n this._optional = value\n this.render()\n }\n\n /**\n * @type {string | null}\n */\n get highlight() {\n return this._highlight\n }\n\n /**\n * @param {string | null} value\n */\n set highlight(value) {\n this._highlight = value\n this.render()\n }\n\n /**\n * no render\n */\n highlightContent() {\n this._highlighted = true\n }\n\n /**\n * no render\n */\n unHighlightContent() {\n this._highlighted = false\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"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","ignoreList":[]}
|
@@ -1,3 +1,37 @@
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
2
|
+
import { ComponentElements } from "./component-elements.js";
|
3
|
+
import { PreviewComponent } from "./preview.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @implements {QuestionElements}
|
7
|
+
*/
|
8
|
+
export class QuestionComponentElements extends ComponentElements {
|
9
|
+
/**
|
10
|
+
* @type {FormComponentsDef}
|
11
|
+
* @protected
|
12
|
+
*/
|
13
|
+
_component;
|
14
|
+
/**
|
15
|
+
* @param {FormComponentsDef} component
|
16
|
+
*/
|
17
|
+
constructor(component) {
|
18
|
+
super(component);
|
19
|
+
this._component = component;
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @protected
|
24
|
+
* @returns {BaseSettings}
|
25
|
+
*/
|
26
|
+
_getValues() {
|
27
|
+
return {
|
28
|
+
...super._getValues(),
|
29
|
+
hintText: this._component.hint ?? '',
|
30
|
+
shortDesc: this._component.shortDescription ?? ''
|
31
|
+
};
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
1
35
|
/**
|
2
36
|
* @class Question
|
3
37
|
* @classdesc
|
@@ -8,110 +42,37 @@
|
|
8
42
|
* the HTML. Question classes should only be responsible for data and rendering as are reused in the
|
9
43
|
* server side.
|
10
44
|
*/
|
11
|
-
export class Question {
|
12
|
-
static PATH = 'preview-components/';
|
13
|
-
|
45
|
+
export class Question extends PreviewComponent {
|
14
46
|
/**
|
15
|
-
* @type {
|
16
|
-
* @protected
|
47
|
+
* @type {ComponentType}
|
17
48
|
*/
|
18
|
-
|
49
|
+
componentType = ComponentType.TextField;
|
50
|
+
|
19
51
|
/**
|
20
|
-
* @type {
|
52
|
+
* @type {string}
|
21
53
|
* @protected
|
22
54
|
*/
|
23
|
-
|
55
|
+
_questionTemplate = PreviewComponent.PATH + 'textfield.njk';
|
24
56
|
/**
|
25
57
|
* @type {string}
|
26
58
|
* @protected
|
27
59
|
*/
|
28
60
|
_fieldName = 'inputField';
|
29
|
-
/**
|
30
|
-
* @type {QuestionRenderer}
|
31
|
-
* @protected
|
32
|
-
*/
|
33
|
-
_questionRenderer;
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @type {QuestionElements}
|
37
|
-
* @private
|
38
|
-
*/
|
39
|
-
_htmlElements;
|
40
61
|
|
41
62
|
/**
|
42
63
|
* @param {QuestionElements} htmlElements
|
43
64
|
* @param {QuestionRenderer} questionRenderer
|
44
65
|
*/
|
45
66
|
constructor(htmlElements, questionRenderer) {
|
67
|
+
super(htmlElements, questionRenderer);
|
46
68
|
const {
|
47
|
-
|
48
|
-
hintText,
|
49
|
-
optional
|
69
|
+
hintText
|
50
70
|
} = htmlElements.values;
|
51
|
-
|
52
|
-
/**
|
53
|
-
* @type {QuestionElements}
|
54
|
-
* @protected
|
55
|
-
*/
|
56
|
-
this._htmlElements = htmlElements;
|
57
|
-
/**
|
58
|
-
* @type {string}
|
59
|
-
* @private
|
60
|
-
*/
|
61
|
-
this._question = question;
|
62
71
|
/**
|
63
72
|
* @type {string}
|
64
73
|
* @private
|
65
74
|
*/
|
66
75
|
this._hintText = hintText;
|
67
|
-
/**
|
68
|
-
* @type {boolean}
|
69
|
-
* @private
|
70
|
-
*/
|
71
|
-
this._optional = optional;
|
72
|
-
/**
|
73
|
-
*
|
74
|
-
* @type {QuestionRenderer}
|
75
|
-
* @protected
|
76
|
-
*/
|
77
|
-
this._questionRenderer = questionRenderer;
|
78
|
-
}
|
79
|
-
|
80
|
-
/**
|
81
|
-
* @param {string} element
|
82
|
-
* @returns {string}
|
83
|
-
* @protected
|
84
|
-
*/
|
85
|
-
getHighlight(element) {
|
86
|
-
return this._highlight === element ? ' highlight' : '';
|
87
|
-
}
|
88
|
-
get titleText() {
|
89
|
-
const optionalText = this._optional ? ' (optional)' : '';
|
90
|
-
return (!this._question ? 'Question' : this._question) + optionalText;
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* @protected
|
95
|
-
* @type {DefaultComponent}
|
96
|
-
*/
|
97
|
-
get label() {
|
98
|
-
return {
|
99
|
-
text: this.titleText,
|
100
|
-
classes: 'govuk-label--l' + this.getHighlight('question')
|
101
|
-
};
|
102
|
-
}
|
103
|
-
|
104
|
-
/**
|
105
|
-
* @protected
|
106
|
-
* @type {GovukFieldset}
|
107
|
-
*/
|
108
|
-
get fieldSet() {
|
109
|
-
return {
|
110
|
-
legend: {
|
111
|
-
text: this.titleText,
|
112
|
-
classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')
|
113
|
-
}
|
114
|
-
};
|
115
76
|
}
|
116
77
|
|
117
78
|
/**
|
@@ -127,42 +88,16 @@ export class Question {
|
|
127
88
|
}
|
128
89
|
|
129
90
|
/**
|
130
|
-
* @returns {
|
131
|
-
|
132
|
-
get customRenderFields() {
|
133
|
-
return {};
|
134
|
-
}
|
135
|
-
|
136
|
-
/**
|
137
|
-
* @type {QuestionBaseModel}
|
91
|
+
* @returns {QuestionBaseModel}
|
92
|
+
* @protected
|
138
93
|
*/
|
139
|
-
|
94
|
+
_renderInput() {
|
140
95
|
return {
|
141
|
-
|
142
|
-
name: this._fieldName,
|
96
|
+
...super._renderInput(),
|
143
97
|
label: this.label,
|
144
|
-
hint: this.hint
|
145
|
-
...this.customRenderFields
|
98
|
+
hint: this.hint
|
146
99
|
};
|
147
100
|
}
|
148
|
-
render() {
|
149
|
-
this._questionRenderer.render(this._questionTemplate, this.renderInput);
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* @type {string}
|
154
|
-
*/
|
155
|
-
get question() {
|
156
|
-
return this._question;
|
157
|
-
}
|
158
|
-
|
159
|
-
/**
|
160
|
-
* @param {string} value
|
161
|
-
*/
|
162
|
-
set question(value) {
|
163
|
-
this._question = value;
|
164
|
-
this.render();
|
165
|
-
}
|
166
101
|
|
167
102
|
/**
|
168
103
|
* @type {string}
|
@@ -178,36 +113,11 @@ export class Question {
|
|
178
113
|
this._hintText = value;
|
179
114
|
this.render();
|
180
115
|
}
|
181
|
-
get optional() {
|
182
|
-
return this._optional;
|
183
|
-
}
|
184
|
-
|
185
|
-
/**
|
186
|
-
* @param {boolean} value
|
187
|
-
*/
|
188
|
-
set optional(value) {
|
189
|
-
this._optional = value;
|
190
|
-
this.render();
|
191
|
-
}
|
192
|
-
|
193
|
-
/**
|
194
|
-
* @type {string | null}
|
195
|
-
*/
|
196
|
-
get highlight() {
|
197
|
-
return this._highlight;
|
198
|
-
}
|
199
|
-
|
200
|
-
/**
|
201
|
-
* @param {string | null} value
|
202
|
-
*/
|
203
|
-
set highlight(value) {
|
204
|
-
this._highlight = value;
|
205
|
-
this.render();
|
206
|
-
}
|
207
116
|
}
|
208
117
|
|
209
118
|
/**
|
210
119
|
* @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
120
|
+
* @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'
|
211
121
|
* @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
|
212
122
|
*/
|
213
123
|
//# sourceMappingURL=question.js.map
|