[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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


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