| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ // The require scope |
| 4 |
/******/ var __webpack_require__ = {}; |
| 5 |
/******/ |
| 6 |
/************************************************************************/ |
| 7 |
/******/ /* webpack/runtime/compat get default export */ |
| 8 |
/******/ !function() { |
| 9 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 10 |
/******/ __webpack_require__.n = function(module) { |
| 11 |
/******/ var getter = module && module.__esModule ? |
| 12 |
/******/ function() { return module['default']; } : |
| 13 |
/******/ function() { return module; }; |
| 14 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 15 |
/******/ return getter; |
| 16 |
/******/ }; |
| 17 |
/******/ }(); |
| 18 |
/******/ |
| 19 |
/******/ /* webpack/runtime/define property getters */ |
| 20 |
/******/ !function() { |
| 21 |
/******/ // define getter functions for harmony exports |
| 22 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 23 |
/******/ for(var key in definition) { |
| 24 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 25 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 26 |
/******/ } |
| 27 |
/******/ } |
| 28 |
/******/ }; |
| 29 |
/******/ }(); |
| 30 |
/******/ |
| 31 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 32 |
/******/ !function() { |
| 33 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 34 |
/******/ }(); |
| 35 |
/******/ |
| 36 |
/******/ /* webpack/runtime/make namespace object */ |
| 37 |
/******/ !function() { |
| 38 |
/******/ // define __esModule on exports |
| 39 |
/******/ __webpack_require__.r = function(exports) { |
| 40 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 41 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 42 |
/******/ } |
| 43 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 44 |
/******/ }; |
| 45 |
/******/ }(); |
| 46 |
/******/ |
| 47 |
/************************************************************************/ |
| 48 |
var __webpack_exports__ = {}; |
| 49 |
// ESM COMPAT FLAG |
| 50 |
__webpack_require__.r(__webpack_exports__); |
| 51 |
|
| 52 |
// EXPORTS |
| 53 |
__webpack_require__.d(__webpack_exports__, { |
| 54 |
"setup": function() { return /* binding */ setup; }, |
| 55 |
"speak": function() { return /* binding */ speak; } |
| 56 |
}); |
| 57 |
|
| 58 |
;// CONCATENATED MODULE: external ["wp","domReady"] |
| 59 |
var external_wp_domReady_namespaceObject = window["wp"]["domReady"]; |
| 60 |
var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_namespaceObject); |
| 61 |
;// CONCATENATED MODULE: external ["wp","i18n"] |
| 62 |
var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
| 63 |
;// CONCATENATED MODULE: ./packages/a11y/build-module/add-intro-text.js |
| 64 |
/** |
| 65 |
* WordPress dependencies |
| 66 |
*/ |
| 67 |
|
| 68 |
/** |
| 69 |
* Build the explanatory text to be placed before the aria live regions. |
| 70 |
* |
| 71 |
* This text is initially hidden from assistive technologies by using a `hidden` |
| 72 |
* HTML attribute which is then removed once a message fills the aria-live regions. |
| 73 |
* |
| 74 |
* @return {HTMLParagraphElement} The explanatory text HTML element. |
| 75 |
*/ |
| 76 |
|
| 77 |
function addIntroText() { |
| 78 |
const introText = document.createElement('p'); |
| 79 |
introText.id = 'a11y-speak-intro-text'; |
| 80 |
introText.className = 'a11y-speak-intro-text'; |
| 81 |
introText.textContent = (0,external_wp_i18n_namespaceObject.__)('Notifications'); |
| 82 |
introText.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;'); |
| 83 |
introText.setAttribute('hidden', 'hidden'); |
| 84 |
const { |
| 85 |
body |
| 86 |
} = document; |
| 87 |
|
| 88 |
if (body) { |
| 89 |
body.appendChild(introText); |
| 90 |
} |
| 91 |
|
| 92 |
return introText; |
| 93 |
} |
| 94 |
//# sourceMappingURL=add-intro-text.js.map |
| 95 |
;// CONCATENATED MODULE: ./packages/a11y/build-module/add-container.js |
| 96 |
/** |
| 97 |
* Build the live regions markup. |
| 98 |
* |
| 99 |
* @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'. |
| 100 |
* |
| 101 |
* @return {HTMLDivElement} The ARIA live region HTML element. |
| 102 |
*/ |
| 103 |
function addContainer() { |
| 104 |
let ariaLive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'polite'; |
| 105 |
const container = document.createElement('div'); |
| 106 |
container.id = `a11y-speak-${ariaLive}`; |
| 107 |
container.className = 'a11y-speak-region'; |
| 108 |
container.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;'); |
| 109 |
container.setAttribute('aria-live', ariaLive); |
| 110 |
container.setAttribute('aria-relevant', 'additions text'); |
| 111 |
container.setAttribute('aria-atomic', 'true'); |
| 112 |
const { |
| 113 |
body |
| 114 |
} = document; |
| 115 |
|
| 116 |
if (body) { |
| 117 |
body.appendChild(container); |
| 118 |
} |
| 119 |
|
| 120 |
return container; |
| 121 |
} |
| 122 |
//# sourceMappingURL=add-container.js.map |
| 123 |
;// CONCATENATED MODULE: ./packages/a11y/build-module/clear.js |
| 124 |
/** |
| 125 |
* Clears the a11y-speak-region elements and hides the explanatory text. |
| 126 |
*/ |
| 127 |
function clear() { |
| 128 |
const regions = document.getElementsByClassName('a11y-speak-region'); |
| 129 |
const introText = document.getElementById('a11y-speak-intro-text'); |
| 130 |
|
| 131 |
for (let i = 0; i < regions.length; i++) { |
| 132 |
regions[i].textContent = ''; |
| 133 |
} // Make sure the explanatory text is hidden from assistive technologies. |
| 134 |
|
| 135 |
|
| 136 |
if (introText) { |
| 137 |
introText.setAttribute('hidden', 'hidden'); |
| 138 |
} |
| 139 |
} |
| 140 |
//# sourceMappingURL=clear.js.map |
| 141 |
;// CONCATENATED MODULE: ./packages/a11y/build-module/filter-message.js |
| 142 |
let previousMessage = ''; |
| 143 |
/** |
| 144 |
* Filter the message to be announced to the screenreader. |
| 145 |
* |
| 146 |
* @param {string} message The message to be announced. |
| 147 |
* |
| 148 |
* @return {string} The filtered message. |
| 149 |
*/ |
| 150 |
|
| 151 |
function filterMessage(message) { |
| 152 |
/* |
| 153 |
* Strip HTML tags (if any) from the message string. Ideally, messages should |
| 154 |
* be simple strings, carefully crafted for specific use with A11ySpeak. |
| 155 |
* When re-using already existing strings this will ensure simple HTML to be |
| 156 |
* stripped out and replaced with a space. Browsers will collapse multiple |
| 157 |
* spaces natively. |
| 158 |
*/ |
| 159 |
message = message.replace(/<[^<>]+>/g, ' '); |
| 160 |
/* |
| 161 |
* Safari + VoiceOver don't announce repeated, identical strings. We use |
| 162 |
* a `no-break space` to force them to think identical strings are different. |
| 163 |
*/ |
| 164 |
|
| 165 |
if (previousMessage === message) { |
| 166 |
message += '\u00A0'; |
| 167 |
} |
| 168 |
|
| 169 |
previousMessage = message; |
| 170 |
return message; |
| 171 |
} |
| 172 |
//# sourceMappingURL=filter-message.js.map |
| 173 |
;// CONCATENATED MODULE: ./packages/a11y/build-module/index.js |
| 174 |
/** |
| 175 |
* WordPress dependencies |
| 176 |
*/ |
| 177 |
|
| 178 |
/** |
| 179 |
* Internal dependencies |
| 180 |
*/ |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
/** |
| 187 |
* Create the live regions. |
| 188 |
*/ |
| 189 |
|
| 190 |
function setup() { |
| 191 |
const introText = document.getElementById('a11y-speak-intro-text'); |
| 192 |
const containerAssertive = document.getElementById('a11y-speak-assertive'); |
| 193 |
const containerPolite = document.getElementById('a11y-speak-polite'); |
| 194 |
|
| 195 |
if (introText === null) { |
| 196 |
addIntroText(); |
| 197 |
} |
| 198 |
|
| 199 |
if (containerAssertive === null) { |
| 200 |
addContainer('assertive'); |
| 201 |
} |
| 202 |
|
| 203 |
if (containerPolite === null) { |
| 204 |
addContainer('polite'); |
| 205 |
} |
| 206 |
} |
| 207 |
/** |
| 208 |
* Run setup on domReady. |
| 209 |
*/ |
| 210 |
|
| 211 |
external_wp_domReady_default()(setup); |
| 212 |
/** |
| 213 |
* Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions. |
| 214 |
* This module is inspired by the `speak` function in `wp-a11y.js`. |
| 215 |
* |
| 216 |
* @param {string} message The message to be announced by assistive technologies. |
| 217 |
* @param {string} [ariaLive] The politeness level for aria-live; default: 'polite'. |
| 218 |
* |
| 219 |
* @example |
| 220 |
* ```js |
| 221 |
* import { speak } from '@wordpress/a11y'; |
| 222 |
* |
| 223 |
* // For polite messages that shouldn't interrupt what screen readers are currently announcing. |
| 224 |
* speak( 'The message you want to send to the ARIA live region' ); |
| 225 |
* |
| 226 |
* // For assertive messages that should interrupt what screen readers are currently announcing. |
| 227 |
* speak( 'The message you want to send to the ARIA live region', 'assertive' ); |
| 228 |
* ``` |
| 229 |
*/ |
| 230 |
|
| 231 |
function speak(message, ariaLive) { |
| 232 |
/* |
| 233 |
* Clear previous messages to allow repeated strings being read out and hide |
| 234 |
* the explanatory text from assistive technologies. |
| 235 |
*/ |
| 236 |
clear(); |
| 237 |
message = filterMessage(message); |
| 238 |
const introText = document.getElementById('a11y-speak-intro-text'); |
| 239 |
const containerAssertive = document.getElementById('a11y-speak-assertive'); |
| 240 |
const containerPolite = document.getElementById('a11y-speak-polite'); |
| 241 |
|
| 242 |
if (containerAssertive && ariaLive === 'assertive') { |
| 243 |
containerAssertive.textContent = message; |
| 244 |
} else if (containerPolite) { |
| 245 |
containerPolite.textContent = message; |
| 246 |
} |
| 247 |
/* |
| 248 |
* Make the explanatory text available to assistive technologies by removing |
| 249 |
* the 'hidden' HTML attribute. |
| 250 |
*/ |
| 251 |
|
| 252 |
|
| 253 |
if (introText) { |
| 254 |
introText.removeAttribute('hidden'); |
| 255 |
} |
| 256 |
} |
| 257 |
//# sourceMappingURL=index.js.map |
| 258 |
(window.wp = window.wp || {}).a11y = __webpack_exports__; |
| 259 |
/******/ })() |
| 260 |
; |