{"version":3,"file":"notification-banner.mjs","sources":["../../../../src/govuk/components/notification-banner/notification-banner.mjs"],"sourcesContent":["import { mergeConfigs, setFocus } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Notification Banner component\n *\n * @preserve\n */\nexport class NotificationBanner extends GOVUKFrontendComponent {\n /**\n * @private\n * @type {NotificationBannerConfig}\n */\n config\n\n /**\n * @param {Element | null} $root - HTML element to use for notification banner\n * @param {NotificationBannerConfig} [config] - Notification banner config\n */\n constructor($root, config = {}) {\n super($root)\n\n this.config = mergeConfigs(\n NotificationBanner.defaults,\n config,\n normaliseDataset(NotificationBanner, this.$root.dataset)\n )\n\n /**\n * Focus the notification banner\n *\n * If `role=\"alert\"` is set, focus the element to help some assistive\n * technologies prioritise announcing it.\n *\n * You can turn off the auto-focus functionality by setting\n * `data-disable-auto-focus=\"true\"` in the component HTML. You might wish to\n * do this based on user research findings, or to avoid a clash with another\n * element which should be focused when the page loads.\n */\n if (\n this.$root.getAttribute('role') === 'alert' &&\n !this.config.disableAutoFocus\n ) {\n setFocus(this.$root)\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-notification-banner'\n\n /**\n * Notification banner default config\n *\n * @see {@link NotificationBannerConfig}\n * @constant\n * @type {NotificationBannerConfig}\n */\n static defaults = Object.freeze({\n disableAutoFocus: false\n })\n\n /**\n * Notification banner config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n disableAutoFocus: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Notification banner config\n *\n * @typedef {object} NotificationBannerConfig\n * @property {boolean} [disableAutoFocus=false] - If set to `true` the\n * notification banner will not be focussed when the page loads. This only\n * applies if the component has a `role` of `alert` – in other cases the\n * component will not be focused on page load, regardless of this option.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["NotificationBanner","GOVUKFrontendComponent","constructor","$root","config","mergeConfigs","defaults","normaliseDataset","dataset","getAttribute","disableAutoFocus","setFocus","moduleName","Object","freeze","schema","properties","type"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,SAASC,sBAAsB,CAAC;AAO7D;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,KAAK,EAAEC,MAAM,GAAG,EAAE,EAAE;IAC9B,KAAK,CAACD,KAAK,CAAC,CAAA;AAAA,IAAA,IAAA,CAPdC,MAAM,GAAA,KAAA,CAAA,CAAA;IASJ,IAAI,CAACA,MAAM,GAAGC,YAAY,CACxBL,kBAAkB,CAACM,QAAQ,EAC3BF,MAAM,EACNG,gBAAgB,CAACP,kBAAkB,EAAE,IAAI,CAACG,KAAK,CAACK,OAAO,CACzD,CAAC,CAAA;AAaD,IAAA,IACE,IAAI,CAACL,KAAK,CAACM,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,IAC3C,CAAC,IAAI,CAACL,MAAM,CAACM,gBAAgB,EAC7B;AACAC,MAAAA,QAAQ,CAAC,IAAI,CAACR,KAAK,CAAC,CAAA;AACtB,KAAA;AACF,GAAA;AA6BF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAhFaH,kBAAkB,CA0CtBY,UAAU,GAAG,2BAA2B,CAAA;AA1CpCZ,kBAAkB,CAmDtBM,QAAQ,GAAGO,MAAM,CAACC,MAAM,CAAC;AAC9BJ,EAAAA,gBAAgB,EAAE,KAAA;AACpB,CAAC,CAAC,CAAA;AArDSV,kBAAkB,CA6DtBe,MAAM,GAAGF,MAAM,CAACC,MAAM,CAAC;AAC5BE,EAAAA,UAAU,EAAE;AACVN,IAAAA,gBAAgB,EAAE;AAAEO,MAAAA,IAAI,EAAE,SAAA;AAAU,KAAA;AACtC,GAAA;AACF,CAAC,CAAC;;;;"}