govuk_publishing_components 16.3.0 → 16.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/modal-dialogue.js +92 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_modal-dialogue.scss +137 -0
  5. data/app/views/govuk_publishing_components/components/_input.html.erb +2 -0
  6. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +21 -0
  7. data/app/views/govuk_publishing_components/components/docs/input.yml +7 -0
  8. data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +71 -0
  9. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -0
  10. data/lib/govuk_publishing_components/presenters/services.rb +1 -1
  11. data/lib/govuk_publishing_components/version.rb +1 -1
  12. data/node_modules/accessible-autocomplete/package.json +1 -1
  13. data/node_modules/govuk-frontend/all.js +26 -1
  14. data/node_modules/govuk-frontend/components/breadcrumbs/macro-options.json +5 -0
  15. data/node_modules/govuk-frontend/components/button/button.js +26 -1
  16. data/node_modules/govuk-frontend/components/button/macro-options.json +6 -0
  17. data/node_modules/govuk-frontend/components/button/template.njk +1 -1
  18. data/node_modules/govuk-frontend/components/character-count/macro-options.json +0 -6
  19. data/node_modules/govuk-frontend/components/checkboxes/macro-options.json +1 -1
  20. data/node_modules/govuk-frontend/components/checkboxes/template.njk +2 -1
  21. data/node_modules/govuk-frontend/components/date-input/macro-options.json +13 -1
  22. data/node_modules/govuk-frontend/components/date-input/template.njk +4 -4
  23. data/node_modules/govuk-frontend/components/error-message/macro-options.json +5 -0
  24. data/node_modules/govuk-frontend/components/error-message/template.njk +3 -0
  25. data/node_modules/govuk-frontend/components/file-upload/macro-options.json +1 -1
  26. data/node_modules/govuk-frontend/components/file-upload/template.njk +2 -1
  27. data/node_modules/govuk-frontend/components/footer/macro-options.json +13 -3
  28. data/node_modules/govuk-frontend/components/footer/template.njk +6 -6
  29. data/node_modules/govuk-frontend/components/input/macro-options.json +8 -2
  30. data/node_modules/govuk-frontend/components/input/template.njk +3 -1
  31. data/node_modules/govuk-frontend/components/inset-text/_inset-text.scss +3 -3
  32. data/node_modules/govuk-frontend/components/inset-text/macro-options.json +2 -2
  33. data/node_modules/govuk-frontend/components/radios/macro-options.json +1 -7
  34. data/node_modules/govuk-frontend/components/radios/template.njk +2 -1
  35. data/node_modules/govuk-frontend/components/select/macro-options.json +9 -3
  36. data/node_modules/govuk-frontend/components/select/template.njk +2 -1
  37. data/node_modules/govuk-frontend/components/skip-link/_skip-link.scss +11 -0
  38. data/node_modules/govuk-frontend/components/summary-list/_summary-list.scss +7 -3
  39. data/node_modules/govuk-frontend/components/tabs/macro-options.json +33 -7
  40. data/node_modules/govuk-frontend/components/textarea/macro-options.json +1 -7
  41. data/node_modules/govuk-frontend/components/textarea/template.njk +2 -1
  42. data/node_modules/govuk-frontend/core/_global-styles.scss +4 -0
  43. data/node_modules/govuk-frontend/core/_links.scss +4 -0
  44. data/node_modules/govuk-frontend/core/_lists.scss +4 -0
  45. data/node_modules/govuk-frontend/core/_section-break.scss +4 -0
  46. data/node_modules/govuk-frontend/core/_template.scss +8 -0
  47. data/node_modules/govuk-frontend/core/_typography.scss +4 -0
  48. data/node_modules/govuk-frontend/objects/_form-group.scss +4 -0
  49. data/node_modules/govuk-frontend/objects/_grid.scss +4 -0
  50. data/node_modules/govuk-frontend/objects/_main-wrapper.scss +4 -0
  51. data/node_modules/govuk-frontend/objects/_width-container.scss +32 -0
  52. data/node_modules/govuk-frontend/overrides/_display.scss +4 -0
  53. data/node_modules/govuk-frontend/overrides/_spacing.scss +4 -0
  54. data/node_modules/govuk-frontend/overrides/_typography.scss +4 -0
  55. data/node_modules/govuk-frontend/overrides/_width.scss +4 -0
  56. data/node_modules/govuk-frontend/package.json +12 -12
  57. data/node_modules/govuk-frontend/template.njk +1 -1
  58. metadata +6 -2
