diff --git a/.deployignore b/.deployignore deleted file mode 100644 index e215dfaf..00000000 --- a/.deployignore +++ /dev/null @@ -1,21 +0,0 @@ -.DS_Store -Thumbs.db -wp-cli.local.yml -node_modules/ -*.sql -*.tar.gz -*.zip -.phpunit.result.cache -Dockerfile -output.log -.github -tests -bin -composer.lock -.phpcs.xml -phpunit.xml -configure.php -DOCKER_ENV -phpunit.xml -.phpcs -Makefile diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 115b12e2..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,25 +0,0 @@ -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - - - package-ecosystem: "composer" - directory: "/" - schedule: - interval: "weekly" - - - package-ecosystem: "npm" - directory: "/" - schedule: - interval: "weekly" - day: "saturday" - time: "09:00" - timezone: "America/New_York" - ignore: - - dependency-name: "@wordpress/*" diff --git a/.github/workflows/built-branch.yml b/.github/workflows/built-branch.yml deleted file mode 100644 index 5e575f31..00000000 --- a/.github/workflows/built-branch.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Create a -built branch - -on: - push: - branches: - - production - -jobs: - built-branch: - uses: alleyinteractive/.github/.github/workflows/built-branch.yml@main - with: - node: 20 diff --git a/.github/workflows/built-release.yml b/.github/workflows/built-release.yml deleted file mode 100644 index 14b40559..00000000 --- a/.github/workflows/built-release.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Built Release - -on: - push: - branches: - - develop - - main - - production - -jobs: - built-release: - uses: alleyinteractive/.github/.github/workflows/built-release.yml@main - with: - node: 20 diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml deleted file mode 100644 index 14ae1bda..00000000 --- a/.github/workflows/code-quality.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Code Quality - -on: - push: - branches: - - production - pull_request: - schedule: - - cron: '0 0 * * *' - -jobs: - coding-quality: - uses: alleyinteractive/.github/.github/workflows/php-composer-command.yml@main - with: - php: 8.1 - command: | - phpcs - phpstan diff --git a/.github/workflows/dependabot-auto-approve.yml b/.github/workflows/dependabot-auto-approve.yml deleted file mode 100644 index e2119dec..00000000 --- a/.github/workflows/dependabot-auto-approve.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: dependabot-auto-approve -on: - pull_request: - -permissions: - pull-requests: write - contents: write - -jobs: - dependabot: - uses: alleyinteractive/.github/.github/workflows/dependabot-auto-approve.yml@main diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml deleted file mode 100644 index aaed13d4..00000000 --- a/.github/workflows/dependabot-auto-merge.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: dependabot-auto-merge -on: pull_request_target - -permissions: - pull-requests: write - contents: write - -jobs: - dependabot: - uses: alleyinteractive/.github/.github/workflows/dependabot-auto-merge.yml@main diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml deleted file mode 100644 index e2d5b6b2..00000000 --- a/.github/workflows/node-tests.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Node Tests - -on: - push: - branches: - - production - pull_request: - schedule: - - cron: '0 0 * * *' - -jobs: - node-tests: - uses: alleyinteractive/.github/.github/workflows/node-tests.yml@main - with: - run-audit: true - ci: true - node: 20 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index 99f051f3..00000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Testing Suite - -on: - pull_request: - -jobs: - unit-tests: - strategy: - matrix: - php: [8.0, 8.1] - wordpress: [5.9, "latest"] - uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main - with: - php: ${{ matrix.php }} - wordpress: ${{ matrix.wordpress }} diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml deleted file mode 100644 index 0cdea233..00000000 --- a/.github/workflows/update-changelog.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: "Update Changelog" - -on: - release: - types: [released] - -jobs: - update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: main - - - name: Update Changelog - uses: stefanzweifel/changelog-updater-action@v1 - with: - latest-version: ${{ github.event.release.name }} - release-notes: ${{ github.event.release.body }} - - - name: Commit updated CHANGELOG - uses: stefanzweifel/git-auto-commit-action@v5 - with: - branch: main - commit_message: Update CHANGELOG - file_pattern: CHANGELOG.md diff --git a/.github/workflows/upgrade-wordpress-plugin.yml b/.github/workflows/upgrade-wordpress-plugin.yml deleted file mode 100644 index 2676fe83..00000000 --- a/.github/workflows/upgrade-wordpress-plugin.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Update WordPress Plugin - -on: - schedule: - - cron: '0 */6 * * *' - -permissions: - contents: write - pull-requests: write - -jobs: - update-plugin: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: alleyinteractive/action-update-wordpress-plugin@v1.2.1 - with: - plugin-file: 'byline-manager.php' diff --git a/.gitignore b/.gitignore index 3074daaf..e215dfaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,21 @@ .DS_Store -.vscode -.npm Thumbs.db wp-cli.local.yml node_modules/ -composer.lock *.sql *.tar.gz *.zip -.phpcs/*.json .phpunit.result.cache - -# Client build files -client/build/ -/vendor +Dockerfile +output.log +.github +tests +bin +composer.lock +.phpcs.xml +phpunit.xml +configure.php +DOCKER_ENV +phpunit.xml +.phpcs +Makefile diff --git a/.phpcs.xml b/.phpcs.xml deleted file mode 100644 index 37c4fa05..00000000 --- a/.phpcs.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - PHP_CodeSniffer standard for byline-manager. - - - - - - - - - - - - - - - - - - - - - - - - tests/ - build/ - vendor/ - - - - - - - - - - - - - - - - - diff --git a/.phpcs/.gitkeep b/.phpcs/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/client/build/assetMap.json b/client/build/assetMap.json new file mode 100644 index 00000000..e566d036 --- /dev/null +++ b/client/build/assetMap.json @@ -0,0 +1 @@ +{"hash":"66d8b6653ab5ca4b386a","mode":"production","main":{"css":{"path":"main.4e315351.min.css","hash":"566381b80137883c50db"},"js":{"path":"main.4e315351.bundle.js","hash":"a15cb16198142bb3a68f"},"php":{"path":"main.4e315351.bundle.asset.php","hash":"66d8b6653ab5ca4b386a"}},"blockEditor":{"css":{"path":"blockEditor.a7ce6649.min.css","hash":"566381b80137883c50db"},"js":{"path":"blockEditor.a7ce6649.bundle.js","hash":"580fabc81ade982b9603"},"php":{"path":"blockEditor.a7ce6649.bundle.asset.php","hash":"66d8b6653ab5ca4b386a"}}} \ No newline at end of file diff --git a/client/build/blockEditor.a7ce6649.bundle.asset.php b/client/build/blockEditor.a7ce6649.bundle.asset.php new file mode 100644 index 00000000..ca0bab50 --- /dev/null +++ b/client/build/blockEditor.a7ce6649.bundle.asset.php @@ -0,0 +1 @@ + array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-polyfill', 'wp-url'), 'version' => '3fc0f8b86c07acbddccd'); diff --git a/client/build/blockEditor.a7ce6649.bundle.js b/client/build/blockEditor.a7ce6649.bundle.js new file mode 100644 index 00000000..b63b12ad --- /dev/null +++ b/client/build/blockEditor.a7ce6649.bundle.js @@ -0,0 +1,2 @@ +/*! For license information please see blockEditor.a7ce6649.bundle.js.LICENSE.txt */ +!function(){var e={"./client/src/block-editor.js":function(e,t,n){"use strict";var r,o,i,a=n("@wordpress/i18n"),l=window.wp.plugins,s=n("./client/src/containers/provider/index.jsx"),c=n("./client/src/containers/container/index.jsx"),d=n("./client/src/containers/panel/index.jsx"),u=("undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature,n("./client/src/store/index.js"));function f(){return React.createElement(d.c,null,React.createElement("p",null,React.createElement("strong",null,(0,a.__)("Byline","byline-manager"))),React.createElement(c.c,{store:u.c}))}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature,(0,l.registerPlugin)("byline-manager-panel-info-provider",{render:s.c}),(0,l.registerPlugin)("byline-manager",{render:f}),(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&o.register(f,"BylineManagerSlotFill","/home/runner/work/byline-manager/byline-manager/client/src/block-editor.js"),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/components/byline-autocomplete/index.jsx":function(e,t,n){"use strict";n.d(t,{c:function(){return L}});var r,o=n("./node_modules/@babel/runtime/helpers/esm/extends.js"),i=n("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),a=n("@wordpress/api-fetch"),l=n.n(a),s=window.wp.url,c=n("@wordpress/element"),d=n("./node_modules/classnames/index.js"),u=n.n(d),f=n("./node_modules/prop-types/index.js"),p=n.n(f),h=n("./node_modules/react-autocomplete/build/lib/Autocomplete.js"),m=n.n(h),b=n("react");function y(e,t){const[n,r]=b.useState(e);return b.useEffect((()=>{const n=setTimeout((()=>{r(e)}),t);return()=>{clearTimeout(n)}}),[e,t]),n}function g(e){var t=e.id,n=e.profiles,r=e.onUpdate,a=e.profilesApiUrl,d=e.addAuthorPlaceholder,f=e.addAuthorLabel,p=(0,c.useState)(""),h=(0,i.c)(p,2),b=h[0],g=h[1],v=(0,c.useState)([]),x=(0,i.c)(v,2),w=x[0],L=x[1],H=y(b,750),j=(0,c.useCallback)((function(e){l()({url:(0,s.addQueryArgs)(a,{s:e})}).then((function(e){var t=n.map((function(e){return e.id})),r=e.filter((function(e){return t.indexOf(e.id)<0}));L(r)}))}),[a,n]),I={className:"components-text-control__input",type:"text",placeholder:d,id:t,onKeyDown:function(e){13===e.keyCode&&e.preventDefault()}};return(0,c.useEffect)((function(){""!==H&&j(H)}),[H,j]),React.createElement("div",{className:"profile-controls components-base-control__field"},React.createElement("label",{className:"components-base-control__label",htmlFor:t},f),React.createElement(m(),{inputProps:I,items:w,value:b,getItemValue:function(e){return e.name},wrapperStyle:{position:"relative",display:"block"},onSelect:function(e,t){g(""),L([]),r(t)},onChange:function(e,t){return g(t)},renderMenu:function(e){return React.createElement("div",{className:"menu"},e)},renderItem:function(e,t){return React.createElement("div",{key:e.id,className:u()("item",{"item-highlighted":t})},e.name)},renderInput:function(e){return React.createElement("input",(0,o.c)({},e,{style:{width:"100%"}}))}}))}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),("undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default.signature:function(e){return e})(g,"useState{[search, setSearch]('')}\nuseState{[searchResults, setSearchResults]([])}\nuseDebounce{debouncedSearchString}\nuseCallback{doProfileSearch}\nuseEffect{}",(function(){return[y]})),g.defaultProps={id:"profiles_autocomplete"},g.propTypes={id:p().string,profiles:p().arrayOf(p().shape({id:p().oneOfType([p().number,p().string]),byline_id:p().number,name:p().string,image:p().oneOfType([p().bool,p().string])})).isRequired,onUpdate:p().func.isRequired,profilesApiUrl:p().string.isRequired,addAuthorPlaceholder:p().string.isRequired,addAuthorLabel:p().string.isRequired};var v,x,w=g,L=w;(v="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(v.register(g,"BylineAutocomplete","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-autocomplete/index.jsx"),v.register(w,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-autocomplete/index.jsx")),(x="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&x(e)},"./client/src/components/byline-freeform/index.jsx":function(e,t,n){"use strict";var r,o=n("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),i=n("./node_modules/prop-types/index.js"),a=n.n(i),l=n("@wordpress/components"),s=n("@wordpress/element");function c(e){var t=e.id,n=e.addFreeformLabel,r=e.addFreeformPlaceholder,i=e.addFreeformButtonLabel,a=e.onUpdate,c=(0,s.useState)(""),d=(0,o.c)(c,2),u=d[0],f=d[1];return React.createElement("div",{className:"freeform-controls components-base-control__field",style:{marginTop:15}},React.createElement("label",{className:"components-base-control__label",htmlFor:t},n),React.createElement("div",{className:"freeformInputGrp"},React.createElement("input",{className:"components-text-control__input",id:t,name:t,onChange:function(e){f(e.target.value)},placeholder:r,type:"text",value:u}),React.createElement(l.Button,{label:i,className:"button",size:"small",variant:"secondary",disabled:!u,onClick:function(e){e.preventDefault(),a({id:("text","".concat("text","-").concat((new Date).getTime())),name:u}),f("")}},i)))}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),("undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default.signature:function(e){return e})(c,"useState{[textByline, setTextByline]('')}"),c.defaultProps={id:"byline_freeform"},c.propTypes={id:a().string,addFreeformLabel:a().string.isRequired,addFreeformPlaceholder:a().string.isRequired,addFreeformButtonLabel:a().string.isRequired,onUpdate:a().func.isRequired};var d,u,f=c;t.c=f,(d="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(d.register(c,"BylineFreeform","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-freeform/index.jsx"),d.register(f,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-freeform/index.jsx")),(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&u(e)},"./client/src/components/byline-list-item/index.jsx":function(e,t,n){"use strict";var r,o=n("./node_modules/react-sortable-hoc/dist/react-sortable-hoc.esm.js"),i=n("@wordpress/components"),a=n("@wordpress/i18n");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,c=(0,o.wX)((function(e){var t=e.name,n=e.image,r=e.removeItem,o=e.removeAuthorLabel;return React.createElement(i.__experimentalItem,{className:"byline-list-item"},n?React.createElement("img",{src:n,alt:t}):null,React.createElement("span",null,t),React.createElement(i.Button,{label:o,isDestructive:!0,variant:"secondary",size:"small",onClick:function(e){e.preventDefault(),r()}},(0,a.__)("Remove","byline-manager")))})),d=c;t.c=d,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(c,"BylineListItem","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-list-item/index.jsx"),l.register(d,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-list-item/index.jsx")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/components/byline-list/index.jsx":function(e,t,n){"use strict";var r,o=n("./node_modules/react-sortable-hoc/dist/react-sortable-hoc.esm.js"),i=n("@wordpress/components"),a=n("./client/src/components/byline-list-item/index.jsx");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,c=(0,o.Yb)((function(e){var t=e.profiles,n=e.removeItem,r=e.removeAuthorLabel;return React.createElement(i.__experimentalItemGroup,{style:{margin:"15px 0 0"}},t.map((function(e,t){return React.createElement(a.c,{key:"item-".concat(e.id),index:t,count:t,bylineId:e.byline_id||0,name:e.name||"",image:e.image||"",removeItem:function(){return n(e.id)},removeAuthorLabel:r})})))})),d=c;t.c=d,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(c,"BylineList","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-list/index.jsx"),l.register(d,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-list/index.jsx")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/components/byline-slot-wrapper/index.jsx":function(e,t,n){"use strict";var r,o=n("./node_modules/prop-types/index.js"),i=n.n(o),a=n("@wordpress/components"),l=n("@wordpress/element"),s=n("./client/src/components/byline-autocomplete/index.jsx"),c=n("./client/src/components/byline-freeform/index.jsx"),d=n("./client/src/components/byline-list/index.jsx");function u(e){var t=e.addAuthorLabel,n=e.addAuthorPlaceholder,r=e.addFreeformButtonLabel,o=e.addFreeformLabel,i=e.addFreeformPlaceholder,u=e.addProfile,f=e.autocompleteInputId,p=e.freeformInputId,h=e.profiles,m=e.profilesApiUrl,b=e.removeAuthorLabel,y=e.removeProfile,g=e.reorderProfile;return React.createElement("div",{className:"components-base-control"},null===h?React.createElement("div",{style:{textAlign:"center"}},React.createElement(a.Spinner,null)):React.createElement(l.Fragment,null,React.createElement(s.c,{id:f,profiles:h,onUpdate:u,profilesApiUrl:m||bylineData.profilesApiUrl,addAuthorPlaceholder:n||bylineData.addAuthorPlaceholder,addAuthorLabel:t||bylineData.addAuthorLabel}),React.createElement(c.c,{id:p,onUpdate:u,addFreeformLabel:o||bylineData.addFreeformLabel,addFreeformPlaceholder:i||bylineData.addFreeformPlaceholder,addFreeformButtonLabel:r||bylineData.addFreeformButtonLabel}),0!==h.length?React.createElement(d.c,{profiles:h,onSortEnd:g,lockAxis:"y",helperClass:"byline-list-item",removeItem:y,removeAuthorLabel:b||bylineData.removeAuthorLabel}):null))}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature,u.defaultProps={addAuthorLabel:null,addAuthorPlaceholder:null,addFreeformButtonLabel:null,addFreeformLabel:null,addFreeformPlaceholder:null,autocompleteInputId:"profiles_autocomplete",freeformInputId:"byline_freeform",profiles:[],profilesApiUrl:null,removeAuthorLabel:null},u.propTypes={addAuthorLabel:i().string,addAuthorPlaceholder:i().string,addFreeformButtonLabel:i().string,addFreeformLabel:i().string,addFreeformPlaceholder:i().string,addProfile:i().func.isRequired,autocompleteInputId:i().string,freeformInputId:i().string,profiles:i().arrayOf(i().shape({id:i().oneOfType([i().number,i().string]),byline_id:i().number,name:i().string,image:i().oneOfType([i().bool,i().string])})),profilesApiUrl:i().string,removeAuthorLabel:i().string,removeProfile:i().func.isRequired,reorderProfile:i().func.isRequired};var f,p,h=u;t.c=h,(f="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(f.register(u,"BylineSlotWrapper","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-slot-wrapper/index.jsx"),f.register(h,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-slot-wrapper/index.jsx")),(p="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&p(e)},"./client/src/containers/container/index.jsx":function(e,t,n){"use strict";var r,o=n("./node_modules/prop-types/index.js"),i=n.n(o),a=n("@wordpress/data"),l=n("@wordpress/element"),s=n("./client/src/utils/set-byline.js"),c=n("./client/src/components/byline-slot-wrapper/index.jsx");function d(e){var t=e.metaKey,n=e.store,r=(0,a.useSelect)((function(e){return e(n).getProfiles()}),[]),o=(0,a.useDispatch)(n),i=o.actionAddProfile,d=o.actionRemoveProfile,u=o.actionReorderProfile,f=(0,l.useCallback)((function(){(0,s.c)(a.dispatch,t)}),[t]);return(0,l.useEffect)((function(){null!==r&&f(r)}),[r,f]),React.createElement(c.c,{profiles:r,addProfile:i,removeProfile:d,reorderProfile:u})}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),("undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default.signature:function(e){return e})(d,"useSelect{profiles}\nuseDispatch{{\n actionAddProfile: addProfile,\n actionRemoveProfile: removeProfile,\n actionReorderProfile: reorderProfile,\n }}\nuseCallback{saveByline}\nuseEffect{}",(function(){return[a.useSelect,a.useDispatch]})),d.defaultProps={metaKey:"byline"},d.propTypes={metaKey:i().string,store:i().string.isRequired};var u,f,p=d;t.c=p,(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(u.register(d,"BylineSlotContainer","/home/runner/work/byline-manager/byline-manager/client/src/containers/container/index.jsx"),u.register(p,"default","/home/runner/work/byline-manager/byline-manager/client/src/containers/container/index.jsx")),(f="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&f(e)},"./client/src/containers/panel/index.jsx":function(e,t,n){"use strict";n.d(t,{c:function(){return m}});var r,o=n("./node_modules/prop-types/index.js"),i=n.n(o),a=window.wp.editPost,l=n("@wordpress/components");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var s=(0,l.createSlotFill)("BylineManagerPanelInfo"),c=s.Fill,d=s.Slot;function u(e){var t=e.children;return React.createElement(c,null,React.createElement(a.PluginPostStatusInfo,null,React.createElement("div",{style:{width:"100%"}},React.createElement(l.__experimentalDivider,null),t)))}u.Slot=d,u.propTypes={children:i().node.isRequired};var f,p,h=u,m=h;(f="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(f.register(c,"Fill","/home/runner/work/byline-manager/byline-manager/client/src/containers/panel/index.jsx"),f.register(d,"Slot","/home/runner/work/byline-manager/byline-manager/client/src/containers/panel/index.jsx"),f.register(u,"BylineManagerPanelInfo","/home/runner/work/byline-manager/byline-manager/client/src/containers/panel/index.jsx"),f.register(h,"default","/home/runner/work/byline-manager/byline-manager/client/src/containers/panel/index.jsx")),(p="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&p(e)},"./client/src/containers/provider/index.jsx":function(e,t,n){"use strict";var r,o=n("@wordpress/element"),i=n("./client/src/containers/panel/index.jsx");function a(){return React.createElement(i.c.Slot,null,(function(e){return React.createElement(o.Fragment,null,e)}))}e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,c=a;t.c=c,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(a,"BylineManagerPanelInfoProvider","/home/runner/work/byline-manager/byline-manager/client/src/containers/provider/index.jsx"),l.register(c,"default","/home/runner/work/byline-manager/byline-manager/client/src/containers/provider/index.jsx")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/store/actions-types/hydrate-action-types.js":function(e,t,n){"use strict";var r;e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a={HYDRATE_PROFILES:"byline-manager/hydrate/HYDRATE_PROFILES",RECEIVE_HYDRATED_PROFILES:"byline-manager/hydrate/RECEIVE_HYDRATED_PROFILES"},l=a;t.c=l,(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(o.register(a,"HYDRATE_ACTION_TYPES","/home/runner/work/byline-manager/byline-manager/client/src/store/actions-types/hydrate-action-types.js"),o.register(l,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/actions-types/hydrate-action-types.js")),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/store/actions-types/index.js":function(e,t,n){"use strict";n.d(t,{C:function(){return o.c},m:function(){return r.c}});var r=n("./client/src/store/actions-types/hydrate-action-types.js"),o=n("./client/src/store/actions-types/modify-action-types.js");"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature},"./client/src/store/actions-types/modify-action-types.js":function(e,t,n){"use strict";var r;e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a={ADD_PROFILE:"byline-manager/modify/ADD_PROFILE",REMOVE_PROFILE:"byline-manager/modify/REMOVE_PROFILE",REORDER_PROFILE:"byline-manager/modify/REORDER_PROFILE"},l=a;t.c=l,(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(o.register(a,"MODIFY_ACTION_TYPES","/home/runner/work/byline-manager/byline-manager/client/src/store/actions-types/modify-action-types.js"),o.register(l,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/actions-types/modify-action-types.js")),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/store/actions/hydrate-actions.js":function(e,t,n){"use strict";n.d(t,{A:function(){return l},k:function(){return s}});var r,o=n("./client/src/store/actions-types/index.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var i,a,l=function(e){return{type:o.m.RECEIVE_HYDRATED_PROFILES,payload:e}},s=function(e){return{type:o.m.HYDRATE_PROFILES,payload:e}};(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(i.register(l,"actionReceiveHydratedProfiles","/home/runner/work/byline-manager/byline-manager/client/src/store/actions/hydrate-actions.js"),i.register(s,"actionHydrateProfiles","/home/runner/work/byline-manager/byline-manager/client/src/store/actions/hydrate-actions.js")),(a="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&a(e)},"./client/src/store/actions/index.js":function(e,t,n){"use strict";n.r(t),n.d(t,{actionAddProfile:function(){return o.LQ},actionHydrateProfiles:function(){return r.k},actionReceiveHydratedProfiles:function(){return r.A},actionRemoveProfile:function(){return o.O0},actionReorderProfile:function(){return o.cV}});var r=n("./client/src/store/actions/hydrate-actions.js"),o=n("./client/src/store/actions/modify-actions.js");"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature},"./client/src/store/actions/modify-actions.js":function(e,t,n){"use strict";n.d(t,{LQ:function(){return l},O0:function(){return s},cV:function(){return c}});var r,o=n("./client/src/store/actions-types/index.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var i,a,l=function(e){return{type:o.C.ADD_PROFILE,payload:e}},s=function(e){return{type:o.C.REMOVE_PROFILE,payload:e}},c=function(e){return{type:o.C.REORDER_PROFILE,payload:e}};(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(i.register(l,"actionAddProfile","/home/runner/work/byline-manager/byline-manager/client/src/store/actions/modify-actions.js"),i.register(s,"actionRemoveProfile","/home/runner/work/byline-manager/byline-manager/client/src/store/actions/modify-actions.js"),i.register(c,"actionReorderProfile","/home/runner/work/byline-manager/byline-manager/client/src/store/actions/modify-actions.js")),(a="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&a(e)},"./client/src/store/constants.js":function(e,t,n){"use strict";var r;e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a="byline-manager",l=a;t.c=l,(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(o.register(a,"STORE_KEY","/home/runner/work/byline-manager/byline-manager/client/src/store/constants.js"),o.register(l,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/constants.js")),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/store/controls.js":function(e,t,n){"use strict";var r,o=n("./node_modules/@babel/runtime/helpers/esm/defineProperty.js"),i=n("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),a=n("@babel/runtime/regenerator"),l=n.n(a),s=n("./client/src/store/actions-types/index.js"),c=n("./client/src/utils/get-hydrate-profiles.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var d,u,f,p=(0,o.c)({},s.m.HYDRATE_PROFILES,(d=(0,i.c)(l().mark((function e(t){return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,c.c)(t.payload));case 1:case"end":return e.stop()}}),e)}))),function(e){return d.apply(this,arguments)}));t.c=p,(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&u.register(p,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/controls.js"),(f="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&f(e)},"./client/src/store/creator.js":function(e,t,n){"use strict";var r,o=n("@wordpress/data"),i=n("./client/src/store/actions/index.js"),a=n("./client/src/store/resolvers.js"),l=n("./client/src/store/selectors.js"),s=n("./client/src/store/reducer.js"),c=n("./client/src/store/controls.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var d,u,f=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"byline",n=(0,o.createReduxStore)(e,{reducer:s.c,actions:i,selectors:{getProfiles:l.c},controls:c.c,resolvers:{getProfiles:function(){return(0,a.c)(e,t)}}});(0,o.register)(n)},p=f;t.c=p,(d="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(d.register(f,"creator","/home/runner/work/byline-manager/byline-manager/client/src/store/creator.js"),d.register(p,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/creator.js")),(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&u(e)},"./client/src/store/index.js":function(e,t,n){"use strict";var r,o=n("./client/src/store/creator.js"),i=n("./client/src/store/constants.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var a=i.c;(0,o.c)(a);var l,s,c=a;t.c=c,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(a,"store","/home/runner/work/byline-manager/byline-manager/client/src/store/index.js"),l.register(c,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/index.js")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/store/reducer.js":function(e,t,n){"use strict";var r,o=n("./client/src/store/actions-types/index.js"),i=n("./client/src/store/reducers/hydrate-reducer.js"),a=n("./client/src/store/reducers/modify-reducer.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,c={byline:{profiles:[]},profilesHydrated:!1},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(!0){case Object.values(o.m).includes(t.type):return(0,i.c)(e,t);case Object.values(o.C).includes(t.type):return{byline:{profiles:(0,a.c)(e.byline.profiles,t)},profilesHydrated:e.profilesHydrated};default:return e}},u=d;t.c=u,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(c,"DEFAULT_STATE","/home/runner/work/byline-manager/byline-manager/client/src/store/reducer.js"),l.register(d,"reducer","/home/runner/work/byline-manager/byline-manager/client/src/store/reducer.js"),l.register(u,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/reducer.js")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/store/reducers/hydrate-reducer.js":function(e,t,n){"use strict";var r,o=n("./client/src/store/actions-types/index.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var i,a,l=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.type,r=t.payload;return n===o.m.RECEIVE_HYDRATED_PROFILES?{byline:{profiles:e.byline.profiles.concat(r)},profilesHydrated:!0}:e},s=l;t.c=s,(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(i.register(l,"reducer","/home/runner/work/byline-manager/byline-manager/client/src/store/reducers/hydrate-reducer.js"),i.register(s,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/reducers/hydrate-reducer.js")),(a="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&a(e)},"./client/src/store/reducers/modify-reducer.js":function(e,t,n){"use strict";var r,o=n("./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js"),i=n("./client/src/store/actions-types/index.js"),a=n("./client/src/utils/remove-index.js"),l=n("./client/src/utils/reorder-index.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var s,c,d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.type,r=t.payload;switch(n){case i.C.ADD_PROFILE:return[].concat((0,o.c)(e),[t.payload]);case i.C.REMOVE_PROFILE:return(0,a.c)(e,r);case i.C.REORDER_PROFILE:var s=r.oldIndex,c=r.newIndex;return(0,l.c)(e,s,c);default:return e}},u=d;t.c=u,(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(s.register(d,"reducer","/home/runner/work/byline-manager/byline-manager/client/src/store/reducers/modify-reducer.js"),s.register(u,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/reducers/modify-reducer.js")),(c="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&c(e)},"./client/src/store/resolvers.js":function(e,t,n){"use strict";var r,o=n("@babel/runtime/regenerator"),i=n.n(o),a=n("@wordpress/data"),l=n("./client/src/store/actions/index.js");e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e);var s=i().mark(c);function c(e,t){var n,r,o,c,d,u;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=(0,a.select)(e),r=n.profilesHydrated,o=n.byline,!r){i.next=3;break}return i.abrupt("return",(0,l.actionReceiveHydratedProfiles)(o.profiles));case 3:return c=(0,a.select)("core/editor").getEditedPostAttribute("meta"),d=c[t]||{},i.next=7,(0,l.actionHydrateProfiles)(d.profiles||[]);case 7:return u=i.sent,i.abrupt("return",(0,l.actionReceiveHydratedProfiles)(u));case 9:case"end":return i.stop()}}),s)}"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var d,u,f=c;t.c=f,(d="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(d.register(c,"resolveProfiles","/home/runner/work/byline-manager/byline-manager/client/src/store/resolvers.js"),d.register(f,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/resolvers.js")),(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&u(e)},"./client/src/store/selectors.js":function(e,t,n){"use strict";var r;e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a=function(e){return e.profilesHydrated?e.byline.profiles||[]:null},l=a;t.c=l,(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(o.register(a,"getProfiles","/home/runner/work/byline-manager/byline-manager/client/src/store/selectors.js"),o.register(l,"default","/home/runner/work/byline-manager/byline-manager/client/src/store/selectors.js")),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/utils/get-hydrate-profiles.js":function(e,t,n){"use strict";var r,o=n("./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js"),i=n("@babel/runtime/regenerator"),a=n.n(i),l=n("@wordpress/api-fetch"),s=n.n(l);e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var c,d,u=function(){var e=(0,o.c)(a().mark((function e(){var t,n=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:[],e.abrupt("return",s()({path:"/byline-manager/v1/hydrateProfiles/",method:"POST",data:{profiles:t}}).catch((function(){return[]})));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),f=u;t.c=f,(c="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(c.register(u,"getHydrateProfiles","/home/runner/work/byline-manager/byline-manager/client/src/utils/get-hydrate-profiles.js"),c.register(f,"default","/home/runner/work/byline-manager/byline-manager/client/src/utils/get-hydrate-profiles.js")),(d="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&d(e)},"./client/src/utils/remove-index.js":function(e,t,n){"use strict";var r;e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a=function(e,t){return e.findIndex((function(e){return e.id===t}))>=0?e.filter((function(e){return e.id!==t})):e},l=a;t.c=l,(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(o.register(a,"removeIndex","/home/runner/work/byline-manager/byline-manager/client/src/utils/remove-index.js"),o.register(l,"default","/home/runner/work/byline-manager/byline-manager/client/src/utils/remove-index.js")),(i="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&i(e)},"./client/src/utils/reorder-index.js":function(e,t,n){"use strict";var r;n.d(t,{c:function(){return s}}),e=n.hmd(e),(r="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&r(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var o,i,a=function(e,t,n){return r=e,o=t,i=n,function(e,t,n){const r=t<0?e.length+t:t;if(r>=0&&r=this.getFilteredItems(t).length)return{highlightedIndex:null}}},{key:"setMenuPositions",value:function(){var e=this.refs.input,t=e.getBoundingClientRect(),r=n.g.window.getComputedStyle(e),o=parseInt(r.marginBottom,10)||0,i=parseInt(r.marginLeft,10)||0,a=parseInt(r.marginRight,10)||0;this.setState({menuTop:t.bottom+o,menuLeft:t.left+i,menuWidth:t.width+i+a})}},{key:"highlightItemFromMouse",value:function(e){this.setState({highlightedIndex:e})}},{key:"selectItemFromMouse",value:function(e){var t=this,n=this.props.getItemValue(e);this.setIgnoreBlur(!1),this.setState({isOpen:!1,highlightedIndex:null},(function(){t.props.onSelect(n,e)}))}},{key:"setIgnoreBlur",value:function(e){this._ignoreBlur=e}},{key:"renderMenu",value:function(){var e=this,t=this.getFilteredItems(this.props).map((function(t,n){var r=e.props.renderItem(t,e.state.highlightedIndex===n,{cursor:"default"});return i.cloneElement(r,{onMouseEnter:e.props.isItemSelectable(t)?function(){return e.highlightItemFromMouse(n)}:null,onClick:e.props.isItemSelectable(t)?function(){return e.selectItemFromMouse(t)}:null,ref:function(t){return e.refs["item-"+n]=t}})})),n={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth},r=this.props.renderMenu(t,this.props.value,n);return i.cloneElement(r,{ref:function(t){return e.refs.menu=t},onTouchStart:function(){return e.setIgnoreBlur(!0)},onMouseEnter:function(){return e.setIgnoreBlur(!0)},onMouseLeave:function(){return e.setIgnoreBlur(!1)}})}},{key:"handleInputBlur",value:function(e){var t=this;if(this._ignoreBlur)return this._ignoreFocus=!0,this._scrollOffset={x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop},void this.refs.input.focus();var n=void 0,r=this.state.highlightedIndex;if(this.props.selectOnBlur&&null!==r){var o=this.getFilteredItems(this.props)[r],i=this.props.getItemValue(o);n=function(){return t.props.onSelect(i,o)}}this.setState({isOpen:!1,highlightedIndex:null},n);var a=this.props.inputProps.onBlur;a&&a(e)}},{key:"handleInputFocus",value:function(e){var t=this;if(this._ignoreFocus){this._ignoreFocus=!1;var n=this._scrollOffset,r=n.x,o=n.y;return this._scrollOffset=null,window.scrollTo(r,o),clearTimeout(this._scrollTimer),void(this._scrollTimer=setTimeout((function(){t._scrollTimer=null,window.scrollTo(r,o)}),0))}this.setState({isOpen:!0});var i=this.props.inputProps.onFocus;i&&i(e)}},{key:"isInputFocused",value:function(){var e=this.refs.input;return e.ownerDocument&&e===e.ownerDocument.activeElement}},{key:"handleInputClick",value:function(){this.isInputFocused()&&!this.isOpen()&&this.setState({isOpen:!0})}},{key:"composeEventHandlers",value:function(e,t){return t?function(n){e(n),t(n)}:e}},{key:"isOpen",value:function(){return"open"in this.props?this.props.open:this.state.isOpen}},{key:"render",value:function(){this.props.debug&&this._debugStates.push({id:this._debugStates.length,state:this.state});var e=this.props.inputProps,t=this.isOpen();return i.createElement("div",r({style:r({},this.props.wrapperStyle)},this.props.wrapperProps),this.props.renderInput(r({},e,{role:"combobox","aria-autocomplete":"list","aria-expanded":t,autoComplete:"off",ref:this.exposeAPI,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleChange,onKeyDown:this.composeEventHandlers(this.handleKeyDown,e.onKeyDown),onClick:this.composeEventHandlers(this.handleInputClick,e.onClick),value:this.props.value})),t&&this.renderMenu(),this.props.debug&&i.createElement("pre",{style:{marginLeft:300}},JSON.stringify(this._debugStates.slice(Math.max(0,this._debugStates.length-5),this._debugStates.length),null,2)))}}]),t}(i.Component);d.propTypes={items:a.array.isRequired,value:a.any,onChange:a.func,onSelect:a.func,shouldItemRender:a.func,isItemSelectable:a.func,sortItems:a.func,getItemValue:a.func.isRequired,renderItem:a.func.isRequired,renderMenu:a.func,menuStyle:a.object,renderInput:a.func,inputProps:a.object,wrapperProps:a.object,wrapperStyle:a.object,autoHighlight:a.bool,selectOnBlur:a.bool,onMenuVisibilityChange:a.func,open:a.bool,debug:a.bool},d.defaultProps={value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},renderInput:function(e){return i.createElement("input",e)},onChange:function(){},onSelect:function(){},isItemSelectable:function(){return!0},renderMenu:function(e,t,n){return i.createElement("div",{style:r({},n,this.menuStyle),children:e})},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,selectOnBlur:!1,onMenuVisibilityChange:function(){}},d.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,r=null===n?-1:n,o=0;o-1&&r!==n&&this.setState({highlightedIndex:r,isOpen:!0})}},ArrowUp:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,r=null===n?t.length:n,o=0;o0?!0===a?r.scrollTop(t,u.top+f.top):!1===a?r.scrollTop(t,u.top+p.top):f.top<0?r.scrollTop(t,u.top+f.top):r.scrollTop(t,u.top+p.top):i||((a=void 0===a||!!a)?r.scrollTop(t,u.top+f.top):r.scrollTop(t,u.top+p.top)),o&&(f.left<0||p.left>0?!0===l?r.scrollLeft(t,u.left+f.left):!1===l?r.scrollLeft(t,u.left+p.left):f.left<0?r.scrollLeft(t,u.left+f.left):r.scrollLeft(t,u.left+p.left):i||((l=void 0===l||!!l)?r.scrollLeft(t,u.left+f.left):r.scrollLeft(t,u.left+p.left)))}},"./node_modules/react-autocomplete/node_modules/dom-scroll-into-view/lib/util.js":function(e){function t(e,t){var n=e["page"+(t?"Y":"X")+"Offset"],r="scroll"+(t?"Top":"Left");if("number"!=typeof n){var o=e.document;"number"!=typeof(n=o.documentElement[r])&&(n=o.body[r])}return n}function n(e){return t(e)}function r(e){return t(e,!0)}function o(e){var t=function(e){var t,n,r,o=e.ownerDocument,i=o.body,a=o&&o.documentElement;return n=(t=e.getBoundingClientRect()).left,r=t.top,{left:n-=a.clientLeft||i.clientLeft||0,top:r-=a.clientTop||i.clientTop||0}}(e),o=e.ownerDocument,i=o.defaultView||o.parentWindow;return t.left+=n(i),t.top+=r(i),t}var i,a=new RegExp("^("+/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source+")(?!px)[a-z%]+$","i"),l=/^(top|right|bottom|left)$/,s="currentStyle",c="runtimeStyle",d="left";function u(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.active.collection;return this.refs[e].sort(w)}}]),e}();function w(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}function L(e,t){return Object.keys(e).reduce((function(n,r){return-1===t.indexOf(r)&&(n[r]=e[r]),n}),{})}var H={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},j=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1];return"ms"===t?"ms":t&&t.length?t[0].toUpperCase()+t.substr(1):""}();function I(e,t){Object.keys(t).forEach((function(n){e.style[n]=t[n]}))}function S(e,t){e.style["".concat(j,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function G(e,t){e.style["".concat(j,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function O(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function _(e,t,n){return Math.max(e,Math.min(n,t))}function E(e){return"px"===e.substr(-2)?parseFloat(e):0}function k(e,t){var n=t.displayName||t.name;return n?"".concat(e,"(").concat(n,")"):e}function T(e,t){var n=e.getBoundingClientRect();return{top:n.top+t.top,left:n.left+t.left}}function R(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function P(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{left:0,top:0};if(e){var r={left:n.left+e.offsetLeft,top:n.top+e.offsetTop};return e.parentNode===t?r:P(e.parentNode,t,r)}}function C(e){var t=e.lockOffset,n=e.width,r=e.height,o=t,i=t,a="px";if("string"==typeof t){var l=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);b()(null!==l,'lockOffset value should be a number or a string of a number followed by "px" or "%". Given %s',t),o=parseFloat(t),i=parseFloat(t),a=l[1]}return b()(isFinite(o)&&isFinite(i),"lockOffset value should be a finite. Given %s",t),"%"===a&&(o=o*n/100,i=i*r/100),{x:o,y:i}}function A(e){return e instanceof HTMLElement?function(e){var t=window.getComputedStyle(e),n=/(auto|scroll)/;return["overflow","overflowX","overflowY"].find((function(e){return n.test(t[e])}))}(e)?e:A(e.parentNode):null}var M={Anchor:"A",Button:"BUTTON",Canvas:"CANVAS",Input:"INPUT",Option:"OPTION",Textarea:"TEXTAREA",Select:"SELECT"};function D(e){return null!=e.sortableHandle}var F=function(){function e(t,n){(0,a.c)(this,e),this.container=t,this.onScrollCallback=n}return(0,l.c)(e,[{key:"clear",value:function(){null!=this.interval&&(clearInterval(this.interval),this.interval=null)}},{key:"update",value:function(e){var t=this,n=e.translate,r=e.minTranslate,o=e.maxTranslate,i=e.width,a=e.height,l={x:0,y:0},s={x:1,y:1},c=this.container,d=c.scrollTop,u=c.scrollLeft,f=c.scrollHeight,p=c.scrollWidth,h=0===d,m=f-d-c.clientHeight==0,b=0===u,y=p-u-c.clientWidth==0;n.y>=o.y-a/2&&!m?(l.y=1,s.y=10*Math.abs((o.y-a/2-n.y)/a)):n.x>=o.x-i/2&&!y?(l.x=1,s.x=10*Math.abs((o.x-i/2-n.x)/i)):n.y<=r.y+a/2&&!h?(l.y=-1,s.y=10*Math.abs((n.y-a/2-r.y)/a)):n.x<=r.x+i/2&&!b&&(l.x=-1,s.x=10*Math.abs((n.x-i/2-r.x)/i)),this.interval&&(this.clear(),this.isAutoScrolling=!1),0===l.x&&0===l.y||(this.interval=setInterval((function(){t.isAutoScrolling=!0;var e={left:s.x*l.x,top:s.y*l.y};t.container.scrollTop+=e.top,t.container.scrollLeft+=e.left,t.onScrollCallback(e)}),5))}}]),e}(),B={axis:v().oneOf(["x","y","xy"]),contentWindow:v().any,disableAutoscroll:v().bool,distance:v().number,getContainer:v().func,getHelperDimensions:v().func,helperClass:v().string,helperContainer:v().oneOfType([v().func,"undefined"==typeof HTMLElement?v().any:v().instanceOf(HTMLElement)]),hideSortableGhost:v().bool,keyboardSortingTransitionDuration:v().number,lockAxis:v().string,lockOffset:v().oneOfType([v().number,v().string,v().arrayOf(v().oneOfType([v().number,v().string]))]),lockToContainerEdges:v().bool,onSortEnd:v().func,onSortMove:v().func,onSortOver:v().func,onSortStart:v().func,pressDelay:v().number,pressThreshold:v().number,keyCodes:v().shape({lift:v().arrayOf(v().number),drop:v().arrayOf(v().number),cancel:v().arrayOf(v().number),up:v().arrayOf(v().number),down:v().arrayOf(v().number)}),shouldCancelStart:v().func,transitionDuration:v().number,updateBeforeSortStart:v().func,useDragHandle:v().bool,useWindowAsScrollContainer:v().bool},W={lift:[32],drop:[32],cancel:[27],up:[38,37],down:[40,39]},N={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:function(e){var t=e.node;return{height:t.offsetHeight,width:t.offsetWidth}},hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:W,shouldCancelStart:function(e){return-1!==[M.Input,M.Textarea,M.Select,M.Option,M.Button].indexOf(e.target.tagName)||!!O(e.target,(function(e){return"true"===e.contentEditable}))},transitionDuration:300,useWindowAsScrollContainer:!1},K=Object.keys(B),V=(0,p.createContext)({manager:{}});function U(e){var t,n,m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=t=function(t){function n(e){var t;(0,a.c)(this,n),t=(0,s.c)(this,(0,c.c)(n).call(this,e)),(0,f.c)((0,u.c)((0,u.c)(t)),"state",{}),(0,f.c)((0,u.c)((0,u.c)(t)),"handleStart",(function(e){var n=t.props,r=n.distance,o=n.shouldCancelStart;if(2!==e.button&&!o(e)){t.touched=!0,t.position=R(e);var i=O(e.target,(function(e){return null!=e.sortableInfo}));if(i&&i.sortableInfo&&t.nodeIsChild(i)&&!t.state.sorting){var a=t.props.useDragHandle,l=i.sortableInfo,s=l.index,c=l.collection;if(l.disabled)return;if(a&&!O(e.target,D))return;t.manager.active={collection:c,index:s},function(e){return e.touches&&e.touches.length||e.changedTouches&&e.changedTouches.length}(e)||e.target.tagName!==M.Anchor||e.preventDefault(),r||(0===t.props.pressDelay?t.handlePress(e):t.pressTimer=setTimeout((function(){return t.handlePress(e)}),t.props.pressDelay))}}})),(0,f.c)((0,u.c)((0,u.c)(t)),"nodeIsChild",(function(e){return e.sortableInfo.manager===t.manager})),(0,f.c)((0,u.c)((0,u.c)(t)),"handleMove",(function(e){var n=t.props,r=n.distance,o=n.pressThreshold;if(!t.state.sorting&&t.touched&&!t._awaitingUpdateBeforeSortStart){var i=R(e),a={x:t.position.x-i.x,y:t.position.y-i.y},l=Math.abs(a.x)+Math.abs(a.y);t.delta=a,r||o&&!(l>=o)?r&&l>=r&&t.manager.isActive()&&t.handlePress(e):(clearTimeout(t.cancelTimer),t.cancelTimer=setTimeout(t.cancel,0))}})),(0,f.c)((0,u.c)((0,u.c)(t)),"handleEnd",(function(){t.touched=!1,t.cancel()})),(0,f.c)((0,u.c)((0,u.c)(t)),"cancel",(function(){var e=t.props.distance;t.state.sorting||(e||clearTimeout(t.pressTimer),t.manager.active=null)})),(0,f.c)((0,u.c)((0,u.c)(t)),"handlePress",(function(e){try{var n=t.manager.getActive(),r=function(){if(n){var r=function(){var n,r,o,d,b,g,v=p.sortableInfo.index,x=(n=p,{bottom:E((r=window.getComputedStyle(n)).marginBottom),left:E(r.marginLeft),right:E(r.marginRight),top:E(r.marginTop)}),w=function(e){var t=window.getComputedStyle(e);return"grid"===t.display?{x:E(t.gridColumnGap),y:E(t.gridRowGap)}:{x:0,y:0}}(t.container),L=t.scrollContainer.getBoundingClientRect(),j=l({index:v,node:p,collection:h});if(t.node=p,t.margin=x,t.gridGap=w,t.width=j.width,t.height=j.height,t.marginOffset={x:t.margin.left+t.margin.right+t.gridGap.x,y:Math.max(t.margin.top,t.margin.bottom,t.gridGap.y)},t.boundingClientRect=p.getBoundingClientRect(),t.containerBoundingRect=L,t.index=v,t.newIndex=v,t.axis={x:a.indexOf("x")>=0,y:a.indexOf("y")>=0},t.offsetEdge=P(p,t.container),t.initialOffset=R(m?(0,i.c)({},e,{pageX:t.boundingClientRect.left,pageY:t.boundingClientRect.top}):e),t.initialScroll={left:t.scrollContainer.scrollLeft,top:t.scrollContainer.scrollTop},t.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},t.helper=t.helperContainer.appendChild((d="input, textarea, select, canvas, [contenteditable]",b=(o=p).querySelectorAll(d),g=o.cloneNode(!0),(0,y.c)(g.querySelectorAll(d)).forEach((function(e,t){"file"!==e.type&&(e.value=b[t].value),"radio"===e.type&&e.name&&(e.name="__sortableClone__".concat(e.name)),e.tagName===M.Canvas&&b[t].width>0&&b[t].height>0&&e.getContext("2d").drawImage(b[t],0,0)})),g)),I(t.helper,{boxSizing:"border-box",height:"".concat(t.height,"px"),left:"".concat(t.boundingClientRect.left-x.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(t.boundingClientRect.top-x.top,"px"),width:"".concat(t.width,"px")}),m&&t.helper.focus(),c&&(t.sortableGhost=p,I(p,{opacity:0,visibility:"hidden"})),t.minTranslate={},t.maxTranslate={},m){var S=f?{top:0,left:0,width:t.contentWindow.innerWidth,height:t.contentWindow.innerHeight}:t.containerBoundingRect,G=S.top,O=S.left,_=S.width,k=G+S.height,T=O+_;t.axis.x&&(t.minTranslate.x=O-t.boundingClientRect.left,t.maxTranslate.x=T-(t.boundingClientRect.left+t.width)),t.axis.y&&(t.minTranslate.y=G-t.boundingClientRect.top,t.maxTranslate.y=k-(t.boundingClientRect.top+t.height))}else t.axis.x&&(t.minTranslate.x=(f?0:L.left)-t.boundingClientRect.left-t.width/2,t.maxTranslate.x=(f?t.contentWindow.innerWidth:L.left+L.width)-t.boundingClientRect.left-t.width/2),t.axis.y&&(t.minTranslate.y=(f?0:L.top)-t.boundingClientRect.top-t.height/2,t.maxTranslate.y=(f?t.contentWindow.innerHeight:L.top+L.height)-t.boundingClientRect.top-t.height/2);s&&s.split(" ").forEach((function(e){return t.helper.classList.add(e)})),t.listenerNode=e.touches?e.target:t.contentWindow,m?(t.listenerNode.addEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.addEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.addEventListener("keydown",t.handleKeyDown)):(H.move.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortMove,!1)})),H.end.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortEnd,!1)}))),t.setState({sorting:!0,sortingIndex:v}),u&&u({node:p,index:v,collection:h,isKeySorting:m,nodes:t.manager.getOrderedRefs(),helper:t.helper},e),m&&t.keyMove(0)},o=t.props,a=o.axis,l=o.getHelperDimensions,s=o.helperClass,c=o.hideSortableGhost,d=o.updateBeforeSortStart,u=o.onSortStart,f=o.useWindowAsScrollContainer,p=n.node,h=n.collection,m=t.manager.isKeySorting,b=function(){if("function"==typeof d){t._awaitingUpdateBeforeSortStart=!0;var n=function(t,n){try{var r=(o=p.sortableInfo.index,Promise.resolve(d({collection:h,index:o,node:p,isKeySorting:m},e)).then((function(){})))}catch(e){return n(!0,e)}var o;return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,value)}(0,(function(e,n){if(t._awaitingUpdateBeforeSortStart=!1,e)throw n;return n}));if(n&&n.then)return n.then((function(){}))}}();return b&&b.then?b.then(r):r()}}();return Promise.resolve(r&&r.then?r.then((function(){})):void 0)}catch(e){return Promise.reject(e)}})),(0,f.c)((0,u.c)((0,u.c)(t)),"handleSortMove",(function(e){var n=t.props.onSortMove;"function"==typeof e.preventDefault&&e.cancelable&&e.preventDefault(),t.updateHelperPosition(e),t.animateNodes(),t.autoscroll(),n&&n(e)})),(0,f.c)((0,u.c)((0,u.c)(t)),"handleSortEnd",(function(e){var n=t.props,r=n.hideSortableGhost,o=n.onSortEnd,i=t.manager,a=i.active.collection,l=i.isKeySorting,s=t.manager.getOrderedRefs();t.listenerNode&&(l?(t.listenerNode.removeEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("keydown",t.handleKeyDown)):(H.move.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortMove)})),H.end.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortEnd)})))),t.helper.parentNode.removeChild(t.helper),r&&t.sortableGhost&&I(t.sortableGhost,{opacity:"",visibility:""});for(var c=0,d=s.length;cr)){t.prevIndex=i,t.newIndex=o;var a=function(e,t,n){return et?e-1:e>n&&eb?b/2:this.height/2,width:this.width>m?m/2:this.width/2},g=c&&h>this.index&&h<=d,v=c&&h=d,x={x:0,y:0},w=a[u].edgeOffset;w||(w=P(p,this.container),a[u].edgeOffset=w,c&&(a[u].boundingClientRect=T(p,o)));var L=u0&&a[u-1];L&&!L.edgeOffset&&(L.edgeOffset=P(L.node,this.container),c&&(L.boundingClientRect=T(L.node,o))),h!==this.index?(t&&G(p,t),this.axis.x?this.axis.y?v||hthis.containerBoundingRect.width-y.width&&L&&(x.x=L.edgeOffset.left-w.left,x.y=L.edgeOffset.top-w.top),null===this.newIndex&&(this.newIndex=h)):(g||h>this.index&&(l+i.left+y.width>=w.left&&s+i.top+y.height>=w.top||s+i.top+y.height>=w.top+b))&&(x.x=-(this.width+this.marginOffset.x),w.left+x.xthis.index&&l+i.left+y.width>=w.left?(x.x=-(this.width+this.marginOffset.x),this.newIndex=h):(v||hthis.index&&s+i.top+y.height>=w.top?(x.y=-(this.height+this.marginOffset.y),this.newIndex=h):(v||h1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=t=function(t){function n(){var e,t;(0,a.c)(this,n);for(var r=arguments.length,o=new Array(r),i=0;i0&&void 0!==arguments[0]?arguments[0]:this.props.collection;this.context.manager.remove(e,this.ref)}},{key:"getWrappedInstance",value:function(){return b()(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.wrappedInstance.current}},{key:"render",value:function(){var t=o.withRef?this.wrappedInstance:null;return(0,p.createElement)(e,(0,r.c)({ref:t},L(this.props,q)))}}]),n}(p.Component),(0,f.c)(t,"displayName",k("sortableElement",e)),(0,f.c)(t,"contextType",V),(0,f.c)(t,"propTypes",Y),(0,f.c)(t,"defaultProps",{collection:0}),n}},react:function(e){"use strict";e.exports=window.React},"react-dom":function(e){"use strict";e.exports=window.ReactDOM},"@babel/runtime/regenerator":function(e){"use strict";e.exports=window.regeneratorRuntime},"@wordpress/api-fetch":function(e){"use strict";e.exports=window.wp.apiFetch},"@wordpress/components":function(e){"use strict";e.exports=window.wp.components},"@wordpress/data":function(e){"use strict";e.exports=window.wp.data},"@wordpress/element":function(e){"use strict";e.exports=window.wp.element},"@wordpress/i18n":function(e){"use strict";e.exports=window.wp.i18n},"./node_modules/classnames/index.js":function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e="",t=0;te.length)&&(t=e.length);for(var n=0,r=new Array(t);ndiv{flex:1;max-width:34.375rem;min-width:15.625rem}.byline-manager-meta-box .current-user-link{font-weight:700}.byline-manager-meta-box .current-user-link button{font-weight:500;margin-left:.625rem}.byline-manager-meta-box .byline-override-option{float:right;margin:.3125rem 0 .9375rem .9375rem}.byline-manager-meta-box label span{display:block}#advanced-sortables .profile-user-link input,#normal-sortables .profile-user-link input{width:28.125rem}@media(min-width: 851px){#side-sortables .menu{right:.625rem;width:27.5rem}.components-panel #side-sortables .menu{left:1.5rem;max-width:14.5rem;right:auto}}.byline-list{min-height:6.25rem}.byline-list ol,.byline-list ul{list-style:none;margin-left:0}.byline-list-item{align-items:center;display:flex;max-width:15.625rem}.byline-list-item button{margin-left:auto}.components-item-group div[role=listitem]:last-child .byline-list-item{margin-bottom:0}div.byline-list-item{align-items:center;background-color:#fff;cursor:move;display:flex;list-style:none;margin-bottom:.3125rem;padding:.3125rem 0 .3125rem .625rem}div.byline-list-item *{vertical-align:middle}div.byline-list-item img{height:3.125rem;margin-right:.625rem;width:3.125rem}div.byline-list-item button.components-button.is-destructive{background:none;border:1px solid rgba(0,0,0,0);cursor:pointer;margin-left:auto;transition:background-color .2s} diff --git a/client/build/main.4e315351.bundle.asset.php b/client/build/main.4e315351.bundle.asset.php new file mode 100644 index 00000000..b930a980 --- /dev/null +++ b/client/build/main.4e315351.bundle.asset.php @@ -0,0 +1 @@ + array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-url'), 'version' => 'd75ba890d34010906fdc'); diff --git a/client/build/main.4e315351.bundle.js b/client/build/main.4e315351.bundle.js new file mode 100644 index 00000000..ac9bb903 --- /dev/null +++ b/client/build/main.4e315351.bundle.js @@ -0,0 +1,2 @@ +/*! For license information please see main.4e315351.bundle.js.LICENSE.txt */ +!function(){var e={"./client/src/components/byline-metabox/index.js":function(e,t,n){"use strict";var o,r=n("./node_modules/prop-types/index.js"),i=n.n(r),a=n("./client/src/components/byline-profiles/index.js");function l(e){var t=e.bylineMetaBox.profiles,n=void 0===t?[]:t,o=bylineData,r=o.addAuthorLabel,i=o.addAuthorPlaceholder,l=o.addFreeformButtonLabel,s=o.addFreeformLabel,u=o.addFreeformPlaceholder,c=o.profilesApiUrl,d=o.removeAuthorLabel;return n?React.createElement("div",{className:"byline-list byline-manager-meta-box"},React.createElement("input",{type:"hidden",name:"byline_source",value:"profiles"}),React.createElement(a.c,{addAuthorLabel:r,addAuthorPlaceholder:i,addFreeformButtonLabel:l,addFreeformLabel:s,addFreeformPlaceholder:u,profilesApiUrl:c,removeAuthorLabel:d,profiles:n})):null}e=n.hmd(e),(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&o(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature,l.propTypes={bylineMetaBox:i().shape({profiles:i().arrayOf(i().shape({id:i().oneOfType([i().number,i().string]),byline_id:i().number,name:i().string,image:i().oneOfType([i().bool,i().string])}))}).isRequired};var s,u,c=l;t.c=c,(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(s.register(l,"BylineMetaBox","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-metabox/index.js"),s.register(c,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-metabox/index.js")),(u="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&u(e)},"./client/src/components/byline-profiles/index.js":function(e,t,n){"use strict";n.d(t,{c:function(){return ye}});var o=n("./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js"),r=n("./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js");function i(e){return function(e){if(Array.isArray(e))return(0,o.c)(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||(0,r.c)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var a=n("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),l=n("./node_modules/prop-types/index.js"),s=n.n(l),u=n("@wordpress/element"),c=n("@wordpress/api-fetch"),d=n.n(c),f=n("@wordpress/url"),p=n("./node_modules/classnames/index.js"),h=n.n(p);function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:this.active.collection;return this.refs[e].sort(A)}}]),e}();function A(e,t){return e.node.sortableInfo.index-t.node.sortableInfo.index}function P(e,t){return Object.keys(e).reduce((function(n,o){return-1===t.indexOf(o)&&(n[o]=e[o]),n}),{})}var D={end:["touchend","touchcancel","mouseup"],move:["touchmove","mousemove"],start:["touchstart","mousedown"]},H=function(){if("undefined"==typeof window||"undefined"==typeof document)return"";var e=window.getComputedStyle(document.documentElement,"")||["-moz-hidden-iframe"],t=(Array.prototype.slice.call(e).join("").match(/-(moz|webkit|ms)-/)||""===e.OLink&&["","o"])[1];return"ms"===t?"ms":t&&t.length?t[0].toUpperCase()+t.substr(1):""}();function M(e,t){Object.keys(t).forEach((function(n){e.style[n]=t[n]}))}function B(e,t){e.style["".concat(H,"Transform")]=null==t?"":"translate3d(".concat(t.x,"px,").concat(t.y,"px,0)")}function N(e,t){e.style["".concat(H,"TransitionDuration")]=null==t?"":"".concat(t,"ms")}function W(e,t){for(;e;){if(t(e))return e;e=e.parentNode}return null}function G(e,t,n){return Math.max(e,Math.min(n,t))}function F(e){return"px"===e.substr(-2)?parseFloat(e):0}function U(e,t){var n=t.displayName||t.name;return n?"".concat(e,"(").concat(n,")"):e}function K(e,t){var n=e.getBoundingClientRect();return{top:n.top+t.top,left:n.left+t.left}}function V(e){return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:e.changedTouches&&e.changedTouches.length?{x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY}:{x:e.pageX,y:e.pageY}}function q(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{left:0,top:0};if(e){var o={left:n.left+e.offsetLeft,top:n.top+e.offsetTop};return e.parentNode===t?o:q(e.parentNode,t,o)}}function X(e){var t=e.lockOffset,n=e.width,o=e.height,r=t,i=t,a="px";if("string"==typeof t){var l=/^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(t);j()(null!==l,'lockOffset value should be a number or a string of a number followed by "px" or "%". Given %s',t),r=parseFloat(t),i=parseFloat(t),a=l[1]}return j()(isFinite(r)&&isFinite(i),"lockOffset value should be a finite. Given %s",t),"%"===a&&(r=r*n/100,i=i*o/100),{x:r,y:i}}function Y(e){return e instanceof HTMLElement?function(e){var t=window.getComputedStyle(e),n=/(auto|scroll)/;return["overflow","overflowX","overflowY"].find((function(e){return n.test(t[e])}))}(e)?e:Y(e.parentNode):null}var z={Anchor:"A",Button:"BUTTON",Canvas:"CANVAS",Input:"INPUT",Option:"OPTION",Textarea:"TEXTAREA",Select:"SELECT"};function $(e){return null!=e.sortableHandle}var J,Q=function(){function e(t,n){x(this,e),this.container=t,this.onScrollCallback=n}return S(e,[{key:"clear",value:function(){null!=this.interval&&(clearInterval(this.interval),this.interval=null)}},{key:"update",value:function(e){var t=this,n=e.translate,o=e.minTranslate,r=e.maxTranslate,i=e.width,a=e.height,l={x:0,y:0},s={x:1,y:1},u=this.container,c=u.scrollTop,d=u.scrollLeft,f=u.scrollHeight,p=u.scrollWidth,h=0===c,m=f-c-u.clientHeight==0,g=0===d,y=p-d-u.clientWidth==0;n.y>=r.y-a/2&&!m?(l.y=1,s.y=10*Math.abs((r.y-a/2-n.y)/a)):n.x>=r.x-i/2&&!y?(l.x=1,s.x=10*Math.abs((r.x-i/2-n.x)/i)):n.y<=o.y+a/2&&!h?(l.y=-1,s.y=10*Math.abs((n.y-a/2-o.y)/a)):n.x<=o.x+i/2&&!g&&(l.x=-1,s.x=10*Math.abs((n.x-i/2-o.x)/i)),this.interval&&(this.clear(),this.isAutoScrolling=!1),0===l.x&&0===l.y||(this.interval=setInterval((function(){t.isAutoScrolling=!0;var e={left:s.x*l.x,top:s.y*l.y};t.container.scrollTop+=e.top,t.container.scrollLeft+=e.left,t.onScrollCallback(e)}),5))}}]),e}(),Z={axis:s().oneOf(["x","y","xy"]),contentWindow:s().any,disableAutoscroll:s().bool,distance:s().number,getContainer:s().func,getHelperDimensions:s().func,helperClass:s().string,helperContainer:s().oneOfType([s().func,"undefined"==typeof HTMLElement?s().any:s().instanceOf(HTMLElement)]),hideSortableGhost:s().bool,keyboardSortingTransitionDuration:s().number,lockAxis:s().string,lockOffset:s().oneOfType([s().number,s().string,s().arrayOf(s().oneOfType([s().number,s().string]))]),lockToContainerEdges:s().bool,onSortEnd:s().func,onSortMove:s().func,onSortOver:s().func,onSortStart:s().func,pressDelay:s().number,pressThreshold:s().number,keyCodes:s().shape({lift:s().arrayOf(s().number),drop:s().arrayOf(s().number),cancel:s().arrayOf(s().number),up:s().arrayOf(s().number),down:s().arrayOf(s().number)}),shouldCancelStart:s().func,transitionDuration:s().number,updateBeforeSortStart:s().func,useDragHandle:s().bool,useWindowAsScrollContainer:s().bool},ee={lift:[32],drop:[32],cancel:[27],up:[38,37],down:[40,39]},te={axis:"y",disableAutoscroll:!1,distance:0,getHelperDimensions:function(e){var t=e.node;return{height:t.offsetHeight,width:t.offsetWidth}},hideSortableGhost:!0,lockOffset:"50%",lockToContainerEdges:!1,pressDelay:0,pressThreshold:5,keyCodes:ee,shouldCancelStart:function(e){return-1!==[z.Input,z.Textarea,z.Select,z.Option,z.Button].indexOf(e.target.tagName)||!!W(e.target,(function(e){return"true"===e.contentEditable}))},transitionDuration:300,useWindowAsScrollContainer:!1},ne=Object.keys(Z),oe=(0,C.createContext)({manager:{}}),re={index:s().number.isRequired,collection:s().oneOfType([s().number,s().string]),disabled:s().bool},ie=Object.keys(re),ae=n("./node_modules/react-autocomplete/build/lib/Autocomplete.js"),le=n.n(ae),se=n("@wordpress/components"),ue=n("./node_modules/@uidotdev/usehooks/index.js");e=n.hmd(e),(J="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&J(e);var ce="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default.signature:function(e){return e},de=function(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=t=function(t){function n(){var e,t;x(this,n);for(var o=arguments.length,r=new Array(o),i=0;i0&&void 0!==arguments[0]?arguments[0]:this.props.collection;this.context.manager.remove(e,this.ref)}},{key:"getWrappedInstance",value:function(){return j()(o.withRef,"To access the wrapped instance, you need to pass in {withRef: true} as the second argument of the SortableElement() call"),this.wrappedInstance.current}},{key:"render",value:function(){var t=o.withRef?this.wrappedInstance:null;return(0,C.createElement)(e,m({ref:t},P(this.props,ie)))}}]),n}(C.Component),b(t,"displayName",U("sortableElement",e)),b(t,"contextType",oe),b(t,"propTypes",re),b(t,"defaultProps",{collection:0}),n}((function(e){var t=e.count,n=e.bylineId,o=e.name,r=e.image,i=e.removeItem,a=e.removeAuthorLabel;return React.createElement("li",{className:"byline-list-item"},React.createElement("input",{type:"hidden",name:"byline_entry[".concat(t,"][type]"),value:n?"byline_id":"text"}),React.createElement("input",{type:"hidden",name:"byline_entry[".concat(t,"][value]"),value:n||o}),r?React.createElement("img",{src:r,alt:o}):null,React.createElement("span",null,o),React.createElement(se.Button,{label:a,isDestructive:!0,size:"small",variant:"secondary",onClick:function(e){e.preventDefault(),i()}},"×"))})),fe=function(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{withRef:!1};return n=t=function(t){function n(e){var t;x(this,n),b(I(I(t=k(this,O(n).call(this,e)))),"state",{}),b(I(I(t)),"handleStart",(function(e){var n=t.props,o=n.distance,r=n.shouldCancelStart;if(2!==e.button&&!r(e)){t.touched=!0,t.position=V(e);var i=W(e.target,(function(e){return null!=e.sortableInfo}));if(i&&i.sortableInfo&&t.nodeIsChild(i)&&!t.state.sorting){var a=t.props.useDragHandle,l=i.sortableInfo,s=l.index,u=l.collection;if(l.disabled)return;if(a&&!W(e.target,$))return;t.manager.active={collection:u,index:s},function(e){return e.touches&&e.touches.length||e.changedTouches&&e.changedTouches.length}(e)||e.target.tagName!==z.Anchor||e.preventDefault(),o||(0===t.props.pressDelay?t.handlePress(e):t.pressTimer=setTimeout((function(){return t.handlePress(e)}),t.props.pressDelay))}}})),b(I(I(t)),"nodeIsChild",(function(e){return e.sortableInfo.manager===t.manager})),b(I(I(t)),"handleMove",(function(e){var n=t.props,o=n.distance,r=n.pressThreshold;if(!t.state.sorting&&t.touched&&!t._awaitingUpdateBeforeSortStart){var i=V(e),a={x:t.position.x-i.x,y:t.position.y-i.y},l=Math.abs(a.x)+Math.abs(a.y);t.delta=a,o||r&&!(l>=r)?o&&l>=o&&t.manager.isActive()&&t.handlePress(e):(clearTimeout(t.cancelTimer),t.cancelTimer=setTimeout(t.cancel,0))}})),b(I(I(t)),"handleEnd",(function(){t.touched=!1,t.cancel()})),b(I(I(t)),"cancel",(function(){var e=t.props.distance;t.state.sorting||(e||clearTimeout(t.pressTimer),t.manager.active=null)})),b(I(I(t)),"handlePress",(function(e){try{var n=t.manager.getActive(),o=function(){if(n){var o=function(){var n,o,r,c,g,y,b=p.sortableInfo.index,x=(n=p,{bottom:F((o=window.getComputedStyle(n)).marginBottom),left:F(o.marginLeft),right:F(o.marginRight),top:F(o.marginTop)}),w=function(e){var t=window.getComputedStyle(e);return"grid"===t.display?{x:F(t.gridColumnGap),y:F(t.gridRowGap)}:{x:0,y:0}}(t.container),S=t.scrollContainer.getBoundingClientRect(),I=l({index:b,node:p,collection:h});if(t.node=p,t.margin=x,t.gridGap=w,t.width=I.width,t.height=I.height,t.marginOffset={x:t.margin.left+t.margin.right+t.gridGap.x,y:Math.max(t.margin.top,t.margin.bottom,t.gridGap.y)},t.boundingClientRect=p.getBoundingClientRect(),t.containerBoundingRect=S,t.index=b,t.newIndex=b,t.axis={x:a.indexOf("x")>=0,y:a.indexOf("y")>=0},t.offsetEdge=q(p,t.container),t.initialOffset=V(m?v({},e,{pageX:t.boundingClientRect.left,pageY:t.boundingClientRect.top}):e),t.initialScroll={left:t.scrollContainer.scrollLeft,top:t.scrollContainer.scrollTop},t.initialWindowScroll={left:window.pageXOffset,top:window.pageYOffset},t.helper=t.helperContainer.appendChild((c="input, textarea, select, canvas, [contenteditable]",g=(r=p).querySelectorAll(c),i((y=r.cloneNode(!0)).querySelectorAll(c)).forEach((function(e,t){"file"!==e.type&&(e.value=g[t].value),"radio"===e.type&&e.name&&(e.name="__sortableClone__".concat(e.name)),e.tagName===z.Canvas&&g[t].width>0&&g[t].height>0&&e.getContext("2d").drawImage(g[t],0,0)})),y)),M(t.helper,{boxSizing:"border-box",height:"".concat(t.height,"px"),left:"".concat(t.boundingClientRect.left-x.left,"px"),pointerEvents:"none",position:"fixed",top:"".concat(t.boundingClientRect.top-x.top,"px"),width:"".concat(t.width,"px")}),m&&t.helper.focus(),u&&(t.sortableGhost=p,M(p,{opacity:0,visibility:"hidden"})),t.minTranslate={},t.maxTranslate={},m){var k=f?{top:0,left:0,width:t.contentWindow.innerWidth,height:t.contentWindow.innerHeight}:t.containerBoundingRect,O=k.top,T=k.left,E=k.width,C=O+k.height,L=T+E;t.axis.x&&(t.minTranslate.x=T-t.boundingClientRect.left,t.maxTranslate.x=L-(t.boundingClientRect.left+t.width)),t.axis.y&&(t.minTranslate.y=O-t.boundingClientRect.top,t.maxTranslate.y=C-(t.boundingClientRect.top+t.height))}else t.axis.x&&(t.minTranslate.x=(f?0:S.left)-t.boundingClientRect.left-t.width/2,t.maxTranslate.x=(f?t.contentWindow.innerWidth:S.left+S.width)-t.boundingClientRect.left-t.width/2),t.axis.y&&(t.minTranslate.y=(f?0:S.top)-t.boundingClientRect.top-t.height/2,t.maxTranslate.y=(f?t.contentWindow.innerHeight:S.top+S.height)-t.boundingClientRect.top-t.height/2);s&&s.split(" ").forEach((function(e){return t.helper.classList.add(e)})),t.listenerNode=e.touches?e.target:t.contentWindow,m?(t.listenerNode.addEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.addEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.addEventListener("keydown",t.handleKeyDown)):(D.move.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortMove,!1)})),D.end.forEach((function(e){return t.listenerNode.addEventListener(e,t.handleSortEnd,!1)}))),t.setState({sorting:!0,sortingIndex:b}),d&&d({node:p,index:b,collection:h,isKeySorting:m,nodes:t.manager.getOrderedRefs(),helper:t.helper},e),m&&t.keyMove(0)},r=t.props,a=r.axis,l=r.getHelperDimensions,s=r.helperClass,u=r.hideSortableGhost,c=r.updateBeforeSortStart,d=r.onSortStart,f=r.useWindowAsScrollContainer,p=n.node,h=n.collection,m=t.manager.isKeySorting,g=function(){if("function"==typeof c){t._awaitingUpdateBeforeSortStart=!0;var n=function(t,n){try{var o=(r=p.sortableInfo.index,Promise.resolve(c({collection:h,index:r,node:p,isKeySorting:m},e)).then((function(){})))}catch(e){return n(!0,e)}var r;return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!1,value)}(0,(function(e,n){if(t._awaitingUpdateBeforeSortStart=!1,e)throw n;return n}));if(n&&n.then)return n.then((function(){}))}}();return g&&g.then?g.then(o):o()}}();return Promise.resolve(o&&o.then?o.then((function(){})):void 0)}catch(e){return Promise.reject(e)}})),b(I(I(t)),"handleSortMove",(function(e){var n=t.props.onSortMove;"function"==typeof e.preventDefault&&e.cancelable&&e.preventDefault(),t.updateHelperPosition(e),t.animateNodes(),t.autoscroll(),n&&n(e)})),b(I(I(t)),"handleSortEnd",(function(e){var n=t.props,o=n.hideSortableGhost,r=n.onSortEnd,i=t.manager,a=i.active.collection,l=i.isKeySorting,s=t.manager.getOrderedRefs();t.listenerNode&&(l?(t.listenerNode.removeEventListener("wheel",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("mousedown",t.handleKeyEnd,!0),t.listenerNode.removeEventListener("keydown",t.handleKeyDown)):(D.move.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortMove)})),D.end.forEach((function(e){return t.listenerNode.removeEventListener(e,t.handleSortEnd)})))),t.helper.parentNode.removeChild(t.helper),o&&t.sortableGhost&&M(t.sortableGhost,{opacity:"",visibility:""});for(var u=0,c=s.length;uo)){t.prevIndex=i,t.newIndex=r;var a=function(e,t,n){return et?e-1:e>n&&eg?g/2:this.height/2,width:this.width>m?m/2:this.width/2},b=u&&h>this.index&&h<=c,v=u&&h=c,x={x:0,y:0},w=a[d].edgeOffset;w||(w=q(p,this.container),a[d].edgeOffset=w,u&&(a[d].boundingClientRect=K(p,r)));var S=d0&&a[d-1];S&&!S.edgeOffset&&(S.edgeOffset=q(S.node,this.container),u&&(S.boundingClientRect=K(S.node,r))),h!==this.index?(t&&N(p,t),this.axis.x?this.axis.y?v||hthis.containerBoundingRect.width-y.width&&S&&(x.x=S.edgeOffset.left-w.left,x.y=S.edgeOffset.top-w.top),null===this.newIndex&&(this.newIndex=h)):(b||h>this.index&&(l+i.left+y.width>=w.left&&s+i.top+y.height>=w.top||s+i.top+y.height>=w.top+g))&&(x.x=-(this.width+this.marginOffset.x),w.left+x.xthis.index&&l+i.left+y.width>=w.left?(x.x=-(this.width+this.marginOffset.x),this.newIndex=h):(v||hthis.index&&s+i.top+y.height>=w.top?(x.y=-(this.height+this.marginOffset.y),this.newIndex=h):(v||h=0&&x([].concat(i(v.slice(0,t)),i(v.slice(t+1))))},removeAuthorLabel:g}))}ce(pe,"useState{[profiles, setProfiles](profilesRaw)}\nuseState{[search, setSearch]('')}\nuseState{[searchResults, setSearchResults]([])}\nuseState{[value, setValue]('')}\nuseDebounce{debouncedSearchString}\nuseCallback{doProfileSearch}\nuseEffect{}",(function(){return[ue.je]})),pe.defaultProps={autocompleteInputId:"profiles_autocomplete",freeformInputId:"byline_freeform"},pe.propTypes={autocompleteInputId:s().string,freeformInputId:s().string,addAuthorLabel:s().string.isRequired,addAuthorPlaceholder:s().string.isRequired,addFreeformButtonLabel:s().string.isRequired,addFreeformLabel:s().string.isRequired,addFreeformPlaceholder:s().string.isRequired,profilesApiUrl:s().string.isRequired,removeAuthorLabel:s().string.isRequired,profiles:s().arrayOf(s().shape({id:s().oneOfType([s().number,s().string]),byline_id:s().number,name:s().string,image:s().oneOfType([s().bool,s().string])})).isRequired};var he,me,ge=pe,ye=ge;(he="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(he.register(de,"SortableItem","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-profiles/index.js"),he.register(fe,"BylineList","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-profiles/index.js"),he.register(pe,"BylineProfiles","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-profiles/index.js"),he.register(ge,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/byline-profiles/index.js")),(me="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&me(e)},"./client/src/components/user-link-metabox/index.js":function(e,t,n){"use strict";var o,r=n("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),i=n("./node_modules/prop-types/index.js"),a=n.n(i),l=n("@wordpress/element"),s=n("@wordpress/api-fetch"),u=n.n(s),c=n("@wordpress/url"),d=n("@wordpress/components"),f=n("./node_modules/react-autocomplete/build/lib/Autocomplete.js"),p=n.n(f),h=n("./node_modules/@uidotdev/usehooks/index.js");function m(e){var t=e.linkUserPlaceholder,n=e.linkedToLabel,o=e.postId,i=e.unlinkLabel,a=e.user,s=e.userAlreadyLinked,f=e.usersApiUrl,m=(0,l.useState)(""),g=(0,r.c)(m,2),y=g[0],b=g[1],v=(0,l.useState)([]),x=(0,r.c)(v,2),w=x[0],S=x[1],I=(0,l.useState)({}),k=(0,r.c)(I,2),O=k[0],T=k[1],E=(0,h.je)(y,750),C=(0,l.useCallback)((function(e){u()({url:(0,c.addQueryArgs)(f,{s:e,post:o})}).then((function(e){return S(e)}))}),[o,f]),L={placeholder:t,onKeyDown:function(e){13===e.keyCode&&e.preventDefault()}};return(0,l.useEffect)((function(){""!==E&&C(E)}),[E,C]),(0,l.useEffect)((function(){T(a)}),[a]),React.createElement("div",{className:"profile-user-link byline-manager-meta-box"},React.createElement("input",{type:"hidden",name:"profile_user_link",value:O.id||0}),O&&O.id&&O.name?React.createElement("p",{className:"current-user-link"},"".concat(n," "),React.createElement("a",{href:"/wp-admin/user-edit.php?user_id=".concat(O.id)},O.name)," ",React.createElement(d.Button,{className:"button button-link-delete button-small",variant:"secondary",isDestructive:!0,size:"small",onClick:function(e){e.preventDefault(),T({})}},i)):null,React.createElement(p(),{inputProps:L,items:w,value:y,getItemValue:function(e){return e.name},onSelect:function(e,t){T(t),b(""),S([])},onChange:function(e,t){return b(t)},isItemSelectable:function(e){return!e.linked},renderMenu:function(e){return React.createElement("div",{className:"menu"},e)},renderItem:function(e,t){return React.createElement("div",{className:["item",t?"item-highlighted":"",e.linked?"item-disabled":""].join(" "),key:e.id},e.name,e.linked?React.createElement("em",null,s):null)},wrapperStyle:{display:"block"}}))}e=n.hmd(e),(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&o(e),("undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default.signature:function(e){return e})(m,"useState{[search, setSearch]('')}\nuseState{[searchResults, setSearchResults]([])}\nuseState{[user, setUser]({})}\nuseDebounce{debouncedSearchString}\nuseCallback{doUserSearch}\nuseEffect{}\nuseEffect{}",(function(){return[h.je]})),m.defaultProps={user:{}},m.propTypes={linkUserPlaceholder:a().string.isRequired,linkedToLabel:a().string.isRequired,postId:a().number.isRequired,unlinkLabel:a().string.isRequired,user:a().shape({id:a().number,name:a().string,linked:a().bool}),userAlreadyLinked:a().string.isRequired,usersApiUrl:a().string.isRequired};var g,y,b=m;t.c=b,(g="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(g.register(m,"UserLinkMetaBox","/home/runner/work/byline-manager/byline-manager/client/src/components/user-link-metabox/index.js"),g.register(b,"default","/home/runner/work/byline-manager/byline-manager/client/src/components/user-link-metabox/index.js")),(y="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&y(e)},"./client/src/init-byline-metabox.js":function(e,t,n){"use strict";var o,r=n("react-dom"),i=n.n(r),a=n("./client/src/components/byline-metabox/index.js");e=n.hmd(e),(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&o(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,u=function(){var e=bylineData.bylineMetaBox;i().createRoot(React.createElement(a.c,{bylineMetaBox:e}),document.getElementById("byline-manager-metabox-root"))},c=u;t.c=c,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(u,"initBylineMetaBox","/home/runner/work/byline-manager/byline-manager/client/src/init-byline-metabox.js"),l.register(c,"default","/home/runner/work/byline-manager/byline-manager/client/src/init-byline-metabox.js")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./client/src/init-user-link-metabox.js":function(e,t,n){"use strict";var o,r=n("react-dom"),i=n.n(r),a=n("./client/src/components/user-link-metabox/index.js");e=n.hmd(e),(o="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.enterModule:void 0)&&o(e),"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature;var l,s,u=function(){var e=document.getElementById("byline-manager-user-link-root"),t=e.dataset.user?JSON.parse(e.dataset.user):{},n=bylineData,o=n.linkUserPlaceholder,r=n.linkedToLabel,l=n.postId,s=n.unlinkLabel,u=n.userAlreadyLinked,c=n.usersApiUrl;i().createRoot(React.createElement(a.c,{linkUserPlaceholder:o,linkedToLabel:r,postId:+l,unlinkLabel:s,user:t,userAlreadyLinked:u,usersApiUrl:c}),e)},c=u;t.c=c,(l="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.default:void 0)&&(l.register(u,"initUserLinkMetaBox","/home/runner/work/byline-manager/byline-manager/client/src/init-user-link-metabox.js"),l.register(c,"default","/home/runner/work/byline-manager/byline-manager/client/src/init-user-link-metabox.js")),(s="undefined"!=typeof reactHotLoaderGlobal?reactHotLoaderGlobal.leaveModule:void 0)&&s(e)},"./node_modules/invariant/browser.js":function(e){"use strict";e.exports=function(e,t,n,o,r,i,a,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,o,r,i,a,l],c=0;(s=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}},"./node_modules/prop-types/factoryWithThrowingShims.js":function(e,t,n){"use strict";var o=n("./node_modules/prop-types/lib/ReactPropTypesSecret.js");function r(){}function i(){}i.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,i,a){if(a!==o){var l=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 l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={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:i,resetWarningCache:r};return n.PropTypes=n,n}},"./node_modules/prop-types/index.js":function(e,t,n){e.exports=n("./node_modules/prop-types/factoryWithThrowingShims.js")()},"./node_modules/prop-types/lib/ReactPropTypesSecret.js":function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},"./node_modules/react-autocomplete/build/lib/Autocomplete.js":function(e,t,n){"use strict";var o=Object.assign||function(e){for(var t=1;t=this.getFilteredItems(t).length)return{highlightedIndex:null}}},{key:"setMenuPositions",value:function(){var e=this.refs.input,t=e.getBoundingClientRect(),o=n.g.window.getComputedStyle(e),r=parseInt(o.marginBottom,10)||0,i=parseInt(o.marginLeft,10)||0,a=parseInt(o.marginRight,10)||0;this.setState({menuTop:t.bottom+r,menuLeft:t.left+i,menuWidth:t.width+i+a})}},{key:"highlightItemFromMouse",value:function(e){this.setState({highlightedIndex:e})}},{key:"selectItemFromMouse",value:function(e){var t=this,n=this.props.getItemValue(e);this.setIgnoreBlur(!1),this.setState({isOpen:!1,highlightedIndex:null},(function(){t.props.onSelect(n,e)}))}},{key:"setIgnoreBlur",value:function(e){this._ignoreBlur=e}},{key:"renderMenu",value:function(){var e=this,t=this.getFilteredItems(this.props).map((function(t,n){var o=e.props.renderItem(t,e.state.highlightedIndex===n,{cursor:"default"});return i.cloneElement(o,{onMouseEnter:e.props.isItemSelectable(t)?function(){return e.highlightItemFromMouse(n)}:null,onClick:e.props.isItemSelectable(t)?function(){return e.selectItemFromMouse(t)}:null,ref:function(t){return e.refs["item-"+n]=t}})})),n={left:this.state.menuLeft,top:this.state.menuTop,minWidth:this.state.menuWidth},o=this.props.renderMenu(t,this.props.value,n);return i.cloneElement(o,{ref:function(t){return e.refs.menu=t},onTouchStart:function(){return e.setIgnoreBlur(!0)},onMouseEnter:function(){return e.setIgnoreBlur(!0)},onMouseLeave:function(){return e.setIgnoreBlur(!1)}})}},{key:"handleInputBlur",value:function(e){var t=this;if(this._ignoreBlur)return this._ignoreFocus=!0,this._scrollOffset={x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop},void this.refs.input.focus();var n=void 0,o=this.state.highlightedIndex;if(this.props.selectOnBlur&&null!==o){var r=this.getFilteredItems(this.props)[o],i=this.props.getItemValue(r);n=function(){return t.props.onSelect(i,r)}}this.setState({isOpen:!1,highlightedIndex:null},n);var a=this.props.inputProps.onBlur;a&&a(e)}},{key:"handleInputFocus",value:function(e){var t=this;if(this._ignoreFocus){this._ignoreFocus=!1;var n=this._scrollOffset,o=n.x,r=n.y;return this._scrollOffset=null,window.scrollTo(o,r),clearTimeout(this._scrollTimer),void(this._scrollTimer=setTimeout((function(){t._scrollTimer=null,window.scrollTo(o,r)}),0))}this.setState({isOpen:!0});var i=this.props.inputProps.onFocus;i&&i(e)}},{key:"isInputFocused",value:function(){var e=this.refs.input;return e.ownerDocument&&e===e.ownerDocument.activeElement}},{key:"handleInputClick",value:function(){this.isInputFocused()&&!this.isOpen()&&this.setState({isOpen:!0})}},{key:"composeEventHandlers",value:function(e,t){return t?function(n){e(n),t(n)}:e}},{key:"isOpen",value:function(){return"open"in this.props?this.props.open:this.state.isOpen}},{key:"render",value:function(){this.props.debug&&this._debugStates.push({id:this._debugStates.length,state:this.state});var e=this.props.inputProps,t=this.isOpen();return i.createElement("div",o({style:o({},this.props.wrapperStyle)},this.props.wrapperProps),this.props.renderInput(o({},e,{role:"combobox","aria-autocomplete":"list","aria-expanded":t,autoComplete:"off",ref:this.exposeAPI,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,onChange:this.handleChange,onKeyDown:this.composeEventHandlers(this.handleKeyDown,e.onKeyDown),onClick:this.composeEventHandlers(this.handleInputClick,e.onClick),value:this.props.value})),t&&this.renderMenu(),this.props.debug&&i.createElement("pre",{style:{marginLeft:300}},JSON.stringify(this._debugStates.slice(Math.max(0,this._debugStates.length-5),this._debugStates.length),null,2)))}}]),t}(i.Component);c.propTypes={items:a.array.isRequired,value:a.any,onChange:a.func,onSelect:a.func,shouldItemRender:a.func,isItemSelectable:a.func,sortItems:a.func,getItemValue:a.func.isRequired,renderItem:a.func.isRequired,renderMenu:a.func,menuStyle:a.object,renderInput:a.func,inputProps:a.object,wrapperProps:a.object,wrapperStyle:a.object,autoHighlight:a.bool,selectOnBlur:a.bool,onMenuVisibilityChange:a.func,open:a.bool,debug:a.bool},c.defaultProps={value:"",wrapperProps:{},wrapperStyle:{display:"inline-block"},inputProps:{},renderInput:function(e){return i.createElement("input",e)},onChange:function(){},onSelect:function(){},isItemSelectable:function(){return!0},renderMenu:function(e,t,n){return i.createElement("div",{style:o({},n,this.menuStyle),children:e})},menuStyle:{borderRadius:"3px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.9)",padding:"2px 0",fontSize:"90%",position:"fixed",overflow:"auto",maxHeight:"50%"},autoHighlight:!0,selectOnBlur:!1,onMenuVisibilityChange:function(){}},c.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,o=null===n?-1:n,r=0;r-1&&o!==n&&this.setState({highlightedIndex:o,isOpen:!0})}},ArrowUp:function(e){e.preventDefault();var t=this.getFilteredItems(this.props);if(t.length){for(var n=this.state.highlightedIndex,o=null===n?t.length:n,r=0;r0?!0===a?o.scrollTop(t,d.top+f.top):!1===a?o.scrollTop(t,d.top+p.top):f.top<0?o.scrollTop(t,d.top+f.top):o.scrollTop(t,d.top+p.top):i||((a=void 0===a||!!a)?o.scrollTop(t,d.top+f.top):o.scrollTop(t,d.top+p.top)),r&&(f.left<0||p.left>0?!0===l?o.scrollLeft(t,d.left+f.left):!1===l?o.scrollLeft(t,d.left+p.left):f.left<0?o.scrollLeft(t,d.left+f.left):o.scrollLeft(t,d.left+p.left):i||((l=void 0===l||!!l)?o.scrollLeft(t,d.left+f.left):o.scrollLeft(t,d.left+p.left)))}},"./node_modules/react-autocomplete/node_modules/dom-scroll-into-view/lib/util.js":function(e){function t(e,t){var n=e["page"+(t?"Y":"X")+"Offset"],o="scroll"+(t?"Top":"Left");if("number"!=typeof n){var r=e.document;"number"!=typeof(n=r.documentElement[o])&&(n=r.body[o])}return n}function n(e){return t(e)}function o(e){return t(e,!0)}function r(e){var t=function(e){var t,n,o,r=e.ownerDocument,i=r.body,a=r&&r.documentElement;return n=(t=e.getBoundingClientRect()).left,o=t.top,{left:n-=a.clientLeft||i.clientLeft||0,top:o-=a.clientTop||i.clientTop||0}}(e),r=e.ownerDocument,i=r.defaultView||r.parentWindow;return t.left+=n(i),t.top+=o(i),t}var i,a=new RegExp("^("+/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source+")(?!px)[a-z%]+$","i"),l=/^(top|right|bottom|left)$/,s="currentStyle",u="runtimeStyle",c="left";function d(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n{const n=setTimeout((()=>{r(e)}),t);return()=>{clearTimeout(n)}}),[e,t]),n}}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o](i,i.exports,n),i.loaded=!0,i.exports}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 o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=n("./client/src/init-byline-metabox.js"),t=n("./client/src/init-user-link-metabox.js");"undefined"!=typeof reactHotLoaderGlobal&&reactHotLoaderGlobal.default.signature,document.getElementById("byline-manager-metabox-root")?(0,e.c)():document.getElementById("byline-manager-user-link-root")&&(0,t.c)()}()}(); \ No newline at end of file diff --git a/client/build/main.4e315351.bundle.js.LICENSE.txt b/client/build/main.4e315351.bundle.js.LICENSE.txt new file mode 100644 index 00000000..827f2732 --- /dev/null +++ b/client/build/main.4e315351.bundle.js.LICENSE.txt @@ -0,0 +1,5 @@ +/*! + Copyright (c) 2018 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/ diff --git a/client/build/main.4e315351.min.css b/client/build/main.4e315351.min.css new file mode 100644 index 00000000..065386c7 --- /dev/null +++ b/client/build/main.4e315351.min.css @@ -0,0 +1 @@ +:root{--spacer: rem(20px)}.demo{background-color:var(--grayLight);font-style:italic;margin:rem(20px) 0;padding:rem(20px);text-align:center}.freeform-controls label,.profile-controls label{display:block}.freeform-controls .freeformInputGrp{align-items:flex-start;display:flex;margin:.3125rem 0}.freeform-controls .freeformInputGrp .components-text-control__input{border-bottom-right-radius:0;border-top-right-radius:0;margin:0}.freeform-controls .freeformInputGrp button{border-bottom-left-radius:0;border-left:0;border-top-left-radius:0;box-shadow:none;margin:0}.profile-controls .components-text-control__input,.profile-user-link .components-text-control__input{margin:.3125rem 0 0}.profile-controls .menu,.profile-user-link .menu{background:#fff;box-sizing:border-box;padding:0;position:absolute;width:100%;z-index:100}.components-panel #side-sortables .profile-controls .menu,.components-panel #side-sortables .profile-user-link .menu{max-width:calc(100% - 48px)}.block-editor-page .profile-controls .menu,.block-editor-page .profile-user-link .menu{background:rgba(0,0,0,0);border:0}.profile-controls .item,.profile-user-link .item{background:#fff;border:0 solid #ccc;border-left-width:1px;border-right-width:1px;cursor:default;padding:.5rem}.profile-controls .item:first-of-type,.profile-user-link .item:first-of-type{border-top-width:1px}.profile-controls .item:last-of-type,.profile-user-link .item:last-of-type{border-bottom-width:1px}.profile-controls .item-highlighted,.profile-user-link .item-highlighted{background-color:#4095bf;color:#fff}.profile-controls .item-disabled,.profile-user-link .item-disabled{color:#aaa;cursor:not-allowed;display:flex;flex-wrap:wrap;justify-content:space-between}.profile-controls .item-disabled em,.profile-user-link .item-disabled em{margin-left:.5rem}.profile-controls .item-header,.profile-user-link .item-header{background-color:#eee;color:#454545;font-weight:700}.profile-user-link .menu{max-width:37.5rem}.byline-manager-meta-box label{color:#555d66;display:block}.byline-manager-meta-box input[type=text],.byline-manager-meta-box input[role=combobox]{display:block;min-height:28px;width:100%}.byline-manager-meta-box .byline-list-controls{border-bottom:1px solid var(--grayLight);display:flex;flex-wrap:wrap;gap:.5rem;padding:.5rem}.byline-manager-meta-box .byline-list-controls>div{flex:1;max-width:34.375rem;min-width:15.625rem}.byline-manager-meta-box .current-user-link{font-weight:700}.byline-manager-meta-box .current-user-link button{font-weight:500;margin-left:.625rem}.byline-manager-meta-box .byline-override-option{float:right;margin:.3125rem 0 .9375rem .9375rem}.byline-manager-meta-box label span{display:block}#advanced-sortables .profile-user-link input,#normal-sortables .profile-user-link input{width:28.125rem}@media(min-width: 851px){#side-sortables .menu{right:.625rem;width:27.5rem}.components-panel #side-sortables .menu{left:1.5rem;max-width:14.5rem;right:auto}}.byline-list{min-height:6.25rem}.byline-list ol,.byline-list ul{list-style:none;margin-left:0}.byline-list-item{align-items:center;display:flex;max-width:15.625rem}.byline-list-item button{margin-left:auto}.components-item-group div[role=listitem]:last-child .byline-list-item{margin-bottom:0}div.byline-list-item{align-items:center;background-color:#fff;cursor:move;display:flex;list-style:none;margin-bottom:.3125rem;padding:.3125rem 0 .3125rem .625rem}div.byline-list-item *{vertical-align:middle}div.byline-list-item img{height:3.125rem;margin-right:.625rem;width:3.125rem}div.byline-list-item button.components-button.is-destructive{background:none;border:1px solid rgba(0,0,0,0);cursor:pointer;margin-left:auto;transition:background-color .2s} diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100755 index 0ca9c560..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,135 +0,0 @@ -maybe_rsync_plugin() - ->before( - function() { - // Load the testcases. - require_once __DIR__ . '/testcases/class-test-controller.php'; - } - ) - ->loaded( fn () => require_once __DIR__ . '/../byline-manager.php' ) - ->install(); - -// XML to Array from Core - -// Convert valid XML to an array tree structure. -// Kinda lame, but it works with a default PHP 4 installation. -class TestXMLParser { - public $xml; - public $data = []; - - /** - * PHP5 constructor. - */ - public function __construct( $in ) { - $this->xml = xml_parser_create(); - xml_set_object( $this->xml, $this ); - xml_parser_set_option( $this->xml, XML_OPTION_CASE_FOLDING, 0 ); - xml_set_element_handler( $this->xml, [ $this, 'start_handler' ], [ $this, 'end_handler' ] ); - xml_set_character_data_handler( $this->xml, [ $this, 'data_handler' ] ); - $this->parse( $in ); - } - - public function parse( $in ) { - $parse = xml_parse( $this->xml, $in, true ); - if ( ! $parse ) { - trigger_error( - sprintf( - 'XML error: %s at line %d', - xml_error_string( xml_get_error_code( $this->xml ) ), - xml_get_current_line_number( $this->xml ) - ), - E_USER_ERROR - ); - xml_parser_free( $this->xml ); - } - return true; - } - - public function start_handler( $parser, $name, $attributes ) { - $data['name'] = $name; - if ( $attributes ) { - $data['attributes'] = $attributes; } - $this->data[] = $data; - } - - public function data_handler( $parser, $data ) { - $index = count( $this->data ) - 1; - - if ( ! isset( $this->data[ $index ]['content'] ) ) { - $this->data[ $index ]['content'] = ''; - } - $this->data[ $index ]['content'] .= $data; - } - - public function end_handler( $parser, $name ) { - if ( count( $this->data ) > 1 ) { - $data = array_pop( $this->data ); - $index = count( $this->data ) - 1; - $this->data[ $index ]['child'][] = $data; - } - } -} - -/** - * Converts an XML string into an array tree structure. - * - * The output of this function can be passed to xml_find() to find nodes by their path. - * - * @param string $in The XML string. - * @return array XML as an array. - */ -function xml_to_array( $in ) { - $p = new TestXMLParser( $in ); - return $p->data; -} - -/** - * Finds XML nodes by a given "path". - * - * Example usage: - * - * $tree = xml_to_array( $rss ); - * $items = xml_find( $tree, 'rss', 'channel', 'item' ); - * - * @param array $tree An array tree structure of XML, typically from xml_to_array(). - * @param string ...$elements Names of XML nodes to create a "path" to find within the XML. - * @return array Array of matching XML node information. - */ -function xml_find( $tree, ...$elements ) { - $n = count( $elements ); - $out = []; - - if ( $n < 1 ) { - return $out; - } - - for ( $i = 0; $i < count( $tree ); $i++ ) { - // echo "checking '{$tree[$i][name]}' == '{$elements[0]}'\n"; - // var_dump( $tree[$i]['name'], $elements[0] ); - if ( $tree[ $i ]['name'] === $elements[0] ) { - // echo "n == {$n}\n"; - if ( 1 === $n ) { - $out[] = $tree[ $i ]; - } else { - $subtree =& $tree[ $i ]['child']; - $out = array_merge( $out, xml_find( $subtree, ...array_slice( $elements, 1 ) ) ); - } - } - } - - return $out; -} - -function get_echo( $callback, $args = [] ) { - ob_start(); - call_user_func_array( $callback, $args ); - return ob_get_clean(); -} diff --git a/tests/feature/controllers/test-authors-controller.php b/tests/feature/controllers/test-authors-controller.php deleted file mode 100644 index b9e1a066..00000000 --- a/tests/feature/controllers/test-authors-controller.php +++ /dev/null @@ -1,44 +0,0 @@ -endpoint = '/' . REST_NAMESPACE . '/authors'; - } - - public function test_get_authors(): void { - $user = self::factory()->user->create(); - - wp_set_current_user( $user ); - - $request = new WP_REST_Request( WP_REST_Server::READABLE, $this->endpoint ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertEquals( 200, $response->get_status() ); - } - - public function test_get_authors_without_permission(): void { - $request = new WP_REST_Request( WP_REST_Server::READABLE, $this->endpoint ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertErrorResponse( 'rest_forbidden', $response, rest_authorization_required_code() ); - } -} diff --git a/tests/feature/controllers/test-hydrate-profiles-controller.php b/tests/feature/controllers/test-hydrate-profiles-controller.php deleted file mode 100644 index a6276640..00000000 --- a/tests/feature/controllers/test-hydrate-profiles-controller.php +++ /dev/null @@ -1,50 +0,0 @@ -endpoint = '/' . REST_NAMESPACE . '/hydrateProfiles'; - } - - public function test_get_hydrated_profiles(): void { - $user = self::factory()->user->create(); - - wp_set_current_user( $user ); - - $request = new WP_REST_Request( WP_REST_Server::CREATABLE, $this->endpoint ); - $request->add_header( 'content-type', 'application/json' ); - $request->set_param( 'context', 'edit' ); - $request->set_body( wp_json_encode( [ 'profiles' => [] ] ) ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertEquals( 200, $response->get_status() ); - } - - public function test_get_hydrated_profiles_without_permission(): void { - $request = new WP_REST_Request( WP_REST_Server::CREATABLE, $this->endpoint ); - $request->add_header( 'content-type', 'application/json' ); - $request->set_param( 'context', 'edit' ); - $request->set_body( wp_json_encode( [ 'profiles' => [] ] ) ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertErrorResponse( 'rest_forbidden', $response, rest_authorization_required_code() ); - } -} diff --git a/tests/feature/controllers/test-users-controller.php b/tests/feature/controllers/test-users-controller.php deleted file mode 100644 index 62df232a..00000000 --- a/tests/feature/controllers/test-users-controller.php +++ /dev/null @@ -1,44 +0,0 @@ -endpoint = '/' . REST_NAMESPACE . '/users'; - } - - public function test_get_authors(): void { - $user = self::factory()->user->create(); - - wp_set_current_user( $user ); - - $request = new WP_REST_Request( WP_REST_Server::READABLE, $this->endpoint ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertEquals( 200, $response->get_status() ); - } - - public function test_get_authors_without_permission(): void { - $request = new WP_REST_Request( WP_REST_Server::READABLE, $this->endpoint ); - - $response = rest_get_server()->dispatch( $request ); - - $this->assertErrorResponse( 'rest_forbidden', $response, rest_authorization_required_code() ); - } -} diff --git a/tests/feature/test-bylines-template-tags.php b/tests/feature/test-bylines-template-tags.php deleted file mode 100644 index b17d96a4..00000000 --- a/tests/feature/test-bylines-template-tags.php +++ /dev/null @@ -1,612 +0,0 @@ - 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - - $post_id = static::factory()->post->create(); - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - ], - ]; - - Utils::set_post_byline( $post_id, $byline_meta ); - - $byline = Utils::get_byline_entries_for_post( $post_id ); - - $this->assertCount( 2, $byline ); - $this->assertEquals( [ $b1->post_id, $b2->post_id ], wp_list_pluck( $byline, 'post_id' ) ); - - // Ensure the order persists. - $byline_meta['byline_entries'] = array_reverse( $byline_meta['byline_entries'] ); - Utils::set_post_byline( $post_id, $byline_meta ); - $byline = Utils::get_byline_entries_for_post( $post_id ); - $this->assertCount( 2, $byline ); - $this->assertEquals( [ $b2->post_id, $b1->post_id ], wp_list_pluck( $byline, 'post_id' ) ); - - // Ensure that adding a text profile item alongside profiles works. - $byline_meta['byline_entries'][] = [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Text Item 1', - ], - ]; - } - - /** - * Ensure get_byline_entries_for_post() returns a user object when no bylines are assigned - */ - public function test_get_byline_entries_for_post_returns_wp_user() { - $this->markTestSkipped( 'TODO: how to handle posts without byline' ); - - $user_id = static::factory()->user->create(); - $post_id = static::factory()->post->create( - [ - 'post_author' => $user_id, - ] - ); - $byline = Utils::get_byline_entries_for_post( $post_id ); - $this->assertCount( 1, $byline ); - $this->assertEquals( [ $user_id ], wp_list_pluck( $byline, 'ID' ) ); - // Adding a byline means the user id should no longer be returned. - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - Utils::set_post_byline( $post_id, [ 'byline_ids' => wp_list_pluck( [ $b1 ], 'term_id' ) ] ); - $byline = Utils::get_byline_entries_for_post( $post_id ); - $this->assertCount( 1, $byline ); - $this->assertEquals( [ 'b1' ], wp_list_pluck( $byline, 'post_name' ) ); - } - - /** - * Render one byline, without the link to its post - */ - public function test_template_tag_the_byline_one_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 1' ); - the_byline(); - } - - /** - * Render two bylines, without the link to its post - */ - public function test_template_tag_the_byline_two_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 2 and Byline 1' ); - the_byline(); - } - - /** - * Render three bylines, without the link to its post - */ - public function test_template_tag_the_byline_three_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - $b3 = Profile::create( - [ - 'post_name' => 'b3', - 'post_title' => 'Byline 3', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b3->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 2, Byline 3, and Byline 1' ); - the_byline(); - } - - /** - * Render four bylines, without the link to its post - */ - public function test_template_tag_the_byline_four_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - $b3 = Profile::create( - [ - 'post_name' => 'b3', - 'post_title' => 'Byline 3', - ] - ); - $b4 = Profile::create( - [ - 'post_name' => 'b4', - 'post_title' => 'Byline 4', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b4->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b3->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 2, Byline 4, Byline 3, and Byline 1' ); - the_byline(); - } - - /** - * Render three bylines, without the link to its post, one as a text item - */ - public function test_template_tag_the_byline_mixed_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Text Item 1', - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 1, Text Item 1, and Byline 2' ); - the_byline(); - } - - /** - * Render two bylines, with the link to its post - */ - public function test_template_tag_the_byline_posts_links_two_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( ' and ' ); - the_byline_posts_links(); - } - - /** - * Render two bylines, with the link to its post - */ - public function test_template_tag_the_byline_posts_links_mixed_byline() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Text Item 1', - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( ' and Text Item 1' ); - the_byline_posts_links(); - } - - /** - * Render one user, with the link to its post - */ - public function test_template_tag_the_byline_posts_links_one_user() { - $this->markTestSkipped( 'TODO: how to handle posts without byline' ); - - global $post; - $user_id = static::factory()->user->create(); - $post_id = static::factory()->post->create( - [ - 'post_author' => $user_id, - ] - ); - $post = get_post( $post_id ); - $user = get_user_by( 'id', $user_id ); - $this->expectOutputString( '' ); - the_byline_posts_links(); - } - - /** - * Render two bylines, one with a custom URL and the other without - */ - public function test_template_tag_the_byline_links_two_bylines() { - global $post; - $b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - update_post_meta( $b2->post_id, 'user_url', 'https://apple.com' ); - - $byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b2->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $b1->term_id, - ], - ], - ], - ]; - - $post_id = static::factory()->post->create(); - $post = get_post( $post_id ); - Utils::set_post_byline( $post_id, $byline_meta ); - $this->expectOutputString( 'Byline 2 and Byline 1' ); - the_byline_links(); - } - - /** - * Render byline override. - */ - public function test_get_override_for_post() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 1', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 1', get_echo( '\Byline_Manager\the_byline' ) ); - } - - /** - * Render byline override that has an HTML link without the link. - */ - public function test_get_override_with_link_for_post() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 1', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 1', get_echo( '\Byline_Manager\the_byline' ) ); - } - - /** - * Render byline override via `the_byline_posts_links()`. - */ - public function test_template_tag_the_byline_posts_links_with_override() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 2', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 2', get_echo( '\Byline_Manager\the_byline_posts_links' ) ); - } - - /** - * Render byline override with a link via `the_byline_posts_links()`. - */ - public function test_template_tag_the_byline_posts_links_with_override_with_link() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 2', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 2', get_echo( '\Byline_Manager\the_byline_posts_links' ) ); - } - - /** - * Render byline override via `the_byline_links()`. - */ - public function test_template_tag_the_byline_links_with_override() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 3', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 3', get_echo( '\Byline_Manager\the_byline_links' ) ); - } - - /** - * Render byline override with a link via `the_byline_links()`. - */ - public function test_template_tag_the_byline_links_with_override_with_link() { - global $post; - $post = static::factory()->post->create_and_get(); - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Override 3', - ], - ], - ], - ] - ); - $this->assertSame( 'Test Override 3', get_echo( '\Byline_Manager\the_byline_links' ) ); - } -} diff --git a/tests/feature/test-core-filters.php b/tests/feature/test-core-filters.php deleted file mode 100644 index 680c7cd2..00000000 --- a/tests/feature/test-core-filters.php +++ /dev/null @@ -1,261 +0,0 @@ -user->create( - [ - 'role' => 'editor', - ] - ); - $this->b1 = Profile::create( - [ - 'post_name' => 'b1', - 'post_title' => 'Byline 1', - ] - ); - $this->b2 = Profile::create( - [ - 'post_name' => 'b2', - 'post_title' => 'Byline 2', - ] - ); - $this->byline_meta = [ - 'byline_entries' => [ - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $this->b1->term_id, - ], - ], - [ - 'type' => 'byline_id', - 'atts' => [ - 'byline_id' => $this->b2->term_id, - ], - ], - ], - ]; - $post = static::factory()->post->create_and_get( [ 'post_author' => $user_id ] ); - setup_postdata( $post ); - } - - /** - * Check that `the_author()` will output the byline automatically. - */ - public function test_the_author_filter() { - global $post; - $byline_meta = $this->byline_meta; - - // Before the byline gets set, `the_author()` should output nothing. - $this->assertEquals( '', get_echo( 'the_author' ) ); - - // Set the byline and confirm that `the_author()` outputs it. - Utils::set_post_byline( $post->ID, $byline_meta ); - $this->assertEquals( 'Byline 1 and Byline 2', get_echo( 'the_author' ) ); - - // Ensure order changes propogate. - $byline_meta['byline_entries'] = array_reverse( $byline_meta['byline_entries'] ); - Utils::set_post_byline( $post->ID, $byline_meta ); - $this->assertEquals( 'Byline 2 and Byline 1', get_echo( 'the_author' ) ); - } - - /** - * Render two profiles in a byline, with the links to their posts. - */ - public function test_template_tag_the_byline_posts_links_two_byline() { - global $post; - $byline_meta = $this->byline_meta; - // Flip the order of the bylines. - $byline_meta['byline_entries'] = array_reverse( $byline_meta['byline_entries'] ); - Utils::set_post_byline( $post->ID, $byline_meta ); - - $this->expectOutputString( ' and ' ); - the_author_posts_link(); - } - - /** - * Check that `the_author()` will output the byline override automatically. - */ - public function test_the_author_filter_byline_override() { - global $post; - - // Before the byline gets set, `the_author()` should output nothing. - $this->assertEquals( '', get_echo( 'the_author' ) ); - - // Set the byline and confirm that `the_author()` outputs it. - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Core Override 1', - ], - ], - ], - ] - ); - $this->assertEquals( 'Test Core Override 1', get_echo( 'the_author' ) ); - } - - /** - * Render the byline override without links. - */ - public function test_template_tag_the_byline_posts_links_override() { - global $post; - - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test Core Override 2', - ], - ], - ], - ] - ); - - $this->assertEquals( 'Test Core Override 2', get_echo( 'the_author_posts_link' ) ); - } - - /** - * This is a bit of a hack used to buffer feed content. - * - * @return string - */ - public function do_rss2(): string { - ob_start(); - try { - @require ABSPATH . 'wp-includes/feed-rss2.php'; - $out = ob_get_clean(); - } catch ( \Exception $e ) { - $out = ob_get_clean(); - throw($e); - } - return $out; - } - - /** - * Test that the rss feed automatically gets the byline profiles added. - */ - public function test_rss_elements() { - global $post; - $byline_meta = $this->byline_meta; - // Flip the order of the bylines. - $byline_meta['byline_entries'] = array_reverse( $byline_meta['byline_entries'] ); - Utils::set_post_byline( $post->ID, $byline_meta ); - - $this->get( '/?feed=rss2' ); - $feed = $this->do_rss2(); - $xml = xml_to_array( $feed ); - - // Get all the child elements of the element - $items = xml_find( $xml, 'rss', 'channel', 'item' ); - - // Verify we only have one post. - $this->assertCount( 1, $items ); - $item = reset( $items ); - - // Check all dc:creator nodes. - $creator = xml_find( $item['child'], 'dc:creator' ); - $this->assertCount( 2, $creator ); - $this->assertEquals( 'Byline 2', $creator[0]['content'] ); - $this->assertEquals( 'Byline 1', $creator[1]['content'] ); - } - - /** - * Test that the rss feed automatically gets the byline override added. - */ - public function test_rss_elements_byline_override() { - global $post; - Utils::set_post_byline( - $post->ID, - [ - 'byline_entries' => [ - [ - 'type' => 'text', - 'atts' => [ - 'text' => 'Test RSS Override 1', - ], - ], - ], - ] - ); - - $this->get( '/?feed=rss2' ); - $feed = $this->do_rss2(); - $xml = xml_to_array( $feed ); - - // Get all the child elements of the element - $items = xml_find( $xml, 'rss', 'channel', 'item' ); - - // Verify we only have one post. - $this->assertCount( 1, $items ); - $item = reset( $items ); - - // Check all dc:creator nodes. - $creator = xml_find( $item['child'], 'dc:creator' ); - $this->assertCount( 1, $creator ); - $this->assertEquals( 'Test RSS Override 1', $creator[0]['content'] ); - } - - public function test_author_link() { - global $post; - - // Before a user is linked to a profile, it should have no posts url. - $this->assertSame( '', get_author_posts_url( $post->post_author ) ); - - // Link the profile and user, then recheck the url. - $this->b1->update_user_link( $post->post_author ); - $this->assertSame( - get_permalink( $this->b1->post_id ), - get_author_posts_url( $post->post_author ) - ); - } - - public function test_get_author_display_name_from_user(): void { - $author_name = 'Dumas Davy de la Pailleterie'; - $user = static::factory()->user->create_and_get( - [ - 'display_name' => $author_name, - 'first_name' => 'Dumas', - 'last_name' => 'Davy de la Pailleterie', - ] - ); - - static::factory()->post->create_and_get( [ 'post_author' => $user->ID ] ); - - $display_name = get_the_author_meta( 'display_name', $user->ID ); - - $this->assertNotSame( '', $display_name ); - $this->assertSame( $author_name, $display_name ); - } -} diff --git a/tests/feature/test-profile-byline-sync.php b/tests/feature/test-profile-byline-sync.php deleted file mode 100755 index 0a8050cf..00000000 --- a/tests/feature/test-profile-byline-sync.php +++ /dev/null @@ -1,70 +0,0 @@ - byline sync functionality. - */ -class Test_Profile_Byline_Sync extends Test_Case { - use Refresh_Database; - - protected $profile_id; - - protected function setUp(): void { - parent::setUp(); - $this->profile_id = self::factory()->post->create( [ 'post_type' => PROFILE_POST_TYPE ] ); - } - - public function test_profile_creates_byline() { - $byline_id = absint( get_post_meta( $this->profile_id, 'byline_id', true ) ); - $this->assertGreaterThan( 0, $byline_id ); - - $term = get_term( $byline_id, BYLINE_TAXONOMY ); - $this->assertInstanceOf( '\WP_Term', $term ); - $this->assertSame( $term->name, "profile-{$this->profile_id}" ); - $this->assertSame( $term->slug, "profile-{$this->profile_id}" ); - } - - public function test_profile_deletes_byline() { - // Verify the byline term exists. - $byline_id = absint( get_post_meta( $this->profile_id, 'byline_id', true ) ); - $this->assertInstanceOf( '\WP_Term', get_term( $byline_id, BYLINE_TAXONOMY ) ); - - // Deleting the profile should delete the byline term. - wp_delete_post( $this->profile_id, true ); - $this->assertNull( get_term( $byline_id, BYLINE_TAXONOMY ) ); - } - - public function test_byline_relationships() { - $post_type_no_author = 'test-without-author'; - register_post_type( - $post_type_no_author, - [ - 'public' => true, - 'supports' => [ 'title', 'editor' ], - ] - ); - - $post_type_with_author = 'test-with-author'; - register_post_type( - $post_type_with_author, - [ - 'public' => true, - 'supports' => [ 'title', 'editor', 'author' ], - ] - ); - - unregister_taxonomy( BYLINE_TAXONOMY ); - register_byline(); - - $this->assertFalse( is_object_in_taxonomy( $post_type_no_author, BYLINE_TAXONOMY ) ); - $this->assertTrue( is_object_in_taxonomy( $post_type_with_author, BYLINE_TAXONOMY ) ); - } -} diff --git a/tests/feature/test-profile-user-sync.php b/tests/feature/test-profile-user-sync.php deleted file mode 100644 index 2e2697f5..00000000 --- a/tests/feature/test-profile-user-sync.php +++ /dev/null @@ -1,96 +0,0 @@ - user sync functionality. - */ -class Test_Profile_User_Sync extends Test_Case { - use Refresh_Database; - - protected $profile_id; - - protected function setUp(): void { - parent::setUp(); - $this->profile_id = self::factory()->post->create( [ 'post_type' => PROFILE_POST_TYPE ] ); - } - - public function test_update_link(): void { - $profile = Profile::get_by_post( $this->profile_id ); - $user1 = self::factory()->user->create( [ 'role' => 'author' ] ); - $user2 = self::factory()->user->create( [ 'role' => 'editor' ] ); - - $this->assertSame( 0, $profile->get_linked_user_id() ); - - // Link user1 and confirm that all data got set properly. - $profile->update_user_link( $user1 ); - $this->assertSame( $user1, $profile->get_linked_user_id() ); - $this->assertSame( $this->profile_id, absint( get_user_meta( $user1, 'profile_id', true ) ) ); - - // Link user2 and confirm that all data got unset and reset properly. - $profile->update_user_link( $user2 ); - $this->assertSame( $user2, $profile->get_linked_user_id() ); - $this->assertSame( $this->profile_id, absint( get_user_meta( $user2, 'profile_id', true ) ) ); - - // user1 should now have no profile_id meta. - $this->assertEmpty( get_user_meta( $user1, 'profile_id', true ) ); - } - - public function test_unlink(): void { - $profile = Profile::get_by_post( $this->profile_id ); - $user = self::factory()->user->create( [ 'role' => 'author' ] ); - - // Link user and confirm that all data got set properly. - $profile->update_user_link( $user ); - $this->assertSame( $user, $profile->get_linked_user_id() ); - $this->assertSame( $this->profile_id, absint( get_user_meta( $user, 'profile_id', true ) ) ); - - // Unlink user 2 and confirm that all data got unset properly. - $profile->update_user_link( 0 ); - $this->assertEmpty( $profile->get_linked_user_id() ); - $this->assertEmpty( get_user_meta( $user, 'profile_id', true ) ); - } - - public function test_profile_from_associated_user(): void { - $profile = Profile::get_by_post( $this->profile_id ); - $user = self::factory()->user->create( [ 'role' => 'author' ] ); - - // Link user and confirm that all data got set properly. - $profile->update_user_link( $user ); - $this->assertSame( $user, $profile->get_linked_user_id() ); - $this->assertSame( $this->profile_id, absint( get_user_meta( $user, 'profile_id', true ) ) ); - - // Delete profile post. - wp_delete_post( $this->profile_id, true ); - - // Confirm the associated user meta was deleted. - $this->assertEmpty( $profile->get_linked_user_id() ); - $this->assertEmpty( get_user_meta( $user, 'profile_id', true ) ); - } - - public function test_profile_from_deleted_user(): void { - $profile = Profile::get_by_post( $this->profile_id ); - $user = self::factory()->user->create( [ 'role' => 'author' ] ); - - // Link user and confirm that all data got set properly. - $profile->update_user_link( $user ); - $this->assertSame( $user, $profile->get_linked_user_id() ); - $this->assertSame( $this->profile_id, absint( get_user_meta( $user, 'profile_id', true ) ) ); - - // Delete user. - require_once(ABSPATH . 'wp-admin/includes/user.php'); - wp_delete_user( $user ); - - // Confirm the profile associated user meta was deleted. - $this->assertEmpty( $profile->get_linked_user_id() ); - } -} diff --git a/tests/testcases/class-test-controller.php b/tests/testcases/class-test-controller.php deleted file mode 100644 index ed3befe0..00000000 --- a/tests/testcases/class-test-controller.php +++ /dev/null @@ -1,40 +0,0 @@ -as_error(); - } - - $this->assertWPError( $response ); - $this->assertSame( $code, $response->get_error_code() ); - - if ( null !== $status ) { - $data = $response->get_error_data(); - $this->assertArrayHasKey( 'status', $data ); - $this->assertSame( $status, $data['status'] ); - } - } -} diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 00000000..6a149bfe --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,25 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..51e734a7 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..0fb0a2c1 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,10 @@ + $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 00000000..15a2ff3a --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ +register(true); + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 00000000..8178707e --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,20 @@ + __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->classMap = ComposerStaticInit98890ecff39c801dd9e825cbd7b010af::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 00000000..f20a6c47 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,5 @@ +{ + "packages": [], + "dev": false, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 00000000..795e5491 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,23 @@ + array( + 'name' => 'alleyinteractive/byline-manager', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => false, + ), + 'versions' => array( + 'alleyinteractive/byline-manager' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +);