hof 20.0.0-beta.3 → 20.0.0-beta.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/.github/workflows/automate-publish.yml +1 -1
  2. package/.github/workflows/automate-tag.yml +1 -1
  3. package/README.md +329 -256
  4. package/build/lib/mkdir.js +2 -2
  5. package/components/date/index.js +37 -26
  6. package/components/date/templates/date.html +3 -3
  7. package/components/emailer/index.js +49 -41
  8. package/components/emailer/transports/debug.js +1 -2
  9. package/components/index.js +2 -1
  10. package/components/notify/index.js +60 -0
  11. package/components/notify/notify.js +25 -0
  12. package/components/summary/index.js +18 -0
  13. package/config/hof-defaults.js +5 -3
  14. package/config/rate-limits.js +20 -0
  15. package/config/sanitisation-rules.js +29 -0
  16. package/controller/base-controller.js +26 -8
  17. package/controller/controller.js +23 -17
  18. package/frontend/govuk-template/build/config.js +1 -1
  19. package/frontend/template-mixins/mixins/template-mixins.js +12 -8
  20. package/frontend/template-mixins/partials/forms/checkbox-group.html +13 -4
  21. package/frontend/template-mixins/partials/forms/input-text-date.html +1 -1
  22. package/frontend/template-mixins/partials/forms/input-text-group.html +6 -4
  23. package/frontend/template-mixins/partials/forms/option-group.html +12 -3
  24. package/frontend/template-mixins/partials/forms/select.html +3 -3
  25. package/frontend/template-mixins/partials/forms/textarea-group.html +3 -3
  26. package/frontend/template-mixins/partials/mixins/panel.html +1 -2
  27. package/frontend/template-partials/translations/src/en/errors.json +12 -0
  28. package/frontend/template-partials/views/layout.html +10 -3
  29. package/frontend/template-partials/views/partials/cookie-banner.html +1 -1
  30. package/frontend/template-partials/views/partials/form.html +2 -1
  31. package/frontend/template-partials/views/partials/warn.html +7 -0
  32. package/frontend/template-partials/views/rate-limit-error.html +10 -0
  33. package/frontend/themes/gov-uk/client-js/govuk-cookies.js +43 -44
  34. package/frontend/themes/gov-uk/client-js/index.js +2 -2
  35. package/frontend/themes/gov-uk/client-js/skip-to-main.js +18 -17
  36. package/frontend/themes/gov-uk/styles/govuk.scss +4 -0
  37. package/frontend/themes/gov-uk/styles/modules/_validation.scss +2 -2
  38. package/frontend/toolkit/assets/javascript/form-focus.js +10 -1
  39. package/frontend/toolkit/assets/javascript/validation.js +6 -1
  40. package/index.js +9 -4
  41. package/lib/router.js +2 -1
  42. package/lib/settings.js +9 -8
  43. package/middleware/errors.js +32 -0
  44. package/middleware/index.js +2 -1
  45. package/middleware/rate-limiter.js +98 -0
  46. package/package.json +6 -6
  47. package/sandbox/apps/sandbox/fields.js +12 -12
  48. package/sandbox/apps/sandbox/index.js +1 -5
  49. package/sandbox/apps/sandbox/translations/en/default.json +24 -0
  50. package/sandbox/assets/scss/app.scss +0 -52
  51. package/sandbox/package.json +2 -0
  52. package/sandbox/public/css/app.css +4908 -4965
  53. package/sandbox/public/js/bundle.js +79 -65
  54. package/sandbox/server.js +7 -1
  55. package/sandbox/yarn.lock +39 -564
  56. package/transpiler/lib/write-files.js +1 -2
  57. package/utilities/helpers/index.js +16 -1
  58. package/wizard/index.js +1 -0
  59. package/.nyc_output/65af88d9-aebe-4d1b-a21d-6fbf7f2bbda4.json +0 -1
  60. package/.nyc_output/processinfo/65af88d9-aebe-4d1b-a21d-6fbf7f2bbda4.json +0 -1
  61. package/.nyc_output/processinfo/index.json +0 -1
  62. package/.vscode/settings.json +0 -6
  63. package/sandbox/.env +0 -1
@@ -2,7 +2,6 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const mkdir = require('mkdirp').sync;
6
5
  const rm = require('rimraf').sync;
7
6
 
8
7
  const debug = require('debug')('hof:transpiler');
@@ -16,7 +15,7 @@ module.exports = (dir, data) => {
16
15
  const outputDir = path.resolve(dir, '..', lang);
17
16
  rm(outputDir);
18
17
  debug(`Emptied directory ${outputDir}`);
19
- mkdir(outputDir);
18
+ fs.mkdirSync(outputDir);
20
19
  debug(`Made directory ${outputDir}`);
21
20
  Object.keys(data[lang]).forEach(namespace => {
22
21
  fs.writeFileSync(path.resolve(outputDir, `${namespace}.json`), JSON.stringify(data[lang][namespace], null, ' '));
@@ -94,7 +94,7 @@ module.exports = class Helpers {
94
94
  /**
95
95
  * utility function which returns undefined on
96
96
  * failed translations instead of returning the key
97
- * @param {Function} translate - the translate funtion
97
+ * @param {Function} translate - the translate function
98
98
  * @param {String} key - the key to translate
99
99
  * @returns {String|undefined} the string result if successful, undefined if not
100
100
  */
@@ -131,4 +131,19 @@ module.exports = class Helpers {
131
131
  `pages.${key}.header`
132
132
  ]) || key;
133
133
  }
134
+ /**
135
+ * utility function which returns true or false on
136
+ * forks depending on whether a value exists on the page
137
+ * @param {Object} req - an http request object
138
+ * @param {Object} res - an http response object
139
+ * @param {Function|Object} condition - a field condition that is either a function or object
140
+ * @returns {Boolean} the boolean result of whether a field value is set on the page or session for a fork
141
+ */
142
+ static isFieldValueInPageOrSessionValid(req, res, condition) {
143
+ return _.isFunction(condition) ?
144
+ condition(req, res) :
145
+ condition.value === (req.form.values[condition.field] ||
146
+ (!Object.keys(req.form.values).includes(condition.field) &&
147
+ _.get(req, `form.historicalValues[${condition.field}]`)));
148
+ }
134
149
  };
package/wizard/index.js CHANGED
@@ -69,6 +69,7 @@ const Wizard = (steps, fields, setts) => {
69
69
  options.confirmStep = settings.confirmStep;
70
70
  options.clearSession = options.clearSession || false;
71
71
  options.fieldsConfig = _.cloneDeep(fields);
72
+ options.sanitiseInputs = settings.sanitiseInputs;
72
73
 
73
74
  options.defaultFormatters = [].concat(settings.formatters);
74
75