@defra/forms-model 3.0.595 → 3.0.596
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/form/form-editor/preview/helpers.js +7 -2
- package/dist/module/form/form-editor/preview/helpers.js.map +1 -1
- package/dist/module/form/form-editor/preview/long-answer.js +88 -1
- package/dist/module/form/form-editor/preview/long-answer.js.map +1 -1
- package/dist/module/form/form-editor/preview/types.js.map +1 -1
- package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/long-answer.d.ts +137 -0
- package/dist/types/form/form-editor/preview/long-answer.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/types.d.ts +7 -0
- package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/form-editor/preview/helpers.js +11 -2
- package/src/form/form-editor/preview/long-answer.js +90 -1
- package/src/form/form-editor/preview/types.ts +9 -0
|
@@ -11,7 +11,7 @@ import { EmailAddressQuestion } from "./email-address.js";
|
|
|
11
11
|
import { HiddenQuestion } from "./hidden.js";
|
|
12
12
|
import { LatLongComponentPreviewElements, LatLongQuestion } from "./lat-long.js";
|
|
13
13
|
import { ListComponentElements, ListQuestion, SelectComponentElements } from "./list.js";
|
|
14
|
-
import { LongAnswerQuestion } from "./long-answer.js";
|
|
14
|
+
import { LongAnswerQuestion, MultilineTextFieldComponentPreviewElements } from "./long-answer.js";
|
|
15
15
|
import { Markdown } from "./markdown.js";
|
|
16
16
|
import { MonthYearQuestion } from "./month-year.js";
|
|
17
17
|
import { NationalGridComponentPreviewElements, NationalGridQuestion } from "./national-grid.js";
|
|
@@ -77,6 +77,11 @@ const ComponentToPreviewQuestion = {
|
|
|
77
77
|
const list = findDefinitionListFromComponent(componentCoerced, definition);
|
|
78
78
|
return new SelectComponentElements(componentCoerced, list);
|
|
79
79
|
},
|
|
80
|
+
[ComponentType.MultilineTextField]: (component, _definition) => {
|
|
81
|
+
const componentCoerced = /** @type {MultilineTextFieldComponent} */
|
|
82
|
+
component;
|
|
83
|
+
return new MultilineTextFieldComponentPreviewElements(componentCoerced);
|
|
84
|
+
},
|
|
80
85
|
[ComponentType.UkAddressField]: (component, _definition) => {
|
|
81
86
|
const componentCoerced = /** @type {UkAddressFieldComponent} */component;
|
|
82
87
|
return new UkAddressComponentPreviewElements(componentCoerced);
|
|
@@ -151,6 +156,6 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
|
|
|
151
156
|
* @import { Question } from '~/src/form/form-editor/preview/question.js'
|
|
152
157
|
* @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
153
158
|
* @import { FormDefinition } from '~/src/form/form-definition/types.js'
|
|
154
|
-
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
159
|
+
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
155
160
|
*/
|
|
156
161
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["ComponentType","hasContentField","hasInputField","hasListField","hasSelectionFields","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","DeclarationComponentPreviewElements","DeclarationQuestion","EastingNorthingComponentPreviewElements","EastingNorthingQuestion","EmailAddressQuestion","HiddenQuestion","LatLongComponentPreviewElements","LatLongQuestion","ListComponentElements","ListQuestion","SelectComponentElements","LongAnswerQuestion","Markdown","MonthYearQuestion","NationalGridComponentPreviewElements","NationalGridQuestion","NumberComponentPreviewElements","NumberOnlyQuestion","OsGridRefComponentPreviewElements","OsGridRefQuestion","PhoneNumberQuestion","QuestionComponentElements","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressComponentPreviewElements","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","InputFieldComponentDefault","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","DeclarationField","FileUploadField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","HiddenField","ComponentToPreviewQuestion","component","definition","componentCoerced","list","_definition","mapComponentToPreviewQuestion","questionRenderer","questionElements","getQuestionElementsFunc","type","QuestionConstructor","previewComponent","id"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/components/helpers.js'\nimport { AutocompleteListQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { CheckboxQuestion } from '~/src/form/form-editor/preview/checkbox.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport {\n DeclarationComponentPreviewElements,\n DeclarationQuestion\n} from '~/src/form/form-editor/preview/declaration.js'\nimport {\n EastingNorthingComponentPreviewElements,\n EastingNorthingQuestion\n} from '~/src/form/form-editor/preview/easting-northing.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { HiddenQuestion } from '~/src/form/form-editor/preview/hidden.js'\nimport {\n LatLongComponentPreviewElements,\n LatLongQuestion\n} from '~/src/form/form-editor/preview/lat-long.js'\nimport {\n ListComponentElements,\n ListQuestion,\n SelectComponentElements\n} from '~/src/form/form-editor/preview/list.js'\nimport { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'\nimport {\n NationalGridComponentPreviewElements,\n NationalGridQuestion\n} from '~/src/form/form-editor/preview/national-grid.js'\nimport {\n NumberComponentPreviewElements,\n NumberOnlyQuestion\n} from '~/src/form/form-editor/preview/number-only.js'\nimport {\n OsGridRefComponentPreviewElements,\n OsGridRefQuestion\n} from '~/src/form/form-editor/preview/os-grid-ref.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { QuestionComponentElements } from '~/src/form/form-editor/preview/question.js'\nimport { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'\nimport { SelectQuestion } from '~/src/form/form-editor/preview/select.js'\nimport { ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { SupportingEvidenceQuestion } from '~/src/form/form-editor/preview/supporting-evidence.js'\nimport {\n UkAddressComponentPreviewElements,\n UkAddressQuestion\n} from '~/src/form/form-editor/preview/uk-address.js'\nimport { YesNoQuestion } from '~/src/form/form-editor/preview/yes-no.js'\nimport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\n/**\n * @type {typeof PreviewComponent}\n */\nconst InputFieldComponentDefault = ShortAnswerQuestion\n\n/**\n * @type {Partial<Record<ComponentType, typeof PreviewComponent>>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: InputFieldComponentDefault,\n [ComponentType.Details]: ShortAnswerQuestion,\n [ComponentType.InsetText]: ShortAnswerQuestion,\n [ComponentType.Html]: ShortAnswerQuestion,\n [ComponentType.Markdown]: Markdown,\n [ComponentType.List]: ListQuestion,\n [ComponentType.EmailAddressField]: EmailAddressQuestion,\n [ComponentType.NumberField]: NumberOnlyQuestion,\n [ComponentType.MultilineTextField]: LongAnswerQuestion,\n [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,\n [ComponentType.MonthYearField]: MonthYearQuestion,\n [ComponentType.DatePartsField]: DateInputQuestion,\n [ComponentType.UkAddressField]: UkAddressQuestion,\n [ComponentType.AutocompleteField]: AutocompleteListQuestion,\n [ComponentType.RadiosField]: RadioQuestion,\n [ComponentType.CheckboxesField]: CheckboxQuestion,\n [ComponentType.SelectField]: SelectQuestion,\n [ComponentType.YesNoField]: YesNoQuestion,\n [ComponentType.DeclarationField]: DeclarationQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion,\n [ComponentType.EastingNorthingField]: EastingNorthingQuestion,\n [ComponentType.OsGridRefField]: OsGridRefQuestion,\n [ComponentType.NationalGridFieldNumberField]: NationalGridQuestion,\n [ComponentType.LatLongField]: LatLongQuestion,\n [ComponentType.HiddenField]: HiddenQuestion\n}\n\n/**\n * @type {Partial<Record<ComponentType, (component: ComponentDef, definition: FormDefinition ) => QuestionElements>>}\n */\nconst ComponentToPreviewQuestion = {\n [ComponentType.AutocompleteField]: (component, definition) => {\n const componentCoerced = /** @type {AutocompleteFieldComponent} */ (\n component\n )\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.SelectField]: (component, definition) => {\n const componentCoerced = /** @type {SelectFieldComponent} */ (component)\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.UkAddressField]: (component, _definition) => {\n const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)\n return new UkAddressComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NumberField]: (component, _definition) => {\n const componentCoerced = /** @type {NumberFieldComponent} */ (component)\n return new NumberComponentPreviewElements(componentCoerced)\n },\n [ComponentType.DeclarationField]: (component, _definition) => {\n const componentCoerced = /** @type {DeclarationFieldComponent} */ (\n component\n )\n return new DeclarationComponentPreviewElements(componentCoerced)\n },\n [ComponentType.YesNoField]: (component, _definition) => {\n const componentCoerced = /** @type {YesNoFieldComponent} */ (component)\n return new QuestionComponentElements(componentCoerced)\n },\n [ComponentType.EastingNorthingField]: (component, _definition) => {\n const componentCoerced = /** @type {EastingNorthingFieldComponent} */ (\n component\n )\n return new EastingNorthingComponentPreviewElements(componentCoerced)\n },\n [ComponentType.OsGridRefField]: (component, _definition) => {\n const componentCoerced = /** @type {OsGridRefFieldComponent} */ (component)\n return new OsGridRefComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NationalGridFieldNumberField]: (component, _definition) => {\n const componentCoerced =\n /** @type {NationalGridFieldNumberFieldComponent} */ (component)\n return new NationalGridComponentPreviewElements(componentCoerced)\n },\n [ComponentType.LatLongField]: (component, _definition) => {\n const componentCoerced = /** @type {LatLongFieldComponent} */ (component)\n return new LatLongComponentPreviewElements(componentCoerced)\n }\n}\n\n/**\n * @param {QuestionRenderer} questionRenderer\n * @param {FormDefinition} definition\n * @returns {(component: ComponentDef) => Question}\n */\nexport function mapComponentToPreviewQuestion(questionRenderer, definition) {\n return /** @type {(component: ComponentDef) => Question} */ (\n (component) => {\n /**\n * @type {QuestionElements}\n */\n let questionElements\n\n // Look for one-to-one mapping first, then fallback if not found\n const getQuestionElementsFunc = ComponentToPreviewQuestion[component.type]\n if (getQuestionElementsFunc) {\n questionElements = getQuestionElementsFunc(component, definition)\n } else if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (hasInputField(component)) {\n questionElements = new QuestionComponentElements(component)\n } else if (hasContentField(component)) {\n questionElements = new ContentElements(component)\n } else {\n questionElements = new ComponentElements(component)\n }\n\n const QuestionConstructor =\n InputFieldComponentDictionary[component.type] ??\n InputFieldComponentDefault\n const previewComponent = new QuestionConstructor(\n questionElements,\n questionRenderer\n )\n previewComponent.id = component.id\n return previewComponent\n }\n )\n}\n\n/**\n * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,kBAAkB;AAEpB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,mCAAmC,EACnCC,mBAAmB;AAErB,SACEC,uCAAuC,EACvCC,uBAAuB;AAEzB,SAASC,oBAAoB;AAC7B,SAASC,cAAc;AACvB,SACEC,+BAA+B,EAC/BC,eAAe;AAEjB,SACEC,qBAAqB,EACrBC,YAAY,EACZC,uBAAuB;AAEzB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SACEC,oCAAoC,EACpCC,oBAAoB;AAEtB,SACEC,8BAA8B,EAC9BC,kBAAkB;AAEpB,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,aAAa;AACtB,SAASC,+BAA+B;AACxC;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGN,mBAAmB;;AAEtD;AACA;AACA;AACA,MAAMO,6BAA6B,GAAG;EACpC,CAACzC,aAAa,CAAC0C,SAAS,GAAGF,0BAA0B;EACrD,CAACxC,aAAa,CAAC2C,OAAO,GAAGT,mBAAmB;EAC5C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D,CAAC,MAAM,IAAIpE,aAAa,CAACiE,SAAS,CAAC,EAAE;MACnCO,gBAAgB,GAAG,IAAI3C,yBAAyB,CAACoC,SAAS,CAAC;IAC7D,CAAC,MAAM,IAAIlE,eAAe,CAACkE,SAAS,CAAC,EAAE;MACrCO,gBAAgB,GAAG,IAAIlE,eAAe,CAAC2D,SAAS,CAAC;IACnD,CAAC,MAAM;MACLO,gBAAgB,GAAG,IAAInE,iBAAiB,CAAC4D,SAAS,CAAC;IACrD;IAEA,MAAMU,mBAAmB,GACvBpC,6BAA6B,CAAC0B,SAAS,CAACS,IAAI,CAAC,IAC7CpC,0BAA0B;IAC5B,MAAMsC,gBAAgB,GAAG,IAAID,mBAAmB,CAC9CH,gBAAgB,EAChBD,gBACF,CAAC;IACDK,gBAAgB,CAACC,EAAE,GAAGZ,SAAS,CAACY,EAAE;IAClC,OAAOD,gBAAgB;EACzB,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["ComponentType","hasContentField","hasInputField","hasListField","hasSelectionFields","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","DeclarationComponentPreviewElements","DeclarationQuestion","EastingNorthingComponentPreviewElements","EastingNorthingQuestion","EmailAddressQuestion","HiddenQuestion","LatLongComponentPreviewElements","LatLongQuestion","ListComponentElements","ListQuestion","SelectComponentElements","LongAnswerQuestion","MultilineTextFieldComponentPreviewElements","Markdown","MonthYearQuestion","NationalGridComponentPreviewElements","NationalGridQuestion","NumberComponentPreviewElements","NumberOnlyQuestion","OsGridRefComponentPreviewElements","OsGridRefQuestion","PhoneNumberQuestion","QuestionComponentElements","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressComponentPreviewElements","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","InputFieldComponentDefault","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","DeclarationField","FileUploadField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","HiddenField","ComponentToPreviewQuestion","component","definition","componentCoerced","list","_definition","mapComponentToPreviewQuestion","questionRenderer","questionElements","getQuestionElementsFunc","type","QuestionConstructor","previewComponent","id"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/components/helpers.js'\nimport { AutocompleteListQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { CheckboxQuestion } from '~/src/form/form-editor/preview/checkbox.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport {\n DeclarationComponentPreviewElements,\n DeclarationQuestion\n} from '~/src/form/form-editor/preview/declaration.js'\nimport {\n EastingNorthingComponentPreviewElements,\n EastingNorthingQuestion\n} from '~/src/form/form-editor/preview/easting-northing.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { HiddenQuestion } from '~/src/form/form-editor/preview/hidden.js'\nimport {\n LatLongComponentPreviewElements,\n LatLongQuestion\n} from '~/src/form/form-editor/preview/lat-long.js'\nimport {\n ListComponentElements,\n ListQuestion,\n SelectComponentElements\n} from '~/src/form/form-editor/preview/list.js'\nimport {\n LongAnswerQuestion,\n MultilineTextFieldComponentPreviewElements\n} from '~/src/form/form-editor/preview/long-answer.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'\nimport {\n NationalGridComponentPreviewElements,\n NationalGridQuestion\n} from '~/src/form/form-editor/preview/national-grid.js'\nimport {\n NumberComponentPreviewElements,\n NumberOnlyQuestion\n} from '~/src/form/form-editor/preview/number-only.js'\nimport {\n OsGridRefComponentPreviewElements,\n OsGridRefQuestion\n} from '~/src/form/form-editor/preview/os-grid-ref.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { QuestionComponentElements } from '~/src/form/form-editor/preview/question.js'\nimport { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'\nimport { SelectQuestion } from '~/src/form/form-editor/preview/select.js'\nimport { ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { SupportingEvidenceQuestion } from '~/src/form/form-editor/preview/supporting-evidence.js'\nimport {\n UkAddressComponentPreviewElements,\n UkAddressQuestion\n} from '~/src/form/form-editor/preview/uk-address.js'\nimport { YesNoQuestion } from '~/src/form/form-editor/preview/yes-no.js'\nimport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\n/**\n * @type {typeof PreviewComponent}\n */\nconst InputFieldComponentDefault = ShortAnswerQuestion\n\n/**\n * @type {Partial<Record<ComponentType, typeof PreviewComponent>>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: InputFieldComponentDefault,\n [ComponentType.Details]: ShortAnswerQuestion,\n [ComponentType.InsetText]: ShortAnswerQuestion,\n [ComponentType.Html]: ShortAnswerQuestion,\n [ComponentType.Markdown]: Markdown,\n [ComponentType.List]: ListQuestion,\n [ComponentType.EmailAddressField]: EmailAddressQuestion,\n [ComponentType.NumberField]: NumberOnlyQuestion,\n [ComponentType.MultilineTextField]: LongAnswerQuestion,\n [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,\n [ComponentType.MonthYearField]: MonthYearQuestion,\n [ComponentType.DatePartsField]: DateInputQuestion,\n [ComponentType.UkAddressField]: UkAddressQuestion,\n [ComponentType.AutocompleteField]: AutocompleteListQuestion,\n [ComponentType.RadiosField]: RadioQuestion,\n [ComponentType.CheckboxesField]: CheckboxQuestion,\n [ComponentType.SelectField]: SelectQuestion,\n [ComponentType.YesNoField]: YesNoQuestion,\n [ComponentType.DeclarationField]: DeclarationQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion,\n [ComponentType.EastingNorthingField]: EastingNorthingQuestion,\n [ComponentType.OsGridRefField]: OsGridRefQuestion,\n [ComponentType.NationalGridFieldNumberField]: NationalGridQuestion,\n [ComponentType.LatLongField]: LatLongQuestion,\n [ComponentType.HiddenField]: HiddenQuestion\n}\n\n/**\n * @type {Partial<Record<ComponentType, (component: ComponentDef, definition: FormDefinition ) => QuestionElements>>}\n */\nconst ComponentToPreviewQuestion = {\n [ComponentType.AutocompleteField]: (component, definition) => {\n const componentCoerced = /** @type {AutocompleteFieldComponent} */ (\n component\n )\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.SelectField]: (component, definition) => {\n const componentCoerced = /** @type {SelectFieldComponent} */ (component)\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.MultilineTextField]: (component, _definition) => {\n const componentCoerced = /** @type {MultilineTextFieldComponent} */ (\n component\n )\n return new MultilineTextFieldComponentPreviewElements(componentCoerced)\n },\n [ComponentType.UkAddressField]: (component, _definition) => {\n const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)\n return new UkAddressComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NumberField]: (component, _definition) => {\n const componentCoerced = /** @type {NumberFieldComponent} */ (component)\n return new NumberComponentPreviewElements(componentCoerced)\n },\n [ComponentType.DeclarationField]: (component, _definition) => {\n const componentCoerced = /** @type {DeclarationFieldComponent} */ (\n component\n )\n return new DeclarationComponentPreviewElements(componentCoerced)\n },\n [ComponentType.YesNoField]: (component, _definition) => {\n const componentCoerced = /** @type {YesNoFieldComponent} */ (component)\n return new QuestionComponentElements(componentCoerced)\n },\n [ComponentType.EastingNorthingField]: (component, _definition) => {\n const componentCoerced = /** @type {EastingNorthingFieldComponent} */ (\n component\n )\n return new EastingNorthingComponentPreviewElements(componentCoerced)\n },\n [ComponentType.OsGridRefField]: (component, _definition) => {\n const componentCoerced = /** @type {OsGridRefFieldComponent} */ (component)\n return new OsGridRefComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NationalGridFieldNumberField]: (component, _definition) => {\n const componentCoerced =\n /** @type {NationalGridFieldNumberFieldComponent} */ (component)\n return new NationalGridComponentPreviewElements(componentCoerced)\n },\n [ComponentType.LatLongField]: (component, _definition) => {\n const componentCoerced = /** @type {LatLongFieldComponent} */ (component)\n return new LatLongComponentPreviewElements(componentCoerced)\n }\n}\n\n/**\n * @param {QuestionRenderer} questionRenderer\n * @param {FormDefinition} definition\n * @returns {(component: ComponentDef) => Question}\n */\nexport function mapComponentToPreviewQuestion(questionRenderer, definition) {\n return /** @type {(component: ComponentDef) => Question} */ (\n (component) => {\n /**\n * @type {QuestionElements}\n */\n let questionElements\n\n // Look for one-to-one mapping first, then fallback if not found\n const getQuestionElementsFunc = ComponentToPreviewQuestion[component.type]\n if (getQuestionElementsFunc) {\n questionElements = getQuestionElementsFunc(component, definition)\n } else if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (hasInputField(component)) {\n questionElements = new QuestionComponentElements(component)\n } else if (hasContentField(component)) {\n questionElements = new ContentElements(component)\n } else {\n questionElements = new ComponentElements(component)\n }\n\n const QuestionConstructor =\n InputFieldComponentDictionary[component.type] ??\n InputFieldComponentDefault\n const previewComponent = new QuestionConstructor(\n questionElements,\n questionRenderer\n )\n previewComponent.id = component.id\n return previewComponent\n }\n )\n}\n\n/**\n * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,kBAAkB;AAEpB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,mCAAmC,EACnCC,mBAAmB;AAErB,SACEC,uCAAuC,EACvCC,uBAAuB;AAEzB,SAASC,oBAAoB;AAC7B,SAASC,cAAc;AACvB,SACEC,+BAA+B,EAC/BC,eAAe;AAEjB,SACEC,qBAAqB,EACrBC,YAAY,EACZC,uBAAuB;AAEzB,SACEC,kBAAkB,EAClBC,0CAA0C;AAE5C,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SACEC,oCAAoC,EACpCC,oBAAoB;AAEtB,SACEC,8BAA8B,EAC9BC,kBAAkB;AAEpB,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,aAAa;AACtB,SAASC,+BAA+B;AACxC;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGN,mBAAmB;;AAEtD;AACA;AACA;AACA,MAAMO,6BAA6B,GAAG;EACpC,CAAC1C,aAAa,CAAC2C,SAAS,GAAGF,0BAA0B;EACrD,CAACzC,aAAa,CAAC4C,OAAO,GAAGT,mBAAmB;EAC5C,CAACnC,aAAa,CAAC6C,SAAS,GAAGV,mBAAmB;EAC9C,CAACnC,aAAa,CAAC8C,IAAI,GAAGX,mBAA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U,CAAC;MACnEM,gBAAgB,GAAG,IAAIzD,qBAAqB,CAACkD,SAAS,EAAEG,IAAI,CAAC;IAC/D,CAAC,MAAM,IAAIrE,aAAa,CAACkE,SAAS,CAAC,EAAE;MACnCO,gBAAgB,GAAG,IAAI3C,yBAAyB,CAACoC,SAAS,CAAC;IAC7D,CAAC,MAAM,IAAInE,eAAe,CAACmE,SAAS,CAAC,EAAE;MACrCO,gBAAgB,GAAG,IAAInE,eAAe,CAAC4D,SAAS,CAAC;IACnD,CAAC,MAAM;MACLO,gBAAgB,GAAG,IAAIpE,iBAAiB,CAAC6D,SAAS,CAAC;IACrD;IAEA,MAAMU,mBAAmB,GACvBpC,6BAA6B,CAAC0B,SAAS,CAACS,IAAI,CAAC,IAC7CpC,0BAA0B;IAC5B,MAAMsC,gBAAgB,GAAG,IAAID,mBAAmB,CAC9CH,gBAAgB,EAChBD,gBACF,CAAC;IACDK,gBAAgB,CAACC,EAAE,GAAGZ,SAAS,CAACY,EAAE;IAClC,OAAOD,gBAAgB;EACzB,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import { ComponentType } from "../../../components/enums.js";
|
|
2
2
|
import { PreviewComponent } from "./preview.js";
|
|
3
|
-
import { Question } from "./question.js";
|
|
3
|
+
import { Question, QuestionComponentElements } from "./question.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @constant
|
|
7
|
+
* @type {number}
|
|
8
|
+
* The default number of rows for a multiline text field.
|
|
9
|
+
*/
|
|
10
|
+
export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @implements {QuestionElements}
|
|
14
|
+
*/
|
|
15
|
+
export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {
|
|
16
|
+
/**
|
|
17
|
+
* @param {MultilineTextFieldComponent} component
|
|
18
|
+
*/
|
|
19
|
+
constructor(component) {
|
|
20
|
+
super(component);
|
|
21
|
+
this._maxLength = component.schema.max;
|
|
22
|
+
this._rows = component.options.rows;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @protected
|
|
27
|
+
* @returns {MultilineTextFieldSettings}
|
|
28
|
+
*/
|
|
29
|
+
_getValues() {
|
|
30
|
+
return {
|
|
31
|
+
...super._getValues(),
|
|
32
|
+
maxLength: this._maxLength ?? 0,
|
|
33
|
+
rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
4
37
|
export class LongAnswerQuestion extends Question {
|
|
5
38
|
/**
|
|
6
39
|
* @type {ComponentType}
|
|
@@ -16,5 +49,59 @@ export class LongAnswerQuestion extends Question {
|
|
|
16
49
|
* @protected
|
|
17
50
|
*/
|
|
18
51
|
_fieldName = 'longAnswerField';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {MultilineTextFieldElements} htmlElements
|
|
55
|
+
* @param {QuestionRenderer} questionRenderer
|
|
56
|
+
*/
|
|
57
|
+
constructor(htmlElements, questionRenderer) {
|
|
58
|
+
super(htmlElements, questionRenderer);
|
|
59
|
+
this._maxLength = htmlElements.values.maxLength;
|
|
60
|
+
this._rows = htmlElements.values.rows;
|
|
61
|
+
}
|
|
62
|
+
get maxLength() {
|
|
63
|
+
return this._maxLength;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {number} val
|
|
68
|
+
*/
|
|
69
|
+
set maxLength(val) {
|
|
70
|
+
this._maxLength = val;
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
get rows() {
|
|
74
|
+
return this._rows;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {number} val
|
|
79
|
+
*/
|
|
80
|
+
set rows(val) {
|
|
81
|
+
this._rows = val;
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @protected
|
|
87
|
+
*/
|
|
88
|
+
_renderInput() {
|
|
89
|
+
const maxLengthObj = this.maxLength && this.maxLength > 0 ? {
|
|
90
|
+
maxlength: this.maxLength
|
|
91
|
+
} : {};
|
|
92
|
+
const rowsObj = this.rows ? {
|
|
93
|
+
rows: this.rows
|
|
94
|
+
} : {};
|
|
95
|
+
return {
|
|
96
|
+
...super._renderInput(),
|
|
97
|
+
...maxLengthObj,
|
|
98
|
+
...rowsObj
|
|
99
|
+
};
|
|
100
|
+
}
|
|
19
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
105
|
+
* @import { MultilineTextFieldComponent } from '~/src/components/types.js'
|
|
106
|
+
*/
|
|
20
107
|
//# sourceMappingURL=long-answer.js.map
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
1
|
+
{"version":3,"file":"long-answer.js","names":["ComponentType","PreviewComponent","Question","QuestionComponentElements","MULTILINE_TEXT_QUESTION_DEFAULT_ROWS","MultilineTextFieldComponentPreviewElements","constructor","component","_maxLength","schema","max","_rows","options","rows","_getValues","maxLength","LongAnswerQuestion","componentType","MultilineTextField","_questionTemplate","PATH","_fieldName","htmlElements","questionRenderer","values","val","render","_renderInput","maxLengthObj","maxlength","rowsObj"],"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 {\n Question,\n QuestionComponentElements\n} from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @constant\n * @type {number}\n * The default number of rows for a multiline text field.\n */\nexport const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5\n\n/**\n * @implements {QuestionElements}\n */\nexport class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {\n /**\n * @param {MultilineTextFieldComponent} component\n */\n constructor(component) {\n super(component)\n this._maxLength = component.schema.max\n this._rows = component.options.rows\n }\n\n /**\n * @protected\n * @returns {MultilineTextFieldSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n maxLength: this._maxLength ?? 0,\n rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS\n }\n }\n}\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 /**\n * @param {MultilineTextFieldElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n this._maxLength = htmlElements.values.maxLength\n this._rows = htmlElements.values.rows\n }\n\n get maxLength() {\n return this._maxLength\n }\n\n /**\n * @param {number} val\n */\n set maxLength(val) {\n this._maxLength = val\n this.render()\n }\n\n get rows() {\n return this._rows\n }\n\n /**\n * @param {number} val\n */\n set rows(val) {\n this._rows = val\n this.render()\n }\n\n /**\n * @protected\n */\n _renderInput() {\n const maxLengthObj =\n this.maxLength && this.maxLength > 0 ? { maxlength: this.maxLength } : {}\n const rowsObj = this.rows ? { rows: this.rows } : {}\n return {\n ...super._renderInput(),\n ...maxLengthObj,\n ...rowsObj\n }\n }\n}\n\n/**\n * @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { MultilineTextFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SACEC,QAAQ,EACRC,yBAAyB;;AAG3B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oCAAoC,GAAG,CAAC;;AAErD;AACA;AACA;AACA,OAAO,MAAMC,0CAA0C,SAASF,yBAAyB,CAAC;EACxF;AACF;AACA;EACEG,WAAWA,CAACC,SAAS,EAAE;IACrB,KAAK,CAACA,SAAS,CAAC;IAChB,IAAI,CAACC,UAAU,GAAGD,SAAS,CAACE,MAAM,CAACC,GAAG;IACtC,IAAI,CAACC,KAAK,GAAGJ,SAAS,CAACK,OAAO,CAACC,IAAI;EACrC;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,OAAO;MACL,GAAG,KAAK,CAACA,UAAU,CAAC,CAAC;MACrBC,SAAS,EAAE,IAAI,CAACP,UAAU,IAAI,CAAC;MAC/BK,IAAI,EAAE,IAAI,CAACF,KAAK,IAAIP;IACtB,CAAC;EACH;AACF;AAEA,OAAO,MAAMY,kBAAkB,SAASd,QAAQ,CAAC;EAC/C;AACF;AACA;EACEe,aAAa,GAAGjB,aAAa,CAACkB,kBAAkB;EAChD;AACF;AACA;AACA;EACEC,iBAAiB,GAAGlB,gBAAgB,CAACmB,IAAI,GAAG,cAAc;EAC1D;AACF;AACA;AACA;EACEC,UAAU,GAAG,iBAAiB;;EAE9B;AACF;AACA;AACA;EACEf,WAAWA,CAACgB,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,IAAI,CAACf,UAAU,GAAGc,YAAY,CAACE,MAAM,CAACT,SAAS;IAC/C,IAAI,CAACJ,KAAK,GAAGW,YAAY,CAACE,MAAM,CAACX,IAAI;EACvC;EAEA,IAAIE,SAASA,CAAA,EAAG;IACd,OAAO,IAAI,CAACP,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAIO,SAASA,CAACU,GAAG,EAAE;IACjB,IAAI,CAACjB,UAAU,GAAGiB,GAAG;IACrB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEA,IAAIb,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAACF,KAAK;EACnB;;EAEA;AACF;AACA;EACE,IAAIE,IAAIA,CAACY,GAAG,EAAE;IACZ,IAAI,CAACd,KAAK,GAAGc,GAAG;IAChB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACEC,YAAYA,CAAA,EAAG;IACb,MAAMC,YAAY,GAChB,IAAI,CAACb,SAAS,IAAI,IAAI,CAACA,SAAS,GAAG,CAAC,GAAG;MAAEc,SAAS,EAAE,IAAI,CAACd;IAAU,CAAC,GAAG,CAAC,CAAC;IAC3E,MAAMe,OAAO,GAAG,IAAI,CAACjB,IAAI,GAAG;MAAEA,IAAI,EAAE,IAAI,CAACA;IAAK,CAAC,GAAG,CAAC,CAAC;IACpD,OAAO;MACL,GAAG,KAAK,CAACc,YAAY,CAAC,CAAC;MACvB,GAAGC,YAAY;MACf,GAAGE;IACL,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import {\n type PagePreviewPanelMacro,\n type QuestionBaseModel\n} from '~/src/form/form-editor/macros/types.js'\nimport { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type SelectSortableQuestion } from '~/src/form/form-editor/preview/select-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { type ListElement } from '~/src/form/form-editor/types.js'\nexport { type QuestionBaseModel } from '~/src/form/form-editor/macros/types.js'\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n userClasses: string\n items: ListElement[]\n content: string\n attributes?: Record<string, string>\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n isPageHeading?: boolean\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | HTMLTextAreaElement | null,\n (target: HTMLInputElement | HTMLTextAreaElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface NumberSettings extends BaseSettings {\n prefix: string\n suffix: string\n}\n\nexport interface DeclarationSettings extends BaseSettings {\n declarationText: string\n}\n\nexport interface DeclarationElements extends DomElementsBase {\n readonly values: DeclarationSettings\n}\n\nexport interface UkAddressSettings extends BaseSettings {\n usePostcodeLookup?: boolean\n}\n\nexport interface UkAddressElements extends DomElementsBase {\n readonly values: UkAddressSettings\n}\n\nexport interface NumberElements extends DomElementsBase {\n readonly values: NumberSettings\n}\n\nexport interface LocationSettings extends BaseSettings {\n instructionText: string\n}\n\nexport interface LocationElements extends DomElementsBase {\n readonly values: LocationSettings\n}\n\nexport interface LocationFieldModel extends QuestionBaseModel {\n userClasses: string\n fieldset: {\n legend: {\n text: string\n classes: string\n }\n }\n instructionText: string\n details: {\n classes: string\n }\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface PageRenderer {\n render(pageTemplate: string, pagePreview: PagePreviewPanelMacro): void\n}\n\nexport type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PagePreviewBaseElements {\n heading: string\n guidance: string\n}\n\nexport interface PageSectionInfo {\n title: string\n hideTitle: boolean\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n section?: PageSectionInfo\n}\n\nexport interface SectionForPreview {\n name: string\n title: string\n pages: { title: string }[]\n}\n\nexport interface SummaryPageElements extends PagePreviewBaseElements {\n declaration: boolean\n showConfirmationEmail: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport interface SummaryPageInitialState {\n showConfirmationEmail: boolean\n declarationText: string\n needDeclaration: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import {\n type PagePreviewPanelMacro,\n type QuestionBaseModel\n} from '~/src/form/form-editor/macros/types.js'\nimport { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type SelectSortableQuestion } from '~/src/form/form-editor/preview/select-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { type ListElement } from '~/src/form/form-editor/types.js'\nexport { type QuestionBaseModel } from '~/src/form/form-editor/macros/types.js'\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n userClasses: string\n items: ListElement[]\n content: string\n attributes?: Record<string, string>\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n isPageHeading?: boolean\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | HTMLTextAreaElement | null,\n (target: HTMLInputElement | HTMLTextAreaElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface NumberSettings extends BaseSettings {\n prefix: string\n suffix: string\n}\n\nexport interface DeclarationSettings extends BaseSettings {\n declarationText: string\n}\n\nexport interface DeclarationElements extends DomElementsBase {\n readonly values: DeclarationSettings\n}\n\nexport interface UkAddressSettings extends BaseSettings {\n usePostcodeLookup?: boolean\n}\n\nexport interface UkAddressElements extends DomElementsBase {\n readonly values: UkAddressSettings\n}\n\nexport interface NumberElements extends DomElementsBase {\n readonly values: NumberSettings\n}\n\nexport interface MultilineTextFieldSettings extends BaseSettings {\n maxLength: number\n rows: number\n}\n\nexport interface MultilineTextFieldElements extends DomElementsBase {\n readonly values: MultilineTextFieldSettings\n}\n\nexport interface LocationSettings extends BaseSettings {\n instructionText: string\n}\n\nexport interface LocationElements extends DomElementsBase {\n readonly values: LocationSettings\n}\n\nexport interface LocationFieldModel extends QuestionBaseModel {\n userClasses: string\n fieldset: {\n legend: {\n text: string\n classes: string\n }\n }\n instructionText: string\n details: {\n classes: string\n }\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface PageRenderer {\n render(pageTemplate: string, pagePreview: PagePreviewPanelMacro): void\n}\n\nexport type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PagePreviewBaseElements {\n heading: string\n guidance: string\n}\n\nexport interface PageSectionInfo {\n title: string\n hideTitle: boolean\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n section?: PageSectionInfo\n}\n\nexport interface SectionForPreview {\n name: string\n title: string\n pages: { title: string }[]\n}\n\nexport interface SummaryPageElements extends PagePreviewBaseElements {\n declaration: boolean\n showConfirmationEmail: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport interface SummaryPageInitialState {\n showConfirmationEmail: boolean\n declarationText: string\n needDeclaration: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/helpers.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/helpers.js"],"names":[],"mappings":"AA8JA;;;;GAIG;AACH,gEAJW,gBAAgB,cAChB,cAAc,GACZ,CAAC,SAAS,EAAE,YAAY,KAAK,QAAQ,CAoCjD;sCAGsD,yCAAyC;oCAG7D,qCAAqC;kCAC6P,2BAA2B;8BAHnU,4CAA4C"}
|
|
@@ -1,4 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @constant
|
|
3
|
+
* @type {number}
|
|
4
|
+
* The default number of rows for a multiline text field.
|
|
5
|
+
*/
|
|
6
|
+
export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS: number;
|
|
7
|
+
/**
|
|
8
|
+
* @implements {QuestionElements}
|
|
9
|
+
*/
|
|
10
|
+
export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements implements QuestionElements {
|
|
11
|
+
/**
|
|
12
|
+
* @param {MultilineTextFieldComponent} component
|
|
13
|
+
*/
|
|
14
|
+
constructor(component: MultilineTextFieldComponent);
|
|
15
|
+
_maxLength: number | undefined;
|
|
16
|
+
_rows: number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* @protected
|
|
19
|
+
* @returns {MultilineTextFieldSettings}
|
|
20
|
+
*/
|
|
21
|
+
protected _getValues(): MultilineTextFieldSettings;
|
|
22
|
+
}
|
|
1
23
|
export class LongAnswerQuestion extends Question {
|
|
24
|
+
/**
|
|
25
|
+
* @param {MultilineTextFieldElements} htmlElements
|
|
26
|
+
* @param {QuestionRenderer} questionRenderer
|
|
27
|
+
*/
|
|
28
|
+
constructor(htmlElements: MultilineTextFieldElements, questionRenderer: QuestionRenderer);
|
|
29
|
+
_maxLength: number;
|
|
30
|
+
_rows: number;
|
|
31
|
+
/**
|
|
32
|
+
* @param {number} val
|
|
33
|
+
*/
|
|
34
|
+
set maxLength(val: number);
|
|
35
|
+
get maxLength(): number;
|
|
36
|
+
/**
|
|
37
|
+
* @param {number} val
|
|
38
|
+
*/
|
|
39
|
+
set rows(val: number);
|
|
40
|
+
get rows(): number;
|
|
41
|
+
/**
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
protected _renderInput(): {
|
|
45
|
+
rows: number;
|
|
46
|
+
maxlength: number;
|
|
47
|
+
id?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
content?: string;
|
|
50
|
+
attributes?: Record<string, string>;
|
|
51
|
+
label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
52
|
+
hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
53
|
+
fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
|
|
54
|
+
items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
|
|
55
|
+
text?: string;
|
|
56
|
+
formGroup?: import("../macros/types.js").FormGroupAfterInput;
|
|
57
|
+
type?: "text" | "number" | "boolean";
|
|
58
|
+
classes?: string;
|
|
59
|
+
previewClasses?: string;
|
|
60
|
+
prefix?: {
|
|
61
|
+
text: string;
|
|
62
|
+
};
|
|
63
|
+
suffix?: {
|
|
64
|
+
text: string;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
rows?: undefined;
|
|
68
|
+
maxlength: number;
|
|
69
|
+
id?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
content?: string;
|
|
72
|
+
attributes?: Record<string, string>;
|
|
73
|
+
label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
74
|
+
hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
75
|
+
fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
|
|
76
|
+
items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
|
|
77
|
+
text?: string;
|
|
78
|
+
formGroup?: import("../macros/types.js").FormGroupAfterInput;
|
|
79
|
+
type?: "text" | "number" | "boolean";
|
|
80
|
+
classes?: string;
|
|
81
|
+
previewClasses?: string;
|
|
82
|
+
prefix?: {
|
|
83
|
+
text: string;
|
|
84
|
+
};
|
|
85
|
+
suffix?: {
|
|
86
|
+
text: string;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
rows: number;
|
|
90
|
+
maxlength?: undefined;
|
|
91
|
+
id?: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
content?: string;
|
|
94
|
+
attributes?: Record<string, string>;
|
|
95
|
+
label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
96
|
+
hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
97
|
+
fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
|
|
98
|
+
items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
|
|
99
|
+
text?: string;
|
|
100
|
+
formGroup?: import("../macros/types.js").FormGroupAfterInput;
|
|
101
|
+
type?: "text" | "number" | "boolean";
|
|
102
|
+
classes?: string;
|
|
103
|
+
previewClasses?: string;
|
|
104
|
+
prefix?: {
|
|
105
|
+
text: string;
|
|
106
|
+
};
|
|
107
|
+
suffix?: {
|
|
108
|
+
text: string;
|
|
109
|
+
};
|
|
110
|
+
} | {
|
|
111
|
+
rows?: undefined;
|
|
112
|
+
maxlength?: undefined;
|
|
113
|
+
id?: string;
|
|
114
|
+
name?: string;
|
|
115
|
+
content?: string;
|
|
116
|
+
attributes?: Record<string, string>;
|
|
117
|
+
label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
118
|
+
hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
|
|
119
|
+
fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
|
|
120
|
+
items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
|
|
121
|
+
text?: string;
|
|
122
|
+
formGroup?: import("../macros/types.js").FormGroupAfterInput;
|
|
123
|
+
type?: "text" | "number" | "boolean";
|
|
124
|
+
classes?: string;
|
|
125
|
+
previewClasses?: string;
|
|
126
|
+
prefix?: {
|
|
127
|
+
text: string;
|
|
128
|
+
};
|
|
129
|
+
suffix?: {
|
|
130
|
+
text: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
2
133
|
}
|
|
134
|
+
import type { QuestionElements } from '../../../form/form-editor/preview/types.js';
|
|
135
|
+
import { QuestionComponentElements } from '../../../form/form-editor/preview/question.js';
|
|
136
|
+
import type { MultilineTextFieldSettings } from '../../../form/form-editor/preview/types.js';
|
|
137
|
+
import type { MultilineTextFieldComponent } from '../../../components/types.js';
|
|
3
138
|
import { Question } from '../../../form/form-editor/preview/question.js';
|
|
139
|
+
import type { MultilineTextFieldElements } from '../../../form/form-editor/preview/types.js';
|
|
140
|
+
import type { QuestionRenderer } from '../../../form/form-editor/preview/types.js';
|
|
4
141
|
//# sourceMappingURL=long-answer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"long-answer.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"long-answer.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,mDAHU,MAAM,CAGqC;AAErD;;GAEG;AACH;IACE;;OAEG;IACH,uBAFW,2BAA2B,EAMrC;IAFC,+BAAsC;IACtC,0BAAmC;IAGrC;;;OAGG;IACH,wBAFa,0BAA0B,CAQtC;CACF;AAED;IAgBE;;;OAGG;IACH,0BAHW,0BAA0B,oBAC1B,gBAAgB,EAM1B;IAFC,mBAA+C;IAC/C,cAAqC;IAOvC;;OAEG;IACH,mBAFW,MAAM,EAKhB;IAVD,iBAKW,MAAM,CAHhB;IAcD;;OAEG;IACH,cAFW,MAAM,EAKhB;IAVD,YAKW,MAAM,CAHhB;IAUD;;OAEG;IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASC;CACF;sCAG8G,yCAAyC;0CArGjJ,4CAA4C;gDAqG4D,yCAAyC;iDACxG,2BAA2B;yBAtGpE,4CAA4C;gDAqG4D,yCAAyC;sCAAzC,yCAAyC"}
|
|
@@ -67,6 +67,13 @@ export interface UkAddressElements extends DomElementsBase {
|
|
|
67
67
|
export interface NumberElements extends DomElementsBase {
|
|
68
68
|
readonly values: NumberSettings;
|
|
69
69
|
}
|
|
70
|
+
export interface MultilineTextFieldSettings extends BaseSettings {
|
|
71
|
+
maxLength: number;
|
|
72
|
+
rows: number;
|
|
73
|
+
}
|
|
74
|
+
export interface MultilineTextFieldElements extends DomElementsBase {
|
|
75
|
+
readonly values: MultilineTextFieldSettings;
|
|
76
|
+
}
|
|
70
77
|
export interface LocationSettings extends BaseSettings {
|
|
71
78
|
instructionText: string;
|
|
72
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL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,eAAe,EAAE,OAAO,CAAA;IACxB,gCAAgC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC9B,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACtC;AAED,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,QAAQ,GACR,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,oBAAoB,CAAA"}
|
package/package.json
CHANGED
|
@@ -29,7 +29,10 @@ import {
|
|
|
29
29
|
ListQuestion,
|
|
30
30
|
SelectComponentElements
|
|
31
31
|
} from '~/src/form/form-editor/preview/list.js'
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
LongAnswerQuestion,
|
|
34
|
+
MultilineTextFieldComponentPreviewElements
|
|
35
|
+
} from '~/src/form/form-editor/preview/long-answer.js'
|
|
33
36
|
import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
|
|
34
37
|
import { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'
|
|
35
38
|
import {
|
|
@@ -108,6 +111,12 @@ const ComponentToPreviewQuestion = {
|
|
|
108
111
|
const list = findDefinitionListFromComponent(componentCoerced, definition)
|
|
109
112
|
return new SelectComponentElements(componentCoerced, list)
|
|
110
113
|
},
|
|
114
|
+
[ComponentType.MultilineTextField]: (component, _definition) => {
|
|
115
|
+
const componentCoerced = /** @type {MultilineTextFieldComponent} */ (
|
|
116
|
+
component
|
|
117
|
+
)
|
|
118
|
+
return new MultilineTextFieldComponentPreviewElements(componentCoerced)
|
|
119
|
+
},
|
|
111
120
|
[ComponentType.UkAddressField]: (component, _definition) => {
|
|
112
121
|
const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)
|
|
113
122
|
return new UkAddressComponentPreviewElements(componentCoerced)
|
|
@@ -193,5 +202,5 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
|
|
|
193
202
|
* @import { Question } from '~/src/form/form-editor/preview/question.js'
|
|
194
203
|
* @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
195
204
|
* @import { FormDefinition } from '~/src/form/form-definition/types.js'
|
|
196
|
-
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
205
|
+
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
197
206
|
*/
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { ComponentType } from '~/src/components/enums.js'
|
|
2
2
|
import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Question,
|
|
5
|
+
QuestionComponentElements
|
|
6
|
+
} from '~/src/form/form-editor/preview/question.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @constant
|
|
10
|
+
* @type {number}
|
|
11
|
+
* The default number of rows for a multiline text field.
|
|
12
|
+
*/
|
|
13
|
+
export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @implements {QuestionElements}
|
|
17
|
+
*/
|
|
18
|
+
export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {
|
|
19
|
+
/**
|
|
20
|
+
* @param {MultilineTextFieldComponent} component
|
|
21
|
+
*/
|
|
22
|
+
constructor(component) {
|
|
23
|
+
super(component)
|
|
24
|
+
this._maxLength = component.schema.max
|
|
25
|
+
this._rows = component.options.rows
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @protected
|
|
30
|
+
* @returns {MultilineTextFieldSettings}
|
|
31
|
+
*/
|
|
32
|
+
_getValues() {
|
|
33
|
+
return {
|
|
34
|
+
...super._getValues(),
|
|
35
|
+
maxLength: this._maxLength ?? 0,
|
|
36
|
+
rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
4
40
|
|
|
5
41
|
export class LongAnswerQuestion extends Question {
|
|
6
42
|
/**
|
|
@@ -17,4 +53,57 @@ export class LongAnswerQuestion extends Question {
|
|
|
17
53
|
* @protected
|
|
18
54
|
*/
|
|
19
55
|
_fieldName = 'longAnswerField'
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {MultilineTextFieldElements} htmlElements
|
|
59
|
+
* @param {QuestionRenderer} questionRenderer
|
|
60
|
+
*/
|
|
61
|
+
constructor(htmlElements, questionRenderer) {
|
|
62
|
+
super(htmlElements, questionRenderer)
|
|
63
|
+
this._maxLength = htmlElements.values.maxLength
|
|
64
|
+
this._rows = htmlElements.values.rows
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get maxLength() {
|
|
68
|
+
return this._maxLength
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {number} val
|
|
73
|
+
*/
|
|
74
|
+
set maxLength(val) {
|
|
75
|
+
this._maxLength = val
|
|
76
|
+
this.render()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get rows() {
|
|
80
|
+
return this._rows
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {number} val
|
|
85
|
+
*/
|
|
86
|
+
set rows(val) {
|
|
87
|
+
this._rows = val
|
|
88
|
+
this.render()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @protected
|
|
93
|
+
*/
|
|
94
|
+
_renderInput() {
|
|
95
|
+
const maxLengthObj =
|
|
96
|
+
this.maxLength && this.maxLength > 0 ? { maxlength: this.maxLength } : {}
|
|
97
|
+
const rowsObj = this.rows ? { rows: this.rows } : {}
|
|
98
|
+
return {
|
|
99
|
+
...super._renderInput(),
|
|
100
|
+
...maxLengthObj,
|
|
101
|
+
...rowsObj
|
|
102
|
+
}
|
|
103
|
+
}
|
|
20
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
108
|
+
* @import { MultilineTextFieldComponent } from '~/src/components/types.js'
|
|
109
|
+
*/
|
|
@@ -83,6 +83,15 @@ export interface NumberElements extends DomElementsBase {
|
|
|
83
83
|
readonly values: NumberSettings
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export interface MultilineTextFieldSettings extends BaseSettings {
|
|
87
|
+
maxLength: number
|
|
88
|
+
rows: number
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface MultilineTextFieldElements extends DomElementsBase {
|
|
92
|
+
readonly values: MultilineTextFieldSettings
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
export interface LocationSettings extends BaseSettings {
|
|
87
96
|
instructionText: string
|
|
88
97
|
}
|