@@ -22,6 +22,11 @@
22
22
  "type": "string",
23
23
  "required": false,
24
24
  "description": "Link for the breadcrumbs item. If not specified, breadcrumbs item is a normal list item."
25
+ },
26
+ {
27
+ "name": "attributes",
28
+ "type": "object",
29
+ "description": "HTML attributes (for example data attributes) to add to the individual crumb."
25
30
  }
26
31
  ]
27
32
  },
@@ -513,13 +513,14 @@ if (detect) return
513
513
  */
514
514
 
515
515
  var KEY_SPACE = 32;
516
+ var DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
517
+ var debounceFormSubmitTimer = null;
516
518
 
517
519
  function Button ($module) {
518
520
  this.$module = $module;
519
521
  }
520
522
 
521
523
  /**
522
- * Add event handler for KeyDown
523
524
  * if the event target element has a role='button' and the event is key space pressed
524
525
  * then it prevents the default event and triggers a click event
525
526
  * @param {object} event event
@@ -535,12 +536,36 @@ Button.prototype.handleKeyDown = function (event) {
535
536
  }
536
537
  };
537
538
 
539
+ /**
540
+ * If the click quickly succeeds a previous click then nothing will happen.
541
+ * This stops people accidentally causing multiple form submissions by
542
+ * double clicking buttons.
543
+ */
544
+ Button.prototype.debounce = function (event) {
545
+ var target = event.target;
546
+ // Check the button that is clicked on has the preventDoubleClick feature enabled
547
+ if (target.getAttribute('data-prevent-double-click') !== 'true') {
548
+ return
549
+ }
550
+
551
+ // If the timer is still running then we want to prevent the click from submitting the form
552
+ if (debounceFormSubmitTimer) {
553
+ event.preventDefault();
554
+ return false
555
+ }
556
+
557
+ debounceFormSubmitTimer = setTimeout(function () {
558
+ debounceFormSubmitTimer = null;
559
+ }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
560
+ };
561
+
538
562
  /**
539
563
  * Initialise an event listener for keydown at document level
540
564
  * this will help listening for later inserted elements with a role="button"
541
565
  */
542
566
  Button.prototype.init = function () {
543
567
  this.$module.addEventListener('keydown', this.handleKeyDown);
568
+ this.$module.addEventListener('click', this.debounce);
544
569
  };
545
570
 
546
571
  return Button;
@@ -58,5 +58,11 @@
58
58
  "type": "object",
59
59
  "required": false,
60
60
  "description": "HTML attributes (for example data attributes) to add to the button component."
61
+ },
62
+ {
63
+ "name": "preventDoubleClick",
64
+ "type": "boolean",
65
+ "required": false,
66
+ "description": "Prevent accidental double clicks on submit buttons from submitting forms multiple times"
61
67
  }
62
68
  ]
@@ -16,7 +16,7 @@
16
16
 
17
17
  {#- Define common attributes we can use for both button and input types #}
18
18
 
19
- {%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% endset %}
19
+ {%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %}
20
20
 
21
21
  {#- Actually create a button... or a link! #}
22
22
 
@@ -5,12 +5,6 @@
5
5
  "required": true,
6
6
  "description": "The id of the textarea."
7
7
  },
8
- {
9
- "name": "describedBy",
10
- "type": "string",
11
- "required": false,
12
- "description": "Text or element id to add to the `aria-describedby` attribute to provide description for screenreader users."
13
- },
14
8
  {
15
9
  "name": "name",
16
10
  "type": "string",
@@ -30,7 +30,7 @@
30
30
  "name": "classes",
31
31
  "type": "string",
32
32
  "required": false,
33
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
33
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
34
34
  }
35
35
  ]
36
36
  },
@@ -42,7 +42,8 @@
42
42
  classes: params.errorMessage.classes,
43
43
  attributes: params.errorMessage.attributes,
44
44
  html: params.errorMessage.html,
45
- text: params.errorMessage.text
45
+ text: params.errorMessage.text,
46
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
46
47
  }) | indent(2) | trim }}
