[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ (() => { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = (exports, definition) => { 11 /******/ for(var key in definition) { 12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14 /******/ } 15 /******/ } 16 /******/ }; 17 /******/ })(); 18 /******/ 19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 20 /******/ (() => { 21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22 /******/ })(); 23 /******/ 24 /******/ /* webpack/runtime/make namespace object */ 25 /******/ (() => { 26 /******/ // define __esModule on exports 27 /******/ __webpack_require__.r = (exports) => { 28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30 /******/ } 31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 32 /******/ }; 33 /******/ })(); 34 /******/ 35 /************************************************************************/ 36 var __webpack_exports__ = {}; 37 // ESM COMPAT FLAG 38 __webpack_require__.r(__webpack_exports__); 39 40 // EXPORTS 41 __webpack_require__.d(__webpack_exports__, { 42 store: () => (/* reexport */ store) 43 }); 44 45 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/actions.js 46 var actions_namespaceObject = {}; 47 __webpack_require__.r(actions_namespaceObject); 48 __webpack_require__.d(actions_namespaceObject, { 49 createErrorNotice: () => (createErrorNotice), 50 createInfoNotice: () => (createInfoNotice), 51 createNotice: () => (createNotice), 52 createSuccessNotice: () => (createSuccessNotice), 53 createWarningNotice: () => (createWarningNotice), 54 removeAllNotices: () => (removeAllNotices), 55 removeNotice: () => (removeNotice), 56 removeNotices: () => (removeNotices) 57 }); 58 59 // NAMESPACE OBJECT: ./node_modules/@wordpress/notices/build-module/store/selectors.js 60 var selectors_namespaceObject = {}; 61 __webpack_require__.r(selectors_namespaceObject); 62 __webpack_require__.d(selectors_namespaceObject, { 63 getNotices: () => (getNotices) 64 }); 65 66 ;// external ["wp","data"] 67 const external_wp_data_namespaceObject = window["wp"]["data"]; 68 ;// ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js 69 /** 70 * Higher-order reducer creator which creates a combined reducer object, keyed 71 * by a property on the action object. 72 * 73 * @param {string} actionProperty Action property by which to key object. 74 * 75 * @return {Function} Higher-order reducer. 76 */ 77 const onSubKey = actionProperty => reducer => (state = {}, action) => { 78 // Retrieve subkey from action. Do not track if undefined; useful for cases 79 // where reducer is scoped by action shape. 80 const key = action[actionProperty]; 81 if (key === undefined) { 82 return state; 83 } 84 85 // Avoid updating state if unchanged. Note that this also accounts for a 86 // reducer which returns undefined on a key which is not yet tracked. 87 const nextKeyState = reducer(state[key], action); 88 if (nextKeyState === state[key]) { 89 return state; 90 } 91 return { 92 ...state, 93 [key]: nextKeyState 94 }; 95 }; 96 /* harmony default export */ const on_sub_key = (onSubKey); 97 98 ;// ./node_modules/@wordpress/notices/build-module/store/reducer.js 99 /* wp:polyfill */ 100 /** 101 * Internal dependencies 102 */ 103 104 105 /** 106 * Reducer returning the next notices state. The notices state is an object 107 * where each key is a context, its value an array of notice objects. 108 * 109 * @param {Object} state Current state. 110 * @param {Object} action Dispatched action. 111 * 112 * @return {Object} Updated state. 113 */ 114 const notices = on_sub_key('context')((state = [], action) => { 115 switch (action.type) { 116 case 'CREATE_NOTICE': 117 // Avoid duplicates on ID. 118 return [...state.filter(({ 119 id 120 }) => id !== action.notice.id), action.notice]; 121 case 'REMOVE_NOTICE': 122 return state.filter(({ 123 id 124 }) => id !== action.id); 125 case 'REMOVE_NOTICES': 126 return state.filter(({ 127 id 128 }) => !action.ids.includes(id)); 129 case 'REMOVE_ALL_NOTICES': 130 return state.filter(({ 131 type 132 }) => type !== action.noticeType); 133 } 134 return state; 135 }); 136 /* harmony default export */ const reducer = (notices); 137 138 ;// ./node_modules/@wordpress/notices/build-module/store/constants.js 139 /** 140 * Default context to use for notice grouping when not otherwise specified. Its 141 * specific value doesn't hold much meaning, but it must be reasonably unique 142 * and, more importantly, referenced consistently in the store implementation. 143 * 144 * @type {string} 145 */ 146 const DEFAULT_CONTEXT = 'global'; 147 148 /** 149 * Default notice status. 150 * 151 * @type {string} 152 */ 153 const DEFAULT_STATUS = 'info'; 154 155 ;// ./node_modules/@wordpress/notices/build-module/store/actions.js 156 /** 157 * Internal dependencies 158 */ 159 160 161 /** 162 * @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice. 163 * 164 * @property {string} label Message to use as action label. 165 * @property {?string} url Optional URL of resource if action incurs 166 * browser navigation. 167 * @property {?Function} onClick Optional function to invoke when action is 168 * triggered by user. 169 */ 170 171 let uniqueId = 0; 172 173 /** 174 * Returns an action object used in signalling that a notice is to be created. 175 * 176 * @param {string|undefined} status Notice status ("info" if undefined is passed). 177 * @param {string} content Notice message. 178 * @param {Object} [options] Notice options. 179 * @param {string} [options.context='global'] Context under which to 180 * group notice. 181 * @param {string} [options.id] Identifier for notice. 182 * Automatically assigned 183 * if not specified. 184 * @param {boolean} [options.isDismissible=true] Whether the notice can 185 * be dismissed by user. 186 * @param {string} [options.type='default'] Type of notice, one of 187 * `default`, or `snackbar`. 188 * @param {boolean} [options.speak=true] Whether the notice 189 * content should be 190 * announced to screen 191 * readers. 192 * @param {Array<WPNoticeAction>} [options.actions] User actions to be 193 * presented with notice. 194 * @param {string} [options.icon] An icon displayed with the notice. 195 * Only used when type is set to `snackbar`. 196 * @param {boolean} [options.explicitDismiss] Whether the notice includes 197 * an explicit dismiss button and 198 * can't be dismissed by clicking 199 * the body of the notice. Only applies 200 * when type is set to `snackbar`. 201 * @param {Function} [options.onDismiss] Called when the notice is dismissed. 202 * 203 * @example 204 * ```js 205 * import { __ } from '@wordpress/i18n'; 206 * import { useDispatch } from '@wordpress/data'; 207 * import { store as noticesStore } from '@wordpress/notices'; 208 * import { Button } from '@wordpress/components'; 209 * 210 * const ExampleComponent = () => { 211 * const { createNotice } = useDispatch( noticesStore ); 212 * return ( 213 * <Button 214 * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) } 215 * > 216 * { __( 'Generate a success notice!' ) } 217 * </Button> 218 * ); 219 * }; 220 * ``` 221 * 222 * @return {Object} Action object. 223 */ 224 function createNotice(status = DEFAULT_STATUS, content, options = {}) { 225 const { 226 speak = true, 227 isDismissible = true, 228 context = DEFAULT_CONTEXT, 229 id = `$context}${++uniqueId}`, 230 actions = [], 231 type = 'default', 232 __unstableHTML, 233 icon = null, 234 explicitDismiss = false, 235 onDismiss 236 } = options; 237 238 // The supported value shape of content is currently limited to plain text 239 // strings. To avoid setting expectation that e.g. a React Element could be 240 // supported, cast to a string. 241 content = String(content); 242 return { 243 type: 'CREATE_NOTICE', 244 context, 245 notice: { 246 id, 247 status, 248 content, 249 spokenMessage: speak ? content : null, 250 __unstableHTML, 251 isDismissible, 252 actions, 253 type, 254 icon, 255 explicitDismiss, 256 onDismiss 257 } 258 }; 259 } 260 261 /** 262 * Returns an action object used in signalling that a success notice is to be 263 * created. Refer to `createNotice` for options documentation. 264 * 265 * @see createNotice 266 * 267 * @param {string} content Notice message. 268 * @param {Object} [options] Optional notice options. 269 * 270 * @example 271 * ```js 272 * import { __ } from '@wordpress/i18n'; 273 * import { useDispatch } from '@wordpress/data'; 274 * import { store as noticesStore } from '@wordpress/notices'; 275 * import { Button } from '@wordpress/components'; 276 * 277 * const ExampleComponent = () => { 278 * const { createSuccessNotice } = useDispatch( noticesStore ); 279 * return ( 280 * <Button 281 * onClick={ () => 282 * createSuccessNotice( __( 'Success!' ), { 283 * type: 'snackbar', 284 * icon: '🔥', 285 * } ) 286 * } 287 * > 288 * { __( 'Generate a snackbar success notice!' ) } 289 * </Button> 290 * ); 291 * }; 292 * ``` 293 * 294 * @return {Object} Action object. 295 */ 296 function createSuccessNotice(content, options) { 297 return createNotice('success', content, options); 298 } 299 300 /** 301 * Returns an action object used in signalling that an info notice is to be 302 * created. Refer to `createNotice` for options documentation. 303 * 304 * @see createNotice 305 * 306 * @param {string} content Notice message. 307 * @param {Object} [options] Optional notice options. 308 * 309 * @example 310 * ```js 311 * import { __ } from '@wordpress/i18n'; 312 * import { useDispatch } from '@wordpress/data'; 313 * import { store as noticesStore } from '@wordpress/notices'; 314 * import { Button } from '@wordpress/components'; 315 * 316 * const ExampleComponent = () => { 317 * const { createInfoNotice } = useDispatch( noticesStore ); 318 * return ( 319 * <Button 320 * onClick={ () => 321 * createInfoNotice( __( 'Something happened!' ), { 322 * isDismissible: false, 323 * } ) 324 * } 325 * > 326 * { __( 'Generate a notice that cannot be dismissed.' ) } 327 * </Button> 328 * ); 329 * }; 330 *``` 331 * 332 * @return {Object} Action object. 333 */ 334 function createInfoNotice(content, options) { 335 return createNotice('info', content, options); 336 } 337 338 /** 339 * Returns an action object used in signalling that an error notice is to be 340 * created. Refer to `createNotice` for options documentation. 341 * 342 * @see createNotice 343 * 344 * @param {string} content Notice message. 345 * @param {Object} [options] Optional notice options. 346 * 347 * @example 348 * ```js 349 * import { __ } from '@wordpress/i18n'; 350 * import { useDispatch } from '@wordpress/data'; 351 * import { store as noticesStore } from '@wordpress/notices'; 352 * import { Button } from '@wordpress/components'; 353 * 354 * const ExampleComponent = () => { 355 * const { createErrorNotice } = useDispatch( noticesStore ); 356 * return ( 357 * <Button 358 * onClick={ () => 359 * createErrorNotice( __( 'An error occurred!' ), { 360 * type: 'snackbar', 361 * explicitDismiss: true, 362 * } ) 363 * } 364 * > 365 * { __( 366 * 'Generate an snackbar error notice with explicit dismiss button.' 367 * ) } 368 * </Button> 369 * ); 370 * }; 371 * ``` 372 * 373 * @return {Object} Action object. 374 */ 375 function createErrorNotice(content, options) { 376 return createNotice('error', content, options); 377 } 378 379 /** 380 * Returns an action object used in signalling that a warning notice is to be 381 * created. Refer to `createNotice` for options documentation. 382 * 383 * @see createNotice 384 * 385 * @param {string} content Notice message. 386 * @param {Object} [options] Optional notice options. 387 * 388 * @example 389 * ```js 390 * import { __ } from '@wordpress/i18n'; 391 * import { useDispatch } from '@wordpress/data'; 392 * import { store as noticesStore } from '@wordpress/notices'; 393 * import { Button } from '@wordpress/components'; 394 * 395 * const ExampleComponent = () => { 396 * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore ); 397 * return ( 398 * <Button 399 * onClick={ () => 400 * createWarningNotice( __( 'Warning!' ), { 401 * onDismiss: () => { 402 * createInfoNotice( 403 * __( 'The warning has been dismissed!' ) 404 * ); 405 * }, 406 * } ) 407 * } 408 * > 409 * { __( 'Generates a warning notice with onDismiss callback' ) } 410 * </Button> 411 * ); 412 * }; 413 * ``` 414 * 415 * @return {Object} Action object. 416 */ 417 function createWarningNotice(content, options) { 418 return createNotice('warning', content, options); 419 } 420 421 /** 422 * Returns an action object used in signalling that a notice is to be removed. 423 * 424 * @param {string} id Notice unique identifier. 425 * @param {string} [context='global'] Optional context (grouping) in which the notice is 426 * intended to appear. Defaults to default context. 427 * 428 * @example 429 * ```js 430 * import { __ } from '@wordpress/i18n'; 431 * import { useDispatch } from '@wordpress/data'; 432 * import { store as noticesStore } from '@wordpress/notices'; 433 * import { Button } from '@wordpress/components'; 434 * 435 * const ExampleComponent = () => { 436 * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() ); 437 * const { createWarningNotice, removeNotice } = useDispatch( noticesStore ); 438 * 439 * return ( 440 * <> 441 * <Button 442 * onClick={ () => 443 * createWarningNotice( __( 'Warning!' ), { 444 * isDismissible: false, 445 * } ) 446 * } 447 * > 448 * { __( 'Generate a notice' ) } 449 * </Button> 450 * { notices.length > 0 && ( 451 * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }> 452 * { __( 'Remove the notice' ) } 453 * </Button> 454 * ) } 455 * </> 456 * ); 457 *}; 458 * ``` 459 * 460 * @return {Object} Action object. 461 */ 462 function removeNotice(id, context = DEFAULT_CONTEXT) { 463 return { 464 type: 'REMOVE_NOTICE', 465 id, 466 context 467 }; 468 } 469 470 /** 471 * Removes all notices from a given context. Defaults to the default context. 472 * 473 * @param {string} noticeType The context to remove all notices from. 474 * @param {string} context The context to remove all notices from. 475 * 476 * @example 477 * ```js 478 * import { __ } from '@wordpress/i18n'; 479 * import { useDispatch, useSelect } from '@wordpress/data'; 480 * import { store as noticesStore } from '@wordpress/notices'; 481 * import { Button } from '@wordpress/components'; 482 * 483 * export const ExampleComponent = () => { 484 * const notices = useSelect( ( select ) => 485 * select( noticesStore ).getNotices() 486 * ); 487 * const { removeAllNotices } = useDispatch( noticesStore ); 488 * return ( 489 * <> 490 * <ul> 491 * { notices.map( ( notice ) => ( 492 * <li key={ notice.id }>{ notice.content }</li> 493 * ) ) } 494 * </ul> 495 * <Button 496 * onClick={ () => 497 * removeAllNotices() 498 * } 499 * > 500 * { __( 'Clear all notices', 'woo-gutenberg-products-block' ) } 501 * </Button> 502 * <Button 503 * onClick={ () => 504 * removeAllNotices( 'snackbar' ) 505 * } 506 * > 507 * { __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) } 508 * </Button> 509 * </> 510 * ); 511 * }; 512 * ``` 513 * 514 * @return {Object} Action object. 515 */ 516 function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) { 517 return { 518 type: 'REMOVE_ALL_NOTICES', 519 noticeType, 520 context 521 }; 522 } 523 524 /** 525 * Returns an action object used in signalling that several notices are to be removed. 526 * 527 * @param {string[]} ids List of unique notice identifiers. 528 * @param {string} [context='global'] Optional context (grouping) in which the notices are 529 * intended to appear. Defaults to default context. 530 * @example 531 * ```js 532 * import { __ } from '@wordpress/i18n'; 533 * import { useDispatch, useSelect } from '@wordpress/data'; 534 * import { store as noticesStore } from '@wordpress/notices'; 535 * import { Button } from '@wordpress/components'; 536 * 537 * const ExampleComponent = () => { 538 * const notices = useSelect( ( select ) => 539 * select( noticesStore ).getNotices() 540 * ); 541 * const { removeNotices } = useDispatch( noticesStore ); 542 * return ( 543 * <> 544 * <ul> 545 * { notices.map( ( notice ) => ( 546 * <li key={ notice.id }>{ notice.content }</li> 547 * ) ) } 548 * </ul> 549 * <Button 550 * onClick={ () => 551 * removeNotices( notices.map( ( { id } ) => id ) ) 552 * } 553 * > 554 * { __( 'Clear all notices' ) } 555 * </Button> 556 * </> 557 * ); 558 * }; 559 * ``` 560 * @return {Object} Action object. 561 */ 562 function removeNotices(ids, context = DEFAULT_CONTEXT) { 563 return { 564 type: 'REMOVE_NOTICES', 565 ids, 566 context 567 }; 568 } 569 570 ;// ./node_modules/@wordpress/notices/build-module/store/selectors.js 571 /** 572 * Internal dependencies 573 */ 574 575 576 /** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */ 577 578 /** 579 * The default empty set of notices to return when there are no notices 580 * assigned for a given notices context. This can occur if the getNotices 581 * selector is called without a notice ever having been created for the 582 * context. A shared value is used to ensure referential equality between 583 * sequential selector calls, since otherwise `[] !== []`. 584 * 585 * @type {Array} 586 */ 587 const DEFAULT_NOTICES = []; 588 589 /** 590 * @typedef {Object} WPNotice Notice object. 591 * 592 * @property {string} id Unique identifier of notice. 593 * @property {string} status Status of notice, one of `success`, 594 * `info`, `error`, or `warning`. Defaults 595 * to `info`. 596 * @property {string} content Notice message. 597 * @property {string} spokenMessage Audibly announced message text used by 598 * assistive technologies. 599 * @property {string} __unstableHTML Notice message as raw HTML. Intended to 600 * serve primarily for compatibility of 601 * server-rendered notices, and SHOULD NOT 602 * be used for notices. It is subject to 603 * removal without notice. 604 * @property {boolean} isDismissible Whether the notice can be dismissed by 605 * user. Defaults to `true`. 606 * @property {string} type Type of notice, one of `default`, 607 * or `snackbar`. Defaults to `default`. 608 * @property {boolean} speak Whether the notice content should be 609 * announced to screen readers. Defaults to 610 * `true`. 611 * @property {WPNoticeAction[]} actions User actions to present with notice. 612 */ 613 614 /** 615 * Returns all notices as an array, optionally for a given context. Defaults to 616 * the global context. 617 * 618 * @param {Object} state Notices state. 619 * @param {?string} context Optional grouping context. 620 * 621 * @example 622 * 623 *```js 624 * import { useSelect } from '@wordpress/data'; 625 * import { store as noticesStore } from '@wordpress/notices'; 626 * 627 * const ExampleComponent = () => { 628 * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() ); 629 * return ( 630 * <ul> 631 * { notices.map( ( notice ) => ( 632 * <li key={ notice.ID }>{ notice.content }</li> 633 * ) ) } 634 * </ul> 635 * ) 636 * }; 637 *``` 638 * 639 * @return {WPNotice[]} Array of notices. 640 */ 641 function getNotices(state, context = DEFAULT_CONTEXT) { 642 return state[context] || DEFAULT_NOTICES; 643 } 644 645 ;// ./node_modules/@wordpress/notices/build-module/store/index.js 646 /** 647 * WordPress dependencies 648 */ 649 650 651 /** 652 * Internal dependencies 653 */ 654 655 656 657 658 /** 659 * Store definition for the notices namespace. 660 * 661 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 662 */ 663 const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', { 664 reducer: reducer, 665 actions: actions_namespaceObject, 666 selectors: selectors_namespaceObject 667 }); 668 (0,external_wp_data_namespaceObject.register)(store); 669 670 ;// ./node_modules/@wordpress/notices/build-module/index.js 671 672 673 (window.wp = window.wp || {}).notices = __webpack_exports__; 674 /******/ })() 675 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Feb 22 08:20:01 2025 | Cross-referenced by PHPXref |