Sha256: 8dd611c165c43defa4102d5a520a2d9e3a598736d04e9837ae1633b323e697ac
Contents?: true
Size: 1.7 KB
Versions: 8
Compression:
Stored size: 1.7 KB
Contents
import { mergeConfigs, setFocus } from '../../common/index.mjs'; import { normaliseDataset } from '../../common/normalise-dataset.mjs'; import { ElementError } from '../../errors/index.mjs'; import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'; /** * Notification Banner component * * @preserve */ class NotificationBanner extends GOVUKFrontendComponent { /** * @param {Element | null} $module - HTML element to use for notification banner * @param {NotificationBannerConfig} [config] - Notification banner config */ constructor($module, config = {}) { super(); this.$module = void 0; this.config = void 0; if (!($module instanceof HTMLElement)) { throw new ElementError({ componentName: 'Notification banner', element: $module, identifier: 'Root element (`$module`)' }); } this.$module = $module; this.config = mergeConfigs(NotificationBanner.defaults, config, normaliseDataset($module.dataset)); if (this.$module.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) { setFocus(this.$module); } } } /** * Notification banner config * * @typedef {object} NotificationBannerConfig * @property {boolean} [disableAutoFocus=false] - If set to `true` the * notification banner will not be focussed when the page loads. This only * applies if the component has a `role` of `alert` – in other cases the * component will not be focused on page load, regardless of this option. */ NotificationBanner.moduleName = 'govuk-notification-banner'; NotificationBanner.defaults = Object.freeze({ disableAutoFocus: false }); export { NotificationBanner }; //# sourceMappingURL=notification-banner.mjs.map
Version data entries
8 entries across 8 versions & 1 rubygems