@wordpress/block-library 7.14.2 → 7.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/build/comments-pagination-next/index.js +1 -1
  2. package/build/comments-pagination-numbers/index.js +1 -1
  3. package/build/comments-pagination-previous/index.js +1 -1
  4. package/build/gallery/deprecated.js +4 -4
  5. package/build/gallery/deprecated.js.map +1 -1
  6. package/build/navigation/edit/index.js +12 -12
  7. package/build/navigation/edit/index.js.map +1 -1
  8. package/build/navigation/menu-items-to-blocks.js +16 -6
  9. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  10. package/build/post-content/edit.js +6 -1
  11. package/build/post-content/edit.js.map +1 -1
  12. package/build/post-featured-image/index.js +1 -1
  13. package/build/post-featured-image/overlay.js +2 -2
  14. package/build/post-featured-image/overlay.js.map +1 -1
  15. package/build/post-template/edit.js +13 -28
  16. package/build/post-template/edit.js.map +1 -1
  17. package/build/query/edit/inspector-controls/index.js +1 -1
  18. package/build/query/edit/inspector-controls/index.js.map +1 -1
  19. package/build/query/utils.js +1 -1
  20. package/build/query/utils.js.map +1 -1
  21. package/build/quote/index.js +0 -1
  22. package/build/quote/index.js.map +1 -1
  23. package/build/quote/transforms.js +2 -2
  24. package/build/quote/transforms.js.map +1 -1
  25. package/build/template-part/edit/index.js +2 -2
  26. package/build/template-part/edit/index.js.map +1 -1
  27. package/build/template-part/index.js +2 -2
  28. package/build/template-part/index.js.map +1 -1
  29. package/build-module/comments-pagination-next/index.js +1 -1
  30. package/build-module/comments-pagination-numbers/index.js +1 -1
  31. package/build-module/comments-pagination-previous/index.js +1 -1
  32. package/build-module/gallery/deprecated.js +4 -4
  33. package/build-module/gallery/deprecated.js.map +1 -1
  34. package/build-module/navigation/edit/index.js +12 -12
  35. package/build-module/navigation/edit/index.js.map +1 -1
  36. package/build-module/navigation/menu-items-to-blocks.js +16 -6
  37. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  38. package/build-module/post-content/edit.js +6 -1
  39. package/build-module/post-content/edit.js.map +1 -1
  40. package/build-module/post-featured-image/index.js +1 -1
  41. package/build-module/post-featured-image/overlay.js +2 -2
  42. package/build-module/post-featured-image/overlay.js.map +1 -1
  43. package/build-module/post-template/edit.js +14 -29
  44. package/build-module/post-template/edit.js.map +1 -1
  45. package/build-module/query/edit/inspector-controls/index.js +1 -1
  46. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  47. package/build-module/query/utils.js +1 -1
  48. package/build-module/query/utils.js.map +1 -1
  49. package/build-module/quote/index.js +0 -1
  50. package/build-module/quote/index.js.map +1 -1
  51. package/build-module/quote/transforms.js +2 -2
  52. package/build-module/quote/transforms.js.map +1 -1
  53. package/build-module/template-part/edit/index.js +3 -3
  54. package/build-module/template-part/edit/index.js.map +1 -1
  55. package/build-module/template-part/index.js +2 -2
  56. package/build-module/template-part/index.js.map +1 -1
  57. package/build-style/classic-rtl.css +85 -0
  58. package/build-style/classic.css +85 -0
  59. package/build-style/code/style-rtl.css +3 -0
  60. package/build-style/code/style.css +3 -0
  61. package/build-style/editor-rtl.css +39 -29
  62. package/build-style/editor.css +39 -29
  63. package/build-style/post-featured-image/editor-rtl.css +39 -29
  64. package/build-style/post-featured-image/editor.css +39 -29
  65. package/build-style/style-rtl.css +3 -0
  66. package/build-style/style.css +3 -0
  67. package/package.json +12 -12
  68. package/src/classic.scss +15 -0
  69. package/src/code/style.scss +12 -7
  70. package/src/comment-template/index.php +18 -8
  71. package/src/comments-pagination-next/block.json +1 -1
  72. package/src/comments-pagination-numbers/block.json +1 -1
  73. package/src/comments-pagination-previous/block.json +1 -1
  74. package/src/gallery/deprecated.js +4 -4
  75. package/src/navigation/edit/index.js +12 -10
  76. package/src/navigation/menu-items-to-blocks.js +39 -22
  77. package/src/navigation/test/menu-items-to-blocks.js +6 -0
  78. package/src/navigation-submenu/index.php +10 -1
  79. package/src/post-content/edit.js +3 -1
  80. package/src/post-featured-image/block.json +1 -1
  81. package/src/post-featured-image/editor.scss +79 -72
  82. package/src/post-featured-image/index.php +18 -24
  83. package/src/post-featured-image/overlay.js +17 -14
  84. package/src/post-template/edit.js +14 -23
  85. package/src/query/edit/inspector-controls/index.js +1 -4
  86. package/src/query/utils.js +1 -1
  87. package/src/quote/block.json +0 -1
  88. package/src/quote/transforms.js +1 -1
  89. package/src/template-part/edit/index.js +60 -58
  90. package/src/template-part/index.js +2 -2
@@ -33,11 +33,13 @@ function menuItemsToBlocks(menuItems) {
33
33
  * A recursive function that maps menu item nodes to blocks.
34
34
  *
35
35
  * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.
36
+ * @param {number} level An integer representing the nesting level.
36
37
  * @return {Object} Object containing innerBlocks and mapping.
37
38
  */
38
39
 
39
40
 
40
41
  function mapMenuItemsToBlocks(menuItems) {
42
+ let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
41
43
  let mapping = {}; // The menuItem should be in menu_order sort order.
42
44
 
43
45
  const sortedItems = [...menuItems].sort((a, b) => a.menu_order - b.menu_order);
@@ -56,19 +58,19 @@ function mapMenuItemsToBlocks(menuItems) {
56
58
  return block;
57
59
  }
58
60
 
59
- const attributes = menuItemToBlockAttributes(menuItem); // If there are children recurse to build those nested blocks.
61
+ const blockType = (_menuItem$children = menuItem.children) !== null && _menuItem$children !== void 0 && _menuItem$children.length ? 'core/navigation-submenu' : 'core/navigation-link';
62
+ const attributes = menuItemToBlockAttributes(menuItem, blockType, level); // If there are children recurse to build those nested blocks.
60
63
 
61
64
  const {
62
65
  innerBlocks: nestedBlocks = [],
63
66
  // alias to avoid shadowing
64
67
  mapping: nestedMapping = {} // alias to avoid shadowing
65
68
 
66
- } = (_menuItem$children = menuItem.children) !== null && _menuItem$children !== void 0 && _menuItem$children.length ? mapMenuItemsToBlocks(menuItem.children) : {}; // Update parent mapping with nested mapping.
69
+ } = (_menuItem$children2 = menuItem.children) !== null && _menuItem$children2 !== void 0 && _menuItem$children2.length ? mapMenuItemsToBlocks(menuItem.children, level + 1) : {}; // Update parent mapping with nested mapping.
67
70
 
68
71
  mapping = { ...mapping,
69
72
  ...nestedMapping
70
- };
71
- const blockType = (_menuItem$children2 = menuItem.children) !== null && _menuItem$children2 !== void 0 && _menuItem$children2.length ? 'core/navigation-submenu' : 'core/navigation-link'; // Create block with nested "innerBlocks".
73
+ }; // Create block with nested "innerBlocks".
72
74
 
