@ministryofjustice/frontend 4.0.1 → 5.1.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.
- package/govuk-prototype-kit.config.json +19 -4
- package/moj/_base.scss +2 -0
- package/moj/_base.scss.map +1 -0
- package/moj/all.bundle.js +3010 -0
- package/moj/all.bundle.js.map +1 -0
- package/moj/all.bundle.mjs +3293 -0
- package/moj/all.bundle.mjs.map +1 -0
- package/moj/all.mjs +17 -110
- package/moj/all.mjs.map +1 -1
- package/moj/all.scss +3 -0
- package/moj/all.scss.map +1 -0
- package/moj/common/index.mjs +57 -0
- package/moj/common/index.mjs.map +1 -0
- package/moj/common/moj-frontend-version.mjs +14 -0
- package/moj/common/moj-frontend-version.mjs.map +1 -0
- package/moj/components/_all.scss +2 -0
- package/moj/components/_all.scss.map +1 -0
- package/moj/components/action-bar/_action-bar.scss +2 -0
- package/moj/components/action-bar/_action-bar.scss.map +1 -0
- package/moj/components/add-another/_add-another.scss +2 -0
- package/moj/components/add-another/_add-another.scss.map +1 -0
- package/moj/components/add-another/add-another.bundle.js +157 -0
- package/moj/components/add-another/add-another.bundle.js.map +1 -0
- package/moj/components/add-another/add-another.bundle.mjs +271 -0
- package/moj/components/add-another/add-another.bundle.mjs.map +1 -0
- package/moj/components/add-another/add-another.mjs +135 -91
- package/moj/components/add-another/add-another.mjs.map +1 -1
- package/moj/components/alert/_alert.scss +4 -0
- package/moj/components/alert/_alert.scss.map +1 -0
- package/moj/components/alert/alert.bundle.js +254 -0
- package/moj/components/alert/alert.bundle.js.map +1 -0
- package/moj/components/alert/alert.bundle.mjs +490 -0
- package/moj/components/alert/alert.bundle.mjs.map +1 -0
- package/moj/components/alert/alert.mjs +97 -218
- package/moj/components/alert/alert.mjs.map +1 -1
- package/moj/components/alert/{alert.spec.helper.js → alert.spec.helper.bundle.js} +1 -1
- package/moj/components/alert/alert.spec.helper.bundle.js.map +1 -0
- package/moj/components/alert/alert.spec.helper.bundle.mjs +67 -0
- package/moj/components/alert/alert.spec.helper.bundle.mjs.map +1 -0
- package/moj/components/alert/alert.spec.helper.mjs.map +1 -1
- package/moj/components/badge/_badge.scss +2 -0
- package/moj/components/badge/_badge.scss.map +1 -0
- package/moj/components/banner/_banner.scss +2 -0
- package/moj/components/banner/_banner.scss.map +1 -0
- package/moj/components/button-menu/README.md +12 -6
- package/moj/components/button-menu/_button-menu.scss +4 -1
- package/moj/components/button-menu/_button-menu.scss.map +1 -0
- package/moj/components/button-menu/button-menu.bundle.js +270 -0
- package/moj/components/button-menu/button-menu.bundle.js.map +1 -0
- package/moj/components/button-menu/button-menu.bundle.mjs +506 -0
- package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -0
- package/moj/components/button-menu/button-menu.mjs +214 -280
- package/moj/components/button-menu/button-menu.mjs.map +1 -1
- package/moj/components/cookie-banner/_cookie-banner.scss +2 -0
- package/moj/components/cookie-banner/_cookie-banner.scss.map +1 -0
- package/moj/components/currency-input/_currency-input.scss +2 -0
- package/moj/components/currency-input/_currency-input.scss.map +1 -0
- package/moj/components/date-picker/_date-picker.scss +2 -0
- package/moj/components/date-picker/_date-picker.scss.map +1 -0
- package/moj/components/date-picker/date-picker.bundle.js +804 -0
- package/moj/components/date-picker/date-picker.bundle.js.map +1 -0
- package/moj/components/date-picker/date-picker.bundle.mjs +1040 -0
- package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -0
- package/moj/components/date-picker/date-picker.mjs +663 -827
- package/moj/components/date-picker/date-picker.mjs.map +1 -1
- package/moj/components/filter/_filter.scss +2 -0
- package/moj/components/filter/_filter.scss.map +1 -0
- package/moj/components/filter/template.njk +1 -1
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +185 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +421 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +166 -81
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
- package/moj/components/form-validator/form-validator.bundle.js +288 -0
- package/moj/components/form-validator/form-validator.bundle.js.map +1 -0
- package/moj/components/form-validator/form-validator.bundle.mjs +524 -0
- package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -0
- package/moj/components/form-validator/form-validator.mjs +226 -149
- package/moj/components/form-validator/form-validator.mjs.map +1 -1
- package/moj/components/header/_header.scss +2 -0
- package/moj/components/header/_header.scss.map +1 -0
- package/moj/components/identity-bar/_identity-bar.scss +2 -0
- package/moj/components/identity-bar/_identity-bar.scss.map +1 -0
- package/moj/components/interruption-card/_interruption-card.scss +2 -0
- package/moj/components/interruption-card/_interruption-card.scss.map +1 -0
- package/moj/components/messages/_messages.scss +2 -0
- package/moj/components/messages/_messages.scss.map +1 -0
- package/moj/components/multi-file-upload/_multi-file-upload.scss +2 -0
- package/moj/components/multi-file-upload/_multi-file-upload.scss.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.js +397 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +633 -0
- package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -0
- package/moj/components/multi-file-upload/multi-file-upload.mjs +384 -213
- package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
- package/moj/components/multi-file-upload/template.njk +1 -1
- package/moj/components/multi-select/_multi-select.scss +2 -0
- package/moj/components/multi-select/_multi-select.scss.map +1 -0
- package/moj/components/multi-select/multi-select.bundle.js +143 -0
- package/moj/components/multi-select/multi-select.bundle.js.map +1 -0
- package/moj/components/multi-select/multi-select.bundle.mjs +379 -0
- package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -0
- package/moj/components/multi-select/multi-select.mjs +123 -64
- package/moj/components/multi-select/multi-select.mjs.map +1 -1
- package/moj/components/notification-badge/_notification-badge.scss +2 -0
- package/moj/components/notification-badge/_notification-badge.scss.map +1 -0
- package/moj/components/organisation-switcher/_organisation-switcher.scss +2 -0
- package/moj/components/organisation-switcher/_organisation-switcher.scss.map +1 -0
- package/moj/components/page-header-actions/_page-header-actions.scss +2 -0
- package/moj/components/page-header-actions/_page-header-actions.scss.map +1 -0
- package/moj/components/pagination/_pagination.scss +2 -2
- package/moj/components/pagination/_pagination.scss.map +1 -0
- package/moj/components/password-reveal/_password-reveal.scss +5 -1
- package/moj/components/password-reveal/_password-reveal.scss.map +1 -0
- package/moj/components/password-reveal/password-reveal.bundle.js +52 -0
- package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -0
- package/moj/components/password-reveal/password-reveal.bundle.mjs +166 -0
- package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -0
- package/moj/components/password-reveal/password-reveal.mjs +39 -29
- package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
- package/moj/components/primary-navigation/_primary-navigation.scss +2 -0
- package/moj/components/primary-navigation/_primary-navigation.scss.map +1 -0
- package/moj/components/progress-bar/_progress-bar.scss +2 -0
- package/moj/components/progress-bar/_progress-bar.scss.map +1 -0
- package/moj/components/rich-text-editor/README.md +16 -9
- package/moj/components/rich-text-editor/_rich-text-editor.scss +2 -0
- package/moj/components/rich-text-editor/_rich-text-editor.scss.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.js +210 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +446 -0
- package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -0
- package/moj/components/rich-text-editor/rich-text-editor.mjs +186 -140
- package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
- package/moj/components/search/_search.scss +2 -0
- package/moj/components/search/_search.scss.map +1 -0
- package/moj/components/search-toggle/{search-toggle.scss → _search-toggle.scss} +2 -0
- package/moj/components/search-toggle/_search-toggle.scss.map +1 -0
- package/moj/components/search-toggle/search-toggle.bundle.js +122 -0
- package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -0
- package/moj/components/search-toggle/search-toggle.bundle.mjs +358 -0
- package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -0
- package/moj/components/search-toggle/search-toggle.mjs +104 -43
- package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
- package/moj/components/side-navigation/_side-navigation.scss +2 -0
- package/moj/components/side-navigation/_side-navigation.scss.map +1 -0
- package/moj/components/sortable-table/_sortable-table.scss +2 -2
- package/moj/components/sortable-table/_sortable-table.scss.map +1 -0
- package/moj/components/sortable-table/sortable-table.bundle.js +202 -0
- package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -0
- package/moj/components/sortable-table/sortable-table.bundle.mjs +438 -0
- package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -0
- package/moj/components/sortable-table/sortable-table.mjs +179 -122
- package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
- package/moj/components/sub-navigation/_sub-navigation.scss +2 -0
- package/moj/components/sub-navigation/_sub-navigation.scss.map +1 -0
- package/moj/components/tag/_tag.scss +2 -0
- package/moj/components/tag/_tag.scss.map +1 -0
- package/moj/components/task-list/_task-list.scss +2 -0
- package/moj/components/task-list/_task-list.scss.map +1 -0
- package/moj/components/ticket-panel/_ticket-panel.scss +2 -0
- package/moj/components/ticket-panel/_ticket-panel.scss.map +1 -0
- package/moj/components/timeline/_timeline.scss +2 -0
- package/moj/components/timeline/_timeline.scss.map +1 -0
- package/moj/core/_all.scss +3 -0
- package/moj/core/_all.scss.map +1 -0
- package/moj/core/_moj-frontend-properties.scss +7 -0
- package/moj/core/_moj-frontend-properties.scss.map +1 -0
- package/moj/filters/all.js +44 -22
- package/moj/filters/prototype-kit-13-filters.js +4 -3
- package/moj/helpers/_all.scss +2 -0
- package/moj/helpers/_all.scss.map +1 -0
- package/moj/helpers/_hidden.scss +2 -0
- package/moj/helpers/_hidden.scss.map +1 -0
- package/moj/helpers/_links.scss +2 -0
- package/moj/helpers/_links.scss.map +1 -0
- package/moj/helpers.bundle.js +140 -0
- package/moj/helpers.bundle.js.map +1 -0
- package/moj/helpers.bundle.mjs +128 -0
- package/moj/helpers.bundle.mjs.map +1 -0
- package/moj/helpers.mjs +50 -77
- package/moj/helpers.mjs.map +1 -1
- package/moj/init.js +11 -2
- package/moj/moj-frontend.min.css +1 -1
- package/moj/moj-frontend.min.css.map +1 -1
- package/moj/moj-frontend.min.js +1 -1
- package/moj/moj-frontend.min.js.map +1 -1
- package/moj/objects/_all.scss +2 -0
- package/moj/objects/_all.scss.map +1 -0
- package/moj/objects/_button-group.scss +2 -0
- package/moj/objects/_button-group.scss.map +1 -0
- package/moj/objects/_filter-layout.scss +2 -0
- package/moj/objects/_filter-layout.scss.map +1 -0
- package/moj/objects/_scrollable-pane.scss +2 -0
- package/moj/objects/_scrollable-pane.scss.map +1 -0
- package/moj/objects/_width-container.scss +2 -0
- package/moj/objects/_width-container.scss.map +1 -0
- package/moj/settings/_all.scss +2 -0
- package/moj/settings/_all.scss.map +1 -0
- package/moj/settings/_assets.scss +2 -0
- package/moj/settings/_assets.scss.map +1 -0
- package/moj/settings/_colours.scss +2 -0
- package/moj/settings/_colours.scss.map +1 -0
- package/moj/settings/_measurements.scss +2 -0
- package/moj/settings/_measurements.scss.map +1 -0
- package/moj/settings/_typography.scss +2 -0
- package/moj/settings/_typography.scss.map +1 -0
- package/moj/template.njk +13 -0
- package/moj/utilities/_all.scss +2 -0
- package/moj/utilities/_all.scss.map +1 -0
- package/moj/utilities/_hidden.scss +2 -0
- package/moj/utilities/_hidden.scss.map +1 -0
- package/moj/utilities/_width-container.scss +2 -0
- package/moj/utilities/_width-container.scss.map +1 -0
- package/moj/vendor/govuk-frontend/_base.scss +2 -0
- package/moj/vendor/govuk-frontend/_base.scss.map +1 -0
- package/moj/vendor/govuk-frontend/_index.scss +2 -0
- package/moj/vendor/govuk-frontend/_index.scss.map +1 -0
- package/package.json +5 -6
- package/moj/all.jquery.min.js +0 -1
- package/moj/all.jquery.min.js.map +0 -1
- package/moj/all.js +0 -2662
- package/moj/all.js.map +0 -1
- package/moj/components/add-another/add-another.js +0 -115
- package/moj/components/add-another/add-another.js.map +0 -1
- package/moj/components/alert/alert.js +0 -356
- package/moj/components/alert/alert.js.map +0 -1
- package/moj/components/alert/alert.spec.helper.js.map +0 -1
- package/moj/components/button-menu/button-menu.js +0 -338
- package/moj/components/button-menu/button-menu.js.map +0 -1
- package/moj/components/date-picker/date-picker.js +0 -970
- package/moj/components/date-picker/date-picker.js.map +0 -1
- package/moj/components/filter-toggle-button/filter-toggle-button.js +0 -102
- package/moj/components/filter-toggle-button/filter-toggle-button.js.map +0 -1
- package/moj/components/form-validator/form-validator.js +0 -205
- package/moj/components/form-validator/form-validator.js.map +0 -1
- package/moj/components/multi-file-upload/multi-file-upload.js +0 -241
- package/moj/components/multi-file-upload/multi-file-upload.js.map +0 -1
- package/moj/components/multi-select/multi-select.js +0 -86
- package/moj/components/multi-select/multi-select.js.map +0 -1
- package/moj/components/password-reveal/password-reveal.js +0 -44
- package/moj/components/password-reveal/password-reveal.js.map +0 -1
- package/moj/components/rich-text-editor/rich-text-editor.js +0 -166
- package/moj/components/rich-text-editor/rich-text-editor.js.map +0 -1
- package/moj/components/search-toggle/search-toggle.js +0 -63
- package/moj/components/search-toggle/search-toggle.js.map +0 -1
- package/moj/components/sortable-table/sortable-table.js +0 -147
- package/moj/components/sortable-table/sortable-table.js.map +0 -1
- package/moj/helpers.js +0 -200
- package/moj/helpers.js.map +0 -1
- package/moj/vendor/html5shiv.js +0 -326
- package/moj/vendor/jquery.js +0 -9300
- package/moj/version.js +0 -12
- package/moj/version.js.map +0 -1
- package/moj/version.mjs +0 -4
- package/moj/version.mjs.map +0 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function isInitialised($root, moduleName) {
|
|
2
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if GOV.UK Frontend is supported on this page
|
|
7
|
+
*
|
|
8
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
|
9
|
+
* won't be supported.
|
|
10
|
+
*
|
|
11
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
|
12
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
|
13
|
+
*/
|
|
14
|
+
function isSupported($scope = document.body) {
|
|
15
|
+
if (!$scope) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return $scope.classList.contains('govuk-frontend-supported');
|
|
19
|
+
}
|
|
20
|
+
function formatErrorMessage(Component, message) {
|
|
21
|
+
return `${Component.moduleName}: ${message}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class GOVUKFrontendError extends Error {
|
|
25
|
+
constructor(...args) {
|
|
26
|
+
super(...args);
|
|
27
|
+
this.name = 'GOVUKFrontendError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class SupportError extends GOVUKFrontendError {
|
|
31
|
+
/**
|
|
32
|
+
* Checks if GOV.UK Frontend is supported on this page
|
|
33
|
+
*
|
|
34
|
+
* @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
|
|
35
|
+
*/
|
|
36
|
+
constructor($scope = document.body) {
|
|
37
|
+
const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
38
|
+
super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
|
|
39
|
+
this.name = 'SupportError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class ElementError extends GOVUKFrontendError {
|
|
43
|
+
constructor(messageOrOptions) {
|
|
44
|
+
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
|
45
|
+
if (typeof messageOrOptions === 'object') {
|
|
46
|
+
const {
|
|
47
|
+
component,
|
|
48
|
+
identifier,
|
|
49
|
+
element,
|
|
50
|
+
expectedType
|
|
51
|
+
} = messageOrOptions;
|
|
52
|
+
message = identifier;
|
|
53
|
+
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
|
54
|
+
message = formatErrorMessage(component, message);
|
|
55
|
+
}
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = 'ElementError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class InitError extends GOVUKFrontendError {
|
|
61
|
+
constructor(componentOrMessage) {
|
|
62
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
|
63
|
+
super(message);
|
|
64
|
+
this.name = 'InitError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class Component {
|
|
69
|
+
/**
|
|
70
|
+
* Returns the root element of the component
|
|
71
|
+
*
|
|
72
|
+
* @protected
|
|
73
|
+
* @returns {RootElementType} - the root element of component
|
|
74
|
+
*/
|
|
75
|
+
get $root() {
|
|
76
|
+
return this._$root;
|
|
77
|
+
}
|
|
78
|
+
constructor($root) {
|
|
79
|
+
this._$root = void 0;
|
|
80
|
+
const childConstructor = this.constructor;
|
|
81
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
|
82
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
|
83
|
+
}
|
|
84
|
+
if (!($root instanceof childConstructor.elementType)) {
|
|
85
|
+
throw new ElementError({
|
|
86
|
+
element: $root,
|
|
87
|
+
component: childConstructor,
|
|
88
|
+
identifier: 'Root element (`$root`)',
|
|
89
|
+
expectedType: childConstructor.elementType.name
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
this._$root = $root;
|
|
93
|
+
}
|
|
94
|
+
childConstructor.checkSupport();
|
|
95
|
+
this.checkInitialised();
|
|
96
|
+
const moduleName = childConstructor.moduleName;
|
|
97
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
|
98
|
+
}
|
|
99
|
+
checkInitialised() {
|
|
100
|
+
const constructor = this.constructor;
|
|
101
|
+
const moduleName = constructor.moduleName;
|
|
102
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
|
103
|
+
throw new InitError(constructor);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
static checkSupport() {
|
|
107
|
+
if (!isSupported()) {
|
|
108
|
+
throw new SupportError();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @typedef ChildClass
|
|
115
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
120
|
+
*/
|
|
121
|
+
Component.elementType = HTMLElement;
|
|
122
|
+
|
|
123
|
+
class PasswordReveal extends Component {
|
|
124
|
+
/**
|
|
125
|
+
* @param {Element | null} $root - HTML element to use for password reveal
|
|
126
|
+
*/
|
|
127
|
+
constructor($root) {
|
|
128
|
+
super($root);
|
|
129
|
+
const $input = this.$root.querySelector('.govuk-input');
|
|
130
|
+
if (!$input || !($input instanceof HTMLInputElement)) {
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
this.$input = $input;
|
|
134
|
+
this.$input.setAttribute('spellcheck', 'false');
|
|
135
|
+
this.createButton();
|
|
136
|
+
}
|
|
137
|
+
createButton() {
|
|
138
|
+
this.$group = document.createElement('div');
|
|
139
|
+
this.$button = document.createElement('button');
|
|
140
|
+
this.$button.setAttribute('type', 'button');
|
|
141
|
+
this.$root.classList.add('moj-password-reveal');
|
|
142
|
+
this.$group.classList.add('moj-password-reveal__wrapper');
|
|
143
|
+
this.$button.classList.add('govuk-button', 'govuk-button--secondary', 'moj-password-reveal__button');
|
|
144
|
+
this.$button.innerHTML = 'Show <span class="govuk-visually-hidden">password</span>';
|
|
145
|
+
this.$button.addEventListener('click', this.onButtonClick.bind(this));
|
|
146
|
+
this.$group.append(this.$input, this.$button);
|
|
147
|
+
this.$root.append(this.$group);
|
|
148
|
+
}
|
|
149
|
+
onButtonClick() {
|
|
150
|
+
if (this.$input.type === 'password') {
|
|
151
|
+
this.$input.type = 'text';
|
|
152
|
+
this.$button.innerHTML = 'Hide <span class="govuk-visually-hidden">password</span>';
|
|
153
|
+
} else {
|
|
154
|
+
this.$input.type = 'password';
|
|
155
|
+
this.$button.innerHTML = 'Show <span class="govuk-visually-hidden">password</span>';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Name for the component used when initialising using data-module attributes.
|
|
161
|
+
*/
|
|
162
|
+
}
|
|
163
|
+
PasswordReveal.moduleName = 'moj-password-reveal';
|
|
164
|
+
|
|
165
|
+
export { PasswordReveal };
|
|
166
|
+
//# sourceMappingURL=password-reveal.bundle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reveal.bundle.mjs","sources":["../../../../node_modules/govuk-frontend/dist/govuk/common/index.mjs","../../../../node_modules/govuk-frontend/dist/govuk/errors/index.mjs","../../../../node_modules/govuk-frontend/dist/govuk/component.mjs","../../../../src/moj/components/password-reveal/password-reveal.mjs"],"sourcesContent":["function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined;\n }\n return url.split('#').pop();\n}\nfunction getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`;\n const value = window.getComputedStyle(document.documentElement).getPropertyValue(property);\n return {\n property,\n value: value || undefined\n };\n}\nfunction setFocus($element, options = {}) {\n var _options$onBeforeFocu;\n const isFocusable = $element.getAttribute('tabindex');\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1');\n }\n function onFocus() {\n $element.addEventListener('blur', onBlur, {\n once: true\n });\n }\n function onBlur() {\n var _options$onBlur;\n (_options$onBlur = options.onBlur) == null || _options$onBlur.call($element);\n if (!isFocusable) {\n $element.removeAttribute('tabindex');\n }\n }\n $element.addEventListener('focus', onFocus, {\n once: true\n });\n (_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);\n $element.focus();\n}\nfunction isInitialised($root, moduleName) {\n return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nfunction isSupported($scope = document.body) {\n if (!$scope) {\n return false;\n }\n return $scope.classList.contains('govuk-frontend-supported');\n}\nfunction isArray(option) {\n return Array.isArray(option);\n}\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option);\n}\nfunction formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`;\n}\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n/**\n * @import { ObjectNested } from './configuration.mjs'\n */\n\nexport { formatErrorMessage, getBreakpoint, getFragmentFromUrl, isInitialised, isObject, isSupported, setFocus };\n//# sourceMappingURL=index.mjs.map\n","import { formatErrorMessage } from '../common/index.mjs';\n\nclass GOVUKFrontendError extends Error {\n constructor(...args) {\n super(...args);\n this.name = 'GOVUKFrontendError';\n }\n}\nclass SupportError extends GOVUKFrontendError {\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';\n super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type=\"module\">`');\n this.name = 'SupportError';\n }\n}\nclass ConfigError extends GOVUKFrontendError {\n constructor(...args) {\n super(...args);\n this.name = 'ConfigError';\n }\n}\nclass ElementError extends GOVUKFrontendError {\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';\n if (typeof messageOrOptions === 'object') {\n const {\n component,\n identifier,\n element,\n expectedType\n } = messageOrOptions;\n message = identifier;\n message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';\n message = formatErrorMessage(component, message);\n }\n super(message);\n this.name = 'ElementError';\n }\n}\nclass InitError extends GOVUKFrontendError {\n constructor(componentOrMessage) {\n const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\\`$root\\`) already initialised`);\n super(message);\n this.name = 'InitError';\n }\n}\n/**\n * @import { ComponentWithModuleName } from '../common/index.mjs'\n */\n\nexport { ConfigError, ElementError, GOVUKFrontendError, InitError, SupportError };\n//# sourceMappingURL=index.mjs.map\n","import { isInitialised, isSupported } from './common/index.mjs';\nimport { InitError, ElementError, SupportError } from './errors/index.mjs';\n\nclass Component {\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root;\n }\n constructor($root) {\n this._$root = void 0;\n const childConstructor = this.constructor;\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`);\n }\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n });\n } else {\n this._$root = $root;\n }\n childConstructor.checkSupport();\n this.checkInitialised();\n const moduleName = childConstructor.moduleName;\n this.$root.setAttribute(`data-${moduleName}-init`, '');\n }\n checkInitialised() {\n const constructor = this.constructor;\n const moduleName = constructor.moduleName;\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor);\n }\n }\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError();\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof Component & ChildClass} ChildClassConstructor\n */\nComponent.elementType = HTMLElement;\n\nexport { Component };\n//# sourceMappingURL=component.mjs.map\n","import { Component } from 'govuk-frontend'\n\nexport class PasswordReveal extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for password reveal\n */\n constructor($root) {\n super($root)\n\n const $input = this.$root.querySelector('.govuk-input')\n if (!$input || !($input instanceof HTMLInputElement)) {\n return this\n }\n\n this.$input = $input\n this.$input.setAttribute('spellcheck', 'false')\n\n this.createButton()\n }\n\n createButton() {\n this.$group = document.createElement('div')\n this.$button = document.createElement('button')\n\n this.$button.setAttribute('type', 'button')\n\n this.$root.classList.add('moj-password-reveal')\n this.$group.classList.add('moj-password-reveal__wrapper')\n this.$button.classList.add(\n 'govuk-button',\n 'govuk-button--secondary',\n 'moj-password-reveal__button'\n )\n\n this.$button.innerHTML =\n 'Show <span class=\"govuk-visually-hidden\">password</span>'\n\n this.$button.addEventListener('click', this.onButtonClick.bind(this))\n\n this.$group.append(this.$input, this.$button)\n this.$root.append(this.$group)\n }\n\n onButtonClick() {\n if (this.$input.type === 'password') {\n this.$input.type = 'text'\n this.$button.innerHTML =\n 'Hide <span class=\"govuk-visually-hidden\">password</span>'\n } else {\n this.$input.type = 'password'\n this.$button.innerHTML =\n 'Show <span class=\"govuk-visually-hidden\">password</span>'\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-password-reveal'\n}\n"],"names":["isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","name","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","PasswordReveal","$input","querySelector","HTMLInputElement","createButton","$group","createElement","$button","add","innerHTML","addEventListener","onButtonClick","bind","append","type"],"mappings":"AAqGO,SAASA,aAAaA,CAACC,KAAK,EAAEC,UAAU,EAAE;EAC/C,OACED,KAAK,YAAYE,WAAW,IAC5BF,KAAK,CAACG,YAAY,CAAC,CAAA,KAAA,EAAQF,UAAU,CAAA,KAAA,CAAO,CAAC;AAEjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACC,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;EAClD,IAAI,CAACF,MAAM,EAAE;AACX,IAAA,OAAO,KAAK;AACd;AAEA,EAAA,OAAOA,MAAM,CAACG,SAAS,CAACC,QAAQ,CAAC,0BAA0B,CAAC;AAC9D;AAiCO,SAASC,kBAAkBA,CAACC,SAAS,EAAEC,OAAO,EAAE;AACrD,EAAA,OAAO,GAAGD,SAAS,CAACV,UAAU,CAAA,EAAA,EAAKW,OAAO,CAAE,CAAA;AAC9C;;ACxIO,MAAMC,kBAAkB,SAASC,KAAK,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;IAAA,IAC5C,CAAAC,IAAI,GAAG,oBAAoB;AAAA;AAC7B;AAKO,MAAMC,YAAY,SAASL,kBAAkB,CAAC;AAGnD;AACF;AACA;AACA;AACA;AACEE,EAAAA,WAAWA,CAACV,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;IAClC,MAAMY,cAAc,GAClB,UAAU,IAAIC,iBAAiB,CAACC,SAAS,GACrC,gHAAgH,GAChH,kDAAkD;AAExD,IAAA,KAAK,CACHhB,MAAM,GACFc,cAAc,GACd,8DACN,CAAC;IAAA,IAjBH,CAAAF,IAAI,GAAG,cAAc;AAkBrB;AACF;AAYO,MAAMK,YAAY,SAAST,kBAAkB,CAAC;EAmBnDE,WAAWA,CAACQ,gBAAgB,EAAE;IAC5B,IAAI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MAAA,IAAI,CAACP,OAAO,CAACE,SAAS,GACpB,0DAA0D;AAC9D,KAAC,MAAM;AACL,MAAA,IAAI,CAACR,MAAM,CAACa,IAAI,GAAG,UAAU;AAC7B,MAAA,IAAI,CAACP,OAAO,CAACE,SAAS,GACpB,0DAA0D;AAC9D;AACF;;AAEA;AACF;AACA;AAEA;AAzDaT,cAAc,CAwDlBnC,UAAU,GAAG,qBAAqB;;;;","x_google_ignoreList":[0,1,2]}
|
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
this.el = element;
|
|
3
|
-
const $el = $(this.el);
|
|
1
|
+
import { Component } from 'govuk-frontend';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
class PasswordReveal extends Component {
|
|
4
|
+
/**
|
|
5
|
+
* @param {Element | null} $root - HTML element to use for password reveal
|
|
6
|
+
*/
|
|
7
|
+
constructor($root) {
|
|
8
|
+
super($root);
|
|
9
|
+
const $input = this.$root.querySelector('.govuk-input');
|
|
10
|
+
if (!$input || !($input instanceof HTMLInputElement)) {
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
this.$input = $input;
|
|
14
|
+
this.$input.setAttribute('spellcheck', 'false');
|
|
15
|
+
this.createButton();
|
|
16
|
+
}
|
|
17
|
+
createButton() {
|
|
18
|
+
this.$group = document.createElement('div');
|
|
19
|
+
this.$button = document.createElement('button');
|
|
20
|
+
this.$button.setAttribute('type', 'button');
|
|
21
|
+
this.$root.classList.add('moj-password-reveal');
|
|
22
|
+
this.$group.classList.add('moj-password-reveal__wrapper');
|
|
23
|
+
this.$button.classList.add('govuk-button', 'govuk-button--secondary', 'moj-password-reveal__button');
|
|
24
|
+
this.$button.innerHTML = 'Show <span class="govuk-visually-hidden">password</span>';
|
|
25
|
+
this.$button.addEventListener('click', this.onButtonClick.bind(this));
|
|
26
|
+
this.$group.append(this.$input, this.$button);
|
|
27
|
+
this.$root.append(this.$group);
|
|
28
|
+
}
|
|
29
|
+
onButtonClick() {
|
|
30
|
+
if (this.$input.type === 'password') {
|
|
31
|
+
this.$input.type = 'text';
|
|
32
|
+
this.$button.innerHTML = 'Hide <span class="govuk-visually-hidden">password</span>';
|
|
33
|
+
} else {
|
|
34
|
+
this.$input.type = 'password';
|
|
35
|
+
this.$button.innerHTML = 'Show <span class="govuk-visually-hidden">password</span>';
|
|
36
|
+
}
|
|
7
37
|
}
|
|
8
38
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
$el.wrap('<div class="moj-password-reveal"></div>');
|
|
13
|
-
this.container = $(this.el).parent();
|
|
14
|
-
this.createButton();
|
|
39
|
+
/**
|
|
40
|
+
* Name for the component used when initialising using data-module attributes.
|
|
41
|
+
*/
|
|
15
42
|
}
|
|
16
|
-
|
|
17
|
-
PasswordReveal.prototype.createButton = function () {
|
|
18
|
-
this.button = $(
|
|
19
|
-
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
20
|
-
);
|
|
21
|
-
this.container.append(this.button);
|
|
22
|
-
this.button.on('click', $.proxy(this, 'onButtonClick'));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
PasswordReveal.prototype.onButtonClick = function () {
|
|
26
|
-
if (this.el.type === 'password') {
|
|
27
|
-
this.el.type = 'text';
|
|
28
|
-
this.button.html('Hide <span class="govuk-visually-hidden">password</span>');
|
|
29
|
-
} else {
|
|
30
|
-
this.el.type = 'password';
|
|
31
|
-
this.button.html('Show <span class="govuk-visually-hidden">password</span>');
|
|
32
|
-
}
|
|
33
|
-
};
|
|
43
|
+
PasswordReveal.moduleName = 'moj-password-reveal';
|
|
34
44
|
|
|
35
45
|
export { PasswordReveal };
|
|
36
46
|
//# sourceMappingURL=password-reveal.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-reveal.mjs","sources":["../../../../src/moj/components/password-reveal/password-reveal.mjs"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"password-reveal.mjs","sources":["../../../../src/moj/components/password-reveal/password-reveal.mjs"],"sourcesContent":["import { Component } from 'govuk-frontend'\n\nexport class PasswordReveal extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for password reveal\n */\n constructor($root) {\n super($root)\n\n const $input = this.$root.querySelector('.govuk-input')\n if (!$input || !($input instanceof HTMLInputElement)) {\n return this\n }\n\n this.$input = $input\n this.$input.setAttribute('spellcheck', 'false')\n\n this.createButton()\n }\n\n createButton() {\n this.$group = document.createElement('div')\n this.$button = document.createElement('button')\n\n this.$button.setAttribute('type', 'button')\n\n this.$root.classList.add('moj-password-reveal')\n this.$group.classList.add('moj-password-reveal__wrapper')\n this.$button.classList.add(\n 'govuk-button',\n 'govuk-button--secondary',\n 'moj-password-reveal__button'\n )\n\n this.$button.innerHTML =\n 'Show <span class=\"govuk-visually-hidden\">password</span>'\n\n this.$button.addEventListener('click', this.onButtonClick.bind(this))\n\n this.$group.append(this.$input, this.$button)\n this.$root.append(this.$group)\n }\n\n onButtonClick() {\n if (this.$input.type === 'password') {\n this.$input.type = 'text'\n this.$button.innerHTML =\n 'Hide <span class=\"govuk-visually-hidden\">password</span>'\n } else {\n this.$input.type = 'password'\n this.$button.innerHTML =\n 'Show <span class=\"govuk-visually-hidden\">password</span>'\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-password-reveal'\n}\n"],"names":["PasswordReveal","Component","constructor","$root","$input","querySelector","HTMLInputElement","setAttribute","createButton","$group","document","createElement","$button","classList","add","innerHTML","addEventListener","onButtonClick","bind","append","type","moduleName"],"mappings":";;AAEO,MAAMA,cAAc,SAASC,SAAS,CAAC;AAC5C;AACF;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IAEZ,MAAMC,MAAM,GAAG,IAAI,CAACD,KAAK,CAACE,aAAa,CAAC,cAAc,CAAC;IACvD,IAAI,CAACD,MAAM,IAAI,EAAE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AAC9D,KAAC,MAAM;AACL,MAAA,IAAI,CAACX,MAAM,CAACgB,IAAI,GAAG,UAAU;AAC7B,MAAA,IAAI,CAACR,OAAO,CAACG,SAAS,GACpB,0DAA0D;AAC9D;AACF;;AAEA;AACF;AACA;AAEA;AAzDaf,cAAc,CAwDlBqB,UAAU,GAAG,qBAAqB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/primary-navigation/_primary-navigation.scss"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,4CAA4C;AAC9C;;AAEA;EACE,YAAY,EAAE,kCAAkC;EAChD,mBAAmB,EAAE,qCAAqC;EAC1D,4BAA4B;;EAE5B;IACE,WAAW;IACX,qBAAqB;IACrB,WAAW;EACb;AACF;;AAEA;EACE,gBAAgB;EAChB;IACE,qBAAqB;IACrB,sBAAsB;EACxB;AACF;;AAEA;EACE,SAAS;EACT,UAAU;EACV,YAAY,EAAE,+DAA+D;EAC7E,gBAAgB;AAClB;;AAEA;EACE,qBAAqB;EACrB,aAAa;EACb,8BAA8B;EAC9B,8BAA8B;;EAE9B;IACE,eAAe;EACjB;AACF;;AAEA;EACE,cAAc;EACd,iBAAiB;EACjB,oBAAoB;EACpB,iBAAiB;EACjB,0BAA0B;EAC1B,iCAAiC;;EAEjC;;;;IAIE,qBAAqB;EACvB;;EAEA;;IAEE,yBAAyB;EAC3B;;EAEA;IACE,+BAA+B;EACjC;;EAEA;IACE,kBAAkB,EAAE,0CAA0C;IAC9D,UAAU;IACV,4BAA4B,EAAE,gDAAgD;IAC9E,gBAAgB;EAClB;;EAEA;IACE,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,SAAS;IACT,OAAO;IACP,WAAW;IACX,WAAW;IACX,uCAAuC;EACzC;;EAEA;IACE,kBAAkB;IAClB,yBAAyB;IACzB,iBAAiB;IACjB,qBAAqB;;IAErB;MACE,WAAW;MACX,cAAc;MACd,kBAAkB;MAClB,SAAS;MACT,OAAO;MACP,WAAW;MACX,WAAW;MACX,oCAAoC;IACtC;;IAEA;MACE,+BAA+B;;MAE/B;QACE,0CAA0C;MAC5C;IACF;;IAEA;MACE,kBAAkB,EAAE,0CAA0C;MAC9D,YAAY;MACZ,4BAA4B,EAAE,gDAAgD;;MAE9E;QACE,uCAAuC;MACzC;IACF;EACF;AACF;;AAEA;EACE;IACE,qBAAqB;IACrB,sBAAsB;EACxB;AACF","file":"_primary-navigation.scss","sourcesContent":["@use \"../../objects/width-container\" as *;\n@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #PRIMARY NAVIGATION\n ========================================================================== */\n\n.moj-primary-navigation {\n background-color: govuk-colour(\"light-grey\");\n}\n\n.moj-primary-navigation__container {\n font-size: 0; // Hide whitespace between elements\n text-align: justify; // Trick to remove the need for floats\n @include moj-width-container;\n\n &::after {\n content: \"\";\n display: inline-block;\n width: 100%;\n }\n}\n\n.moj-primary-navigation__nav {\n text-align: left;\n @include govuk-media-query($from: desktop) {\n display: inline-block;\n vertical-align: middle;\n }\n}\n\n.moj-primary-navigation__list {\n margin: 0;\n padding: 0;\n font-size: 0; // Removes white space when using inline-block on child element.\n list-style: none;\n}\n\n.moj-primary-navigation__item {\n display: inline-block;\n margin-top: 0;\n margin-right: govuk-spacing(4);\n @include govuk-font($size: 19);\n\n &:last-child {\n margin-right: 0;\n }\n}\n\n.moj-primary-navigation__link {\n display: block;\n padding-top: 15px;\n padding-bottom: 15px;\n font-weight: bold;\n @include govuk-link-common;\n @include govuk-link-style-default;\n\n &:link,\n &:visited,\n &:hover,\n &:active {\n text-decoration: none;\n }\n\n &:link,\n &:visited {\n color: $govuk-link-colour;\n }\n\n &:hover {\n color: $govuk-link-hover-colour;\n }\n\n &:focus {\n position: relative; // Ensure focus sits above everything else.\n z-index: 1;\n color: govuk-colour(\"black\"); // Focus colour on yellow should really be black.\n box-shadow: none;\n }\n\n &:focus::before {\n content: \"\";\n display: block;\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 5px;\n background-color: govuk-colour(\"black\");\n }\n\n &[aria-current] {\n position: relative;\n color: $govuk-link-colour;\n font-weight: bold;\n text-decoration: none;\n\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 5px;\n background-color: $govuk-link-colour;\n }\n\n &:hover {\n color: $govuk-link-hover-colour;\n\n &::before {\n background-color: $govuk-link-hover-colour;\n }\n }\n\n &:focus {\n position: relative; // Ensure focus sits above everything else.\n border: none;\n color: govuk-colour(\"black\"); // Focus colour on yellow should really be black.\n\n &::before {\n background-color: govuk-colour(\"black\");\n }\n }\n }\n}\n\n.moj-primary-navigation__search {\n @include govuk-media-query($from: desktop) {\n display: inline-block;\n vertical-align: middle;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/progress-bar/_progress-bar.scss"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,+BAA+B;AACjC;;AAEA;EACE,kBAAkB;EAClB,SAAS;EACT,UAAU;EACV,YAAY,EAAE,mCAAmC;EACjD,gBAAgB;EAChB,mBAAmB;EACnB,mBAAmB;;EAEnB;IACE,WAAW;IACX,qBAAqB;IACrB,WAAW;EACb;;EAEA;IACE,WAAW;IACX,kBAAkB;IAClB,SAAS;IACT,OAAO;IACP,WAAW;IACX,2CAA2C;EAC7C;AACF;;AAEA;EACE,qBAAqB;EACrB,kBAAkB;EAClB,cAAc;EACd,kBAAkB;EAClB,mBAAmB;EACnB,uBAAuB;;EAEvB;;IAEE;MACE,WAAW;MACX,kBAAkB;MAClB,SAAS;MACT,OAAO;MACP,UAAU;MACV,2CAA2C;IAC7C;EACF;;EAEA;IACE;MACE,OAAO;IACT;EACF;;EAEA;IACE;MACE,QAAQ;MACR,UAAU;IACZ;EACF;;EAEA;IACE,kDAAkD;IAClD,+CAA+C;EACjD;AACF;;AAEA;EACE,sBAAsB;EACtB,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB,iBAAiB;EACjB,uCAAuC;EACvC,kBAAkB;EAClB,uCAAuC;AACzC;;AAEA;EACE,uCAAuC;EACvC,gEAAgE;EAChE,4BAA4B;EAC5B,4BAA4B;AAC9B;;AAEA;EACE,cAAc;EACd,kBAAkB;EAClB,4BAA4B;EAC5B,oBAAoB;EACpB,qBAAqB,EAAE,cAAc;EACrC,uBAAuB;AACzB","file":"_progress-bar.scss","sourcesContent":["@use \"../../settings/assets\" as *;\n@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #PROGRESS BAR\n ========================================================================== */\n\n.moj-progress-bar {\n margin-bottom: govuk-spacing(7);\n}\n\n.moj-progress-bar__list {\n position: relative;\n margin: 0;\n padding: 0;\n font-size: 0; // Hide white space between elements\n list-style: none;\n text-align: justify;\n vertical-align: top;\n\n &::after {\n content: \"\";\n display: inline-block;\n width: 100%;\n }\n\n &::before {\n content: \"\";\n position: absolute;\n top: 13px;\n left: 0;\n width: 100%;\n border-top: 6px solid govuk-colour(\"green\");\n }\n}\n\n.moj-progress-bar__item {\n display: inline-block;\n position: relative;\n max-width: 20%;\n text-align: center;\n vertical-align: top;\n @include govuk-font(19);\n\n &:first-child,\n &:last-child {\n &::before {\n content: \"\";\n position: absolute;\n top: 13px;\n left: 0;\n width: 50%;\n border-top: 6px solid govuk-colour(\"white\");\n }\n }\n\n &:first-child {\n &::before {\n left: 0;\n }\n }\n\n &:last-child {\n &::before {\n right: 0;\n left: auto;\n }\n }\n\n &[aria-current=\"step\"] {\n // https://tink.uk/using-the-aria-current-attribute\n @include govuk-font($size: 19, $weight: \"bold\");\n }\n}\n\n.moj-progress-bar__icon {\n box-sizing: border-box;\n display: block;\n position: relative;\n width: 32px;\n height: 32px;\n margin-right: auto;\n margin-left: auto;\n border: 6px solid govuk-colour(\"green\");\n border-radius: 50%;\n background-color: govuk-colour(\"white\");\n}\n\n.moj-progress-bar__icon--complete {\n background-color: govuk-colour(\"green\");\n background-image: url(#{$moj-images-path}icon-progress-tick.svg);\n background-repeat: no-repeat;\n background-position: 50% 50%;\n}\n\n.moj-progress-bar__label {\n display: block;\n position: relative;\n margin-top: govuk-spacing(3);\n font-weight: inherit;\n word-wrap: break-word; // Just in case\n @include govuk-font(16);\n}\n"]}
|
|
@@ -4,13 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
## Example
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</script>
|
|
14
|
-
```
|
|
7
|
+
```mjs
|
|
8
|
+
import { RichTextEditor } from '@ministryofjustice/frontend'
|
|
9
|
+
|
|
10
|
+
const $richTextEditor = document.querySelector(
|
|
11
|
+
'[data-module="moj-rich-text-editor"]'
|
|
12
|
+
)
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
new RichTextEditor($richTextEditor, {
|
|
15
|
+
toolbar: {
|
|
16
|
+
bold: true,
|
|
17
|
+
italic: true,
|
|
18
|
+
underline: true,
|
|
19
|
+
bullets: true,
|
|
20
|
+
numbers: true
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/moj/components/rich-text-editor/_rich-text-editor.scss"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,uBAAuB;EACvB,+BAA+B;AACjC;;AAEA;EACE,WAAW;EACX,YAAY;EACZ,iBAAiB;EACjB,WAAW;EACX,uCAAuC;EACvC,UAAU;EACV,4BAA4B;EAC5B,uCAAuC;EACvC,4BAA4B;EAC5B,4BAA4B;EAC5B,0BAA0B;EAC1B,qBAAqB;EACrB,mBAAmB;EACnB,eAAe;;EAEf;IACE,cAAc;EAChB;;EAEA,wCAAwC;EACxC;IACE,UAAU;IACV,SAAS;EACX;;EAEA;IACE,kBAAkB;IAClB,UAAU;IACV,aAAa;IACb,+BAA+B;IAC/B,qCAAqC;IACrC;;oCAEgC;EAClC;AACF;;AAEA;EACE,+DAA+D;AACjE;;AAEA;EACE,iEAAiE;AACnE;;AAEA;EACE,oEAAoE;AACtE;;AAEA;EACE,6BAA6B;EAC7B,yEAAyE;AAC3E;;AAEA;EACE,uEAAuE;AACzE;;AAEA;EACE,iBAAiB;EACjB,cAAc;EACd,gBAAgB;EAChB,aAAa;AACf","file":"_rich-text-editor.scss","sourcesContent":["@use \"../../settings/assets\" as *;\n@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #RICH TEXT EDITOR\n ========================================================================== */\n\n.moj-rich-text-editor__toolbar {\n @include govuk-clearfix;\n margin-bottom: govuk-spacing(2);\n}\n\n.moj-rich-text-editor__toolbar-button {\n width: 40px;\n height: 40px;\n margin-left: -2px;\n float: left;\n border: 2px solid govuk-colour(\"black\");\n outline: 0;\n color: govuk-colour(\"black\");\n background-color: govuk-colour(\"white\");\n background-repeat: no-repeat;\n background-position: 50% 50%;\n background-size: 40px 40px;\n text-decoration: none;\n vertical-align: top;\n cursor: pointer;\n\n &:first-child {\n margin-left: 0;\n }\n\n // Fix unwanted button padding in Firefox\n &::-moz-focus-inner {\n padding: 0;\n border: 0;\n }\n\n &:focus {\n position: relative;\n z-index: 2;\n outline: none;\n color: $govuk-focus-text-colour;\n background-color: $govuk-focus-colour;\n box-shadow:\n 0 -2px $govuk-focus-colour,\n 0 4px $govuk-focus-text-colour;\n }\n}\n\n.moj-rich-text-editor__toolbar-button--bold {\n background-image: url(#{$moj-images-path}icon-wysiwyg-bold.svg);\n}\n\n.moj-rich-text-editor__toolbar-button--italic {\n background-image: url(#{$moj-images-path}icon-wysiwyg-italic.svg);\n}\n\n.moj-rich-text-editor__toolbar-button--underline {\n background-image: url(#{$moj-images-path}icon-wysiwyg-underline.svg);\n}\n\n.moj-rich-text-editor__toolbar-button--unordered-list {\n margin-left: govuk-spacing(2);\n background-image: url(#{$moj-images-path}icon-wysiwyg-unordered-list.svg);\n}\n\n.moj-rich-text-editor__toolbar-button--ordered-list {\n background-image: url(#{$moj-images-path}icon-wysiwyg-ordered-list.svg);\n}\n\n.moj-rich-text-editor__content {\n min-height: 130px;\n overflow: auto;\n resize: vertical;\n outline: none;\n}\n"]}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('govuk-frontend')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'govuk-frontend'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}, global.GOVUKFrontend));
|
|
5
|
+
})(this, (function (exports, govukFrontend) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @augments {ConfigurableComponent<RichTextEditorConfig>}
|
|
9
|
+
*/
|
|
10
|
+
class RichTextEditor extends govukFrontend.ConfigurableComponent {
|
|
11
|
+
/**
|
|
12
|
+
* @param {Element | null} $root - HTML element to use for rich text editor
|
|
13
|
+
* @param {RichTextEditorConfig} config
|
|
14
|
+
*/
|
|
15
|
+
constructor($root, config = {}) {
|
|
16
|
+
super($root, config);
|
|
17
|
+
if (!RichTextEditor.isSupported()) {
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
const $textarea = this.$root.querySelector('.govuk-textarea');
|
|
21
|
+
if (!$textarea || !($textarea instanceof HTMLTextAreaElement)) {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
this.$textarea = $textarea;
|
|
25
|
+
this.createToolbar();
|
|
26
|
+
this.hideDefault();
|
|
27
|
+
this.configureToolbar();
|
|
28
|
+
this.keys = {
|
|
29
|
+
left: 37,
|
|
30
|
+
right: 39,
|
|
31
|
+
up: 38,
|
|
32
|
+
down: 40
|
|
33
|
+
};
|
|
34
|
+
this.$content.addEventListener('input', this.onEditorInput.bind(this));
|
|
35
|
+
this.$root.querySelector('label').addEventListener('click', this.onLabelClick.bind(this));
|
|
36
|
+
this.$toolbar.addEventListener('keydown', this.onToolbarKeydown.bind(this));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {KeyboardEvent} event - Click event
|
|
41
|
+
*/
|
|
42
|
+
onToolbarKeydown(event) {
|
|
43
|
+
let $focusableButton;
|
|
44
|
+
switch (event.keyCode) {
|
|
45
|
+
case this.keys.right:
|
|
46
|
+
case this.keys.down:
|
|
47
|
+
{
|
|
48
|
+
$focusableButton = this.$buttons.find(button => button.getAttribute('tabindex') === '0');
|
|
49
|
+
if ($focusableButton) {
|
|
50
|
+
const $nextButton = $focusableButton.nextElementSibling;
|
|
51
|
+
if ($nextButton && $nextButton instanceof HTMLButtonElement) {
|
|
52
|
+
$nextButton.focus();
|
|
53
|
+
$focusableButton.setAttribute('tabindex', '-1');
|
|
54
|
+
$nextButton.setAttribute('tabindex', '0');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case this.keys.left:
|
|
60
|
+
case this.keys.up:
|
|
61
|
+
{
|
|
62
|
+
$focusableButton = this.$buttons.find(button => button.getAttribute('tabindex') === '0');
|
|
63
|
+
if ($focusableButton) {
|
|
64
|
+
const $previousButton = $focusableButton.previousElementSibling;
|
|
65
|
+
if ($previousButton && $previousButton instanceof HTMLButtonElement) {
|
|
66
|
+
$previousButton.focus();
|
|
67
|
+
$focusableButton.setAttribute('tabindex', '-1');
|
|
68
|
+
$previousButton.setAttribute('tabindex', '0');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
getToolbarHtml() {
|
|
76
|
+
let html = '';
|
|
77
|
+
html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">';
|
|
78
|
+
if (this.config.toolbar.bold) {
|
|
79
|
+
html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>';
|
|
80
|
+
}
|
|
81
|
+
if (this.config.toolbar.italic) {
|
|
82
|
+
html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>';
|
|
83
|
+
}
|
|
84
|
+
if (this.config.toolbar.underline) {
|
|
85
|
+
html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>';
|
|
86
|
+
}
|
|
87
|
+
if (this.config.toolbar.bullets) {
|
|
88
|
+
html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>';
|
|
89
|
+
}
|
|
90
|
+
if (this.config.toolbar.numbers) {
|
|
91
|
+
html += '<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>';
|
|
92
|
+
}
|
|
93
|
+
html += '</div>';
|
|
94
|
+
return html;
|
|
95
|
+
}
|
|
96
|
+
getEnhancedHtml() {
|
|
97
|
+
return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`;
|
|
98
|
+
}
|
|
99
|
+
hideDefault() {
|
|
100
|
+
this.$textarea.classList.add('govuk-visually-hidden');
|
|
101
|
+
this.$textarea.setAttribute('aria-hidden', 'true');
|
|
102
|
+
this.$textarea.setAttribute('tabindex', '-1');
|
|
103
|
+
}
|
|
104
|
+
createToolbar() {
|
|
105
|
+
this.$toolbar = document.createElement('div');
|
|
106
|
+
this.$toolbar.className = 'moj-rich-text-editor';
|
|
107
|
+
this.$toolbar.innerHTML = this.getEnhancedHtml();
|
|
108
|
+
this.$root.append(this.$toolbar);
|
|
109
|
+
this.$content = /** @type {HTMLElement} */
|
|
110
|
+
this.$root.querySelector('.moj-rich-text-editor__content');
|
|
111
|
+
this.$content.innerHTML = this.$textarea.value;
|
|
112
|
+
}
|
|
113
|
+
configureToolbar() {
|
|
114
|
+
this.$buttons = Array.from(/** @type {NodeListOf<HTMLButtonElement>} */
|
|
115
|
+
this.$root.querySelectorAll('.moj-rich-text-editor__toolbar-button'));
|
|
116
|
+
this.$buttons.forEach(($button, index) => {
|
|
117
|
+
$button.setAttribute('tabindex', !index ? '0' : '-1');
|
|
118
|
+
$button.addEventListener('click', this.onButtonClick.bind(this));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {MouseEvent} event - Click event
|
|
124
|
+
*/
|
|
125
|
+
onButtonClick(event) {
|
|
126
|
+
if (!(event.currentTarget instanceof HTMLElement)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
document.execCommand(event.currentTarget.getAttribute('data-command'), false, undefined);
|
|
130
|
+
}
|
|
131
|
+
getContent() {
|
|
132
|
+
return this.$content.innerHTML;
|
|
133
|
+
}
|
|
134
|
+
onEditorInput() {
|
|
135
|
+
this.updateTextarea();
|
|
136
|
+
}
|
|
137
|
+
updateTextarea() {
|
|
138
|
+
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
139
|
+
this.$textarea.value = this.getContent();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {MouseEvent} event - Click event
|
|
144
|
+
*/
|
|
145
|
+
onLabelClick(event) {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
this.$content.focus();
|
|
148
|
+
}
|
|
149
|
+
static isSupported() {
|
|
150
|
+
return 'contentEditable' in document.documentElement;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Name for the component used when initialising using data-module attributes.
|
|
155
|
+
*/
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Rich text editor config
|
|
160
|
+
*
|
|
161
|
+
* @typedef {object} RichTextEditorConfig
|
|
162
|
+
* @property {RichTextEditorToolbar} [toolbar] - Toolbar options
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Rich text editor toolbar options
|
|
167
|
+
*
|
|
168
|
+
* @typedef {object} RichTextEditorToolbar
|
|
169
|
+
* @property {boolean} [bold] - Show the bold button
|
|
170
|
+
* @property {boolean} [italic] - Show the italic button
|
|
171
|
+
* @property {boolean} [underline] - Show the underline button
|
|
172
|
+
* @property {boolean} [bullets] - Show the bullets button
|
|
173
|
+
* @property {boolean} [numbers] - Show the numbers button
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'
|
|
178
|
+
*/
|
|
179
|
+
RichTextEditor.moduleName = 'moj-rich-text-editor';
|
|
180
|
+
/**
|
|
181
|
+
* Rich text editor config
|
|
182
|
+
*
|
|
183
|
+
* @type {RichTextEditorConfig}
|
|
184
|
+
*/
|
|
185
|
+
RichTextEditor.defaults = Object.freeze({
|
|
186
|
+
toolbar: {
|
|
187
|
+
bold: false,
|
|
188
|
+
italic: false,
|
|
189
|
+
underline: false,
|
|
190
|
+
bullets: true,
|
|
191
|
+
numbers: true
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
/**
|
|
195
|
+
* Rich text editor config schema
|
|
196
|
+
*
|
|
197
|
+
* @satisfies {Schema<RichTextEditorConfig>}
|
|
198
|
+
*/
|
|
199
|
+
RichTextEditor.schema = Object.freeze(/** @type {const} */{
|
|
200
|
+
properties: {
|
|
201
|
+
toolbar: {
|
|
202
|
+
type: 'object'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
exports.RichTextEditor = RichTextEditor;
|
|
208
|
+
|
|
209
|
+
}));
|
|
210
|
+
//# sourceMappingURL=rich-text-editor.bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-editor.bundle.js","sources":["../../../../src/moj/components/rich-text-editor/rich-text-editor.mjs"],"sourcesContent":["import { ConfigurableComponent } from 'govuk-frontend'\n\n/**\n * @augments {ConfigurableComponent<RichTextEditorConfig>}\n */\nexport class RichTextEditor extends ConfigurableComponent {\n /**\n * @param {Element | null} $root - HTML element to use for rich text editor\n * @param {RichTextEditorConfig} config\n */\n constructor($root, config = {}) {\n super($root, config)\n\n if (!RichTextEditor.isSupported()) {\n return this\n }\n\n const $textarea = this.$root.querySelector('.govuk-textarea')\n if (!$textarea || !($textarea instanceof HTMLTextAreaElement)) {\n return this\n }\n\n this.$textarea = $textarea\n\n this.createToolbar()\n this.hideDefault()\n this.configureToolbar()\n\n this.keys = {\n left: 37,\n right: 39,\n up: 38,\n down: 40\n }\n\n this.$content.addEventListener('input', this.onEditorInput.bind(this))\n\n this.$root\n .querySelector('label')\n .addEventListener('click', this.onLabelClick.bind(this))\n\n this.$toolbar.addEventListener('keydown', this.onToolbarKeydown.bind(this))\n }\n\n /**\n * @param {KeyboardEvent} event - Click event\n */\n onToolbarKeydown(event) {\n let $focusableButton\n switch (event.keyCode) {\n case this.keys.right:\n case this.keys.down: {\n $focusableButton = this.$buttons.find(\n (button) => button.getAttribute('tabindex') === '0'\n )\n\n if ($focusableButton) {\n const $nextButton = $focusableButton.nextElementSibling\n\n if ($nextButton && $nextButton instanceof HTMLButtonElement) {\n $nextButton.focus()\n $focusableButton.setAttribute('tabindex', '-1')\n $nextButton.setAttribute('tabindex', '0')\n }\n }\n\n break\n }\n\n case this.keys.left:\n case this.keys.up: {\n $focusableButton = this.$buttons.find(\n (button) => button.getAttribute('tabindex') === '0'\n )\n\n if ($focusableButton) {\n const $previousButton = $focusableButton.previousElementSibling\n\n if ($previousButton && $previousButton instanceof HTMLButtonElement) {\n $previousButton.focus()\n $focusableButton.setAttribute('tabindex', '-1')\n $previousButton.setAttribute('tabindex', '0')\n }\n }\n\n break\n }\n }\n }\n\n getToolbarHtml() {\n let html = ''\n\n html += '<div class=\"moj-rich-text-editor__toolbar\" role=\"toolbar\">'\n\n if (this.config.toolbar.bold) {\n html +=\n '<button class=\"moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold\" type=\"button\" data-command=\"bold\"><span class=\"govuk-visually-hidden\">Bold</span></button>'\n }\n\n if (this.config.toolbar.italic) {\n html +=\n '<button class=\"moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic\" type=\"button\" data-command=\"italic\"><span class=\"govuk-visually-hidden\">Italic</span></button>'\n }\n\n if (this.config.toolbar.underline) {\n html +=\n '<button class=\"moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline\" type=\"button\" data-command=\"underline\"><span class=\"govuk-visually-hidden\">Underline</span></button>'\n }\n\n if (this.config.toolbar.bullets) {\n html +=\n '<button class=\"moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list\" type=\"button\" data-command=\"insertUnorderedList\"><span class=\"govuk-visually-hidden\">Unordered list</span></button>'\n }\n\n if (this.config.toolbar.numbers) {\n html +=\n '<button class=\"moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list\" type=\"button\" data-command=\"insertOrderedList\"><span class=\"govuk-visually-hidden\">Ordered list</span></button>'\n }\n\n html += '</div>'\n return html\n }\n\n getEnhancedHtml() {\n return `${this.getToolbarHtml()}<div class=\"govuk-textarea moj-rich-text-editor__content\" contenteditable=\"true\" spellcheck=\"false\"></div>`\n }\n\n hideDefault() {\n this.$textarea.classList.add('govuk-visually-hidden')\n this.$textarea.setAttribute('aria-hidden', 'true')\n this.$textarea.setAttribute('tabindex', '-1')\n }\n\n createToolbar() {\n this.$toolbar = document.createElement('div')\n this.$toolbar.className = 'moj-rich-text-editor'\n this.$toolbar.innerHTML = this.getEnhancedHtml()\n this.$root.append(this.$toolbar)\n\n this.$content = /** @type {HTMLElement} */ (\n this.$root.querySelector('.moj-rich-text-editor__content')\n )\n\n this.$content.innerHTML = this.$textarea.value\n }\n\n configureToolbar() {\n this.$buttons = Array.from(\n /** @type {NodeListOf<HTMLButtonElement>} */\n (this.$root.querySelectorAll('.moj-rich-text-editor__toolbar-button'))\n )\n\n this.$buttons.forEach(($button, index) => {\n $button.setAttribute('tabindex', !index ? '0' : '-1')\n $button.addEventListener('click', this.onButtonClick.bind(this))\n })\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n onButtonClick(event) {\n if (!(event.currentTarget instanceof HTMLElement)) {\n return\n }\n\n document.execCommand(\n event.currentTarget.getAttribute('data-command'),\n false,\n undefined\n )\n }\n\n getContent() {\n return this.$content.innerHTML\n }\n\n onEditorInput() {\n this.updateTextarea()\n }\n\n updateTextarea() {\n document.execCommand('defaultParagraphSeparator', false, 'p')\n this.$textarea.value = this.getContent()\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n onLabelClick(event) {\n event.preventDefault()\n this.$content.focus()\n }\n\n static isSupported() {\n return 'contentEditable' in document.documentElement\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-rich-text-editor'\n\n /**\n * Rich text editor config\n *\n * @type {RichTextEditorConfig}\n */\n static defaults = Object.freeze({\n toolbar: {\n bold: false,\n italic: false,\n underline: false,\n bullets: true,\n numbers: true\n }\n })\n\n /**\n * Rich text editor config schema\n *\n * @satisfies {Schema<RichTextEditorConfig>}\n */\n static schema = Object.freeze(\n /** @type {const} */ ({\n properties: {\n toolbar: { type: 'object' }\n }\n })\n )\n}\n\n/**\n * Rich text editor config\n *\n * @typedef {object} RichTextEditorConfig\n * @property {RichTextEditorToolbar} [toolbar] - Toolbar options\n */\n\n/**\n * Rich text editor toolbar options\n *\n * @typedef {object} RichTextEditorToolbar\n * @property {boolean} [bold] - Show the bold button\n * @property {boolean} [italic] - Show the italic button\n * @property {boolean} [underline] - Show the underline button\n * @property {boolean} [bullets] - Show the bullets button\n * @property {boolean} [numbers] - Show the numbers button\n */\n\n/**\n * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'\n */\n"],"names":["RichTextEditor","ConfigurableComponent","constructor","$root","config","isSupported","$textarea","querySelector","HTMLTextAreaElement","createToolbar","hideDefault","configureToolbar","keys","left","right","up","down","$content","addEventListener","onEditorInput","bind","onLabelClick","$toolbar","onToolbarKeydown","event","$focusableButton","keyCode","$buttons","find","button","getAttribute","$nextButton","nextElementSibling","HTMLButtonElement","focus","setAttribute","$previousButton","previousElementSibling","getToolbarHtml","html","toolbar","bold","italic","underline","bullets","numbers","getEnhancedHtml","classList","add","document","createElement","className","innerHTML","append","value","Array","from","querySelectorAll","forEach","$button","index","onButtonClick","currentTarget","HTMLElement","execCommand","undefined","getContent","updateTextarea","preventDefault","documentElement","moduleName","defaults","Object","freeze","schema","properties","type"],"mappings":";;;;;;EAEA;EACA;EACA;EACO,MAAMA,cAAc,SAASC,mCAAqB,CAAC;EACxD;EACF;EACA;EACA;EACEC,EAAAA,WAAWA,CAACC,KAAK,EAAEC,MAAM,GAAG,EAAE,EAAE;EAC9B,IAAA,KAAK,CAACD,KAAK,EAAEC,MAAM,CAAC;EAEpB,IAAA,IAAI,CAACJ,cAAc,CAACK,WAAW,EAAE,EAAE;EACjC,MAAA,OAAO,IAAI;EACb;MAEA,MAAMC,SAAS,GAAG,IAAI,CAACH,KAAK,CAACI,aAAa,CAAC,iBAAiB,CAAC;MAC7D,IAAI,CAACD,SAAS,IAAI,EAAEA,SAAS,YAAYE,mBAAmB,CAAC,EAAE;EAC7D,MAAA,OAAO,IAAI;EACb;MAEA,IAAI,CAACF,SAAS,GAAGA,SAAS;MAE1B,IAAI,CAACG,aAAa,EAAE;MACpB,IAAI,CAACC,WAAW,EAAE;MAClB,IAAI,CAACC,gBAAgB,EA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