UNPKG

@10up/block-components

Version:

10up Components built for the WordPress Block Editor.

2 lines 2.98 kB
!function(){"use strict";var e={161:function(e,t,o){o.d(t,{Zm:function(){return u}});var r=o(7966);const n={postId:void 0,postType:void 0,isEditable:void 0},s=(0,r.createContext)(n),u=()=>(0,r.useContext)(s)},687:function(e,t,o){o.d(t,{useIsPluginActive:function(){return u}});var r=o(5214),n=o(7816);const s=["active","network-active"],u=e=>(0,r.useSelect)(t=>{const o=t(n.store),r=o.getPlugin(e),u=o.hasFinishedResolution("getPlugin",[e]);return[s.includes(r?.status),u]},[e])},4275:function(e,t,o){o.d(t,{useIsSupportedTaxonomy:function(){return s}});var r=o(5214),n=o(7816);const s=(e,t)=>(0,r.useSelect)(o=>{const{getPostType:r,hasFinishedResolution:s}=o(n.store),u=r(e),i=s("getPostType",[e]),a=u?.taxonomies?.some(e=>e===t);return[!!a,i]},[e,t])},2312:function(e,t,o){o.d(t,{usePost:function(){return u}});var r=o(5214),n=o(4951),s=o(161);function u(){const{postId:e,postType:t,isEditable:o}=(0,s.Zm)(),{globalPostId:u,globalPostType:i}=(0,r.useSelect)(e=>({globalPostId:e(n.store).getCurrentPostId(),globalPostType:e(n.store).getCurrentPostType()}),[]);return{postId:e||u,postType:t||i,isEditable:!(!!e&&!!t)||o}}},7816:function(e){e.exports=require("@wordpress/core-data")},5214:function(e){e.exports=require("@wordpress/data")},4951:function(e){e.exports=require("@wordpress/editor")},7966:function(e){e.exports=require("@wordpress/element")},8450:function(e){e.exports=require("@wordpress/i18n")}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,o),s.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{usePrimaryTerm:function(){return c}});var n=o(5214),s=o(8450),u=o(7816),i=o(2312),a=o(687),l=o(4275);const c=e=>{const{postType:t,isEditable:o}=(0,i.usePost)(),[r,c]=(0,a.useIsPluginActive)("wordpress-seo/wp-seo"),[d,p]=(0,l.useIsSupportedTaxonomy)(t,e),f=(0,n.useSelect)(o=>{if(!p||!c)return null;if(!r&&c)return console.error("Yoast SEO is not active. Please install and activate Yoast SEO to use the PostPrimaryCategory component."),null;if(!d&&p)return console.error(`The taxonomy "${e}" is not supported for the post type "${t}". Please use a supported taxonomy.`),null;return o("yoast-seo/editor")?o("yoast-seo/editor").getPrimaryTaxonomyId(e):(console.error("The yoast-seo/editor store does is not available."),null)},[e,r,d,p,c]),y=(0,n.useSelect)(t=>{if(!f)return null;const{getEntityRecord:o}=t(u.store);return o("taxonomy",e,f)},[f]);return[o?y:{name:(0,s.__)("Primary Term","tenup"),link:"#"},d]};module.exports=r}(); //# sourceMappingURL=index.js.map