diff --git a/build/index.js b/build/index.js index ccee6f15..bdb44740 100644 --- a/build/index.js +++ b/build/index.js @@ -1 +1,2087 @@ -!function(){var e,t={992:function(e,t,r){"use strict";var n=window.wp.element,o=window.wp.plugins,a=window.wp.editPost,s=window.wp.i18n,u=window.wp.data,l=window.wp.apiFetch,c=r.n(l),i=window.wp.components,p=window.wp.hooks,h=window.wp.compose,m=r(697),d=r.n(m),v=window.wp.primitives,f=(0,n.createElement)(v.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,n.createElement)(v.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})),g=(0,n.createElement)(v.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,n.createElement)(v.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})),w=(0,n.createElement)(v.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(v.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));const E=(e,t,r)=>{const n=t.map((e=>e.value)).indexOf(e.value),o=n+("up"===r?-1:1),a=t.map((e=>Object.assign({},e))),s=a[n],u=[...a.filter((e=>e.value?e.value!==s.value:e!==s))];return u.splice(o,0,s),u},b=e=>{let{id:t,displayName:r,userNicename:n,email:o,userType:a}=e;return{id:t,label:`${r} | ${o}`,display:r,value:n,userType:a}},y=e=>{let{selectedAuthors:t,updateAuthors:r}=e;const o=(e,n)=>{let o;switch(n){case"moveDown":o=E(e,t,"down");break;case"moveUp":o=E(e,t,"up");break;case"remove":a=e,o=t.filter((e=>e.value!==a.value))}var a;r(o)};return null!=t&&t.length?t.map(((e,r)=>{const a=e.display,u=e.value;return(0,n.createElement)("div",{key:u,className:"cap-author"},(0,n.createElement)(i.Flex,{align:"center"},(0,n.createElement)(i.FlexItem,{className:"cap-author-flex-item"},(0,n.createElement)("span",null,a)),(0,n.createElement)(i.FlexItem,{justify:"flex-end",className:"cap-author-flex-item"},(0,n.createElement)(i.Flex,null,(0,n.createElement)("div",{className:"cap-icon-button-stack"},(0,n.createElement)(i.Button,{icon:f,className:"cap-icon-button",label:(0,s.__)("Move Up","co-authors-plus"),disabled:0===r||1===t.length,onClick:()=>o(e,"moveUp")}),(0,n.createElement)(i.Button,{icon:g,className:"cap-icon-button",label:(0,s.__)("Move down","co-authors-plus"),disabled:r===t.length-1||1===t.length,onClick:()=>o(e,"moveDown")})),(0,n.createElement)(i.Button,{icon:w,iconSize:20,className:"cap-icon-button",label:(0,s.__)("Remove Author","co-authors-plus"),disabled:1===t.length,onClick:()=>o(e,"remove")})))))})):null};y.propTypes={selectedAuthors:d().arrayOf([d().shape({id:d().oneOfType([d().string,d().number]),userNiceName:d().string,login:d().string,email:d().string,displayName:d().string,avatar:d().string})]).isRequired,updateAuthors:d().func.isRequired};var S=y;const _={authors:[]},A={setAuthors(e){return{type:"SET_AUTHORS",authors:[...e]}},setAuthorsStore(e){return{type:"SET_AUTHORS_STORE",authors:[...e]}},apiRequest(e){return{type:"API_REQUEST",path:e,method:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET"}}};var O=(0,u.createReduxStore)("cap/authors",{reducer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_AUTHORS":return{...e,authors:[...e.authors,...t.authors]};case"SET_AUTHORS_STORE":return{...e,authors:[...t.authors]}}return e},actions:A,selectors:{getAuthors(e){const{authors:t}=e;return t},saveAuthors(e){const{authors:t}=e;return t}},controls:{API_REQUEST(e){return c()({path:e.path,method:e.method})}},resolvers:{*getAuthors(e){if(!e)return A.setAuthors([]);const t=`/coauthors/v1/authors/${e}`,r=(yield A.apiRequest(t)).map((e=>b(e)));return A.setAuthors(r)},*saveAuthors(e,t){const r=`/coauthors/v1/authors/${e}?new_authors=${t.map((e=>e.value)).join(",")}`;yield A.apiRequest(r,"POST")}}});(0,u.register)(O);var T=()=>{const[e,t]=(0,n.useState)([]),[r,o]=(0,n.useState)([]),a=(0,u.useSelect)((e=>e("core/editor").getCurrentPostId())),l=((0,u.useSelect)((e=>{var t;return null===(t=e("cap/authors"))||void 0===t?void 0:t.saveAuthors}),[]),(0,u.useSelect)((e=>{var t;return null===(t=e("cap/authors"))||void 0===t?void 0:t.getAuthors(a)}),[a])),{setAuthorsStore:m}=(0,u.useDispatch)("cap/authors"),d=((0,u.useSelect)((e=>e("core/editor").isSavingPost)),(0,p.applyFilters)("coAuthors.search.threshold",2)),v=e=>{m(e),t(e)},f=(0,h.useDebounce)((async t=>{let r=0;if(t.lengthe.value)).join(",");try{r=await c()({path:`/coauthors/v1/search/?q=${t}&existing_authors=${n}`,method:"GET"});const e=(a=r).length>0?a.map((e=>b(e))):[];o(e)}catch(e){r=0,console.log(e)}var a}),500);return(0,n.useEffect)((()=>{l.length&&v(l)}),[l]),(0,n.createElement)(n.Fragment,null,Boolean(e.length)?(0,n.createElement)(n.Fragment,null,(0,n.createElement)(S,{selectedAuthors:e,updateAuthors:v})):(0,n.createElement)(i.Spinner,null),(0,n.createElement)(i.ComboboxControl,{className:"cap-combobox",label:(0,s.__)("Select An Author","co-authors-plus"),value:null,options:r,onChange:t=>{const n=((e,t,r)=>[...t,r.filter((t=>t.value===e))[0]])(t,e,r);v(n)},onFilterValueChange:f}))};(0,o.registerPlugin)("plugin-coauthors-document-setting",{render:()=>(0,n.createElement)(a.PluginDocumentSettingPanel,{name:"coauthors-panel",title:(0,s.__)("Authors","co-authors-plus"),className:"coauthors"},(0,n.createElement)(T,null)),icon:"users"});const{isSavingPost:x,getCurrentPost:P}=(0,u.select)("core/editor"),{getAuthors:R,saveAuthors:k}=(0,u.select)("cap/authors");let C=!0;(0,u.subscribe)((()=>{if(x())C=!1;else if(!C){const{id:e}=P(),t=R(e);k(e,t),C=!0}}))},703:function(e,t,r){"use strict";var n=r(414);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,a,s){if(s!==n){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return r.PropTypes=r,r}},697:function(e,t,r){e.exports=r(703)()},414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,e=[],n.O=function(t,r,o,a){if(!r){var s=1/0;for(i=0;i=a)&&Object.keys(n.O).every((function(e){return n.O[e](r[l])}))?r.splice(l--,1):(u=!1,a0&&e[i-1][2]>a;i--)e[i]=e[i-1];e[i]=[r,o,a]},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={826:0,431:0};n.O.j=function(t){return 0===e[t]};var t=function(t,r){var o,a,s=r[0],u=r[1],l=r[2],c=0;if(s.some((function(t){return 0!==e[t]}))){for(o in u)n.o(u,o)&&(n.m[o]=u[o]);if(l)var i=l(n)}for(t&&t(r);c { + let { + selectedAuthors, + updateAuthors + } = _ref; + /** + * + * @param {object} author author object. + * @param {function} action action type. + */ + const onClick = (author, action) => { + let authors; + switch (action) { + case 'moveDown': + authors = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.moveItem)(author, selectedAuthors, 'down'); + break; + case 'moveUp': + authors = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.moveItem)(author, selectedAuthors, 'up'); + break; + case 'remove': + authors = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.removeItem)(author, selectedAuthors); + break; + } + updateAuthors(authors); + }; + + // Bail if there are no selected authors. + if (!(selectedAuthors !== null && selectedAuthors !== void 0 && selectedAuthors.length)) { + return null; + } + return selectedAuthors.map((author, i) => { + const display = author.display; + const value = author.value; + return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { + key: value, + className: "cap-author" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Flex, { + align: "center" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.FlexItem, { + className: "cap-author-flex-item" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, display)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.FlexItem, { + justify: "flex-end", + className: "cap-author-flex-item" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Flex, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { + className: "cap-icon-button-stack" + }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_4__["default"], + className: 'cap-icon-button', + label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Move Up', 'co-authors-plus'), + disabled: i === 0 || 1 === selectedAuthors.length, + onClick: () => onClick(author, 'moveUp') + }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_5__["default"], + className: 'cap-icon-button', + label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Move down', 'co-authors-plus'), + disabled: i === selectedAuthors.length - 1 || 1 === selectedAuthors.length, + onClick: () => onClick(author, 'moveDown') + })), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.Button, { + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"], + iconSize: 20, + className: 'cap-icon-button', + label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Remove Author', 'co-authors-plus'), + disabled: 1 === selectedAuthors.length, + onClick: () => onClick(author, 'remove') + }))))); + }); +}; +AuthorsSelection.propTypes = { + selectedAuthors: prop_types__WEBPACK_IMPORTED_MODULE_7___default().arrayOf([prop_types__WEBPACK_IMPORTED_MODULE_7___default().shape({ + id: prop_types__WEBPACK_IMPORTED_MODULE_7___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), (prop_types__WEBPACK_IMPORTED_MODULE_7___default().number)]), + userNiceName: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), + login: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), + email: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), + displayName: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), + avatar: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().string), + termID: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().number) + })]).isRequired, + updateAuthors: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().func.isRequired) +}; +/* harmony default export */ __webpack_exports__["default"] = (AuthorsSelection); + +/***/ }), + +/***/ "./src/components/co-authors/index.jsx": +/*!*********************************************!*\ + !*** ./src/components/co-authors/index.jsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); +/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); +/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_6__); +/* harmony import */ var _author_selection__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../author-selection */ "./src/components/author-selection/index.jsx"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils */ "./src/utils.js"); +/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../store */ "./src/store.js"); +/* harmony import */ var _style_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./style.css */ "./src/components/co-authors/style.css"); + +/** + * Dependencies. + */ + + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Components + */ + + +/** + * Utilities + */ + + +/** + * Store + */ + + +/** + * Styles + */ + + +/** + * Register our data store. + */ +(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.register)(_store__WEBPACK_IMPORTED_MODULE_9__["default"]); + +/** + * The Render component that will be populated with data from + * the select and methods from dispatch as composed below. + * + * @return {JSX.Element} Document sidebar panel component. +*/ +const CoAuthors = () => { + /** + * Local state + */ + const [selectedAuthors, setSelectedAuthors] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)([]); // Currently selected options. + const [dropdownOptions, setDropdownOptions] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)([]); // Options that are available in the dropdown. + + /** + * Retrieve post id. + */ + const postId = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select('core/editor').getCurrentPostId()); + + /** + * CoAuthor select functions. + */ + const saveAuthors = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => { + var _select; + return (_select = select('cap/authors')) === null || _select === void 0 ? void 0 : _select.saveAuthors; + }, []); + + /** + * CoAuthor select functions. + */ + const authors = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => { + var _select2; + return (_select2 = select('cap/authors')) === null || _select2 === void 0 ? void 0 : _select2.getAuthors(postId); + }, [postId]); + + /** + * Dispatchers + */ + const { + setAuthorsStore + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useDispatch)('cap/authors'); + + /** + * Is saving post + */ + const isSavingPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select('core/editor').isSavingPost); + + /** + * Threshold filter for determining when a search query is preformed. + * + * @param {integer} threshold length threshold. default 2. + */ + const threshold = (0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_4__.applyFilters)('coAuthors.search.threshold', 2); + + /** + * Setter for updating authors and selected authors simultaneously. + * + * @param {Array} newAuthors array of new authors. + */ + const updateAuthors = newAuthors => { + setAuthorsStore(newAuthors); + setSelectedAuthors(newAuthors); + setPostTerms(newAuthors); + }; + const setPostTerms = newAuthors => { + var authorTerms = []; + newAuthors.forEach(author => { + authorTerms.push(author.termID); + }); + wp.data.dispatch('core/editor').editPost({ + coauthors: authorTerms + }); + }; + + /** + * Change handler for adding new item by value. + * Updates authors state. + * + * @param {Object} newAuthorValue new authors selected. + */ + const onChange = newAuthorValue => { + const newAuthors = (0,_utils__WEBPACK_IMPORTED_MODULE_8__.addItemByValue)(newAuthorValue, selectedAuthors, dropdownOptions); + updateAuthors(newAuthors); + }; + + /** + * The callback for updating autocomplete in the ComboBox component. + * Fetch a list of authors matching the search text. + * + * @param {string} query The text to search. + */ + const onFilterValueChange = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_6__.useDebounce)(async query => { + let response = 0; + + // Don't kick off search without having at least two characters. + if (query.length < threshold) { + setDropdownOptions([]); + return; + } + const existingAuthors = selectedAuthors.map(item => item.value).join(','); + try { + response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ + path: `/coauthors/v1/search/?q=${query}&existing_authors=${existingAuthors}`, + method: 'GET' + }); + const formattedAuthors = (items => { + if (items.length > 0) { + return items.map(item => (0,_utils__WEBPACK_IMPORTED_MODULE_8__.formatAuthorData)(item)); + } + return []; + })(response); + setDropdownOptions(formattedAuthors); + } catch (error) { + response = 0; + console.log(error); // eslint-disable-line no-console + } + }, 500); + + /** + * Run when authors updates. + */ + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { + // Bail if no authors exist, no need to set empty values. + if (!authors.length) { + return; + } + updateAuthors(authors); + }, [authors]); + return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, Boolean(selectedAuthors.length) ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_author_selection__WEBPACK_IMPORTED_MODULE_7__["default"], { + selectedAuthors: selectedAuthors, + updateAuthors: updateAuthors + })) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Spinner, null), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ComboboxControl, { + className: "cap-combobox", + label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Select An Author', 'co-authors-plus'), + value: null, + options: dropdownOptions, + onChange: onChange, + onFilterValueChange: onFilterValueChange + })); +}; +/* harmony default export */ __webpack_exports__["default"] = (CoAuthors); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins"); +/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/edit-post */ "@wordpress/edit-post"); +/* harmony import */ var _wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _components_co_authors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/co-authors */ "./src/components/co-authors/index.jsx"); + +/** + * WordPress dependencies + */ + + + + + +/** + * Components + */ + + +/** + * Component for rendering the plugin sidebar. + */ +const PluginDocumentSettingPanelAuthors = () => (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_edit_post__WEBPACK_IMPORTED_MODULE_2__.PluginDocumentSettingPanel, { + name: "coauthors-panel", + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Authors', 'co-authors-plus'), + className: "coauthors" +}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_co_authors__WEBPACK_IMPORTED_MODULE_5__["default"], null)); +(0,_wordpress_plugins__WEBPACK_IMPORTED_MODULE_1__.registerPlugin)('plugin-coauthors-document-setting', { + render: PluginDocumentSettingPanelAuthors, + icon: 'users' +}); + +/***/ }), + +/***/ "./src/store.js": +/*!**********************!*\ + !*** ./src/store.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); +/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js"); +/** + * WordPress dependencies + */ + + + +/** + * Utils + */ + + +/** + * Store defaults + */ +const DEFAULT_STATE = { + authors: [] +}; +const COAUTHORS_ENDPOINT = '/coauthors/v1/authors'; +const actions = { + setAuthors(authors) { + return { + type: 'SET_AUTHORS', + authors: [...authors] + }; + }, + setAuthorsStore(newAuthors) { + return { + type: 'SET_AUTHORS_STORE', + authors: [...newAuthors] + }; + }, + apiRequest(path) { + let method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET'; + return { + type: 'API_REQUEST', + path, + method + }; + } +}; +/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.createReduxStore)('cap/authors', { + reducer() { + let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATE; + let action = arguments.length > 1 ? arguments[1] : undefined; + switch (action.type) { + case 'SET_AUTHORS': + return { + ...state, + authors: [...state.authors, ...action.authors] + }; + case 'SET_AUTHORS_STORE': + return { + ...state, + authors: [...action.authors] + }; + } + return state; + }, + actions, + selectors: { + getAuthors(state) { + const { + authors + } = state; + return authors; + }, + saveAuthors(state) { + const { + authors + } = state; + return authors; + } + }, + controls: { + API_REQUEST(action) { + return _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_0___default()({ + path: action.path, + method: action.method + }); + } + }, + resolvers: { + *getAuthors(postId) { + if (!postId) { + return actions.setAuthors([]); + } + const path = `${COAUTHORS_ENDPOINT}/${postId}`; + const result = yield actions.apiRequest(path); + const authors = result.map(author => (0,_utils__WEBPACK_IMPORTED_MODULE_2__.formatAuthorData)(author)); + return actions.setAuthors(authors); + }, + *saveAuthors(postId, authors) { + const authorsStr = authors.map(item => item.value).join(','); + const path = `${COAUTHORS_ENDPOINT}/${postId}?new_authors=${authorsStr}`; + yield actions.apiRequest(path, 'POST'); + } + } +})); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "addItemByValue": function() { return /* binding */ addItemByValue; }, +/* harmony export */ "formatAuthorData": function() { return /* binding */ formatAuthorData; }, +/* harmony export */ "moveItem": function() { return /* binding */ moveItem; }, +/* harmony export */ "removeItem": function() { return /* binding */ removeItem; } +/* harmony export */ }); +/** + * Move an item up or down in an array. + * + * @param {string} targetItem Item to move. + * @param {Array} itemsArr Array in which to move the item. + * @param {string} direction 'up' or 'down' + * @return {Array} Array with reordered items. + */ +const moveItem = (targetItem, itemsArr, direction) => { + const currIndex = itemsArr.map(item => item.value).indexOf(targetItem.value); + const indexUpdate = direction === 'up' ? -1 : 1; + const newIndex = currIndex + indexUpdate; + const arrCopy = itemsArr.map(item => Object.assign({}, item)); + const targetCopy = arrCopy[currIndex]; + const newItems = (() => { + return arrCopy.filter(item => { + if (item.value) { + return item.value !== targetCopy.value; + } + return item !== targetCopy; + }); + })(); + const sortedArr = [...newItems]; + sortedArr.splice(newIndex, 0, targetCopy); + return sortedArr; +}; + +/** + * Remove an item from the array. + * + * @param {Object} targetItem + * @param {Array} itemsArr + * @return {Array} array of items with the target item removed. + */ +const removeItem = (targetItem, itemsArr) => { + return itemsArr.filter(item => item.value !== targetItem.value); +}; + +/** + * Get the author object from the list of available authors, + * then add it to the selected authors. + * + * @param {string} newAuthorValue + * @param {Array} currAuthors + * @param {Array} dropDownAuthors + * @return {Array} Author objects including the new author. + */ +const addItemByValue = (newAuthorValue, currAuthors, dropDownAuthors) => { + const newAuthorObj = dropDownAuthors.filter(item => item.value === newAuthorValue); + return [...currAuthors, newAuthorObj[0]]; +}; + +/** + * Format the author option object. + * + * @param {Object} root0 An author object from the API endpoint. + * @param {string} root0.id The author ID. + * @param {string} root0.displayName Name to display in the UI. + * @param {string} root0.userNicename The unique username. + * @param {string} root0.email The author's email address. + * @param {string} root0.userType The entity type, either 'wpuser' or 'guest-user'. + * @param {string} root0.termID The ID for the user's term in the "author" taxonomy + * + * @return {Object} The object containing data relevant to the Coauthors component. + */ +const formatAuthorData = _ref => { + let { + id, + displayName, + userNicename, + email, + userType, + termID + } = _ref; + return { + id, + label: `${displayName} | ${email}`, + display: displayName, + value: userNicename, + userType, + termID + }; +}; + +/***/ }), + +/***/ "./src/components/co-authors/style.css": +/*!*********************************************!*\ + !*** ./src/components/co-authors/style.css ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./node_modules/object-assign/index.js": +/*!*********************************************!*\ + !*** ./node_modules/object-assign/index.js ***! + \*********************************************/ +/***/ (function(module) { + +"use strict"; +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + + +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + + +/***/ }), + +/***/ "./node_modules/prop-types/checkPropTypes.js": +/*!***************************************************!*\ + !*** ./node_modules/prop-types/checkPropTypes.js ***! + \***************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var printWarning = function() {}; + +if (true) { + var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); + var loggedTypeFailures = {}; + var has = __webpack_require__(/*! ./lib/has */ "./node_modules/prop-types/lib/has.js"); + + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) { /**/ } + }; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + if (true) { + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ); + } + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + printWarning( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +/** + * Resets warning cache when testing. + * + * @private + */ +checkPropTypes.resetWarningCache = function() { + if (true) { + loggedTypeFailures = {}; + } +} + +module.exports = checkPropTypes; + + +/***/ }), + +/***/ "./node_modules/prop-types/factoryWithTypeCheckers.js": +/*!************************************************************!*\ + !*** ./node_modules/prop-types/factoryWithTypeCheckers.js ***! + \************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/prop-types/node_modules/react-is/index.js"); +var assign = __webpack_require__(/*! object-assign */ "./node_modules/object-assign/index.js"); + +var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "./node_modules/prop-types/lib/ReactPropTypesSecret.js"); +var has = __webpack_require__(/*! ./lib/has */ "./node_modules/prop-types/lib/has.js"); +var checkPropTypes = __webpack_require__(/*! ./checkPropTypes */ "./node_modules/prop-types/checkPropTypes.js"); + +var printWarning = function() {}; + +if (true) { + printWarning = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +function emptyFunctionThatReturnsNull() { + return null; +} + +module.exports = function(isValidElement, throwOnDirectAccess) { + /* global Symbol */ + var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. + + /** + * Returns the iterator method function contained on the iterable object. + * + * Be sure to invoke the function with the iterable as context: + * + * var iteratorFn = getIteratorFn(myIterable); + * if (iteratorFn) { + * var iterator = iteratorFn.call(myIterable); + * ... + * } + * + * @param {?object} maybeIterable + * @return {?function} + */ + function getIteratorFn(maybeIterable) { + var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } + } + + /** + * Collection of methods that allow declaration and validation of props that are + * supplied to React components. Example usage: + * + * var Props = require('ReactPropTypes'); + * var MyArticle = React.createClass({ + * propTypes: { + * // An optional string prop named "description". + * description: Props.string, + * + * // A required enum prop named "category". + * category: Props.oneOf(['News','Photos']).isRequired, + * + * // A prop named "dialog" that requires an instance of Dialog. + * dialog: Props.instanceOf(Dialog).isRequired + * }, + * render: function() { ... } + * }); + * + * A more formal specification of how these methods are used: + * + * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) + * decl := ReactPropTypes.{type}(.isRequired)? + * + * Each and every declaration produces a function with the same signature. This + * allows the creation of custom validation functions. For example: + * + * var MyLink = React.createClass({ + * propTypes: { + * // An optional string or URI prop named "href". + * href: function(props, propName, componentName) { + * var propValue = props[propName]; + * if (propValue != null && typeof propValue !== 'string' && + * !(propValue instanceof URI)) { + * return new Error( + * 'Expected a string or an URI for ' + propName + ' in ' + + * componentName + * ); + * } + * } + * }, + * render: function() {...} + * }); + * + * @internal + */ + + var ANONYMOUS = '<>'; + + // Important! + // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. + var ReactPropTypes = { + array: createPrimitiveTypeChecker('array'), + bigint: createPrimitiveTypeChecker('bigint'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + symbol: createPrimitiveTypeChecker('symbol'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + elementType: createElementTypeTypeChecker(), + instanceOf: createInstanceTypeChecker, + node: createNodeChecker(), + objectOf: createObjectOfTypeChecker, + oneOf: createEnumTypeChecker, + oneOfType: createUnionTypeChecker, + shape: createShapeTypeChecker, + exact: createStrictShapeTypeChecker, + }; + + /** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ + /*eslint-disable no-self-compare*/ + function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return x !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } + } + /*eslint-enable no-self-compare*/ + + /** + * We use an Error-like object for backward compatibility as people may call + * PropTypes directly and inspect their output. However, we don't use real + * Errors anymore. We don't inspect their stack anyway, and creating them + * is prohibitively expensive if they are created too often, such as what + * happens in oneOfType() for any type before the one that matched. + */ + function PropTypeError(message, data) { + this.message = message; + this.data = data && typeof data === 'object' ? data: {}; + this.stack = ''; + } + // Make `instanceof Error` still work for returned errors. + PropTypeError.prototype = Error.prototype; + + function createChainableTypeChecker(validate) { + if (true) { + var manualPropTypeCallCache = {}; + var manualPropTypeWarningCount = 0; + } + function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { + componentName = componentName || ANONYMOUS; + propFullName = propFullName || propName; + + if (secret !== ReactPropTypesSecret) { + if (throwOnDirectAccess) { + // New behavior only for users of `prop-types` package + var err = new Error( + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use `PropTypes.checkPropTypes()` to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + err.name = 'Invariant Violation'; + throw err; + } else if ( true && typeof console !== 'undefined') { + // Old behavior for people using React.PropTypes + var cacheKey = componentName + ':' + propName; + if ( + !manualPropTypeCallCache[cacheKey] && + // Avoid spamming the console because they are often not actionable except for lib authors + manualPropTypeWarningCount < 3 + ) { + printWarning( + 'You are manually calling a React.PropTypes validation ' + + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + + 'and will throw in the standalone `prop-types` package. ' + + 'You may be seeing this warning due to a third-party PropTypes ' + + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' + ); + manualPropTypeCallCache[cacheKey] = true; + manualPropTypeWarningCount++; + } + } + } + if (props[propName] == null) { + if (isRequired) { + if (props[propName] === null) { + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); + } + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); + } + return null; + } else { + return validate(props, propName, componentName, location, propFullName); + } + } + + var chainedCheckType = checkType.bind(null, false); + chainedCheckType.isRequired = checkType.bind(null, true); + + return chainedCheckType; + } + + function createPrimitiveTypeChecker(expectedType) { + function validate(props, propName, componentName, location, propFullName, secret) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== expectedType) { + // `propValue` being instance of, say, date/regexp, pass the 'object' + // check, but we can offer a more precise error message here rather than + // 'of type `object`'. + var preciseType = getPreciseType(propValue); + + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), + {expectedType: expectedType} + ); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunctionThatReturnsNull); + } + + function createArrayOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); + } + var propValue = props[propName]; + if (!Array.isArray(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); + } + for (var i = 0; i < propValue.length; i++) { + var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!isValidElement(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!ReactIs.isValidElementType(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createInstanceTypeChecker(expectedClass) { + function validate(props, propName, componentName, location, propFullName) { + if (!(props[propName] instanceof expectedClass)) { + var expectedClassName = expectedClass.name || ANONYMOUS; + var actualClassName = getClassName(props[propName]); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createEnumTypeChecker(expectedValues) { + if (!Array.isArray(expectedValues)) { + if (true) { + if (arguments.length > 1) { + printWarning( + 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' + ); + } else { + printWarning('Invalid argument supplied to oneOf, expected an array.'); + } + } + return emptyFunctionThatReturnsNull; + } + + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (is(propValue, expectedValues[i])) { + return null; + } + } + + var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { + var type = getPreciseType(value); + if (type === 'symbol') { + return String(value); + } + return value; + }); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + } + return createChainableTypeChecker(validate); + } + + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); + } + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); + } + for (var key in propValue) { + if (has(propValue, key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : 0; + return emptyFunctionThatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + printWarning( + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' + ); + return emptyFunctionThatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + var expectedTypes = []; + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret); + if (checkerResult == null) { + return null; + } + if (checkerResult.data && has(checkerResult.data, 'expectedType')) { + expectedTypes.push(checkerResult.data.expectedType); + } + } + var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': ''; + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.')); + } + return createChainableTypeChecker(validate); + } + + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function invalidValidatorError(componentName, location, propFullName, key, type) { + return new PropTypeError( + (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.' + ); + } + + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createStrictShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + // We need to check all keys in case some are required but missing from props. + var allKeys = assign({}, props[propName], shapeTypes); + for (var key in allKeys) { + var checker = shapeTypes[key]; + if (has(shapeTypes, key) && typeof checker !== 'function') { + return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); + } + if (!checker) { + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') + ); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || isValidElement(propValue)) { + return true; + } + + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; + } + } + } else { + // Iterator will provide entry [k,v] tuples rather than values. + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; + } + } + } + } + } else { + return false; + } + + return true; + default: + return false; + } + } + + function isSymbol(propType, propValue) { + // Native Symbol. + if (propType === 'symbol') { + return true; + } + + // falsy value can't be a Symbol + if (!propValue) { + return false; + } + + // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' + if (propValue['@@toStringTag'] === 'Symbol') { + return true; + } + + // Fallback for non-spec compliant Symbols which are polyfilled. + if (typeof Symbol === 'function' && propValue instanceof Symbol) { + return true; + } + + return false; + } + + // Equivalent of `typeof` but with special handling for array and regexp. + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; + } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } + if (isSymbol(propType, propValue)) { + return 'symbol'; + } + return propType; + } + + // This handles more types than `getPropType`. Only used for error messages. + // See `createPrimitiveTypeChecker`. + function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; + } + + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + + // Returns class name of the object, if any. + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + ReactPropTypes.checkPropTypes = checkPropTypes; + ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; + + +/***/ }), + +/***/ "./node_modules/prop-types/index.js": +/*!******************************************!*\ + !*** ./node_modules/prop-types/index.js ***! + \******************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if (true) { + var ReactIs = __webpack_require__(/*! react-is */ "./node_modules/prop-types/node_modules/react-is/index.js"); + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = __webpack_require__(/*! ./factoryWithTypeCheckers */ "./node_modules/prop-types/factoryWithTypeCheckers.js")(ReactIs.isElement, throwOnDirectAccess); +} else {} + + +/***/ }), + +/***/ "./node_modules/prop-types/lib/ReactPropTypesSecret.js": +/*!*************************************************************!*\ + !*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***! + \*************************************************************/ +/***/ (function(module) { + +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +module.exports = ReactPropTypesSecret; + + +/***/ }), + +/***/ "./node_modules/prop-types/lib/has.js": +/*!********************************************!*\ + !*** ./node_modules/prop-types/lib/has.js ***! + \********************************************/ +/***/ (function(module) { + +module.exports = Function.call.bind(Object.prototype.hasOwnProperty); + + +/***/ }), + +/***/ "./node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js": +/*!***********************************************************************************!*\ + !*** ./node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js ***! + \***********************************************************************************/ +/***/ (function(__unused_webpack_module, exports) { + +"use strict"; +/** @license React v16.13.1 + * react-is.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + + + +if (true) { + (function() { +'use strict'; + +// The Symbol used to tag the ReactElement-like types. If there is no native Symbol +// nor polyfill, then a plain number is used for performance. +var hasSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; +var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; +var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + +var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; +var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; + +function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); +} + +function typeOf(object) { + if (typeof object === 'object' && object !== null) { + var $$typeof = object.$$typeof; + + switch ($$typeof) { + case REACT_ELEMENT_TYPE: + var type = object.type; + + switch (type) { + case REACT_ASYNC_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: + case REACT_FRAGMENT_TYPE: + case REACT_PROFILER_TYPE: + case REACT_STRICT_MODE_TYPE: + case REACT_SUSPENSE_TYPE: + return type; + + default: + var $$typeofType = type && type.$$typeof; + + switch ($$typeofType) { + case REACT_CONTEXT_TYPE: + case REACT_FORWARD_REF_TYPE: + case REACT_LAZY_TYPE: + case REACT_MEMO_TYPE: + case REACT_PROVIDER_TYPE: + return $$typeofType; + + default: + return $$typeof; + } + + } + + case REACT_PORTAL_TYPE: + return $$typeof; + } + } + + return undefined; +} // AsyncMode is deprecated along with isAsyncMode + +var AsyncMode = REACT_ASYNC_MODE_TYPE; +var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; +var ContextConsumer = REACT_CONTEXT_TYPE; +var ContextProvider = REACT_PROVIDER_TYPE; +var Element = REACT_ELEMENT_TYPE; +var ForwardRef = REACT_FORWARD_REF_TYPE; +var Fragment = REACT_FRAGMENT_TYPE; +var Lazy = REACT_LAZY_TYPE; +var Memo = REACT_MEMO_TYPE; +var Portal = REACT_PORTAL_TYPE; +var Profiler = REACT_PROFILER_TYPE; +var StrictMode = REACT_STRICT_MODE_TYPE; +var Suspense = REACT_SUSPENSE_TYPE; +var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated + +function isAsyncMode(object) { + { + if (!hasWarnedAboutDeprecatedIsAsyncMode) { + hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint + + console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); + } + } + + return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; +} +function isConcurrentMode(object) { + return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; +} +function isContextConsumer(object) { + return typeOf(object) === REACT_CONTEXT_TYPE; +} +function isContextProvider(object) { + return typeOf(object) === REACT_PROVIDER_TYPE; +} +function isElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +} +function isForwardRef(object) { + return typeOf(object) === REACT_FORWARD_REF_TYPE; +} +function isFragment(object) { + return typeOf(object) === REACT_FRAGMENT_TYPE; +} +function isLazy(object) { + return typeOf(object) === REACT_LAZY_TYPE; +} +function isMemo(object) { + return typeOf(object) === REACT_MEMO_TYPE; +} +function isPortal(object) { + return typeOf(object) === REACT_PORTAL_TYPE; +} +function isProfiler(object) { + return typeOf(object) === REACT_PROFILER_TYPE; +} +function isStrictMode(object) { + return typeOf(object) === REACT_STRICT_MODE_TYPE; +} +function isSuspense(object) { + return typeOf(object) === REACT_SUSPENSE_TYPE; +} + +exports.AsyncMode = AsyncMode; +exports.ConcurrentMode = ConcurrentMode; +exports.ContextConsumer = ContextConsumer; +exports.ContextProvider = ContextProvider; +exports.Element = Element; +exports.ForwardRef = ForwardRef; +exports.Fragment = Fragment; +exports.Lazy = Lazy; +exports.Memo = Memo; +exports.Portal = Portal; +exports.Profiler = Profiler; +exports.StrictMode = StrictMode; +exports.Suspense = Suspense; +exports.isAsyncMode = isAsyncMode; +exports.isConcurrentMode = isConcurrentMode; +exports.isContextConsumer = isContextConsumer; +exports.isContextProvider = isContextProvider; +exports.isElement = isElement; +exports.isForwardRef = isForwardRef; +exports.isFragment = isFragment; +exports.isLazy = isLazy; +exports.isMemo = isMemo; +exports.isPortal = isPortal; +exports.isProfiler = isProfiler; +exports.isStrictMode = isStrictMode; +exports.isSuspense = isSuspense; +exports.isValidElementType = isValidElementType; +exports.typeOf = typeOf; + })(); +} + + +/***/ }), + +/***/ "./node_modules/prop-types/node_modules/react-is/index.js": +/*!****************************************************************!*\ + !*** ./node_modules/prop-types/node_modules/react-is/index.js ***! + \****************************************************************/ +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { + +"use strict"; + + +if (false) {} else { + module.exports = __webpack_require__(/*! ./cjs/react-is.development.js */ "./node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js"); +} + + +/***/ }), + +/***/ "@wordpress/api-fetch": +/*!**********************************!*\ + !*** external ["wp","apiFetch"] ***! + \**********************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["apiFetch"]; + +/***/ }), + +/***/ "@wordpress/components": +/*!************************************!*\ + !*** external ["wp","components"] ***! + \************************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["components"]; + +/***/ }), + +/***/ "@wordpress/compose": +/*!*********************************!*\ + !*** external ["wp","compose"] ***! + \*********************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["compose"]; + +/***/ }), + +/***/ "@wordpress/data": +/*!******************************!*\ + !*** external ["wp","data"] ***! + \******************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["data"]; + +/***/ }), + +/***/ "@wordpress/edit-post": +/*!**********************************!*\ + !*** external ["wp","editPost"] ***! + \**********************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["editPost"]; + +/***/ }), + +/***/ "@wordpress/element": +/*!*********************************!*\ + !*** external ["wp","element"] ***! + \*********************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["element"]; + +/***/ }), + +/***/ "@wordpress/hooks": +/*!*******************************!*\ + !*** external ["wp","hooks"] ***! + \*******************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["hooks"]; + +/***/ }), + +/***/ "@wordpress/i18n": +/*!******************************!*\ + !*** external ["wp","i18n"] ***! + \******************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["i18n"]; + +/***/ }), + +/***/ "@wordpress/plugins": +/*!*********************************!*\ + !*** external ["wp","plugins"] ***! + \*********************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["plugins"]; + +/***/ }), + +/***/ "@wordpress/primitives": +/*!************************************!*\ + !*** external ["wp","primitives"] ***! + \************************************/ +/***/ (function(module) { + +"use strict"; +module.exports = window["wp"]["primitives"]; + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/chunk loaded */ +/******/ !function() { +/******/ var deferred = []; +/******/ __webpack_require__.O = function(result, chunkIds, fn, priority) { +/******/ if(chunkIds) { +/******/ priority = priority || 0; +/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; +/******/ deferred[i] = [chunkIds, fn, priority]; +/******/ return; +/******/ } +/******/ var notFulfilled = Infinity; +/******/ for (var i = 0; i < deferred.length; i++) { +/******/ var chunkIds = deferred[i][0]; +/******/ var fn = deferred[i][1]; +/******/ var priority = deferred[i][2]; +/******/ var fulfilled = true; +/******/ for (var j = 0; j < chunkIds.length; j++) { +/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every(function(key) { return __webpack_require__.O[key](chunkIds[j]); })) { +/******/ chunkIds.splice(j--, 1); +/******/ } else { +/******/ fulfilled = false; +/******/ if(priority < notFulfilled) notFulfilled = priority; +/******/ } +/******/ } +/******/ if(fulfilled) { +/******/ deferred.splice(i--, 1) +/******/ var r = fn(); +/******/ if (r !== undefined) result = r; +/******/ } +/******/ } +/******/ return result; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ !function() { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function() { return module['default']; } : +/******/ function() { return module; }; +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ !function() { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = function(exports, definition) { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ !function() { +/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } +/******/ }(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ !function() { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ }(); +/******/ +/******/ /* webpack/runtime/jsonp chunk loading */ +/******/ !function() { +/******/ // no baseURI +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ "index": 0, +/******/ "./style-index": 0 +/******/ }; +/******/ +/******/ // no chunk on demand loading +/******/ +/******/ // no prefetching +/******/ +/******/ // no preloaded +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ +/******/ __webpack_require__.O.j = function(chunkId) { return installedChunks[chunkId] === 0; }; +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = function(parentChunkLoadingFunction, data) { +/******/ var chunkIds = data[0]; +/******/ var moreModules = data[1]; +/******/ var runtime = data[2]; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ return __webpack_require__.O(result); +/******/ } +/******/ +/******/ var chunkLoadingGlobal = self["webpackChunkco_authors_plus"] = self["webpackChunkco_authors_plus"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ }(); +/******/ +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module depends on other loaded chunks and execution need to be delayed +/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["./style-index"], function() { return __webpack_require__("./src/index.js"); }) +/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); +/******/ +/******/ })() +; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/php/api/endpoints/class-coauthors-controller.php b/php/api/endpoints/class-coauthors-controller.php index 3166ec89..a4122c2d 100644 --- a/php/api/endpoints/class-coauthors-controller.php +++ b/php/api/endpoints/class-coauthors-controller.php @@ -275,6 +275,12 @@ public function get_item_schema(): array { 'context' => array( 'view' ), 'readonly' => true, ), + 'term_id' => array( + 'description' => __( 'Term ID for the Authors Taxonomy', 'co-authors-plus' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), ), ); diff --git a/php/class-coauthors-endpoint.php b/php/class-coauthors-endpoint.php index d7424265..de3e7b8d 100644 --- a/php/class-coauthors-endpoint.php +++ b/php/class-coauthors-endpoint.php @@ -209,6 +209,8 @@ public function can_edit_coauthors(): bool { */ public function _format_author_data( $author ): array { + $term = $this -> coauthors -> get_author_term( $author ); + return array( 'id' => esc_html( $author->ID ), 'userNicename' => esc_html( rawurldecode( $author->user_nicename ) ), @@ -217,6 +219,7 @@ public function _format_author_data( $author ): array { 'displayName' => esc_html( str_replace( '∣', '|', $author->display_name ) ), 'avatar' => esc_url( get_avatar_url( $author->ID ) ), 'userType' => esc_html( $author->type ), + 'termID' => absint( $term -> term_id ), ); } diff --git a/src/components/author-selection/index.jsx b/src/components/author-selection/index.jsx index f84ac175..eee87f19 100644 --- a/src/components/author-selection/index.jsx +++ b/src/components/author-selection/index.jsx @@ -123,6 +123,7 @@ AuthorsSelection.propTypes = { email: PropTypes.string, displayName: PropTypes.string, avatar: PropTypes.string, + termID: PropTypes.number, } ), ] ).isRequired, updateAuthors: PropTypes.func.isRequired, diff --git a/src/components/co-authors/index.jsx b/src/components/co-authors/index.jsx index 501318a2..a76b0f2f 100644 --- a/src/components/co-authors/index.jsx +++ b/src/components/co-authors/index.jsx @@ -102,8 +102,21 @@ const CoAuthors = () => { const updateAuthors = ( newAuthors ) => { setAuthorsStore( newAuthors ); setSelectedAuthors( newAuthors ); + setPostTerms( newAuthors ); }; + const setPostTerms = ( newAuthors ) => { + + var authorTerms = []; + + newAuthors.forEach(( author ) => { + + authorTerms.push( author.termID ); + }); + + wp.data.dispatch('core/editor').editPost({ coauthors: authorTerms } ); + } + /** * Change handler for adding new item by value. * Updates authors state. diff --git a/src/index.js b/src/index.js index 57020182..fa6ff4d9 100644 --- a/src/index.js +++ b/src/index.js @@ -29,21 +29,3 @@ registerPlugin( 'plugin-coauthors-document-setting', { icon: 'users', } ); -// Save authors when the post is saved. -// https://github.com/WordPress/gutenberg/issues/17632 -const { isSavingPost, getCurrentPost } = select("core/editor"); -const { getAuthors, saveAuthors } = select("cap/authors"); - -let checked = true; // Start in a checked state. - -subscribe(() => { - if (isSavingPost()) { - checked = false; - } else if (!checked) { - const { id } = getCurrentPost(); - const authors = getAuthors(id); - saveAuthors(id, authors); - checked = true; - } -}); - diff --git a/src/utils.js b/src/utils.js index cb5e8146..6dcf6b74 100644 --- a/src/utils.js +++ b/src/utils.js @@ -71,15 +71,17 @@ export const addItemByValue = ( * @param {string} root0.userNicename The unique username. * @param {string} root0.email The author's email address. * @param {string} root0.userType The entity type, either 'wpuser' or 'guest-user'. + * @param {string} root0.termID The ID for the user's term in the "author" taxonomy * * @return {Object} The object containing data relevant to the Coauthors component. */ -export const formatAuthorData = ( { id, displayName, userNicename, email, userType } ) => { +export const formatAuthorData = ( { id, displayName, userNicename, email, userType, termID } ) => { return { id, label: `${ displayName } | ${ email }`, display: displayName, value: userNicename, userType, + termID, }; };