Ticket #8571: 8571.4.patch
File 8571.4.patch, 196.5 KB (added by , 3 years ago) |
---|
-
src/bp-activity/classes/class-bp-activity-component.php
diff --git src/bp-activity/classes/class-bp-activity-component.php src/bp-activity/classes/class-bp-activity-component.php index 38c80cf5d..5b702b34e 100644
class BP_Activity_Component extends BP_Component { 499 499 'wp-components', 500 500 'wp-i18n', 501 501 'wp-block-editor', 502 'wp-server-side-render', 502 503 'bp-block-data', 503 'bp-block-components',504 504 ), 505 505 'style' => 'bp-latest-activities-block', 506 506 'style_url' => plugins_url( 'css/blocks/latest-activities.css', dirname( __FILE__ ) ), -
src/bp-activity/js/blocks/embed-activity.js
diff --git src/bp-activity/js/blocks/embed-activity.js src/bp-activity/js/blocks/embed-activity.js index fc3a737c8..cc62d03b8 100644
parcelRequire = (function (modules, cache, entry, globalName) { 117 117 } 118 118 119 119 return newRequire; 120 })({"DCTP":[function(require,module,exports) { 121 function _arrayWithHoles(arr) { 122 if (Array.isArray(arr)) return arr; 123 } 124 125 module.exports = _arrayWithHoles; 126 },{}],"LoeL":[function(require,module,exports) { 127 function _iterableToArrayLimit(arr, i) { 128 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 129 var _arr = []; 130 var _n = true; 131 var _d = false; 132 var _e = undefined; 133 134 try { 135 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 136 _arr.push(_s.value); 137 138 if (i && _arr.length === i) break; 139 } 140 } catch (err) { 141 _d = true; 142 _e = err; 143 } finally { 144 try { 145 if (!_n && _i["return"] != null) _i["return"](); 146 } finally { 147 if (_d) throw _e; 148 } 149 } 150 151 return _arr; 152 } 153 154 module.exports = _iterableToArrayLimit; 155 },{}],"jEQo":[function(require,module,exports) { 156 function _arrayLikeToArray(arr, len) { 157 if (len == null || len > arr.length) len = arr.length; 158 159 for (var i = 0, arr2 = new Array(len); i < len; i++) { 160 arr2[i] = arr[i]; 161 } 162 163 return arr2; 164 } 165 166 module.exports = _arrayLikeToArray; 167 },{}],"Dbv9":[function(require,module,exports) { 168 var arrayLikeToArray = require("./arrayLikeToArray"); 169 170 function _unsupportedIterableToArray(o, minLen) { 171 if (!o) return; 172 if (typeof o === "string") return arrayLikeToArray(o, minLen); 173 var n = Object.prototype.toString.call(o).slice(8, -1); 174 if (n === "Object" && o.constructor) n = o.constructor.name; 175 if (n === "Map" || n === "Set") return Array.from(n); 176 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 177 } 178 179 module.exports = _unsupportedIterableToArray; 180 },{"./arrayLikeToArray":"jEQo"}],"MWEO":[function(require,module,exports) { 181 function _nonIterableRest() { 182 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 183 } 184 185 module.exports = _nonIterableRest; 186 },{}],"DERy":[function(require,module,exports) { 187 var arrayWithHoles = require("./arrayWithHoles"); 188 189 var iterableToArrayLimit = require("./iterableToArrayLimit"); 190 191 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 192 193 var nonIterableRest = require("./nonIterableRest"); 194 195 function _slicedToArray(arr, i) { 196 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 197 } 198 199 module.exports = _slicedToArray; 200 },{"./arrayWithHoles":"DCTP","./iterableToArrayLimit":"LoeL","./unsupportedIterableToArray":"Dbv9","./nonIterableRest":"MWEO"}],"Sjre":[function(require,module,exports) { 120 })({"Sjre":[function(require,module,exports) { 201 121 "use strict"; 202 122 203 123 Object.defineProperty(exports, "__esModule", { … … Object.defineProperty(exports, "__esModule", { 205 125 }); 206 126 exports.default = void 0; 207 127 208 var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));209 210 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }211 212 128 /** 213 129 * WordPress dependencies. 214 130 */ 215 var _wp = wp, 216 _wp$element = _wp.element, 217 createElement = _wp$element.createElement, 218 Fragment = _wp$element.Fragment, 219 useState = _wp$element.useState, 220 __ = _wp.i18n.__, 221 _wp$components = _wp.components, 222 Placeholder = _wp$components.Placeholder, 223 Disabled = _wp$components.Disabled, 224 SandBox = _wp$components.SandBox, 225 Button = _wp$components.Button, 226 ExternalLink = _wp$components.ExternalLink, 227 Spinner = _wp$components.Spinner, 228 ToolbarGroup = _wp$components.ToolbarGroup, 229 ToolbarButton = _wp$components.ToolbarButton, 230 compose = _wp.compose.compose, 231 withSelect = _wp.data.withSelect, 232 _wp$blockEditor = _wp.blockEditor, 233 RichText = _wp$blockEditor.RichText, 234 BlockControls = _wp$blockEditor.BlockControls; 131 const { 132 element: { 133 createElement, 134 Fragment, 135 useState 136 }, 137 i18n: { 138 __ 139 }, 140 components: { 141 Placeholder, 142 Disabled, 143 SandBox, 144 Button, 145 ExternalLink, 146 Spinner, 147 ToolbarGroup, 148 ToolbarButton 149 }, 150 compose: { 151 compose 152 }, 153 data: { 154 withSelect 155 }, 156 blockEditor: { 157 RichText, 158 BlockControls 159 } 160 } = wp; 235 161 /** 236 162 * BuddyPress dependencies. 237 163 */ 238 164 239 var _bp = bp, 240 embedScriptURL = _bp.blockData.embedScriptURL; 241 242 var EditEmbedActivity = function EditEmbedActivity(_ref) { 243 var attributes = _ref.attributes, 244 setAttributes = _ref.setAttributes, 245 isSelected = _ref.isSelected, 246 preview = _ref.preview, 247 fetching = _ref.fetching; 248 var url = attributes.url, 249 caption = attributes.caption; 250 251 var label = __('BuddyPress Activity URL', 'buddypress'); 252 253 var _useState = useState(url), 254 _useState2 = (0, _slicedToArray2.default)(_useState, 2), 255 value = _useState2[0], 256 setURL = _useState2[1]; 257 258 var _useState3 = useState(!url), 259 _useState4 = (0, _slicedToArray2.default)(_useState3, 2), 260 isEditingURL = _useState4[0], 261 setIsEditingURL = _useState4[1]; 262 263 var onSubmit = function onSubmit(event) { 165 const { 166 blockData: { 167 embedScriptURL 168 } 169 } = bp; 170 171 const EditEmbedActivity = ({ 172 attributes, 173 setAttributes, 174 isSelected, 175 preview, 176 fetching 177 }) => { 178 const { 179 url, 180 caption 181 } = attributes; 182 183 const label = __('BuddyPress Activity URL', 'buddypress'); 184 185 const [value, setURL] = useState(url); 186 const [isEditingURL, setIsEditingURL] = useState(!url); 187 188 const onSubmit = event => { 264 189 if (event) { 265 190 event.preventDefault(); 266 191 } … … var EditEmbedActivity = function EditEmbedActivity(_ref) { 271 196 }); 272 197 }; 273 198 274 var switchBackToURLInput = function switchBackToURLInput(event){199 const switchBackToURLInput = event => { 275 200 if (event) { 276 201 event.preventDefault(); 277 202 } … … var EditEmbedActivity = function EditEmbedActivity(_ref) { 279 204 setIsEditingURL(true); 280 205 }; 281 206 282 vareditToolbar = createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {207 const editToolbar = createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, { 283 208 icon: "edit", 284 209 title: __('Edit URL', 'buddypress'), 285 210 onClick: switchBackToURLInput … … var EditEmbedActivity = function EditEmbedActivity(_ref) { 299 224 className: "components-placeholder__input", 300 225 "aria-label": label, 301 226 placeholder: __('Enter URL to embed here…', 'buddypress'), 302 onChange: function onChange(event) { 303 return setURL(event.target.value); 304 } 227 onChange: event => setURL(event.target.value) 305 228 }), createElement(Button, { 306 229 isPrimary: true, 307 230 type: "submit" … … var EditEmbedActivity = function EditEmbedActivity(_ref) { 338 261 tagName: "figcaption", 339 262 placeholder: __('Write caption…', 'buddypress'), 340 263 value: caption, 341 onChange: function onChange(value) { 342 return setAttributes({ 343 caption: value 344 }); 345 }, 264 onChange: value => setAttributes({ 265 caption: value 266 }), 346 267 inlineToolbar: true 347 268 }))); 348 269 }; 349 270 350 var editEmbedActivityBlock = compose([withSelect(function (select, ownProps) { 351 var url = ownProps.attributes.url; 352 353 var _select = select('core'), 354 getEmbedPreview = _select.getEmbedPreview, 355 isRequestingEmbedPreview = _select.isRequestingEmbedPreview; 356 357 var preview = !!url && getEmbedPreview(url); 358 var fetching = !!url && isRequestingEmbedPreview(url); 271 const editEmbedActivityBlock = compose([withSelect((select, ownProps) => { 272 const { 273 url 274 } = ownProps.attributes; 275 const { 276 getEmbedPreview, 277 isRequestingEmbedPreview 278 } = select('core'); 279 const preview = !!url && getEmbedPreview(url); 280 const fetching = !!url && isRequestingEmbedPreview(url); 359 281 return { 360 282 preview: preview, 361 283 fetching: fetching … … var editEmbedActivityBlock = compose([withSelect(function (select, ownProps) { 363 285 })])(EditEmbedActivity); 364 286 var _default = editEmbedActivityBlock; 365 287 exports.default = _default; 366 },{ "@babel/runtime/helpers/slicedToArray":"DERy"}],"zmBI":[function(require,module,exports) {288 },{}],"zmBI":[function(require,module,exports) { 367 289 "use strict"; 368 290 369 291 Object.defineProperty(exports, "__esModule", { … … exports.default = void 0; 374 296 /** 375 297 * WordPress dependencies. 376 298 */ 377 var _wp = wp, 378 RichText = _wp.blockEditor.RichText, 379 createElement = _wp.element.createElement; 299 const { 300 blockEditor: { 301 RichText 302 }, 303 element: { 304 createElement 305 } 306 } = wp; 380 307 381 var saveEmbedActivityBlock = function saveEmbedActivityBlock(_ref) { 382 var attributes = _ref.attributes; 383 var url = attributes.url, 384 caption = attributes.caption; 308 const saveEmbedActivityBlock = ({ 309 attributes 310 }) => { 311 const { 312 url, 313 caption 314 } = attributes; 385 315 386 316 if (!url) { 387 317 return null; … … var saveEmbedActivityBlock = function saveEmbedActivityBlock(_ref) { 391 321 className: "wp-block-embed is-type-bp-activity" 392 322 }, createElement("div", { 393 323 className: "wp-block-embed__wrapper" 394 }, "\n".concat(url, "\n")324 }, `\n${url}\n` 395 325 /* URL needs to be on its own line. */ 396 326 ), !RichText.isEmpty(caption) && createElement(RichText.Content, { 397 327 tagName: "figcaption", … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 413 343 /** 414 344 * WordPress dependencies. 415 345 */ 416 var _wp = wp, 417 __ = _wp.i18n.__, 418 registerBlockType = _wp.blocks.registerBlockType; 346 const { 347 i18n: { 348 __ 349 }, 350 blocks: { 351 registerBlockType 352 } 353 } = wp; 419 354 /** 420 355 * Internal dependencies. 421 356 */ -
src/bp-activity/js/blocks/latest-activities.js
diff --git src/bp-activity/js/blocks/latest-activities.js src/bp-activity/js/blocks/latest-activities.js index 158c08d57..d84849602 100644
const { 145 145 }, 146 146 i18n: { 147 147 __ 148 } 148 }, 149 serverSideRender: ServerSideRender 149 150 } = wp; 150 151 /** 151 152 * BuddyPress dependencies. 152 153 */ 153 154 154 155 const { 155 blockComponents: {156 ServerSideRender157 },158 156 blockData: { 159 157 currentPostId, 160 158 activityTypes -
src/bp-blogs/classes/class-bp-blogs-component.php
diff --git src/bp-blogs/classes/class-bp-blogs-component.php src/bp-blogs/classes/class-bp-blogs-component.php index 617330a1b..eaf62872d 100644
class BP_Blogs_Component extends BP_Component { 408 408 'wp-components', 409 409 'wp-i18n', 410 410 'wp-block-editor', 411 ' bp-block-components',411 'wp-server-side-render', 412 412 ), 413 413 'style' => 'bp-recent-posts-block', 414 414 'style_url' => plugins_url( 'css/blocks/recent-posts.css', dirname( __FILE__ ) ), -
src/bp-blogs/js/blocks/recent-posts.js
diff --git src/bp-blogs/js/blocks/recent-posts.js src/bp-blogs/js/blocks/recent-posts.js index 69a2add7f..ed5b309f5 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 PanelBody = _wp$components.PanelBody, 136 RangeControl = _wp$components.RangeControl, 137 TextControl = _wp$components.TextControl, 138 ToggleControl = _wp$components.ToggleControl, 139 _wp$element = _wp.element, 140 Fragment = _wp$element.Fragment, 141 createElement = _wp$element.createElement, 142 __ = _wp.i18n.__; 143 /** 144 * BuddyPress dependencies. 145 */ 146 147 var _bp = bp, 148 ServerSideRender = _bp.blockComponents.ServerSideRender; 149 150 var editRecentPostsBlock = function editRecentPostsBlock(_ref) { 151 var attributes = _ref.attributes, 152 setAttributes = _ref.setAttributes; 153 var title = attributes.title, 154 maxPosts = attributes.maxPosts, 155 linkTitle = attributes.linkTitle; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 PanelBody, 138 RangeControl, 139 TextControl, 140 ToggleControl 141 }, 142 element: { 143 Fragment, 144 createElement 145 }, 146 i18n: { 147 __ 148 }, 149 serverSideRender: ServerSideRender 150 } = wp; 151 152 const editRecentPostsBlock = ({ 153 attributes, 154 setAttributes 155 }) => { 156 const { 157 title, 158 maxPosts, 159 linkTitle 160 } = attributes; 156 161 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 157 162 title: __('Settings', 'buddypress'), 158 163 initialOpen: true 159 164 }, createElement(TextControl, { 160 165 label: __('Title', 'buddypress'), 161 166 value: title, 162 onChange: function onChange(text){167 onChange: text => { 163 168 setAttributes({ 164 169 title: text 165 170 }); … … var editRecentPostsBlock = function editRecentPostsBlock(_ref) { 167 172 }), createElement(RangeControl, { 168 173 label: __('Max posts to show', 'buddypress'), 169 174 value: maxPosts, 170 onChange: function onChange(value) { 171 return setAttributes({ 172 maxPosts: value 173 }); 174 }, 175 onChange: value => setAttributes({ 176 maxPosts: value 177 }), 175 178 min: 1, 176 179 max: 10, 177 180 required: true 178 181 }), createElement(ToggleControl, { 179 182 label: __('Link block title to Blogs directory', 'buddypress'), 180 183 checked: !!linkTitle, 181 onChange: function onChange(){184 onChange: () => { 182 185 setAttributes({ 183 186 linkTitle: !linkTitle 184 187 }); … … exports.default = void 0; 202 205 /** 203 206 * WordPress dependencies. 204 207 */ 205 var _wp = wp, 206 createBlock = _wp.blocks.createBlock; 208 const { 209 blocks: { 210 createBlock 211 } 212 } = wp; 207 213 /** 208 214 * Transforms Legacy Widget to Recent Posts Block. 209 215 * 210 216 * @type {Object} 211 217 */ 212 218 213 vartransforms = {219 const transforms = { 214 220 from: [{ 215 221 type: 'block', 216 222 blocks: ['core/legacy-widget'], 217 isMatch: function isMatch(_ref){218 var idBase = _ref.idBase,219 instance = _ref.instance;220 223 isMatch: ({ 224 idBase, 225 instance 226 }) => { 221 227 if (!(instance !== null && instance !== void 0 && instance.raw)) { 222 228 return false; 223 229 } 224 230 225 231 return idBase === 'bp_blogs_recent_posts_widget'; 226 232 }, 227 transform: function transform(_ref2) { 228 var instance = _ref2.instance; 233 transform: ({ 234 instance 235 }) => { 229 236 return createBlock('bp/recent-posts', { 230 237 title: instance.raw.title, 231 238 maxPosts: instance.raw.max_posts, … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 248 255 /** 249 256 * WordPress dependencies. 250 257 */ 251 var _wp = wp, 252 registerBlockType = _wp.blocks.registerBlockType, 253 __ = _wp.i18n.__; 258 const { 259 blocks: { 260 registerBlockType 261 }, 262 i18n: { 263 __ 264 } 265 } = wp; 254 266 /** 255 267 * Internal dependencies. 256 268 */ -
src/bp-core/bp-core-blocks.php
diff --git src/bp-core/bp-core-blocks.php src/bp-core/bp-core-blocks.php index 1ce5c1f18..7f844a045 100644
function bp_support_blocks() { 37 37 * Uses a dependency to `wp-editor` otherwise. 38 38 */ 39 39 function bp_register_block_components() { 40 $server_side_renderer_dep = 'wp-server-side-render';41 if ( bp_is_running_wp( '5.3.0', '<' ) ) {42 $server_side_renderer_dep = 'wp-editor';43 }44 45 40 wp_register_script( 46 41 'bp-block-components', 47 42 plugins_url( 'js/block-components.js', __FILE__ ), … … function bp_register_block_components() { 51 46 'wp-i18n', 52 47 'wp-api-fetch', 53 48 'wp-url', 54 $server_side_renderer_dep,55 49 ), 56 50 bp_get_version(), 57 51 false -
src/bp-core/classes/class-bp-core.php
diff --git src/bp-core/classes/class-bp-core.php src/bp-core/classes/class-bp-core.php index e2ee0bcde..9ecf8ab8d 100644
class BP_Core extends BP_Component { 392 392 'wp-components', 393 393 'wp-i18n', 394 394 'wp-block-editor', 395 ' bp-block-components',395 'wp-server-side-render', 396 396 ), 397 397 'style' => 'bp-login-form-block', 398 398 'style_url' => plugins_url( 'css/blocks/login-form.css', dirname( __FILE__ ) ), -
src/bp-core/js/block-components.js
diff --git src/bp-core/js/block-components.js src/bp-core/js/block-components.js index 35f909b36..df14748df 100644
parcelRequire = (function (modules, cache, entry, globalName) { 117 117 } 118 118 119 119 return newRequire; 120 })({"IC7x":[function(require,module,exports) { 121 function _classCallCheck(instance, Constructor) { 122 if (!(instance instanceof Constructor)) { 123 throw new TypeError("Cannot call a class as a function"); 124 } 125 } 126 127 module.exports = _classCallCheck; 128 },{}],"WiqS":[function(require,module,exports) { 129 function _defineProperties(target, props) { 130 for (var i = 0; i < props.length; i++) { 131 var descriptor = props[i]; 132 descriptor.enumerable = descriptor.enumerable || false; 133 descriptor.configurable = true; 134 if ("value" in descriptor) descriptor.writable = true; 135 Object.defineProperty(target, descriptor.key, descriptor); 136 } 137 } 138 139 function _createClass(Constructor, protoProps, staticProps) { 140 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 141 if (staticProps) _defineProperties(Constructor, staticProps); 142 return Constructor; 143 } 144 145 module.exports = _createClass; 146 },{}],"NS7G":[function(require,module,exports) { 147 function _assertThisInitialized(self) { 148 if (self === void 0) { 149 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 150 } 151 152 return self; 153 } 154 155 module.exports = _assertThisInitialized; 156 },{}],"zqo5":[function(require,module,exports) { 157 function _setPrototypeOf(o, p) { 158 module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 159 o.__proto__ = p; 160 return o; 161 }; 162 163 return _setPrototypeOf(o, p); 164 } 165 166 module.exports = _setPrototypeOf; 167 },{}],"RISo":[function(require,module,exports) { 168 var setPrototypeOf = require("./setPrototypeOf"); 169 170 function _inherits(subClass, superClass) { 171 if (typeof superClass !== "function" && superClass !== null) { 172 throw new TypeError("Super expression must either be null or a function"); 173 } 174 175 subClass.prototype = Object.create(superClass && superClass.prototype, { 176 constructor: { 177 value: subClass, 178 writable: true, 179 configurable: true 180 } 181 }); 182 if (superClass) setPrototypeOf(subClass, superClass); 183 } 184 185 module.exports = _inherits; 186 },{"./setPrototypeOf":"zqo5"}],"xOn8":[function(require,module,exports) { 187 function _typeof(obj) { 188 "@babel/helpers - typeof"; 189 190 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 191 module.exports = _typeof = function _typeof(obj) { 192 return typeof obj; 193 }; 194 } else { 195 module.exports = _typeof = function _typeof(obj) { 196 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 197 }; 198 } 199 200 return _typeof(obj); 201 } 202 203 module.exports = _typeof; 204 },{}],"oXYo":[function(require,module,exports) { 205 var _typeof = require("../helpers/typeof"); 206 207 var assertThisInitialized = require("./assertThisInitialized"); 208 209 function _possibleConstructorReturn(self, call) { 210 if (call && (_typeof(call) === "object" || typeof call === "function")) { 211 return call; 212 } 213 214 return assertThisInitialized(self); 215 } 216 217 module.exports = _possibleConstructorReturn; 218 },{"../helpers/typeof":"xOn8","./assertThisInitialized":"NS7G"}],"goD2":[function(require,module,exports) { 219 function _getPrototypeOf(o) { 220 module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 221 return o.__proto__ || Object.getPrototypeOf(o); 222 }; 223 return _getPrototypeOf(o); 224 } 225 226 module.exports = _getPrototypeOf; 227 },{}],"W80x":[function(require,module,exports) { 120 })({"W80x":[function(require,module,exports) { 228 121 "use strict"; 229 122 230 123 Object.defineProperty(exports, "__esModule", { … … Object.defineProperty(exports, "__esModule", { 232 125 }); 233 126 exports.default = void 0; 234 127 235 var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));236 237 var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));238 239 var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));240 241 var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));242 243 var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));244 245 var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));246 247 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }248 249 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }250 251 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }252 253 128 /** 254 129 * WordPress dependencies. 255 130 */ 256 var _wp = wp, 257 apiFetch = _wp.apiFetch, 258 Popover = _wp.components.Popover, 259 _wp$element = _wp.element, 260 Component = _wp$element.Component, 261 Fragment = _wp$element.Fragment, 262 createElement = _wp$element.createElement, 263 __ = _wp.i18n.__, 264 addQueryArgs = _wp.url.addQueryArgs; 265 266 var AutoCompleter = /*#__PURE__*/function (_Component) { 267 (0, _inherits2.default)(AutoCompleter, _Component); 268 269 var _super = _createSuper(AutoCompleter); 270 271 function AutoCompleter() { 272 var _this; 273 274 (0, _classCallCheck2.default)(this, AutoCompleter); 275 _this = _super.apply(this, arguments); 276 _this.state = { 131 const { 132 apiFetch, 133 components: { 134 Popover 135 }, 136 element: { 137 Component, 138 Fragment, 139 createElement 140 }, 141 i18n: { 142 __ 143 }, 144 url: { 145 addQueryArgs 146 } 147 } = wp; 148 149 class AutoCompleter extends Component { 150 constructor() { 151 super(...arguments); 152 this.state = { 277 153 search: '', 278 154 items: [], 279 155 error: '' 280 156 }; 281 _this.searchItemName = _this.searchItemName.bind((0, _assertThisInitialized2.default)(_this)); 282 _this.selectItemName = _this.selectItemName.bind((0, _assertThisInitialized2.default)(_this)); 283 return _this; 157 this.searchItemName = this.searchItemName.bind(this); 158 this.selectItemName = this.selectItemName.bind(this); 284 159 } 285 160 286 (0, _createClass2.default)(AutoCompleter, [{ 287 key: "searchItemName", 288 value: function searchItemName(value) { 289 var _this2 = this; 290 291 var search = this.state.search; 292 var _this$props = this.props, 293 component = _this$props.component, 294 objectQueryArgs = _this$props.objectQueryArgs; 161 searchItemName(value) { 162 const { 163 search 164 } = this.state; 165 const { 166 component, 167 objectQueryArgs 168 } = this.props; 169 this.setState({ 170 search: value 171 }); 172 173 if (value.length < search.length) { 295 174 this.setState({ 296 search: value175 items: [] 297 176 }); 177 } 298 178 299 if (value.length < search.length) { 300 this.setState({ 301 items: [] 302 }); 303 } 304 305 var path = '/buddypress/v1/' + component; 306 var queryArgs = {}; 307 308 if (value) { 309 queryArgs.search = encodeURIComponent(value); 310 } 179 let path = '/buddypress/v1/' + component; 180 let queryArgs = {}; 311 181 312 if (objectQueryArgs) {313 queryArgs = Object.assign(queryArgs, objectQueryArgs);314 182 if (value) { 183 queryArgs.search = encodeURIComponent(value); 184 } 315 185 316 apiFetch({ 317 path: addQueryArgs(path, queryArgs) 318 }).then(function (items) { 319 _this2.setState({ 320 items: items 321 }); 322 }, function (error) { 323 _this2.setState({ 324 error: error.message 325 }); 326 }); 186 if (objectQueryArgs) { 187 queryArgs = Object.assign(queryArgs, objectQueryArgs); 327 188 } 328 }, { 329 key: "selectItemName", 330 value: function selectItemName(event, itemID) { 331 var onSelectItem = this.props.onSelectItem; 332 event.preventDefault(); 189 190 apiFetch({ 191 path: addQueryArgs(path, queryArgs) 192 }).then(items => { 333 193 this.setState({ 334 search: '', 335 items: [], 336 error: '' 194 items: items 337 195 }); 338 return onSelectItem({ 339 itemID: itemID 196 }, error => { 197 this.setState({ 198 error: error.message 340 199 }); 341 } 342 }, { 343 key: "render", 344 value: function render() { 345 var _this3 = this; 346 347 var _this$state = this.state, 348 search = _this$state.search, 349 items = _this$state.items; 350 var _this$props2 = this.props, 351 ariaLabel = _this$props2.ariaLabel, 352 placeholder = _this$props2.placeholder, 353 useAvatar = _this$props2.useAvatar, 354 slugValue = _this$props2.slugValue; 355 var itemsList; 356 357 if (!ariaLabel) { 358 ariaLabel = __('Item\'s name', 'buddypress'); 359 } 360 361 if (!placeholder) { 362 placeholder = __('Enter Item\'s name here…', 'buddypress'); 363 } 200 }); 201 } 364 202 365 if (items.length) { 366 itemsList = items.map(function (item) { 367 return createElement("button", { 368 type: "button", 369 key: 'editor-autocompleters__item-item-' + item.id, 370 role: "option", 371 "aria-selected": "true", 372 className: "components-button components-autocomplete__result editor-autocompleters__user", 373 onClick: function onClick(event) { 374 return _this3.selectItemName(event, item.id); 375 } 376 }, useAvatar && createElement("img", { 377 key: "avatar", 378 className: "editor-autocompleters__user-avatar", 379 alt: "", 380 src: item.avatar_urls.thumb.replaceAll('&', '&') 381 }), createElement("span", { 382 key: "name", 383 className: "editor-autocompleters__user-name" 384 }, item.name), slugValue && null !== slugValue(item) && createElement("span", { 385 key: "slug", 386 className: "editor-autocompleters__user-slug" 387 }, slugValue(item))); 388 }); 389 } 203 selectItemName(event, itemID) { 204 const { 205 onSelectItem 206 } = this.props; 207 event.preventDefault(); 208 this.setState({ 209 search: '', 210 items: [], 211 error: '' 212 }); 213 return onSelectItem({ 214 itemID: itemID 215 }); 216 } 390 217 391 return createElement(Fragment, null, createElement("input", { 392 type: "text", 393 value: search, 394 className: "components-placeholder__input", 395 "aria-label": ariaLabel, 396 placeholder: placeholder, 397 onChange: function onChange(event) { 398 return _this3.searchItemName(event.target.value); 399 } 400 }), 0 !== items.length && createElement(Popover, { 401 className: "components-autocomplete__popover", 402 focusOnMount: false, 403 position: "bottom left" 404 }, createElement("div", { 405 className: "components-autocomplete__results" 406 }, itemsList))); 218 render() { 219 const { 220 search, 221 items 222 } = this.state; 223 let { 224 ariaLabel, 225 placeholder, 226 useAvatar, 227 slugValue 228 } = this.props; 229 let itemsList; 230 231 if (!ariaLabel) { 232 ariaLabel = __('Item\'s name', 'buddypress'); 407 233 } 408 }]);409 return AutoCompleter;410 }(Component);411 234 412 var _default = AutoCompleter; 413 exports.default = _default; 414 },{"@babel/runtime/helpers/classCallCheck":"IC7x","@babel/runtime/helpers/createClass":"WiqS","@babel/runtime/helpers/assertThisInitialized":"NS7G","@babel/runtime/helpers/inherits":"RISo","@babel/runtime/helpers/possibleConstructorReturn":"oXYo","@babel/runtime/helpers/getPrototypeOf":"goD2"}],"fOJU":[function(require,module,exports) { 415 "use strict"; 235 if (!placeholder) { 236 placeholder = __('Enter Item\'s name here…', 'buddypress'); 237 } 416 238 417 Object.defineProperty(exports, "__esModule", { 418 value: true 419 }); 420 exports.default = ServerSideRender; 239 if (items.length) { 240 itemsList = items.map(item => { 241 return createElement("button", { 242 type: "button", 243 key: 'editor-autocompleters__item-item-' + item.id, 244 role: "option", 245 "aria-selected": "true", 246 className: "components-button components-autocomplete__result editor-autocompleters__user", 247 onClick: event => this.selectItemName(event, item.id) 248 }, useAvatar && createElement("img", { 249 key: "avatar", 250 className: "editor-autocompleters__user-avatar", 251 alt: "", 252 src: item.avatar_urls.thumb.replaceAll('&', '&') 253 }), createElement("span", { 254 key: "name", 255 className: "editor-autocompleters__user-name" 256 }, item.name), slugValue && null !== slugValue(item) && createElement("span", { 257 key: "slug", 258 className: "editor-autocompleters__user-slug" 259 }, slugValue(item))); 260 }); 261 } 421 262 422 /** 423 * WordPress dependencies. 424 */ 425 var _wp = wp, 426 createElement = _wp.element.createElement; 427 /** 428 * Compatibility Server Side Render. 429 * 430 * @since 9.0.0 431 */ 263 return createElement(Fragment, null, createElement("input", { 264 type: "text", 265 value: search, 266 className: "components-placeholder__input", 267 "aria-label": ariaLabel, 268 placeholder: placeholder, 269 onChange: event => this.searchItemName(event.target.value) 270 }), 0 !== items.length && createElement(Popover, { 271 className: "components-autocomplete__popover", 272 focusOnMount: false, 273 position: "bottom left" 274 }, createElement("div", { 275 className: "components-autocomplete__results" 276 }, itemsList))); 277 } 432 278 433 function ServerSideRender(props) {434 var CompatibiltyServerSideRender = wp.serverSideRender ? wp.serverSideRender : wp.editor.ServerSideRender;435 return createElement(CompatibiltyServerSideRender, props);436 279 } 280 281 var _default = AutoCompleter; 282 exports.default = _default; 437 283 },{}],"iA92":[function(require,module,exports) { 438 284 "use strict"; 439 285 … … exports.default = void 0; 444 290 445 291 var _autocompleter = _interopRequireDefault(require("./autocompleter")); 446 292 447 var _serverSideRender = _interopRequireDefault(require("./server-side-render"));448 449 293 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 450 294 451 295 /** 452 296 * BuddyPress components. 453 297 */ 454 298 var _default = { 455 AutoCompleter: _autocompleter.default, 456 ServerSideRender: _serverSideRender.default 299 AutoCompleter: _autocompleter.default 457 300 }; 458 301 exports.default = _default; 459 },{"./autocompleter":"W80x" ,"./server-side-render":"fOJU"}],"Ee8M":[function(require,module,exports) {302 },{"./autocompleter":"W80x"}],"Ee8M":[function(require,module,exports) { 460 303 "use strict"; 461 304 462 305 Object.defineProperty(exports, "__esModule", { -
src/bp-core/js/block-data.js
diff --git src/bp-core/js/block-data.js src/bp-core/js/block-data.js index f9fc38caf..03185dce6 100644
parcelRequire = (function (modules, cache, entry, globalName) { 117 117 } 118 118 119 119 return newRequire; 120 })({"DCTP":[function(require,module,exports) { 121 function _arrayWithHoles(arr) { 122 if (Array.isArray(arr)) return arr; 123 } 124 125 module.exports = _arrayWithHoles; 126 },{}],"LoeL":[function(require,module,exports) { 127 function _iterableToArrayLimit(arr, i) { 128 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 129 var _arr = []; 130 var _n = true; 131 var _d = false; 132 var _e = undefined; 133 134 try { 135 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 136 _arr.push(_s.value); 137 138 if (i && _arr.length === i) break; 139 } 140 } catch (err) { 141 _d = true; 142 _e = err; 143 } finally { 144 try { 145 if (!_n && _i["return"] != null) _i["return"](); 146 } finally { 147 if (_d) throw _e; 148 } 149 } 150 151 return _arr; 152 } 153 154 module.exports = _iterableToArrayLimit; 155 },{}],"jEQo":[function(require,module,exports) { 156 function _arrayLikeToArray(arr, len) { 157 if (len == null || len > arr.length) len = arr.length; 158 159 for (var i = 0, arr2 = new Array(len); i < len; i++) { 160 arr2[i] = arr[i]; 161 } 162 163 return arr2; 164 } 165 166 module.exports = _arrayLikeToArray; 167 },{}],"Dbv9":[function(require,module,exports) { 168 var arrayLikeToArray = require("./arrayLikeToArray"); 169 170 function _unsupportedIterableToArray(o, minLen) { 171 if (!o) return; 172 if (typeof o === "string") return arrayLikeToArray(o, minLen); 173 var n = Object.prototype.toString.call(o).slice(8, -1); 174 if (n === "Object" && o.constructor) n = o.constructor.name; 175 if (n === "Map" || n === "Set") return Array.from(n); 176 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 177 } 178 179 module.exports = _unsupportedIterableToArray; 180 },{"./arrayLikeToArray":"jEQo"}],"MWEO":[function(require,module,exports) { 181 function _nonIterableRest() { 182 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 183 } 184 185 module.exports = _nonIterableRest; 186 },{}],"DERy":[function(require,module,exports) { 187 var arrayWithHoles = require("./arrayWithHoles"); 188 189 var iterableToArrayLimit = require("./iterableToArrayLimit"); 190 191 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 192 193 var nonIterableRest = require("./nonIterableRest"); 194 195 function _slicedToArray(arr, i) { 196 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 197 } 198 199 module.exports = _slicedToArray; 200 },{"./arrayWithHoles":"DCTP","./iterableToArrayLimit":"LoeL","./unsupportedIterableToArray":"Dbv9","./nonIterableRest":"MWEO"}],"Ih1j":[function(require,module,exports) { 120 })({"Ih1j":[function(require,module,exports) { 201 121 "use strict"; 202 122 203 123 Object.defineProperty(exports, "__esModule", { … … exports.STORE_KEY = void 0; 210 130 * 211 131 * @type {string} 212 132 */ 213 varSTORE_KEY = 'bp/core';133 const STORE_KEY = 'bp/core'; 214 134 exports.STORE_KEY = STORE_KEY; 215 135 },{}],"DDtj":[function(require,module,exports) { 216 136 "use strict"; … … exports.getActiveComponents = void 0; 226 146 * @param {Object} state The current state. 227 147 * @return {array} The list of Active BP Components. 228 148 */ 229 var getActiveComponents = function getActiveComponents(state){149 const getActiveComponents = state => { 230 150 return state.components || []; 231 151 }; 232 152 … … exports.TYPES = void 0; 244 164 * 245 165 * @type {Object} 246 166 */ 247 varTYPES = {167 const TYPES = { 248 168 GET_ACTIVE_COMPONENTS: 'GET_ACTIVE_COMPONENTS', 249 169 FETCH_FROM_API: 'FETCH_FROM_API' 250 170 }; … … var _actionTypes = require("./action-types"); 272 192 function getActiveComponents(list) { 273 193 return { 274 194 type: _actionTypes.TYPES.GET_ACTIVE_COMPONENTS, 275 list : list195 list 276 196 }; 277 197 } 278 198 /** … … function getActiveComponents(list) { 287 207 function fetchFromAPI(path, parse) { 288 208 return { 289 209 type: _actionTypes.TYPES.FETCH_FROM_API, 290 path : path,291 parse : parse210 path, 211 parse 292 212 }; 293 213 } 294 },{"./action-types":"gg2v"}],"rqzK":[function(require,module,exports) { 295 /** 296 * Copyright (c) 2014-present, Facebook, Inc. 297 * 298 * This source code is licensed under the MIT license found in the 299 * LICENSE file in the root directory of this source tree. 300 */ 301 302 var runtime = (function (exports) { 303 "use strict"; 304 305 var Op = Object.prototype; 306 var hasOwn = Op.hasOwnProperty; 307 var undefined; // More compressible than void 0. 308 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 309 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 310 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 311 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 312 313 function wrap(innerFn, outerFn, self, tryLocsList) { 314 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 315 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 316 var generator = Object.create(protoGenerator.prototype); 317 var context = new Context(tryLocsList || []); 318 319 // The ._invoke method unifies the implementations of the .next, 320 // .throw, and .return methods. 321 generator._invoke = makeInvokeMethod(innerFn, self, context); 322 323 return generator; 324 } 325 exports.wrap = wrap; 326 327 // Try/catch helper to minimize deoptimizations. Returns a completion 328 // record like context.tryEntries[i].completion. This interface could 329 // have been (and was previously) designed to take a closure to be 330 // invoked without arguments, but in all the cases we care about we 331 // already have an existing method we want to call, so there's no need 332 // to create a new function object. We can even get away with assuming 333 // the method takes exactly one argument, since that happens to be true 334 // in every case, so we don't have to touch the arguments object. The 335 // only additional allocation required is the completion record, which 336 // has a stable shape and so hopefully should be cheap to allocate. 337 function tryCatch(fn, obj, arg) { 338 try { 339 return { type: "normal", arg: fn.call(obj, arg) }; 340 } catch (err) { 341 return { type: "throw", arg: err }; 342 } 343 } 344 345 var GenStateSuspendedStart = "suspendedStart"; 346 var GenStateSuspendedYield = "suspendedYield"; 347 var GenStateExecuting = "executing"; 348 var GenStateCompleted = "completed"; 349 350 // Returning this object from the innerFn has the same effect as 351 // breaking out of the dispatch switch statement. 352 var ContinueSentinel = {}; 353 354 // Dummy constructor functions that we use as the .constructor and 355 // .constructor.prototype properties for functions that return Generator 356 // objects. For full spec compliance, you may wish to configure your 357 // minifier not to mangle the names of these two functions. 358 function Generator() {} 359 function GeneratorFunction() {} 360 function GeneratorFunctionPrototype() {} 361 362 // This is a polyfill for %IteratorPrototype% for environments that 363 // don't natively support it. 364 var IteratorPrototype = {}; 365 IteratorPrototype[iteratorSymbol] = function () { 366 return this; 367 }; 368 369 var getProto = Object.getPrototypeOf; 370 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 371 if (NativeIteratorPrototype && 372 NativeIteratorPrototype !== Op && 373 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 374 // This environment has a native %IteratorPrototype%; use it instead 375 // of the polyfill. 376 IteratorPrototype = NativeIteratorPrototype; 377 } 378 379 var Gp = GeneratorFunctionPrototype.prototype = 380 Generator.prototype = Object.create(IteratorPrototype); 381 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 382 GeneratorFunctionPrototype.constructor = GeneratorFunction; 383 GeneratorFunctionPrototype[toStringTagSymbol] = 384 GeneratorFunction.displayName = "GeneratorFunction"; 385 386 // Helper for defining the .next, .throw, and .return methods of the 387 // Iterator interface in terms of a single ._invoke method. 388 function defineIteratorMethods(prototype) { 389 ["next", "throw", "return"].forEach(function(method) { 390 prototype[method] = function(arg) { 391 return this._invoke(method, arg); 392 }; 393 }); 394 } 395 396 exports.isGeneratorFunction = function(genFun) { 397 var ctor = typeof genFun === "function" && genFun.constructor; 398 return ctor 399 ? ctor === GeneratorFunction || 400 // For the native GeneratorFunction constructor, the best we can 401 // do is to check its .name property. 402 (ctor.displayName || ctor.name) === "GeneratorFunction" 403 : false; 404 }; 405 406 exports.mark = function(genFun) { 407 if (Object.setPrototypeOf) { 408 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 409 } else { 410 genFun.__proto__ = GeneratorFunctionPrototype; 411 if (!(toStringTagSymbol in genFun)) { 412 genFun[toStringTagSymbol] = "GeneratorFunction"; 413 } 414 } 415 genFun.prototype = Object.create(Gp); 416 return genFun; 417 }; 418 419 // Within the body of any async function, `await x` is transformed to 420 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 421 // `hasOwn.call(value, "__await")` to determine if the yielded value is 422 // meant to be awaited. 423 exports.awrap = function(arg) { 424 return { __await: arg }; 425 }; 426 427 function AsyncIterator(generator, PromiseImpl) { 428 function invoke(method, arg, resolve, reject) { 429 var record = tryCatch(generator[method], generator, arg); 430 if (record.type === "throw") { 431 reject(record.arg); 432 } else { 433 var result = record.arg; 434 var value = result.value; 435 if (value && 436 typeof value === "object" && 437 hasOwn.call(value, "__await")) { 438 return PromiseImpl.resolve(value.__await).then(function(value) { 439 invoke("next", value, resolve, reject); 440 }, function(err) { 441 invoke("throw", err, resolve, reject); 442 }); 443 } 444 445 return PromiseImpl.resolve(value).then(function(unwrapped) { 446 // When a yielded Promise is resolved, its final value becomes 447 // the .value of the Promise<{value,done}> result for the 448 // current iteration. 449 result.value = unwrapped; 450 resolve(result); 451 }, function(error) { 452 // If a rejected Promise was yielded, throw the rejection back 453 // into the async generator function so it can be handled there. 454 return invoke("throw", error, resolve, reject); 455 }); 456 } 457 } 458 459 var previousPromise; 460 461 function enqueue(method, arg) { 462 function callInvokeWithMethodAndArg() { 463 return new PromiseImpl(function(resolve, reject) { 464 invoke(method, arg, resolve, reject); 465 }); 466 } 467 468 return previousPromise = 469 // If enqueue has been called before, then we want to wait until 470 // all previous Promises have been resolved before calling invoke, 471 // so that results are always delivered in the correct order. If 472 // enqueue has not been called before, then it is important to 473 // call invoke immediately, without waiting on a callback to fire, 474 // so that the async generator function has the opportunity to do 475 // any necessary setup in a predictable way. This predictability 476 // is why the Promise constructor synchronously invokes its 477 // executor callback, and why async functions synchronously 478 // execute code before the first await. Since we implement simple 479 // async functions in terms of async generators, it is especially 480 // important to get this right, even though it requires care. 481 previousPromise ? previousPromise.then( 482 callInvokeWithMethodAndArg, 483 // Avoid propagating failures to Promises returned by later 484 // invocations of the iterator. 485 callInvokeWithMethodAndArg 486 ) : callInvokeWithMethodAndArg(); 487 } 488 489 // Define the unified helper method that is used to implement .next, 490 // .throw, and .return (see defineIteratorMethods). 491 this._invoke = enqueue; 492 } 493 494 defineIteratorMethods(AsyncIterator.prototype); 495 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 496 return this; 497 }; 498 exports.AsyncIterator = AsyncIterator; 499 500 // Note that simple async functions are implemented on top of 501 // AsyncIterator objects; they just return a Promise for the value of 502 // the final result produced by the iterator. 503 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { 504 if (PromiseImpl === void 0) PromiseImpl = Promise; 505 506 var iter = new AsyncIterator( 507 wrap(innerFn, outerFn, self, tryLocsList), 508 PromiseImpl 509 ); 510 511 return exports.isGeneratorFunction(outerFn) 512 ? iter // If outerFn is a generator, return the full iterator. 513 : iter.next().then(function(result) { 514 return result.done ? result.value : iter.next(); 515 }); 516 }; 517 518 function makeInvokeMethod(innerFn, self, context) { 519 var state = GenStateSuspendedStart; 520 521 return function invoke(method, arg) { 522 if (state === GenStateExecuting) { 523 throw new Error("Generator is already running"); 524 } 525 526 if (state === GenStateCompleted) { 527 if (method === "throw") { 528 throw arg; 529 } 530 531 // Be forgiving, per 25.3.3.3.3 of the spec: 532 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 533 return doneResult(); 534 } 535 536 context.method = method; 537 context.arg = arg; 538 539 while (true) { 540 var delegate = context.delegate; 541 if (delegate) { 542 var delegateResult = maybeInvokeDelegate(delegate, context); 543 if (delegateResult) { 544 if (delegateResult === ContinueSentinel) continue; 545 return delegateResult; 546 } 547 } 548 549 if (context.method === "next") { 550 // Setting context._sent for legacy support of Babel's 551 // function.sent implementation. 552 context.sent = context._sent = context.arg; 553 554 } else if (context.method === "throw") { 555 if (state === GenStateSuspendedStart) { 556 state = GenStateCompleted; 557 throw context.arg; 558 } 559 560 context.dispatchException(context.arg); 561 562 } else if (context.method === "return") { 563 context.abrupt("return", context.arg); 564 } 565 566 state = GenStateExecuting; 567 568 var record = tryCatch(innerFn, self, context); 569 if (record.type === "normal") { 570 // If an exception is thrown from innerFn, we leave state === 571 // GenStateExecuting and loop back for another invocation. 572 state = context.done 573 ? GenStateCompleted 574 : GenStateSuspendedYield; 575 576 if (record.arg === ContinueSentinel) { 577 continue; 578 } 579 580 return { 581 value: record.arg, 582 done: context.done 583 }; 584 585 } else if (record.type === "throw") { 586 state = GenStateCompleted; 587 // Dispatch the exception by looping back around to the 588 // context.dispatchException(context.arg) call above. 589 context.method = "throw"; 590 context.arg = record.arg; 591 } 592 } 593 }; 594 } 595 596 // Call delegate.iterator[context.method](context.arg) and handle the 597 // result, either by returning a { value, done } result from the 598 // delegate iterator, or by modifying context.method and context.arg, 599 // setting context.delegate to null, and returning the ContinueSentinel. 600 function maybeInvokeDelegate(delegate, context) { 601 var method = delegate.iterator[context.method]; 602 if (method === undefined) { 603 // A .throw or .return when the delegate iterator has no .throw 604 // method always terminates the yield* loop. 605 context.delegate = null; 606 607 if (context.method === "throw") { 608 // Note: ["return"] must be used for ES3 parsing compatibility. 609 if (delegate.iterator["return"]) { 610 // If the delegate iterator has a return method, give it a 611 // chance to clean up. 612 context.method = "return"; 613 context.arg = undefined; 614 maybeInvokeDelegate(delegate, context); 615 616 if (context.method === "throw") { 617 // If maybeInvokeDelegate(context) changed context.method from 618 // "return" to "throw", let that override the TypeError below. 619 return ContinueSentinel; 620 } 621 } 622 623 context.method = "throw"; 624 context.arg = new TypeError( 625 "The iterator does not provide a 'throw' method"); 626 } 627 628 return ContinueSentinel; 629 } 630 631 var record = tryCatch(method, delegate.iterator, context.arg); 632 633 if (record.type === "throw") { 634 context.method = "throw"; 635 context.arg = record.arg; 636 context.delegate = null; 637 return ContinueSentinel; 638 } 639 640 var info = record.arg; 641 642 if (! info) { 643 context.method = "throw"; 644 context.arg = new TypeError("iterator result is not an object"); 645 context.delegate = null; 646 return ContinueSentinel; 647 } 648 649 if (info.done) { 650 // Assign the result of the finished delegate to the temporary 651 // variable specified by delegate.resultName (see delegateYield). 652 context[delegate.resultName] = info.value; 653 654 // Resume execution at the desired location (see delegateYield). 655 context.next = delegate.nextLoc; 656 657 // If context.method was "throw" but the delegate handled the 658 // exception, let the outer generator proceed normally. If 659 // context.method was "next", forget context.arg since it has been 660 // "consumed" by the delegate iterator. If context.method was 661 // "return", allow the original .return call to continue in the 662 // outer generator. 663 if (context.method !== "return") { 664 context.method = "next"; 665 context.arg = undefined; 666 } 667 668 } else { 669 // Re-yield the result returned by the delegate method. 670 return info; 671 } 672 673 // The delegate iterator is finished, so forget it and continue with 674 // the outer generator. 675 context.delegate = null; 676 return ContinueSentinel; 677 } 678 679 // Define Generator.prototype.{next,throw,return} in terms of the 680 // unified ._invoke helper method. 681 defineIteratorMethods(Gp); 682 683 Gp[toStringTagSymbol] = "Generator"; 684 685 // A Generator should always return itself as the iterator object when the 686 // @@iterator function is called on it. Some browsers' implementations of the 687 // iterator prototype chain incorrectly implement this, causing the Generator 688 // object to not be returned from this call. This ensures that doesn't happen. 689 // See https://github.com/facebook/regenerator/issues/274 for more details. 690 Gp[iteratorSymbol] = function() { 691 return this; 692 }; 693 694 Gp.toString = function() { 695 return "[object Generator]"; 696 }; 697 698 function pushTryEntry(locs) { 699 var entry = { tryLoc: locs[0] }; 700 701 if (1 in locs) { 702 entry.catchLoc = locs[1]; 703 } 704 705 if (2 in locs) { 706 entry.finallyLoc = locs[2]; 707 entry.afterLoc = locs[3]; 708 } 709 710 this.tryEntries.push(entry); 711 } 712 713 function resetTryEntry(entry) { 714 var record = entry.completion || {}; 715 record.type = "normal"; 716 delete record.arg; 717 entry.completion = record; 718 } 719 720 function Context(tryLocsList) { 721 // The root entry object (effectively a try statement without a catch 722 // or a finally block) gives us a place to store values thrown from 723 // locations where there is no enclosing try statement. 724 this.tryEntries = [{ tryLoc: "root" }]; 725 tryLocsList.forEach(pushTryEntry, this); 726 this.reset(true); 727 } 728 729 exports.keys = function(object) { 730 var keys = []; 731 for (var key in object) { 732 keys.push(key); 733 } 734 keys.reverse(); 735 736 // Rather than returning an object with a next method, we keep 737 // things simple and return the next function itself. 738 return function next() { 739 while (keys.length) { 740 var key = keys.pop(); 741 if (key in object) { 742 next.value = key; 743 next.done = false; 744 return next; 745 } 746 } 747 748 // To avoid creating an additional object, we just hang the .value 749 // and .done properties off the next function object itself. This 750 // also ensures that the minifier will not anonymize the function. 751 next.done = true; 752 return next; 753 }; 754 }; 755 756 function values(iterable) { 757 if (iterable) { 758 var iteratorMethod = iterable[iteratorSymbol]; 759 if (iteratorMethod) { 760 return iteratorMethod.call(iterable); 761 } 762 763 if (typeof iterable.next === "function") { 764 return iterable; 765 } 766 767 if (!isNaN(iterable.length)) { 768 var i = -1, next = function next() { 769 while (++i < iterable.length) { 770 if (hasOwn.call(iterable, i)) { 771 next.value = iterable[i]; 772 next.done = false; 773 return next; 774 } 775 } 776 777 next.value = undefined; 778 next.done = true; 779 780 return next; 781 }; 782 783 return next.next = next; 784 } 785 } 786 787 // Return an iterator with no values. 788 return { next: doneResult }; 789 } 790 exports.values = values; 791 792 function doneResult() { 793 return { value: undefined, done: true }; 794 } 795 796 Context.prototype = { 797 constructor: Context, 798 799 reset: function(skipTempReset) { 800 this.prev = 0; 801 this.next = 0; 802 // Resetting context._sent for legacy support of Babel's 803 // function.sent implementation. 804 this.sent = this._sent = undefined; 805 this.done = false; 806 this.delegate = null; 807 808 this.method = "next"; 809 this.arg = undefined; 810 811 this.tryEntries.forEach(resetTryEntry); 812 813 if (!skipTempReset) { 814 for (var name in this) { 815 // Not sure about the optimal order of these conditions: 816 if (name.charAt(0) === "t" && 817 hasOwn.call(this, name) && 818 !isNaN(+name.slice(1))) { 819 this[name] = undefined; 820 } 821 } 822 } 823 }, 824 825 stop: function() { 826 this.done = true; 827 828 var rootEntry = this.tryEntries[0]; 829 var rootRecord = rootEntry.completion; 830 if (rootRecord.type === "throw") { 831 throw rootRecord.arg; 832 } 833 834 return this.rval; 835 }, 836 837 dispatchException: function(exception) { 838 if (this.done) { 839 throw exception; 840 } 841 842 var context = this; 843 function handle(loc, caught) { 844 record.type = "throw"; 845 record.arg = exception; 846 context.next = loc; 847 848 if (caught) { 849 // If the dispatched exception was caught by a catch block, 850 // then let that catch block handle the exception normally. 851 context.method = "next"; 852 context.arg = undefined; 853 } 854 855 return !! caught; 856 } 857 858 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 859 var entry = this.tryEntries[i]; 860 var record = entry.completion; 861 862 if (entry.tryLoc === "root") { 863 // Exception thrown outside of any try block that could handle 864 // it, so set the completion value of the entire function to 865 // throw the exception. 866 return handle("end"); 867 } 868 869 if (entry.tryLoc <= this.prev) { 870 var hasCatch = hasOwn.call(entry, "catchLoc"); 871 var hasFinally = hasOwn.call(entry, "finallyLoc"); 872 873 if (hasCatch && hasFinally) { 874 if (this.prev < entry.catchLoc) { 875 return handle(entry.catchLoc, true); 876 } else if (this.prev < entry.finallyLoc) { 877 return handle(entry.finallyLoc); 878 } 879 880 } else if (hasCatch) { 881 if (this.prev < entry.catchLoc) { 882 return handle(entry.catchLoc, true); 883 } 884 885 } else if (hasFinally) { 886 if (this.prev < entry.finallyLoc) { 887 return handle(entry.finallyLoc); 888 } 889 890 } else { 891 throw new Error("try statement without catch or finally"); 892 } 893 } 894 } 895 }, 896 897 abrupt: function(type, arg) { 898 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 899 var entry = this.tryEntries[i]; 900 if (entry.tryLoc <= this.prev && 901 hasOwn.call(entry, "finallyLoc") && 902 this.prev < entry.finallyLoc) { 903 var finallyEntry = entry; 904 break; 905 } 906 } 907 908 if (finallyEntry && 909 (type === "break" || 910 type === "continue") && 911 finallyEntry.tryLoc <= arg && 912 arg <= finallyEntry.finallyLoc) { 913 // Ignore the finally entry if control is not jumping to a 914 // location outside the try/catch block. 915 finallyEntry = null; 916 } 917 918 var record = finallyEntry ? finallyEntry.completion : {}; 919 record.type = type; 920 record.arg = arg; 921 922 if (finallyEntry) { 923 this.method = "next"; 924 this.next = finallyEntry.finallyLoc; 925 return ContinueSentinel; 926 } 927 928 return this.complete(record); 929 }, 930 931 complete: function(record, afterLoc) { 932 if (record.type === "throw") { 933 throw record.arg; 934 } 935 936 if (record.type === "break" || 937 record.type === "continue") { 938 this.next = record.arg; 939 } else if (record.type === "return") { 940 this.rval = this.arg = record.arg; 941 this.method = "return"; 942 this.next = "end"; 943 } else if (record.type === "normal" && afterLoc) { 944 this.next = afterLoc; 945 } 946 947 return ContinueSentinel; 948 }, 949 950 finish: function(finallyLoc) { 951 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 952 var entry = this.tryEntries[i]; 953 if (entry.finallyLoc === finallyLoc) { 954 this.complete(entry.completion, entry.afterLoc); 955 resetTryEntry(entry); 956 return ContinueSentinel; 957 } 958 } 959 }, 960 961 "catch": function(tryLoc) { 962 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 963 var entry = this.tryEntries[i]; 964 if (entry.tryLoc === tryLoc) { 965 var record = entry.completion; 966 if (record.type === "throw") { 967 var thrown = record.arg; 968 resetTryEntry(entry); 969 } 970 return thrown; 971 } 972 } 973 974 // The context.catch method must only be called with a location 975 // argument that corresponds to a known catch block. 976 throw new Error("illegal catch attempt"); 977 }, 978 979 delegateYield: function(iterable, resultName, nextLoc) { 980 this.delegate = { 981 iterator: values(iterable), 982 resultName: resultName, 983 nextLoc: nextLoc 984 }; 985 986 if (this.method === "next") { 987 // Deliberately forget the last sent value so that we don't 988 // accidentally pass it on to the delegate. 989 this.arg = undefined; 990 } 991 992 return ContinueSentinel; 993 } 994 }; 995 996 // Regardless of whether this script is executing as a CommonJS module 997 // or not, return the runtime object so that we can declare the variable 998 // regeneratorRuntime in the outer scope, which allows this module to be 999 // injected easily by `bin/regenerator --include-runtime script.js`. 1000 return exports; 1001 1002 }( 1003 // If this script is executing as a CommonJS module, use module.exports 1004 // as the regeneratorRuntime namespace. Otherwise create a new empty 1005 // object. Either way, the resulting object will be used to initialize 1006 // the regeneratorRuntime variable at the top of this file. 1007 typeof module === "object" ? module.exports : {} 1008 )); 1009 1010 try { 1011 regeneratorRuntime = runtime; 1012 } catch (accidentalStrictMode) { 1013 // This module should not be running in strict mode, so the above 1014 // assignment should always work unless something is misconfigured. Just 1015 // in case runtime.js accidentally runs in strict mode, we can escape 1016 // strict mode using a global Function call. This could conceivably fail 1017 // if a Content Security Policy forbids using Function, but in that case 1018 // the proper solution is to fix the accidental strict mode problem. If 1019 // you've misconfigured your bundler to force strict mode and applied a 1020 // CSP to forbid Function, and you're not willing to fix either of those 1021 // problems, please detail your unique predicament in a GitHub issue. 1022 Function("r", "regeneratorRuntime = r")(runtime); 1023 } 1024 1025 },{}],"BxGn":[function(require,module,exports) { 1026 module.exports = require("regenerator-runtime"); 1027 1028 },{"regenerator-runtime":"rqzK"}],"SaI5":[function(require,module,exports) { 214 },{"./action-types":"gg2v"}],"SaI5":[function(require,module,exports) { 1029 215 "use strict"; 1030 216 1031 217 Object.defineProperty(exports, "__esModule", { … … Object.defineProperty(exports, "__esModule", { 1033 219 }); 1034 220 exports.getActiveComponents = getActiveComponents; 1035 221 1036 var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));1037 1038 222 var _actions = require("./actions"); 1039 223 1040 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1041 1042 var _marked = /*#__PURE__*/_regenerator.default.mark(getActiveComponents); 224 /** 225 * Internal dependencies. 226 */ 1043 227 1044 228 /** 1045 229 * Resolver for retrieving active BP Components. 1046 230 */ 1047 function getActiveComponents() { 1048 var list; 1049 return _regenerator.default.wrap(function getActiveComponents$(_context) { 1050 while (1) { 1051 switch (_context.prev = _context.next) { 1052 case 0: 1053 _context.next = 2; 1054 return (0, _actions.fetchFromAPI)('/buddypress/v1/components?status=active', true); 1055 1056 case 2: 1057 list = _context.sent; 1058 _context.next = 5; 1059 return (0, _actions.getActiveComponents)(list); 1060 1061 case 5: 1062 case "end": 1063 return _context.stop(); 1064 } 1065 } 1066 }, _marked); 231 function* getActiveComponents() { 232 const list = yield (0, _actions.fetchFromAPI)('/buddypress/v1/components?status=active', true); 233 yield (0, _actions.getActiveComponents)(list); 1067 234 } 1068 },{"@babel/runtime/regenerator":"BxGn","./actions":"NTbX"}],"cQfh":[function(require,module,exports) { 1069 function _defineProperty(obj, key, value) { 1070 if (key in obj) { 1071 Object.defineProperty(obj, key, { 1072 value: value, 1073 enumerable: true, 1074 configurable: true, 1075 writable: true 1076 }); 1077 } else { 1078 obj[key] = value; 1079 } 1080 1081 return obj; 1082 } 1083 1084 module.exports = _defineProperty; 1085 },{}],"yrui":[function(require,module,exports) { 235 },{"./actions":"NTbX"}],"yrui":[function(require,module,exports) { 1086 236 "use strict"; 1087 237 1088 238 Object.defineProperty(exports, "__esModule", { … … Object.defineProperty(exports, "__esModule", { 1090 240 }); 1091 241 exports.default = void 0; 1092 242 1093 var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));1094 1095 243 var _actionTypes = require("./action-types"); 1096 244 1097 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1098 1099 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } 1100 1101 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 245 /** 246 * Internal dependencies 247 */ 1102 248 1103 249 /** 1104 250 * Default state. 1105 251 */ 1106 varDEFAULT_STATE = {252 const DEFAULT_STATE = { 1107 253 components: [] 1108 254 }; 1109 255 /** … … var DEFAULT_STATE = { 1115 261 * @return {Object} New or existing state. 1116 262 */ 1117 263 1118 var reducer = function reducer() { 1119 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATE; 1120 var action = arguments.length > 1 ? arguments[1] : undefined; 1121 264 const reducer = (state = DEFAULT_STATE, action) => { 1122 265 switch (action.type) { 1123 266 case _actionTypes.TYPES.GET_ACTIVE_COMPONENTS: 1124 return _objectSpread(_objectSpread({}, state), {}, {267 return { ...state, 1125 268 components: action.list 1126 } );269 }; 1127 270 } 1128 271 1129 272 return state; … … var reducer = function reducer() { 1131 274 1132 275 var _default = reducer; 1133 276 exports.default = _default; 1134 },{" @babel/runtime/helpers/defineProperty":"cQfh","./action-types":"gg2v"}],"KdPQ":[function(require,module,exports) {277 },{"./action-types":"gg2v"}],"KdPQ":[function(require,module,exports) { 1135 278 "use strict"; 1136 279 1137 280 Object.defineProperty(exports, "__esModule", { … … exports.controls = void 0; 1142 285 /** 1143 286 * WordPress dependencies. 1144 287 */ 1145 var _wp = wp, 1146 apiFetch = _wp.apiFetch; 288 const { 289 apiFetch 290 } = wp; 1147 291 /** 1148 292 * Default export for registering the controls with the store. 1149 293 * … … var _wp = wp, 1151 295 * the controls property of the registration object. 1152 296 */ 1153 297 1154 var controls = { 1155 FETCH_FROM_API: function FETCH_FROM_API(_ref) { 1156 var path = _ref.path, 1157 parse = _ref.parse; 298 const controls = { 299 FETCH_FROM_API({ 300 path, 301 parse 302 }) { 1158 303 return apiFetch({ 1159 path : path,1160 parse : parse304 path, 305 parse 1161 306 }); 1162 307 } 308 1163 309 }; 1164 310 exports.controls = controls; 1165 311 },{}],"QFc2":[function(require,module,exports) { … … function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && 1191 337 /** 1192 338 * WordPress dependencies. 1193 339 */ 1194 var _wp = wp, 1195 registerStore = _wp.data.registerStore; 340 const { 341 data: { 342 registerStore 343 } 344 } = wp; 1196 345 /** 1197 346 * Internal dependencies. 1198 347 */ 1199 348 1200 349 registerStore(_constants.STORE_KEY, { 1201 350 reducer: _reducers.default, 1202 actions : actions,1203 selectors : selectors,351 actions, 352 selectors, 1204 353 controls: _controls.controls, 1205 resolvers : resolvers354 resolvers 1206 355 }); 1207 varBP_CORE_STORE_KEY = _constants.STORE_KEY;356 const BP_CORE_STORE_KEY = _constants.STORE_KEY; 1208 357 exports.BP_CORE_STORE_KEY = BP_CORE_STORE_KEY; 1209 358 var _default = BP_CORE_STORE_KEY; 1210 359 exports.default = _default; … … exports.currentPostId = currentPostId; 1222 371 exports.getCurrentWidgetsSidebar = getCurrentWidgetsSidebar; 1223 372 exports.default = void 0; 1224 373 1225 var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));1226 1227 374 var _register = _interopRequireDefault(require("./register")); 1228 375 1229 376 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 1231 378 /** 1232 379 * WordPress dependencies. 1233 380 */ 1234 var _wp = wp, 1235 useSelect = _wp.data.useSelect; 381 const { 382 data: { 383 useSelect 384 } 385 } = wp; 1236 386 /** 1237 387 * External dependencies. 1238 388 */ 1239 389 1240 var _lodash = lodash, 1241 find = _lodash.find, 1242 get = _lodash.get; 390 const { 391 find, 392 get 393 } = lodash; 1243 394 /** 1244 395 * Internal dependencies. 1245 396 */ … … var _lodash = lodash, 1253 404 * @param {string} feature (optional) The feature to check. 1254 405 * @return {boolean} Whether a component or the feature of an active component is enabled. 1255 406 */ 1256 function isActive(component) { 1257 var feature = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 1258 var components = useSelect(function (select) { 407 function isActive(component, feature = '') { 408 const components = useSelect(select => { 1259 409 return select(_register.default).getActiveComponents(); 1260 410 }, []); 1261 varactiveComponent = find(components, ['name', component]);411 const activeComponent = find(components, ['name', component]); 1262 412 1263 413 if (!feature) { 1264 414 return !!activeComponent; … … var _default = isActive; 1279 429 exports.default = _default; 1280 430 1281 431 function activityTypes() { 1282 var components = useSelect(function (select){432 const components = useSelect(select => { 1283 433 return select(_register.default).getActiveComponents(); 1284 434 }, []); 1285 varactivityComponent = find(components, ['name', 'activity']);435 const activityComponent = find(components, ['name', 'activity']); 1286 436 1287 437 if (!activityComponent) { 1288 438 return []; 1289 439 } 1290 440 1291 var activityTypes = get(activityComponent, ['features', 'types']); 1292 var activityTypesList = []; 1293 Object.entries(activityTypes).forEach(function (_ref) { 1294 var _ref2 = (0, _slicedToArray2.default)(_ref, 2), 1295 type = _ref2[0], 1296 label = _ref2[1]; 1297 441 const activityTypes = get(activityComponent, ['features', 'types']); 442 let activityTypesList = []; 443 Object.entries(activityTypes).forEach(([type, label]) => { 1298 444 activityTypesList.push({ 1299 445 label: label, 1300 446 value: type … … function activityTypes() { 1312 458 1313 459 1314 460 function loggedInUser() { 1315 var loggedInUser = useSelect(function (select){1316 varstore = select('core');461 const loggedInUser = useSelect(select => { 462 const store = select('core'); 1317 463 1318 464 if (store) { 1319 465 return select('core').getCurrentUser(); … … function loggedInUser() { 1333 479 1334 480 1335 481 function postAuhor() { 1336 var postAuhor = useSelect(function (select){1337 vareditorStore = select('core/editor');1338 varcoreStore = select('core');482 const postAuhor = useSelect(select => { 483 const editorStore = select('core/editor'); 484 const coreStore = select('core'); 1339 485 1340 486 if (editorStore && coreStore) { 1341 varpostAuthorId = editorStore.getCurrentPostAttribute('author');1342 varauthorsList = coreStore.getAuthors();487 const postAuthorId = editorStore.getCurrentPostAttribute('author'); 488 const authorsList = coreStore.getAuthors(); 1343 489 return find(authorsList, ['id', postAuthorId]); 1344 490 } 1345 491 … … function postAuhor() { 1357 503 1358 504 1359 505 function currentPostId() { 1360 var currentPostId = useSelect(function (select){1361 varstore = select('core/editor');506 const currentPostId = useSelect(select => { 507 const store = select('core/editor'); 1362 508 1363 509 if (store) { 1364 510 return store.getCurrentPostId(); … … function currentPostId() { 1378 524 */ 1379 525 1380 526 1381 function getCurrentWidgetsSidebar() { 1382 var widgetClientId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 1383 var currentWidgetsSidebar = useSelect(function (select) { 1384 var blockEditorStore = select('core/block-editor'); 1385 var widgetsStore = select('core/edit-widgets'); 527 function getCurrentWidgetsSidebar(widgetClientId = '') { 528 const currentWidgetsSidebar = useSelect(select => { 529 const blockEditorStore = select('core/block-editor'); 530 const widgetsStore = select('core/edit-widgets'); 1386 531 1387 532 if (widgetClientId && widgetsStore && blockEditorStore) { 1388 var areas = blockEditorStore.getBlocks(); 1389 var parents = blockEditorStore.getBlockParents(widgetClientId); 1390 var sidebars = []; 1391 areas.forEach(function (_ref3) { 1392 var clientId = _ref3.clientId, 1393 attributes = _ref3.attributes; 533 const areas = blockEditorStore.getBlocks(); 534 const parents = blockEditorStore.getBlockParents(widgetClientId); 535 let sidebars = []; 536 areas.forEach(({ 537 clientId, 538 attributes 539 }) => { 1394 540 sidebars.push({ 1395 541 id: attributes.id, 1396 542 isCurrent: -1 !== parents.indexOf(clientId) … … function getCurrentWidgetsSidebar() { 1403 549 }, []); 1404 550 return currentWidgetsSidebar; 1405 551 } 1406 },{" @babel/runtime/helpers/slicedToArray":"DERy","./register":"QFc2"}],"xHVY":[function(require,module,exports) {552 },{"./register":"QFc2"}],"xHVY":[function(require,module,exports) { 1407 553 "use strict"; 1408 554 1409 555 Object.defineProperty(exports, "__esModule", { -
src/bp-core/js/blocks/login-form.js
diff --git src/bp-core/js/blocks/login-form.js src/bp-core/js/blocks/login-form.js index 5f9eb3d0a..1fc1d0fa0 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 PanelBody = _wp$components.PanelBody, 136 TextControl = _wp$components.TextControl, 137 ToggleControl = _wp$components.ToggleControl, 138 _wp$element = _wp.element, 139 Fragment = _wp$element.Fragment, 140 createElement = _wp$element.createElement, 141 __ = _wp.i18n.__; 142 /** 143 * BuddyPress dependencies. 144 */ 145 146 var _bp = bp, 147 ServerSideRender = _bp.blockComponents.ServerSideRender; 148 149 var editLoginForm = function editLoginForm(_ref) { 150 var attributes = _ref.attributes, 151 setAttributes = _ref.setAttributes; 152 var title = attributes.title, 153 forgotPwdLink = attributes.forgotPwdLink; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 PanelBody, 138 TextControl, 139 ToggleControl 140 }, 141 element: { 142 Fragment, 143 createElement 144 }, 145 i18n: { 146 __ 147 }, 148 serverSideRender: ServerSideRender 149 } = wp; 150 151 const editLoginForm = ({ 152 attributes, 153 setAttributes 154 }) => { 155 const { 156 title, 157 forgotPwdLink 158 } = attributes; 154 159 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 155 160 title: __('Settings', 'buddypress'), 156 161 initialOpen: true 157 162 }, createElement(TextControl, { 158 163 label: __('Title', 'buddypress'), 159 164 value: title, 160 onChange: function onChange(text){165 onChange: text => { 161 166 setAttributes({ 162 167 title: text 163 168 }); … … var editLoginForm = function editLoginForm(_ref) { 165 170 }), createElement(ToggleControl, { 166 171 label: __('Include the link to reset the user password', 'buddypress'), 167 172 checked: !!forgotPwdLink, 168 onChange: function onChange(){173 onChange: () => { 169 174 setAttributes({ 170 175 forgotPwdLink: !forgotPwdLink 171 176 }); … … exports.default = void 0; 189 194 /** 190 195 * WordPress dependencies. 191 196 */ 192 var _wp = wp, 193 createBlock = _wp.blocks.createBlock; 197 const { 198 blocks: { 199 createBlock 200 } 201 } = wp; 194 202 /** 195 203 * Transforms Legacy Login Form Widget to Login Form Block. 196 204 * 197 205 * @type {Object} 198 206 */ 199 207 200 vartransforms = {208 const transforms = { 201 209 from: [{ 202 210 type: 'block', 203 211 blocks: ['core/legacy-widget'], 204 isMatch: function isMatch(_ref){205 var idBase = _ref.idBase,206 instance = _ref.instance;207 212 isMatch: ({ 213 idBase, 214 instance 215 }) => { 208 216 if (!(instance !== null && instance !== void 0 && instance.raw)) { 209 217 return false; 210 218 } 211 219 212 220 return idBase === 'bp_core_login_widget'; 213 221 }, 214 transform: function transform(_ref2) { 215 var instance = _ref2.instance; 222 transform: ({ 223 instance 224 }) => { 216 225 return createBlock('bp/login-form', { 217 226 title: instance.raw.title 218 227 }); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 233 242 /** 234 243 * WordPress dependencies. 235 244 */ 236 var _wp = wp, 237 registerBlockType = _wp.blocks.registerBlockType, 238 __ = _wp.i18n.__; 245 const { 246 blocks: { 247 registerBlockType 248 }, 249 i18n: { 250 __ 251 } 252 } = wp; 239 253 /** 240 254 * Internal dependencies. 241 255 */ -
src/bp-core/js/blocks/primary-nav.js
diff --git src/bp-core/js/blocks/primary-nav.js src/bp-core/js/blocks/primary-nav.js index 67b40d2d0..adb34d270 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 Notice = _wp$components.Notice, 136 PanelBody = _wp$components.PanelBody, 137 ToggleControl = _wp$components.ToggleControl, 138 _wp$element = _wp.element, 139 Fragment = _wp$element.Fragment, 140 createElement = _wp$element.createElement, 141 __ = _wp.i18n.__; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 Notice, 138 PanelBody, 139 ToggleControl 140 }, 141 element: { 142 Fragment, 143 createElement 144 }, 145 i18n: { 146 __ 147 }, 148 serverSideRender: ServerSideRender 149 } = wp; 142 150 /** 143 151 * BuddyPress dependencies. 144 152 */ 145 153 146 var _bp = bp, 147 ServerSideRender = _bp.blockComponents.ServerSideRender, 148 getCurrentWidgetsSidebar = _bp.blockData.getCurrentWidgetsSidebar; 149 150 var editPrimaryNavBlock = function editPrimaryNavBlock(_ref) { 151 var attributes = _ref.attributes, 152 setAttributes = _ref.setAttributes, 153 clientId = _ref.clientId; 154 var displayTitle = attributes.displayTitle; 155 var currentSidebar = getCurrentWidgetsSidebar(clientId); 156 var disabledSidebars = ['sidebar-buddypress-members', 'sidebar-buddypress-groups']; 154 const { 155 blockData: { 156 getCurrentWidgetsSidebar 157 } 158 } = bp; 159 160 const editPrimaryNavBlock = ({ 161 attributes, 162 setAttributes, 163 clientId 164 }) => { 165 const { 166 displayTitle 167 } = attributes; 168 const currentSidebar = getCurrentWidgetsSidebar(clientId); 169 const disabledSidebars = ['sidebar-buddypress-members', 'sidebar-buddypress-groups']; 157 170 158 171 if (currentSidebar && currentSidebar.id && -1 !== disabledSidebars.indexOf(currentSidebar.id)) { 159 172 return createElement(Notice, { … … var editPrimaryNavBlock = function editPrimaryNavBlock(_ref) { 168 181 }, createElement(ToggleControl, { 169 182 label: __('Include navigation title', 'buddypress'), 170 183 checked: !!displayTitle, 171 onChange: function onChange(){184 onChange: () => { 172 185 setAttributes({ 173 186 displayTitle: !displayTitle 174 187 }); … … exports.default = void 0; 192 205 /** 193 206 * WordPress dependencies. 194 207 */ 195 var _wp = wp, 196 createBlock = _wp.blocks.createBlock; 208 const { 209 blocks: { 210 createBlock 211 } 212 } = wp; 197 213 /** 198 214 * Transforms Legacy Widget to Primary Nav Block. 199 215 * 200 216 * @type {Object} 201 217 */ 202 218 203 vartransforms = {219 const transforms = { 204 220 from: [{ 205 221 type: 'block', 206 222 blocks: ['core/legacy-widget'], 207 isMatch: function isMatch(_ref){208 var idBase = _ref.idBase,209 instance = _ref.instance;210 223 isMatch: ({ 224 idBase, 225 instance 226 }) => { 211 227 if (!(instance !== null && instance !== void 0 && instance.raw)) { 212 228 return false; 213 229 } 214 230 215 231 return idBase === 'bp_nouveau_sidebar_object_nav_widget'; 216 232 }, 217 transform: function transform(_ref2) { 218 var instance = _ref2.instance; 233 transform: ({ 234 instance 235 }) => { 219 236 return createBlock('bp/primary-nav', { 220 237 displayTitle: instance.raw.bp_nouveau_widget_title 221 238 }); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 236 253 /** 237 254 * WordPress dependencies. 238 255 */ 239 var _wp = wp, 240 registerBlockType = _wp.blocks.registerBlockType, 241 __ = _wp.i18n.__; 256 const { 257 blocks: { 258 registerBlockType 259 }, 260 i18n: { 261 __ 262 } 263 } = wp; 242 264 /** 243 265 * Internal dependencies. 244 266 */ -
src/bp-core/js/dynamic-widget-block.js
diff --git src/bp-core/js/dynamic-widget-block.js src/bp-core/js/dynamic-widget-block.js index dfe59fefc..867540738 100644
parcelRequire = (function (modules, cache, entry, globalName) { 118 118 119 119 return newRequire; 120 120 })({"eNhW":[function(require,module,exports) { 121 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }122 123 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }124 125 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }126 127 121 /** 128 122 * WordPress dependencies. 129 123 */ 130 var _wp = wp, 131 addQueryArgs = _wp.url.addQueryArgs; 124 const { 125 url: { 126 addQueryArgs 127 } 128 } = wp; 132 129 /** 133 130 * External dependencies. 134 131 */ 135 132 136 var _lodash = lodash, 137 template = _lodash.template; // Use the bp global. 133 const { 134 template 135 } = lodash; // Use the bp global. 138 136 139 137 window.bp = window.bp || {}; 140 138 /** … … window.bp = window.bp || {}; 143 141 * @since 9.0.0 144 142 */ 145 143 146 bp.dynamicWidgetBlock = /*#__PURE__*/function () { 147 function bpDynamicWidgetBlock(settings, blocks) { 148 var _this = this; 149 150 _classCallCheck(this, bpDynamicWidgetBlock); 151 152 var path = settings.path, 153 root = settings.root, 154 nonce = settings.nonce; 144 bp.dynamicWidgetBlock = class bpDynamicWidgetBlock { 145 constructor(settings, blocks) { 146 const { 147 path, 148 root, 149 nonce 150 } = settings; 155 151 this.path = path; 156 152 this.root = root; 157 153 this.nonce = nonce, this.blocks = blocks; 158 this.blocks.forEach( function (block, i){159 var _ref = block.query_args || 'active',160 type = _ref.type;161 162 var _ref2 = block.preloaded || [],163 body = _ref2.body;164 165 _this.blocks[i].items = {154 this.blocks.forEach((block, i) => { 155 const { 156 type 157 } = block.query_args || 'active'; 158 const { 159 body 160 } = block.preloaded || []; 161 this.blocks[i].items = { 166 162 'active': [], 167 163 'newest': [], 168 164 'popular': [], 169 165 'alphabetical': [] 170 166 }; 171 167 172 if (! _this.blocks[i].items[type].length && body && body.length) {173 _this.blocks[i].items[type] = body;168 if (!this.blocks[i].items[type].length && body && body.length) { 169 this.blocks[i].items[type] = body; 174 170 } 175 171 }); 176 172 } 177 173 178 _createClass(bpDynamicWidgetBlock, [{ 179 key: "useTemplate", 180 value: function useTemplate(tmpl) { 181 var options = { 182 evaluate: /<#([\s\S]+?)#>/g, 183 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g, 184 escape: /\{\{([^\}]+?)\}\}(?!\})/g, 185 variable: 'data' 186 }; 187 return template(document.querySelector('#tmpl-' + tmpl).innerHTML, options); 188 } 189 }, { 190 key: "loop", 191 value: function loop() {// This method needs to be overriden. 192 } 193 }, { 194 key: "getItems", 195 value: function getItems() { 196 var _this2 = this; 174 useTemplate(tmpl) { 175 const options = { 176 evaluate: /<#([\s\S]+?)#>/g, 177 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g, 178 escape: /\{\{([^\}]+?)\}\}(?!\})/g, 179 variable: 'data' 180 }; 181 return template(document.querySelector('#tmpl-' + tmpl).innerHTML, options); 182 } 183 184 loop() {// This method needs to be overriden. 185 } 197 186 198 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'active'; 199 var blockIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 200 this.blocks[blockIndex].query_args.type = type; 187 getItems(type = 'active', blockIndex = 0) { 188 this.blocks[blockIndex].query_args.type = type; 201 189 202 if (this.blocks[blockIndex].items[type].length) { 190 if (this.blocks[blockIndex].items[type].length) { 191 this.loop(this.blocks[blockIndex].items[type], this.blocks[blockIndex].selector, type); 192 } else { 193 fetch(addQueryArgs(this.root + this.path, this.blocks[blockIndex].query_args), { 194 method: 'GET', 195 headers: { 196 'X-WP-Nonce': this.nonce 197 } 198 }).then(response => response.json()).then(data => { 199 this.blocks[blockIndex].items[type] = data; 203 200 this.loop(this.blocks[blockIndex].items[type], this.blocks[blockIndex].selector, type); 204 } else { 205 fetch(addQueryArgs(this.root + this.path, this.blocks[blockIndex].query_args), { 206 method: 'GET', 207 headers: { 208 'X-WP-Nonce': this.nonce 209 } 210 }).then(function (response) { 211 return response.json(); 212 }).then(function (data) { 213 _this2.blocks[blockIndex].items[type] = data; 214 215 _this2.loop(_this2.blocks[blockIndex].items[type], _this2.blocks[blockIndex].selector, type); 216 }); 217 } 201 }); 218 202 } 219 } ]);203 } 220 204 221 return bpDynamicWidgetBlock; 222 }(); 205 }; 223 206 },{}]},{},["eNhW"], null) 207 No newline at end of file -
src/bp-friends/classes/class-bp-friends-component.php
diff --git src/bp-friends/classes/class-bp-friends-component.php src/bp-friends/classes/class-bp-friends-component.php index 287a6f417..aeb6eb70b 100644
class BP_Friends_Component extends BP_Component { 370 370 'wp-components', 371 371 'wp-i18n', 372 372 'wp-block-editor', 373 'wp-server-side-render', 373 374 'bp-block-data', 374 'bp-block-components',375 375 ), 376 376 'style' => 'bp-friends-block', 377 377 'style_url' => plugins_url( 'css/blocks/friends.css', dirname( __FILE__ ) ), -
src/bp-friends/js/blocks/friends.js
diff --git src/bp-friends/js/blocks/friends.js src/bp-friends/js/blocks/friends.js index 611ea18c8..d5b81cd0e 100644
exports.TYPES = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 133 136 /** 134 137 * Friends ordering types. 135 138 * 136 139 * @type {Array} 137 140 */ 138 141 139 varTYPES = [{142 const TYPES = [{ 140 143 label: __('Newest', 'buddypress'), 141 144 value: 'newest' 142 145 }, { … … var _constants = require("./constants"); 160 163 /** 161 164 * WordPress dependencies. 162 165 */ 163 var _wp = wp, 164 InspectorControls = _wp.blockEditor.InspectorControls, 165 _wp$components = _wp.components, 166 Disabled = _wp$components.Disabled, 167 PanelBody = _wp$components.PanelBody, 168 RangeControl = _wp$components.RangeControl, 169 SelectControl = _wp$components.SelectControl, 170 ToggleControl = _wp$components.ToggleControl, 171 _wp$element = _wp.element, 172 Fragment = _wp$element.Fragment, 173 createElement = _wp$element.createElement, 174 __ = _wp.i18n.__; 166 const { 167 blockEditor: { 168 InspectorControls 169 }, 170 components: { 171 Disabled, 172 PanelBody, 173 RangeControl, 174 SelectControl, 175 ToggleControl 176 }, 177 element: { 178 Fragment, 179 createElement 180 }, 181 i18n: { 182 __ 183 }, 184 serverSideRender: ServerSideRender 185 } = wp; 175 186 /** 176 187 * BuddyPress dependencies. 177 188 */ 178 189 179 var _bp = bp, 180 ServerSideRender = _bp.blockComponents.ServerSideRender, 181 currentPostId = _bp.blockData.currentPostId; 190 const { 191 blockData: { 192 currentPostId 193 } 194 } = bp; 182 195 /** 183 196 * Internal dependencies. 184 197 */ 185 198 186 var editDynamicFriendsBlock = function editDynamicFriendsBlock(_ref) { 187 var attributes = _ref.attributes, 188 setAttributes = _ref.setAttributes; 189 var postId = attributes.postId, 190 maxFriends = attributes.maxFriends, 191 friendDefault = attributes.friendDefault, 192 linkTitle = attributes.linkTitle; 193 var post = currentPostId(); 199 const editDynamicFriendsBlock = ({ 200 attributes, 201 setAttributes 202 }) => { 203 const { 204 postId, 205 maxFriends, 206 friendDefault, 207 linkTitle 208 } = attributes; 209 const post = currentPostId(); 194 210 195 211 if (!postId && post) { 196 212 setAttributes({ … … var editDynamicFriendsBlock = function editDynamicFriendsBlock(_ref) { 204 220 }, createElement(RangeControl, { 205 221 label: __('Max friends to show', 'buddypress'), 206 222 value: maxFriends, 207 onChange: function onChange(value) { 208 return setAttributes({ 209 maxFriends: value 210 }); 211 }, 223 onChange: value => setAttributes({ 224 maxFriends: value 225 }), 212 226 min: 1, 213 227 max: 10, 214 228 required: true … … var editDynamicFriendsBlock = function editDynamicFriendsBlock(_ref) { 216 230 label: __('Default members to show', 'buddypress'), 217 231 value: friendDefault, 218 232 options: _constants.TYPES, 219 onChange: function onChange(option){233 onChange: option => { 220 234 setAttributes({ 221 235 friendDefault: option 222 236 }); … … var editDynamicFriendsBlock = function editDynamicFriendsBlock(_ref) { 224 238 }), createElement(ToggleControl, { 225 239 label: __('Link block title to Member\'s profile friends page', 'buddypress'), 226 240 checked: !!linkTitle, 227 onChange: function onChange(){241 onChange: () => { 228 242 setAttributes({ 229 243 linkTitle: !linkTitle 230 244 }); … … exports.default = void 0; 248 262 /** 249 263 * WordPress dependencies. 250 264 */ 251 var _wp = wp, 252 createBlock = _wp.blocks.createBlock; 265 const { 266 blocks: { 267 createBlock 268 } 269 } = wp; 253 270 /** 254 271 * Transforms Legacy Widget to Friends Block. 255 272 * 256 273 * @type {Object} 257 274 */ 258 275 259 vartransforms = {276 const transforms = { 260 277 from: [{ 261 278 type: 'block', 262 279 blocks: ['core/legacy-widget'], 263 isMatch: function isMatch(_ref){264 var idBase = _ref.idBase,265 instance = _ref.instance;266 280 isMatch: ({ 281 idBase, 282 instance 283 }) => { 267 284 if (!(instance !== null && instance !== void 0 && instance.raw)) { 268 285 return false; 269 286 } 270 287 271 288 return idBase === 'bp_core_friends_widget'; 272 289 }, 273 transform: function transform(_ref2) { 274 var instance = _ref2.instance; 290 transform: ({ 291 instance 292 }) => { 275 293 return createBlock('bp/friends', { 276 294 maxFriends: instance.raw.max_friends, 277 295 friendDefault: instance.raw.friend_default, … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 294 312 /** 295 313 * WordPress dependencies. 296 314 */ 297 var _wp = wp, 298 registerBlockType = _wp.blocks.registerBlockType, 299 __ = _wp.i18n.__; 315 const { 316 blocks: { 317 registerBlockType 318 }, 319 i18n: { 320 __ 321 } 322 } = wp; 300 323 /** 301 324 * Internal dependencies. 302 325 */ -
src/bp-friends/js/friends.js
diff --git src/bp-friends/js/friends.js src/bp-friends/js/friends.js index 93de95628..359827b35 100644
parcelRequire = (function (modules, cache, entry, globalName) { 118 118 119 119 return newRequire; 120 120 })({"pMhP":[function(require,module,exports) { 121 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }122 123 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }124 125 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }126 127 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }128 129 function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }130 131 function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }132 133 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }134 135 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }136 137 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }138 139 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }140 141 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }142 143 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }144 145 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }146 147 121 /** 148 122 * WordPress dependencies. 149 123 */ 150 var _wp = wp, 151 _wp$i18n = _wp.i18n, 152 __ = _wp$i18n.__, 153 sprintf = _wp$i18n.sprintf; 124 const { 125 i18n: { 126 __, 127 sprintf 128 } 129 } = wp; 154 130 /** 155 131 * BuddyPress dependencies. 156 132 */ 157 133 158 var _bp = bp, 159 dynamicWidgetBlock = _bp.dynamicWidgetBlock; 134 const { 135 dynamicWidgetBlock 136 } = bp; 160 137 /** 161 138 * Front-end Friends block class. 162 139 */ 163 140 164 var bpFriendsWidgetBlock = /*#__PURE__*/function (_dynamicWidgetBlock) { 165 _inherits(bpFriendsWidgetBlock, _dynamicWidgetBlock); 166 167 var _super = _createSuper(bpFriendsWidgetBlock); 168 169 function bpFriendsWidgetBlock() { 170 _classCallCheck(this, bpFriendsWidgetBlock); 171 172 return _super.apply(this, arguments); 173 } 174 175 _createClass(bpFriendsWidgetBlock, [{ 176 key: "loop", 177 value: function loop() { 178 var friends = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 179 var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 180 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'active'; 181 182 var tmpl = _get(_getPrototypeOf(bpFriendsWidgetBlock.prototype), "useTemplate", this).call(this, 'bp-friends-item'); 183 184 var selector = document.querySelector('#' + container); 185 var output = ''; 186 187 if (friends && friends.length) { 188 friends.forEach(function (friend) { 189 if ('active' === type && friend.last_activity) { 190 /* translators: %s: a human time diff. */ 191 friend.extra = sprintf(__('Active %s', 'buddypress'), friend.last_activity.timediff); 192 } else if ('popular' === type && friend.total_friend_count) { 193 var friendsCount = parseInt(friend.total_friend_count, 10); 194 195 if (0 === friendsCount) { 196 friend.extra = __('No friends', 'buddypress'); 197 } else if (1 === friendsCount) { 198 friend.extra = __('1 friend', 'buddypress'); 199 } else { 200 /* translators: %s: total friend count (more than 1). */ 201 friend.extra = sprintf(__('%s friends', 'buddypress'), friend.total_friend_count); 202 } 203 } else if ('newest' === type && friend.registered_since) { 204 /* translators: %s is time elapsed since the registration date happened */ 205 friend.extra = sprintf(__('Registered %s', 'buddypress'), friend.registered_since); 141 class bpFriendsWidgetBlock extends dynamicWidgetBlock { 142 loop(friends = [], container = '', type = 'active') { 143 const tmpl = super.useTemplate('bp-friends-item'); 144 const selector = document.querySelector('#' + container); 145 let output = ''; 146 147 if (friends && friends.length) { 148 friends.forEach(friend => { 149 if ('active' === type && friend.last_activity) { 150 /* translators: %s: a human time diff. */ 151 friend.extra = sprintf(__('Active %s', 'buddypress'), friend.last_activity.timediff); 152 } else if ('popular' === type && friend.total_friend_count) { 153 const friendsCount = parseInt(friend.total_friend_count, 10); 154 155 if (0 === friendsCount) { 156 friend.extra = __('No friends', 'buddypress'); 157 } else if (1 === friendsCount) { 158 friend.extra = __('1 friend', 'buddypress'); 159 } else { 160 /* translators: %s: total friend count (more than 1). */ 161 friend.extra = sprintf(__('%s friends', 'buddypress'), friend.total_friend_count); 206 162 } 207 /* translators: %s: member name */ 208 163 } else if ('newest' === type && friend.registered_since) { 164 /* translators: %s is time elapsed since the registration date happened */ 165 friend.extra = sprintf(__('Registered %s', 'buddypress'), friend.registered_since); 166 } 167 /* translators: %s: member name */ 209 168 210 friend.avatar_alt = sprintf(__('Profile picture of %s', 'buddypress'), friend.name);211 output += tmpl(friend);212 });213 } else {214 output = '<div class="widget-error">' + __('Sorry, no members were found.', 'buddypress') + '</div>';215 }216 169 217 selector.innerHTML = output; 170 friend.avatar_alt = sprintf(__('Profile picture of %s', 'buddypress'), friend.name); 171 output += tmpl(friend); 172 }); 173 } else { 174 output = '<div class="widget-error">' + __('Sorry, no members were found.', 'buddypress') + '</div>'; 218 175 } 219 }, {220 key: "start",221 value: function start() {222 var _this = this;223 176 224 this.blocks.forEach(function (block, i) { 225 var selector = block.selector; 226 var type = block.query_args.type; 227 var list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type friends. 177 selector.innerHTML = output; 178 } 228 179 229 _get(_getPrototypeOf(bpFriendsWidgetBlock.prototype), "getItems", _this).call(_this, type, i); // Listen to Block's Nav item clics 180 start() { 181 this.blocks.forEach((block, i) => { 182 const { 183 selector 184 } = block; 185 const { 186 type 187 } = block.query_args; 188 const list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type friends. 230 189 190 super.getItems(type, i); // Listen to Block's Nav item clics 231 191 232 list.querySelectorAll('.item-options a').forEach(function (navItem){233 navItem.addEventListener('click', function (event){234 192 list.querySelectorAll('.item-options a').forEach(navItem => { 193 navItem.addEventListener('click', event => { 194 event.preventDefault(); // Changes the displayed filter. 235 195 236 237 238 varnewType = event.target.getAttribute('data-bp-sort');196 event.target.closest('.item-options').querySelector('.selected').classList.remove('selected'); 197 event.target.classList.add('selected'); 198 const newType = event.target.getAttribute('data-bp-sort'); 239 199 240 if (newType !== _this.blocks[i].query_args.type) { 241 _get(_getPrototypeOf(bpFriendsWidgetBlock.prototype), "getItems", _this).call(_this, newType, i); 242 } 243 }); 200 if (newType !== this.blocks[i].query_args.type) { 201 super.getItems(newType, i); 202 } 244 203 }); 245 204 }); 246 } 247 } ]);205 }); 206 } 248 207 249 return bpFriendsWidgetBlock; 250 }(dynamicWidgetBlock); 208 } 251 209 252 varsettings = window.bpFriendsSettings || {};253 varblocks = window.bpFriendsBlocks || {};254 varbpFriends = new bpFriendsWidgetBlock(settings, blocks);210 const settings = window.bpFriendsSettings || {}; 211 const blocks = window.bpFriendsBlocks || {}; 212 const bpFriends = new bpFriendsWidgetBlock(settings, blocks); 255 213 256 214 if ('loading' === document.readyState) { 257 215 document.addEventListener('DOMContentLoaded', bpFriends.start()); -
src/bp-groups/classes/class-bp-groups-component.php
diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php index b272b3bdb..8f771c7d0 100644
class BP_Groups_Component extends BP_Component { 1018 1018 'wp-components', 1019 1019 'wp-i18n', 1020 1020 'wp-block-editor', 1021 'wp-server-side-render', 1021 1022 'bp-block-components', 1022 1023 'bp-block-data', 1023 1024 ), … … class BP_Groups_Component extends BP_Component { 1107 1108 'wp-components', 1108 1109 'wp-i18n', 1109 1110 'wp-block-editor', 1110 ' bp-block-components',1111 'wp-server-side-render', 1111 1112 ), 1112 1113 'style' => 'bp-dynamic-groups-block', 1113 1114 'style_url' => plugins_url( 'css/blocks/dynamic-groups.css', dirname( __FILE__ ) ), -
src/bp-groups/js/blocks/dynamic-groups.js
diff --git src/bp-groups/js/blocks/dynamic-groups.js src/bp-groups/js/blocks/dynamic-groups.js index ed9e2a31e..e4f636006 100644
exports.TYPES = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 133 136 /** 134 137 * Groups ordering types. 135 138 * 136 139 * @type {Array} 137 140 */ 138 141 139 varTYPES = [{142 const TYPES = [{ 140 143 label: __('Newest', 'buddypress'), 141 144 value: 'newest' 142 145 }, { … … var _constants = require("./constants"); 163 166 /** 164 167 * WordPress dependencies. 165 168 */ 166 var _wp = wp, 167 InspectorControls = _wp.blockEditor.InspectorControls, 168 _wp$components = _wp.components, 169 Disabled = _wp$components.Disabled, 170 PanelBody = _wp$components.PanelBody, 171 RangeControl = _wp$components.RangeControl, 172 SelectControl = _wp$components.SelectControl, 173 TextControl = _wp$components.TextControl, 174 ToggleControl = _wp$components.ToggleControl, 175 _wp$element = _wp.element, 176 Fragment = _wp$element.Fragment, 177 createElement = _wp$element.createElement, 178 __ = _wp.i18n.__; 179 /** 180 * BuddyPress dependencies. 181 */ 182 183 var _bp = bp, 184 ServerSideRender = _bp.blockComponents.ServerSideRender; 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; 185 190 /** 186 191 * Internal dependencies. 187 192 */ 188 193 189 var editDynamicGroupsBlock = function editDynamicGroupsBlock(_ref) { 190 var attributes = _ref.attributes, 191 setAttributes = _ref.setAttributes; 192 var title = attributes.title, 193 maxGroups = attributes.maxGroups, 194 groupDefault = attributes.groupDefault, 195 linkTitle = attributes.linkTitle; 194 const editDynamicGroupsBlock = ({ 195 attributes, 196 setAttributes 197 }) => { 198 const { 199 title, 200 maxGroups, 201 groupDefault, 202 linkTitle 203 } = attributes; 196 204 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 197 205 title: __('Settings', 'buddypress'), 198 206 initialOpen: true 199 207 }, createElement(TextControl, { 200 208 label: __('Title', 'buddypress'), 201 209 value: title, 202 onChange: function onChange(text){210 onChange: text => { 203 211 setAttributes({ 204 212 title: text 205 213 }); … … var editDynamicGroupsBlock = function editDynamicGroupsBlock(_ref) { 207 215 }), createElement(RangeControl, { 208 216 label: __('Max groups to show', 'buddypress'), 209 217 value: maxGroups, 210 onChange: function onChange(value) { 211 return setAttributes({ 212 maxGroups: value 213 }); 214 }, 218 onChange: value => setAttributes({ 219 maxGroups: value 220 }), 215 221 min: 1, 216 222 max: 10, 217 223 required: true … … var editDynamicGroupsBlock = function editDynamicGroupsBlock(_ref) { 219 225 label: __('Default groups to show', 'buddypress'), 220 226 value: groupDefault, 221 227 options: _constants.TYPES, 222 onChange: function onChange(option){228 onChange: option => { 223 229 setAttributes({ 224 230 groupDefault: option 225 231 }); … … var editDynamicGroupsBlock = function editDynamicGroupsBlock(_ref) { 227 233 }), createElement(ToggleControl, { 228 234 label: __('Link block title to Groups directory', 'buddypress'), 229 235 checked: !!linkTitle, 230 onChange: function onChange(){236 onChange: () => { 231 237 setAttributes({ 232 238 linkTitle: !linkTitle 233 239 }); … … exports.default = void 0; 251 257 /** 252 258 * WordPress dependencies. 253 259 */ 254 var _wp = wp, 255 createBlock = _wp.blocks.createBlock; 260 const { 261 blocks: { 262 createBlock 263 } 264 } = wp; 256 265 /** 257 266 * Transforms Legacy Widget to Dynamic Groups Block. 258 267 * 259 268 * @type {Object} 260 269 */ 261 270 262 vartransforms = {271 const transforms = { 263 272 from: [{ 264 273 type: 'block', 265 274 blocks: ['core/legacy-widget'], 266 isMatch: function isMatch(_ref){267 var idBase = _ref.idBase,268 instance = _ref.instance;269 275 isMatch: ({ 276 idBase, 277 instance 278 }) => { 270 279 if (!(instance !== null && instance !== void 0 && instance.raw)) { 271 280 return false; 272 281 } 273 282 274 283 return idBase === 'bp_groups_widget'; 275 284 }, 276 transform: function transform(_ref2) { 277 var instance = _ref2.instance; 285 transform: ({ 286 instance 287 }) => { 278 288 return createBlock('bp/dynamic-groups', { 279 289 title: instance.raw.title, 280 290 maxGroups: instance.raw.max_groups, … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 298 308 /** 299 309 * WordPress dependencies. 300 310 */ 301 var _wp = wp, 302 registerBlockType = _wp.blocks.registerBlockType, 303 __ = _wp.i18n.__; 311 const { 312 blocks: { 313 registerBlockType 314 }, 315 i18n: { 316 __ 317 } 318 } = wp; 304 319 /** 305 320 * Internal dependencies. 306 321 */ -
src/bp-groups/js/blocks/group.js
diff --git src/bp-groups/js/blocks/group.js src/bp-groups/js/blocks/group.js index 0e3c7aafe..6ffee4cd5 100644
exports.GROUP_STATI = exports.AVATAR_SIZES = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 133 136 /** 134 137 * Avatar sizes. 135 138 * 136 139 * @type {Array} 137 140 */ 138 141 139 varAVATAR_SIZES = [{142 const AVATAR_SIZES = [{ 140 143 label: __('None', 'buddypress'), 141 144 value: 'none' 142 145 }, { … … var AVATAR_SIZES = [{ 153 156 */ 154 157 155 158 exports.AVATAR_SIZES = AVATAR_SIZES; 156 varGROUP_STATI = {159 const GROUP_STATI = { 157 160 public: __('Public', 'buddypress'), 158 161 private: __('Private', 'buddypress'), 159 162 hidden: __('Hidden', 'buddypress') … … var _constants = require("./constants"); 172 175 /** 173 176 * WordPress dependencies. 174 177 */ 175 var _wp = wp, 176 _wp$blockEditor = _wp.blockEditor, 177 InspectorControls = _wp$blockEditor.InspectorControls, 178 BlockControls = _wp$blockEditor.BlockControls, 179 _wp$components = _wp.components, 180 Placeholder = _wp$components.Placeholder, 181 Disabled = _wp$components.Disabled, 182 PanelBody = _wp$components.PanelBody, 183 SelectControl = _wp$components.SelectControl, 184 ToggleControl = _wp$components.ToggleControl, 185 Toolbar = _wp$components.Toolbar, 186 ToolbarButton = _wp$components.ToolbarButton, 187 _wp$element = _wp.element, 188 Fragment = _wp$element.Fragment, 189 createElement = _wp$element.createElement, 190 __ = _wp.i18n.__; 178 const { 179 blockEditor: { 180 InspectorControls, 181 BlockControls 182 }, 183 components: { 184 Placeholder, 185 Disabled, 186 PanelBody, 187 SelectControl, 188 ToggleControl, 189 Toolbar, 190 ToolbarButton 191 }, 192 element: { 193 Fragment, 194 createElement 195 }, 196 i18n: { 197 __ 198 }, 199 serverSideRender: ServerSideRender 200 } = wp; 191 201 /** 192 202 * BuddyPress dependencies. 193 203 */ 194 204 195 var _bp = bp, 196 _bp$blockComponents = _bp.blockComponents, 197 AutoCompleter = _bp$blockComponents.AutoCompleter, 198 ServerSideRender = _bp$blockComponents.ServerSideRender, 199 isActive = _bp.blockData.isActive; 205 const { 206 blockComponents: { 207 AutoCompleter 208 }, 209 blockData: { 210 isActive 211 } 212 } = bp; 200 213 /** 201 214 * Internal dependencies. 202 215 */ 203 216 204 var getSlugValue = function getSlugValue(item){217 const getSlugValue = item => { 205 218 if (item && item.status && _constants.GROUP_STATI[item.status]) { 206 219 return _constants.GROUP_STATI[item.status]; 207 220 } … … var getSlugValue = function getSlugValue(item) { 209 222 return null; 210 223 }; 211 224 212 var editGroupBlock = function editGroupBlock(_ref) { 213 var attributes = _ref.attributes, 214 setAttributes = _ref.setAttributes; 215 var isAvatarEnabled = isActive('groups', 'avatar'); 216 var isCoverImageEnabled = isActive('groups', 'cover'); 217 var avatarSize = attributes.avatarSize, 218 displayDescription = attributes.displayDescription, 219 displayActionButton = attributes.displayActionButton, 220 displayCoverImage = attributes.displayCoverImage; 225 const editGroupBlock = ({ 226 attributes, 227 setAttributes 228 }) => { 229 const isAvatarEnabled = isActive('groups', 'avatar'); 230 const isCoverImageEnabled = isActive('groups', 'cover'); 231 const { 232 avatarSize, 233 displayDescription, 234 displayActionButton, 235 displayCoverImage 236 } = attributes; 221 237 222 238 if (!attributes.itemID) { 223 239 return createElement(Placeholder, { … … var editGroupBlock = function editGroupBlock(_ref) { 242 258 }, createElement(ToolbarButton, { 243 259 icon: "edit", 244 260 title: __('Select another group', 'buddypress'), 245 onClick: function onClick(){261 onClick: () => { 246 262 setAttributes({ 247 263 itemID: 0 248 264 }); … … var editGroupBlock = function editGroupBlock(_ref) { 253 269 }, createElement(ToggleControl, { 254 270 label: __('Display Group\'s home button', 'buddypress'), 255 271 checked: !!displayActionButton, 256 onChange: function onChange(){272 onChange: () => { 257 273 setAttributes({ 258 274 displayActionButton: !displayActionButton 259 275 }); … … var editGroupBlock = function editGroupBlock(_ref) { 262 278 }), createElement(ToggleControl, { 263 279 label: __('Display group\'s description', 'buddypress'), 264 280 checked: !!displayDescription, 265 onChange: function onChange(){281 onChange: () => { 266 282 setAttributes({ 267 283 displayDescription: !displayDescription 268 284 }); … … var editGroupBlock = function editGroupBlock(_ref) { 273 289 value: avatarSize, 274 290 options: _constants.AVATAR_SIZES, 275 291 help: __('Select "None" to disable the avatar.', 'buddypress'), 276 onChange: function onChange(option){292 onChange: option => { 277 293 setAttributes({ 278 294 avatarSize: option 279 295 }); … … var editGroupBlock = function editGroupBlock(_ref) { 281 297 }), isCoverImageEnabled && createElement(ToggleControl, { 282 298 label: __('Display Cover Image', 'buddypress'), 283 299 checked: !!displayCoverImage, 284 onChange: function onChange(){300 onChange: () => { 285 301 setAttributes({ 286 302 displayCoverImage: !displayCoverImage 287 303 }); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 305 321 /** 306 322 * WordPress dependencies. 307 323 */ 308 var _wp = wp, 309 registerBlockType = _wp.blocks.registerBlockType, 310 __ = _wp.i18n.__; 324 const { 325 blocks: { 326 registerBlockType 327 }, 328 i18n: { 329 __ 330 } 331 } = wp; 311 332 /** 312 333 * Internal dependencies. 313 334 */ -
src/bp-groups/js/blocks/groups.js
diff --git src/bp-groups/js/blocks/groups.js src/bp-groups/js/blocks/groups.js index 092956c2f..e6231296e 100644
parcelRequire = (function (modules, cache, entry, globalName) { 117 117 } 118 118 119 119 return newRequire; 120 })({"jEQo":[function(require,module,exports) { 121 function _arrayLikeToArray(arr, len) { 122 if (len == null || len > arr.length) len = arr.length; 123 124 for (var i = 0, arr2 = new Array(len); i < len; i++) { 125 arr2[i] = arr[i]; 126 } 127 128 return arr2; 129 } 130 131 module.exports = _arrayLikeToArray; 132 },{}],"o3SL":[function(require,module,exports) { 133 var arrayLikeToArray = require("./arrayLikeToArray"); 134 135 function _arrayWithoutHoles(arr) { 136 if (Array.isArray(arr)) return arrayLikeToArray(arr); 137 } 138 139 module.exports = _arrayWithoutHoles; 140 },{"./arrayLikeToArray":"jEQo"}],"lZpU":[function(require,module,exports) { 141 function _iterableToArray(iter) { 142 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 143 } 144 145 module.exports = _iterableToArray; 146 },{}],"Dbv9":[function(require,module,exports) { 147 var arrayLikeToArray = require("./arrayLikeToArray"); 148 149 function _unsupportedIterableToArray(o, minLen) { 150 if (!o) return; 151 if (typeof o === "string") return arrayLikeToArray(o, minLen); 152 var n = Object.prototype.toString.call(o).slice(8, -1); 153 if (n === "Object" && o.constructor) n = o.constructor.name; 154 if (n === "Map" || n === "Set") return Array.from(n); 155 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 156 } 157 158 module.exports = _unsupportedIterableToArray; 159 },{"./arrayLikeToArray":"jEQo"}],"NCaH":[function(require,module,exports) { 160 function _nonIterableSpread() { 161 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 162 } 163 164 module.exports = _nonIterableSpread; 165 },{}],"I9dH":[function(require,module,exports) { 166 var arrayWithoutHoles = require("./arrayWithoutHoles"); 167 168 var iterableToArray = require("./iterableToArray"); 169 170 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 171 172 var nonIterableSpread = require("./nonIterableSpread"); 173 174 function _toConsumableArray(arr) { 175 return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); 176 } 177 178 module.exports = _toConsumableArray; 179 },{"./arrayWithoutHoles":"o3SL","./iterableToArray":"lZpU","./unsupportedIterableToArray":"Dbv9","./nonIterableSpread":"NCaH"}],"DCTP":[function(require,module,exports) { 180 function _arrayWithHoles(arr) { 181 if (Array.isArray(arr)) return arr; 182 } 183 184 module.exports = _arrayWithHoles; 185 },{}],"LoeL":[function(require,module,exports) { 186 function _iterableToArrayLimit(arr, i) { 187 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 188 var _arr = []; 189 var _n = true; 190 var _d = false; 191 var _e = undefined; 192 193 try { 194 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 195 _arr.push(_s.value); 196 197 if (i && _arr.length === i) break; 198 } 199 } catch (err) { 200 _d = true; 201 _e = err; 202 } finally { 203 try { 204 if (!_n && _i["return"] != null) _i["return"](); 205 } finally { 206 if (_d) throw _e; 207 } 208 } 209 210 return _arr; 211 } 212 213 module.exports = _iterableToArrayLimit; 214 },{}],"MWEO":[function(require,module,exports) { 215 function _nonIterableRest() { 216 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 217 } 218 219 module.exports = _nonIterableRest; 220 },{}],"DERy":[function(require,module,exports) { 221 var arrayWithHoles = require("./arrayWithHoles"); 222 223 var iterableToArrayLimit = require("./iterableToArrayLimit"); 224 225 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 226 227 var nonIterableRest = require("./nonIterableRest"); 228 229 function _slicedToArray(arr, i) { 230 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 231 } 232 233 module.exports = _slicedToArray; 234 },{"./arrayWithHoles":"DCTP","./iterableToArrayLimit":"LoeL","./unsupportedIterableToArray":"Dbv9","./nonIterableRest":"MWEO"}],"jS06":[function(require,module,exports) { 120 })({"jS06":[function(require,module,exports) { 235 121 "use strict"; 236 122 237 123 Object.defineProperty(exports, "__esModule", { … … exports.EXTRA_INFO = exports.GROUP_STATI = exports.AVATAR_SIZES = void 0; 242 128 /** 243 129 * WordPress dependencies. 244 130 */ 245 var _wp = wp, 246 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 247 136 /** 248 137 * Avatar sizes. 249 138 * 250 139 * @type {Array} 251 140 */ 252 141 253 varAVATAR_SIZES = [{142 const AVATAR_SIZES = [{ 254 143 label: __('None', 'buddypress'), 255 144 value: 'none' 256 145 }, { … … var AVATAR_SIZES = [{ 267 156 */ 268 157 269 158 exports.AVATAR_SIZES = AVATAR_SIZES; 270 varGROUP_STATI = {159 const GROUP_STATI = { 271 160 public: __('Public', 'buddypress'), 272 161 private: __('Private', 'buddypress'), 273 162 hidden: __('Hidden', 'buddypress') … … var GROUP_STATI = { 279 168 */ 280 169 281 170 exports.GROUP_STATI = GROUP_STATI; 282 varEXTRA_INFO = [{171 const EXTRA_INFO = [{ 283 172 label: __('None', 'buddypress'), 284 173 value: 'none' 285 174 }, { … … Object.defineProperty(exports, "__esModule", { 301 190 }); 302 191 exports.default = void 0; 303 192 304 var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));305 306 var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));307 308 193 var _constants = require("./constants"); 309 194 310 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }311 312 195 /** 313 196 * WordPress dependencies. 314 197 */ 315 var _wp = wp, 316 _wp$blockEditor = _wp.blockEditor, 317 InspectorControls = _wp$blockEditor.InspectorControls, 318 BlockControls = _wp$blockEditor.BlockControls, 319 _wp$components = _wp.components, 320 Placeholder = _wp$components.Placeholder, 321 PanelBody = _wp$components.PanelBody, 322 SelectControl = _wp$components.SelectControl, 323 ToggleControl = _wp$components.ToggleControl, 324 Button = _wp$components.Button, 325 Dashicon = _wp$components.Dashicon, 326 Tooltip = _wp$components.Tooltip, 327 ToolbarGroup = _wp$components.ToolbarGroup, 328 RangeControl = _wp$components.RangeControl, 329 _wp$element = _wp.element, 330 createElement = _wp$element.createElement, 331 Fragment = _wp$element.Fragment, 332 useState = _wp$element.useState, 333 _wp$i18n = _wp.i18n, 334 __ = _wp$i18n.__, 335 sprintf = _wp$i18n.sprintf, 336 _n = _wp$i18n._n, 337 apiFetch = _wp.apiFetch, 338 addQueryArgs = _wp.url.addQueryArgs; 198 const { 199 blockEditor: { 200 InspectorControls, 201 BlockControls 202 }, 203 components: { 204 Placeholder, 205 PanelBody, 206 SelectControl, 207 ToggleControl, 208 Button, 209 Dashicon, 210 Tooltip, 211 ToolbarGroup, 212 RangeControl 213 }, 214 element: { 215 createElement, 216 Fragment, 217 useState 218 }, 219 i18n: { 220 __, 221 sprintf, 222 _n 223 }, 224 apiFetch, 225 url: { 226 addQueryArgs 227 } 228 } = wp; 339 229 /** 340 230 * BuddyPress dependencies. 341 231 */ 342 232 343 var _bp = bp, 344 AutoCompleter = _bp.blockComponents.AutoCompleter, 345 isActive = _bp.blockData.isActive; 233 const { 234 blockComponents: { 235 AutoCompleter 236 }, 237 blockData: { 238 isActive 239 } 240 } = bp; 346 241 /** 347 242 * Internal dependencies. 348 243 */ … … var _bp = bp, 350 245 /** 351 246 * External dependencies. 352 247 */ 353 var _lodash = lodash, 354 reject = _lodash.reject, 355 remove = _lodash.remove, 356 sortBy = _lodash.sortBy; 248 const { 249 reject, 250 remove, 251 sortBy 252 } = lodash; 357 253 358 var getSlugValue = function getSlugValue(item){254 const getSlugValue = item => { 359 255 if (item && item.status && _constants.GROUP_STATI[item.status]) { 360 256 return _constants.GROUP_STATI[item.status]; 361 257 } … … var getSlugValue = function getSlugValue(item) { 363 259 return null; 364 260 }; 365 261 366 var editGroupsBlock = function editGroupsBlock(_ref) { 367 var attributes = _ref.attributes, 368 setAttributes = _ref.setAttributes, 369 isSelected = _ref.isSelected; 370 var isAvatarEnabled = isActive('groups', 'avatar'); 371 var itemIDs = attributes.itemIDs, 372 avatarSize = attributes.avatarSize, 373 displayGroupName = attributes.displayGroupName, 374 extraInfo = attributes.extraInfo, 375 layoutPreference = attributes.layoutPreference, 376 columns = attributes.columns; 377 var hasGroups = 0 !== itemIDs.length; 378 379 var _useState = useState([]), 380 _useState2 = (0, _slicedToArray2.default)(_useState, 2), 381 groups = _useState2[0], 382 setGroups = _useState2[1]; 383 384 var layoutControls = [{ 262 const editGroupsBlock = ({ 263 attributes, 264 setAttributes, 265 isSelected 266 }) => { 267 const isAvatarEnabled = isActive('groups', 'avatar'); 268 const { 269 itemIDs, 270 avatarSize, 271 displayGroupName, 272 extraInfo, 273 layoutPreference, 274 columns 275 } = attributes; 276 const hasGroups = 0 !== itemIDs.length; 277 const [groups, setGroups] = useState([]); 278 const layoutControls = [{ 385 279 icon: 'text', 386 280 title: __('List view', 'buddypress'), 387 onClick: function onClick() { 388 return setAttributes({ 389 layoutPreference: 'list' 390 }); 391 }, 281 onClick: () => setAttributes({ 282 layoutPreference: 'list' 283 }), 392 284 isActive: layoutPreference === 'list' 393 285 }, { 394 286 icon: 'screenoptions', 395 287 title: __('Grid view', 'buddypress'), 396 onClick: function onClick() { 397 return setAttributes({ 398 layoutPreference: 'grid' 399 }); 400 }, 288 onClick: () => setAttributes({ 289 layoutPreference: 'grid' 290 }), 401 291 isActive: layoutPreference === 'grid' 402 292 }]; 403 vargroupsList;404 varcontainerClasses = 'bp-block-groups avatar-' + avatarSize;405 varextraInfoOptions = _constants.EXTRA_INFO;293 let groupsList; 294 let containerClasses = 'bp-block-groups avatar-' + avatarSize; 295 let extraInfoOptions = _constants.EXTRA_INFO; 406 296 407 297 if (layoutPreference === 'grid') { 408 298 containerClasses += ' is-grid columns-' + columns; 409 extraInfoOptions = _constants.EXTRA_INFO.filter( function (extra){299 extraInfoOptions = _constants.EXTRA_INFO.filter(extra => { 410 300 return 'description' !== extra.value; 411 301 }); 412 302 } 413 303 414 var onSelectedGroup = function onSelectedGroup(_ref2){415 var itemID = _ref2.itemID;416 304 const onSelectedGroup = ({ 305 itemID 306 }) => { 417 307 if (itemID && -1 === itemIDs.indexOf(itemID)) { 418 308 setAttributes({ 419 itemIDs: [ ].concat((0, _toConsumableArray2.default)(itemIDs), [parseInt(itemID, 10)])309 itemIDs: [...itemIDs, parseInt(itemID, 10)] 420 310 }); 421 311 } 422 312 }; 423 313 424 var onRemoveGroup = function onRemoveGroup(itemID){314 const onRemoveGroup = itemID => { 425 315 if (itemID && -1 !== itemIDs.indexOf(itemID)) { 426 316 setGroups(reject(groups, ['id', itemID])); 427 317 setAttributes({ 428 itemIDs: remove(itemIDs, function (value){318 itemIDs: remove(itemIDs, value => { 429 319 return value !== itemID; 430 320 }) 431 321 }); … … var editGroupsBlock = function editGroupsBlock(_ref) { 434 324 435 325 if (hasGroups && itemIDs.length !== groups.length) { 436 326 apiFetch({ 437 path: addQueryArgs( "/buddypress/v1/groups", {327 path: addQueryArgs(`/buddypress/v1/groups`, { 438 328 populate_extras: true, 439 329 include: itemIDs 440 330 }) 441 }).then( function (items){442 setGroups(sortBy(items, [ function (item){331 }).then(items => { 332 setGroups(sortBy(items, [item => { 443 333 return itemIDs.indexOf(item.id); 444 334 }])); 445 335 }); 446 336 } 447 337 448 338 if (groups.length) { 449 groupsList = groups.map( function (group){450 varhasDescription = false;451 vargroupItemClasses = 'group-content';339 groupsList = groups.map(group => { 340 let hasDescription = false; 341 let groupItemClasses = 'group-content'; 452 342 453 343 if (layoutPreference === 'list' && 'description' === extraInfo && group.description && group.description.rendered) { 454 344 hasDescription = true; … … var editGroupsBlock = function editGroupsBlock(_ref) { 462 352 text: __('Remove group', 'buddypress') 463 353 }, createElement(Button, { 464 354 className: "is-right", 465 onClick: function onClick() { 466 return onRemoveGroup(group.id); 467 }, 355 onClick: () => onRemoveGroup(group.id), 468 356 label: __('Remove group', 'buddypress') 469 357 }, createElement(Dashicon, { 470 358 icon: "no" … … var editGroupsBlock = function editGroupsBlock(_ref) { 504 392 }, createElement(ToggleControl, { 505 393 label: __('Display the group\'s name', 'buddypress'), 506 394 checked: !!displayGroupName, 507 onChange: function onChange(){395 onChange: () => { 508 396 setAttributes({ 509 397 displayGroupName: !displayGroupName 510 398 }); … … var editGroupsBlock = function editGroupsBlock(_ref) { 515 403 value: avatarSize, 516 404 options: _constants.AVATAR_SIZES, 517 405 help: __('Select "None" to disable the avatar.', 'buddypress'), 518 onChange: function onChange(option){406 onChange: option => { 519 407 setAttributes({ 520 408 avatarSize: option 521 409 }); … … var editGroupsBlock = function editGroupsBlock(_ref) { 525 413 value: extraInfo, 526 414 options: extraInfoOptions, 527 415 help: __('Select "None" to show no extra information.', 'buddypress'), 528 onChange: function onChange(option){416 onChange: option => { 529 417 setAttributes({ 530 418 extraInfo: option 531 419 }); … … var editGroupsBlock = function editGroupsBlock(_ref) { 533 421 }), layoutPreference === 'grid' && createElement(RangeControl, { 534 422 label: __('Columns', 'buddypress'), 535 423 value: columns, 536 onChange: function onChange(value) { 537 return setAttributes({ 538 columns: value 539 }); 540 }, 424 onChange: value => setAttributes({ 425 columns: value 426 }), 541 427 min: 2, 542 428 max: 4, 543 429 required: true … … var editGroupsBlock = function editGroupsBlock(_ref) { 566 452 567 453 var _default = editGroupsBlock; 568 454 exports.default = _default; 569 },{" @babel/runtime/helpers/toConsumableArray":"I9dH","@babel/runtime/helpers/slicedToArray":"DERy","./constants":"jS06"}],"jcTh":[function(require,module,exports) {455 },{"./constants":"jS06"}],"jcTh":[function(require,module,exports) { 570 456 "use strict"; 571 457 572 458 var _edit = _interopRequireDefault(require("./groups/edit")); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 576 462 /** 577 463 * WordPress dependencies. 578 464 */ 579 var _wp = wp, 580 registerBlockType = _wp.blocks.registerBlockType, 581 __ = _wp.i18n.__; 465 const { 466 blocks: { 467 registerBlockType 468 }, 469 i18n: { 470 __ 471 } 472 } = wp; 582 473 /** 583 474 * Internal dependencies. 584 475 */ -
src/bp-groups/js/dynamic-groups.js
diff --git src/bp-groups/js/dynamic-groups.js src/bp-groups/js/dynamic-groups.js index 4a0839982..801585d38 100644
parcelRequire = (function (modules, cache, entry, globalName) { 118 118 119 119 return newRequire; 120 120 })({"UOvc":[function(require,module,exports) { 121 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }122 123 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }124 125 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }126 127 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }128 129 function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }130 131 function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }132 133 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }134 135 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }136 137 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }138 139 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }140 141 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }142 143 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }144 145 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }146 147 121 /** 148 122 * WordPress dependencies 149 123 */ 150 var _wp = wp, 151 _wp$i18n = _wp.i18n, 152 __ = _wp$i18n.__, 153 sprintf = _wp$i18n.sprintf; 124 const { 125 i18n: { 126 __, 127 sprintf 128 } 129 } = wp; 154 130 /** 155 131 * BuddyPress dependencies. 156 132 */ 157 133 158 var _bp = bp, 159 dynamicWidgetBlock = _bp.dynamicWidgetBlock; 134 const { 135 dynamicWidgetBlock 136 } = bp; 160 137 /** 161 138 * Front-end Dynamic Groups Widget Block class. 162 139 * 163 140 * @since 9.0.0 164 141 */ 165 142 166 var bpGroupsWidgetBlock = /*#__PURE__*/function (_dynamicWidgetBlock) { 167 _inherits(bpGroupsWidgetBlock, _dynamicWidgetBlock); 168 169 var _super = _createSuper(bpGroupsWidgetBlock); 170 171 function bpGroupsWidgetBlock() { 172 _classCallCheck(this, bpGroupsWidgetBlock); 173 174 return _super.apply(this, arguments); 175 } 176 177 _createClass(bpGroupsWidgetBlock, [{ 178 key: "loop", 179 value: function loop() { 180 var groups = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 181 var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 182 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'active'; 183 184 var tmpl = _get(_getPrototypeOf(bpGroupsWidgetBlock.prototype), "useTemplate", this).call(this, 'bp-dynamic-groups-item'); 185 186 var selector = document.querySelector('#' + container); 187 var output = ''; 188 189 if (groups && groups.length) { 190 groups.forEach(function (group) { 191 if ('newest' === type && group.created_since) { 192 /* translators: %s is time elapsed since the group was created */ 193 group.extra = sprintf(__('Created %s', 'buddypress'), group.created_since); 194 } else if ('popular' === type && group.total_member_count) { 195 var membersCount = parseInt(group.total_member_count, 10); 196 197 if (0 === membersCount) { 198 group.extra = __('No members', 'buddypress'); 199 } else if (1 === membersCount) { 200 group.extra = __('1 member', 'buddypress'); 201 } else { 202 /* translators: %s is the number of Group members (more than 1). */ 203 group.extra = sprintf(__('%s members', 'buddypress'), group.total_member_count); 204 } 143 class bpGroupsWidgetBlock extends dynamicWidgetBlock { 144 loop(groups = [], container = '', type = 'active') { 145 const tmpl = super.useTemplate('bp-dynamic-groups-item'); 146 const selector = document.querySelector('#' + container); 147 let output = ''; 148 149 if (groups && groups.length) { 150 groups.forEach(group => { 151 if ('newest' === type && group.created_since) { 152 /* translators: %s is time elapsed since the group was created */ 153 group.extra = sprintf(__('Created %s', 'buddypress'), group.created_since); 154 } else if ('popular' === type && group.total_member_count) { 155 const membersCount = parseInt(group.total_member_count, 10); 156 157 if (0 === membersCount) { 158 group.extra = __('No members', 'buddypress'); 159 } else if (1 === membersCount) { 160 group.extra = __('1 member', 'buddypress'); 205 161 } else { 206 /* translators: %s : a human time diff. */207 group.extra = sprintf(__(' Active %s', 'buddypress'), group.last_activity_diff);162 /* translators: %s is the number of Group members (more than 1). */ 163 group.extra = sprintf(__('%s members', 'buddypress'), group.total_member_count); 208 164 } 209 /* Translators: %s is the group's name. */ 210 165 } else { 166 /* translators: %s: a human time diff. */ 167 group.extra = sprintf(__('Active %s', 'buddypress'), group.last_activity_diff); 168 } 169 /* Translators: %s is the group's name. */ 211 170 212 group.avatar_alt = sprintf(__('Group Profile photo of %s', 'buddypress'), group.name);213 output += tmpl(group);214 });215 } else {216 output = '<div class="widget-error">' + __('There are no groups to display.', 'buddypress') + '</div>';217 }218 171 219 selector.innerHTML = output; 172 group.avatar_alt = sprintf(__('Group Profile photo of %s', 'buddypress'), group.name); 173 output += tmpl(group); 174 }); 175 } else { 176 output = '<div class="widget-error">' + __('There are no groups to display.', 'buddypress') + '</div>'; 220 177 } 221 }, {222 key: "start",223 value: function start() {224 var _this = this;225 178 226 this.blocks.forEach(function (block, i) { 227 var selector = block.selector; 228 var type = block.query_args.type; 229 var list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type groups. 179 selector.innerHTML = output; 180 } 230 181 231 _get(_getPrototypeOf(bpGroupsWidgetBlock.prototype), "getItems", _this).call(_this, type, i); // Listen to Block's Nav item clics 182 start() { 183 this.blocks.forEach((block, i) => { 184 const { 185 selector 186 } = block; 187 const { 188 type 189 } = block.query_args; 190 const list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type groups. 232 191 192 super.getItems(type, i); // Listen to Block's Nav item clics 233 193 234 list.querySelectorAll('.item-options a').forEach(function (navItem){235 navItem.addEventListener('click', function (event){236 194 list.querySelectorAll('.item-options a').forEach(navItem => { 195 navItem.addEventListener('click', event => { 196 event.preventDefault(); // Changes the displayed filter. 237 197 238 239 240 varnewType = event.target.getAttribute('data-bp-sort');198 event.target.closest('.item-options').querySelector('.selected').classList.remove('selected'); 199 event.target.classList.add('selected'); 200 const newType = event.target.getAttribute('data-bp-sort'); 241 201 242 if (newType !== _this.blocks[i].query_args.type) { 243 _get(_getPrototypeOf(bpGroupsWidgetBlock.prototype), "getItems", _this).call(_this, newType, i); 244 } 245 }); 202 if (newType !== this.blocks[i].query_args.type) { 203 super.getItems(newType, i); 204 } 246 205 }); 247 206 }); 248 } 249 } ]);207 }); 208 } 250 209 251 return bpGroupsWidgetBlock; 252 }(dynamicWidgetBlock); 210 } 253 211 254 varsettings = window.bpDynamicGroupsSettings || {};255 varblocks = window.bpDynamicGroupsBlocks || [];256 varbpDynamicGroups = new bpGroupsWidgetBlock(settings, blocks);212 const settings = window.bpDynamicGroupsSettings || {}; 213 const blocks = window.bpDynamicGroupsBlocks || []; 214 const bpDynamicGroups = new bpGroupsWidgetBlock(settings, blocks); 257 215 258 216 if ('loading' === document.readyState) { 259 217 document.addEventListener('DOMContentLoaded', bpDynamicGroups.start()); -
src/bp-members/classes/class-bp-members-component.php
diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php index 432e3ecce..7bca5d8bb 100644
class BP_Members_Component extends BP_Component { 764 764 'wp-components', 765 765 'wp-i18n', 766 766 'wp-block-editor', 767 'wp-server-side-render', 767 768 'bp-block-components', 768 769 'bp-block-data', 769 770 ), … … class BP_Members_Component extends BP_Component { 857 858 'wp-components', 858 859 'wp-i18n', 859 860 'wp-block-editor', 861 'wp-server-side-render', 860 862 'bp-block-data', 861 'bp-block-components',862 863 ), 863 864 'style' => 'bp-dynamic-members-block', 864 865 'style_url' => plugins_url( 'css/blocks/dynamic-members.css', dirname( __FILE__ ) ), … … class BP_Members_Component extends BP_Component { 892 893 'wp-components', 893 894 'wp-i18n', 894 895 'wp-block-editor', 895 ' bp-block-components',896 'wp-server-side-render', 896 897 ), 897 898 'editor_style' => 'bp-member-avatar-blocks', 898 899 'editor_style_url' => plugins_url( 'css/blocks/member-avatar-blocks.css', dirname( __FILE__ ) ), … … class BP_Members_Component extends BP_Component { 918 919 'wp-components', 919 920 'wp-i18n', 920 921 'wp-block-editor', 921 ' bp-block-components',922 'wp-server-side-render', 922 923 ), 923 924 'editor_style' => 'bp-member-avatar-blocks', 924 925 'editor_style_url' => plugins_url( 'css/blocks/member-avatar-blocks.css', dirname( __FILE__ ) ), -
src/bp-members/js/blocks/active-members.js
diff --git src/bp-members/js/blocks/active-members.js src/bp-members/js/blocks/active-members.js index 1ff2415e1..4cdb55e89 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 PanelBody = _wp$components.PanelBody, 136 RangeControl = _wp$components.RangeControl, 137 TextControl = _wp$components.TextControl, 138 _wp$element = _wp.element, 139 Fragment = _wp$element.Fragment, 140 createElement = _wp$element.createElement, 141 __ = _wp.i18n.__; 142 /** 143 * BuddyPress dependencies. 144 */ 145 146 var _bp = bp, 147 ServerSideRender = _bp.blockComponents.ServerSideRender; 148 149 var editActiveMembersBlock = function editActiveMembersBlock(_ref) { 150 var attributes = _ref.attributes, 151 setAttributes = _ref.setAttributes; 152 var title = attributes.title, 153 maxMembers = attributes.maxMembers; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 PanelBody, 138 RangeControl, 139 TextControl 140 }, 141 element: { 142 Fragment, 143 createElement 144 }, 145 i18n: { 146 __ 147 }, 148 serverSideRender: ServerSideRender 149 } = wp; 150 151 const editActiveMembersBlock = ({ 152 attributes, 153 setAttributes 154 }) => { 155 const { 156 title, 157 maxMembers 158 } = attributes; 154 159 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 155 160 title: __('Settings', 'buddypress'), 156 161 initialOpen: true 157 162 }, createElement(TextControl, { 158 163 label: __('Title', 'buddypress'), 159 164 value: title, 160 onChange: function onChange(text){165 onChange: text => { 161 166 setAttributes({ 162 167 title: text 163 168 }); … … var editActiveMembersBlock = function editActiveMembersBlock(_ref) { 165 170 }), createElement(RangeControl, { 166 171 label: __('Max members to show', 'buddypress'), 167 172 value: maxMembers, 168 onChange: function onChange(value) { 169 return setAttributes({ 170 maxMembers: value 171 }); 172 }, 173 onChange: value => setAttributes({ 174 maxMembers: value 175 }), 173 176 min: 1, 174 177 max: 15, 175 178 required: true … … exports.default = void 0; 192 195 /** 193 196 * WordPress dependencies. 194 197 */ 195 var _wp = wp, 196 createBlock = _wp.blocks.createBlock; 198 const { 199 blocks: { 200 createBlock 201 } 202 } = wp; 197 203 /** 198 204 * Transforms Legacy Widget to Active Members Block. 199 205 * 200 206 * @type {Object} 201 207 */ 202 208 203 vartransforms = {209 const transforms = { 204 210 from: [{ 205 211 type: 'block', 206 212 blocks: ['core/legacy-widget'], 207 isMatch: function isMatch(_ref){208 var idBase = _ref.idBase,209 instance = _ref.instance;210 213 isMatch: ({ 214 idBase, 215 instance 216 }) => { 211 217 if (!(instance !== null && instance !== void 0 && instance.raw)) { 212 218 return false; 213 219 } 214 220 215 221 return idBase === 'bp_core_recently_active_widget'; 216 222 }, 217 transform: function transform(_ref2) { 218 var instance = _ref2.instance; 223 transform: ({ 224 instance 225 }) => { 219 226 return createBlock('bp/active-members', { 220 227 title: instance.raw.title, 221 228 maxMembers: instance.raw.max_members … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 237 244 /** 238 245 * WordPress dependencies. 239 246 */ 240 var _wp = wp, 241 registerBlockType = _wp.blocks.registerBlockType, 242 __ = _wp.i18n.__; 247 const { 248 blocks: { 249 registerBlockType 250 }, 251 i18n: { 252 __ 253 } 254 } = wp; 243 255 /** 244 256 * Internal dependencies. 245 257 */ -
src/bp-members/js/blocks/dynamic-members.js
diff --git src/bp-members/js/blocks/dynamic-members.js src/bp-members/js/blocks/dynamic-members.js index 6f55a264e..54e8d8d9a 100644
exports.TYPES = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 133 136 /** 134 137 * Members ordering types. 135 138 * 136 139 * @type {Array} 137 140 */ 138 141 139 varTYPES = [{142 const TYPES = [{ 140 143 label: __('Newest', 'buddypress'), 141 144 value: 'newest' 142 145 }, { … … var _constants = require("./constants"); 160 163 /** 161 164 * WordPress dependencies. 162 165 */ 163 var _wp = wp, 164 InspectorControls = _wp.blockEditor.InspectorControls, 165 _wp$components = _wp.components, 166 Disabled = _wp$components.Disabled, 167 PanelBody = _wp$components.PanelBody, 168 RangeControl = _wp$components.RangeControl, 169 SelectControl = _wp$components.SelectControl, 170 TextControl = _wp$components.TextControl, 171 ToggleControl = _wp$components.ToggleControl, 172 _wp$element = _wp.element, 173 Fragment = _wp$element.Fragment, 174 createElement = _wp$element.createElement, 175 __ = _wp.i18n.__; 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; 176 187 /** 177 188 * BuddyPress dependencies. 178 189 */ 179 190 180 var _bp = bp, 181 ServerSideRender = _bp.blockComponents.ServerSideRender, 182 isActive = _bp.blockData.isActive; 191 const { 192 blockData: { 193 isActive 194 } 195 } = bp; 183 196 /** 184 197 * Internal dependencies. 185 198 */ 186 199 187 var editDynamicMembersBlock = function editDynamicMembersBlock(_ref) { 188 var attributes = _ref.attributes, 189 setAttributes = _ref.setAttributes; 190 var title = attributes.title, 191 maxMembers = attributes.maxMembers, 192 memberDefault = attributes.memberDefault, 193 linkTitle = attributes.linkTitle; 194 var sortTypes = !!isActive('friends') ? _constants.TYPES : _constants.TYPES.filter(function (type) { 195 return 'popular' !== type.value; 196 }); 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); 197 211 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 198 212 title: __('Settings', 'buddypress'), 199 213 initialOpen: true 200 214 }, createElement(TextControl, { 201 215 label: __('Title', 'buddypress'), 202 216 value: title, 203 onChange: function onChange(text){217 onChange: text => { 204 218 setAttributes({ 205 219 title: text 206 220 }); … … var editDynamicMembersBlock = function editDynamicMembersBlock(_ref) { 208 222 }), createElement(RangeControl, { 209 223 label: __('Max members to show', 'buddypress'), 210 224 value: maxMembers, 211 onChange: function onChange(value) { 212 return setAttributes({ 213 maxMembers: value 214 }); 215 }, 225 onChange: value => setAttributes({ 226 maxMembers: value 227 }), 216 228 min: 1, 217 229 max: 10, 218 230 required: true … … var editDynamicMembersBlock = function editDynamicMembersBlock(_ref) { 220 232 label: __('Default members to show', 'buddypress'), 221 233 value: memberDefault, 222 234 options: sortTypes, 223 onChange: function onChange(option){235 onChange: option => { 224 236 setAttributes({ 225 237 memberDefault: option 226 238 }); … … var editDynamicMembersBlock = function editDynamicMembersBlock(_ref) { 228 240 }), createElement(ToggleControl, { 229 241 label: __('Link block title to Members directory', 'buddypress'), 230 242 checked: !!linkTitle, 231 onChange: function onChange(){243 onChange: () => { 232 244 setAttributes({ 233 245 linkTitle: !linkTitle 234 246 }); … … exports.default = void 0; 252 264 /** 253 265 * WordPress dependencies. 254 266 */ 255 var _wp = wp, 256 createBlock = _wp.blocks.createBlock; 267 const { 268 blocks: { 269 createBlock 270 } 271 } = wp; 257 272 /** 258 273 * Transforms Legacy Widget to Dynamic Members Block. 259 274 * 260 275 * @type {Object} 261 276 */ 262 277 263 vartransforms = {278 const transforms = { 264 279 from: [{ 265 280 type: 'block', 266 281 blocks: ['core/legacy-widget'], 267 isMatch: function isMatch(_ref){268 var idBase = _ref.idBase,269 instance = _ref.instance;270 282 isMatch: ({ 283 idBase, 284 instance 285 }) => { 271 286 if (!(instance !== null && instance !== void 0 && instance.raw)) { 272 287 return false; 273 288 } 274 289 275 290 return idBase === 'bp_core_members_widget'; 276 291 }, 277 transform: function transform(_ref2) { 278 var instance = _ref2.instance; 292 transform: ({ 293 instance 294 }) => { 279 295 return createBlock('bp/dynamic-members', { 280 296 title: instance.raw.title, 281 297 maxMembers: instance.raw.max_members, … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 299 315 /** 300 316 * WordPress dependencies. 301 317 */ 302 var _wp = wp, 303 registerBlockType = _wp.blocks.registerBlockType, 304 __ = _wp.i18n.__; 318 const { 319 blocks: { 320 registerBlockType 321 }, 322 i18n: { 323 __ 324 } 325 } = wp; 305 326 /** 306 327 * Internal dependencies. 307 328 */ -
src/bp-members/js/blocks/member.js
diff --git src/bp-members/js/blocks/member.js src/bp-members/js/blocks/member.js index 2e3648a9e..5a9053321 100644
exports.AVATAR_SIZES = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 133 136 /** 134 137 * Avatar sizes. 135 138 * 136 139 * @type {Array} 137 140 */ 138 141 139 varAVATAR_SIZES = [{142 const AVATAR_SIZES = [{ 140 143 label: __('None', 'buddypress'), 141 144 value: 'none' 142 145 }, { … … var _constants = require("./constants"); 160 163 /** 161 164 * WordPress dependencies. 162 165 */ 163 var _wp = wp, 164 _wp$blockEditor = _wp.blockEditor, 165 InspectorControls = _wp$blockEditor.InspectorControls, 166 BlockControls = _wp$blockEditor.BlockControls, 167 _wp$components = _wp.components, 168 Placeholder = _wp$components.Placeholder, 169 Disabled = _wp$components.Disabled, 170 PanelBody = _wp$components.PanelBody, 171 SelectControl = _wp$components.SelectControl, 172 ToggleControl = _wp$components.ToggleControl, 173 Toolbar = _wp$components.Toolbar, 174 ToolbarButton = _wp$components.ToolbarButton, 175 _wp$element = _wp.element, 176 Fragment = _wp$element.Fragment, 177 createElement = _wp$element.createElement, 178 __ = _wp.i18n.__; 166 const { 167 blockEditor: { 168 InspectorControls, 169 BlockControls 170 }, 171 components: { 172 Placeholder, 173 Disabled, 174 PanelBody, 175 SelectControl, 176 ToggleControl, 177 Toolbar, 178 ToolbarButton 179 }, 180 element: { 181 Fragment, 182 createElement 183 }, 184 i18n: { 185 __ 186 }, 187 serverSideRender: ServerSideRender 188 } = wp; 179 189 /** 180 190 * BuddyPress dependencies. 181 191 */ 182 192 183 var _bp = bp, 184 _bp$blockComponents = _bp.blockComponents, 185 AutoCompleter = _bp$blockComponents.AutoCompleter, 186 ServerSideRender = _bp$blockComponents.ServerSideRender, 187 isActive = _bp.blockData.isActive; 193 const { 194 blockComponents: { 195 AutoCompleter 196 }, 197 blockData: { 198 isActive 199 } 200 } = bp; 188 201 /** 189 202 * Internal dependencies. 190 203 */ 191 204 192 var getSlugValue = function getSlugValue(item){205 const getSlugValue = item => { 193 206 if (item && item.mention_name) { 194 207 return item.mention_name; 195 208 } … … var getSlugValue = function getSlugValue(item) { 197 210 return null; 198 211 }; 199 212 200 var editMemberBlock = function editMemberBlock(_ref) { 201 var attributes = _ref.attributes, 202 setAttributes = _ref.setAttributes; 203 var isAvatarEnabled = isActive('members', 'avatar'); 204 var isMentionEnabled = isActive('activity', 'mentions'); 205 var isCoverImageEnabled = isActive('members', 'cover'); 206 var avatarSize = attributes.avatarSize, 207 displayMentionSlug = attributes.displayMentionSlug, 208 displayActionButton = attributes.displayActionButton, 209 displayCoverImage = attributes.displayCoverImage; 213 const editMemberBlock = ({ 214 attributes, 215 setAttributes 216 }) => { 217 const isAvatarEnabled = isActive('members', 'avatar'); 218 const isMentionEnabled = isActive('activity', 'mentions'); 219 const isCoverImageEnabled = isActive('members', 'cover'); 220 const { 221 avatarSize, 222 displayMentionSlug, 223 displayActionButton, 224 displayCoverImage 225 } = attributes; 210 226 211 227 if (!attributes.itemID) { 212 228 return createElement(Placeholder, { … … var editMemberBlock = function editMemberBlock(_ref) { 228 244 }, createElement(ToolbarButton, { 229 245 icon: "edit", 230 246 title: __('Select another member', 'buddypress'), 231 onClick: function onClick(){247 onClick: () => { 232 248 setAttributes({ 233 249 itemID: 0 234 250 }); … … var editMemberBlock = function editMemberBlock(_ref) { 239 255 }, createElement(ToggleControl, { 240 256 label: __('Display Profile button', 'buddypress'), 241 257 checked: !!displayActionButton, 242 onChange: function onChange(){258 onChange: () => { 243 259 setAttributes({ 244 260 displayActionButton: !displayActionButton 245 261 }); … … var editMemberBlock = function editMemberBlock(_ref) { 250 266 value: avatarSize, 251 267 options: _constants.AVATAR_SIZES, 252 268 help: __('Select "None" to disable the avatar.', 'buddypress'), 253 onChange: function onChange(option){269 onChange: option => { 254 270 setAttributes({ 255 271 avatarSize: option 256 272 }); … … var editMemberBlock = function editMemberBlock(_ref) { 258 274 }), isCoverImageEnabled && createElement(ToggleControl, { 259 275 label: __('Display Cover Image', 'buddypress'), 260 276 checked: !!displayCoverImage, 261 onChange: function onChange(){277 onChange: () => { 262 278 setAttributes({ 263 279 displayCoverImage: !displayCoverImage 264 280 }); … … var editMemberBlock = function editMemberBlock(_ref) { 267 283 }), isMentionEnabled && createElement(ToggleControl, { 268 284 label: __('Display Mention slug', 'buddypress'), 269 285 checked: !!displayMentionSlug, 270 onChange: function onChange(){286 onChange: () => { 271 287 setAttributes({ 272 288 displayMentionSlug: !displayMentionSlug 273 289 }); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 291 307 /** 292 308 * WordPress dependencies. 293 309 */ 294 var _wp = wp, 295 registerBlockType = _wp.blocks.registerBlockType, 296 __ = _wp.i18n.__; 310 const { 311 blocks: { 312 registerBlockType 313 }, 314 i18n: { 315 __ 316 } 317 } = wp; 297 318 /** 298 319 * Internal dependencies. 299 320 */ -
src/bp-members/js/blocks/members.js
diff --git src/bp-members/js/blocks/members.js src/bp-members/js/blocks/members.js index a37f593c2..0bfe8fe6f 100644
parcelRequire = (function (modules, cache, entry, globalName) { 117 117 } 118 118 119 119 return newRequire; 120 })({"jEQo":[function(require,module,exports) { 121 function _arrayLikeToArray(arr, len) { 122 if (len == null || len > arr.length) len = arr.length; 123 124 for (var i = 0, arr2 = new Array(len); i < len; i++) { 125 arr2[i] = arr[i]; 126 } 127 128 return arr2; 129 } 130 131 module.exports = _arrayLikeToArray; 132 },{}],"o3SL":[function(require,module,exports) { 133 var arrayLikeToArray = require("./arrayLikeToArray"); 134 135 function _arrayWithoutHoles(arr) { 136 if (Array.isArray(arr)) return arrayLikeToArray(arr); 137 } 138 139 module.exports = _arrayWithoutHoles; 140 },{"./arrayLikeToArray":"jEQo"}],"lZpU":[function(require,module,exports) { 141 function _iterableToArray(iter) { 142 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); 143 } 144 145 module.exports = _iterableToArray; 146 },{}],"Dbv9":[function(require,module,exports) { 147 var arrayLikeToArray = require("./arrayLikeToArray"); 148 149 function _unsupportedIterableToArray(o, minLen) { 150 if (!o) return; 151 if (typeof o === "string") return arrayLikeToArray(o, minLen); 152 var n = Object.prototype.toString.call(o).slice(8, -1); 153 if (n === "Object" && o.constructor) n = o.constructor.name; 154 if (n === "Map" || n === "Set") return Array.from(n); 155 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); 156 } 157 158 module.exports = _unsupportedIterableToArray; 159 },{"./arrayLikeToArray":"jEQo"}],"NCaH":[function(require,module,exports) { 160 function _nonIterableSpread() { 161 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 162 } 163 164 module.exports = _nonIterableSpread; 165 },{}],"I9dH":[function(require,module,exports) { 166 var arrayWithoutHoles = require("./arrayWithoutHoles"); 167 168 var iterableToArray = require("./iterableToArray"); 169 170 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 171 172 var nonIterableSpread = require("./nonIterableSpread"); 173 174 function _toConsumableArray(arr) { 175 return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); 176 } 177 178 module.exports = _toConsumableArray; 179 },{"./arrayWithoutHoles":"o3SL","./iterableToArray":"lZpU","./unsupportedIterableToArray":"Dbv9","./nonIterableSpread":"NCaH"}],"DCTP":[function(require,module,exports) { 180 function _arrayWithHoles(arr) { 181 if (Array.isArray(arr)) return arr; 182 } 183 184 module.exports = _arrayWithHoles; 185 },{}],"LoeL":[function(require,module,exports) { 186 function _iterableToArrayLimit(arr, i) { 187 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 188 var _arr = []; 189 var _n = true; 190 var _d = false; 191 var _e = undefined; 192 193 try { 194 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { 195 _arr.push(_s.value); 196 197 if (i && _arr.length === i) break; 198 } 199 } catch (err) { 200 _d = true; 201 _e = err; 202 } finally { 203 try { 204 if (!_n && _i["return"] != null) _i["return"](); 205 } finally { 206 if (_d) throw _e; 207 } 208 } 209 210 return _arr; 211 } 212 213 module.exports = _iterableToArrayLimit; 214 },{}],"MWEO":[function(require,module,exports) { 215 function _nonIterableRest() { 216 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 217 } 218 219 module.exports = _nonIterableRest; 220 },{}],"DERy":[function(require,module,exports) { 221 var arrayWithHoles = require("./arrayWithHoles"); 222 223 var iterableToArrayLimit = require("./iterableToArrayLimit"); 224 225 var unsupportedIterableToArray = require("./unsupportedIterableToArray"); 226 227 var nonIterableRest = require("./nonIterableRest"); 228 229 function _slicedToArray(arr, i) { 230 return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); 231 } 232 233 module.exports = _slicedToArray; 234 },{"./arrayWithHoles":"DCTP","./iterableToArrayLimit":"LoeL","./unsupportedIterableToArray":"Dbv9","./nonIterableRest":"MWEO"}],"gr8I":[function(require,module,exports) { 120 })({"gr8I":[function(require,module,exports) { 235 121 "use strict"; 236 122 237 123 Object.defineProperty(exports, "__esModule", { … … exports.EXTRA_DATA = exports.AVATAR_SIZES = void 0; 242 128 /** 243 129 * WordPress dependencies. 244 130 */ 245 var _wp = wp, 246 __ = _wp.i18n.__; 131 const { 132 i18n: { 133 __ 134 } 135 } = wp; 247 136 /** 248 137 * Avatar sizes. 249 138 * 250 139 * @type {Array} 251 140 */ 252 141 253 varAVATAR_SIZES = [{142 const AVATAR_SIZES = [{ 254 143 label: __('None', 'buddypress'), 255 144 value: 'none' 256 145 }, { … … var AVATAR_SIZES = [{ 267 156 */ 268 157 269 158 exports.AVATAR_SIZES = AVATAR_SIZES; 270 varEXTRA_DATA = [{159 const EXTRA_DATA = [{ 271 160 label: __('None', 'buddypress'), 272 161 value: 'none' 273 162 }, { … … Object.defineProperty(exports, "__esModule", { 286 175 }); 287 176 exports.default = void 0; 288 177 289 var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));290 291 var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));292 293 178 var _constants = require("./constants"); 294 179 295 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }296 297 180 /** 298 181 * WordPress dependencies. 299 182 */ 300 var _wp = wp, 301 _wp$blockEditor = _wp.blockEditor, 302 InspectorControls = _wp$blockEditor.InspectorControls, 303 BlockControls = _wp$blockEditor.BlockControls, 304 _wp$components = _wp.components, 305 Placeholder = _wp$components.Placeholder, 306 PanelBody = _wp$components.PanelBody, 307 SelectControl = _wp$components.SelectControl, 308 ToggleControl = _wp$components.ToggleControl, 309 Button = _wp$components.Button, 310 Dashicon = _wp$components.Dashicon, 311 Tooltip = _wp$components.Tooltip, 312 ToolbarGroup = _wp$components.ToolbarGroup, 313 RangeControl = _wp$components.RangeControl, 314 _wp$element = _wp.element, 315 createElement = _wp$element.createElement, 316 Fragment = _wp$element.Fragment, 317 useState = _wp$element.useState, 318 _wp$i18n = _wp.i18n, 319 __ = _wp$i18n.__, 320 sprintf = _wp$i18n.sprintf, 321 apiFetch = _wp.apiFetch, 322 addQueryArgs = _wp.url.addQueryArgs; 183 const { 184 blockEditor: { 185 InspectorControls, 186 BlockControls 187 }, 188 components: { 189 Placeholder, 190 PanelBody, 191 SelectControl, 192 ToggleControl, 193 Button, 194 Dashicon, 195 Tooltip, 196 ToolbarGroup, 197 RangeControl 198 }, 199 element: { 200 createElement, 201 Fragment, 202 useState 203 }, 204 i18n: { 205 __, 206 sprintf 207 }, 208 apiFetch, 209 url: { 210 addQueryArgs 211 } 212 } = wp; 323 213 /** 324 214 * BuddyPress dependencies. 325 215 */ 326 216 327 var _bp = bp, 328 AutoCompleter = _bp.blockComponents.AutoCompleter, 329 isActive = _bp.blockData.isActive; 217 const { 218 blockComponents: { 219 AutoCompleter 220 }, 221 blockData: { 222 isActive 223 } 224 } = bp; 330 225 /** 331 226 * Internal dependencies. 332 227 */ … … var _bp = bp, 334 229 /** 335 230 * External dependencies. 336 231 */ 337 var _lodash = lodash, 338 reject = _lodash.reject, 339 remove = _lodash.remove, 340 sortBy = _lodash.sortBy; 232 const { 233 reject, 234 remove, 235 sortBy 236 } = lodash; 341 237 342 var getSlugValue = function getSlugValue(item){238 const getSlugValue = item => { 343 239 if (item && item.mention_name) { 344 240 return item.mention_name; 345 241 } … … var getSlugValue = function getSlugValue(item) { 347 243 return null; 348 244 }; 349 245 350 var editMembersBlock = function editMembersBlock(_ref) { 351 var attributes = _ref.attributes, 352 setAttributes = _ref.setAttributes, 353 isSelected = _ref.isSelected; 354 var isAvatarEnabled = isActive('members', 'avatar'); 355 var isMentionEnabled = isActive('activity', 'mentions'); 356 var itemIDs = attributes.itemIDs, 357 avatarSize = attributes.avatarSize, 358 displayMentionSlug = attributes.displayMentionSlug, 359 displayUserName = attributes.displayUserName, 360 extraData = attributes.extraData, 361 layoutPreference = attributes.layoutPreference, 362 columns = attributes.columns; 363 var hasMembers = 0 !== itemIDs.length; 364 365 var _useState = useState([]), 366 _useState2 = (0, _slicedToArray2.default)(_useState, 2), 367 members = _useState2[0], 368 setMembers = _useState2[1]; 369 370 var layoutControls = [{ 246 const editMembersBlock = ({ 247 attributes, 248 setAttributes, 249 isSelected 250 }) => { 251 const isAvatarEnabled = isActive('members', 'avatar'); 252 const isMentionEnabled = isActive('activity', 'mentions'); 253 const { 254 itemIDs, 255 avatarSize, 256 displayMentionSlug, 257 displayUserName, 258 extraData, 259 layoutPreference, 260 columns 261 } = attributes; 262 const hasMembers = 0 !== itemIDs.length; 263 const [members, setMembers] = useState([]); 264 const layoutControls = [{ 371 265 icon: 'text', 372 266 title: __('List view', 'buddypress'), 373 onClick: function onClick() { 374 return setAttributes({ 375 layoutPreference: 'list' 376 }); 377 }, 267 onClick: () => setAttributes({ 268 layoutPreference: 'list' 269 }), 378 270 isActive: layoutPreference === 'list' 379 271 }, { 380 272 icon: 'screenoptions', 381 273 title: __('Grid view', 'buddypress'), 382 onClick: function onClick() { 383 return setAttributes({ 384 layoutPreference: 'grid' 385 }); 386 }, 274 onClick: () => setAttributes({ 275 layoutPreference: 'grid' 276 }), 387 277 isActive: layoutPreference === 'grid' 388 278 }]; 389 varmembersList;390 varcontainerClasses = 'bp-block-members avatar-' + avatarSize;391 varextraDataOptions = _constants.EXTRA_DATA;279 let membersList; 280 let containerClasses = 'bp-block-members avatar-' + avatarSize; 281 let extraDataOptions = _constants.EXTRA_DATA; 392 282 393 283 if (layoutPreference === 'grid') { 394 284 containerClasses += ' is-grid columns-' + columns; 395 extraDataOptions = _constants.EXTRA_DATA.filter( function (extra){285 extraDataOptions = _constants.EXTRA_DATA.filter(extra => { 396 286 return 'latest_update' !== extra.value; 397 287 }); 398 288 } 399 289 400 var onSelectedMember = function onSelectedMember(_ref2){401 var itemID = _ref2.itemID;402 290 const onSelectedMember = ({ 291 itemID 292 }) => { 403 293 if (itemID && -1 === itemIDs.indexOf(itemID)) { 404 294 setAttributes({ 405 itemIDs: [ ].concat((0, _toConsumableArray2.default)(itemIDs), [parseInt(itemID, 10)])295 itemIDs: [...itemIDs, parseInt(itemID, 10)] 406 296 }); 407 297 } 408 298 }; 409 299 410 var onRemoveMember = function onRemoveMember(itemID){300 const onRemoveMember = itemID => { 411 301 if (itemID && -1 !== itemIDs.indexOf(itemID)) { 412 302 setMembers(reject(members, ['id', itemID])); 413 303 setAttributes({ 414 itemIDs: remove(itemIDs, function (value){304 itemIDs: remove(itemIDs, value => { 415 305 return value !== itemID; 416 306 }) 417 307 }); … … var editMembersBlock = function editMembersBlock(_ref) { 420 310 421 311 if (hasMembers && itemIDs.length !== members.length) { 422 312 apiFetch({ 423 path: addQueryArgs( "/buddypress/v1/members", {313 path: addQueryArgs(`/buddypress/v1/members`, { 424 314 populate_extras: true, 425 315 include: itemIDs 426 316 }) 427 }).then( function (items){428 setMembers(sortBy(items, [ function (item){317 }).then(items => { 318 setMembers(sortBy(items, [item => { 429 319 return itemIDs.indexOf(item.id); 430 320 }])); 431 321 }); 432 322 } 433 323 434 324 if (members.length) { 435 membersList = members.map( function (member){436 varhasActivity = false;437 varmemberItemClasses = 'member-content';325 membersList = members.map(member => { 326 let hasActivity = false; 327 let memberItemClasses = 'member-content'; 438 328 439 329 if (layoutPreference === 'list' && 'latest_update' === extraData && member.latest_update && member.latest_update.rendered) { 440 330 hasActivity = true; … … var editMembersBlock = function editMembersBlock(_ref) { 448 338 text: __('Remove member', 'buddypress') 449 339 }, createElement(Button, { 450 340 className: "is-right", 451 onClick: function onClick() { 452 return onRemoveMember(member.id); 453 }, 341 onClick: () => onRemoveMember(member.id), 454 342 label: __('Remove member', 'buddypress') 455 343 }, createElement(Dashicon, { 456 344 icon: "no" … … var editMembersBlock = function editMembersBlock(_ref) { 492 380 }, createElement(ToggleControl, { 493 381 label: __('Display the user name', 'buddypress'), 494 382 checked: !!displayUserName, 495 onChange: function onChange(){383 onChange: () => { 496 384 setAttributes({ 497 385 displayUserName: !displayUserName 498 386 }); … … var editMembersBlock = function editMembersBlock(_ref) { 501 389 }), isMentionEnabled && createElement(ToggleControl, { 502 390 label: __('Display Mention slug', 'buddypress'), 503 391 checked: !!displayMentionSlug, 504 onChange: function onChange(){392 onChange: () => { 505 393 setAttributes({ 506 394 displayMentionSlug: !displayMentionSlug 507 395 }); … … var editMembersBlock = function editMembersBlock(_ref) { 512 400 value: avatarSize, 513 401 options: _constants.AVATAR_SIZES, 514 402 help: __('Select "None" to disable the avatar.', 'buddypress'), 515 onChange: function onChange(option){403 onChange: option => { 516 404 setAttributes({ 517 405 avatarSize: option 518 406 }); … … var editMembersBlock = function editMembersBlock(_ref) { 522 410 value: extraData, 523 411 options: extraDataOptions, 524 412 help: __('Select "None" to show no extra information.', 'buddypress'), 525 onChange: function onChange(option){413 onChange: option => { 526 414 setAttributes({ 527 415 extraData: option 528 416 }); … … var editMembersBlock = function editMembersBlock(_ref) { 530 418 }), layoutPreference === 'grid' && createElement(RangeControl, { 531 419 label: __('Columns', 'buddypress'), 532 420 value: columns, 533 onChange: function onChange(value) { 534 return setAttributes({ 535 columns: value 536 }); 537 }, 421 onChange: value => setAttributes({ 422 columns: value 423 }), 538 424 min: 2, 539 425 max: 4, 540 426 required: true … … var editMembersBlock = function editMembersBlock(_ref) { 562 448 563 449 var _default = editMembersBlock; 564 450 exports.default = _default; 565 },{" @babel/runtime/helpers/toConsumableArray":"I9dH","@babel/runtime/helpers/slicedToArray":"DERy","./constants":"gr8I"}],"XEHU":[function(require,module,exports) {451 },{"./constants":"gr8I"}],"XEHU":[function(require,module,exports) { 566 452 "use strict"; 567 453 568 454 var _edit = _interopRequireDefault(require("./members/edit")); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 572 458 /** 573 459 * WordPress dependencies. 574 460 */ 575 var _wp = wp, 576 registerBlockType = _wp.blocks.registerBlockType, 577 __ = _wp.i18n.__; 461 const { 462 blocks: { 463 registerBlockType 464 }, 465 i18n: { 466 __ 467 } 468 } = wp; 578 469 /** 579 470 * Internal dependencies. 580 471 */ -
src/bp-members/js/blocks/online-members.js
diff --git src/bp-members/js/blocks/online-members.js src/bp-members/js/blocks/online-members.js index 21fbf528f..27420d521 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 PanelBody = _wp$components.PanelBody, 136 RangeControl = _wp$components.RangeControl, 137 TextControl = _wp$components.TextControl, 138 _wp$element = _wp.element, 139 Fragment = _wp$element.Fragment, 140 createElement = _wp$element.createElement, 141 __ = _wp.i18n.__; 142 /** 143 * BuddyPress dependencies. 144 */ 145 146 var _bp = bp, 147 ServerSideRender = _bp.blockComponents.ServerSideRender; 148 149 var editOnlineMembersBlock = function editOnlineMembersBlock(_ref) { 150 var attributes = _ref.attributes, 151 setAttributes = _ref.setAttributes; 152 var title = attributes.title, 153 maxMembers = attributes.maxMembers; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 PanelBody, 138 RangeControl, 139 TextControl 140 }, 141 element: { 142 Fragment, 143 createElement 144 }, 145 i18n: { 146 __ 147 }, 148 serverSideRender: ServerSideRender 149 } = wp; 150 151 const editOnlineMembersBlock = ({ 152 attributes, 153 setAttributes 154 }) => { 155 const { 156 title, 157 maxMembers 158 } = attributes; 154 159 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 155 160 title: __('Settings', 'buddypress'), 156 161 initialOpen: true 157 162 }, createElement(TextControl, { 158 163 label: __('Title', 'buddypress'), 159 164 value: title, 160 onChange: function onChange(text){165 onChange: text => { 161 166 setAttributes({ 162 167 title: text 163 168 }); … … var editOnlineMembersBlock = function editOnlineMembersBlock(_ref) { 165 170 }), createElement(RangeControl, { 166 171 label: __('Max members to show', 'buddypress'), 167 172 value: maxMembers, 168 onChange: function onChange(value) { 169 return setAttributes({ 170 maxMembers: value 171 }); 172 }, 173 onChange: value => setAttributes({ 174 maxMembers: value 175 }), 173 176 min: 1, 174 177 max: 15, 175 178 required: true … … exports.default = void 0; 192 195 /** 193 196 * WordPress dependencies. 194 197 */ 195 var _wp = wp, 196 createBlock = _wp.blocks.createBlock; 198 const { 199 blocks: { 200 createBlock 201 } 202 } = wp; 197 203 /** 198 204 * Transforms Legacy Widget to Online Members Block. 199 205 * 200 206 * @type {Object} 201 207 */ 202 208 203 vartransforms = {209 const transforms = { 204 210 from: [{ 205 211 type: 'block', 206 212 blocks: ['core/legacy-widget'], 207 isMatch: function isMatch(_ref){208 var idBase = _ref.idBase,209 instance = _ref.instance;210 213 isMatch: ({ 214 idBase, 215 instance 216 }) => { 211 217 if (!(instance !== null && instance !== void 0 && instance.raw)) { 212 218 return false; 213 219 } 214 220 215 221 return idBase === 'bp_core_whos_online_widget'; 216 222 }, 217 transform: function transform(_ref2) { 218 var instance = _ref2.instance; 223 transform: ({ 224 instance 225 }) => { 219 226 return createBlock('bp/online-members', { 220 227 title: instance.raw.title, 221 228 maxMembers: instance.raw.max_members … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 237 244 /** 238 245 * WordPress dependencies. 239 246 */ 240 var _wp = wp, 241 registerBlockType = _wp.blocks.registerBlockType, 242 __ = _wp.i18n.__; 247 const { 248 blocks: { 249 registerBlockType 250 }, 251 i18n: { 252 __ 253 } 254 } = wp; 243 255 /** 244 256 * Internal dependencies. 245 257 */ -
src/bp-members/js/dynamic-members.js
diff --git src/bp-members/js/dynamic-members.js src/bp-members/js/dynamic-members.js index 827f914c5..076e8ca2b 100644
parcelRequire = (function (modules, cache, entry, globalName) { 118 118 119 119 return newRequire; 120 120 })({"k5We":[function(require,module,exports) { 121 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }122 123 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }124 125 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }126 127 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }128 129 function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }130 131 function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }132 133 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }134 135 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }136 137 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }138 139 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }140 141 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }142 143 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }144 145 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }146 147 121 /** 148 122 * WordPress dependencies. 149 123 */ 150 var _wp = wp, 151 _wp$i18n = _wp.i18n, 152 __ = _wp$i18n.__, 153 sprintf = _wp$i18n.sprintf; 124 const { 125 i18n: { 126 __, 127 sprintf 128 } 129 } = wp; 154 130 /** 155 131 * BuddyPress dependencies. 156 132 */ 157 133 158 var _bp = bp, 159 dynamicWidgetBlock = _bp.dynamicWidgetBlock; 134 const { 135 dynamicWidgetBlock 136 } = bp; 160 137 /** 161 138 * Front-end Dynamic Members Widget Block class. 162 139 * 163 140 * @since 9.0.0 164 141 */ 165 142 166 var bpMembersWidgetBlock = /*#__PURE__*/function (_dynamicWidgetBlock) { 167 _inherits(bpMembersWidgetBlock, _dynamicWidgetBlock); 168 169 var _super = _createSuper(bpMembersWidgetBlock); 170 171 function bpMembersWidgetBlock() { 172 _classCallCheck(this, bpMembersWidgetBlock); 173 174 return _super.apply(this, arguments); 175 } 176 177 _createClass(bpMembersWidgetBlock, [{ 178 key: "loop", 179 value: function loop() { 180 var members = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; 181 var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 182 var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'active'; 183 184 var tmpl = _get(_getPrototypeOf(bpMembersWidgetBlock.prototype), "useTemplate", this).call(this, 'bp-dynamic-members-item'); 185 186 var selector = document.querySelector('#' + container); 187 var output = ''; 188 189 if (members && members.length) { 190 members.forEach(function (member) { 191 if ('active' === type && member.last_activity) { 192 /* translators: %s: a human time diff. */ 193 member.extra = sprintf(__('Active %s', 'buddypress'), member.last_activity.timediff); 194 } else if ('popular' === type && member.total_friend_count) { 195 var friendsCount = parseInt(member.total_friend_count, 10); 196 197 if (0 === friendsCount) { 198 member.extra = __('No friends', 'buddypress'); 199 } else if (1 === friendsCount) { 200 member.extra = __('1 friend', 'buddypress'); 201 } else { 202 /* translators: %s: total friend count (more than 1). */ 203 member.extra = sprintf(__('%s friends', 'buddypress'), member.total_friend_count); 204 } 205 } else if ('newest' === type && member.registered_since) { 206 /* translators: %s is time elapsed since the registration date happened */ 207 member.extra = sprintf(__('Registered %s', 'buddypress'), member.registered_since); 143 class bpMembersWidgetBlock extends dynamicWidgetBlock { 144 loop(members = [], container = '', type = 'active') { 145 const tmpl = super.useTemplate('bp-dynamic-members-item'); 146 const selector = document.querySelector('#' + container); 147 let output = ''; 148 149 if (members && members.length) { 150 members.forEach(member => { 151 if ('active' === type && member.last_activity) { 152 /* translators: %s: a human time diff. */ 153 member.extra = sprintf(__('Active %s', 'buddypress'), member.last_activity.timediff); 154 } else if ('popular' === type && member.total_friend_count) { 155 const friendsCount = parseInt(member.total_friend_count, 10); 156 157 if (0 === friendsCount) { 158 member.extra = __('No friends', 'buddypress'); 159 } else if (1 === friendsCount) { 160 member.extra = __('1 friend', 'buddypress'); 161 } else { 162 /* translators: %s: total friend count (more than 1). */ 163 member.extra = sprintf(__('%s friends', 'buddypress'), member.total_friend_count); 208 164 } 209 /* translators: %s: member name */ 210 165 } else if ('newest' === type && member.registered_since) { 166 /* translators: %s is time elapsed since the registration date happened */ 167 member.extra = sprintf(__('Registered %s', 'buddypress'), member.registered_since); 168 } 169 /* translators: %s: member name */ 211 170 212 member.avatar_alt = sprintf(__('Profile picture of %s', 'buddypress'), member.name);213 output += tmpl(member);214 });215 } else {216 output = '<div class="widget-error">' + __('No members found.', 'buddypress') + '</div>';217 }218 171 219 selector.innerHTML = output; 172 member.avatar_alt = sprintf(__('Profile picture of %s', 'buddypress'), member.name); 173 output += tmpl(member); 174 }); 175 } else { 176 output = '<div class="widget-error">' + __('No members found.', 'buddypress') + '</div>'; 220 177 } 221 }, {222 key: "start",223 value: function start() {224 var _this = this;225 178 226 this.blocks.forEach(function (block, i) { 227 var selector = block.selector; 228 var type = block.query_args.type; 229 var list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type members. 179 selector.innerHTML = output; 180 } 230 181 231 _get(_getPrototypeOf(bpMembersWidgetBlock.prototype), "getItems", _this).call(_this, type, i); // Listen to Block's Nav item clics 182 start() { 183 this.blocks.forEach((block, i) => { 184 const { 185 selector 186 } = block; 187 const { 188 type 189 } = block.query_args; 190 const list = document.querySelector('#' + selector).closest('.bp-dynamic-block-container'); // Get default Block's type members. 232 191 192 super.getItems(type, i); // Listen to Block's Nav item clics 233 193 234 list.querySelectorAll('.item-options a').forEach(function (navItem){235 navItem.addEventListener('click', function (event){236 194 list.querySelectorAll('.item-options a').forEach(navItem => { 195 navItem.addEventListener('click', event => { 196 event.preventDefault(); // Changes the displayed filter. 237 197 238 239 240 varnewType = event.target.getAttribute('data-bp-sort');198 event.target.closest('.item-options').querySelector('.selected').classList.remove('selected'); 199 event.target.classList.add('selected'); 200 const newType = event.target.getAttribute('data-bp-sort'); 241 201 242 if (newType !== _this.blocks[i].query_args.type) { 243 _get(_getPrototypeOf(bpMembersWidgetBlock.prototype), "getItems", _this).call(_this, newType, i); 244 } 245 }); 202 if (newType !== this.blocks[i].query_args.type) { 203 super.getItems(newType, i); 204 } 246 205 }); 247 206 }); 248 } 249 } ]);207 }); 208 } 250 209 251 return bpMembersWidgetBlock; 252 }(dynamicWidgetBlock); 210 } 253 211 254 varsettings = window.bpDynamicMembersSettings || {};255 varblocks = window.bpDynamicMembersBlocks || {};256 varbpDynamicMembers = new bpMembersWidgetBlock(settings, blocks);212 const settings = window.bpDynamicMembersSettings || {}; 213 const blocks = window.bpDynamicMembersBlocks || {}; 214 const bpDynamicMembers = new bpMembersWidgetBlock(settings, blocks); 257 215 258 216 if ('loading' === document.readyState) { 259 217 document.addEventListener('DOMContentLoaded', bpDynamicMembers.start()); -
src/bp-messages/classes/class-bp-messages-component.php
diff --git src/bp-messages/classes/class-bp-messages-component.php src/bp-messages/classes/class-bp-messages-component.php index 01105f390..9d1656173 100644
class BP_Messages_Component extends BP_Component { 468 468 'wp-components', 469 469 'wp-i18n', 470 470 'wp-block-editor', 471 'wp-server-side-render', 471 472 'bp-block-data', 472 'bp-block-components',473 473 ), 474 474 'style' => 'bp-sitewide-notices-block', 475 475 'style_url' => plugins_url( 'css/blocks/sitewide-notices.css', dirname( __FILE__ ) ), -
src/bp-messages/js/blocks/sitewide-notices.js
diff --git src/bp-messages/js/blocks/sitewide-notices.js src/bp-messages/js/blocks/sitewide-notices.js index 683f80566..31b4a16b2 100644
exports.default = void 0; 128 128 /** 129 129 * WordPress dependencies. 130 130 */ 131 var _wp = wp, 132 InspectorControls = _wp.blockEditor.InspectorControls, 133 _wp$components = _wp.components, 134 Disabled = _wp$components.Disabled, 135 PanelBody = _wp$components.PanelBody, 136 TextControl = _wp$components.TextControl, 137 _wp$element = _wp.element, 138 Fragment = _wp$element.Fragment, 139 createElement = _wp$element.createElement, 140 __ = _wp.i18n.__; 141 /** 142 * BuddyPress dependencies. 143 */ 144 145 var _bp = bp, 146 ServerSideRender = _bp.blockComponents.ServerSideRender; 147 148 var editSitewideNoticesBlock = function editSitewideNoticesBlock(_ref) { 149 var attributes = _ref.attributes, 150 setAttributes = _ref.setAttributes; 151 var title = attributes.title; 131 const { 132 blockEditor: { 133 InspectorControls 134 }, 135 components: { 136 Disabled, 137 PanelBody, 138 TextControl 139 }, 140 element: { 141 Fragment, 142 createElement 143 }, 144 i18n: { 145 __ 146 }, 147 serverSideRender: ServerSideRender 148 } = wp; 149 150 const editSitewideNoticesBlock = ({ 151 attributes, 152 setAttributes 153 }) => { 154 const { 155 title 156 } = attributes; 152 157 return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { 153 158 title: __('Settings', 'buddypress'), 154 159 initialOpen: true 155 160 }, createElement(TextControl, { 156 161 label: __('Title', 'buddypress'), 157 162 value: title, 158 onChange: function onChange(text){163 onChange: text => { 159 164 setAttributes({ 160 165 title: text 161 166 }); … … exports.default = void 0; 179 184 /** 180 185 * WordPress dependencies. 181 186 */ 182 var _wp = wp, 183 createBlock = _wp.blocks.createBlock; 187 const { 188 blocks: { 189 createBlock 190 } 191 } = wp; 184 192 /** 185 193 * Transforms Legacy Widget to Friends Block. 186 194 * 187 195 * @type {Object} 188 196 */ 189 197 190 vartransforms = {198 const transforms = { 191 199 from: [{ 192 200 type: 'block', 193 201 blocks: ['core/legacy-widget'], 194 isMatch: function isMatch(_ref){195 var idBase = _ref.idBase,196 instance = _ref.instance;197 202 isMatch: ({ 203 idBase, 204 instance 205 }) => { 198 206 if (!(instance !== null && instance !== void 0 && instance.raw)) { 199 207 return false; 200 208 } 201 209 202 210 return idBase === 'bp_messages_sitewide_notices_widget'; 203 211 }, 204 transform: function transform(_ref2) { 205 var instance = _ref2.instance; 212 transform: ({ 213 instance 214 }) => { 206 215 return createBlock('bp/sitewide-notices', { 207 216 title: instance.raw.title 208 217 }); … … function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de 223 232 /** 224 233 * WordPress dependencies. 225 234 */ 226 var _wp = wp, 227 registerBlockType = _wp.blocks.registerBlockType, 228 __ = _wp.i18n.__; 235 const { 236 blocks: { 237 registerBlockType 238 }, 239 i18n: { 240 __ 241 } 242 } = wp; 229 243 /** 230 244 * Internal dependencies. 231 245 */ -
src/bp-messages/js/sitewide-notices.js
diff --git src/bp-messages/js/sitewide-notices.js src/bp-messages/js/sitewide-notices.js index d027afa70..eceea12ef 100644
parcelRequire = (function (modules, cache, entry, globalName) { 118 118 119 119 return newRequire; 120 120 })({"nIsC":[function(require,module,exports) { 121 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }122 123 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }124 125 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }126 127 121 /** 128 122 * Front-end Sitewide notices block class. 129 123 * 130 124 * @since 9.0.0 131 125 */ 132 var bpSitewideNoticeBlock = /*#__PURE__*/function (){133 function bpSitewideNoticeBlock(settings) {134 _classCallCheck(this, bpSitewideNoticeBlock);135 136 var path = settings.path,137 dismissPath = settings.dismissPath,138 root = settings.root,139 nonce = settings.nonce;126 class bpSitewideNoticeBlock { 127 constructor(settings) { 128 const { 129 path, 130 dismissPath, 131 root, 132 nonce 133 } = settings; 140 134 this.path = path; 141 135 this.dismissPath = dismissPath; 142 136 this.root = root; 143 137 this.nonce = nonce; 144 138 } 145 139 146 _createClass(bpSitewideNoticeBlock, [{ 147 key: "start", 148 value: function start() { 149 var _this = this; 150 151 // Listen to each Block's dismiss button clicks 152 document.querySelectorAll('.bp-sitewide-notice-block a.dismiss-notice').forEach(function (dismissButton) { 153 dismissButton.addEventListener('click', function (event) { 154 event.preventDefault(); 155 fetch(_this.root + _this.dismissPath, { 156 method: 'POST', 157 headers: { 158 'X-WP-Nonce': _this.nonce 159 } 160 }).then(function (response) { 161 return response.json(); 162 }).then(function (data) { 163 if ('undefined' !== typeof data && 'undefined' !== typeof data.dismissed && data.dismissed) { 164 document.querySelectorAll('.bp-sitewide-notice-block').forEach(function (elem) { 165 elem.remove(); 166 }); 167 } 168 }); 140 start() { 141 // Listen to each Block's dismiss button clicks 142 document.querySelectorAll('.bp-sitewide-notice-block a.dismiss-notice').forEach(dismissButton => { 143 dismissButton.addEventListener('click', event => { 144 event.preventDefault(); 145 fetch(this.root + this.dismissPath, { 146 method: 'POST', 147 headers: { 148 'X-WP-Nonce': this.nonce 149 } 150 }).then(response => response.json()).then(data => { 151 if ('undefined' !== typeof data && 'undefined' !== typeof data.dismissed && data.dismissed) { 152 document.querySelectorAll('.bp-sitewide-notice-block').forEach(elem => { 153 elem.remove(); 154 }); 155 } 169 156 }); 170 157 }); 171 } 172 } ]);158 }); 159 } 173 160 174 return bpSitewideNoticeBlock; 175 }(); // widget_bp_core_sitewide_messages buddypress widget wp-block-bp-sitewide-notices > bp-sitewide-notice > a.dismiss-notice 161 } // widget_bp_core_sitewide_messages buddypress widget wp-block-bp-sitewide-notices > bp-sitewide-notice > a.dismiss-notice 176 162 177 163 178 varsettings = window.bpSitewideNoticeBlockSettings || {};179 varbpSitewideNotice = new bpSitewideNoticeBlock(settings);164 const settings = window.bpSitewideNoticeBlockSettings || {}; 165 const bpSitewideNotice = new bpSitewideNoticeBlock(settings); 180 166 181 167 if ('loading' === document.readyState) { 182 168 document.addEventListener('DOMContentLoaded', bpSitewideNotice.start()); -
src/bp-templates/bp-nouveau/includes/functions.php
diff --git src/bp-templates/bp-nouveau/includes/functions.php src/bp-templates/bp-nouveau/includes/functions.php index a01f82e03..a761586ae 100644
function bp_nouveau_register_primary_nav_widget_block( $blocks = array() ) { 1511 1511 'wp-components', 1512 1512 'wp-i18n', 1513 1513 'wp-block-editor', 1514 'wp-server-side-render', 1514 1515 'bp-block-data', 1515 'bp-block-components',1516 1516 ), 1517 1517 'editor_style' => 'bp-primary-nav-block', 1518 1518 'editor_style_url' => $editor_style['uri'], -
src/js/bp-activity/js/blocks/latest-activities/edit.js
diff --git src/js/bp-activity/js/blocks/latest-activities/edit.js src/js/bp-activity/js/blocks/latest-activities/edit.js index f5ebcaddc..9d0e984e8 100644
const { 19 19 i18n: { 20 20 __, 21 21 }, 22 serverSideRender: ServerSideRender, 22 23 } = wp; 23 24 24 25 /** 25 26 * BuddyPress dependencies. 26 27 */ 27 28 const { 28 blockComponents: {29 ServerSideRender,30 },31 29 blockData: { 32 30 currentPostId, 33 31 activityTypes, -
src/js/bp-blogs/js/blocks/recent-posts/edit.js
diff --git src/js/bp-blogs/js/blocks/recent-posts/edit.js src/js/bp-blogs/js/blocks/recent-posts/edit.js index 921087ac0..67450683c 100644
const { 19 19 i18n: { 20 20 __, 21 21 }, 22 serverSideRender: ServerSideRender, 22 23 } = wp; 23 24 24 /**25 * BuddyPress dependencies.26 */27 const {28 blockComponents: {29 ServerSideRender,30 },31 } = bp;32 33 25 const editRecentPostsBlock = ( { attributes, setAttributes } ) => { 34 26 const { title, maxPosts, linkTitle } = attributes; 35 27 -
src/js/bp-core/js/block-components/components/index.js
diff --git src/js/bp-core/js/block-components/components/index.js src/js/bp-core/js/block-components/components/index.js index ea14e9b39..926aa0616 100644
2 2 * BuddyPress components. 3 3 */ 4 4 import AutoCompleter from './autocompleter'; 5 import ServerSideRender from './server-side-render';6 5 7 6 export default { 8 7 AutoCompleter, 9 ServerSideRender,10 8 }; -
deleted file src/js/bp-core/js/block-components/components/server-side-render.js
diff --git src/js/bp-core/js/block-components/components/server-side-render.js src/js/bp-core/js/block-components/components/server-side-render.js deleted file mode 100644 index cba764ff7..000000000
+ - 1 /**2 * WordPress dependencies.3 */4 const {5 element: {6 createElement,7 },8 } = wp;9 10 /**11 * Compatibility Server Side Render.12 *13 * @since 9.0.014 */15 export default function ServerSideRender( props ) {16 const CompatibiltyServerSideRender = wp.serverSideRender ? wp.serverSideRender : wp.editor.ServerSideRender;17 18 return (19 <CompatibiltyServerSideRender { ...props } />20 );21 } -
src/js/bp-core/js/blocks/login-form/edit.js
diff --git src/js/bp-core/js/blocks/login-form/edit.js src/js/bp-core/js/blocks/login-form/edit.js index 7734dc7d8..36c65c342 100644
const { 18 18 i18n: { 19 19 __, 20 20 }, 21 serverSideRender: ServerSideRender, 21 22 } = wp; 22 23 23 /**24 * BuddyPress dependencies.25 */26 const {27 blockComponents: {28 ServerSideRender,29 },30 } = bp;31 32 24 const editLoginForm = ( { attributes, setAttributes } ) => { 33 25 const { title,forgotPwdLink } = attributes; 34 26 -
src/js/bp-core/js/blocks/primary-nav/edit.js
diff --git src/js/bp-core/js/blocks/primary-nav/edit.js src/js/bp-core/js/blocks/primary-nav/edit.js index 8aa4b4375..a9553486c 100644
const { 18 18 i18n: { 19 19 __, 20 20 }, 21 serverSideRender: ServerSideRender, 21 22 } = wp; 22 23 23 24 /** 24 25 * BuddyPress dependencies. 25 26 */ 26 27 const { 27 blockComponents: {28 ServerSideRender,29 },30 28 blockData: { 31 29 getCurrentWidgetsSidebar, 32 30 } -
src/js/bp-friends/js/blocks/friends/edit.js
diff --git src/js/bp-friends/js/blocks/friends/edit.js src/js/bp-friends/js/blocks/friends/edit.js index a5928e51b..1ebb2bd17 100644
const { 19 19 i18n: { 20 20 __, 21 21 }, 22 serverSideRender: ServerSideRender, 22 23 } = wp; 23 24 24 25 /** 25 26 * BuddyPress dependencies. 26 27 */ 27 28 const { 28 blockComponents: {29 ServerSideRender,30 },31 29 blockData: { 32 30 currentPostId, 33 31 } -
src/js/bp-groups/js/blocks/dynamic-groups/edit.js
diff --git src/js/bp-groups/js/blocks/dynamic-groups/edit.js src/js/bp-groups/js/blocks/dynamic-groups/edit.js index b1be4d5b5..719c5ee1c 100644
const { 20 20 i18n: { 21 21 __, 22 22 }, 23 serverSideRender: ServerSideRender, 23 24 } = wp; 24 25 25 /**26 * BuddyPress dependencies.27 */28 const {29 blockComponents: {30 ServerSideRender,31 },32 } = bp;33 34 26 /** 35 27 * Internal dependencies. 36 28 */ -
src/js/bp-groups/js/blocks/group/edit.js
diff --git src/js/bp-groups/js/blocks/group/edit.js src/js/bp-groups/js/blocks/group/edit.js index 0f44b18b2..46cc34917 100644
const { 22 22 i18n: { 23 23 __, 24 24 }, 25 serverSideRender: ServerSideRender, 25 26 } = wp; 26 27 27 28 /** … … const { 30 31 const { 31 32 blockComponents: { 32 33 AutoCompleter, 33 ServerSideRender,34 34 }, 35 35 blockData: { 36 36 isActive, -
src/js/bp-members/js/blocks/active-members/edit.js
diff --git src/js/bp-members/js/blocks/active-members/edit.js src/js/bp-members/js/blocks/active-members/edit.js index 8b3722b22..c814ccc2e 100644
const { 18 18 i18n: { 19 19 __, 20 20 }, 21 serverSideRender: ServerSideRender, 21 22 } = wp; 22 23 23 /**24 * BuddyPress dependencies.25 */26 const {27 blockComponents: {28 ServerSideRender,29 },30 } = bp;31 32 24 const editActiveMembersBlock = ( { attributes, setAttributes } ) => { 33 25 const { title, maxMembers } = attributes; 34 26 -
src/js/bp-members/js/blocks/dynamic-members/edit.js
diff --git src/js/bp-members/js/blocks/dynamic-members/edit.js src/js/bp-members/js/blocks/dynamic-members/edit.js index 88b5ee297..afe5c3b85 100644
const { 20 20 i18n: { 21 21 __, 22 22 }, 23 serverSideRender: ServerSideRender, 23 24 } = wp; 24 25 25 26 /** 26 27 * BuddyPress dependencies. 27 28 */ 28 29 const { 29 blockComponents: {30 ServerSideRender,31 },32 30 blockData: { 33 31 isActive, 34 32 } -
src/js/bp-members/js/blocks/member/edit.js
diff --git src/js/bp-members/js/blocks/member/edit.js src/js/bp-members/js/blocks/member/edit.js index fbafdb359..c3ebbce4e 100644
const { 22 22 i18n: { 23 23 __, 24 24 }, 25 serverSideRender: ServerSideRender, 25 26 } = wp; 26 27 27 28 /** … … const { 30 31 const { 31 32 blockComponents: { 32 33 AutoCompleter, 33 ServerSideRender,34 34 },