관리-도구
편집 파일: customizable-dashboard.js
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[30],{439:function(e,t,n){"use strict";var r=n(8),c=n(12),o=n(4),a=n.n(o),i=n(0);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}t.a=function(e){var t=e.as,n=void 0===t?"div":t,o=e.className,s=Object(c.a)(e,["as","className"]);return function(e){var t=e.as,n=void 0===t?"div":t,r=Object(c.a)(e,["as"]);return"function"==typeof r.children?r.children(r):Object(i.createElement)(n,r)}(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){Object(r.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({as:n,className:a()("components-visually-hidden",o)},s))}},762:function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return u}));var r=n(0),c=n(55),o=n(214),a=n.n(o),i=n(36),l=a()(i.b),s=function(e){var t=l.getCurrencyConfig(),n=Object(c.applyFilters)("kkart_admin_report_currency",t,e);return a()(n)},u=Object(r.createContext)(l)},767:function(e,t,n){"use strict";var r=n(0),c=n(4),o=n.n(c),a=n(439);function i(e){var t=e.id,n=e.label,c=e.hideLabelFromVision,l=e.help,s=e.className,u=e.children;return Object(r.createElement)("div",{className:o()("components-base-control",s)},Object(r.createElement)("div",{className:"components-base-control__field"},n&&t&&(c?Object(r.createElement)(a.a,{as:"label",htmlFor:t},n):Object(r.createElement)("label",{className:"components-base-control__label",htmlFor:t},n)),n&&!t&&(c?Object(r.createElement)(a.a,{as:"label"},n):Object(r.createElement)(i.VisualLabel,null,n)),u),!!l&&Object(r.createElement)("p",{id:t+"__help",className:"components-base-control__help"},l))}i.VisualLabel=function(e){var t=e.className,n=e.children;return t=o()("components-base-control__label",t),Object(r.createElement)("span",{className:t},n)},t.a=i},770:function(e,t,n){"use strict";var r=n(5),c=n.n(r),o=n(17),a=n.n(o),i=n(15),l=n.n(i),s=n(11),u=n.n(s),d=n(18),b=n.n(d),p=n(19),m=n.n(p),f=n(9),v=n.n(f),O=n(0),h=n(1),y=n.n(h),j=n(2),_=n(20),g=n(77),k=n(36),w=n(35),E=n(40),D=n(64),S=n(762);function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=v()(e);if(t){var c=v()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return m()(this,n)}}var T=function(e){b()(n,e);var t=F(n);function n(){var e;return a()(this,n),(e=t.call(this)).trackDateSelect=e.trackDateSelect.bind(u()(e)),e.trackFilterSelect=e.trackFilterSelect.bind(u()(e)),e.trackAdvancedFilterAction=e.trackAdvancedFilterAction.bind(u()(e)),e}return l()(n,[{key:"trackDateSelect",value:function(e){var t=this.props.report;Object(D.recordEvent)("datepicker_update",C({report:t},Object(j.omitBy)(e,j.isUndefined)))}},{key:"trackFilterSelect",value:function(e){var t=this.props.report;Object(D.recordEvent)("analytics_filter",{report:t,filter:e.filter||"all"})}},{key:"trackAdvancedFilterAction",value:function(e,t){var n=this.props.report;switch(e){case"add":Object(D.recordEvent)("analytics_filters_add",{report:n,filter:t.key});break;case"remove":Object(D.recordEvent)("analytics_filters_remove",{report:n,filter:t.key});break;case"filter":var r=Object.keys(t).reduce((function(e,n){return e[Object(j.snakeCase)(n)]=t[n],e}),{});Object(D.recordEvent)("analytics_filters_filter",C({report:n},r));break;case"clear_all":Object(D.recordEvent)("analytics_filters_clear_all",{report:n});break;case"match":Object(D.recordEvent)("analytics_filters_all_any",{report:n,value:t.match})}}},{key:"render",value:function(){var e=this.props,t=e.advancedFilters,n=e.filters,r=e.path,c=e.query,o=e.showDatePicker,a=e.defaultDateRange,i=Object(E.getDateParamsFromQuery)(c,a),l=i.period,s=i.compare,u=i.before,d=i.after,b=Object(E.getCurrentDates)(c,a),p={period:l,compare:s,before:u,after:d,primaryDate:b.primary,secondaryDate:b.secondary},m=this.context;return Object(O.createElement)(g.ReportFilters,{query:c,siteLocale:k.c.siteLocale,currency:m.getCurrencyConfig(),path:r,filters:n,advancedFilters:t,showDatePicker:o,onDateSelect:this.trackDateSelect,onFilterSelect:this.trackFilterSelect,onAdvancedFilterAction:this.trackAdvancedFilterAction,dateQuery:p,isoDateFormat:E.isoDateFormat})}}]),n}(O.Component);T.contextType=S.a,t.a=Object(_.withSelect)((function(e){return{defaultDateRange:e(w.SETTINGS_STORE_NAME).getSetting("kkart_admin","wcAdminSettings").kkart_default_date_range}}))(T),T.propTypes={advancedFilters:y.a.object,filters:y.a.array,path:y.a.string.isRequired,query:y.a.object,showDatePicker:y.a.bool,report:y.a.string.isRequired}},839:function(e,t,n){"use strict";n.r(t);var r=n(62),c=n.n(r),o=n(5),a=n.n(o),i=n(30),l=n.n(i),s=n(0),u=n(3),d=n(277),b=n(2),p=n(535),m=n(72),f=n(133),v=n(55),O=n(570),h=n(88),y=Object(s.createElement)(h.c,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(s.createElement)(h.b,{d:"M2 12C2 6.44444 6.44444 2 12 2C17.5556 2 22 6.44444 22 12C22 17.5556 17.5556 22 12 22C6.44444 22 2 17.5556 2 12ZM13 11V7H11V11H7V13H11V17H13V13H17V11H13Z"})),j=n(20),_=n(77),g=n(35),k=n(32),w=n(40),E=n(64),D=(n(780),Object(s.lazy)((function(){return Promise.all([n.e(1),n.e(2),n.e(3),n.e(8),n.e(32)]).then(n.bind(null,854))}))),S=Object(s.lazy)((function(){return Promise.all([n.e(3),n.e(4),n.e(37)]).then(n.bind(null,857))})),P=Object(s.lazy)((function(){return n.e(49).then(n.bind(null,846))})),C=Object(v.applyFilters)("kkart_dashboard_default_sections",[{key:"store-performance",component:function(e){return Object(s.createElement)(s.Suspense,{fallback:Object(s.createElement)(_.Spinner,null)},Object(s.createElement)(P,e))},title:Object(u.__)("Performance",'kkart'),isVisible:!0,icon:"arrow-right-alt",hiddenBlocks:["coupons/amount","coupons/orders_count","downloads/download_count","taxes/order_tax","taxes/total_tax","taxes/shipping_tax","revenue/shipping","orders/avg_order_value","revenue/refunds","revenue/gross_sales"]},{key:"charts",component:function(e){return Object(s.createElement)(s.Suspense,{fallback:Object(s.createElement)(_.Spinner,null)},Object(s.createElement)(D,e))},title:Object(u.__)("Charts",'kkart'),isVisible:!0,icon:"chart-bar",hiddenBlocks:["orders_avg_order_value","avg_items_per_order","products_items_sold","revenue_total_sales","revenue_refunds","coupons_amount","coupons_orders_count","revenue_shipping","taxes_total_tax","taxes_order_tax","taxes_shipping_tax","downloads_download_count"]},{key:"leaderboards",component:function(e){return Object(s.createElement)(s.Suspense,{fallback:Object(s.createElement)(_.Spinner,null)},Object(s.createElement)(S,e))},title:Object(u.__)("Leaderboards",'kkart'),isVisible:!0,icon:"editor-ol",hiddenBlocks:["coupons","customers"]}]),F=n(38),T=n.n(F),R=n(17),x=n.n(R),N=n(15),B=n.n(N),M=n(11),V=n.n(M),A=n(18),I=n.n(A),H=n(19),L=n.n(H),U=n(9),q=n.n(U),Q=n(7),z=n(12),G=n(300),J=n(767);function Z(e){var t=e.label,n=e.hideLabelFromVision,r=e.value,c=e.help,o=e.className,a=e.onChange,i=e.type,l=void 0===i?"text":i,u=Object(z.a)(e,["label","hideLabelFromVision","value","help","className","onChange","type"]),d=Object(G.a)(Z),b="inspector-text-control-".concat(d);return Object(s.createElement)(J.a,{label:t,hideLabelFromVision:n,id:b,help:c,className:o},Object(s.createElement)("input",Object(Q.a)({className:"components-text-control__input",type:l,id:b,value:r,onChange:function(e){return a(e.target.value)},"aria-describedby":c?b+"__help":void 0},u)))}function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=q()(e);if(t){var c=q()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return L()(this,n)}}var W=function(e){I()(n,e);var t=K(n);function n(e){var r;return x()(this,n),(r=t.call(this,e)).onMoveUp=r.onMoveUp.bind(V()(r)),r.onMoveDown=r.onMoveDown.bind(V()(r)),r}return B()(n,[{key:"onMoveUp",value:function(){var e=this.props,t=e.onMove,n=e.onToggle;t(-1),n()}},{key:"onMoveDown",value:function(){var e=this.props,t=e.onMove,n=e.onToggle;t(1),n()}},{key:"render",value:function(){var e=this.props,t=e.onRemove,n=e.isFirst,r=e.isLast,c=e.onTitleBlur,o=e.onTitleChange,a=e.titleInput;return Object(s.createElement)(s.Fragment,null,Object(s.createElement)("div",{className:"kkart-ellipsis-menu__item"},Object(s.createElement)(Z,{label:Object(u.__)("Section Title",'kkart'),onBlur:c,onChange:o,required:!0,value:a})),Object(s.createElement)("div",{className:"kkart-dashboard-section-controls"},!n&&Object(s.createElement)(_.MenuItem,{isClickable:!0,onInvoke:this.onMoveUp},Object(s.createElement)(f.a,{icon:"arrow-up-alt2",label:Object(u.__)("Move up")}),Object(u.__)("Move up",'kkart')),!r&&Object(s.createElement)(_.MenuItem,{isClickable:!0,onInvoke:this.onMoveDown},Object(s.createElement)(f.a,{icon:"arrow-down-alt2",label:Object(u.__)("Move Down")}),Object(u.__)("Move Down",'kkart')),Object(s.createElement)(_.MenuItem,{isClickable:!0,onInvoke:t},Object(s.createElement)(f.a,{icon:"trash",label:Object(u.__)("Remove block")}),Object(u.__)("Remove section",'kkart'))))}}]),n}(s.Component);function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=q()(e);if(t){var c=q()(this).constructor;n=Reflect.construct(r,arguments,c)}else n=r.apply(this,arguments);return L()(this,n)}}var Y=function(e){I()(n,e);var t=X(n);function n(e){var r;x()(this,n),r=t.call(this,e);var c=e.title;return r.state={titleInput:c},r.onToggleHiddenBlock=r.onToggleHiddenBlock.bind(V()(r)),r.onTitleChange=r.onTitleChange.bind(V()(r)),r.onTitleBlur=r.onTitleBlur.bind(V()(r)),r}return B()(n,[{key:"onTitleChange",value:function(e){this.setState({titleInput:e})}},{key:"onTitleBlur",value:function(){var e=this.props,t=e.onTitleUpdate,n=e.title,r=this.state.titleInput;""===r?this.setState({titleInput:n}):t&&t(r)}},{key:"onToggleHiddenBlock",value:function(e){var t=this;return function(){var n=Object(b.xor)(t.props.hiddenBlocks,[e]);t.props.onChangeHiddenBlocks(n)}}},{key:"render",value:function(){var e=this.props,t=e.component,n=c()(e,["component"]),r=this.state.titleInput;return Object(s.createElement)("div",{className:"kkart-dashboard-section"},Object(s.createElement)(t,T()({onTitleChange:this.onTitleChange,onTitleBlur:this.onTitleBlur,onToggleHiddenBlock:this.onToggleHiddenBlock,titleInput:r,controls:W},n)))}}]),n}(s.Component),$=n(770),ee=n(762);function te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?te(Object(n),!0).forEach((function(t){a()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var re=Object(v.applyFilters)("kkart_admin_dashboard_filters",[]);t.default=Object(d.a)(Object(j.withSelect)((function(e){return{defaultDateRange:e(g.SETTINGS_STORE_NAME).getSetting("kkart_admin","wcAdminSettings").kkart_default_date_range}})))((function(e){var t,n,r,o,a,i,d,v,h,j=e.defaultDateRange,D=e.path,S=e.query,P=Object(g.useUserPreferences)(),F=P.updateUserPreferences,T=function(e){if(!e||0===e.length)return C;var t=C.map((function(e){return e.key})),n=e.map((function(e){return e.key})),r=new Set([].concat(l()(n),l()(t))),c=[];return r.forEach((function(t){var n=C.find((function(e){return e.key===t}));if(n){var r=e.find((function(e){return e.key===t}));c.push(ne(ne({},n),r))}})),c}(c()(P,["updateUserPreferences"]).dashboard_sections),R=function(e){F({dashboard_sections:e})},x=function(e,t){var n=T.map((function(n){return n.key===e?ne(ne({},n),t):n}));R(n)},N=function(e){return function(t){Object(E.recordEvent)("dash_section_rename",{key:e}),x(e,{title:t})}},B=function(e,t){return function(){t&&t();var n=T.findIndex((function(t){return e===t.key})),r=T.splice(n,1).shift();r.isVisible=!r.isVisible,T.push(r),r.isVisible?Object(E.recordEvent)("dash_section_add",{key:r.key}):Object(E.recordEvent)("dash_section_remove",{key:r.key}),R(T)}},M=function e(t,n){var r=T.splice(t,1).shift(),c=t+n;if(T[n<0?c:c-1].isVisible||0===t||t===T.length-1){T.splice(c,0,r),R(T);var o={key:r.key,direction:n>0?"down":"up"};Object(E.recordEvent)("dash_section_order_change",o)}else e(t,n+n)};return Object(s.createElement)(ee.a.Provider,{value:Object(ee.b)(Object(k.getQuery)())},(n=Object(w.getDateParamsFromQuery)(S,j),r=n.period,o=n.compare,a=n.before,i=n.after,d=Object(w.getCurrentDates)(S,j),v={period:r,compare:o,before:a,after:i,primaryDate:d.primary,secondaryDate:d.secondary},h=T.filter((function(e){return e.isVisible})).map((function(e){return e.key})),Object(s.createElement)(s.Fragment,null,Object(s.createElement)($.a,{report:"dashboard",query:S,path:D,dateQuery:v,isoDateFormat:w.isoDateFormat,filters:re}),T.map((function(e,t){return e.isVisible?Object(s.createElement)(Y,{component:e.component,hiddenBlocks:e.hiddenBlocks,key:e.key,onChangeHiddenBlocks:(n=e.key,function(e){x(n,{hiddenBlocks:e})}),onTitleUpdate:N(e.key),path:D,query:S,title:e.title,onMove:Object(b.partial)(M,t),onRemove:B(e.key),isFirst:e.key===h[0],isLast:e.key===h[h.length-1],filters:re}):null;var n})),0===(t=T.filter((function(e){return!1===e.isVisible}))).length?null:Object(s.createElement)(p.a,{position:"top center",className:"kkart-dashboard-section__add-more",renderToggle:function(e){var t=e.onToggle,n=e.isOpen;return Object(s.createElement)(m.a,{onClick:t,title:Object(u.__)("Add more sections",'kkart'),"aria-expanded":n},Object(s.createElement)(O.a,{icon:y}))},renderContent:function(e){var n=e.onToggle;return Object(s.createElement)(s.Fragment,null,Object(s.createElement)(_.H,null,Object(u.__)("Dashboard Sections",'kkart')),Object(s.createElement)("div",{className:"kkart-dashboard-section__add-more-choices"},t.map((function(e){return Object(s.createElement)(m.a,{key:e.key,onClick:B(e.key,n),className:"kkart-dashboard-section__add-more-btn",title:Object(u.sprintf)(Object(u.__)("Add %s section",'kkart'),e.title)},Object(s.createElement)(f.a,{icon:e.icon,size:30}),Object(s.createElement)("span",{className:"kkart-dashboard-section__add-more-btn-title"},e.title))}))))}}))))}))}}]);