File: /www/wwwroot/www.waciwang.com/wp-content/plugins/gutenberg/build/scripts/notices/index.min.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_C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AUH,CAAM",
"names": ["require_data", "__commonJSMin", "exports", "module", "import_data", "onSubKey", "actionProperty", "reducer", "state", "action", "key", "nextKeyState", "on_sub_key_default", "notices", "on_sub_key_default", "state", "action", "id", "type", "reducer_default", "DEFAULT_CONTEXT", "DEFAULT_STATUS", "uniqueId", "createNotice", "status", "DEFAULT_STATUS", "content", "options", "speak", "isDismissible", "context", "DEFAULT_CONTEXT", "id", "actions", "type", "__unstableHTML", "icon", "explicitDismiss", "onDismiss", "createSuccessNotice", "createInfoNotice", "createErrorNotice", "createWarningNotice", "removeNotice", "removeAllNotices", "noticeType", "removeNotices", "ids", "DEFAULT_NOTICES", "getNotices", "state", "context", "DEFAULT_CONTEXT", "store", "reducer_default", "actions_exports", "selectors_exports"]
}