govuk_publishing_components 65.1.0 → 65.2.0

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +13 -15
  3. data/app/assets/stylesheets/govuk_publishing_components/all-components.scss +0 -1
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +25 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_details.scss +34 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +4 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/specific-components.scss +0 -1
  9. data/app/controllers/govuk_publishing_components/applications_page_controller.rb +1 -1
  10. data/app/controllers/govuk_publishing_components/audit_controller.rb +0 -1
  11. data/app/models/govuk_publishing_components/component_doc.rb +10 -3
  12. data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +4 -2
  13. data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +1 -1
  14. data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +2 -2
  15. data/app/views/govuk_publishing_components/component_guide/show.html.erb +47 -33
  16. data/app/views/govuk_publishing_components/components/_details.html.erb +4 -0
  17. data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +2 -2
  18. data/app/views/govuk_publishing_components/components/_option_select.html.erb +2 -2
  19. data/app/views/govuk_publishing_components/components/docs/details.yml +16 -0
  20. data/lib/govuk_publishing_components/presenters/devolved_nations_helper.rb +13 -7
  21. data/lib/govuk_publishing_components/version.rb +1 -1
  22. data/node_modules/choices.js/README.md +140 -30
  23. data/node_modules/choices.js/package.json +10 -13
  24. data/node_modules/choices.js/public/assets/scripts/choices.js +144 -89
  25. data/node_modules/choices.js/public/assets/scripts/choices.min.js +2 -2
  26. data/node_modules/choices.js/public/assets/scripts/choices.mjs +144 -89
  27. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.js +144 -86
  28. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.min.js +2 -2
  29. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.mjs +144 -86
  30. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.js +139 -77
  31. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.min.js +2 -2
  32. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.mjs +139 -77
  33. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.js +137 -76
  34. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.min.js +2 -2
  35. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.mjs +137 -76
  36. data/node_modules/choices.js/public/assets/styles/base.css +39 -9
  37. data/node_modules/choices.js/public/assets/styles/base.css.map +1 -1
  38. data/node_modules/choices.js/public/assets/styles/base.min.css +1 -1
  39. data/node_modules/choices.js/public/assets/styles/choices.css +93 -95
  40. data/node_modules/choices.js/public/assets/styles/choices.css.map +1 -1
  41. data/node_modules/choices.js/public/assets/styles/choices.min.css +1 -1
  42. data/node_modules/choices.js/public/types/src/scripts/choices.d.ts +11 -0
  43. data/node_modules/choices.js/public/types/src/scripts/components/container.d.ts +2 -0
  44. data/node_modules/choices.js/public/types/src/scripts/interfaces/choice-full.d.ts +2 -1
  45. data/node_modules/choices.js/public/types/src/scripts/interfaces/class-names.d.ts +2 -0
  46. data/node_modules/choices.js/public/types/src/scripts/interfaces/input-choice.d.ts +2 -1
  47. data/node_modules/choices.js/public/types/src/scripts/interfaces/options.d.ts +19 -3
  48. data/node_modules/choices.js/public/types/src/scripts/interfaces/store.d.ts +2 -1
  49. data/node_modules/choices.js/public/types/src/scripts/interfaces/types.d.ts +2 -1
  50. data/node_modules/choices.js/public/types/src/scripts/lib/utils.d.ts +3 -1
  51. data/node_modules/choices.js/src/scripts/choices.ts +110 -64
  52. data/node_modules/choices.js/src/scripts/components/container.ts +8 -0
  53. data/node_modules/choices.js/src/scripts/components/wrapped-select.ts +3 -1
  54. data/node_modules/choices.js/src/scripts/defaults.ts +12 -7
  55. data/node_modules/choices.js/src/scripts/interfaces/choice-full.ts +2 -1
  56. data/node_modules/choices.js/src/scripts/interfaces/class-names.ts +2 -0
  57. data/node_modules/choices.js/src/scripts/interfaces/event-choice.ts +1 -0
  58. data/node_modules/choices.js/src/scripts/interfaces/input-choice.ts +4 -2
  59. data/node_modules/choices.js/src/scripts/interfaces/options.ts +21 -3
  60. data/node_modules/choices.js/src/scripts/interfaces/store.ts +2 -1
  61. data/node_modules/choices.js/src/scripts/interfaces/types.ts +3 -1
  62. data/node_modules/choices.js/src/scripts/lib/utils.ts +27 -4
  63. data/node_modules/choices.js/src/scripts/search/kmp.ts +2 -1
  64. data/node_modules/choices.js/src/scripts/store/store.ts +4 -1
  65. data/node_modules/choices.js/src/scripts/templates.ts +6 -3
  66. data/node_modules/choices.js/src/styles/base.scss +42 -9
  67. data/node_modules/choices.js/src/styles/choices.scss +119 -93
  68. metadata +2 -3
  69. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_contents-list-helper.scss +0 -24