47
48
  {% endif %}
48
49
  <div class="govuk-checkboxes {%- if params.classes %} {{ params.classes }}{% endif %}"
@@ -47,11 +47,23 @@
47
47
  "required": false,
48
48
  "description": "Attribute to [identify input purpose](https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html), for instance \"postal-code\" or \"username\". See [autofill](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill) for full list of attributes that can be used."
49
49
  },
50
+ {
51
+ "name": "pattern",
52
+ "type": "string",
53
+ "required": false,
54
+ "description": "Attribute to [provide a regular expression pattern](https://www.w3.org/TR/html51/sec-forms.html#the-pattern-attribute), used to match allowed character combinations for the input value."
55
+ },
50
56
  {
51
57
  "name": "classes",
52
58
  "type": "string",
53
59
  "required": false,
54
60
  "description": "Classes to add to date input item."
61
+ },
62
+ {
63
+ "name": "attributes",
64
+ "type": "object",
65
+ "required": false,
66
+ "description": "HTML attributes (for example data attributes) to add to the date input tag."
55
67
  }
56
68
  ]
57
69
  },
@@ -79,7 +91,7 @@
79
91
  "name": "classes",
80
92
  "type": "string",
81
93
  "required": false,
82
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
94
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
83
95
  }
84
96
  ]
85
97
  },
@@ -47,7 +47,8 @@
47
47
  classes: params.errorMessage.classes,
48
48
  attributes: params.errorMessage.attributes,
49
49
  html: params.errorMessage.html,
50
- text: params.errorMessage.text
50
+ text: params.errorMessage.text,
51
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
51
52
  }) | indent(2) | trim }}
52
53
  {% endif %}
53
54
  <div class="govuk-date-input {%- if params.classes %} {{ params.classes }}{% endif %}"
@@ -66,9 +67,8 @@
66
67
  value: item.value,
67
68
  type: "number",
68
69
  autocomplete: item.autocomplete,
69
- attributes: {
70
- pattern: "[0-9]*"
71
- }
70
+ pattern: item.pattern if item.pattern else "[0-9]*",
71
+ attributes: item.attributes
72
72
  }) | indent(6) | trim }}
73
73
  </div>
74
74
  {% endfor %}
@@ -28,5 +28,10 @@
28
28
  "type": "object",
29
29
  "required": false,
30
30
  "description": "HTML attributes (for example data attributes) to add to the error message span tag"
31
+ },
32
+ {
33
+ "name": "visuallyHiddenText",
34
+ "type": "string",
35
+ "description": "A visually hidden prefix used before the error message. Defaults to \"Error\"."
31
36
  }
32
37
  ]
@@ -1,3 +1,6 @@
1
+ {% set visuallyHiddenText = params.visuallyHiddenText | default("Error") -%}
2
+
1
3
  <span {%- if params.id %} id="{{ params.id }}"{% endif %} class="govuk-error-message{%- if params.classes %} {{ params.classes }}{% endif %}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
4
+ {% if visuallyHiddenText %}<span class="govuk-visually-hidden">{{ visuallyHiddenText }}:</span> {% endif -%}
2
5
  {{ params.html | safe if params.html else params.text }}
3
6
  </span>
@@ -48,7 +48,7 @@
48
48
  "name": "classes",
49
49
  "type": "string",
50
50
  "required": false,
51
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
51
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
52
52
  }
53
53
  ]
54
54
  },
@@ -33,7 +33,8 @@
33
33
  classes: params.errorMessage.classes,
34
34
  attributes: params.errorMessage.attributes,
35
35
  html: params.errorMessage.html,
36
- text: params.errorMessage.text
36
+ text: params.errorMessage.text,
37
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
37
38
  }) | indent(2) | trim }}
38
39
  {% endif %}
39
40
  <input class="govuk-file-upload {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} govuk-file-upload--error{% endif %}" id="{{ params.id }}" name="{{ params.name }}" type="file"
@@ -4,7 +4,17 @@
4
4
  "type": "object",
5
5
  "required": false,
6
6
  "description": "Object containing options for the meta navigation.",
