File: /www/wwwroot/www.waciwang.com/wp-content/plugins/gutenberg/build/scripts/notices/index.js.map
{
"version": 3,
"sources": ["package-external:@wordpress/data", "../../../packages/notices/src/store/index.ts", "../../../packages/notices/src/store/utils/on-sub-key.ts", "../../../packages/notices/src/store/reducer.ts", "../../../packages/notices/src/store/constants.ts", "../../../packages/notices/src/store/actions.ts", "../../../packages/notices/src/store/selectors.ts"],
"sourcesContent": ["module.exports = window.wp.data;", "/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\n/**\n * Store definition for the notices namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( 'core/notices', {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n", "/**\n * External dependencies\n */\nimport type { Reducer, Action } from 'redux';\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param actionProperty Action property by which to key object.\n *\n * @return Higher-order reducer.\n */\nexport const onSubKey =\n\t( actionProperty: string ) =>\n\t< S, A extends Action & Record< string, any > >(\n\t\treducer: Reducer< S, A >\n\t) =>\n\t( state: Record< string, S > = {}, action: A ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\nexport default onSubKey;\n", "/**\n * Internal dependencies\n */\nimport type { Notice, ReducerAction } from './types';\nimport onSubKey from './utils/on-sub-key';\n\n/**\n * Reducer returning the next notices state. The notices state is an object\n * where each key is a context, its value an array of notice objects.\n *\n * @param state Current state.\n * @param action Dispatched action.\n *\n * @return Updated state.\n */\nconst notices = onSubKey( 'context' )< Array< Notice >, ReducerAction >( (\n\tstate = [],\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'CREATE_NOTICE':\n\t\t\t// Avoid duplicates on ID.\n\t\t\treturn [\n\t\t\t\t...state.filter( ( { id } ) => id !== action.notice.id ),\n\t\t\t\taction.notice,\n\t\t\t];\n\n\t\tcase 'REMOVE_NOTICE':\n\t\t\treturn state.filter( ( { id } ) => id !== action.id );\n\n\t\tcase 'REMOVE_NOTICES':\n\t\t\treturn state.filter( ( { id } ) => ! action.ids.includes( id ) );\n\n\t\tcase 'REMOVE_ALL_NOTICES':\n\t\t\treturn state.filter( ( { type } ) => type !== action.noticeType );\n\n\t\tdefault:\n\t\t\treturn state;\n\t}\n} );\n\nexport default notices;\n", "/**\n * Internal dependencies\n */\nimport type { Notice } from './types';\n\n/**\n * Default context to use for notice grouping when not otherwise specified. Its\n * specific value doesn't hold much meaning, but it must be reasonably unique\n * and, more importantly, referenced consistently in the store implementation.\n */\nexport const DEFAULT_CONTEXT = 'global';\n\n/**\n * Default notice status.\n */\nexport const DEFAULT_STATUS: Notice[ 'status' ] = 'info';\n", "/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT, DEFAULT_STATUS } from './constants';\nimport type { NoticeOptions, ReducerAction } from './types';\n\nlet uniqueId = 0;\n\n/**\n * Returns an action object used in signalling that a notice is to be created.\n *\n * @param status Notice status (\"info\" if undefined is passed).\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }\n * >\n * { __( 'Generate a success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createNotice(\n\tstatus = DEFAULT_STATUS,\n\tcontent: string,\n\toptions: NoticeOptions = {}\n): Extract< ReducerAction, { type: 'CREATE_NOTICE' } > {\n\tconst {\n\t\tspeak = true,\n\t\tisDismissible = true,\n\t\tcontext = DEFAULT_CONTEXT,\n\t\tid = `${ context }${ ++uniqueId }`,\n\t\tactions = [],\n\t\ttype = 'default',\n\t\t__unstableHTML,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\tonDismiss,\n\t} = options;\n\n\t// The supported value shape of content is currently limited to plain text\n\t// strings. To avoid setting expectation that e.g. a React Element could be\n\t// supported, cast to a string.\n\tcontent = String( content );\n\n\treturn {\n\t\ttype: 'CREATE_NOTICE',\n\t\tcontext,\n\t\tnotice: {\n\t\t\tid,\n\t\t\tstatus,\n\t\t\tcontent,\n\t\t\tspokenMessage: speak ? content : null,\n\t\t\t__unstableHTML,\n\t\t\tisDismissible,\n\t\t\tactions,\n\t\t\ttype,\n\t\t\ticon,\n\t\t\texplicitDismiss,\n\t\t\tonDismiss,\n\t\t},\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a success notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createSuccessNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createSuccessNotice( __( 'Success!' ), {\n * type: 'snackbar',\n * icon: '\uD83D\uDD25',\n * } )\n * }\n * >\n * { __( 'Generate a snackbar success notice!' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createSuccessNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\n\treturn createNotice( 'success', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an info notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createInfoNotice( __( 'Something happened!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice that cannot be dismissed.' ) }\n * </Button>\n * );\n * };\n *```\n *\n * @return Action object.\n */\nexport function createInfoNotice( content: string, options?: NoticeOptions ) {\n\treturn createNotice( 'info', content, options );\n}\n\n/**\n * Returns an action object used in signalling that an error notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createErrorNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createErrorNotice( __( 'An error occurred!' ), {\n * type: 'snackbar',\n * explicitDismiss: true,\n * } )\n * }\n * >\n * { __(\n * 'Generate a snackbar error notice with explicit dismiss button.'\n * ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createErrorNotice( content: string, options?: NoticeOptions ) {\n\treturn createNotice( 'error', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a warning notice is to be\n * created. Refer to `createNotice` for options documentation.\n *\n * @see createNotice\n *\n * @param content Notice message.\n * @param options Optional notice options.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );\n * return (\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * onDismiss: () => {\n * createInfoNotice(\n * __( 'The warning has been dismissed!' )\n * );\n * },\n * } )\n * }\n * >\n * { __( 'Generates a warning notice with onDismiss callback' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return Action object.\n */\nexport function createWarningNotice(\n\tcontent: string,\n\toptions?: NoticeOptions\n) {\n\treturn createNotice( 'warning', content, options );\n}\n\n/**\n * Returns an action object used in signalling that a notice is to be removed.\n *\n * @param id Notice unique identifier.\n * @param context Optional context (grouping) in which the notice is\n * intended to appear. Defaults to 'default' context.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * const { createWarningNotice, removeNotice } = useDispatch( noticesStore );\n *\n * return (\n * <>\n * <Button\n * onClick={ () =>\n * createWarningNotice( __( 'Warning!' ), {\n * isDismissible: false,\n * } )\n * }\n * >\n * { __( 'Generate a notice' ) }\n * </Button>\n * { notices.length > 0 && (\n * <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>\n * { __( 'Remove the notice' ) }\n * </Button>\n * ) }\n * </>\n * );\n *};\n * ```\n *\n * @return Action object.\n */\nexport function removeNotice(\n\tid: string,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICE' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICE',\n\t\tid,\n\t\tcontext,\n\t};\n}\n\n/**\n * Removes all notices from a given context. Defaults to the default context.\n *\n * @param noticeType The context to remove all notices from.\n * @param context The optional context to remove all notices from.\n *\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * export const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeAllNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices()\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveAllNotices( 'snackbar' )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n *\n * @return \t Action object.\n */\nexport function removeAllNotices(\n\tnoticeType = 'default',\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_ALL_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_ALL_NOTICES',\n\t\tnoticeType,\n\t\tcontext,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that several notices are to be removed.\n *\n * @param ids List of unique notice identifiers.\n * @param context Optional context (grouping) in which the notices are\n * intended to appear. Defaults to 'default' context.\n * @example\n * ```js\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch, useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * \tconst notices = useSelect( ( select ) =>\n * \t\tselect( noticesStore ).getNotices()\n * \t);\n * \tconst { removeNotices } = useDispatch( noticesStore );\n * \treturn (\n * \t\t<>\n * \t\t\t<ul>\n * \t\t\t\t{ notices.map( ( notice ) => (\n * \t\t\t\t\t<li key={ notice.id }>{ notice.content }</li>\n * \t\t\t\t) ) }\n * \t\t\t</ul>\n * \t\t\t<Button\n * \t\t\t\tonClick={ () =>\n * \t\t\t\t\tremoveNotices( notices.map( ( { id } ) => id ) )\n * \t\t\t\t}\n * \t\t\t>\n * \t\t\t\t{ __( 'Clear all notices' ) }\n * \t\t\t</Button>\n * \t\t</>\n * \t);\n * };\n * ```\n * @return Action object.\n */\nexport function removeNotices(\n\tids: Array< string >,\n\tcontext: string = DEFAULT_CONTEXT\n): Extract< ReducerAction, { type: 'REMOVE_NOTICES' } > {\n\treturn {\n\t\ttype: 'REMOVE_NOTICES',\n\t\tids,\n\t\tcontext,\n\t};\n}\n", "/**\n * Internal dependencies\n */\nimport { DEFAULT_CONTEXT } from './constants';\nimport type { Notice } from './types';\n\n/**\n * The default empty set of notices to return when there are no notices\n * assigned for a given notices context. This can occur if the getNotices\n * selector is called without a notice ever having been created for the\n * context. A shared value is used to ensure referential equality between\n * sequential selector calls, since otherwise `[] !== []`.\n *\n */\nconst DEFAULT_NOTICES: Array< Notice > = [];\n\n/**\n * Returns all notices as an array, optionally for a given context. Defaults to\n * the global context.\n *\n * @param state Notices state.\n * @param context Optional grouping context.\n *\n * @example\n *\n *```js\n * import { useSelect } from '@wordpress/data';\n * import { store as noticesStore } from '@wordpress/notices';\n *\n * const ExampleComponent = () => {\n * const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );\n * return (\n * <ul>\n * { notices.map( ( notice ) => (\n * <li key={ notice.ID }>{ notice.content }</li>\n * ) ) }\n * </ul>\n * )\n * };\n *```\n *\n * @return Array of notices.\n */\nexport function getNotices(\n\tstate: Record< string, Array< Notice > >,\n\tcontext: string = DEFAULT_CONT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