@@ -4,6 +4,7 @@ import { StringPreEscaped } from '../interfaces/string-pre-escaped';
4
4
  import { ChoiceFull } from '../interfaces/choice-full';
5
5
  import { Types } from '../interfaces/types';
6
6
  import { canUseDom } from '../interfaces/build-flags';
7
+ import { EventChoice } from '../interfaces';
7
8
 
8
9
  const getRandomNumber = (min: number, max: number): number => Math.floor(Math.random() * (max - min) + min);
9
10
 
@@ -91,10 +92,6 @@ export const strToEl = ((): ((str: string) => Element) => {
91
92
  };
92
93
  })();
93
94
 
94
- export const resolveNoticeFunction = (fn: Types.NoticeStringFunction | string, value: string): string => {
95
- return typeof fn === 'function' ? fn(sanitise(value), value) : fn;
96
- };
97
-
98
95
  export const resolveStringFunction = (fn: Types.StringFunction | string): string => {
99
96
  return typeof fn === 'function' ? fn() : fn;
100
97
  };
@@ -133,6 +130,32 @@ export const unwrapStringForEscaped = (s?: StringUntrusted | StringPreEscaped |
133
130
  return '';
134
131
  };
135
132
 
133
+ export const getChoiceForOutput = (choice: ChoiceFull, keyCode?: number): EventChoice => {
134
+ return {
135
+ id: choice.id,
136
+ highlighted: choice.highlighted,
137
+ labelClass: choice.labelClass,
138
+ labelDescription: unwrapStringForRaw(choice.labelDescription),
139
+ customProperties: choice.customProperties,
140
+ disabled: choice.disabled,
141
+ active: choice.active,
142
+ label: choice.label,
143
+ placeholder: choice.placeholder,
144
+ value: choice.value,
145
+ groupValue: choice.group ? choice.group.label : undefined,
146
+ element: choice.element,
147
+ keyCode,
148
+ };
149
+ };
150
+
151
+ export const resolveNoticeFunction = (
152
+ fn: Types.NoticeStringFunction | string,
153
+ value: StringUntrusted | StringPreEscaped | string,
154
+ item?: EventChoice,
155
+ ): string => {
156
+ return typeof fn === 'function' ? fn(sanitise<string>(value), unwrapStringForRaw(value), item) : fn;
157
+ };
158
+
136
159
  export const escapeForTemplate = (allowHTML: boolean, s: StringUntrusted | StringPreEscaped | string): string =>
137
160
  allowHTML ? unwrapStringForEscaped(s) : (sanitise(s) as string);
138
161
 
@@ -73,11 +73,12 @@ export class SearchByKMP<T extends object> implements Searcher<T> {
73
73
  const field = this._fields[k];
74
74
  if (field in obj && kmpSearch(needle, (obj[field] as string).toLowerCase()) !== -1) {
75
75
  results.push({
76
- item: obj[field],
76
+ item: obj,
77
77
  score: count,
78
78
  rank: count + 1,
79
79
  });
80
80
  count++;
81
+ break;
81
82
  }
82
83
  }
83
84
  }
@@ -2,6 +2,7 @@ import { AnyAction, Reducer, Store as IStore, StoreListener } from '../interface
2
2
  import { StateChangeSet, State } from '../interfaces/state';
3
3
  import { ChoiceFull } from '../interfaces/choice-full';
4
4
  import { GroupFull } from '../interfaces/group-full';
5
+ import { Options } from '../interfaces/options';
5
6
  import items from '../reducers/items';
6
7
  import groups from '../reducers/groups';
7
8
  import choices from '../reducers/choices';
