1 line
5.5 KiB
JavaScript
1 line
5.5 KiB
JavaScript
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[3],{141:function(e,t,n){"use strict";n.d(t,"b",(function(){return w})),n.d(t,"a",(function(){return y}));var c=n(5),r=n.n(c),o=n(8),i=n.n(o),s=n(0),u=(n(2),n(14)),a=n(68),f=n(63),d=n(9),l=n.n(d),b=n(6),v=n.n(b),O=n(890),p=(n(207),function(e){var t=e.status;switch(void 0===t?"default":t){case"error":return"woocommerce-error";case"success":return"woocommerce-message";case"info":case"warning":return"woocommerce-info"}return""}),j=function(e){var t=e.className,n=e.notices,c=e.removeNotice,r=n.filter((function(e){return"snackbar"!==e.type}));if(!r.length)return null;var o=v()(t,"wc-block-components-notices");return Object(s.createElement)("div",{className:o},r.map((function(e){return Object(s.createElement)(O.a,l()({key:"store-notice-"+e.id},e,{className:v()("wc-block-components-notices__notice",p(e)),onRemove:function(){e.isDismissible&&c(e.id)}}),e.content)})))};function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,c)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach((function(t){r()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var h=Object(s.createContext)({notices:[],createNotice:function(e,t,n){},removeNotice:function(e,t){},setIsSuppressed:function(e){},context:"wc/core"}),w=function(){return Object(s.useContext)(h)},y=function(e){var t=e.children,n=e.className,c=void 0===n?"":n,r=e.createNoticeContainer,o=void 0===r||r,d=e.context,l=void 0===d?"wc/core":d,b=Object(u.useDispatch)("core/notices"),v=b.createNotice,O=b.removeNotice,p=Object(s.useState)(!1),m=i()(p,2),w=m[0],y=m[1],N=Object(a.a)().dispatchStoreEvent,E=Object(f.b)().isEditor,P=Object(s.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};v(e,t,g(g({},n),{},{context:n.context||l})),N("store-notice-create",{status:e,content:t,options:n})}),[v,N,l]),S=Object(s.useCallback)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;O(e,t)}),[O,l]),D={notices:Object(u.useSelect)((function(e){return{notices:e("core/notices").getNotices(l)}}),[l]).notices,createNotice:P,removeNotice:S,context:l,setIsSuppressed:y},k=w?null:Object(s.createElement)(j,{className:c,notices:D.notices,removeNotice:D.removeNotice,isEditor:E});return Object(s.createElement)(h.Provider,{value:D},o&&k,t)}},207:function(e,t){},59:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var c=n(5),r=n.n(c),o=n(0),i=n(141);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,c)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){r()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var a=function(){var e=Object(i.b)(),t=e.notices,n=e.createNotice,c=e.removeNotice,r=e.setIsSuppressed,s=Object(o.useRef)(t);Object(o.useEffect)((function(){s.current=t}),[t]);var a=Object(o.useMemo)((function(){return{hasNoticesOfType:function(e){return s.current.some((function(t){return t.type===e}))},removeNotices:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;s.current.forEach((function(t){null!==e&&t.status!==e||c(t.id)}))},removeNotice:c}}),[c]),f=Object(o.useMemo)((function(){return{addDefaultNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("default",e,u({},t))},addErrorNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("error",e,u({},t))},addWarningNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("warning",e,u({},t))},addInfoNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("info",e,u({},t))},addSuccessNotice:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n("success",e,u({},t))}}}),[n]);return u(u(u({notices:t},a),f),{},{setIsSuppressed:r})}},788:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var c=n(8),r=n.n(c),o=n(0),i=n(14),s=n(24),u=n(25),a=n(43),f=n(59),d=function(e,t){var n=e.find((function(e){return e.id===t}));return n?n.quantity:0},l=function(e){var t=Object(i.useDispatch)(s.CART_STORE_KEY).addItemToCart,n=Object(a.a)(),c=n.cartItems,l=n.cartIsLoading,b=Object(f.a)(),v=b.addErrorNotice,O=b.removeNotice,p=Object(o.useState)(!1),j=r()(p,2),m=j[0],g=j[1],h=Object(o.useRef)(d(c,e));return Object(o.useEffect)((function(){var t=d(c,e);t!==h.current&&(h.current=t)}),[c,e]),{cartQuantity:Number.isFinite(h.current)?h.current:0,addingToCart:m,cartIsLoading:l,addToCart:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return g(!0),t(e,n).then((function(){O("add-to-cart")})).catch((function(e){v(Object(u.decodeEntities)(e.message),{context:"wc/all-products",id:"add-to-cart",isDismissible:!0})})).finally((function(){g(!1)}))}}}}}]); |