@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 23 kB
Source Map (JSON)
{"version":3,"file":"utils.cjs","names":["decodeEntities","useSelect","coreStore","useMemo","__","blocksStore","cloneBlock","blockEditorStore"],"sources":["../../src/query/utils.js"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n/** @typedef {import('@wordpress/components/build-types/query-controls/types').OrderByOption} OrderByOption */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of entities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n * 3. A helper map with post format support per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) {\n\t\t\treturn;\n\t\t}\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\tconst postTypeFormatSupportMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] =\n\t\t\t\ttype.supports?.[ 'post-formats' ] || false;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\treturn {\n\t\tpostTypesTaxonomiesMap,\n\t\tpostTypesSelectOptions,\n\t\tpostTypeFormatSupportMap,\n\t};\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies, getPostType } = select( coreStore );\n\t\t\t// Does the post type have taxonomies?\n\t\t\tif ( getPostType( postType )?.taxonomies?.length > 0 ) {\n\t\t\t\treturn getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn [];\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => !! visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * List of available options to order by.\n *\n * @param {string} postType The post type to check.\n * @return {OrderByOption[]} List of order options.\n */\nexport function useOrderByOptions( postType ) {\n\tconst supportsCustomOrder = useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn !! type?.supports?.[ 'page-attributes' ];\n\t\t},\n\t\t[ postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst orderByOptions = [\n\t\t\t{\n\t\t\t\tlabel: __( 'Newest to oldest' ),\n\t\t\t\tvalue: 'date/desc',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: __( 'Oldest to newest' ),\n\t\t\t\tvalue: 'date/asc',\n\t\t\t},\n\t\t\t{\n\t\t\t\t/* translators: Label for ordering posts by title in ascending order. */\n\t\t\t\tlabel: __( 'A → Z' ),\n\t\t\t\tvalue: 'title/asc',\n\t\t\t},\n\t\t\t{\n\t\t\t\t/* translators: Label for ordering posts by title in descending order. */\n\t\t\t\tlabel: __( 'Z → A' ),\n\t\t\t\tvalue: 'title/desc',\n\t\t\t},\n\t\t];\n\n\t\tif ( supportsCustomOrder ) {\n\t\t\torderByOptions.push(\n\t\t\t\t{\n\t\t\t\t\t/* translators: Label for ordering posts by ascending menu order. */\n\t\t\t\t\tlabel: __( 'Ascending by order' ),\n\t\t\t\t\tvalue: 'menu_order/asc',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t/* translators: Label for ordering posts by descending menu order. */\n\t\t\t\t\tlabel: __( 'Descending by order' ),\n\t\t\t\t\tvalue: 'menu_order/desc',\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn orderByOptions;\n\t}, [ supportsCustomOrder ] );\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t\tnamespace,\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tif ( namespace ) {\n\t\t\t\tblock.attributes.namespace = namespace;\n\t\t\t}\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst activeVariationName = select(\n\t\t\t\tblocksStore\n\t\t\t).getActiveBlockVariation( 'core/query', attributes )?.name;\n\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn 'core/query';\n\t\t\t}\n\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\t`core/query/${ activeVariationName }`,\n\t\t\t\trootClientId\n\t\t\t);\n\n\t\t\treturn activePatterns.length > 0\n\t\t\t\t? `core/query/${ activeVariationName }`\n\t\t\t\t: 'core/query';\n\t\t},\n\t\t[ clientId, attributes ]\n\t);\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that, given a block clientId, returns the titles of the unsupported\n * blocks it contains, without duplicates.\n *\n * @param {string} clientId The block's client ID.\n * @return {string[]} The titles of the unsupported blocks.\n */\nexport const useUnsupportedBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockSupport, getBlockType } = select( blocksStore );\n\t\t\tconst blockTitles = new Set();\n\t\t\tgetClientIdsOfDescendants( clientId ).forEach(\n\t\t\t\t( descendantClientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( descendantClientId );\n\t\t\t\t\t/*\n\t\t\t\t\t * Client side navigation can be true in two states:\n\t\t\t\t\t * - supports.interactivity = true;\n\t\t\t\t\t * - supports.interactivity.clientNavigation = true;\n\t\t\t\t\t */\n\t\t\t\t\tconst blockSupportsInteractivity = Object.is(\n\t\t\t\t\t\tgetBlockSupport( blockName, 'interactivity' ),\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t\tconst blockSupportsInteractivityClientNavigation =\n\t\t\t\t\t\tgetBlockSupport(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\t'interactivity.clientNavigation'\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! blockSupportsInteractivity &&\n\t\t\t\t\t\t! blockSupportsInteractivityClientNavigation\n\t\t\t\t\t) {\n\t\t\t\t\t\tblockTitles.add(\n\t\t\t\t\t\t\tgetBlockType( blockName )?.title || blockName\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn [ ...blockTitles ];\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n\n/**\n * Helper function that returns the query context from the editor based on the\n * available template slug.\n *\n * @param {string} templateSlug Current template slug based on context.\n * @return {Object} An object with isSingular and templateType properties.\n */\nexport function getQueryContextFromTemplate( templateSlug ) {\n\t// In the Post Editor, the template slug is not available.\n\tif ( ! templateSlug ) {\n\t\treturn { isSingular: true };\n\t}\n\tlet isSingular = false;\n\tlet templateType = templateSlug === 'wp' ? 'custom' : templateSlug;\n\tconst singularTemplates = [ '404', 'blank', 'single', 'page', 'custom' ];\n\tconst templateTypeFromSlug = templateSlug.includes( '-' )\n\t\t? templateSlug.split( '-', 1 )[ 0 ]\n\t\t: templateSlug;\n\tconst queryFromTemplateSlug = templateSlug.includes( '-' )\n\t\t? templateSlug.split( '-' ).slice( 1 ).join( '-' )\n\t\t: '';\n\tif ( queryFromTemplateSlug ) {\n\t\ttemplateType = templateTypeFromSlug;\n\t}\n\tisSingular = singularTemplates.includes( templateType );\n\n\treturn { isSingular, templateType };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,mBAAoB,aAAc;CAW9C,OAAO;EACN;EACA,GAZe,UAAU,QACvB,aAAa,WAAY;GAC1B,MAAM,EAAE,SAAS,WAAW,UAAU;GACtC,QAAS,OAAO,MAAO;GACvB,UAAW,OAAO,QAAS;GAC3B,MAAM,KAAM,OAAO,IAAK;GACxB,OAAO;EACR,GACA;GAAE,SAAS,CAAC;GAAG,WAAW,CAAC;GAAG,OAAO,CAAC;EAAE,CACzC;CAIA;AACD;;;;;;;;;;AAWA,MAAa,0BAA2B,QAAQ,SAAU;CACzD,MAAM,iBAAiB,KAAK,MAAO,GAAI;CACvC,IAAI,QAAQ;CACZ,eAAe,SAAW,cAAe;EACxC,QAAQ,QAAS;CAClB,CAAE;CACF,OAAO;AACR;;;;;;;;;;AAWA,MAAa,sBAAuB,UAAU,SAAU;CACvD,QAAS,YAAY,CAAC,EAAA,CAAI,KAAO,YAAc;EAC9C,GAAG;EACH,OAAA,GAAMA,yBAAAA,eAAAA,CAAgB,uBAAwB,QAAQ,IAAK,CAAE;CAC9D,EAAI;AACL;;;;;;;;;AAUA,MAAa,qBAAqB;CACjC,MAAM,aAAA,GAAYC,gBAAAA,UAAAA,EAAa,WAAY;EAC1C,MAAM,EAAE,iBAAiB,OAAQC,qBAAAA,KAAU;EAC3C,MAAM,oBAAoB,CAAE,YAAa;EAKzC,OAJ0B,aAAc,EAAE,UAAU,GAAG,CAAE,CAAC,EAAE,QACzD,EAAE,UAAU,WACb,YAAY,CAAE,kBAAkB,SAAU,IAAK,CACjD;CAED,GAAG,CAAC,CAAE;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