[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-members/js/blocks/ -> dynamic-members.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  })({"gOka":[function(require,module,exports) {
 121  "use strict";
 122  
 123  Object.defineProperty(exports, "__esModule", {
 124    value: true
 125  });
 126  exports.TYPES = void 0;
 127  
 128  /**
 129   * WordPress dependencies.
 130   */
 131  const {
 132    i18n: {
 133      __
 134    }
 135  } = wp;
 136  /**
 137   * Members ordering types.
 138   *
 139   * @type {Array}
 140   */
 141  
 142  const TYPES = [{
 143    label: __('Newest', 'buddypress'),
 144    value: 'newest'
 145  }, {
 146    label: __('Active', 'buddypress'),
 147    value: 'active'
 148  }, {
 149    label: __('Popular', 'buddypress'),
 150    value: 'popular'
 151  }];
 152  exports.TYPES = TYPES;
 153  },{}],"z0p7":[function(require,module,exports) {
 154  "use strict";
 155  
 156  Object.defineProperty(exports, "__esModule", {
 157    value: true
 158  });
 159  exports.default = void 0;
 160  
 161  var _constants = require("./constants");
 162  
 163  /**
 164   * WordPress dependencies.
 165   */
 166  const {
 167    blockEditor: {
 168      InspectorControls
 169    },
 170    components: {
 171      Disabled,
 172      PanelBody,
 173      RangeControl,
 174      SelectControl,
 175      TextControl,
 176      ToggleControl
 177    },
 178    element: {
 179      Fragment,
 180      createElement
 181    },
 182    i18n: {
 183      __
 184    },
 185    serverSideRender: ServerSideRender
 186  } = wp;
 187  /**
 188   * BuddyPress dependencies.
 189   */
 190  
 191  const {
 192    blockData: {
 193      isActive
 194    }
 195  } = bp;
 196  /**
 197   * Internal dependencies.
 198   */
 199  
 200  const editDynamicMembersBlock = ({
 201    attributes,
 202    setAttributes
 203  }) => {
 204    const {
 205      title,
 206      maxMembers,
 207      memberDefault,
 208      linkTitle
 209    } = attributes;
 210    const sortTypes = !!isActive('friends') ? _constants.TYPES : _constants.TYPES.filter(type => 'popular' !== type.value);
 211    return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
 212      title: __('Settings', 'buddypress'),
 213      initialOpen: true
 214    }, createElement(TextControl, {
 215      label: __('Title', 'buddypress'),
 216      value: title,
 217      onChange: text => {
 218        setAttributes({
 219          title: text
 220        });
 221      }
 222    }), createElement(RangeControl, {
 223      label: __('Max members to show', 'buddypress'),
 224      value: maxMembers,
 225      onChange: value => setAttributes({
 226        maxMembers: value
 227      }),
 228      min: 1,
 229      max: 10,
 230      required: true
 231    }), createElement(SelectControl, {
 232      label: __('Default members to show', 'buddypress'),
 233      value: memberDefault,
 234      options: sortTypes,
 235      onChange: option => {
 236        setAttributes({
 237          memberDefault: option
 238        });
 239      }
 240    }), createElement(ToggleControl, {
 241      label: __('Link block title to Members directory', 'buddypress'),
 242      checked: !!linkTitle,
 243      onChange: () => {
 244        setAttributes({
 245          linkTitle: !linkTitle
 246        });
 247      }
 248    }))), createElement(Disabled, null, createElement(ServerSideRender, {
 249      block: "bp/dynamic-members",
 250      attributes: attributes
 251    })));
 252  };
 253  
 254  var _default = editDynamicMembersBlock;
 255  exports.default = _default;
 256  },{"./constants":"gOka"}],"qfGr":[function(require,module,exports) {
 257  "use strict";
 258  
 259  Object.defineProperty(exports, "__esModule", {
 260    value: true
 261  });
 262  exports.default = void 0;
 263  
 264  /**
 265   * WordPress dependencies.
 266   */
 267  const {
 268    blocks: {
 269      createBlock
 270    }
 271  } = wp;
 272  /**
 273   * Transforms Legacy Widget to Dynamic Members Block.
 274   *
 275   * @type {Object}
 276   */
 277  
 278  const transforms = {
 279    from: [{
 280      type: 'block',
 281      blocks: ['core/legacy-widget'],
 282      isMatch: ({
 283        idBase,
 284        instance
 285      }) => {
 286        if (!(instance !== null && instance !== void 0 && instance.raw)) {
 287          return false;
 288        }
 289  
 290        return idBase === 'bp_core_members_widget';
 291      },
 292      transform: ({
 293        instance
 294      }) => {
 295        return createBlock('bp/dynamic-members', {
 296          title: instance.raw.title,
 297          maxMembers: instance.raw.max_members,
 298          memberDefault: instance.raw.member_default,
 299          linkTitle: instance.raw.link_title
 300        });
 301      }
 302    }]
 303  };
 304  var _default = transforms;
 305  exports.default = _default;
 306  },{}],"Znbi":[function(require,module,exports) {
 307  "use strict";
 308  
 309  var _edit = _interopRequireDefault(require("./dynamic-members/edit"));
 310  
 311  var _transforms = _interopRequireDefault(require("./dynamic-members/transforms"));
 312  
 313  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 314  
 315  /**
 316   * WordPress dependencies.
 317   */
 318  const {
 319    blocks: {
 320      registerBlockType
 321    },
 322    i18n: {
 323      __
 324    }
 325  } = wp;
 326  /**
 327   * Internal dependencies.
 328   */
 329  
 330  registerBlockType('bp/dynamic-members', {
 331    title: __('Dynamic Members List', 'buddypress'),
 332    description: __('A dynamic list of recently active, popular, and newest members.', 'buddypress'),
 333    icon: {
 334      background: '#fff',
 335      foreground: '#d84800',
 336      src: 'groups'
 337    },
 338    category: 'buddypress',
 339    attributes: {
 340      title: {
 341        type: 'string',
 342        default: __('Members', 'buddypress')
 343      },
 344      maxMembers: {
 345        type: 'number',
 346        default: 5
 347      },
 348      memberDefault: {
 349        type: 'string',
 350        default: 'active'
 351      },
 352      linkTitle: {
 353        type: 'boolean',
 354        default: false
 355      }
 356    },
 357    edit: _edit.default,
 358    transforms: _transforms.default
 359  });
 360  },{"./dynamic-members/edit":"z0p7","./dynamic-members/transforms":"qfGr"}]},{},["Znbi"], null)


Generated: Wed Jan 19 01:01:00 2022 Cross-referenced by PHPXref 0.7.1