[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/js/ -> block-data.js (source)

   1  // modules are defined as an array
   2  // [ module function, map of requires ]
   3  //
   4  // map of requires is short require name -> numeric require
   5  //
   6  // anything defined in a previous bundle is accessed via the
   7  // orig method which is the require for previous bundles
   8  parcelRequire = (function (modules, cache, entry, globalName) {
   9    // Save the require from previous bundle to this closure if any
  10    var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
  11    var nodeRequire = typeof require === 'function' && require;
  12  
  13    function newRequire(name, jumped) {
  14      if (!cache[name]) {
  15        if (!modules[name]) {
  16          // if we cannot find the module within our internal map or
  17          // cache jump to the current global require ie. the last bundle
  18          // that was added to the page.
  19          var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
  20          if (!jumped && currentRequire) {
  21            return currentRequire(name, true);
  22          }
  23  
  24          // If there are other bundles on this page the require from the
  25          // previous one is saved to 'previousRequire'. Repeat this as
  26          // many times as there are bundles until the module is found or
  27          // we exhaust the require chain.
  28          if (previousRequire) {
  29            return previousRequire(name, true);
  30          }
  31  
  32          // Try the node require function if it exists.
  33          if (nodeRequire && typeof name === 'string') {
  34            return nodeRequire(name);
  35          }
  36  
  37          var err = new Error('Cannot find module \'' + name + '\'');
  38          err.code = 'MODULE_NOT_FOUND';
  39          throw err;
  40        }
  41  
  42        localRequire.resolve = resolve;
  43        localRequire.cache = {};
  44  
  45        var module = cache[name] = new newRequire.Module(name);
  46  
  47        modules[name][0].call(module.exports, localRequire, module, module.exports, this);
  48      }
  49  
  50      return cache[name].exports;
  51  
  52      function localRequire(x){
  53        return newRequire(localRequire.resolve(x));
  54      }
  55  
  56      function resolve(x){
  57        return modules[name][1][x] || x;
  58      }
  59    }
  60  
  61    function Module(moduleName) {
  62      this.id = moduleName;
  63      this.bundle = newRequire;
  64      this.exports = {};
  65    }
  66  
  67    newRequire.isParcelRequire = true;
  68    newRequire.Module = Module;
  69    newRequire.modules = modules;
  70    newRequire.cache = cache;
  71    newRequire.parent = previousRequire;
  72    newRequire.register = function (id, exports) {
  73      modules[id] = [function (require, module) {
  74        module.exports = exports;
  75      }, {}];
  76    };
  77  
  78    var error;
  79    for (var i = 0; i < entry.length; i++) {
  80      try {
  81        newRequire(entry[i]);
  82      } catch (e) {
  83        // Save first error but execute all entries
  84        if (!error) {
  85          error = e;
  86        }
  87      }
  88    }
  89  
  90    if (entry.length) {
  91      // Expose entry point to Node, AMD or browser globals
  92      // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
  93      var mainExports = newRequire(entry[entry.length - 1]);
  94  
  95      // CommonJS
  96      if (typeof exports === "object" && typeof module !== "undefined") {
  97        module.exports = mainExports;
  98  
  99      // RequireJS
 100      } else if (typeof define === "function" && define.amd) {
 101       define(function () {
 102         return mainExports;
 103       });
 104  
 105      // <script>
 106      } else if (globalName) {
 107        this[globalName] = mainExports;
 108      }
 109    }
 110  
 111    // Override the current require with this new one
 112    parcelRequire = newRequire;
 113  
 114    if (error) {
 115      // throw error from earlier, _after updating parcelRequire_
 116      throw error;
 117    }
 118  
 119    return newRequire;
 120  })({"Ih1j":[function(require,module,exports) {
 121  "use strict";
 122  
 123  Object.defineProperty(exports, "__esModule", {
 124    value: true
 125  });
 126  exports.STORE_KEY = void 0;
 127  
 128  /**
 129   * Identifier key for BP Core store reducer.
 130   *
 131   * @type {string}
 132   */
 133  const STORE_KEY = 'bp/core';
 134  exports.STORE_KEY = STORE_KEY;
 135  },{}],"DDtj":[function(require,module,exports) {
 136  "use strict";
 137  
 138  Object.defineProperty(exports, "__esModule", {
 139    value: true
 140  });
 141  exports.getActiveComponents = void 0;
 142  
 143  /**
 144   * Returns the list of Active BP Components.
 145   *
 146   * @param {Object} state The current state.
 147   * @return {array} The list of Active BP Components.
 148   */
 149  const getActiveComponents = state => {
 150    return state.components || [];
 151  };
 152  
 153  exports.getActiveComponents = getActiveComponents;
 154  },{}],"gg2v":[function(require,module,exports) {
 155  "use strict";
 156  
 157  Object.defineProperty(exports, "__esModule", {
 158    value: true
 159  });
 160  exports.TYPES = void 0;
 161  
 162  /**
 163   * Action types.
 164   *
 165   * @type {Object}
 166   */
 167  const TYPES = {
 168    GET_ACTIVE_COMPONENTS: 'GET_ACTIVE_COMPONENTS',
 169    FETCH_FROM_API: 'FETCH_FROM_API'
 170  };
 171  exports.TYPES = TYPES;
 172  },{}],"NTbX":[function(require,module,exports) {
 173  "use strict";
 174  
 175  Object.defineProperty(exports, "__esModule", {
 176    value: true
 177  });
 178  exports.getActiveComponents = getActiveComponents;
 179  exports.fetchFromAPI = fetchFromAPI;
 180  
 181  var _actionTypes = require("./action-types");
 182  
 183  /**
 184   * Internal dependencies.
 185   */
 186  
 187  /**
 188   * Returns the list of active components.
 189   *
 190   * @return {Object} Object for action.
 191   */
 192  function getActiveComponents(list) {
 193    return {
 194      type: _actionTypes.TYPES.GET_ACTIVE_COMPONENTS,
 195      list
 196    };
 197  }
 198  /**
 199   * Returns an action object used to fetch something from the API.
 200   *
 201   * @param {string} path Endpoint path.
 202   * @param {boolean} parse Should we parse the request.
 203   * @return {Object} Object for action.
 204   */
 205  
 206  
 207  function fetchFromAPI(path, parse) {
 208    return {
 209      type: _actionTypes.TYPES.FETCH_FROM_API,
 210      path,
 211      parse
 212    };
 213  }
 214  },{"./action-types":"gg2v"}],"SaI5":[function(require,module,exports) {
 215  "use strict";
 216  
 217  Object.defineProperty(exports, "__esModule", {
 218    value: true
 219  });
 220  exports.getActiveComponents = getActiveComponents;
 221  
 222  var _actions = require("./actions");
 223  
 224  /**
 225   * Internal dependencies.
 226   */
 227  
 228  /**
 229   * Resolver for retrieving active BP Components.
 230   */
 231  function* getActiveComponents() {
 232    const list = yield (0, _actions.fetchFromAPI)('/buddypress/v1/components?status=active', true);
 233    yield (0, _actions.getActiveComponents)(list);
 234  }
 235  },{"./actions":"NTbX"}],"yrui":[function(require,module,exports) {
 236  "use strict";
 237  
 238  Object.defineProperty(exports, "__esModule", {
 239    value: true
 240  });
 241  exports.default = void 0;
 242  
 243  var _actionTypes = require("./action-types");
 244  
 245  /**
 246   * Internal dependencies
 247   */
 248  
 249  /**
 250   * Default state.
 251   */
 252  const DEFAULT_STATE = {
 253    components: []
 254  };
 255  /**
 256   * Reducer for the BuddyPress data store.
 257   *
 258   * @param   {Object}  state   The current state in the store.
 259   * @param   {Object}  action  Action object.
 260   *
 261   * @return  {Object}          New or existing state.
 262   */
 263  
 264  const reducer = (state = DEFAULT_STATE, action) => {
 265    switch (action.type) {
 266      case _actionTypes.TYPES.GET_ACTIVE_COMPONENTS:
 267        return { ...state,
 268          components: action.list
 269        };
 270    }
 271  
 272    return state;
 273  };
 274  
 275  var _default = reducer;
 276  exports.default = _default;
 277  },{"./action-types":"gg2v"}],"KdPQ":[function(require,module,exports) {
 278  "use strict";
 279  
 280  Object.defineProperty(exports, "__esModule", {
 281    value: true
 282  });
 283  exports.controls = void 0;
 284  
 285  /**
 286   * WordPress dependencies.
 287   */
 288  const {
 289    apiFetch
 290  } = wp;
 291  /**
 292   * Default export for registering the controls with the store.
 293   *
 294   * @return {Object} An object with the controls to register with the store on
 295   *                  the controls property of the registration object.
 296   */
 297  
 298  const controls = {
 299    FETCH_FROM_API({
 300      path,
 301      parse
 302    }) {
 303      return apiFetch({
 304        path,
 305        parse
 306      });
 307    }
 308  
 309  };
 310  exports.controls = controls;
 311  },{}],"QFc2":[function(require,module,exports) {
 312  "use strict";
 313  
 314  Object.defineProperty(exports, "__esModule", {
 315    value: true
 316  });
 317  exports.default = exports.BP_CORE_STORE_KEY = void 0;
 318  
 319  var _constants = require("./constants");
 320  
 321  var selectors = _interopRequireWildcard(require("./selectors"));
 322  
 323  var actions = _interopRequireWildcard(require("./actions"));
 324  
 325  var resolvers = _interopRequireWildcard(require("./resolvers"));
 326  
 327  var _reducers = _interopRequireDefault(require("./reducers"));
 328  
 329  var _controls = require("./controls");
 330  
 331  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 332  
 333  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
 334  
 335  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
 336  
 337  /**
 338   * WordPress dependencies.
 339   */
 340  const {
 341    data: {
 342      registerStore
 343    }
 344  } = wp;
 345  /**
 346   * Internal dependencies.
 347   */
 348  
 349  registerStore(_constants.STORE_KEY, {
 350    reducer: _reducers.default,
 351    actions,
 352    selectors,
 353    controls: _controls.controls,
 354    resolvers
 355  });
 356  const BP_CORE_STORE_KEY = _constants.STORE_KEY;
 357  exports.BP_CORE_STORE_KEY = BP_CORE_STORE_KEY;
 358  var _default = BP_CORE_STORE_KEY;
 359  exports.default = _default;
 360  },{"./constants":"Ih1j","./selectors":"DDtj","./actions":"NTbX","./resolvers":"SaI5","./reducers":"yrui","./controls":"KdPQ"}],"qcHp":[function(require,module,exports) {
 361  "use strict";
 362  
 363  Object.defineProperty(exports, "__esModule", {
 364    value: true
 365  });
 366  exports.isActive = isActive;
 367  exports.activityTypes = activityTypes;
 368  exports.loggedInUser = loggedInUser;
 369  exports.postAuhor = postAuhor;
 370  exports.currentPostId = currentPostId;
 371  exports.getCurrentWidgetsSidebar = getCurrentWidgetsSidebar;
 372  exports.default = void 0;
 373  
 374  var _register = _interopRequireDefault(require("./register"));
 375  
 376  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 377  
 378  /**
 379   * WordPress dependencies.
 380   */
 381  const {
 382    data: {
 383      useSelect
 384    }
 385  } = wp;
 386  /**
 387   * External dependencies.
 388   */
 389  
 390  const {
 391    find,
 392    get
 393  } = lodash;
 394  /**
 395   * Internal dependencies.
 396   */
 397  
 398  /**
 399   * Checks whether a component or the feature of an active component is enabled.
 400   *
 401   * @since 9.0.0
 402   *
 403   * @param {string} component (required) The component to check.
 404   * @param {string} feature (optional) The feature to check.
 405   * @return {boolean} Whether a component or the feature of an active component is enabled.
 406   */
 407  function isActive(component, feature = '') {
 408    const components = useSelect(select => {
 409      return select(_register.default).getActiveComponents();
 410    }, []);
 411    const activeComponent = find(components, ['name', component]);
 412  
 413    if (!feature) {
 414      return !!activeComponent;
 415    }
 416  
 417    return get(activeComponent, ['features', feature]);
 418  }
 419  
 420  var _default = isActive;
 421  /**
 422   * Checks whether a component or the feature of an active component is enabled.
 423   *
 424   * @since 9.0.0
 425   *
 426   * @return {array} An array of objects keyed by activity types.
 427   */
 428  
 429  exports.default = _default;
 430  
 431  function activityTypes() {
 432    const components = useSelect(select => {
 433      return select(_register.default).getActiveComponents();
 434    }, []);
 435    const activityComponent = find(components, ['name', 'activity']);
 436  
 437    if (!activityComponent) {
 438      return [];
 439    }
 440  
 441    const activityTypes = get(activityComponent, ['features', 'types']);
 442    let activityTypesList = [];
 443    Object.entries(activityTypes).forEach(([type, label]) => {
 444      activityTypesList.push({
 445        label: label,
 446        value: type
 447      });
 448    });
 449    return activityTypesList;
 450  }
 451  /**
 452   * Returns the logged in user object.
 453   *
 454   * @since 9.0.0
 455   *
 456   * @return {Object} The logged in user object.
 457   */
 458  
 459  
 460  function loggedInUser() {
 461    const loggedInUser = useSelect(select => {
 462      const store = select('core');
 463  
 464      if (store) {
 465        return select('core').getCurrentUser();
 466      }
 467  
 468      return {};
 469    }, []);
 470    return loggedInUser;
 471  }
 472  /**
 473   * Returns the post author user object.
 474   *
 475   * @since 9.0.0
 476   *
 477   * @return {Object} The post author user object.
 478   */
 479  
 480  
 481  function postAuhor() {
 482    const postAuhor = useSelect(select => {
 483      const editorStore = select('core/editor');
 484      const coreStore = select('core');
 485  
 486      if (editorStore && coreStore) {
 487        const postAuthorId = editorStore.getCurrentPostAttribute('author');
 488        const authorsList = coreStore.getAuthors();
 489        return find(authorsList, ['id', postAuthorId]);
 490      }
 491  
 492      return {};
 493    }, []);
 494    return postAuhor;
 495  }
 496  /**
 497   * Returns the current post ID.
 498   *
 499   * @since 9.0.0
 500   *
 501   * @return {integer} The current post ID.
 502   */
 503  
 504  
 505  function currentPostId() {
 506    const currentPostId = useSelect(select => {
 507      const store = select('core/editor');
 508  
 509      if (store) {
 510        return store.getCurrentPostId();
 511      }
 512  
 513      return 0;
 514    }, []);
 515    return currentPostId;
 516  }
 517  /**
 518   * Get the current sidebar of a Widget Block.
 519   *
 520   * @since 9.0.0
 521   *
 522   * @param {string} widgetClientId clientId of the sidebar widget.
 523   * @return {object} An object containing the sidebar Id.
 524   */
 525  
 526  
 527  function getCurrentWidgetsSidebar(widgetClientId = '') {
 528    const currentWidgetsSidebar = useSelect(select => {
 529      const blockEditorStore = select('core/block-editor');
 530      const widgetsStore = select('core/edit-widgets');
 531  
 532      if (widgetClientId && widgetsStore && blockEditorStore) {
 533        const areas = blockEditorStore.getBlocks();
 534        const parents = blockEditorStore.getBlockParents(widgetClientId);
 535        let sidebars = [];
 536        areas.forEach(({
 537          clientId,
 538          attributes
 539        }) => {
 540          sidebars.push({
 541            id: attributes.id,
 542            isCurrent: -1 !== parents.indexOf(clientId)
 543          });
 544        });
 545        return find(sidebars, ['isCurrent', true]);
 546      }
 547  
 548      return {};
 549    }, []);
 550    return currentWidgetsSidebar;
 551  }
 552  },{"./register":"QFc2"}],"xHVY":[function(require,module,exports) {
 553  "use strict";
 554  
 555  Object.defineProperty(exports, "__esModule", {
 556    value: true
 557  });
 558  exports.default = void 0;
 559  
 560  var _utils = _interopRequireWildcard(require("./utils"));
 561  
 562  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
 563  
 564  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
 565  
 566  // Data.
 567  var _default = {
 568    isActive: _utils.default,
 569    activityTypes: _utils.activityTypes,
 570    loggedInUser: _utils.loggedInUser,
 571    postAuhor: _utils.postAuhor,
 572    currentPostId: _utils.currentPostId,
 573    getCurrentWidgetsSidebar: _utils.getCurrentWidgetsSidebar
 574  };
 575  exports.default = _default;
 576  },{"./utils":"qcHp"}],"tYf0":[function(require,module,exports) {
 577  "use strict";
 578  
 579  Object.defineProperty(exports, "__esModule", {
 580    value: true
 581  });
 582  Object.defineProperty(exports, "blockData", {
 583    enumerable: true,
 584    get: function () {
 585      return _data.default;
 586    }
 587  });
 588  
 589  var _data = _interopRequireDefault(require("./data"));
 590  
 591  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 592  },{"./data":"xHVY"}]},{},["tYf0"], "bpBlock")


Generated: Mon Jun 27 01:00:52 2022 Cross-referenced by PHPXref 0.7.1