7
- "arguments": [
7
+ "params": [
8
+ {
9
+ "name": "html",
10
+ "type": "string",
11
+ "description": "HTML to add to the meta section of the footer, which will appear below any links specified using meta.items."
12
+ },
13
+ {
14
+ "name": "text",
15
+ "type": "string",
16
+ "description": "Text to add to the meta section of the footer, which will appear below any links specified using meta.items. If meta.html is specified, this option is ignored."
17
+ },
8
18
  {
9
19
  "name": "items",
10
20
  "type": "array",
@@ -38,7 +48,7 @@
38
48
  "type": "array",
39
49
  "required": false,
40
50
  "description": "Array of items for use in the navigation section of the footer.",
41
- "arguments": [
51
+ "params": [
42
52
  {
43
53
  "name": "title",
44
54
  "type": "string",
@@ -56,7 +66,7 @@
56
66
  "type": "array",
57
67
  "required": false,
58
68
  "description": "Array of items to display in the list in navigation section of the footer.",
59
- "arguments": [
69
+ "params": [
60
70
  {
61
71
  "name": "text",
62
72
  "type": "string",
@@ -3,17 +3,17 @@
3
3
  <div class="govuk-width-container {{ params.containerClasses if params.containerClasses }}">
4
4
  {% if params.navigation %}
5
5
  <div class="govuk-footer__navigation">
6
- {% for item in params.navigation %}
6
+ {% for nav in params.navigation %}
7
7
  <div class="govuk-footer__section">
8
- <h2 class="govuk-footer__heading govuk-heading-m">{{ item.title }}</h2>
9
- {% if item.items %}
8
+ <h2 class="govuk-footer__heading govuk-heading-m">{{ nav.title }}</h2>
9
+ {% if nav.items %}
10
10
  {% set listClasses %}
11
- {% if item.columns %}
12
- govuk-footer__list--columns-{{ item.columns }}
11
+ {% if nav.columns %}
12
+ govuk-footer__list--columns-{{ nav.columns }}
13
13
  {% endif %}
14
14
  {% endset %}
15
15
  <ul class="govuk-footer__list {{ listClasses | trim }}">
16
- {% for item in item.items %}
16
+ {% for item in nav.items %}
17
17
  {% if item.href and item.text %}
18
18
  <li class="govuk-footer__list-item">
19
19
  <a class="govuk-footer__link" href="{{ item.href }}"{% for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
@@ -54,7 +54,7 @@
54
54
  "name": "classes",
55
55
  "type": "string",
56
56
  "required": false,
57
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
57
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
58
58
  }
59
59
  ]
60
60
  },
@@ -62,7 +62,7 @@
62
62
  "name": "classes",
63
63
  "type": "string",
64
64
  "required": false,
65
- "description": "Classes to add to the anchor tag."
65
+ "description": "Classes to add to the input."
66
66
  },
67
67
  {
68
68
  "name": "autocomplete",
@@ -70,6 +70,12 @@
70
70
  "required": false,
71
71
  "description": "Attribute to [identify input purpose](https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html), for instance \"postal-code\" or \"username\". See [autofill](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill) for full list of attributes that can be used."
72
72
  },
73
+ {
74
+ "name": "pattern",
75
+ "type": "string",
76
+ "required": false,
77
+ "description": "Attribute to [provide a regular expression pattern](https://www.w3.org/TR/html51/sec-forms.html#the-pattern-attribute), used to match allowed character combinations for the input value."
78
+ },
73
79
  {
74
80
  "name": "attributes",
75
81
  "type": "object",
@@ -33,12 +33,14 @@
33
33
  classes: params.errorMessage.classes,
34
34
  attributes: params.errorMessage.attributes,
35
35
  html: params.errorMessage.html,
36
- text: params.errorMessage.text
36
+ text: params.errorMessage.text,
37
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
37
38
  }) | indent(2) | trim }}
38
39
  {% endif %}
39
40
  <input class="govuk-input {%- if params.classes %} {{ params.classes }}{% endif %} {%- if params.errorMessage %} govuk-input--error{% endif %}" id="{{ params.id }}" name="{{ params.name }}" type="{{ params.type | default('text') }}"
40
41
  {%- if params.value %} value="{{ params.value}}"{% endif %}
41
42
  {%- if describedBy %} aria-describedby="{{ describedBy }}"{% endif %}
42
43
  {%- if params.autocomplete %} autocomplete="{{ params.autocomplete}}"{% endif %}
44
+ {%- if params.pattern %} pattern="{{ params.pattern }}"{% endif %}
43
45
  {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
44
46
  </div>
@@ -16,12 +16,12 @@
16
16
 
17
17
  border-left: $govuk-border-width-wide solid $govuk-border-colour;
18
18
 
19
- :first-child {
19
+ > :first-child {
20
20
  margin-top: 0;
21
21
  }
22
22
 
23
- :only-child,
24
- :last-child {
23
+ > :only-child,
24
+ > :last-child {
25
25
  margin-bottom: 0;
26
26
  }
27
27
  }
@@ -21,12 +21,12 @@
21
21
  "name": "classes",
22
22
  "type": "string",
23
23
  "required": false,
24
- "description": "Classes to add to the anchor tag."
24
+ "description": "Classes to add to the inset text container."
25
25
  },
26
26
  {
27
27
  "name": "attributes",
28
28
  "type": "object",
29
29
  "required": false,
30
- "description": "HTML attributes (for example data attributes) to add to the anchor tag."
30
+ "description": "HTML attributes (for example data attributes) to add to the inset text container."
31
31
  }
32
32
  ]
@@ -30,7 +30,7 @@
30
30
  "name": "classes",
31
31
  "type": "string",
32
32
  "required": false,
33
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
33
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
34
34
  }
35
35
  ]
36
36
  },
