@wordpress/block-library 8.19.8 → 8.19.10

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 (49) hide show
  1. package/build/file/view.js +1 -1
  2. package/build/file/view.js.map +1 -1
  3. package/build/image/image.js +8 -2
  4. package/build/image/image.js.map +1 -1
  5. package/build/image/view.js +10 -20
  6. package/build/image/view.js.map +1 -1
  7. package/build/navigation/view.js +20 -5
  8. package/build/navigation/view.js.map +1 -1
  9. package/build/query/edit/enhanced-pagination-modal.js +4 -4
  10. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  11. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +9 -5
  12. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  13. package/build/query/utils.js +10 -8
  14. package/build/query/utils.js.map +1 -1
  15. package/build/term-description/index.js +0 -1
  16. package/build/term-description/index.js.map +1 -1
  17. package/build-module/file/view.js +2 -2
  18. package/build-module/file/view.js.map +1 -1
  19. package/build-module/image/image.js +8 -2
  20. package/build-module/image/image.js.map +1 -1
  21. package/build-module/image/view.js +10 -20
  22. package/build-module/image/view.js.map +1 -1
  23. package/build-module/navigation/view.js +20 -5
  24. package/build-module/navigation/view.js.map +1 -1
  25. package/build-module/query/edit/enhanced-pagination-modal.js +5 -5
  26. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  27. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +10 -6
  28. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  29. package/build-module/query/utils.js +8 -5
  30. package/build-module/query/utils.js.map +1 -1
  31. package/build-module/term-description/index.js +0 -1
  32. package/build-module/term-description/index.js.map +1 -1
  33. package/build-style/file/style-rtl.css +0 -5
  34. package/build-style/file/style.css +0 -5
  35. package/build-style/style-rtl.css +0 -5
  36. package/build-style/style.css +0 -5
  37. package/package.json +32 -32
  38. package/src/file/index.php +2 -1
  39. package/src/file/style.scss +0 -6
  40. package/src/file/view.js +2 -2
  41. package/src/image/image.js +13 -2
  42. package/src/image/index.php +5 -6
  43. package/src/image/view.js +13 -19
  44. package/src/navigation/index.php +7 -0
  45. package/src/navigation/view.js +18 -6
  46. package/src/query/edit/enhanced-pagination-modal.js +5 -5
  47. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +18 -9
  48. package/src/query/utils.js +14 -7
  49. package/src/term-description/block.json +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["store","wpStore","focusableSelectors","openMenu","menuOpenedOn","context","ref","selectors","core","navigation","menuOpenedBy","previousFocus","type","document","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","focus","remove","effects","initMenu","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","ariaLabel","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, ref, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tcontext.core.navigation.previousFocus = ref;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaLabel: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? context.core.navigation.ariaLabel\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors } = store;\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\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},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3D,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+B,KAAK,CAACK,aACP,CAAC,IACDL,KAAK,CAACM,MAAM,KAAKpC,MAAM,CAACT,QAAQ,CAACU,aAAa,EAC7C;YACDN,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;YAC3BiB,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["store","wpStore","focusableSelectors","document","addEventListener","openMenu","menuOpenedOn","context","selectors","core","navigation","menuOpenedBy","type","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","previousFocus","focus","remove","effects","initMenu","ref","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","ariaModal","ariaLabel","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n// This is a fix for Safari in iOS/iPadOS. Without it, Safari doesn't focus out\n// when the user taps in the body. It can be removed once we add an overlay to\n// capture the clicks, instead of relying on the focusout event.\ndocument.addEventListener( 'click', () => {} );\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus?.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaModal: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tariaLabel: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? context.core.navigation.ariaLabel\n\t\t\t\t\t\t: null;\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\tconst { context, ref } = store;\n\t\t\t\t\tcontext.core.navigation.previousFocus = ref;\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors, context, ref } = store;\n\t\t\t\t\t// Safari won't send focus to the clicked element, so we need to manually place it: https://bugs.webkit.org/show_bug.cgi?id=22261\n\t\t\t\t\tif ( window.document.activeElement !== ref ) ref.focus();\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.core.navigation.previousFocus = ref;\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\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},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outsite the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\n\t\t\t\t\t// The event.relatedTarget is null when something outside the navigation menu is clicked. This is only necessary for Safari.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.relatedTarget === null ||\n\t\t\t\t\t\t( ! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\tevent.target !== window.document.activeElement )\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3D,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,mBAAmB,EACnB,iCAAiC,CACjC;;AAED;AACA;AACA;AACAC,QAAQ,CAACC,gBAAgB,CAAE,OAAO,EAAE,MAAM,CAAC,CAAE,CAAC;AAE9C,MAAMC,QAAQ,GAAGA,CAAEL,KAAK,EAAEM,YAAY,KAAM;EAC3C,MAAM;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAGR,KAAK;EACpCQ,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEX,KAAM,CAAC,CAAEM,YAAY,CAAE,GAAG,IAAI;EACtE,IAAKC,OAAO,CAACE,IAAI,CAACC,UAAU,CAACE,IAAI,KAAK,SAAS,EAAG;IACjD;IACAT,QAAQ,CAACU,eAAe,CAACC,SAAS,CAACC,GAAG,CAAE,gBAAiB,CAAC;EAC3D;AACD,CAAC;AAED,MAAMC,SAAS,GAAGA,CAAEhB,KAAK,EAAEiB,YAAY,KAAM;EAC5C,MAAM;IAAEV,OAAO;IAAEC;EAAU,CAAC,GAAGR,KAAK;EACpCQ,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEX,KAAM,CAAC,CAAEiB,YAAY,CAAE,GAAG,KAAK;EACvE;EACA,IA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;cACA,IACCD,KAAK,CAACE,QAAQ,IACdlC,MAAM,CAAClB,QAAQ,CAACmB,aAAa,KAC5Bf,OAAO,CAACE,IAAI,CAACC,UAAU,CACrBqB,qBAAqB,EACvB;gBACDsB,KAAK,CAACG,cAAc,CAAC,CAAC;gBACtBjD,OAAO,CAACE,IAAI,CAACC,UAAU,CAACsB,oBAAoB,CAACR,KAAK,CAAC,CAAC;cACrD,CAAC,MAAM,IACN,CAAE6B,KAAK,CAACE,QAAQ,IAChBlC,MAAM,CAAClB,QAAQ,CAACmB,aAAa,KAC5Bf,OAAO,CAACE,IAAI,CAACC,UAAU,CAACsB,oBAAoB,EAC5C;gBACDqB,KAAK,CAACG,cAAc,CAAC,CAAC;gBACtBjD,OAAO,CAACE,IAAI,CAACC,UAAU,CAACqB,qBAAqB,CAACP,KAAK,CAAC,CAAC;cACtD;YACD;UACD;QACD,CAAC;QACDiC,kBAAkB,EAAIzD,KAAK,IAAM;UAChC,MAAM;YAAEO,OAAO;YAAE8C;UAAM,CAAC,GAAGrD,KAAK;UAChC;UACA;UACA;UACA;UACA;;UAEA;UACA,IACCqD,KAAK,CAACK,aAAa,KAAK,IAAI,IAC1B,CAAEnD,OAAO,CAACE,IAAI,CAACC,UAAU,CAACS,KAAK,EAAEC,QAAQ,CAC1CiC,KAAK,CAACK,aACP,CAAC,IACAL,KAAK,CAACM,MAAM,KAAKtC,MAAM,CAAClB,QAAQ,CAACmB,aAAe,EAChD;YACDN,SAAS,CAAEhB,KAAK,EAAE,OAAQ,CAAC;YAC3BgB,SAAS,CAAEhB,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -9,8 +9,8 @@ import { useState, useEffect } from '@wordpress/element';
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import { useContainsThirdPartyBlocks } from '../utils';
13
- const disableEnhancedPaginationDescription = __('Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable "Enhanced pagination" in the Query Block settings.');
12
+ import { useUnsupportedBlockList } from '../utils';
13
+ const disableEnhancedPaginationDescription = __('You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable "Enhanced pagination" in the Query Block settings.');
14
14
  const modalDescriptionId = 'wp-block-query-enhanced-pagination-modal__description';
15
15
  export default function EnhancedPaginationModal({
16
16
  clientId,
@@ -20,10 +20,10 @@ export default function EnhancedPaginationModal({
20
20
  setAttributes
21
21
  }) {
22
22
  const [isOpen, setOpen] = useState(false);
23
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks(clientId);
23
+ const unsupported = useUnsupportedBlockList(clientId);
24
24
  useEffect(() => {
25
- setOpen(containsThirdPartyBlocks && enhancedPagination);
26
- }, [containsThirdPartyBlocks, enhancedPagination, setOpen]);
25
+ setOpen(!!unsupported.length && enhancedPagination);
26
+ }, [unsupported.length, enhancedPagination, setOpen]);
27
27
  return isOpen && createElement(Modal, {
28
28
  title: __('Enhanced pagination will be disabled'),
29
29
  className: "wp-block-query__enhanced-pagination-modal",
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Modal","__experimentalVStack","VStack","__","useState","useEffect","useContainsThirdPartyBlocks","disableEnhancedPaginationDescription","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","containsThirdPartyBlocks","createElement","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","alignment","spacing","id","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'Plugin blocks are not supported yet. For the enhanced pagination to work, remove the plugin block, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( containsThirdPartyBlocks && enhancedPagination );\n\t}, [ containsThirdPartyBlocks, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'OK' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA,SAASC,2BAA2B,QAAQ,UAAU;AAEtD,MAAMC,oCAAoC,GAAGJ,EAAE,CAC9C,sKACD,CAAC;AAED,MAAMK,kBAAkB,GACvB,uDAAuD;AAExD,eAAe,SAASC,uBAAuBA,CAAE;EAChDC,QAAQ;EACRC,UAAU,EAAE;IAAEC;EAAmB,CAAC;EAClCC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,MAAM,EAAEC,OAAO,CAAE,GAAGX,QAAQ,CAAE,KAAM,CAAC;EAE7C,MAAMY,wBAAwB,GAAGV,2BAA2B,CAAEI,QAAS,CAAC;EAExEL,SAAS,CAAE,MAAM;IAChBU,OAAO,CAAEC,wBAAwB,IAAIJ,kBAAmB,CAAC;EAC1D,CAAC,EAAE,CAAEI,wBAAwB,EAAEJ,kBAAkB,EAAEG,OAAO,CAAG,CAAC;EAE9D,OACCD,MAAM,IACLG,aAAA,CAACjB,KAAK;IACLkB,KAAK,EAAGf,EAAE,CAAE,sCAAuC,CAAG;IACtDgB,SAAS,EAAC,2CAA2C;IACrDC,IAAI,EAAG;MACNC,WAAW,EAAEb;IACd,CAAG;IACHc,aAAa,EAAG,KAAO;IACvBC,gBAAgB,EAAG,KAAO;IAC1BC,yBAAyB,EAAG;EAAO,GAEnCP,aAAA,CAACf,MAAM;IAACuB,SAAS,EAAC,OAAO;IAACC,OAAO,EAAG;EAAG,GACtCT,aAAA;IAAMU,EAAE,EAAGnB;EAAoB,GAC5BD,oCACG,CAAC,EACPU,aAAA,CAAClB,MAAM;IACN6B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfhB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAEDT,EAAE,CAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
1
+ {"version":3,"names":["Button","Modal","__experimentalVStack","VStack","__","useState","useEffect","useUnsupportedBlockList","disableEnhancedPaginationDescription","modalDescriptionId","EnhancedPaginationModal","clientId","attributes","enhancedPagination","setAttributes","isOpen","setOpen","unsupported","length","createElement","title","className","aria","describedby","isDismissible","shouldCloseOnEsc","shouldCloseOnClickOutside","alignment","spacing","id","variant","onClick"],"sources":["@wordpress/block-library/src/query/edit/enhanced-pagination-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../utils';\n\nconst disableEnhancedPaginationDescription = __(\n\t'You have added unsupported blocks. For the enhanced pagination to work, remove them, then re-enable \"Enhanced pagination\" in the Query Block settings.'\n);\n\nconst modalDescriptionId =\n\t'wp-block-query-enhanced-pagination-modal__description';\n\nexport default function EnhancedPaginationModal( {\n\tclientId,\n\tattributes: { enhancedPagination },\n\tsetAttributes,\n} ) {\n\tconst [ isOpen, setOpen ] = useState( false );\n\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\tuseEffect( () => {\n\t\tsetOpen( !! unsupported.length && enhancedPagination );\n\t}, [ unsupported.length, enhancedPagination, setOpen ] );\n\n\treturn (\n\t\tisOpen && (\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Enhanced pagination will be disabled' ) }\n\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-modal\"\n\t\t\t\taria={ {\n\t\t\t\t\tdescribedby: modalDescriptionId,\n\t\t\t\t} }\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t>\n\t\t\t\t<VStack alignment=\"right\" spacing={ 5 }>\n\t\t\t\t\t<span id={ modalDescriptionId }>\n\t\t\t\t\t\t{ disableEnhancedPaginationDescription }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { enhancedPagination: false } );\n\t\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AAGpB;EAAoB,GAC5BD,oCACG,CAAC,EACPW,aAAA,CAACnB,MAAM;IACN8B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAGA,CAAA,KAAM;MACfjB,aAAa,CAAE;QAAED,kBAAkB,EAAE;MAAM,CAAE,CAAC;IAC/C;EAAG,GAEDT,EAAE,CAAE,IAAK,CACJ,CACD,CACF,CACP;AAEH"}
@@ -4,32 +4,36 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  */
5
5
  import { ToggleControl, Notice } from '@wordpress/components';
6
6
  import { __ } from '@wordpress/i18n';
7
+ import { BlockTitle } from '@wordpress/block-editor';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
- import { useContainsThirdPartyBlocks } from '../../utils';
12
+ import { useUnsupportedBlockList } from '../../utils';
12
13
  export default function EnhancedPaginationControl({
13
14
  enhancedPagination,
14
15
  setAttributes,
15
16
  clientId
16
17
  }) {
17
- const enhancedPaginationNotice = __("Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.");
18
- const containsThirdPartyBlocks = useContainsThirdPartyBlocks(clientId);
18
+ const unsupported = useUnsupportedBlockList(clientId);
19
19
  return createElement(Fragment, null, createElement(ToggleControl, {
20
20
  label: __('Enhanced pagination'),
21
21
  help: __('Browsing between pages won’t require a full page reload.'),
22
22
  checked: !!enhancedPagination,
23
- disabled: containsThirdPartyBlocks,
23
+ disabled: unsupported.length,
24
24
  onChange: value => {
25
25
  setAttributes({
26
26
  enhancedPagination: !!value
27
27
  });
28
28
  }
29
- }), containsThirdPartyBlocks && createElement(Notice, {
29
+ }), !!unsupported.length && createElement(Notice, {
30
30
  status: "warning",
31
31
  isDismissible: false,
32
32
  className: "wp-block-query__enhanced-pagination-notice"
33
- }, enhancedPaginationNotice));
33
+ }, __("Enhanced pagination doesn't support the following blocks:"), createElement("ul", null, unsupported.map(id => createElement("li", {
34
+ key: id
35
+ }, createElement(BlockTitle, {
36
+ clientId: id
37
+ })))), __('If you want to enable it, you have to remove all unsupported blocks first.')));
34
38
  }
35
39
  //# sourceMappingURL=enhanced-pagination-control.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ToggleControl","Notice","__","useContainsThirdPartyBlocks","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","enhancedPaginationNotice","containsThirdPartyBlocks","createElement","Fragment","label","help","checked","disabled","onChange","value","status","isDismissible","className"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContainsThirdPartyBlocks } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst enhancedPaginationNotice = __(\n\t\t\"Enhanced pagination doesn't support plugin blocks yet. If you want to enable it, you have to remove all plugin blocks from the Query Loop.\"\n\t);\n\n\tconst containsThirdPartyBlocks = useContainsThirdPartyBlocks( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ containsThirdPartyBlocks }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ containsThirdPartyBlocks && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ enhancedPaginationNotice }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,2BAA2B,QAAQ,aAAa;AAEzD,eAAe,SAASC,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,wBAAwB,GAAGN,EAAE,CAClC,4IACD,CAAC;EAED,MAAMO,wBAAwB,GAAGN,2BAA2B,CAAEI,QAAS,CAAC;EAExE,OACCG,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACV,aAAa;IACbY,KAAK,EAAGV,EAAE,CAAE,qBAAsB,CAAG;IACrCW,IAAI,EAAGX,EAAE,CACR,0DACD,CAAG;IACHY,OAAO,EAAG,CAAC,CAAET,kBAAoB;IACjCU,QAAQ,EAAGN,wBAA0B;IACrCO,QAAQ,EAAKC,KAAK,IAAM;MACvBX,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEY;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACAR,wBAAwB,IACzBC,aAAA,CAACT,MAAM;IACNiB,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpDZ,wBACK,CAER,CAAC;AAEL"}
1
+ {"version":3,"names":["ToggleControl","Notice","__","BlockTitle","useUnsupportedBlockList","EnhancedPaginationControl","enhancedPagination","setAttributes","clientId","unsupported","createElement","Fragment","label","help","checked","disabled","length","onChange","value","status","isDismissible","className","map","id","key"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/enhanced-pagination-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToggleControl, Notice } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { BlockTitle } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useUnsupportedBlockList } from '../../utils';\n\nexport default function EnhancedPaginationControl( {\n\tenhancedPagination,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst unsupported = useUnsupportedBlockList( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Browsing between pages won’t require a full page reload.'\n\t\t\t\t) }\n\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\tdisabled={ unsupported.length }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tenhancedPagination: !! value,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ !! unsupported.length && (\n\t\t\t\t<Notice\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\tclassName=\"wp-block-query__enhanced-pagination-notice\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t\"Enhanced pagination doesn't support the following blocks:\"\n\t\t\t\t\t) }\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{ unsupported.map( ( id ) => (\n\t\t\t\t\t\t\t<li key={ id }>\n\t\t\t\t\t\t\t\t<BlockTitle clientId={ id } />\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'If you want to enable it, you have to remove all unsupported blocks first.'\n\t\t\t\t\t) }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,yBAAyB;;AAEpD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,aAAa;AAErD,eAAe,SAASC,yBAAyBA,CAAE;EAClDC,kBAAkB;EAClBC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAAGL,uBAAuB,CAAEI,QAAS,CAAC;EAEvD,OACCE,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACV,aAAa;IACbY,KAAK,EAAGV,EAAE,CAAE,qBAAsB,CAAG;IACrCW,IAAI,EAAGX,EAAE,CACR,0DACD,CAAG;IACHY,OAAO,EAAG,CAAC,CAAER,kBAAoB;IACjCS,QAAQ,EAAGN,WAAW,CAACO,MAAQ;IAC/BC,QAAQ,EAAKC,KAAK,IAAM;MACvBX,aAAa,CAAE;QACdD,kBAAkB,EAAE,CAAC,CAAEY;MACxB,CAAE,CAAC;IACJ;EAAG,CACH,CAAC,EACA,CAAC,CAAET,WAAW,CAACO,MAAM,IACtBN,aAAA,CAACT,MAAM;IACNkB,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG,KAAO;IACvBC,SAAS,EAAC;EAA4C,GAEpDnB,EAAE,CACH,2DACD,CAAC,EACDQ,aAAA,aACGD,WAAW,CAACa,GAAG,CAAIC,EAAE,IACtBb,aAAA;IAAIc,GAAG,EAAGD;EAAI,GACbb,aAAA,CAACP,UAAU;IAACK,QAAQ,EAAGe;EAAI,CAAE,CAC1B,CACH,CACC,CAAC,EACHrB,EAAE,CACH,4EACD,CACO,CAER,CAAC;AAEL"}
@@ -332,19 +332,22 @@ export const usePatterns = (clientId, name) => {
332
332
  };
333
333
 
334
334
  /**
335
- * Hook that returns whether the Query Loop with the given `clientId` contains
336
- * any third-party block.
335
+ * Hook that returns a list of unsupported blocks inside the Query Loop with the
336
+ * given `clientId`.
337
337
  *
338
338
  * @param {string} clientId The block's client ID.
339
- * @return {boolean} True if it contains third-party blocks.
339
+ * @return {string[]} List of block titles.
340
340
  */
341
- export const useContainsThirdPartyBlocks = clientId => {
341
+ export const useUnsupportedBlockList = clientId => {
342
342
  return useSelect(select => {
343
343
  const {
344
344
  getClientIdsOfDescendants,
345
345
  getBlockName
346
346
  } = select(blockEditorStore);
347
- return getClientIdsOfDescendants(clientId).some(descendantClientId => !getBlockName(descendantClientId).startsWith('core/'));
347
+ return getClientIdsOfDescendants(clientId).filter(descendantClientId => {
348
+ const blockName = getBlockName(descendantClientId);
349
+ return !blockName.startsWith('core/') || blockName === 'core/post-content' || blockName === 'core/template-part' || blockName === 'core/block';
350
+ });
348
351
  }, [clientId]);
349
352
  };
350
353
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useContainsThirdPartyBlocks","getClientIdsOfDescendants","getBlockName","some","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\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/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of 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( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = 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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns whether the Query Loop with the given `clientId` contains\n * any third-party block.\n *\n * @param {string} clientId The block's client ID.\n * @return {boolean} True if it contains third-party blocks.\n */\nexport const useContainsThirdPartyBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).some(\n\t\t\t\t( descendantClientId ) =>\n\t\t\t\t\t! getBlockName( descendantClientId ).startsWith( 'core/' )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAKC,QAAQ,IAAM;EAC9C,MAAMC,OAAO,GAAGD,QAAQ,EAAEE,MAAM,CAC/B,CAAEC,WAAW,EAAEC,MAA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K,CAAC,CAAEc,mBAAmB,CAAClD,MAAM,EAAG;MACpC,OAAOkD,mBAAmB;IAC3B;IACA,OAAON,eAAe,CAACjD,MAAM,CAAEoD,cAAe,CAAC;EAChD,CAAC,EAAE,CAAEX,mBAAmB,EAAEQ,eAAe,CAAG,CAAC;EAC7C,OAAOE,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,WAAW,GAAGA,CAAEpB,QAAQ,EAAEvD,IAAI,KAAM;EAChD,OAAOlB,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAEiD,oBAAoB;MAAEC;IAAwB,CAAC,GACtDlD,MAAM,CAAE5B,gBAAiB,CAAC;IAC3B,MAAM+E,YAAY,GAAGF,oBAAoB,CAAER,QAAS,CAAC;IACrD,OAAOS,uBAAuB,CAAEhE,IAAI,EAAEiE,YAAa,CAAC;EACrD,CAAC,EACD,CAAEjE,IAAI,EAAEuD,QAAQ,CACjB,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMqB,2BAA2B,GAAKrB,QAAQ,IAAM;EAC1D,OAAOzE,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAE+D,yBAAyB;MAAEC;IAAa,CAAC,GAChDhE,MAAM,CAAE5B,gBAAiB,CAAC;IAE3B,OAAO2F,yBAAyB,CAAEtB,QAAS,CAAC,CAACwB,IAAI,CAC9CC,kBAAkB,IACnB,CAAEF,YAAY,CAAEE,kBAAmB,CAAC,CAACC,UAAU,CAAE,OAAQ,CAC3D,CAAC;EACF,CAAC,EACD,CAAE1B,QAAQ,CACX,CAAC;AACF,CAAC"}
1
+ {"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useUnsupportedBlockList","getClientIdsOfDescendants","getBlockName","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\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/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of 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( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = 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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns a list of unsupported blocks inside the Query Loop with the\n * given `clientId`.\n *\n * @param {string} clientId The block's client ID.\n * @return {string[]} List of block titles.\n */\nexport const useUnsupportedBlockList = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).filter(\n\t\t\t\t( descendantClientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( descendantClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! blockName.startsWith( 'core/' ) ||\n\t\t\t\t\t\tblockName === 'core/post-content' ||\n\t\t\t\t\t\tblockName === 'core/template-part' ||\n\t\t\t\t\t\tblockName === 'core/block'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAKC,QAAQ,IAAM;EAC9C,MAAMC,OAAO,GAAGD,QAAQ,EAAEE,MAAM,CAC/B,CAAEC,WAAW,EAAEC,MAAM,KAAM;IAC1B,MAAM;MAAEC,OAAO;MAAEC,SAAS;MAAEC;IAAM,CAAC,GAAGJ,WAAW;IACjDE,OAAO,CAAED,MAAM,CAACI,EAAE,CAAE,GAAGJ,MAAM;IAC7BE,SAAS,CAAEF,MAAM,CAACK,IAAI,CAAE,GAAGL,MAAM;IACjCG,KAAK,CAACG,IAAI,CAAEN,MAAM,CAACK,IAAK,CAAC;IACzB,OAAON,WAAW;EACnB,CAAC,EACD;IAAEE,OAAO,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AAI,KAAM;EAChD,OAAOlB,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAEiD,oBAAoB;MAAEC;IAAwB,CAAC,GACtDlD,MAAM,CAAE5B,gBAAiB,CAAC;IAC3B,MAAM+E,YAAY,GAAGF,oBAAoB,CAAER,QAAS,CAAC;IACrD,OAAOS,uBAAuB,CAAEhE,IAAI,EAAEiE,YAAa,CAAC;EACrD,CAAC,EACD,CAAEjE,IAAI,EAAEuD,QAAQ,CACjB,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMqB,uBAAuB,GAAKrB,QAAQ,IAAM;EACtD,OAAOzE,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAE+D,yBAAyB;MAAEC;IAAa,CAAC,GAChDhE,MAAM,CAAE5B,gBAAiB,CAAC;IAE3B,OAAO2F,yBAAyB,CAAEtB,QAAS,CAAC,CAACpC,MAAM,CAChD4D,kBAAkB,IAAM;MACzB,MAAMlB,SAAS,GAAGiB,YAAY,CAAEC,kBAAmB,CAAC;MACpD,OACC,CAAElB,SAAS,CAACmB,UAAU,CAAE,OAAQ,CAAC,IACjCnB,SAAS,KAAK,mBAAmB,IACjCA,SAAS,KAAK,oBAAoB,IAClCA,SAAS,KAAK,YAAY;IAE5B,CACD,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,CACX,CAAC;AACF,CAAC"}
@@ -10,7 +10,6 @@ import initBlock from '../utils/init-block';
10
10
  const metadata = {
11
11
  $schema: "https://schemas.wp.org/trunk/block.json",
12
12
  apiVersion: 3,
13
- __experimental: "fse",
14
13
  name: "core/term-description",
15
14
  title: "Term Description",
16
15
  category: "theme",
@@ -1 +1 @@
1
- {"version":3,"names":["termDescription","icon","initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","edit","settings","init"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAE5C,OAAOQ,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE5B;AAAK,CAAC,GAAGJ,QAAQ;AACzB,SAASA,QAAQ,EAAEI,IAAI;AAEvB,OAAO,MAAM6B,QAAQ,GAAG;EACvBnC,IAAI;EACJkC;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMnC,SAAS,CAAE;EAAEK,IAAI;EAAEJ,QAAQ;EAAEiC;AAAS,CAAE,CAAC"}
1
+ {"version":3,"names":["termDescription","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","textAlign","type","supports","align","html","color","link","__experimentalDefaultControls","background","text","spacing","padding","margin","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","edit","settings","init"],"sources":["@wordpress/block-library/src/term-description/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,SAAA;MAAAC,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,KAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,OAAA;MAAAC,MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAd,6BAAA;QAAAO,QAAA;MAAA;IAAA;EAAA;AAAA;AAE5C,OAAOQ,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE5B;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM6B,QAAQ,GAAG;EACvBlC,IAAI;EACJiC;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMlC,SAAS,CAAE;EAAEI,IAAI;EAAEH,QAAQ;EAAEgC;AAAS,CAAE,CAAC"}
@@ -110,11 +110,6 @@
110
110
  margin-bottom: 1em;
111
111
  }
112
112
 
113
- @media (max-width: 768px) {
114
- .wp-block-file__embed {
115
- display: none;
116
- }
117
- }
118
113
  :where(.wp-block-file__button) {
119
114
  border-radius: 2em;
120
115
  padding: 0.5em 1em;
@@ -111,11 +111,6 @@
111
111
  margin-bottom: 1em;
112
112
  }
113
113
 
114
- @media (max-width: 768px) {
115
- .wp-block-file__embed {
116
- display: none;
117
- }
118
- }
119
114
  :where(.wp-block-file__button) {
120
115
  border-radius: 2em;
121
116
  padding: 0.5em 1em;
@@ -1136,11 +1136,6 @@ section.wp-block-cover-image > h2,
1136
1136
  margin-bottom: 1em;
1137
1137
  }
1138
1138
 
1139
- @media (max-width: 768px) {
1140
- .wp-block-file__embed {
1141
- display: none;
1142
- }
1143
- }
1144
1139
  :where(.wp-block-file__button) {
1145
1140
  border-radius: 2em;
1146
1141
  padding: 0.5em 1em;
@@ -1144,11 +1144,6 @@ section.wp-block-cover-image > h2,
1144
1144
  margin-bottom: 1em;
1145
1145
  }
1146
1146
 
1147
- @media (max-width: 768px) {
1148
- .wp-block-file__embed {
1149
- display: none;
1150
- }
1151
- }
1152
1147
  :where(.wp-block-file__button) {
1153
1148
  border-radius: 2em;
1154
1149
  padding: 0.5em 1em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.19.8",
3
+ "version": "8.19.10",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,36 +31,36 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.42.8",
35
- "@wordpress/api-fetch": "^6.39.8",
36
- "@wordpress/autop": "^3.42.8",
37
- "@wordpress/blob": "^3.42.8",
38
- "@wordpress/block-editor": "^12.10.8",
39
- "@wordpress/blocks": "^12.19.8",
40
- "@wordpress/components": "^25.8.8",
41
- "@wordpress/compose": "^6.19.8",
42
- "@wordpress/core-data": "^6.19.8",
43
- "@wordpress/data": "^9.12.8",
44
- "@wordpress/date": "^4.42.8",
45
- "@wordpress/deprecated": "^3.42.8",
46
- "@wordpress/dom": "^3.42.8",
47
- "@wordpress/element": "^5.19.8",
48
- "@wordpress/escape-html": "^2.42.8",
49
- "@wordpress/hooks": "^3.42.8",
50
- "@wordpress/html-entities": "^3.42.8",
51
- "@wordpress/i18n": "^4.42.8",
52
- "@wordpress/icons": "^9.33.8",
53
- "@wordpress/interactivity": "^2.3.8",
54
- "@wordpress/keycodes": "^3.42.8",
55
- "@wordpress/notices": "^4.10.8",
56
- "@wordpress/primitives": "^3.40.8",
57
- "@wordpress/private-apis": "^0.24.8",
58
- "@wordpress/reusable-blocks": "^4.19.8",
59
- "@wordpress/rich-text": "^6.19.8",
60
- "@wordpress/server-side-render": "^4.19.8",
61
- "@wordpress/url": "^3.43.8",
62
- "@wordpress/viewport": "^5.19.8",
63
- "@wordpress/wordcount": "^3.42.8",
34
+ "@wordpress/a11y": "^3.42.10",
35
+ "@wordpress/api-fetch": "^6.39.10",
36
+ "@wordpress/autop": "^3.42.10",
37
+ "@wordpress/blob": "^3.42.10",
38
+ "@wordpress/block-editor": "^12.10.10",
39
+ "@wordpress/blocks": "^12.19.10",
40
+ "@wordpress/components": "^25.8.10",
41
+ "@wordpress/compose": "^6.19.10",
42
+ "@wordpress/core-data": "^6.19.10",
43
+ "@wordpress/data": "^9.12.10",
44
+ "@wordpress/date": "^4.42.10",
45
+ "@wordpress/deprecated": "^3.42.10",
46
+ "@wordpress/dom": "^3.42.10",
47
+ "@wordpress/element": "^5.19.10",
48
+ "@wordpress/escape-html": "^2.42.10",
49
+ "@wordpress/hooks": "^3.42.10",
50
+ "@wordpress/html-entities": "^3.42.10",
51
+ "@wordpress/i18n": "^4.42.10",
52
+ "@wordpress/icons": "^9.33.10",
53
+ "@wordpress/interactivity": "^2.3.10",
54
+ "@wordpress/keycodes": "^3.42.10",
55
+ "@wordpress/notices": "^4.10.10",
56
+ "@wordpress/primitives": "^3.40.10",
57
+ "@wordpress/private-apis": "^0.24.10",
58
+ "@wordpress/reusable-blocks": "^4.19.10",
59
+ "@wordpress/rich-text": "^6.19.10",
60
+ "@wordpress/server-side-render": "^4.19.10",
61
+ "@wordpress/url": "^3.43.10",
62
+ "@wordpress/viewport": "^5.19.10",
63
+ "@wordpress/wordcount": "^3.42.10",
64
64
  "change-case": "^4.1.2",
65
65
  "classnames": "^2.3.1",
66
66
  "colord": "^2.7.0",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "9ef7560ce92c4736819b5e767810b9a80d51d030"
81
+ "gitHead": "11504931036f9db3612c82298a7eab60147e0706"
82
82
  }
@@ -59,7 +59,8 @@ function render_block_core_file( $attributes, $content, $block ) {
59
59
  $processor->next_tag();
60
60
  $processor->set_attribute( 'data-wp-interactive', '' );
61
61
  $processor->next_tag( 'object' );
62
- $processor->set_attribute( 'data-wp-style--display', 'selectors.core.file.hasPdfPreview' );
62
+ $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
63
+ $processor->set_attribute( 'hidden', true );
63
64
  return $processor->get_updated_html();
64
65
  }
65
66
 
@@ -29,12 +29,6 @@
29
29
  margin-bottom: 1em;
30
30
  }
31
31
 
32
- @media (max-width: 768px) {
33
- .wp-block-file__embed {
34
- display: none;
35
- }
36
- }
37
-
38
32
  //This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
39
33
  :where(.wp-block-file__button) {
40
34
  border-radius: 2em;
package/src/file/view.js CHANGED
@@ -5,13 +5,13 @@ import { store } from '@wordpress/interactivity';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
8
- import { browserSupportsPdfs } from './utils';
8
+ import { browserSupportsPdfs as hasPdfPreview } from './utils';
9
9
 
10
10
  store( {
11
11
  selectors: {
12
12
  core: {
13
13
  file: {
14
- hasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none',
14
+ hasPdfPreview,
15
15
  },
16
16
  },
17
17
  },
@@ -83,6 +83,11 @@ const scaleOptions = [
83
83
  },
84
84
  ];
85
85
 
86
+ const disabledClickProps = {
87
+ onClick: ( event ) => event.preventDefault(),
88
+ 'aria-disabled': true,
89
+ };
90
+
86
91
  export default function Image( {
87
92
  temporaryURL,
88
93
  attributes,
@@ -725,7 +730,6 @@ export default function Image( {
725
730
  }
726
731
  }
727
732
  /* eslint-enable no-lonely-if */
728
-
729
733
  img = (
730
734
  <ResizableBox
731
735
  style={ {
@@ -784,7 +788,14 @@ export default function Image( {
784
788
  { /* Hide controls during upload to avoid component remount,
785
789
  which causes duplicated image upload. */ }
786
790
  { ! temporaryURL && controls }
787
- { img }
791
+ { /* If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles */ }
792
+ { !! href ? (
793
+ <a href={ href } { ...disabledClickProps }>
794
+ { img }
795
+ </a>
796
+ ) : (
797
+ img
798
+ ) }
788
799
  { showCaption &&
789
800
  ( ! RichText.isEmpty( caption ) || isSelected ) && (
790
801
  <RichText
@@ -235,6 +235,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
235
235
  $button =
236
236
  $img[0]
237
237
  . '<button
238
+ class="lightbox-trigger"
238
239
  type="button"
239
240
  aria-haspopup="dialog"
240
241
  aria-label="' . esc_attr( $aria_label ) . '"
@@ -243,11 +244,8 @@ function block_core_image_render_lightbox( $block_content, $block ) {
243
244
  data-wp-style--top="context.core.image.imageButtonTop"
244
245
  style="background: #000"
245
246
  >
246
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
247
- <path d="M9 5H5V9" stroke="#FFFFFF" stroke-width="1.5"/>
248
- <path d="M15 19L19 19L19 15" stroke="#FFFFFF" stroke-width="1.5"/>
249
- <path d="M15 5H19V9" stroke="#FFFFFF" stroke-width="1.5"/>
250
- <path d="M9 19L5 19L5 15" stroke="#FFFFFF" stroke-width="1.5"/>
247
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
248
+ <Path stroke="#FFFFFF" d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />
251
249
  </svg>
252
250
  </button>';
253
251
 
@@ -322,12 +320,13 @@ function block_core_image_render_lightbox( $block_content, $block ) {
322
320
  data-wp-on--touchmove="actions.core.image.handleTouchMove"
323
321
  data-wp-on--touchend="actions.core.image.handleTouchEnd"
324
322
  data-wp-on--click="actions.core.image.hideLightbox"
323
+ tabindex="-1"
325
324
  >
326
325
  <button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
327
326
  $close_button_icon
328
327
  </button>
329
328
  <div class="lightbox-image-container">$initial_image_content</div>
330
- <div class="lightbox-image-container">$enlarged_image_content</div>
329
+ <div class="lightbox-image-container">$enlarged_image_content</div>
331
330
  <div class="scrim" style="background-color: $background_color" aria-hidden="true"></div>
332
331
  </div>
333
332
  HTML;