@@ -142,7 +143,9 @@ export default class Store<T> implements IStore {
142
143
  * Get choices that can be searched (excluding placeholders or disabled choices)
143
144
  */
144
145
  get searchableChoices(): ChoiceFull[] {
145
- return this.choices.filter((choice) => !choice.disabled && !choice.placeholder);
146
+ const context = this._context as Options;
147
+
148
+ return this.choices.filter((choice) => !choice.placeholder && (context.searchDisabledChoices || !choice.disabled));
146
149
  }
147
150
 
148
151
  /**
@@ -16,6 +16,7 @@ import {
16
16
  escapeForTemplate,
17
17
  addClassesToElement,
18
18
  removeClassesFromElement,
19
+ getChoiceForOutput,
19
20
  } from './lib/utils';
20
21
  import { NoticeType, NoticeTypes, TemplateOptions, Templates as TemplatesInterface } from './interfaces/templates';
21
22
  import { StringUntrusted } from './interfaces/string-untrusted';
@@ -40,7 +41,7 @@ const assignCustomProperties = (el: HTMLElement, choice: ChoiceFull, withCustomP
40
41
  }
41
42
 
42
43
  if (labelDescription) {
43
- dataset.labelDescription = labelDescription;
44
+ dataset.labelDescription = unwrapStringForRaw(labelDescription);
44
45
  }
45
46
 
46
47
  if (withCustomProperties && customProperties) {
@@ -189,9 +190,10 @@ const templates: TemplatesInterface = {
189
190
  const removeButton = document.createElement('button');
190
191
  removeButton.type = 'button';
191
192
  addClassesToElement(removeButton, button);
192
- setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value));
193
+ const eventChoice = getChoiceForOutput(choice);
194
+ setElementHtml(removeButton, true, resolveNoticeFunction(removeItemIconText, choice.value, eventChoice));
193
195
 
194
- const REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value);
196
+ const REMOVE_ITEM_LABEL = resolveNoticeFunction(removeItemLabelText, choice.value, eventChoice);
195
197
  if (REMOVE_ITEM_LABEL) {
196
198
  removeButton.setAttribute('aria-label', REMOVE_ITEM_LABEL);
197
199
  }
@@ -320,6 +322,7 @@ const templates: TemplatesInterface = {
320
322
  } else {
321
323
  addClassesToElement(div, itemSelectable);
322
324
  div.dataset.choiceSelectable = '';
325
+ div.setAttribute('aria-selected', choice.selected ? 'true' : 'false');
323
326
  }
324
327
 
325
328
  return div;
@@ -2,6 +2,39 @@
2
2
  = Generic styling =
3
3
  ============================================= */
4
4
 
5
+ :root {
6
+ --color-primary: #005F75;
7
+ }
8
+
9
+ @media (prefers-color-scheme: dark) {
10
+ :root {
11
+ /* Demo defaults */
12
+ --body-bg: #272a2b;
13
+ --text-color: #cacaca;
14
+ --color-primary: #38daff;
15
+ --section-bg: #181a1b;
16
+ --section-color: #cacaca;
17
+ --hr-border: #373a3d;
18
+ --choices-primary-color: #38daff;
19
+ --choices-item-color: black;
20
+ --choices-bg-color: #101010;
21
+ --choices-bg-color-dropdown: #101010;
22
+ --choices-keyline-color: #3b3e40;
23
+ --choices-bg-color-disabled: #181a1b;
24
+ --choices-item-disabled-color: #eee;
25
+ --choices-disabled-color: #2d2d2d;
26
+ --choices-highlighted-color: #16292d;
27
+ --choices-icon-cross: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");
28
+ --choices-icon-cross-inverse: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==");
29
+
30
+ color-scheme: dark;
31
+ }
32
+
33
+ input, select {
34
+ color: #fff;
35
+ }
36
+ }
37
+
5
38
  $global-guttering: 24px;
6
39
  $global-font-size-h1: 32px;
7
40
  $global-font-size-h2: 24px;
@@ -33,8 +66,8 @@ body {
33
66
  font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
34
67
  font-size: 16px;
35
68
  line-height: 1.4;
36
- color: #fff;
37
- background-color: #333;
69
+ color: var(--text-color, #fff);
70
+ background-color: var(--body-bg, #333);
38
71
  overflow-x: hidden;
39
72
  }
40
73
 
@@ -55,7 +88,7 @@ hr {
55
88
  display: block;
56
89
  margin: $global-guttering * 1.25 0;
57
90
  border: 0;
58
- border-bottom: 1px solid #eaeaea;
91
+ border-bottom: 1px solid var(--hr-border, #eaeaea);
59
92
  height: 1px;
60
93
  }
61
94
 
@@ -74,7 +107,7 @@ h6 {
74
107
  a,
75
108
  a:visited,
76
109
  a:focus {
77
- color: #fff;
110
+ color: var(--link-color, #fff);
78
111
  text-decoration: none;
79
112
  font-weight: 600;
80
113
  }
@@ -82,9 +115,9 @@ a:focus {
82
115
  .form-control {
83
116
  display: block;
84
117
  width: 100%;
85
- background-color: #f9f9f9;
118
+ background-color: var(--form-bg, #f9f9f9);
86
119
  padding: 12px;
87
- border: 1px solid #ddd;
120
+ border: 1px solid var(--form-boder, #ddd);
88
121
  border-radius: 2.5px;
89
122
  font-size: 14px;
90
123
  appearance: none;
@@ -137,14 +170,14 @@ label + p {
137
170
  }
138
171
 
139
172
  .section {
140
- background-color: #fff;
173
+ background-color: var(--section-bg, #fff);
141
174
  padding: $global-guttering;
142
- color: #333;
175
+ color: var(--section-color, #333);
143
176
 
144
177
  a,
145
178
  a:visited,
146
179
  a:focus {
147
- color: #005F75;
180
+ color: var(--link-color-section, var(--color-primary));
148
181
  }
149
182
  }
150
183
 
@@ -2,8 +2,6 @@
2
2
  = Choices =
3
3
  =============================== */
4
4
 
5
- @use "sass:color";
6
-
7
5
  $choices-selector: "choices" !default;
8
6
  $choices-font-size-lg: 16px !default;
9
7
  $choices-font-size-md: 14px !default;
@@ -15,21 +13,45 @@ $choices-bg-color: #f9f9f9 !default;
15
13
  $choices-bg-color-disabled: #eaeaea !default;
16
14
  $choices-bg-color-dropdown: #fff !default;
17
15
  $choices-text-color: #333 !default;
16
+ $choices-item-color: #fff !default;
18
17
  $choices-keyline-color: #ddd !default;
19
18
  $choices-primary-color: #005F75 !default;
20
19
  $choices-disabled-color: #eaeaea !default;
20
+ $choices-item-disabled-color: #fff !default;
21
+ $choices-invalid-color: #d33141 !default;
22
+ $choices-highlighted-color: #f2f2f2 !default;
21
23
  $choices-highlight-color: $choices-primary-color !default;
22
24
  $choices-button-dimension: 8px !default;
23
25
  $choices-button-offset: 8px !default;
24
26
  $choices-icon-cross: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==") !default;
25
27
  $choices-icon-cross-inverse: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==") !default;
26
28
  $choices-z-index: 1 !default;
29
+ $choices-input-height: 44px !default;
30
+ $choices-width: 100% !default;
31
+ $choices-base-border: 1px solid !default;
32
+ $choices-multiple-item-margin: 3.75px !default;
33
+ $choices-multiple-item-padding: 4px 10px !default;
34
+ $choices-dropdown-item-padding: 10px !default;
35
+ $choices-list-single-padding: 4px 16px 4px 4px !default;
36
+ $choices-input-margin-bottom: 5px;
37
+ $choices-input-padding: 4px 0 4px 2px !default;
38
+ $choices-inner-padding: 7.5px 7.5px 3.75px !default;
39
+ $choices-inner-one-padding: 7.5px !default;
40
+ $choices-arrow-size: 5px !default;
41
+ $choices-arrow-margin-top: -2.5px !default;
42
+ $choices-arrow-margin-top-open: -7.5px !default;
43
+ $choices-arrow-right: 11.5px !default;
44
+ $choices-button-line-height: 1 !default;
45
+ $choices-button-border-radius: 0 !default;
46
+ $choices-button-opacity: 0.75 !default;
47
+ $choices-button-opacity-hover: 1 !default;
48
+ $choices-placeholder-opacity: 0.5 !default;
27
49
 
28
50
  .#{$choices-selector} {
29
51
  position: relative;
30
52
  overflow: hidden;
31
- margin-bottom: $choices-guttering;
32
- font-size: $choices-font-size-lg;
53
+ margin-bottom: var(--choices-guttering, #{$choices-guttering});
54
+ font-size: var(--choices-font-size-lg, #{$choices-font-size-lg});
33
55
 
34
56
  &:focus {
35
57
  outline: none;
@@ -44,37 +66,40 @@ $choices-z-index: 1 !default;
44
66
  }
45
67
 
46
68
  &.is-disabled {
47
- .#{$choices-selector}__inner,
48
- .#{$choices-selector}__input {
49
- background-color: $choices-bg-color-disabled;
50
- cursor: not-allowed;
69
+ :is(.#{$choices-selector}__inner, .#{$choices-selector}__input) {
70
+ background-color: var(--choices-bg-color-disabled, #{$choices-bg-color-disabled});
71
+ cursor: not-allowed !important;
51
72
  user-select: none;
52
73
  }
53
74
  .#{$choices-selector}__item {
54
75
  cursor: not-allowed;
76
+ color: var(--choices-item-disabled-color, #{$choices-item-disabled-color});
55
77
  }
56
78
  }
57
79
 
58
80
  [hidden] {
59
- display: none !important;
81
+ position: absolute;
82
+ inset: 0;
83
+ pointer-events: none;
84
+ opacity: 0;
60
85
  }
61
86
  }
62
87
 
63
88
  .#{$choices-selector}[data-type*='select-one'] {
64
89
  cursor: pointer;
65
90
  .#{$choices-selector}__inner {
66
- padding-bottom: 7.5px;
91
+ padding-bottom: var(--choices-inner-one-padding, #{$choices-inner-one-padding});
67
92
  }
68
93
  .#{$choices-selector}__input {
69
94
  display: block;
70
- width: 100%;
71
- padding: 10px;
72
- border-bottom: 1px solid $choices-keyline-color;
73
- background-color: #fff;
95
+ width: var(--choices-width, #{$choices-width});
96
+ padding: var(--choices-dropdown-item-padding, #{$choices-dropdown-item-padding});
97
+ border-bottom: var(--choices-base-border, #{$choices-base-border}) var(--choices-keyline-color, #{$choices-keyline-color});
98
+ background-color: var(--choices-bg-color-dropdown, #{$choices-bg-color-dropdown});
74
99
  margin: 0;
75
100
  }
76
101
  .#{$choices-selector}__button {
77
- background-image: $choices-icon-cross-inverse;
102
+ background-image: var(--choices-icon-cross-inverse, #{$choices-icon-cross-inverse});
78
103
  padding: 0;
79
104
  background-size: 8px;
80
105
  position: absolute;
@@ -87,13 +112,12 @@ $choices-z-index: 1 !default;
87
112
  border-radius: 10em;
88
113
  opacity: 0.25;
89
114
 
90
- &:hover,
91
- &:focus {
92
- opacity: 1;
115
+ &:is(:hover, :focus) {
116
+ opacity: var(--choices-button-opacity-hover, #{$choices-button-opacity-hover});
93
117
  }
94
118
 
95
119
  &:focus {
96
- box-shadow: 0 0 0 2px $choices-highlight-color;
120
+ box-shadow: 0 0 0 2px var(--choices-highlight-color, #{$choices-highlight-color});
97
121
  }
98
122
  }
99
123
  .#{$choices-selector}__item[data-placeholder] .#{$choices-selector}__button {
@@ -105,18 +129,18 @@ $choices-z-index: 1 !default;
105
129
  height: 0;
106
130
  width: 0;
107
131
  border-style: solid;
108
- border-color: $choices-text-color transparent transparent transparent;
109
- border-width: 5px;
132
+ border-color: var(--choices-text-color, #{$choices-text-color}) transparent transparent transparent;
133
+ border-width: var(--choices-arrow-size, #{$choices-arrow-size});
110
134
  position: absolute;
111
- right: 11.5px;
135
+ right: var(--choices-arrow-right, #{$choices-arrow-right});
112
136
  top: 50%;
113
- margin-top: -2.5px;
137
+ margin-top: var(--choices-arrow-margin-top, #{$choices-arrow-margin-top});
114
138
  pointer-events: none;
115
139
  }
116
140
 
117
141
  &.is-open::after {
118
- border-color: transparent transparent $choices-text-color;
119
- margin-top: -7.5px;
142
+ border-color: transparent transparent var(--choices-text-color, #{$choices-text-color});
143
+ margin-top: var(--choices-arrow-margin-top-open, #{$choices-arrow-margin-top-open});
120
144
  }
121
145
 
122
146
  &[dir="rtl"] {
@@ -133,30 +157,25 @@ $choices-z-index: 1 !default;
133
157
  }
134
158
  }
135
159
 
136
- .#{$choices-selector}[data-type*='select-multiple'],
137
- .#{$choices-selector}[data-type*='text'] {
160
+ .#{$choices-selector}:is([data-type*='select-multiple'], [data-type*='text']) {
138
161
  .#{$choices-selector}__inner {
139
162
  cursor: text;
140
163
  }
141
164
  .#{$choices-selector}__button {
142
165
  position: relative;
143
166
  display: inline-block;
144
- margin-top: 0;
145
- margin-right: -$choices-button-offset * 0.5;
146
- margin-bottom: 0;
147
- margin-left: $choices-button-offset;
148
- padding-left: $choices-button-offset * 2;
149
- border-left: 1px solid color.adjust($choices-primary-color, $lightness: -10%);
150
- background-image: $choices-icon-cross;
151
- background-size: $choices-button-dimension;
152
- width: $choices-button-dimension;
153
- line-height: 1;
154
- opacity: 0.75;
155
- border-radius: 0;
156
-
157
- &:hover,
158
- &:focus {
159
- opacity: 1;
167
+ margin: 0 calc(var(--choices-button-offset, #{$choices-button-offset}) * -0.5) 0 var(--choices-button-offset, #{$choices-button-offset});
168
+ padding-left: calc(var(--choices-button-offset, #{$choices-button-offset}) * 2);
169
+ border-left: 1px solid color-mix(in srgb, var(--choices-primary-color, #{$choices-primary-color}) 90%, var(--choices-darken, black));
170
+ background-image: var(--choices-icon-cross, #{$choices-icon-cross});
171
+ background-size: var(--choices-button-dimension, #{$choices-button-dimension});
172
+ width: var(--choices-button-dimension, #{$choices-button-dimension});
173
+ line-height: var(--choices-button-line-height, #{$choices-button-line-height});
174
+ border-radius: var(--choices-button-border-radius, #{$choices-button-border-radius});
175
+ opacity: var(--choices-button-opacity, #{$choices-button-opacity});
176
+
177
+ &:is(:hover, :focus) {
178
+ --choices-button-opacity: var(--choices-button-opacity-hover, #{$choices-button-opacity-hover});
160
179
  }
161
180
  }
162
181
  }
@@ -164,26 +183,30 @@ $choices-z-index: 1 !default;
164
183
  .#{$choices-selector}__inner {
165
184
  display: inline-block;
166
185
  vertical-align: top;
167
- width: 100%;
168
- background-color: $choices-bg-color;
169
- padding: 7.5px 7.5px 3.75px;
170
- border: 1px solid $choices-keyline-color;
171
- border-radius: $choices-border-radius;
172
- font-size: $choices-font-size-md;
173
- min-height: 44px;
186
+ width: var(--choices-width, #{$choices-width});
187
+ background-color: var(--choices-bg-color, #{$choices-bg-color});
188
+ padding: var(--choices-inner-padding, #{$choices-inner-padding});;
189
+ border: var(--choices-base-border, #{$choices-base-border}) var(--choices-keyline-color, #{$choices-keyline-color});
190
+ border-radius: var(--choices-border-radius, #{$choices-border-radius});
191
+ font-size: var(--choices-font-size-md, #{$choices-font-size-md});
192
+ min-height: var(--choices-input-height, #{$choices-input-height});
174
193
  overflow: hidden;
175
194
 
176
195
  .is-focused &,
177
196
  .is-open & {
178
- border-color: color.adjust($choices-keyline-color, $lightness: -15%);
197
+ border-color: color-mix(in srgb, var(--choices-keyline-color, #{$choices-keyline-color}) 85%, var(--choices-darken, black));
179
198
  }
180
199
 
181
200
  .is-open & {
182
- border-radius: $choices-border-radius $choices-border-radius 0 0;
201
+ border-radius: var(--choices-border-radius, #{$choices-border-radius}) var(--choices-border-radius, #{$choices-border-radius}) 0 0;
202
+ }
203
+
204
+ .is-invalid & {
205
+ border-color: var(--choices-invalid-color, #{$choices-invalid-color});
183
206
  }
184
207
 
185
208
  .is-flipped.is-open & {
186
- border-radius: 0 0 $choices-border-radius $choices-border-radius;
209
+ border-radius: 0 0 var(--choices-border-radius, #{$choices-border-radius}) var(--choices-border-radius, #{$choices-border-radius});
187
210
  }
188
211
  }
189
212
 
@@ -199,15 +222,15 @@ $choices-z-index: 1 !default;
199
222
 
200
223
  .#{$choices-selector}__list--single {
201
224
  display: inline-block;
202
- padding: 4px 16px 4px 4px;
203
- width: 100%;
225
+ padding: var(--choices-list-single-padding, #{$choices-list-single-padding});
226
+ width: var(--choices-width, #{$choices-width});
204
227
 
205
228
  [dir="rtl"] & {
206
229
  padding-right: 4px;
207
230
  padding-left: 16px;
208
231
  }
209
232
  .#{$choices-selector}__item {
210
- width: 100%;
233
+ width: var(--choices-width, #{$choices-width});
211
234
  }
212
235
  }
213
236
 
@@ -216,15 +239,15 @@ $choices-z-index: 1 !default;
216
239
  .#{$choices-selector}__item {
217
240
  display: inline-block;
218
241
  vertical-align: middle;
219
- border-radius: $choices-border-radius-item;
220
- padding: 4px 10px;
221
- font-size: $choices-font-size-sm;
242
+ border-radius: var(--choices-border-radius-item, #{$choices-border-radius-item});
243
+ padding: var(--choices-multiple-item-padding, #{$choices-multiple-item-padding});
244
+ font-size: var(--choices-font-size-sm, #{$choices-font-size-sm});
222
245
  font-weight: 500;
223
- margin-right: 3.75px;
224
- margin-bottom: 3.75px;
225
- background-color: $choices-primary-color;
226
- border: 1px solid color.adjust($choices-primary-color, $lightness: -5%);
227
- color: #fff;
246
+ margin-right: var(--choices-multiple-item-margin, #{$choices-multiple-item-margin});
247
+ margin-bottom: var(--choices-multiple-item-margin, #{$choices-multiple-item-margin});
248
+ background-color: var(--choices-primary-color, #{$choices-primary-color});
249
+ border: 1px solid color-mix(in srgb, var(--choices-primary-color, #{$choices-primary-color}) 95%, var(--choices-darken, black));
250
+ color: var(--choices-item-color, #{$choices-item-color});
228
251
  word-break: break-all;
229
252
  box-sizing: border-box;
230
253
 
@@ -234,32 +257,32 @@ $choices-z-index: 1 !default;
234
257
 
235
258
  [dir="rtl"] & {
236
259
  margin-right: 0;
237
- margin-left: 3.75px;
260
+ margin-left: var(--choices-multiple-item-margin, #{$choices-multiple-item-margin});
238
261
  }
239
262
 
240
263
  &.is-highlighted {
241
- background-color: color.adjust($choices-primary-color, $lightness: -5%);
242
- border: 1px solid color.adjust($choices-primary-color, $lightness: -10%);
264
+ background-color: color-mix(in srgb, var(--choices-primary-color, #{$choices-primary-color}) 95%, var(--choices-darken, black));
265
+ border: 1px solid color-mix(in srgb, var(--choices-primary-color, #{$choices-primary-color}) 90%, var(--choices-darken, black));
243
266
  }
244
267
 
245
268
  .is-disabled & {
246
- background-color: color.adjust($choices-disabled-color, $lightness: -25%);
247
- border: 1px solid color.adjust($choices-disabled-color, $lightness: -35%);
269
+ background-color: color-mix(in srgb, var(--choices-disabled-color, #{$choices-disabled-color}) 75%, var(--choices-darken, black));
270
+ border: 1px solid color-mix(in srgb, var(--choices-disabled-color, #{$choices-disabled-color}) 65%, var(--choices-darken, black));
248
271
  }
249
272
  }
250
273
  }
251
274
 
252
275
  %choices-dropdown {
253
276
  display: none;
254
- z-index: $choices-z-index;
277
+ z-index: var(--choices-z-index, #{$choices-z-index});
255
278
  position: absolute;
256
- width: 100%;
257
- background-color: $choices-bg-color-dropdown;
258
- border: 1px solid $choices-keyline-color;
279
+ width: var(--choices-width, #{$choices-width});
280
+ background-color: var(--choices-bg-color-dropdown, #{$choices-bg-color-dropdown});
281
+ border: var(--choices-base-border, #{$choices-base-border}) var(--choices-keyline-color, #{$choices-keyline-color});
259
282
  top: 100%;
260
283
  margin-top: -1px;
261
- border-bottom-left-radius: $choices-border-radius;
262
- border-bottom-right-radius: $choices-border-radius;
284
+ border-bottom-left-radius: var(--choices-border-radius, #{$choices-border-radius});
285
+ border-bottom-right-radius: var(--choices-border-radius, #{$choices-border-radius});
263
286
  overflow: hidden;
264
287
  word-break: break-all;
265
288
 
@@ -268,7 +291,7 @@ $choices-z-index: 1 !default;
268
291
  }
269
292
 
270
293
  .is-open & {
271
- border-color: color.adjust($choices-keyline-color, $lightness: -15%);
294
+ border-color: color-mix(in srgb, var(--choices-keyline-color, #{$choices-keyline-color}) 85%, var(--choices-darken, black));
272
295
  }
273
296
 
274
297
  .is-flipped & {
@@ -287,22 +310,21 @@ $choices-z-index: 1 !default;
287
310
  }
288
311
  .#{$choices-selector}__item {
289
312
  position: relative;
290
- padding: 10px;
291
- font-size: $choices-font-size-md;
313
+ padding: var(--choices-dropdown-item-padding, #{$choices-dropdown-item-padding});
314
+ font-size: var(--choices-font-size-md, #{$choices-font-size-md});
292
315
 
293
316
  [dir="rtl"] & {
294
317
  text-align: right;
295
318
  }
296
319
  }
297
320
  .#{$choices-selector}__item--selectable {
298
- &[data-select-text] {
321
+ &.is-highlighted[data-select-text] {
299
322
  @media (min-width: 640px) {
300
323
  padding-right: 100px;
301
324
 
302
325
  &::after {
303
326
  content: attr(data-select-text);
304
- font-size: $choices-font-size-sm;
305
- opacity: 0;
327
+ font-size: var(--choices-font-size-sm, #{$choices-font-size-sm});
306
328
  position: absolute;
307
329
  right: 10px;
308
330
  top: 50%;
@@ -322,13 +344,17 @@ $choices-z-index: 1 !default;
322
344
  }
323
345
  }
324
346
 
325
- &.is-highlighted {
326
- background-color: color.mix(#000, #fff, 5%);
327
-
347
+ // Reset the content on selected option
348
+ &.is-selected {
328
349
  &::after {
329
- opacity: 0.5;
350
+ content: none !important;
330
351
  }
331
352
  }
353
+
354
+ &.is-selected,
355
+ &.is-highlighted {
356
+ background-color: var(--choices-highlighted-color, #{$choices-highlighted-color});
357
+ }
332
358
  }
333
359
  }
334
360
 
@@ -354,8 +380,8 @@ $choices-z-index: 1 !default;
354
380
  font-weight: 600;
355
381
  font-size: $choices-font-size-sm;
356
382
  padding: 10px;
357
- border-bottom: 1px solid color.adjust($choices-keyline-color, $lightness: 10%);
358
- color: color.adjust(#333, $lightness: 30%);
383
+ border-bottom: 1px solid color-mix(in srgb, var(--choices-keyline-color, #{$choices-keyline-color}) 90%, var(--choices-lighten, white));
384
+ color: gray;
359
385
  }
360
386
 
361
387
  .#{$choices-selector}__button {
@@ -375,13 +401,13 @@ $choices-z-index: 1 !default;
375
401
  .#{$choices-selector}__input {
376
402
  display: inline-block;
377
403
  vertical-align: baseline;
378
- background-color: $choices-bg-color;
379
- font-size: $choices-font-size-md;
380
- margin-bottom: 5px;
404
+ background-color: var(--choices-bg-color, #{$choices-bg-color});
405
+ font-size: var(--choices-font-size-md, #{$choices-font-size-md});
406
+ margin-bottom: var(--choices-input-margin-bottom, #{$choices-input-margin-bottom});
381
407
  border: 0;
382
408
  border-radius: 0;
383
- max-width: 100%;
384
- padding: 4px 0 4px 2px;
409
+ max-width: var(--choices-width, #{$choices-width});
410
+ padding: var(--choices-input-padding, #{$choices-input-padding});
385
411
 
386
412
  &:focus {
387
413
  outline: 0;
@@ -408,7 +434,7 @@ $choices-z-index: 1 !default;
408
434
  }
409
435
 
410
436
  .#{$choices-selector}__placeholder {
411
- opacity: 0.5;
437
+ opacity: var(--choices-placeholder-opacity, #{$choices-placeholder-opacity});
412
438
  }
413
439
 
414
440
  /* ===== End of Choices ====== */
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 65.1.0
4
+ version: 65.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
@@ -653,7 +653,6 @@ files:
653
653
  - app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss
654
654
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss
655
655
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_colours.scss
656
- - app/assets/stylesheets/govuk_publishing_components/components/helpers/_contents-list-helper.scss
657
656
  - app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss
658
657
  - app/assets/stylesheets/govuk_publishing_components/components/mixins/_grid-helper.scss
659
658
  - app/assets/stylesheets/govuk_publishing_components/components/mixins/_index.scss
@@ -2124,7 +2123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2124
2123
  - !ruby/object:Gem::Version
2125
2124
  version: '0'
2126
2125
  requirements: []
2127
- rubygems_version: 4.0.8
2126
+ rubygems_version: 4.0.9
2128
2127
  specification_version: 4
2129
2128
  summary: A gem to document components in GOV.UK frontend applications
2130
2129
  test_files: []