WordPress/wp-includes/js/dist/nux.min.js

2 lines
3.4 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{DotTip:()=>v,store:()=>b});var n={};e.r(n),e.d(n,{disableTips:()=>a,dismissTip:()=>u,enableTips:()=>l,triggerGuide:()=>p});var i={};e.r(i),e.d(i,{areTipsEnabled:()=>T,getAssociatedGuide:()=>w,isTipVisible:()=>f});const r=window.wp.deprecated;var s=e.n(r);const o=window.wp.data;const c=(0,o.combineReducers)({areTipsEnabled:function(e=!0,t){switch(t.type){case"DISABLE_TIPS":return!1;case"ENABLE_TIPS":return!0}return e},dismissedTips:function(e={},t){switch(t.type){case"DISMISS_TIP":return{...e,[t.id]:!0};case"ENABLE_TIPS":return{}}return e}}),d=(0,o.combineReducers)({guides:function(e=[],t){return"TRIGGER_GUIDE"===t.type?[...e,t.tipIds]:e},preferences:c});function p(e){return{type:"TRIGGER_GUIDE",tipIds:e}}function u(e){return{type:"DISMISS_TIP",id:e}}function a(){return{type:"DISABLE_TIPS"}}function l(){return{type:"ENABLE_TIPS"}}const w=(0,o.createSelector)(((e,t)=>{for(const n of e.guides)if(n.includes(t)){const t=n.filter((t=>!Object.keys(e.preferences.dismissedTips).includes(t))),[i=null,r=null]=t;return{tipIds:n,currentTipId:i,nextTipId:r}}return null}),(e=>[e.guides,e.preferences.dismissedTips]));function f(e,t){if(!e.preferences.areTipsEnabled)return!1;if(e.preferences.dismissedTips?.hasOwnProperty(t))return!1;const n=w(e,t);return!n||n.currentTipId===t}function T(e){return e.preferences.areTipsEnabled}const m="core/nux",b=(0,o.createReduxStore)(m,{reducer:d,actions:n,selectors:i,persist:["preferences"]});(0,o.registerStore)(m,{reducer:d,actions:n,selectors:i,persist:["preferences"]});const I=window.React,E=window.wp.compose,S=window.wp.components,_=window.wp.i18n,g=window.wp.element,y=window.wp.primitives,h=(0,I.createElement)(y.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,I.createElement)(y.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));function P(e){e.stopPropagation()}const v=(0,E.compose)((0,o.withSelect)(((e,{tipId:t})=>{const{isTipVisible:n,getAssociatedGuide:i}=e(b),r=i(t);return{isVisible:n(t),hasNextTip:!(!r||!r.nextTipId)}})),(0,o.withDispatch)(((e,{tipId:t})=>{const{dismissTip:n,disableTips:i}=e(b);return{onDismiss(){n(t)},onDisable(){i()}}})))((function({position:e="middle right",children:t,isVisible:n,hasNextTip:i,onDismiss:r,onDisable:s}){const o=(0,g.useRef)(null),c=(0,g.useCallback)((e=>{o.current&&(o.current.contains(e.relatedTarget)||s())}),[s,o]);return n?(0,I.createElement)(S.Popover,{className:"nux-dot-tip",position:e,focusOnMount:!0,role:"dialog","aria-label":(0,_.__)("Editor tips"),onClick:P,onFocusOutside:c},(0,I.createElement)("p",null,t),(0,I.createElement)("p",null,(0,I.createElement)(S.Button,{variant:"link",onClick:r},i?(0,_.__)("See next tip"):(0,_.__)("Got it"))),(0,I.createElement)(S.Button,{className:"nux-dot-tip__disable",icon:h,label:(0,_.__)("Disable tips"),onClick:s})):null}));s()("wp.nux",{since:"5.4",hint:"wp.components.Guide can be used to show a user guide.",version:"6.2"}),(window.wp=window.wp||{}).nux=t})();