73
75
  const block = (0, _blocks.createBlock)(blockType, attributes, nestedBlocks); // Create mapping for menuItem -> block.
74
76
 
@@ -104,12 +106,14 @@ function mapMenuItemsToBlocks(menuItems) {
104
106
  /**
105
107
  * Convert block attributes to menu item.
106
108
  *
107
- * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
109
+ * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
110
+ * @param {string} blockType The block type.
111
+ * @param {number} level An integer representing the nesting level.
108
112
  * @return {Object} the block attributes converted from the WPNavMenuItem item.
109
113
  */
110
114
 
111
115
 
112
- function menuItemToBlockAttributes(_ref) {
116
+ function menuItemToBlockAttributes(_ref, blockType, level) {
113
117
  var _object;
114
118
 
115
119
  let {
@@ -163,6 +167,12 @@ function menuItemToBlockAttributes(_ref) {
163
167
  }),
164
168
  ...(target === '_blank' && {
165
169
  opensInNewTab: true
170
+ }),
171
+ ...(blockType === 'core/navigation-submenu' && {
172
+ isTopLevelItem: level === 0
173
+ }),
174
+ ...(blockType === 'core/navigation-link' && {
175
+ isTopLevelLink: level === 0
166
176
  })
167
177
  };
168
178
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/menu-items-to-blocks.js"],"names":["menuItemsToBlocks","menuItems","menuTree","createDataTree","blocks","mapMenuItemsToBlocks","mapping","sortedItems","sort","a","b","menu_order","innerBlocks","map","menuItem","type","block","content","raw","attributes","menuItemToBlockAttributes","nestedBlocks","nestedMapping","children","length","blockType","id","clientId","title","menuItemTitleField","xfn","classes","attr_title","object","object_id","description","url","menuItemTypeField","target","label","rendered","kind","replace","join","trim","rel","className","opensInNewTab","dataset","relation","hashTable","Object","create","dataTree","data","push"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAT,CAA4BC,SAA5B,EAAwC;AACtD,MAAK,CAAEA,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMC,QAAQ,GAAGC,cAAc,CAAEF,SAAF,CAA/B;AACA,QAAMG,MAAM,GAAGC,oBAAoB,CAAEH,QAAF,CAAnC;AACA,SAAO,yBACN,+CADM,EAENE,MAFM,EAGNH,SAHM,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,oBAAT,CAA+BJ,SAA/B,EAA2C;AAC1C,MAAIK,OAAO,GAAG,EAAd,CAD0C,CAG1C;;AACA,QAAMC,WAAW,GAAG,CAAE,GAAGN,SAAL,EAAiBO,IAAjB,CACnB,CAAEC,CAAF,EAAKC,CAAL,KAAYD,CAAC,CAACE,UAAF,GAAeD,CAAC,CAACC,UADV,CAApB;AAIA,QAAMC,WAAW,GAAGL,WAAW,CAACM,GAAZ,CAAmBC,QAAF,IAAgB;AAAA;;AACpD,QAAKA,QAAQ,CAACC,IAAT,KAAkB,OAAvB,EAAiC;AAChC,YAAM,CAAEC,KAAF,IAAY,mBAAOF,QAAQ,CAACG,OAAT,CAAiBC,GAAxB,CAAlB;;AAEA,UAAK,CAAEF,KAAP,EAAe;AACd,eAAO,yBAAa,eAAb,EAA8B;AACpCC,UAAAA,OAAO,EAAEH,QAAQ,CAACG;AADkB,SAA9B,CAAP;AAGA;;AAED,aAAOD,KAAP;AACA;;AAED,UAAMG,UAAU,GAAGC,yBAAyB,CAAEN,QAAF,CAA5C,CAboD,CAepD;;AACA,UAAM;AACLF,MAAAA,WAAW,EAAES,YAAY,GAAG,EADvB;AAC2B;AAChCf,MAAAA,OAAO,EAAEgB,aAAa,GAAG,EAFpB,CAEwB;;AAFx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BM,GAAP;AA+BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS5C,cAAT,CAAyB6C,OAAzB,EAAmE;AAAA,MAAjCtB,EAAiC,uEAA5B,IAA4B;AAAA,MAAtBuB,QAAsB,uEAAX,QAAW;AAClE,QAAMC,SAAS,GAAGC,MAAM,CAACC,MAAP,CAAe,IAAf,CAAlB;AACA,QAAMC,QAAQ,GAAG,EAAjB;;AAEA,OAAM,MAAMC,IAAZ,IAAoBN,OAApB,EAA8B;AAC7BE,IAAAA,SAAS,CAAEI,IAAI,CAAE5B,EAAF,CAAN,CAAT,GAA0B,EACzB,GAAG4B,IADsB;AAEzB/B,MAAAA,QAAQ,EAAE;AAFe,KAA1B;;AAIA,QAAK+B,IAAI,CAAEL,QAAF,CAAT,EAAwB;AACvBC,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,GAAgCC,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,IAAiC,EAAjE;AACAC,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B1B,QAA9B,GACC2B,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B1B,QAA9B,IAA0C,EAD3C;AAEA2B,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B1B,QAA9B,CAAuCgC,IAAvC,CACCL,SAAS,CAAEI,IAAI,CAAE5B,EAAF,CAAN,CADV;AAGA,KAPD,MAOO;AACN2B,MAAAA,QAAQ,CAACE,IAAT,CAAeL,SAAS,CAAEI,IAAI,CAAE5B,EAAF,CAAN,CAAxB;AACA;AACD;;AAED,SAAO2B,QAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, parse } from '@wordpress/blocks';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Convert a flat menu item structure to a nested blocks structure.\n *\n * @param {Object[]} menuItems An array of menu items.\n *\n * @return {WPBlock[]} An array of blocks.\n */\nexport default function menuItemsToBlocks( menuItems ) {\n\tif ( ! menuItems ) {\n\t\treturn null;\n\t}\n\n\tconst menuTree = createDataTree( menuItems );\n\tconst blocks = mapMenuItemsToBlocks( menuTree );\n\treturn applyFilters(\n\t\t'blocks.navigation.__unstableMenuItemsToBlocks',\n\t\tblocks,\n\t\tmenuItems\n\t);\n}\n\n/**\n * A recursive function that maps menu item nodes to blocks.\n *\n * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.\n * @return {Object} Object containing innerBlocks and mapping.\n */\nfunction mapMenuItemsToBlocks( menuItems ) {\n\tlet mapping = {};\n\n\t// The menuItem should be in menu_order sort order.\n\tconst sortedItems = [ ...menuItems ].sort(\n\t\t( a, b ) => a.menu_order - b.menu_order\n\t);\n\n\tconst innerBlocks = sortedItems.map( ( menuItem ) => {\n\t\tif ( menuItem.type === 'block' ) {\n\t\t\tconst [ block ] = parse( menuItem.content.raw );\n\n\t\t\tif ( ! block ) {\n\t\t\t\treturn createBlock( 'core/freeform', {\n\t\t\t\t\tcontent: menuItem.content,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn block;\n\t\t}\n\n\t\tconst attributes = menuItemToBlockAttributes( menuItem );\n\n\t\t// If there are children recurse to build those nested blocks.\n\t\tconst {\n\t\t\tinnerBlocks: nestedBlocks = [], // alias to avoid shadowing\n\t\t\tmapping: nestedMapping = {}, // alias to avoid shadowing\n\t\t} = menuItem.children?.length\n\t\t\t? mapMenuItemsToBlocks( menuItem.children )\n\t\t\t: {};\n\n\t\t// Update parent mapping with nested mapping.\n\t\tmapping = {\n\t\t\t...mapping,\n\t\t\t...nestedMapping,\n\t\t};\n\n\t\tconst blockType = menuItem.children?.length\n\t\t\t? 'core/navigation-submenu'\n\t\t\t: 'core/navigation-link';\n\n\t\t// Create block with nested \"innerBlocks\".\n\t\tconst block = createBlock( blockType, attributes, nestedBlocks );\n\n\t\t// Create mapping for menuItem -> block.\n\t\tmapping[ menuItem.id ] = block.clientId;\n\n\t\treturn block;\n\t} );\n\n\treturn {\n\t\tinnerBlocks,\n\t\tmapping,\n\t};\n}\n\n/**\n * A WP nav_menu_item object.\n * For more documentation on the individual fields present on a menu item please see:\n * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789\n *\n * Changes made here should also be mirrored in packages/edit-navigation/src/store/utils.js.\n *\n * @typedef WPNavMenuItem\n *\n * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.\n * @property {Array} xfn the XFN relationships expressed in the link of this menu item.\n * @property {Array} classes the HTML class attributes for this menu item.\n * @property {string} attr_title the HTML title attribute for this menu item.\n * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.\n * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.\n * @property {string} description The description of this menu item.\n * @property {string} url The URL to which this menu item points.\n * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.\n * @property {string} target The target attribute of the link element for this menu item.\n */\n\n/**\n * Convert block attributes to menu item.\n *\n * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.\n * @return {Object} the block attributes converted from the WPNavMenuItem item.\n */\nfunction menuItemToBlockAttributes( {\n\ttitle: menuItemTitleField,\n\txfn,\n\tclasses,\n\t// eslint-disable-next-line camelcase\n\tattr_title,\n\tobject,\n\t// eslint-disable-next-line camelcase\n\tobject_id,\n\tdescription,\n\turl,\n\ttype: menuItemTypeField,\n\ttarget,\n} ) {\n\t// For historical reasons, the `core/navigation-link` variation type is `tag`\n\t// whereas WP Core expects `post_tag` as the `object` type.\n\t// To avoid writing a block migration we perform a conversion here.\n\t// See also inverse equivalent in `blockAttributesToMenuItem`.\n\tif ( object && object === 'post_tag' ) {\n\t\tobject = 'tag';\n\t}\n\n\treturn {\n\t\tlabel: menuItemTitleField?.rendered || '',\n\t\t...( object?.length && {\n\t\t\ttype: object,\n\t\t} ),\n\t\tkind: menuItemTypeField?.replace( '_', '-' ) || 'custom',\n\t\turl: url || '',\n\t\t...( xfn?.length &&\n\t\t\txfn.join( ' ' ).trim() && {\n\t\t\t\trel: xfn.join( ' ' ).trim(),\n\t\t\t} ),\n\t\t...( classes?.length &&\n\t\t\tclasses.join( ' ' ).trim() && {\n\t\t\t\tclassName: classes.join( ' ' ).trim(),\n\t\t\t} ),\n\t\t/* eslint-disable camelcase */\n\t\t...( attr_title?.length && {\n\t\t\ttitle: attr_title,\n\t\t} ),\n\t\t...( object_id &&\n\t\t\t'custom' !== object && {\n\t\t\t\tid: object_id,\n\t\t\t} ),\n\t\t/* eslint-enable camelcase */\n\t\t...( description?.length && {\n\t\t\tdescription,\n\t\t} ),\n\t\t...( target === '_blank' && {\n\t\t\topensInNewTab: true,\n\t\t} ),\n\t};\n}\n\n/**\n * Creates a nested, hierarchical tree representation from unstructured data that\n * has an inherent relationship defined between individual items.\n *\n * For example, by default, each element in the dataset should have an `id` and\n * `parent` property where the `parent` property indicates a relationship between\n * the current item and another item with a matching `id` properties.\n *\n * This is useful for building linked lists of data from flat data structures.\n *\n * @param {Array} dataset linked data to be rearranged into a hierarchical tree based on relational fields.\n * @param {string} id the property which uniquely identifies each entry within the array.\n * @param {*} relation the property which identifies how the current item is related to other items in the data (if at all).\n * @return {Array} a nested array of parent/child relationships\n */\nfunction createDataTree( dataset, id = 'id', relation = 'parent' ) {\n\tconst hashTable = Object.create( null );\n\tconst dataTree = [];\n\n\tfor ( const data of dataset ) {\n\t\thashTable[ data[ id ] ] = {\n\t\t\t...data,\n\t\t\tchildren: [],\n\t\t};\n\t\tif ( data[ relation ] ) {\n\t\t\thashTable[ data[ relation ] ] = hashTable[ data[ relation ] ] || {};\n\t\t\thashTable[ data[ relation ] ].children =\n\t\t\t\thashTable[ data[ relation ] ].children || [];\n\t\t\thashTable[ data[ relation ] ].children.push(\n\t\t\t\thashTable[ data[ id ] ]\n\t\t\t);\n\t\t} else {\n\t\t\tdataTree.push( hashTable[ data[ id ] ] );\n\t\t}\n\t}\n\n\treturn dataTree;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/menu-items-to-blocks.js"],"names":["menuItemsToBlocks","menuItems","menuTree","createDataTree","blocks","mapMenuItemsToBlocks","level","mapping","sortedItems","sort","a","b","menu_order","innerBlocks","map","menuItem","type","block","content","raw","blockType","children","length","attributes","menuItemToBlockAttributes","nestedBlocks","nestedMapping","id","clientId","title","menuItemTitleField","xfn","classes","attr_title","object","object_id","description","url","menuItemTypeField","target","label","rendered","kind","replace","join","trim","rel","className","opensInNewTab","isTopLevelItem","isTopLevelLink","dataset","relation","hashTable","Object","create","dataTree","data","push"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAT,CAA4BC,SAA5B,EAAwC;AACtD,MAAK,CAAEA,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMC,QAAQ,GAAGC,cAAc,CAAEF,SAAF,CAA/B;AACA,QAAMG,MAAM,GAAGC,oBAAoB,CAAEH,QAAF,CAAnC;AACA,SAAO,yBACN,+CADM,EAENE,MAFM,EAGNH,SAHM,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,oBAAT,CAA+BJ,SAA/B,EAAsD;AAAA,MAAZK,KAAY,uEAAJ,CAAI;AACrD,MAAIC,OAAO,GAAG,EAAd,CADqD,CAGrD;;AACA,QAAMC,WAAW,GAAG,CAAE,GAAGP,SAAL,EAAiBQ,IAAjB,CACnB,CAAEC,CAAF,EAAKC,CAAL,KAAYD,CAAC,CAACE,UAAF,GAAeD,CAAC,CAACC,UADV,CAApB;AAIA,QAAMC,WAAW,GAAGL,WAAW,CAACM,GAAZ,CAAmBC,QAAF,IAAgB;AAAA;;AACpD,QAAKA,QAAQ,CAACC,IAAT,KAAkB,OAAvB,EAAiC;AAChC,YAAM,CAAEC,KAAF,IAAY,m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C,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,GAAgCC,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,IAAiC,EAAjE;AACAC,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B/B,QAA9B,GACCgC,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B/B,QAA9B,IAA0C,EAD3C;AAEAgC,MAAAA,SAAS,CAAEI,IAAI,CAAEL,QAAF,CAAN,CAAT,CAA8B/B,QAA9B,CAAuCqC,IAAvC,CACCL,SAAS,CAAEI,IAAI,CAAE9B,EAAF,CAAN,CADV;AAGA,KAPD,MAOO;AACN6B,MAAAA,QAAQ,CAACE,IAAT,CAAeL,SAAS,CAAEI,IAAI,CAAE9B,EAAF,CAAN,CAAxB;AACA;AACD;;AAED,SAAO6B,QAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, parse } from '@wordpress/blocks';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Convert a flat menu item structure to a nested blocks structure.\n *\n * @param {Object[]} menuItems An array of menu items.\n *\n * @return {WPBlock[]} An array of blocks.\n */\nexport default function menuItemsToBlocks( menuItems ) {\n\tif ( ! menuItems ) {\n\t\treturn null;\n\t}\n\n\tconst menuTree = createDataTree( menuItems );\n\tconst blocks = mapMenuItemsToBlocks( menuTree );\n\treturn applyFilters(\n\t\t'blocks.navigation.__unstableMenuItemsToBlocks',\n\t\tblocks,\n\t\tmenuItems\n\t);\n}\n\n/**\n * A recursive function that maps menu item nodes to blocks.\n *\n * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.\n * @param {number} level An integer representing the nesting level.\n * @return {Object} Object containing innerBlocks and mapping.\n */\nfunction mapMenuItemsToBlocks( menuItems, level = 0 ) {\n\tlet mapping = {};\n\n\t// The menuItem should be in menu_order sort order.\n\tconst sortedItems = [ ...menuItems ].sort(\n\t\t( a, b ) => a.menu_order - b.menu_order\n\t);\n\n\tconst innerBlocks = sortedItems.map( ( menuItem ) => {\n\t\tif ( menuItem.type === 'block' ) {\n\t\t\tconst [ block ] = parse( menuItem.content.raw );\n\n\t\t\tif ( ! block ) {\n\t\t\t\treturn createBlock( 'core/freeform', {\n\t\t\t\t\tcontent: menuItem.content,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn block;\n\t\t}\n\n\t\tconst blockType = menuItem.children?.length\n\t\t\t? 'core/navigation-submenu'\n\t\t\t: 'core/navigation-link';\n\n\t\tconst attributes = menuItemToBlockAttributes(\n\t\t\tmenuItem,\n\t\t\tblockType,\n\t\t\tlevel\n\t\t);\n\n\t\t// If there are children recurse to build those nested blocks.\n\t\tconst {\n\t\t\tinnerBlocks: nestedBlocks = [], // alias to avoid shadowing\n\t\t\tmapping: nestedMapping = {}, // alias to avoid shadowing\n\t\t} = menuItem.children?.length\n\t\t\t? mapMenuItemsToBlocks( menuItem.children, level + 1 )\n\t\t\t: {};\n\n\t\t// Update parent mapping with nested mapping.\n\t\tmapping = {\n\t\t\t...mapping,\n\t\t\t...nestedMapping,\n\t\t};\n\n\t\t// Create block with nested \"innerBlocks\".\n\t\tconst block = createBlock( blockType, attributes, nestedBlocks );\n\n\t\t// Create mapping for menuItem -> block.\n\t\tmapping[ menuItem.id ] = block.clientId;\n\n\t\treturn block;\n\t} );\n\n\treturn {\n\t\tinnerBlocks,\n\t\tmapping,\n\t};\n}\n\n/**\n * A WP nav_menu_item object.\n * For more documentation on the individual fields present on a menu item please see:\n * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789\n *\n * Changes made here should also be mirrored in packages/edit-navigation/src/store/utils.js.\n *\n * @typedef WPNavMenuItem\n *\n * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.\n * @property {Array} xfn the XFN relationships expressed in the link of this menu item.\n * @property {Array} classes the HTML class attributes for this menu item.\n * @property {string} attr_title the HTML title attribute for this menu item.\n * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.\n * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.\n * @property {string} description The description of this menu item.\n * @property {string} url The URL to which this menu item points.\n * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.\n * @property {string} target The target attribute of the link element for this menu item.\n */\n\n/**\n * Convert block attributes to menu item.\n *\n * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.\n * @param {string} blockType The block type.\n * @param {number} level An integer representing the nesting level.\n * @return {Object} the block attributes converted from the WPNavMenuItem item.\n */\nfunction menuItemToBlockAttributes(\n\t{\n\t\ttitle: menuItemTitleField,\n\t\txfn,\n\t\tclasses,\n\t\t// eslint-disable-next-line camelcase\n\t\tattr_title,\n\t\tobject,\n\t\t// eslint-disable-next-line camelcase\n\t\tobject_id,\n\t\tdescription,\n\t\turl,\n\t\ttype: menuItemTypeField,\n\t\ttarget,\n\t},\n\tblockType,\n\tlevel\n) {\n\t// For historical reasons, the `core/navigation-link` variation type is `tag`\n\t// whereas WP Core expects `post_tag` as the `object` type.\n\t// To avoid writing a block migration we perform a conversion here.\n\t// See also inverse equivalent in `blockAttributesToMenuItem`.\n\tif ( object && object === 'post_tag' ) {\n\t\tobject = 'tag';\n\t}\n\n\treturn {\n\t\tlabel: menuItemTitleField?.rendered || '',\n\t\t...( object?.length && {\n\t\t\ttype: object,\n\t\t} ),\n\t\tkind: menuItemTypeField?.replace( '_', '-' ) || 'custom',\n\t\turl: url || '',\n\t\t...( xfn?.length &&\n\t\t\txfn.join( ' ' ).trim() && {\n\t\t\t\trel: xfn.join( ' ' ).trim(),\n\t\t\t} ),\n\t\t...( classes?.length &&\n\t\t\tclasses.join( ' ' ).trim() && {\n\t\t\t\tclassName: classes.join( ' ' ).trim(),\n\t\t\t} ),\n\t\t/* eslint-disable camelcase */\n\t\t...( attr_title?.length && {\n\t\t\ttitle: attr_title,\n\t\t} ),\n\t\t...( object_id &&\n\t\t\t'custom' !== object && {\n\t\t\t\tid: object_id,\n\t\t\t} ),\n\t\t/* eslint-enable camelcase */\n\t\t...( description?.length && {\n\t\t\tdescription,\n\t\t} ),\n\t\t...( target === '_blank' && {\n\t\t\topensInNewTab: true,\n\t\t} ),\n\t\t...( blockType === 'core/navigation-submenu' && {\n\t\t\tisTopLevelItem: level === 0,\n\t\t} ),\n\t\t...( blockType === 'core/navigation-link' && {\n\t\t\tisTopLevelLink: level === 0,\n\t\t} ),\n\t};\n}\n\n/**\n * Creates a nested, hierarchical tree representation from unstructured data that\n * has an inherent relationship defined between individual items.\n *\n * For example, by default, each element in the dataset should have an `id` and\n * `parent` property where the `parent` property indicates a relationship between\n * the current item and another item with a matching `id` properties.\n *\n * This is useful for building linked lists of data from flat data structures.\n *\n * @param {Array} dataset linked data to be rearranged into a hierarchical tree based on relational fields.\n * @param {string} id the property which uniquely identifies each entry within the array.\n * @param {*} relation the property which identifies how the current item is related to other items in the data (if at all).\n * @return {Array} a nested array of parent/child relationships\n */\nfunction createDataTree( dataset, id = 'id', relation = 'parent' ) {\n\tconst hashTable = Object.create( null );\n\tconst dataTree = [];\n\n\tfor ( const data of dataset ) {\n\t\thashTable[ data[ id ] ] = {\n\t\t\t...data,\n\t\t\tchildren: [],\n\t\t};\n\t\tif ( data[ relation ] ) {\n\t\t\thashTable[ data[ relation ] ] = hashTable[ data[ relation ] ] || {};\n\t\t\thashTable[ data[ relation ] ].children =\n\t\t\t\thashTable[ data[ relation ] ].children || [];\n\t\t\thashTable[ data[ relation ] ].children.push(\n\t\t\t\thashTable[ data[ id ] ]\n\t\t\t);\n\t\t} else {\n\t\t\tdataTree.push( hashTable[ data[ id ] ] );\n\t\t}\n\t}\n\n\treturn dataTree;\n}\n"]}
@@ -61,7 +61,12 @@ function EditableContent(_ref2) {
61
61
  return (_getSettings = getSettings()) === null || _getSettings === void 0 ? void 0 : _getSettings.supportsLayout;
62
62
  }, []);
63
63
  const defaultLayout = (0, _blockEditor.useSetting)('layout') || {};
64
- const usedLayout = !!layout && layout.inherit ? defaultLayout : layout;
64
+ const usedLayout = !(layout !== null && layout !== void 0 && layout.type) ? { ...defaultLayout,
65
+ ...layout,
66
+ type: 'default'
67
+ } : { ...defaultLayout,
68
+ ...layout
69
+ };
65
70
  const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', postType, {
66
71
  id: postId
67
72
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","inherit","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,M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n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","type","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAO,GAAG;AAApB,GAA2B;AACpD,QAAM;AAAET,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuBQ,OAA7B;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,2BAAOD,WAAW,EAAlB,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,WADf;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,MAAM,EAAGC;AAHV,IAHD;AASA;;AAED,SAASgC,WAAT,GAAuB;AACtB,QAAM9B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,uCACG,cACD,4FADC,CADH,CADD,EAMC,uCACG,cACD,mMADC,CADH,CAND,EAWC,uCACG,cACD,uIADC,CADH,CAXD,CADD;AAmBA;;AAED,SAAS+B,cAAT,GAA0B;AACzB,QAAM/B,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,oBAAD,QACG,cAAI,yCAAJ,CADH,CADD,CADD;AAOA;;AAEc,SAASgC,eAAT,QAAoD;AAAA,MAA1B;AAAE1B,IAAAA,OAAF;AAAW2B,IAAAA;AAAX,GAA0B;AAClE,QAAM;AAAEnC,IAAAA,MAAM,EAAEoC,aAAV;AAAyBrC,IAAAA,QAAQ,EAAEsC;AAAnC,MAAuD7B,OAA7D;AACA,QAAM;AAAED,IAAAA,MAAM,GAAG;AAAX,MAAkB4B,UAAxB;AACA,QAAMG,kBAAkB,GAAG,gDAAiBF,aAAjB,CAA3B;;AAEA,MAAKA,aAAa,IAAIC,eAAjB,IAAoCC,kBAAzC,EAA8D;AAC7D,WAAO,4BAAC,cAAD,OAAP;AACA;;AAED,SACC,4BAAC,4CAAD;AAAmB,IAAA,QAAQ,EAAGF;AAA9B,KACGA,aAAa,IAAIC,eAAjB,GACD,4BAAC,OAAD;AAAS,IAAA,OAAO,EAAG7B,OAAnB;AAA6B,IAAA,MAAM,EAAGD;AAAtC,IADC,GAGD,4BAAC,WAAD,OAJF,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
@@ -84,7 +84,7 @@ const metadata = {
84
84
  color: true,
85
85
  radius: true,
86
86
  width: true,
87
- __experimentalSelector: "img, .block-editor-media-placeholder",
87
+ __experimentalSelector: "img, .block-editor-media-placeholder, .wp-block-post-featured-image__overlay",
88
88
  __experimentalSkipSerialization: true,
89
89
  __experimentalDefaultControls: {
90
90
  color: true,
@@ -57,14 +57,14 @@ const Overlay = _ref => {
57
57
  backgroundImage: gradientValue,
58
58
  ...borderProps.style
59
59
  };
60
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("span", {
60
+ return (0, _element.createElement)(_element.Fragment, null, !!dimRatio && (0, _element.createElement)("span", {
61
61
  "aria-hidden": "true",
62
62
  className: (0, _classnames.default)('wp-block-post-featured-image__overlay', (0, _utils.dimRatioToClass)(dimRatio), {
63
63
  [overlayColor.class]: overlayColor.class,
64
64
  'has-background-dim': dimRatio !== undefined,
65
65
  'has-background-gradient': gradientValue,
66
66
  [gradientClass]: gradientClass
67
- }),
67
+ }, borderProps.className),
68
68
  style: overlayStyles
69
69
  }), (0, _element.createElement)(_blockEditor.InspectorControls, {
70
70
  __experimentalGroup: "color"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-featured-image/overlay.js"],"names":["Overlay","clientId","attributes","setAttributes","overlayColor","setOverlayColor","dimRatio","gradientClass","gradientValue","setGradient","colorGradientSettings","borderProps","overlayStyles","backgroundColor","color","backgroundImage","style","class","undefined","colorValue","label","onColorChange","onGradientChange","isShownByDefault","resetAllFilter","customOverlayColor","gradient","customGradient","newDimRatio"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AAIA;;AAQA;;AACA;;AAKA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,OAAO,GAAG,QAMT;AAAA,MANW;AACjBC,IAAAA,QADiB;AAEjBC,IAAAA,UAFiB;AAGjBC,IAAAA,aAHiB;AAIjBC,IAAAA,YAJiB;AAKjBC,IAAAA;AALiB,GAMX;AACN,QAAM;AAAEC,IAAAA;AAAF,MAAeJ,UAArB;AACA,QAAM;AAAEK,IAAAA,aAAF;AAAiBC,IAAAA,aAAjB;AAAgCC,IAAAA;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AAQ,KAAKY,SAD/B;AAEC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMf,aAAa,CAAE;AAAEG,MAAAA,QAAQ,EAAE;AAAZ,KAAF,CAHjC;AAIC,IAAA,cAAc,EAAG,OAAQ;AACxBA,MAAAA,QAAQ,EAAE;AADc,KAAR,CAJlB;AAOC,IAAA,gBAAgB,MAPjB;AAQC,IAAA,OAAO,EAAGL;AARX,KAUC,4BAAC,wBAAD;AACC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CADT;AAEC,IAAA,KAAK,EAAGK,QAFT;AAGC,IAAA,QAAQ,EAAKsB,WAAF,IACVzB,aAAa,CAAE;AACdG,MAAAA,QAAQ,EAAEsB;AADI,KAAF,CAJf;AAQC,IAAA,GAAG,EAAG,CARP;AASC,IAAA,GAAG,EAAG,GATP;AAUC,IAAA,IAAI,EAAG,EAVR;AAWC,IAAA,QAAQ;AAXT,IAVD,CAvBD,CAfD,CADD;AAkEA,CArFD;;eAuFe,sBAAS,CACvB,6BAAY;AAAExB,EAAAA,YAAY,EAAE;AAAhB,CAAZ,CADuB,CAAT,EAEVJ,OAFU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\twithColors,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseGradient,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { dimRatioToClass } from './utils';\n\nconst Overlay = ( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\toverlayColor,\n\tsetOverlayColor,\n} ) => {\n\tconst { dimRatio } = attributes;\n\tconst { gradientClass, gradientValue, setGradient } =\n\t\t__experimentalUseGradient();\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst overlayStyles = {\n\t\tbackgroundColor: overlayColor.color,\n\t\tbackgroundImage: gradientValue,\n\t\t...borderProps.style,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'wp-block-post-featured-image__overlay',\n\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t{\n\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ overlayStyles }\n\t\t\t/>\n\t\t\t<InspectorControls __experimentalGroup=\"color\">\n\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolorValue: overlayColor.color,\n\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\tlabel: __( 'Overlay' ),\n\t\t\t\t\t\t\tonColorChange: setOverlayColor,\n\t\t\t\t\t\t\tonGradientChange: setGradient,\n\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\tresetAllFilter: () => ( {\n\t\t\t\t\t\t\t\toverlayColor: undefined,\n\t\t\t\t\t\t\t\tcustomOverlayColor: undefined,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\tcustomGradient: undefined,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t/>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => dimRatio !== undefined }\n\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\tonDeselect={ () => setAttributes( { dimRatio: 0 } ) }\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tdimRatio: 0,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ ( newDimRatio ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\tstep={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( Overlay );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-featured-image/overlay.js"],"names":["Overlay","clientId","attributes","setAttributes","overlayColor","setOverlayColor","dimRatio","gradientClass","gradientValue","setGradient","colorGradientSettings","borderProps","overlayStyles","backgroundColor","color","backgroundImage","style","class","undefined","className","colorValue","label","onColorChange","onGradientChange","isShownByDefault","resetAllFilter","customOverlayColor","gradient","customGradient","newDimRatio"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AAIA;;AAQA;;AACA;;AAKA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,OAAO,GAAG,QAMT;AAAA,M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AAE,OAAQ;AACvBrB,QAAAA,YAAY,EAAEc,SADS;AAEvBQ,QAAAA,kBAAkB,EAAER,SAFG;AAGvBS,QAAAA,QAAQ,EAAET,SAHa;AAIvBU,QAAAA,cAAc,EAAEV;AAJO,OAAR;AAPjB,KADU,CAHZ;AAmBC,IAAA,OAAO,EAAGjB;AAnBX,KAoBMS,qBApBN,EADD,EAuBC,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAMJ,QAAQ,KAAKY,SAD/B;AAEC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMf,aAAa,CAAE;AAAEG,MAAAA,QAAQ,EAAE;AAAZ,KAAF,CAHjC;AAIC,IAAA,cAAc,EAAG,OAAQ;AACxBA,MAAAA,QAAQ,EAAE;AADc,KAAR,CAJlB;AAOC,IAAA,gBAAgB,MAPjB;AAQC,IAAA,OAAO,EAAGL;AARX,KAUC,4BAAC,wBAAD;AACC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CADT;AAEC,IAAA,KAAK,EAAGK,QAFT;AAGC,IAAA,QAAQ,EAAKuB,WAAF,IACV1B,aAAa,CAAE;AACdG,MAAAA,QAAQ,EAAEuB;AADI,KAAF,CAJf;AAQC,IAAA,GAAG,EAAG,CARP;AASC,IAAA,GAAG,EAAG,GATP;AAUC,IAAA,IAAI,EAAG,EAVR;AAWC,IAAA,QAAQ;AAXT,IAVD,CAvBD,CAlBD,CADD;AAqEA,CAxFD;;eA0Fe,sBAAS,CACvB,6BAAY;AAAEzB,EAAAA,YAAY,EAAE;AAAhB,CAAZ,CADuB,CAAT,EAEVJ,OAFU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\twithColors,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseGradient,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { dimRatioToClass } from './utils';\n\nconst Overlay = ( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\toverlayColor,\n\tsetOverlayColor,\n} ) => {\n\tconst { dimRatio } = attributes;\n\tconst { gradientClass, gradientValue, setGradient } =\n\t\t__experimentalUseGradient();\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst overlayStyles = {\n\t\tbackgroundColor: overlayColor.color,\n\t\tbackgroundImage: gradientValue,\n\t\t...borderProps.style,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ !! dimRatio && (\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'wp-block-post-featured-image__overlay',\n\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tborderProps.className\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ overlayStyles }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<InspectorControls __experimentalGroup=\"color\">\n\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolorValue: overlayColor.color,\n\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\tlabel: __( 'Overlay' ),\n\t\t\t\t\t\t\tonColorChange: setOverlayColor,\n\t\t\t\t\t\t\tonGradientChange: setGradient,\n\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\tresetAllFilter: () => ( {\n\t\t\t\t\t\t\t\toverlayColor: undefined,\n\t\t\t\t\t\t\t\tcustomOverlayColor: undefined,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\tcustomGradient: undefined,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t\t},\n\t\t\t\t\t] }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t/>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => dimRatio !== undefined }\n\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\tonDeselect={ () => setAttributes( { dimRatio: 0 } ) }\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tdimRatio: 0,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ ( newDimRatio ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\tstep={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( Overlay );\n"]}
@@ -114,21 +114,6 @@ function PostTemplateEdit(_ref2) {
114
114
  page
115
115
  }] = queryContext;
116
116
  const [activeBlockContextId, setActiveBlockContextId] = (0, _element.useState)();
117
- let categorySlug = null;
118
-
119
- if (templateSlug !== null && templateSlug !== void 0 && templateSlug.startsWith('category-')) {
120
- categorySlug = templateSlug.replace('category-', '');
121
- }
122
-
123
- const {
124
- records: categories,
125
- hasResolved: hasResolvedCategories
126
- } = (0, _coreData.useEntityRecords)('taxonomy', 'category', {
127
- context: 'view',
128
- per_page: -1,
129
- _fields: ['id'],
130
- slug: categorySlug
131
- });
132
117
  const {
133
118
  posts,
134
119
  blocks
@@ -145,13 +130,19 @@ function PostTemplateEdit(_ref2) {
145
130
  per_page: -1,
146
131
  context: 'view'
147
132
  });
133
+ const templateCategory = inherit && (templateSlug === null || templateSlug === void 0 ? void 0 : templateSlug.startsWith('category-')) && getEntityRecords('taxonomy', 'category', {
134
+ context: 'view',
135
+ per_page: 1,
136
+ _fields: ['id'],
137
+ slug: templateSlug.replace('category-', '')
138
+ });
148
139
  const query = {
149
140
  offset: perPage ? perPage * (page - 1) + offset : 0,
150
141
  order,
151
142
  orderby: orderBy
152
- };
143
+ }; // There is no need to build the taxQuery if we inherit.
153
144
 
154
- if (taxQuery) {
145
+ if (taxQuery && !inherit) {
155
146
  // We have to build the tax query for the REST API and use as
156
147
  // keys the taxonomies `rest_base` with the `term ids` as values.
157
148
  const builtTaxQuery = Object.entries(taxQuery).reduce((accumulator, _ref3) => {
@@ -208,16 +199,10 @@ function PostTemplateEdit(_ref2) {
208
199
  if (templateSlug !== null && templateSlug !== void 0 && templateSlug.startsWith('archive-')) {
209
200
  query.postType = templateSlug.replace('archive-', '');
210
201
  postType = query.postType;
211
- } else if (!!categorySlug && hasResolvedCategories) {
212
- query.taxQuery = {
213
- category: categories.map(_ref5 => {
214
- let {
215
- id
216
- } = _ref5;
217
- return id;
218
- })
219
- };
220
- taxQuery = query.taxQuery;
202
+ } else if (templateCategory) {
203
+ var _templateCategory$;
204
+
205
+ query.categories = (_templateCategory$ = templateCategory[0]) === null || _templateCategory$ === void 0 ? void 0 : _templateCategory$.id;
221
206
  }
222
207
  } // When we preview Query Loop blocks we should prefer the current
223
208
  // block's postType, which is passed through block context.
@@ -230,7 +215,7 @@ function PostTemplateEdit(_ref2) {
230
215
  }),
231
216
  blocks: getBlocks(clientId)
232
217
  };
233
- }, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents, restQueryArgs, previewPostType, categories, categorySlug, hasResolvedCategories]);
218
+ }, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents, restQueryArgs, previewPostType]);
234
219
  const blockContexts = (0, _element.useMemo)(() => posts === null || posts === void 0 ? void 0 : posts.map(post => ({
235
220
  postType: post.type,
236
221
  postId: post.id
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","pages","restQueryArgs","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","previewPostType","activeBlockContextId","categorySlug","startsWith","replace","records","categories","hasResolved","hasResolvedCategories","per_page","_fields","slug","posts","select","getEntityRecords","getTaxonomies","coreStore","getBlocks","blockEditorStore","taxonomies","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","rest_base","keys","length","assign","parent","category","map","id","usedPostType","blockContexts","post","postId","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAOA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAcA,MAAMA,QAAQ,GAAG,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aAAa,IACdA,aAAa,CAACH,GAAd,CAAqBQ,YAAF;AAAA;;AAAA,WAClB,4BAAC,iCAAD;AACC,MAAA,GAAG,EAAGA,YAAY,CAACH,MADpB;AAEC,MAAA,KAAK,EAAGG;AAFT,OAIGA,YAAY,CAACH,MAAb,MACAxC,oBAAoB,wBACrBsC,aAAa,CAAE,CAAF,CADQ,oDACrB,gBAAoBE,MADC,CADpB,IAGD,4BAAC,uBAAD,OAHC,GAIE,IARL,EASC,4BAAC,gCAAD;AACC,MAAA,MAAM,EAAG7E,MADV;AAEC,MAAA,cAAc,EAAGgF,YAAY,CAACH,MAF/B;AAGC,MAAA,uBAAuB,EAAG1E,uBAH3B;AAIC,MAAA,QAAQ,EACP6E,YAAY,CAACH,MAAb,MACExC,oBAAoB,yBACrBsC,aAAa,CAAE,CAAF,CADQ,qDACrB,iBAAoBE,MADC,CADtB;AALF,MATD,CADkB;AAAA,GAAnB,CAFF,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore, useEntityRecords } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t\tpreviewPostType,\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tlet categorySlug = null;\n\tif ( templateSlug?.startsWith( 'category-' ) ) {\n\t\tcategorySlug = templateSlug.replace( 'category-', '' );\n\t}\n\tconst { records: categories, hasResolved: hasResolvedCategories } =\n\t\tuseEntityRecords( 'taxonomy', 'category', {\n\t\t\tcontext: 'view',\n\t\t\tper_page: -1,\n\t\t\t_fields: [ 'id' ],\n\t\t\tslug: categorySlug,\n\t\t} );\n\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\tif ( taxQuery ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t} else if ( !! categorySlug && hasResolvedCategories ) {\n\t\t\t\t\tquery.taxQuery = {\n\t\t\t\t\t\tcategory: categories.map( ( { id } ) => id ),\n\t\t\t\t\t};\n\t\t\t\t\ttaxQuery = query.taxQuery;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || postType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t\tcategories,\n\t\t\tcategorySlug,\n\t\t\thasResolvedCategories,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","pages","restQueryArgs","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","previewPostType","activeBlockContextId","posts","select","getEntityRecords","getTaxonomies","coreStore","getBlocks","blockEditorStore","taxonomies","per_page","templateCategory","startsWith","_fields","slug","replace","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","rest_base","keys","length","assign","parent","categories","id","usedPostType","blockContexts","map","post","postId","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAOA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAcA,MAAMA,QAAQ,GAAG,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,gBAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,CAAjB;;AAMA,SAASC,uBAAT,GAAmC;AAClC,QAAMC,gBAAgB,GAAG,sCACxB;AAAEC,IAAAA,SAAS,EAAE;AAAb,GADwB,EAExB;AAAEC,IAAAA,QAAQ,EAAEJ;AAAZ,GAFwB,CAAzB;AAIA,SAAO,kCAASE,gBAAT,CAAP;AACA;;AAED,SAASG,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,MADkC;AAElCC,IAAAA,cAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,GAK/B;AACH,QAAMC,iBAAiB,GAAG,gDAAiB;AAC1CJ,IAAAA,M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K,MAAf,IAAyBC,OAAO,GAAG,CAAzD;AACA,QAAMwC,UAAU,GAAG,gCAAe;AACjC9E,IAAAA,SAAS,EAAE,yBAAY;AACtB,2BAAqB6E,aADC;AAEtB,OAAG,WAAWvC,OAAS,EAAvB,GAA4BuC;AAFN,KAAZ;AADsB,GAAf,CAAnB;;AAOA,MAAK,CAAEpC,KAAP,EAAe;AACd,WACC,iCAAQqC,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAErC,KAAK,CAAC0B,MAAb,EAAsB;AACrB,WAAO,iCAAQW,UAAR,OAAwB,cAAI,mBAAJ,CAAxB,CAAP;AACA,GAtIE,CAwIH;AACA;AACA;AACA;;;AACA,SACC,kCAASA,UAAT,EACGL,aAAa,IACdA,aAAa,CAACC,GAAd,CAAqBK,YAAF;AAAA;;AAAA,WAClB,4BAAC,iCAAD;AACC,MAAA,GAAG,EAAGA,YAAY,CAACH,MADpB;AAEC,MAAA,KAAK,EAAGG;AAFT,OAIGA,YAAY,CAACH,MAAb,MACApC,oBAAoB,wBACrBiC,aAAa,CAAE,CAAF,CADQ,oDACrB,gBAAoBG,MADC,CADpB,IAGD,4BAAC,uBAAD,OAHC,GAIE,IARL,EASC,4BAAC,gCAAD;AACC,MAAA,MAAM,EAAGzE,MADV;AAEC,MAAA,cAAc,EAAG4E,YAAY,CAACH,MAF/B;AAGC,MAAA,uBAAuB,EAAGtE,uBAH3B;AAIC,MAAA,QAAQ,EACPyE,YAAY,CAACH,MAAb,MACEpC,oBAAoB,yBACrBiC,aAAa,CAAE,CAAF,CADQ,qDACrB,iBAAoBG,MADC,CADtB;AALF,MATD,CADkB;AAAA,GAAnB,CAFF,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpages,\n\t\t\t// We gather extra query args to pass to the REST API call.\n\t\t\t// This way extenders of Query Loop can add their own query args,\n\t\t\t// and have accurate previews in the editor.\n\t\t\t// Noting though that these args should either be supported by the\n\t\t\t// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.\n\t\t\t...restQueryArgs\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t\tpreviewPostType,\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst templateCategory =\n\t\t\t\tinherit &&\n\t\t\t\ttemplateSlug?.startsWith( 'category-' ) &&\n\t\t\t\tgetEntityRecords( 'taxonomy', 'category', {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tper_page: 1,\n\t\t\t\t\t_fields: [ 'id' ],\n\t\t\t\t\tslug: templateSlug.replace( 'category-', '' ),\n\t\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\t// There is no need to build the taxQuery if we inherit.\n\t\t\tif ( taxQuery && ! inherit ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t} else if ( templateCategory ) {\n\t\t\t\t\tquery.categories = templateCategory[ 0 ]?.id;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || postType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, {\n\t\t\t\t\t...query,\n\t\t\t\t\t...restQueryArgs,\n\t\t\t\t} ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\trestQueryArgs,\n\t\t\tpreviewPostType,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
@@ -190,7 +190,7 @@ function QueryInspectorControls(_ref) {
190
190
  label: (0, _i18n.__)('Keyword'),
191
191
  value: querySearch,
192
192
  onChange: setQuerySearch
193
- })), isPostTypeHierarchical && !(0, _utils.isControlAllowed)(allowedControls, 'parents') && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
193
+ })), isPostTypeHierarchical && (0, _utils.isControlAllowed)(allowedControls, 'parents') && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
194
194
  hasValue: () => !!(parents !== null && parents !== void 0 && parents.length),