@@ -70,12 +70,6 @@
70
70
  "required": false,
71
71
  "description": "Specific id attribute for the radio item. If omitted, then `idPrefix` string will be applied."
72
72
  },
73
- {
74
- "name": "name",
75
- "type": "string",
76
- "required": true,
77
- "description": "Specific name for the radio item. If omitted, then component global `name` string will be applied."
78
- },
79
73
  {
80
74
  "name": "value",
81
75
  "type": "string",
@@ -39,7 +39,8 @@
39
39
  classes: params.errorMessage.classes,
40
40
  attributes: params.errorMessage.attributes,
41
41
  html: params.errorMessage.html,
42
- text: params.errorMessage.text
42
+ text: params.errorMessage.text,
43
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
43
44
  }) | indent(2) | trim }}
44
45
  {% endif %}
45
46
  <div class="govuk-radios {%- if params.classes %} {{ params.classes }}{% endif %}{%- if isConditional %} govuk-radios--conditional{% endif -%}"
@@ -40,6 +40,12 @@
40
40
  "type": "boolean",
41
41
  "required": false,
42
42
  "description": "Sets the option item as disabled."
43
+ },
44
+ {
45
+ "name": "attributes",
46
+ "type": "object",
47
+ "required": false,
48
+ "description": "HTML attributes (for example data attributes) to add to the option."
43
49
  }
44
50
  ]
45
51
  },
@@ -74,7 +80,7 @@
74
80
  "name": "classes",
75
81
  "type": "string",
76
82
  "required": false,
77
- "description": "Optional classes to add to the form group (e.g. to show error state for the whole group)"
83
+ "description": "Classes to add to the form group (e.g. to show error state for the whole group)"
78
84
  }
79
85
  ]
80
86
  },
@@ -82,12 +88,12 @@
82
88
  "name": "classes",
83
89
  "type": "string",
84
90
  "required": false,
85
- "description": "Classes to add to the anchor tag."
91
+ "description": "Classes to add to the select."
86
92
  },
87
93
  {
88
94
  "name": "attributes",
89
95
  "type": "object",
90
96
  "required": false,
91
- "description": "HTML attributes (for example data attributes) to add to the anchor tag."
97
+ "description": "HTML attributes (for example data attributes) to add to the select."
92
98
  }
93
99
  ]
@@ -33,7 +33,8 @@
33
33
  classes: params.errorMessage.classes,
34
34
  attributes: params.errorMessage.attributes,
35
35
  html: params.errorMessage.html,
36
- text: params.errorMessage.text
36
+ text: params.errorMessage.text,
37
+ visuallyHiddenText: params.errorMessage.visuallyHiddenText
37
38
  }) | indent(2) | trim }}
38
39
  {% endif %}
39
40
  <select class="govuk-select