[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> nux.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/compat get default export */
   8  /******/     (() => {
   9  /******/         // getDefaultExport function for compatibility with non-harmony modules
  10  /******/         __webpack_require__.n = (module) => {
  11  /******/             var getter = module && module.__esModule ?
  12  /******/                 () => (module['default']) :
  13  /******/                 () => (module);
  14  /******/             __webpack_require__.d(getter, { a: getter });
  15  /******/             return getter;
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/define property getters */
  20  /******/     (() => {
  21  /******/         // define getter functions for harmony exports
  22  /******/         __webpack_require__.d = (exports, definition) => {
  23  /******/             for(var key in definition) {
  24  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26  /******/                 }
  27  /******/             }
  28  /******/         };
  29  /******/     })();
  30  /******/     
  31  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  32  /******/     (() => {
  33  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  34  /******/     })();
  35  /******/     
  36  /******/     /* webpack/runtime/make namespace object */
  37  /******/     (() => {
  38  /******/         // define __esModule on exports
  39  /******/         __webpack_require__.r = (exports) => {
  40  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42  /******/             }
  43  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  44  /******/         };
  45  /******/     })();
  46  /******/     
  47  /************************************************************************/
  48  var __webpack_exports__ = {};
  49  // ESM COMPAT FLAG
  50  __webpack_require__.r(__webpack_exports__);
  51  
  52  // EXPORTS
  53  __webpack_require__.d(__webpack_exports__, {
  54    DotTip: () => (/* reexport */ dot_tip),
  55    store: () => (/* reexport */ store)
  56  });
  57  
  58  // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/actions.js
  59  var actions_namespaceObject = {};
  60  __webpack_require__.r(actions_namespaceObject);
  61  __webpack_require__.d(actions_namespaceObject, {
  62    disableTips: () => (disableTips),
  63    dismissTip: () => (dismissTip),
  64    enableTips: () => (enableTips),
  65    triggerGuide: () => (triggerGuide)
  66  });
  67  
  68  // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/selectors.js
  69  var selectors_namespaceObject = {};
  70  __webpack_require__.r(selectors_namespaceObject);
  71  __webpack_require__.d(selectors_namespaceObject, {
  72    areTipsEnabled: () => (selectors_areTipsEnabled),
  73    getAssociatedGuide: () => (getAssociatedGuide),
  74    isTipVisible: () => (isTipVisible)
  75  });
  76  
  77  ;// external ["wp","deprecated"]
  78  const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  79  var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  80  ;// external ["wp","data"]
  81  const external_wp_data_namespaceObject = window["wp"]["data"];
  82  ;// ./node_modules/@wordpress/nux/build-module/store/reducer.js
  83  /**
  84   * WordPress dependencies
  85   */
  86  
  87  
  88  /**
  89   * Reducer that tracks which tips are in a guide. Each guide is represented by
  90   * an array which contains the tip identifiers contained within that guide.
  91   *
  92   * @param {Array}  state  Current state.
  93   * @param {Object} action Dispatched action.
  94   *
  95   * @return {Array} Updated state.
  96   */
  97  function guides(state = [], action) {
  98    switch (action.type) {
  99      case 'TRIGGER_GUIDE':
 100        return [...state, action.tipIds];
 101    }
 102    return state;
 103  }
 104  
 105  /**
 106   * Reducer that tracks whether or not tips are globally enabled.
 107   *
 108   * @param {boolean} state  Current state.
 109   * @param {Object}  action Dispatched action.
 110   *
 111   * @return {boolean} Updated state.
 112   */
 113  function areTipsEnabled(state = true, action) {
 114    switch (action.type) {
 115      case 'DISABLE_TIPS':
 116        return false;
 117      case 'ENABLE_TIPS':
 118        return true;
 119    }
 120    return state;
 121  }
 122  
 123  /**
 124   * Reducer that tracks which tips have been dismissed. If the state object
 125   * contains a tip identifier, then that tip is dismissed.
 126   *
 127   * @param {Object} state  Current state.
 128   * @param {Object} action Dispatched action.
 129   *
 130   * @return {Object} Updated state.
 131   */
 132  function dismissedTips(state = {}, action) {
 133    switch (action.type) {
 134      case 'DISMISS_TIP':
 135        return {
 136          ...state,
 137          [action.id]: true
 138        };
 139      case 'ENABLE_TIPS':
 140        return {};
 141    }
 142    return state;
 143  }
 144  const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
 145    areTipsEnabled,
 146    dismissedTips
 147  });
 148  /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
 149    guides,
 150    preferences
 151  }));
 152  
 153  ;// ./node_modules/@wordpress/nux/build-module/store/actions.js
 154  /**
 155   * Returns an action object that, when dispatched, presents a guide that takes
 156   * the user through a series of tips step by step.
 157   *
 158   * @param {string[]} tipIds Which tips to show in the guide.
 159   *
 160   * @return {Object} Action object.
 161   */
 162  function triggerGuide(tipIds) {
 163    return {
 164      type: 'TRIGGER_GUIDE',
 165      tipIds
 166    };
 167  }
 168  
 169  /**
 170   * Returns an action object that, when dispatched, dismisses the given tip. A
 171   * dismissed tip will not show again.
 172   *
 173   * @param {string} id The tip to dismiss.
 174   *
 175   * @return {Object} Action object.
 176   */
 177  function dismissTip(id) {
 178    return {
 179      type: 'DISMISS_TIP',
 180      id
 181    };
 182  }
 183  
 184  /**
 185   * Returns an action object that, when dispatched, prevents all tips from
 186   * showing again.
 187   *
 188   * @return {Object} Action object.
 189   */
 190  function disableTips() {
 191    return {
 192      type: 'DISABLE_TIPS'
 193    };
 194  }
 195  
 196  /**
 197   * Returns an action object that, when dispatched, makes all tips show again.
 198   *
 199   * @return {Object} Action object.
 200   */
 201  function enableTips() {
 202    return {
 203      type: 'ENABLE_TIPS'
 204    };
 205  }
 206  
 207  ;// ./node_modules/@wordpress/nux/build-module/store/selectors.js
 208  /**
 209   * WordPress dependencies
 210   */
 211  
 212  
 213  /**
 214   * An object containing information about a guide.
 215   *
 216   * @typedef {Object} NUXGuideInfo
 217   * @property {string[]} tipIds       Which tips the guide contains.
 218   * @property {?string}  currentTipId The guide's currently showing tip.
 219   * @property {?string}  nextTipId    The guide's next tip to show.
 220   */
 221  
 222  /**
 223   * Returns an object describing the guide, if any, that the given tip is a part
 224   * of.
 225   *
 226   * @param {Object} state Global application state.
 227   * @param {string} tipId The tip to query.
 228   *
 229   * @return {?NUXGuideInfo} Information about the associated guide.
 230   */
 231  const getAssociatedGuide = (0,external_wp_data_namespaceObject.createSelector)((state, tipId) => {
 232    for (const tipIds of state.guides) {
 233      if (tipIds.includes(tipId)) {
 234        const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
 235        const [currentTipId = null, nextTipId = null] = nonDismissedTips;
 236        return {
 237          tipIds,
 238          currentTipId,
 239          nextTipId
 240        };
 241      }
 242    }
 243    return null;
 244  }, state => [state.guides, state.preferences.dismissedTips]);
 245  
 246  /**
 247   * Determines whether or not the given tip is showing. Tips are hidden if they
 248   * are disabled, have been dismissed, or are not the current tip in any
 249   * guide that they have been added to.
 250   *
 251   * @param {Object} state Global application state.
 252   * @param {string} tipId The tip to query.
 253   *
 254   * @return {boolean} Whether or not the given tip is showing.
 255   */
 256  function isTipVisible(state, tipId) {
 257    if (!state.preferences.areTipsEnabled) {
 258      return false;
 259    }
 260    if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) {
 261      return false;
 262    }
 263    const associatedGuide = getAssociatedGuide(state, tipId);
 264    if (associatedGuide && associatedGuide.currentTipId !== tipId) {
 265      return false;
 266    }
 267    return true;
 268  }
 269  
 270  /**
 271   * Returns whether or not tips are globally enabled.
 272   *
 273   * @param {Object} state Global application state.
 274   *
 275   * @return {boolean} Whether tips are globally enabled.
 276   */
 277  function selectors_areTipsEnabled(state) {
 278    return state.preferences.areTipsEnabled;
 279  }
 280  
 281  ;// ./node_modules/@wordpress/nux/build-module/store/index.js
 282  /**
 283   * WordPress dependencies
 284   */
 285  
 286  
 287  /**
 288   * Internal dependencies
 289   */
 290  
 291  
 292  
 293  const STORE_NAME = 'core/nux';
 294  
 295  /**
 296   * Store definition for the nux namespace.
 297   *
 298   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 299   *
 300   * @type {Object}
 301   */
 302  const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
 303    reducer: reducer,
 304    actions: actions_namespaceObject,
 305    selectors: selectors_namespaceObject,
 306    persist: ['preferences']
 307  });
 308  
 309  // Once we build a more generic persistence plugin that works across types of stores
 310  // we'd be able to replace this with a register call.
 311  (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, {
 312    reducer: reducer,
 313    actions: actions_namespaceObject,
 314    selectors: selectors_namespaceObject,
 315    persist: ['preferences']
 316  });
 317  
 318  ;// external ["wp","compose"]
 319  const external_wp_compose_namespaceObject = window["wp"]["compose"];
 320  ;// external ["wp","components"]
 321  const external_wp_components_namespaceObject = window["wp"]["components"];
 322  ;// external ["wp","i18n"]
 323  const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
 324  ;// external ["wp","element"]
 325  const external_wp_element_namespaceObject = window["wp"]["element"];
 326  ;// external ["wp","primitives"]
 327  const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
 328  ;// external "ReactJSXRuntime"
 329  const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
 330  ;// ./node_modules/@wordpress/icons/build-module/library/close.js
 331  /**
 332   * WordPress dependencies
 333   */
 334  
 335  
 336  const close_close = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
 337    xmlns: "http://www.w3.org/2000/svg",
 338    viewBox: "0 0 24 24",
 339    children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
 340      d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"
 341    })
 342  });
 343  /* harmony default export */ const library_close = (close_close);
 344  
 345  ;// ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js
 346  /**
 347   * WordPress dependencies
 348   */
 349  
 350  
 351  
 352  
 353  
 354  
 355  
 356  /**
 357   * Internal dependencies
 358   */
 359  
 360  
 361  
 362  function onClick(event) {
 363    // Tips are often nested within buttons. We stop propagation so that clicking
 364    // on a tip doesn't result in the button being clicked.
 365    event.stopPropagation();
 366  }
 367  function DotTip({
 368    position = 'middle right',
 369    children,
 370    isVisible,
 371    hasNextTip,
 372    onDismiss,
 373    onDisable
 374  }) {
 375    const anchorParent = (0,external_wp_element_namespaceObject.useRef)(null);
 376    const onFocusOutsideCallback = (0,external_wp_element_namespaceObject.useCallback)(event => {
 377      if (!anchorParent.current) {
 378        return;
 379      }
 380      if (anchorParent.current.contains(event.relatedTarget)) {
 381        return;
 382      }
 383      onDisable();
 384    }, [onDisable, anchorParent]);
 385    if (!isVisible) {
 386      return null;
 387    }
 388    return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Popover, {
 389      className: "nux-dot-tip",
 390      position: position,
 391      focusOnMount: true,
 392      role: "dialog",
 393      "aria-label": (0,external_wp_i18n_namespaceObject.__)('Editor tips'),
 394      onClick: onClick,
 395      onFocusOutside: onFocusOutsideCallback,
 396      children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
 397        children: children
 398      }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
 399        children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
 400          __next40pxDefaultSize: true,
 401          variant: "link",
 402          onClick: onDismiss,
 403          children: hasNextTip ? (0,external_wp_i18n_namespaceObject.__)('See next tip') : (0,external_wp_i18n_namespaceObject.__)('Got it')
 404        })
 405      }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
 406        size: "small",
 407        className: "nux-dot-tip__disable",
 408        icon: library_close,
 409        label: (0,external_wp_i18n_namespaceObject.__)('Disable tips'),
 410        onClick: onDisable
 411      })]
 412    });
 413  }
 414  /* harmony default export */ const dot_tip = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
 415    tipId
 416  }) => {
 417    const {
 418      isTipVisible,
 419      getAssociatedGuide
 420    } = select(store);
 421    const associatedGuide = getAssociatedGuide(tipId);
 422    return {
 423      isVisible: isTipVisible(tipId),
 424      hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
 425    };
 426  }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
 427    tipId
 428  }) => {
 429    const {
 430      dismissTip,
 431      disableTips
 432    } = dispatch(store);
 433    return {
 434      onDismiss() {
 435        dismissTip(tipId);
 436      },
 437      onDisable() {
 438        disableTips();
 439      }
 440    };
 441  }))(DotTip));
 442  
 443  ;// ./node_modules/@wordpress/nux/build-module/index.js
 444  /**
 445   * WordPress dependencies
 446   */
 447  
 448  
 449  
 450  external_wp_deprecated_default()('wp.nux', {
 451    since: '5.4',
 452    hint: 'wp.components.Guide can be used to show a user guide.',
 453    version: '6.2'
 454  });
 455  
 456  (window.wp = window.wp || {}).nux = __webpack_exports__;
 457  /******/ })()
 458  ;


Generated : Sun Dec 22 08:20:01 2024 Cross-referenced by PHPXref