195
195
  label: (0, _i18n.__)('Parents'),
196
196
  onDeselect: () => setQuery({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["QueryInspectorControls","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomiesInfo","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","type","showOrderControl","showStickyControl","showSettings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AAC,sBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGJ,QAFZ;AAGC,IAAA,QAAQ,EAAGR;AAHZ,IAPD,CA9DH,CADD,CApEF,CADD;AAuJA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n} from '../../utils';\n\nexport default function QueryInspectorControls( {\n\tattributes,\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomiesInfo = useTaxonomiesInfo( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = displayLayout?.type === 'flex';\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\treturn (\n\t\t<>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called \"Post types\". By default there are a few different ones such as blog posts and pages, but plugins could add more.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'taxQuery' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'author' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'search' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isPostTypeHierarchical &&\n\t\t\t\t\t\t\t! isControlAllowed(\n\t\t\t\t\t\t\t\tallowedControls,\n\t\t\t\t\t\t\t\t'parents'\n\t\t\t\t\t\t\t) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { parents: [] } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["QueryInspectorControls","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomiesInfo","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","type","showOrderControl","showStickyControl","showSettingsPanel","value","columns","Math","max","values","some"],"mappings":";;;;;;;;;AAoBA;;AAjBA;;AAKA;;AAUA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAae,SAASA,sBAAT,OAIX;AAAA,MAJ4C;AAC/CC,IAAAA,UAD+C;AAE/CC,IAAAA,QAF+C;AAG/CC,IAAAA;AAH+C,GAI5C;AACH,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAA2BJ,UAAjC;AACA,QAAM;AACLK,IAAAA,KADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,MAAM,EAAEC,SAHH;AAILC,IAAAA,QAJK;AAKLC,IAAAA,MALK;AAMLC,IAAAA,OANK;AAOLC,IAAAA,QAPK;AAQLC,IAAAA;AARK,MASFV,KATJ;AAUA,QAAMW,eAAe,GAAG,+BAAoBd,UAApB,CAAxB;AACA,QAAM,CAAEe,UAAF,EAAcC,aAAd,IAAgC,uBAAUP,QAAQ,KAAK,MAAvB,CAAtC;AACA,QAAM;AAAEQ,IAAAA,sBAAF;AAA0BC,IAAAA;AAA1B,MAAqD,0BAA3D;AACA,QAAMC,cAAc,GAAG,yCAAmBV,QAAnB,CAAvB;AACA,QAAMW,sBAAsB,GAAG,sCAA2BX,QAA3B,CAA/B;AACA,0BAAW,MAAM;AAChBO,IAAAA,aAAa,CAAEP,QAAQ,KAAK,MAAf,CAAb;AACA,GAFD,EAEG,CAAEA,QAAF,CAFH;;AAGA,QAAMY,gBAAgB,GAAKC,QAAF,IAAgB;AACxC,UAAMC,WAAW,GAAG;AAAEd,MAAAA,QAAQ,EAAEa;AAAZ,KAApB,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AAF,eAAEA,OAAO,CAAEqB,MAAX,CADnB;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MACZjC,QAAQ,CAAE;AAAEY,MAAAA,OAAO,EAAE;AAAX,KAAF;AAJV,KAOC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGJ,QAFZ;AAGC,IAAA,QAAQ,EAAGR;AAHZ,IAPD,CA3DH,CADD,CApEF,CADD;AAoJA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n} from '../../utils';\n\nexport default function QueryInspectorControls( {\n\tattributes,\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomiesInfo = useTaxonomiesInfo( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = displayLayout?.type === 'flex';\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\treturn (\n\t\t<>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called \"Post types\". By default there are a few different ones such as blog posts and pages, but plugins could add more.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'taxQuery' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'author' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'search' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isPostTypeHierarchical &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'parents' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { parents: [] } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -272,7 +272,7 @@ function useAllowedControls(attributes) {
272
272
  return (0, _data.useSelect)(select => {
273
273
  var _select$getActiveBloc;
274
274
 
275
- return (_select$getActiveBloc = select(_blocks.store).getActiveBlockVariation(queryLoopName, attributes)) === null || _select$getActiveBloc === void 0 ? void 0 : _select$getActiveBloc.allowControls;
275
+ return (_select$getActiveBloc = select(_blocks.store).getActiveBlockVariation(queryLoopName, attributes)) === null || _select$getActiveBloc === void 0 ? void 0 : _select$getActiveBloc.allowedControls;
276
276
  }, [attributes]);
277
277
  }
278
278
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowControls","isControlAllowed","allowedControls","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMA,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,Q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A9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BtD,MAAF,IAAc;AACb,QAAK,CAAEoD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFxD,MAAM,CAAEyD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE3C,MAAzB,GAAkC0C,SAAlC,GAA8CtB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { 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 { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\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 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 enitities 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( get( 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 *\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 ) return;\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\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\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 } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn 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 * 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\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowControls,\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} = 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\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\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;;AAEA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uBAAtB,CACCC,aADD,EAECH,UAFD,CADD,2DACC,uBAGGnC,IAJJ;AAAA,GAD2B,EAO3B,CAAEmC,UAAF,CAP2B,CAA5B;AASA,QAAMwB,SAAS,GAAI,GAAGrB,aAAe,IAAIoB,mBAAqB,EAA9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BrD,MAAF,IAAc;AACb,QAAK,CAAEmD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFvD,MAAM,CAAEwD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE1C,MAAzB,GAAkCyC,SAAlC,GAA8CrB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { 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 { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\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 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 enitities 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( get( 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 *\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 ) return;\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\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\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 } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn 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 * 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\tqueryLoopName,\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} = 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\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\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
@@ -59,7 +59,6 @@ const metadata = {
59
59
  },
60
60
  supports: {
61
61
  anchor: true,
62
- __experimentalSlashInserter: true,
63
62
  __experimentalOnEnter: true,
64
63
  typography: {
65
64
  fontSize: true,