<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12576] trunk/src/js: Add the BP Block components & BP Blocks JavaScript development version</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12576">12576</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12576","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-03-25 06:46:46 +0000 (Wed, 25 Mar 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Add the BP Block components & BP Blocks JavaScript development version

The `src/js` directory is containing the development version of the JavaScript files used to create the first BP Block Component and the two first BP Blocks.

The BP AutoCompleter component is this first BP Block Component, it is used by the BP Member Block and the BP Group Block to let site owners easily select the member or the group they wish to feature into their post. This component uses the BP REST API to suggest results for BP single items.

See <a href="http://buddypress.trac.wordpress.org/ticket/8048">#8048</a></pre>

<h3>Added Paths</h3>
<ul>
<li>trunk/src/js/</li>
<li>trunk/src/js/bp-core/</li>
<li>trunk/src/js/bp-core/js/</li>
<li>trunk/src/js/bp-core/js/block-components/</li>
<li><a href="#trunksrcjsbpcorejsblockcomponentsbabelrc">trunk/src/js/bp-core/js/block-components/.babelrc</a></li>
<li><a href="#trunksrcjsbpcorejsblockcomponentsblockcomponentsjs">trunk/src/js/bp-core/js/block-components/block-components.js</a></li>
<li>trunk/src/js/bp-core/js/block-components/components/</li>
<li><a href="#trunksrcjsbpcorejsblockcomponentscomponentsautocompleterjs">trunk/src/js/bp-core/js/block-components/components/autocompleter.js</a></li>
<li><a href="#trunksrcjsbpcorejsblockcomponentscomponentsindexjs">trunk/src/js/bp-core/js/block-components/components/index.js</a></li>
<li>trunk/src/js/bp-groups/</li>
<li>trunk/src/js/bp-groups/js/</li>
<li>trunk/src/js/bp-groups/js/blocks/</li>
<li><a href="#trunksrcjsbpgroupsjsblocksbabelrc">trunk/src/js/bp-groups/js/blocks/.babelrc</a></li>
<li><a href="#trunksrcjsbpgroupsjsblocksgroupjs">trunk/src/js/bp-groups/js/blocks/group.js</a></li>
<li>trunk/src/js/bp-members/</li>
<li>trunk/src/js/bp-members/js/</li>
<li>trunk/src/js/bp-members/js/blocks/</li>
<li><a href="#trunksrcjsbpmembersjsblocksbabelrc">trunk/src/js/bp-members/js/blocks/.babelrc</a></li>
<li><a href="#trunksrcjsbpmembersjsblocksmemberjs">trunk/src/js/bp-members/js/blocks/member.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcjsbpcorejsblockcomponentsbabelrc"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-core/js/block-components/.babelrc</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-core/js/block-components/.babelrc                         (rev 0)
+++ trunk/src/js/bp-core/js/block-components/.babelrc   2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,3 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+{
+       "presets": ["@wordpress/default"]
+}
</ins></span></pre></div>
<a id="trunksrcjsbpcorejsblockcomponentsblockcomponentsjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-core/js/block-components/block-components.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-core/js/block-components/block-components.js                              (rev 0)
+++ trunk/src/js/bp-core/js/block-components/block-components.js        2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+export { default as blockComponents } from './components';
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-core/js/block-components/block-components.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpcorejsblockcomponentscomponentsautocompleterjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-core/js/block-components/components/autocompleter.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-core/js/block-components/components/autocompleter.js                              (rev 0)
+++ trunk/src/js/bp-core/js/block-components/components/autocompleter.js        2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,124 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const { Component, Fragment, createElement } = wp.element;
+const { Popover } = wp.components;
+const { apiFetch } = wp;
+const { __ } = wp.i18n;
+
+class AutoCompleter extends Component {
+       constructor() {
+               super( ...arguments );
+
+               this.state = {
+                       search: '',
+                       items: [],
+                       error: '',
+               };
+
+               this.searchItemName = this.searchItemName.bind( this );
+               this.selectItemName = this.selectItemName.bind( this );
+       }
+
+       searchItemName( value ) {
+               const { search } = this.state;
+               const { component, objectStatus } = this.props;
+               this.setState( { search: value } );
+
+               if ( value.length < search.length ) {
+                       this.setState( { items: [] } );
+               }
+
+               let path= '/buddypress/v1/' + component;
+
+               if ( value ) {
+                       path += '?search=' + encodeURIComponent( value );
+               }
+
+               if ( objectStatus ) {
+                       path += '&status=' + objectStatus;
+               }
+
+               apiFetch( { path:  path } ).then( items => {
+                       this.setState( { items: items } );
+               }, error => {
+                       this.setState( { error: error.message } );
+               } );
+       }
+
+       selectItemName( event, itemID ) {
+               const { onSelectItem } = this.props;
+               event.preventDefault();
+
+               this.setState( {
+                       search: '',
+                       items: [],
+                       error: '',
+               } );
+
+               return onSelectItem( { itemID: itemID } );
+       }
+
+       render() {
+               const { search, items } = this.state;
+               let { ariaLabel, placeholder, useAvatar } = this.props;
+               let itemsList;
+
+               if ( ! ariaLabel ) {
+                       ariaLabel = __( 'Item\'s name', 'buddypress' );
+               }
+
+               if ( ! placeholder ) {
+                       placeholder = __( 'Enter Item\'s name here…', 'buddypress' );
+               }
+
+               if ( items.length ) {
+                       itemsList = items.map( ( item ) => {
+                               return (
+                                       <button
+                                               type="button" key={ 'editor-autocompleters__item-item-' + item.id }
+                                               role="option"
+                                               aria-selected="true"
+                                               className="components-button components-autocomplete__result editor-autocompleters__user"
+                                               onClick={ ( event ) => this.selectItemName( event, item.id ) }
+                                       >
+                                               { useAvatar && (
+                                                       <img key="avatar" className="editor-autocompleters__user-avatar" alt="" src={ item.avatar_urls.thumb } />
+                                               ) }
+                                               <span key="name" className="editor-autocompleters__user-name">{ item.name }</span>
+
+                                               { item.mention_name && (
+                                                       <span key="slug" className="editor-autocompleters__user-slug">{ item.mention_name }</span>
+                                               ) }
+                                       </button>
+                               );
+                       } );
+               }
+
+               return (
+                       <Fragment>
+                               <input
+                                       type="text"
+                                       value={ search }
+                                       className="components-placeholder__input"
+                                       aria-label={ ariaLabel }
+                                       placeholder={ placeholder }
+                                       onChange={ ( event ) => this.searchItemName( event.target.value ) }
+                               />
+                               { 0 !== items.length &&
+                                       <Popover
+                                               className="components-autocomplete__popover"
+                                               focusOnMount={ false }
+                                               position="bottom left"
+                                       >
+                                               <div className="components-autocomplete__results">
+                                                       { itemsList }
+                                               </div>
+                                       </Popover>
+                               }
+                       </Fragment>
+               );
+       }
+}
+
+export default AutoCompleter;
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-core/js/block-components/components/autocompleter.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpcorejsblockcomponentscomponentsindexjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-core/js/block-components/components/index.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-core/js/block-components/components/index.js                              (rev 0)
+++ trunk/src/js/bp-core/js/block-components/components/index.js        2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,6 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Components
+import AutoCompleter from './autocompleter'
+
+export default {
+       AutoCompleter
+};
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-core/js/block-components/components/index.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpgroupsjsblocksbabelrc"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-groups/js/blocks/.babelrc</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-groups/js/blocks/.babelrc                         (rev 0)
+++ trunk/src/js/bp-groups/js/blocks/.babelrc   2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,3 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+{
+       "presets": ["@wordpress/default"]
+}
</ins></span></pre></div>
<a id="trunksrcjsbpgroupsjsblocksgroupjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-groups/js/blocks/group.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-groups/js/blocks/group.js                         (rev 0)
+++ trunk/src/js/bp-groups/js/blocks/group.js   2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,176 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const { registerBlockType } = wp.blocks;
+const { createElement, Fragment } = wp.element;
+const { Placeholder, Disabled, PanelBody, SelectControl, ToggleControl, Toolbar, ToolbarButton } = wp.components;
+const { InspectorControls, BlockControls } = wp.blockEditor;
+const { withSelect } = wp.data;
+const { compose } = wp.compose;
+const { ServerSideRender } = wp.editor;
+const { __ } = wp.i18n;
+
+/**
+ * BuddyPress dependencies.
+ */
+const { AutoCompleter } = bp.blockComponents;
+
+const AVATAR_SIZES = [
+       {
+               label: __( 'None', 'buddypress' ),
+               value: 'none',
+       },
+       {
+               label: __( 'Thumb', 'buddypress' ),
+               value: 'thumb',
+       },
+       {
+               label: __( 'Full', 'buddypress' ),
+               value: 'full',
+       },
+];
+
+const editGroup = ( { attributes, setAttributes, bpSettings } ) => {
+       const { isAvatarEnabled, isCoverImageEnabled } = bpSettings;
+       const { avatarSize, displayDescription, displayActionButton, displayCoverImage } = attributes;
+
+       if ( ! attributes.itemID ) {
+               return (
+                       <Placeholder
+                               icon="buddicons-groups"
+                               label={ __( 'BuddyPress Group', 'buddypress' ) }
+                               instructions={ __( 'Start typing the name of the group you want to feature into this post.', 'buddypress' ) }
+                       >
+                               <AutoCompleter
+                                       component="groups"
+                                       objectStatus="public"
+                                       ariaLabel={ __( 'Group\'s name', 'buddypress' ) }
+                                       placeholder={ __( 'Enter Group\'s name here…', 'buddypress' ) }
+                                       onSelectItem={ setAttributes }
+                                       useAvatar={ isAvatarEnabled }
+                               />
+                       </Placeholder>
+               );
+       }
+
+       return (
+               <Fragment>
+                       <BlockControls>
+                               <Toolbar>
+                                       <ToolbarButton
+                                               icon="edit"
+                                               title={ __( 'Select another group', 'buddypress' ) }
+                                               onClick={ () =>{
+                                                       setAttributes( { itemID: 0 } );
+                                               } }
+                                       />
+                               </Toolbar>
+                       </BlockControls>
+                       <InspectorControls>
+                               <PanelBody title={ __( 'Group\'s home button settings', 'buddypress' ) } initialOpen={ true }>
+                                       <ToggleControl
+                                               label={ __( 'Display Group\'s home button', 'buddypress' ) }
+                                               checked={ !! displayActionButton }
+                                               onChange={ () => {
+                                                       setAttributes( { displayActionButton: ! displayActionButton } );
+                                               } }
+                                               help={
+                                                       displayActionButton
+                                                               ? __( 'Include a link to the group\'s home page under their name.', 'buddypress' )
+                                                               : __( 'Toggle to display a link to the group\'s home page under their name.', 'buddypress' )
+                                               }
+                                       />
+                               </PanelBody>
+                               <PanelBody title={ __( 'Description settings', 'buddypress' ) } initialOpen={ false }>
+                                       <ToggleControl
+                                               label={ __( 'Display group\'s description', 'buddypress' ) }
+                                               checked={ !! displayDescription }
+                                               onChange={ () => {
+                                                       setAttributes( { displayDescription: ! displayDescription } );
+                                               } }
+                                               help={
+                                                       displayDescription
+                                                               ? __( 'Include the group\'s description under their name.', 'buddypress' )
+                                                               : __( 'Toggle to display the group\'s description under their name.', 'buddypress' )
+                                               }
+                                       />
+                               </PanelBody>
+                               { isAvatarEnabled && (
+                                       <PanelBody title={ __( 'Avatar settings', 'buddypress' ) } initialOpen={ false }>
+                                               <SelectControl
+                                                       label={ __( 'Size', 'buddypress' ) }
+                                                       value={ avatarSize }
+                                                       options={ AVATAR_SIZES }
+                                                       onChange={ ( option ) => {
+                                                               setAttributes( { avatarSize: option } );
+                                                       } }
+                                               />
+                                       </PanelBody>
+                               ) }
+                               { isCoverImageEnabled && (
+                                       <PanelBody title={ __( 'Cover image settings', 'buddypress' ) } initialOpen={ false }>
+                                               <ToggleControl
+                                                       label={ __( 'Display Cover Image', 'buddypress' ) }
+                                                       checked={ !! displayCoverImage }
+                                                       onChange={ () => {
+                                                               setAttributes( { displayCoverImage: ! displayCoverImage } );
+                                                       } }
+                                                       help={
+                                                               displayCoverImage
+                                                                       ? __( 'Include the group\'s cover image over their name.', 'buddypress' )
+                                                                       : __( 'Toggle to display the group\'s cover image over their name.', 'buddypress' )
+                                                       }
+                                               />
+                                       </PanelBody>
+                               ) }
+                       </InspectorControls>
+                       <Disabled>
+                               <ServerSideRender block="bp/group" attributes={ attributes } />
+                       </Disabled>
+               </Fragment>
+       );
+};
+
+const editGroupBlock = compose( [
+       withSelect( ( select ) => {
+               const editorSettings = select( 'core/editor' ).getEditorSettings();
+               return {
+                       bpSettings: editorSettings.bp.groups || {},
+               };
+       } ),
+] )( editGroup );
+
+registerBlockType( 'bp/group', {
+       title: __( 'Group', 'buddypress' ),
+
+       description: __( 'BuddyPress Group.', 'buddypress' ),
+
+       icon: 'buddicons-groups',
+
+       category: 'buddypress',
+
+       attributes: {
+               itemID: {
+                       type: 'integer',
+                       default: 0,
+               },
+               avatarSize: {
+                       type: 'string',
+                       default: 'full',
+               },
+               displayDescription: {
+                       type: 'boolean',
+                       default: true,
+               },
+               displayActionButton: {
+                       type: 'boolean',
+                       default: true,
+               },
+               displayCoverImage: {
+                       type: 'boolean',
+                       default: true,
+               },
+       },
+
+       edit: editGroupBlock,
+} );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-groups/js/blocks/group.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpmembersjsblocksbabelrc"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-members/js/blocks/.babelrc</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-members/js/blocks/.babelrc                                (rev 0)
+++ trunk/src/js/bp-members/js/blocks/.babelrc  2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,3 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+{
+       "presets": ["@wordpress/default"]
+}
</ins></span></pre></div>
<a id="trunksrcjsbpmembersjsblocksmemberjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-members/js/blocks/member.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-members/js/blocks/member.js                               (rev 0)
+++ trunk/src/js/bp-members/js/blocks/member.js 2020-03-25 06:46:46 UTC (rev 12576)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,177 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const { registerBlockType } = wp.blocks;
+const { createElement, Fragment } = wp.element;
+const { Placeholder, Disabled, PanelBody, SelectControl, ToggleControl, Toolbar, ToolbarButton } = wp.components;
+const { InspectorControls, BlockControls } = wp.blockEditor;
+const { withSelect } = wp.data;
+const { compose } = wp.compose;
+const { ServerSideRender } = wp.editor;
+const { __ } = wp.i18n;
+
+/**
+ * BuddyPress dependencies.
+ */
+const { AutoCompleter } = bp.blockComponents;
+
+const AVATAR_SIZES = [
+       {
+               label: __( 'None', 'buddypress' ),
+               value: 'none',
+       },
+       {
+               label: __( 'Thumb', 'buddypress' ),
+               value: 'thumb',
+       },
+       {
+               label: __( 'Full', 'buddypress' ),
+               value: 'full',
+       },
+];
+
+const editMember = ( { attributes, setAttributes, bpSettings } ) => {
+       const { isAvatarEnabled, isMentionEnabled, isCoverImageEnabled } = bpSettings;
+       const { avatarSize, displayMentionSlug, displayActionButton, displayCoverImage } = attributes;
+
+       if ( ! attributes.itemID ) {
+               return (
+                       <Placeholder
+                               icon="admin-users"
+                               label={ __( 'BuddyPress Member', 'buddypress' ) }
+                               instructions={ __( 'Start typing the name of the member you want to feature into this post.', 'buddypress' ) }
+                       >
+                               <AutoCompleter
+                                       component="members"
+                                       ariaLabel={ __( 'Member\'s username', 'buddypress' ) }
+                                       placeholder={ __( 'Enter Member\'s username here…', 'buddypress' ) }
+                                       onSelectItem={ setAttributes }
+                                       useAvatar={ isAvatarEnabled }
+                               />
+                       </Placeholder>
+               );
+       }
+
+       return (
+               <Fragment>
+                       <BlockControls>
+                               <Toolbar>
+                                       <ToolbarButton
+                                               icon="edit"
+                                               title={ __( 'Select another member', 'buddypress' ) }
+                                               onClick={ () =>{
+                                                       setAttributes( { itemID: 0 } );
+                                               } }
+                                       />
+                               </Toolbar>
+                       </BlockControls>
+                       <InspectorControls>
+                               <PanelBody title={ __( 'Profile button settings', 'buddypress' ) } initialOpen={ true }>
+                                       <ToggleControl
+                                               label={ __( 'Display Profile button', 'buddypress' ) }
+                                               checked={ !! displayActionButton }
+                                               onChange={ () => {
+                                                       setAttributes( { displayActionButton: ! displayActionButton } );
+                                               } }
+                                               help={
+                                                       displayActionButton
+                                                               ? __( 'Include a link to the user\'s profile page under their display name.', 'buddypress' )
+                                                               : __( 'Toggle to display a link to the user\'s profile page under their display name.', 'buddypress' )
+                                               }
+                                       />
+                               </PanelBody>
+                               { isAvatarEnabled && (
+                                       <PanelBody title={ __( 'Avatar settings', 'buddypress' ) } initialOpen={ false }>
+                                               <SelectControl
+                                                       label={ __( 'Size', 'buddypress' ) }
+                                                       value={ avatarSize }
+                                                       options={ AVATAR_SIZES }
+                                                       onChange={ ( option ) => {
+                                                               setAttributes( { avatarSize: option } );
+                                                       } }
+                                               />
+                                       </PanelBody>
+                               ) }
+                               { isCoverImageEnabled && (
+                                       <PanelBody title={ __( 'Cover image settings', 'buddypress' ) } initialOpen={ false }>
+                                               <ToggleControl
+                                                       label={ __( 'Display Cover Image', 'buddypress' ) }
+                                                       checked={ !! displayCoverImage }
+                                                       onChange={ () => {
+                                                               setAttributes( { displayCoverImage: ! displayCoverImage } );
+                                                       } }
+                                                       help={
+                                                               displayCoverImage
+                                                                       ? __( 'Include the user\'s cover image over their display name.', 'buddypress' )
+                                                                       : __( 'Toggle to display the user\'s cover image over their display name.', 'buddypress' )
+                                                       }
+                                               />
+                                       </PanelBody>
+                               ) }
+                               { isMentionEnabled && (
+                                       <PanelBody title={ __( 'Mention settings', 'buddypress' ) } initialOpen={ false }>
+                                               <ToggleControl
+                                                       label={ __( 'Display Mention slug', 'buddypress' ) }
+                                                       checked={ !! displayMentionSlug }
+                                                       onChange={ () => {
+                                                               setAttributes( { displayMentionSlug: ! displayMentionSlug } );
+                                                       } }
+                                                       help={
+                                                               displayMentionSlug
+                                                                       ? __( 'Include the user\'s mention name under their display name.', 'buddypress' )
+                                                                       : __( 'Toggle to display the user\'s mention name under their display name.', 'buddypress' )
+                                                       }
+                                               />
+                                       </PanelBody>
+                               ) }
+                       </InspectorControls>
+                       <Disabled>
+                               <ServerSideRender block="bp/member" attributes={ attributes } />
+                       </Disabled>
+               </Fragment>
+       );
+};
+
+const editMemberBlock = compose( [
+       withSelect( ( select ) => {
+               const editorSettings = select( 'core/editor' ).getEditorSettings();
+               return {
+                       bpSettings: editorSettings.bp.members || {},
+               };
+       } ),
+] )( editMember );
+
+registerBlockType( 'bp/member', {
+       title: __( 'Member', 'buddypress' ),
+
+       description: __( 'BuddyPress Member.', 'buddypress' ),
+
+       icon: 'admin-users',
+
+       category: 'buddypress',
+
+       attributes: {
+               itemID: {
+                       type: 'integer',
+                       default: 0,
+               },
+               avatarSize: {
+                       type: 'string',
+                       default: 'full',
+               },
+               displayMentionSlug: {
+                       type: 'boolean',
+                       default: true,
+               },
+               displayActionButton: {
+                       type: 'boolean',
+                       default: true,
+               },
+               displayCoverImage: {
+                       type: 'boolean',
+                       default: true,
+               },
+       },
+
+       edit: editMemberBlock,
+} );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-members/js/blocks/member.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>