JezK
Edit File: mutations-7458343f.js.map
{"file":"mutations-7458343f.js","mappings":";;;AAGA,MAAM,KAAK,GAAG,WAAW,CACvB;IACE,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,EAAE;QACR,WAAW,EAAE,EAAE;KAChB;IACD,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,KAAK;CACnB,EACD,CAAC,QAAQ,EAAE,QAAQ;IACjB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC,CACF,CAAC;MAEI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG;;ACrBtD;;;AAYA;;;AAGA;;;AAIA;;;;;;;;;;;;;;;;;yBAkBqB,UAAE;;;;;;;;;;;;AAgBvB;AAEA;;;;;;;;AAQA;AAYA;;;;;;;;AAQA;AAYA;;;;;;;;;;;;;AAaA;;;;","names":[],"sources":["src/store/notices/store.ts","src/store/notices/mutations.ts"],"sourcesContent":["import { createStore } from '@stencil/store';\nimport { ScNoticeStore } from '../../types';\n\nconst store = createStore<ScNoticeStore>(\n {\n type: 'default',\n code: '',\n message: '',\n data: {\n status: 0,\n type: '',\n http_status: '',\n },\n additional_errors: [],\n dismissible: false,\n },\n (newValue, oldValue) => {\n return JSON.stringify(newValue) !== JSON.stringify(oldValue);\n },\n);\n\nconst { state, onChange, on, dispose, forceUpdate } = store;\nexport default state;\nexport { state, onChange, on, dispose, forceUpdate };\n","/**\n * External dependencies.\n */\nimport { __ } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies.\n */\nimport state from './store';\nimport { NoticeType, ScNoticeStore } from '../../types';\n\n/**\n * Default notice options.\n */\nconst defaultOptions = {\n dismissible: false,\n};\n\n/**\n * Create a notice.\n *\n * @param {NoticeType} status\n * @param {ScNoticeStore} notice\n */\nexport const createNotice = (status: NoticeType, notice: ScNoticeStore, options = defaultOptions) => {\n // if notice is a string, then it is message, else the notice object.\n if (typeof notice === 'string') {\n notice = {\n type: status,\n message: notice,\n code: '',\n };\n }\n\n // If no notice message, then set the default message.\n if (!notice?.message) {\n notice.message = __('Something went wrong. Please try again.', 'surecart');\n }\n\n // Set the notice type.\n state.type = status;\n\n // Merge options and notice.\n notice = { ...options, ...notice };\n\n // speak the error notice.\n speak(notice.message, 'assertive');\n\n // Set notice properties to the state.\n Object.keys(notice).forEach(key => {\n state[key] = notice[key];\n });\n};\n\n/**\n * Create an error notice.\n *\n * @param {ScNoticeStore} notice\n * @param {object} options\n */\nexport const createErrorNotice = (notice, options = defaultOptions) => {\n createNotice('error', notice, options);\n};\n\n/**\n * Create a success notice.\n *\n * @param {ScNoticeStore} notice\n * @param {object} options\n */\nexport const createSuccessNotice = (notice, options = defaultOptions) => {\n createNotice('success', notice, options);\n};\n\n/**\n * Create an info notice.\n *\n * @param {ScNoticeStore} notice\n * @param {object} options\n */\nexport const createInfoNotice = (notice, options = defaultOptions) => {\n createNotice('info', notice, options);\n};\n\n/**\n * Create a warning notice.\n *\n * @param {ScNoticeStore} notice\n * @param {object} options\n */\nexport const createWarningNotice = (notice, options = defaultOptions) => {\n createNotice('warning', notice, options);\n};\n\n/**\n * Remove the notice.\n */\nexport const removeNotice = () => {\n state.type = 'default';\n state.code = '';\n state.message = '';\n state.data = {\n status: 0,\n type: '',\n http_status: '',\n };\n state.additional_errors = [];\n};\n"],"version":3}