@defra/forms-engine-plugin 4.11.0 → 4.11.1
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.
|
@@ -9,7 +9,7 @@ export class MultilineTextField extends FormComponent {
|
|
|
9
9
|
schema,
|
|
10
10
|
options
|
|
11
11
|
} = def;
|
|
12
|
-
let formSchema = Joi.string().trim().label(this.label).required();
|
|
12
|
+
let formSchema = Joi.string().replace(/\r\n/g, '\n').trim().label(this.label).required();
|
|
13
13
|
if (options.required === false) {
|
|
14
14
|
formSchema = formSchema.allow('');
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultilineTextField.js","names":["Joi","FormComponent","messageTemplate","MultilineTextField","isCharacterOrWordCount","constructor","def","props","schema","options","formSchema","string","trim","label","required","allow","length","max","min","maxWords","custom","getValidatorMaxWords","regex","pattern","RegExp","customValidationMessage","message","messages","customValidationMessages","minMaxErrorText","buildMinMaxText","ruleset","default","stateSchema","getViewModel","payload","errors","viewModel","maxlength","maxwords","rows","minMaxError","minMax","replace","toString","getAllPossibleErrors","staticErrors","advancedSettingsErrors","type","template","baseErrors","component","validator","value","helpers","limit","count","error","text","tokens","match"],"sources":["../../../../../src/server/plugins/engine/components/MultilineTextField.ts"],"sourcesContent":["import { type MultilineTextFieldComponent } from '@defra/forms-model'\nimport Joi, { type CustomValidator, type StringSchema } from 'joi'\n\nimport { type ComponentBase } from '~/src/server/plugins/engine/components/ComponentBase.js'\nimport { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js'\nimport { messageTemplate } from '~/src/server/plugins/engine/pageControllers/validationOptions.js'\nimport {\n type ErrorMessageTemplateList,\n type FormPayload,\n type FormSubmissionError\n} from '~/src/server/plugins/engine/types.js'\n\nexport class MultilineTextField extends FormComponent {\n declare options: MultilineTextFieldComponent['options']\n declare schema: MultilineTextFieldComponent['schema']\n declare formSchema: StringSchema\n declare stateSchema: StringSchema\n\n isCharacterOrWordCount = false\n\n constructor(\n def: MultilineTextFieldComponent,\n props: ConstructorParameters<typeof ComponentBase>[1]\n ) {\n super(def, props)\n\n const { schema, options } = def\n\n let formSchema = Joi.string().trim().label(this.label).required()\n\n if (options.required === false) {\n formSchema = formSchema.allow('')\n }\n\n if (typeof schema.length !== 'number') {\n if (typeof schema.max === 'number') {\n formSchema = formSchema.max(schema.max)\n this.isCharacterOrWordCount = true\n }\n\n if (typeof schema.min === 'number') {\n formSchema = formSchema.min(schema.min)\n }\n } else {\n formSchema = formSchema.length(schema.length)\n }\n\n if (typeof options.maxWords === 'number') {\n formSchema = formSchema.custom(\n getValidatorMaxWords(this),\n 'max words validation'\n )\n\n this.isCharacterOrWordCount = true\n }\n\n if (schema.regex) {\n const pattern = new RegExp(schema.regex)\n formSchema = formSchema.pattern(pattern)\n }\n\n if (options.customValidationMessage) {\n const message = options.customValidationMessage\n\n formSchema = formSchema.messages({\n 'any.required': message,\n 'string.empty': message,\n 'string.max': message,\n 'string.min': message,\n 'string.length': message,\n 'string.pattern.base': message,\n 'string.maxWords': message\n })\n } else if (options.customValidationMessages) {\n formSchema = formSchema.messages(options.customValidationMessages)\n } else if (\n typeof schema.max === 'number' &&\n typeof schema.min === 'number'\n ) {\n const minMaxErrorText = this.buildMinMaxText(schema.min, schema.max)\n formSchema = formSchema.ruleset\n .min(schema.min)\n .max(schema.max)\n .message(minMaxErrorText)\n }\n\n this.formSchema = formSchema.default('')\n this.stateSchema = formSchema.default(null).allow(null)\n this.options = options\n this.schema = schema\n }\n\n getViewModel(payload: FormPayload, errors?: FormSubmissionError[]) {\n const { schema, options, isCharacterOrWordCount } = this\n\n const viewModel = super.getViewModel(payload, errors)\n let { maxlength, maxwords, rows } = viewModel\n\n if (schema.max) {\n maxlength = schema.max\n }\n\n if (options.maxWords) {\n maxwords = options.maxWords\n }\n\n if (options.rows) {\n rows = options.rows\n }\n\n return {\n ...viewModel,\n isCharacterOrWordCount,\n maxlength,\n maxwords,\n rows\n }\n }\n\n buildMinMaxText(min?: number, max?: number): string {\n const minMaxError = messageTemplate.minMax as string\n return minMaxError\n .replace('{{#min}}', min ? min.toString() : '[min length]')\n .replace('{{#max}}', max ? max.toString() : '[max length]')\n }\n\n /**\n * For error preview page that shows all possible errors on a component\n */\n getAllPossibleErrors(): ErrorMessageTemplateList {\n const staticErrors = MultilineTextField.getAllPossibleErrors()\n return {\n ...staticErrors,\n advancedSettingsErrors: [\n ...staticErrors.advancedSettingsErrors,\n {\n type: 'minMax',\n template: this.buildMinMaxText(this.schema.min, this.schema.max)\n }\n ]\n }\n }\n\n /**\n * Static version of getAllPossibleErrors that doesn't require a component instance.\n */\n static getAllPossibleErrors(): ErrorMessageTemplateList {\n return {\n baseErrors: [{ type: 'required', template: messageTemplate.required }],\n advancedSettingsErrors: [\n { type: 'min', template: messageTemplate.min },\n { type: 'max', template: messageTemplate.max }\n ]\n }\n }\n}\n\nfunction getValidatorMaxWords(component: MultilineTextField) {\n const validator: CustomValidator = (value: string, helpers) => {\n const { options } = component\n\n const {\n customValidationMessage: custom,\n maxWords: limit // See {{#limit}} variable\n } = options\n\n if (!limit || count(value) <= limit) {\n return value\n }\n\n return custom\n ? helpers.message({ custom }, { limit })\n : helpers.error('string.maxWords', { limit })\n }\n\n /**\n * Count the number of words in the given text\n * @see GOV.UK Frontend {@link https://github.com/alphagov/govuk-frontend/blob/v5.4.0/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs#L343 | Character count `maxwords` implementation}\n */\n function count(text: string) {\n const tokens = text.match(/\\S+/g) ?? []\n return tokens.length\n }\n\n return validator\n}\n"],"mappings":"AACA,OAAOA,GAAG,MAAmD,KAAK;AAGlE,SAASC,aAAa;AACtB,SAASC,eAAe;AAOxB,OAAO,MAAMC,kBAAkB,SAASF,aAAa,CAAC;EAMpDG,sBAAsB,GAAG,KAAK;EAE9BC,WAAWA,CACTC,GAAgC,EAChCC,KAAqD,EACrD;IACA,KAAK,CAACD,GAAG,EAAEC,KAAK,CAAC;IAEjB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;MAAS,CAAC,CAAC;MACtEiC,sBAAsB,EAAE,CACtB;QAAEC,IAAI,EAAE,KAAK;QAAEC,QAAQ,EAAE/C,eAAe,CAACgB;MAAI,CAAC,EAC9C;QAAE8B,IAAI,EAAE,KAAK;QAAEC,QAAQ,EAAE/C,eAAe,CAACe;MAAI,CAAC;IAElD,CAAC;EACH;AACF;AAEA,SAASI,oBAAoBA,CAAC8B,SAA6B,EAAE;EAC3D,MAAMC,SAA0B,GAAGA,CAACC,KAAa,EAAEC,OAAO,KAAK;IAC7D,MAAM;MAAE7C;IAAQ,CAAC,GAAG0C,SAAS;IAE7B,MAAM;MACJ1B,uBAAuB,EAAEL,MAAM;MAC/BD,QAAQ,EAAEoC,KAAK,CAAC;IAClB,CAAC,GAAG9C,OAAO;IAEX,IAAI,CAAC8C,KAAK,IAAIC,KAAK,CAACH,KAAK,CAAC,IAAIE,KAAK,EAAE;MACnC,OAAOF,KAAK;IACd;IAEA,OAAOjC,MAAM,GACTkC,OAAO,CAAC5B,OAAO,CAAC;MAAEN;IAAO,CAAC,EAAE;MAAEmC;IAAM,CAAC,CAAC,GACtCD,OAAO,CAACG,KAAK,CAAC,iBAAiB,EAAE;MAAEF;IAAM,CAAC,CAAC;EACjD,CAAC;;EAED;AACF;AACA;AACA;EACE,SAASC,KAAKA,CAACE,IAAY,EAAE;IAC3B,MAAMC,MAAM,GAAGD,IAAI,CAACE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;IACvC,OAAOD,MAAM,CAAC3C,MAAM;EACtB;EAEA,OAAOoC,SAAS;AAClB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MultilineTextField.js","names":["Joi","FormComponent","messageTemplate","MultilineTextField","isCharacterOrWordCount","constructor","def","props","schema","options","formSchema","string","replace","trim","label","required","allow","length","max","min","maxWords","custom","getValidatorMaxWords","regex","pattern","RegExp","customValidationMessage","message","messages","customValidationMessages","minMaxErrorText","buildMinMaxText","ruleset","default","stateSchema","getViewModel","payload","errors","viewModel","maxlength","maxwords","rows","minMaxError","minMax","toString","getAllPossibleErrors","staticErrors","advancedSettingsErrors","type","template","baseErrors","component","validator","value","helpers","limit","count","error","text","tokens","match"],"sources":["../../../../../src/server/plugins/engine/components/MultilineTextField.ts"],"sourcesContent":["import { type MultilineTextFieldComponent } from '@defra/forms-model'\nimport Joi, { type CustomValidator, type StringSchema } from 'joi'\n\nimport { type ComponentBase } from '~/src/server/plugins/engine/components/ComponentBase.js'\nimport { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js'\nimport { messageTemplate } from '~/src/server/plugins/engine/pageControllers/validationOptions.js'\nimport {\n type ErrorMessageTemplateList,\n type FormPayload,\n type FormSubmissionError\n} from '~/src/server/plugins/engine/types.js'\n\nexport class MultilineTextField extends FormComponent {\n declare options: MultilineTextFieldComponent['options']\n declare schema: MultilineTextFieldComponent['schema']\n declare formSchema: StringSchema\n declare stateSchema: StringSchema\n\n isCharacterOrWordCount = false\n\n constructor(\n def: MultilineTextFieldComponent,\n props: ConstructorParameters<typeof ComponentBase>[1]\n ) {\n super(def, props)\n\n const { schema, options } = def\n\n let formSchema = Joi.string()\n .replace(/\\r\\n/g, '\\n')\n .trim()\n .label(this.label)\n .required()\n\n if (options.required === false) {\n formSchema = formSchema.allow('')\n }\n\n if (typeof schema.length !== 'number') {\n if (typeof schema.max === 'number') {\n formSchema = formSchema.max(schema.max)\n this.isCharacterOrWordCount = true\n }\n\n if (typeof schema.min === 'number') {\n formSchema = formSchema.min(schema.min)\n }\n } else {\n formSchema = formSchema.length(schema.length)\n }\n\n if (typeof options.maxWords === 'number') {\n formSchema = formSchema.custom(\n getValidatorMaxWords(this),\n 'max words validation'\n )\n\n this.isCharacterOrWordCount = true\n }\n\n if (schema.regex) {\n const pattern = new RegExp(schema.regex)\n formSchema = formSchema.pattern(pattern)\n }\n\n if (options.customValidationMessage) {\n const message = options.customValidationMessage\n\n formSchema = formSchema.messages({\n 'any.required': message,\n 'string.empty': message,\n 'string.max': message,\n 'string.min': message,\n 'string.length': message,\n 'string.pattern.base': message,\n 'string.maxWords': message\n })\n } else if (options.customValidationMessages) {\n formSchema = formSchema.messages(options.customValidationMessages)\n } else if (\n typeof schema.max === 'number' &&\n typeof schema.min === 'number'\n ) {\n const minMaxErrorText = this.buildMinMaxText(schema.min, schema.max)\n formSchema = formSchema.ruleset\n .min(schema.min)\n .max(schema.max)\n .message(minMaxErrorText)\n }\n\n this.formSchema = formSchema.default('')\n this.stateSchema = formSchema.default(null).allow(null)\n this.options = options\n this.schema = schema\n }\n\n getViewModel(payload: FormPayload, errors?: FormSubmissionError[]) {\n const { schema, options, isCharacterOrWordCount } = this\n\n const viewModel = super.getViewModel(payload, errors)\n let { maxlength, maxwords, rows } = viewModel\n\n if (schema.max) {\n maxlength = schema.max\n }\n\n if (options.maxWords) {\n maxwords = options.maxWords\n }\n\n if (options.rows) {\n rows = options.rows\n }\n\n return {\n ...viewModel,\n isCharacterOrWordCount,\n maxlength,\n maxwords,\n rows\n }\n }\n\n buildMinMaxText(min?: number, max?: number): string {\n const minMaxError = messageTemplate.minMax as string\n return minMaxError\n .replace('{{#min}}', min ? min.toString() : '[min length]')\n .replace('{{#max}}', max ? max.toString() : '[max length]')\n }\n\n /**\n * For error preview page that shows all possible errors on a component\n */\n getAllPossibleErrors(): ErrorMessageTemplateList {\n const staticErrors = MultilineTextField.getAllPossibleErrors()\n return {\n ...staticErrors,\n advancedSettingsErrors: [\n ...staticErrors.advancedSettingsErrors,\n {\n type: 'minMax',\n template: this.buildMinMaxText(this.schema.min, this.schema.max)\n }\n ]\n }\n }\n\n /**\n * Static version of getAllPossibleErrors that doesn't require a component instance.\n */\n static getAllPossibleErrors(): ErrorMessageTemplateList {\n return {\n baseErrors: [{ type: 'required', template: messageTemplate.required }],\n advancedSettingsErrors: [\n { type: 'min', template: messageTemplate.min },\n { type: 'max', template: messageTemplate.max }\n ]\n }\n }\n}\n\nfunction getValidatorMaxWords(component: MultilineTextField) {\n const validator: CustomValidator = (value: string, helpers) => {\n const { options } = component\n\n const {\n customValidationMessage: custom,\n maxWords: limit // See {{#limit}} variable\n } = options\n\n if (!limit || count(value) <= limit) {\n return value\n }\n\n return custom\n ? helpers.message({ custom }, { limit })\n : helpers.error('string.maxWords', { limit })\n }\n\n /**\n * Count the number of words in the given text\n * @see GOV.UK Frontend {@link https://github.com/alphagov/govuk-frontend/blob/v5.4.0/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs#L343 | Character count `maxwords` implementation}\n */\n function count(text: string) {\n const tokens = text.match(/\\S+/g) ?? []\n return tokens.length\n }\n\n return validator\n}\n"],"mappings":"AACA,OAAOA,GAAG,MAAmD,KAAK;AAGlE,SAASC,aAAa;AACtB,SAASC,eAAe;AAOxB,OAAO,MAAMC,kBAAkB,SAASF,aAAa,CAAC;EAMpDG,sBAAsB,GAAG,KAAK;EAE9BC,WAAWA,CACTC,GAAgC,EAChCC,KAAqD,EACrD;IACA,KAAK,CAACD,GAAG,EAAEC,KAAK,CAAC;IAEjB,MAAM;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAGH,GAAG;IAE/B,IAAII,UAAU,GAAGV,GAAG,CAACW,MAAM,CAAC,CAAC,CAC1BC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CACtBC,IAAI,CAAC,CAAC,CACNC,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC,CACjBC,QAAQ,CAAC,CAAC;IAEb,IAAIN,OAAO,CAACM,QAAQ,KAAK,KAAK,EAAE;MAC9BL,UAAU,GAAGA,UAAU,CAACM,KAAK,CAAC,EAAE,CAAC;IACnC;IAEA,IAAI,OAAOR,MAAM,CAACS,MAAM,KAAK,QAAQ,EAAE;MACrC,IAAI,OAAOT,MAAM,CAACU,GAAG,KAAK,QAAQ,EAAE;QAClCR,UAAU,GAAGA,UAAU,CAACQ,GAAG,CAACV,MAAM,CAACU,GAAG,CAAC;QACvC,IAAI,CAACd,sBAAsB,GAAG,IAAI;MACpC;MAEA,IAAI,OAAOI,MAAM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;IACd;IAEA,OAAOhC,MAAM,GACTiC,OAAO,CAAC3B,OAAO,CAAC;MAAEN;IAAO,CAAC,EAAE;MAAEkC;IAAM,CAAC,CAAC,GACtCD,OAAO,CAACG,KAAK,CAAC,iBAAiB,EAAE;MAAEF;IAAM,CAAC,CAAC;EACjD,CAAC;;EAED;AACF;AACA;AACA;EACE,SAASC,KAAKA,CAACE,IAAY,EAAE;IAC3B,MAAMC,MAAM,GAAGD,IAAI,CAACE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;IACvC,OAAOD,MAAM,CAAC1C,MAAM;EACtB;EAEA,OAAOmC,SAAS;AAClB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -26,7 +26,11 @@ export class MultilineTextField extends FormComponent {
|
|
|
26
26
|
|
|
27
27
|
const { schema, options } = def
|
|
28
28
|
|
|
29
|
-
let formSchema = Joi.string()
|
|
29
|
+
let formSchema = Joi.string()
|
|
30
|
+
.replace(/\r\n/g, '\n')
|
|
31
|
+
.trim()
|
|
32
|
+
.label(this.label)
|
|
33
|
+
.required()
|
|
30
34
|
|
|
31
35
|
if (options.required === false) {
|
|
32
36
|
formSchema = formSchema.allow('')
|