@wordpress/edit-widgets 5.11.0 → 5.12.0

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 (116) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/blocks/widget-area/edit/index.js +24 -29
  3. package/build/blocks/widget-area/edit/index.js.map +1 -1
  4. package/build/blocks/widget-area/edit/inner-blocks.js +3 -4
  5. package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  6. package/build/blocks/widget-area/index.js +3 -6
  7. package/build/blocks/widget-area/index.js.map +1 -1
  8. package/build/components/error-boundary/index.js +8 -10
  9. package/build/components/error-boundary/index.js.map +1 -1
  10. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -4
  11. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  12. package/build/components/keyboard-shortcut-help-modal/index.js +41 -50
  13. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  14. package/build/components/keyboard-shortcut-help-modal/shortcut.js +10 -12
  15. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  16. package/build/components/layout/index.js +3 -4
  17. package/build/components/layout/index.js.map +1 -1
  18. package/build/components/layout/interface.js +3 -4
  19. package/build/components/layout/interface.js.map +1 -1
  20. package/build/components/layout/unsaved-changes-warning.js +1 -1
  21. package/build/components/layout/unsaved-changes-warning.js.map +1 -1
  22. package/build/components/more-menu/tools-more-menu-group.js +5 -8
  23. package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
  24. package/build/components/notices/index.js +11 -20
  25. package/build/components/notices/index.js.map +1 -1
  26. package/build/components/save-button/index.js +1 -3
  27. package/build/components/save-button/index.js.map +1 -1
  28. package/build/components/secondary-sidebar/list-view-sidebar.js +8 -3
  29. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  30. package/build/components/sidebar/index.js +7 -8
  31. package/build/components/sidebar/index.js.map +1 -1
  32. package/build/components/sidebar/widget-areas.js +5 -6
  33. package/build/components/sidebar/widget-areas.js.map +1 -1
  34. package/build/components/welcome-guide/index.js +6 -7
  35. package/build/components/welcome-guide/index.js.map +1 -1
  36. package/build/components/widget-areas-block-editor-content/index.js +3 -4
  37. package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
  38. package/build/components/widget-areas-block-editor-provider/index.js +12 -17
  39. package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
  40. package/build/filters/move-to-widget-area.js +2 -4
  41. package/build/filters/move-to-widget-area.js.map +1 -1
  42. package/build/hooks/use-last-selected-widget-area.js +2 -4
  43. package/build/hooks/use-last-selected-widget-area.js.map +1 -1
  44. package/build/hooks/use-widget-library-insertion-point.js +1 -3
  45. package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
  46. package/build/store/actions.js +49 -74
  47. package/build/store/actions.js.map +1 -1
  48. package/build/store/index.js +1 -3
  49. package/build/store/index.js.map +1 -1
  50. package/build/store/reducer.js +3 -11
  51. package/build/store/reducer.js.map +1 -1
  52. package/build/store/resolvers.js +8 -10
  53. package/build/store/resolvers.js.map +1 -1
  54. package/build/store/selectors.js +15 -32
  55. package/build/store/selectors.js.map +1 -1
  56. package/build/store/transformers.js +1 -2
  57. package/build/store/transformers.js.map +1 -1
  58. package/build-module/blocks/widget-area/edit/index.js +24 -29
  59. package/build-module/blocks/widget-area/edit/index.js.map +1 -1
  60. package/build-module/blocks/widget-area/edit/inner-blocks.js +3 -4
  61. package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  62. package/build-module/blocks/widget-area/index.js +3 -6
  63. package/build-module/blocks/widget-area/index.js.map +1 -1
  64. package/build-module/components/error-boundary/index.js +8 -10
  65. package/build-module/components/error-boundary/index.js.map +1 -1
  66. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +3 -4
  67. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  68. package/build-module/components/keyboard-shortcut-help-modal/index.js +39 -48
  69. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  70. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +10 -12
  71. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  72. package/build-module/components/layout/index.js +3 -4
  73. package/build-module/components/layout/index.js.map +1 -1
  74. package/build-module/components/layout/interface.js +3 -4
  75. package/build-module/components/layout/interface.js.map +1 -1
  76. package/build-module/components/layout/unsaved-changes-warning.js +1 -1
  77. package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
  78. package/build-module/components/more-menu/tools-more-menu-group.js +5 -8
  79. package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
  80. package/build-module/components/notices/index.js +11 -20
  81. package/build-module/components/notices/index.js.map +1 -1
  82. package/build-module/components/save-button/index.js +1 -3
  83. package/build-module/components/save-button/index.js.map +1 -1
  84. package/build-module/components/secondary-sidebar/list-view-sidebar.js +9 -3
  85. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  86. package/build-module/components/sidebar/index.js +9 -10
  87. package/build-module/components/sidebar/index.js.map +1 -1
  88. package/build-module/components/sidebar/widget-areas.js +5 -6
  89. package/build-module/components/sidebar/widget-areas.js.map +1 -1
  90. package/build-module/components/welcome-guide/index.js +6 -7
  91. package/build-module/components/welcome-guide/index.js.map +1 -1
  92. package/build-module/components/widget-areas-block-editor-content/index.js +3 -4
  93. package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
  94. package/build-module/components/widget-areas-block-editor-provider/index.js +12 -17
  95. package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
  96. package/build-module/filters/move-to-widget-area.js +2 -4
  97. package/build-module/filters/move-to-widget-area.js.map +1 -1
  98. package/build-module/hooks/use-last-selected-widget-area.js +2 -4
  99. package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
  100. package/build-module/hooks/use-widget-library-insertion-point.js +1 -3
  101. package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
  102. package/build-module/store/actions.js +49 -74
  103. package/build-module/store/actions.js.map +1 -1
  104. package/build-module/store/index.js +1 -3
  105. package/build-module/store/index.js.map +1 -1
  106. package/build-module/store/reducer.js +3 -11
  107. package/build-module/store/reducer.js.map +1 -1
  108. package/build-module/store/resolvers.js +8 -10
  109. package/build-module/store/resolvers.js.map +1 -1
  110. package/build-module/store/selectors.js +15 -32
  111. package/build-module/store/selectors.js.map +1 -1
  112. package/build-module/store/transformers.js +1 -2
  113. package/build-module/store/transformers.js.map +1 -1
  114. package/package.json +27 -27
  115. package/src/components/secondary-sidebar/list-view-sidebar.js +8 -1
  116. package/src/components/sidebar/index.js +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/resolvers.js"],"names":["createBlock","store","coreStore","persistStubPost","setWidgetAreasOpenState","KIND","WIDGET_AREA_ENTITY_TYPE","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","buildWidgetAreasPostId","transformWidgetToBlock","getWidgetAreas","dispatch","registry","query","widgetAreas","resolveSelect","getEntityRecords","widgetAreaBlocks","sortedWidgetAreas","sort","a","b","id","widgetArea","push","name","widgets","length","widgetAreasOpenState","forEach","widgetAreaBlock","index","clientId","getWidgets","groupedBySidebar","widget","block","sidebar","sidebarId","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,uBAA1B,QAAyD,WAAzD;AACA,SACCC,IADD,EAECC,uBAFD,EAGCC,iBAHD,EAICC,qBAJD,EAKCC,qBALD,EAMCC,sBAND,QAOO,SAPP;AAQA,SAASC,sBAAT,QAAuC,gBAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,cAAc,GAC1B,MACA,cAAoC;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ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AsB,EAAxB,EAA4BS,gBAA5B,CADR,CAAR;AAGA,CAhDK;AAkDP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMgB,UAAU,GACtB,MACA,eAAoC;AAAA,MAA5B;AAAEtB,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACnC,QAAMC,KAAK,GAAGR,iBAAiB,EAA/B;AACA,QAAMqB,OAAO,GAAG,MAAMd,QAAQ,CAC5BG,aADoB,CACLf,SADK,EAEpBgB,gBAFoB,CAEF,MAFE,EAEM,QAFN,EAEgBH,KAFhB,CAAtB;AAIA,QAAMqB,gBAAgB,GAAG,EAAzB;;AAEA,OAAM,MAAMC,MAAZ,IAAsBT,OAAtB,EAAgC;AAC/B,UAAMU,KAAK,GAAG3B,sBAAsB,CAAE0B,MAAF,CAApC;AACAD,IAAAA,gBAAgB,CAAEC,MAAM,CAACE,OAAT,CAAhB,GACCH,gBAAgB,CAAEC,MAAM,CAACE,OAAT,CAAhB,IAAsC,EADvC;AAEAH,IAAAA,gBAAgB,CAAEC,MAAM,CAACE,OAAT,CAAhB,CAAmCb,IAAnC,CAAyCY,KAAzC;AACA;;AAED,OAAM,MAAME,SAAZ,IAAyBJ,gBAAzB,EAA4C;AAC3C,QAAKA,gBAAgB,CAACK,cAAjB,CAAiCD,SAAjC,CAAL,EAAoD;AACnD;AACA3B,MAAAA,QAAQ,CACPV,eAAe,CACdM,qBAAqB,CAAE+B,SAAF,CADP,EAEdJ,gBAAgB,CAAEI,SAAF,CAFF,CADR,CAAR;AAMA;AACD;AACD,CA5BK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\n\t\t\t\t\t\t[]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/store/resolvers.js"],"names":["createBlock","store","coreStore","persistStubPost","setWidgetAreasOpenState","KIND","WIDGET_AREA_ENTITY_TYPE","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","buildWidgetAreasPostId","transformWidgetToBlock","getWidgetAreas","dispatch","registry","query","widgetAreas","resolveSelect","getEntityRecords","widgetAreaBlocks","sortedWidgetAreas","sort","a","b","id","widgetArea","push","name","widgets","length","widgetAreasOpenState","forEach","widgetAreaBlock","index","clientId","getWidgets","groupedBySidebar","widget","block","sidebar","sidebarId","hasOwnProperty"],"mappings":"AAAA;AACA;A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ACnD;AACA3B,MAAAA,QAAQ,CACPV,eAAe,CACdM,qBAAqB,CAAE+B,SAAF,CADP,EAEdJ,gBAAgB,CAAEI,SAAF,CAFF,CADR,CAAR;AAMA;AACD;AACD,CA5BK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\n\t\t\t\t\t\t[]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"]}
@@ -20,9 +20,9 @@ import { STORE_NAME as editWidgetsStoreName } from './constants';
20
20
  export const getWidgets = createRegistrySelector(select => () => {
21
21
  const widgets = select(coreStore).getEntityRecords('root', 'widget', buildWidgetsQuery());
22
22
  return (// Key widgets by their ID.
23
- (widgets === null || widgets === void 0 ? void 0 : widgets.reduce((allWidgets, widget) => ({ ...allWidgets,
23
+ widgets?.reduce((allWidgets, widget) => ({ ...allWidgets,
24
24
  [widget.id]: widget
25
- }), {})) || {}
25
+ }), {}) || {}
26
26
  );
27
27
  });
28
28
  /**
@@ -94,25 +94,16 @@ export const getEditedWidgetAreas = createRegistrySelector(select => (state, ids
94
94
  }
95
95
 
96
96
  if (ids) {
97
- widgetAreas = widgetAreas.filter(_ref => {
98
- let {
99
- id
100
- } = _ref;
101
- return ids.includes(id);
102
- });
97
+ widgetAreas = widgetAreas.filter(({
98
+ id
99
+ }) => ids.includes(id));
103
100
  }
104
101
 
105
- return widgetAreas.filter(_ref2 => {
106
- let {
107
- id
108
- } = _ref2;
109
- return select(coreStore).hasEditsForEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(id));
110
- }).map(_ref3 => {
111
- let {
112
- id
113
- } = _ref3;
114
- return select(coreStore).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id);
115
- });
102
+ return widgetAreas.filter(({
103
+ id
104
+ }) => select(coreStore).hasEditsForEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(id))).map(({
105
+ id
106
+ }) => select(coreStore).getEditedEntityRecord(KIND, WIDGET_AREA_ENTITY_TYPE, id));
116
107
  });
117
108
  /**
118
109
  * Returns all blocks representing reference widgets.
@@ -121,8 +112,7 @@ export const getEditedWidgetAreas = createRegistrySelector(select => (state, ids
121
112
  * @return {Array} List of all blocks representing reference widgets
122
113
  */
123
114
 
124
- export const getReferenceWidgetBlocks = createRegistrySelector(select => function (state) {
125
- let referenceWidgetName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
115
+ export const getReferenceWidgetBlocks = createRegistrySelector(select => (state, referenceWidgetName = null) => {
126
116
  const results = [];
127
117
  const widgetAreas = select(editWidgetsStoreName).getWidgetAreas();
128
118
 
@@ -130,9 +120,7 @@ export const getReferenceWidgetBlocks = createRegistrySelector(select => functio
130
120
  const post = select(coreStore).getEditedEntityRecord(KIND, POST_TYPE, buildWidgetAreaPostId(_widgetArea.id));
131
121
 
132
122
  for (const block of post.blocks) {
133
- var _block$attributes;
134
-
135
- if (block.name === 'core/legacy-widget' && (!referenceWidgetName || ((_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.referenceWidgetName) === referenceWidgetName)) {
123
+ if (block.name === 'core/legacy-widget' && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) {
136
124
  results.push(block);
137
125
  }
138
126
  }
@@ -147,14 +135,9 @@ export const getReferenceWidgetBlocks = createRegistrySelector(select => functio
147
135
  */
148
136
 
149
137
  export const isSavingWidgetAreas = createRegistrySelector(select => () => {
150
- var _select$getWidgetArea;
151
-
152
- const widgetAreasIds = (_select$getWidgetArea = select(editWidgetsStoreName).getWidgetAreas()) === null || _select$getWidgetArea === void 0 ? void 0 : _select$getWidgetArea.map(_ref4 => {
153
- let {
154
- id
155
- } = _ref4;
156
- return id;
157
- });
138
+ const widgetAreasIds = select(editWidgetsStoreName).getWidgetAreas()?.map(({
139
+ id
140
+ }) => id);
158
141
 
159
142
  if (!widgetAreasIds) {
160
143
  return false;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","reduce","allWidgets","widget","id","getWidget","state","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAGb,sBAAsB,CAAIc,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAEX,SAAF,CAAN,CAAoBa,gBAApB,CACf,MADe,EAEf,QAFe,EAGfX,iBAAiB,EAHF,CAAhB;AAMA,SACC;AACA,KAAAU,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,MAAT,CACC,CAAEC,UAAF,EAAcC,MAAd,MAA4B,EAC3B,GAAGD,UADwB;AAE3B,OAAEC,MAAM,CAACC,EAAT,GAAeD;AAFY,KAA5B,CADD,EAKC,EALD,MAMK;AARN;AAUA,CAjB+C,CAAzC;AAmBP;AACA;AACA;AACA;AACA;A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,EAASkD,SAAT,KAAwB;AACrC;AACA,QAAM7C,WAAW,GAAGb,MAAM,CAAEV,gBAAF,CAAN,CAA2BqE,SAA3B,EAApB,CAFqC,CAIrC;AACA;AACA;;AACA,QAAM,CAAEC,eAAF,IAAsB/C,WAA5B;AACA,SAAOb,MAAM,CAAEV,gBAAF,CAAN,CAA2BuE,kBAA3B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsC,gBAAT,CAA2BtD,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CAACuD,aAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn (\n\t\t// Key widgets by their ID.\n\t\twidgets?.reduce(\n\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t...allWidgets,\n\t\t\t\t[ widget.id ]: widget,\n\t\t\t} ),\n\t\t\t{}\n\t\t) || {}\n\t);\n} );\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["createRegistrySelector","getWidgetIdFromBlock","store","coreStore","blockEditorStore","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","reduce","allWidgets","widget","id","getWidget","state","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","isListViewOpened","listViewPanel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAGb,sBAAsB,CAAIc,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAEX,SAAF,CAAN,CAAoBa,gBAApB,CACf,MADe,EAEf,QAFe,EAGfX,iBAAiB,EAHF,CAAhB;AAMA,SACC;AACAU,IAAAA,OAAO,EAAEE,MAAT,CACC,CAAEC,UAAF,EAAcC,MAAd,MAA4B,EAC3B,GAAGD,UADwB;AAE3B,OAAEC,MAAM,CAACC,EAAT,GAAeD;AAFY,KAA5B,CADD,EAKC,EALD,KAMK;AARN;AAUA,CAjB+C,CAAzC;AAmBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,SAAS,GAAGrB,sBAAsB,CAC5Cc,MAAF,IAAc,CAAEQ,KAAF,EAASF,EAAT,KAAiB;AAC9B,QAAML,OAAO,GAAGD,MAAM,CAAEF,oBAAF,CAAN,CAA+BC,UAA/B,EAAhB;AACA,SAAOE,OAAO,CAAEK,EAAF,CAAd;AACA,CAJ6C,CAAxC;AAOP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,cAAc,GAAGvB,sBAAsB,CAAIc,MAAF,IAAc,MAAM;AACzE,QAAMU,KAAK,GAAGlB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AnCwD,CAAlD;AAqCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMM,mBAAmB,GAAG,CAAE1C,KAAF,EAASgB,QAAT,KAAuB;AACzD,QAAM;AAAE2B,IAAAA;AAAF,MAA2B3C,KAAjC;AACA,SAAO,CAAC,CAAE2C,oBAAoB,CAAE3B,QAAF,CAA9B;AACA,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS4B,gBAAT,CAA2B5C,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAAC6C,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,CAA0C9C,KAA1C,EAAkD;AACxD,QAAM;AAAE+C,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmChD,KAAK,CAAC6C,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAGvE,sBAAsB,CAC7Dc,MAAF,IAAc,CAAEQ,KAAF,EAASkD,SAAT,KAAwB;AACrC;AACA,QAAM7C,WAAW,GAAGb,MAAM,CAAEV,gBAAF,CAAN,CAA2BqE,SAA3B,EAApB,CAFqC,CAIrC;AACA;AACA;;AACA,QAAM,CAAEC,eAAF,IAAsB/C,WAA5B;AACA,SAAOb,MAAM,CAAEV,gBAAF,CAAN,CAA2BuE,kBAA3B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsC,gBAAT,CAA2BtD,KAA3B,EAAmC;AACzC,SAAOA,KAAK,CAACuD,aAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Returns all API widgets.\n *\n * @return {Object[]} API List of widgets.\n */\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( coreStore ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn (\n\t\t// Key widgets by their ID.\n\t\twidgets?.reduce(\n\t\t\t( allWidgets, widget ) => ( {\n\t\t\t\t...allWidgets,\n\t\t\t\t[ widget.id ]: widget,\n\t\t\t} ),\n\t\t\t{}\n\t\t) || {}\n\t);\n} );\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID.\n *\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\n/**\n * Returns all API widget areas.\n *\n * @return {Object[]} API List of widget areas.\n */\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( coreStore ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } =\n\t\t\tselect( blockEditorStore );\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\n/**\n * Returns all edited widget area entity records.\n *\n * @return {Object[]} List of edited widget area entity records.\n */\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) =>\n\t\t( state, referenceWidgetName = null ) => {\n\t\t\tconst results = [];\n\t\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t\t);\n\t\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t\t) {\n\t\t\t\t\t\tresults.push( block );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n);\n\n/**\n * Returns true if any widget area is currently being saved.\n *\n * @return {boolean} True if any widget area is currently being saved. False otherwise.\n */\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( coreStore ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n *\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( blockEditorStore ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( blockEditorStore ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n"]}
@@ -46,8 +46,7 @@ export function transformWidgetToBlock(widget) {
46
46
  * @return {Object} the widget object (converted from block).
47
47
  */
48
48
 
49
- export function transformBlockToWidget(block) {
50
- let relatedWidget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
49
+ export function transformBlockToWidget(block, relatedWidget = {}) {
51
50
  let widget;
52
51
  const isValidLegacyWidgetBlock = block.name === 'core/legacy-widget' && (block.attributes.id || block.attributes.instance);
53
52
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"names":["createBlock","parse","serialize","addWidgetIdToBlock","transformWidgetToBlock","widget","id_base","parsedBlocks","instance","raw","content","__unstableSkipAutop","length","id","attributes","_embedded","about","is_multi","idBase","transformBlockToWidget","block","relatedWidget","isValidLegacyWidgetBlock","name","rendered","rendered_form"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,KAAtB,EAA6BC,SAA7B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,MAAjC,EAA0C;AAChD,MAAKA,MAAM,CAACC,OAAP,KAAmB,OAAxB,EAAkC;AACjC,UAAMC,YAAY,GAAGN,KAAK,CAAEI,MAAM,CAACG,QAAP,CAAgBC,GAAhB,CAAoBC,OAAtB,EAA+B;AACxDC,MAAAA,mBAAmB,EAAE;AADmC,KAA/B,CAA1B;;AAGA,QAAK,CAAEJ,YAAY,CAACK,MAApB,EAA6B;AAC5B,aAAOT,kBAAkB,CACxBH,WAAW,CAAE,gBAAF,EAAoB,EAApB,EAAwB,EAAxB,CADa,EAExBK,MAAM,CAACQ,EAFiB,CAAzB;AAIA;;AACD,WAAOV,kBAAkB,CAAEI,YAAY,CAAE,CAAF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AAE,OAFD;AAGRE,MAAAA,QAAQ,EAAE;AACTC,QAAAA,GAAG,EAAE;AACJC,UAAAA,OAAO,EAAER,SAAS,CAAEkB,KAAF;AADd;AADI;AAHF,KAAT;AASA,GAxBkE,CA0BnE;;;AACA,SAAOf,MAAM,CAACmB,QAAd;AACA,SAAOnB,MAAM,CAACoB,aAAd;AAEA,SAAOpB,MAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, parse, serialize } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Converts a widget entity record into a block.\n *\n * @param {Object} widget The widget entity record.\n * @return {Object} a block (converted from the entity record).\n */\nexport function transformWidgetToBlock( widget ) {\n\tif ( widget.id_base === 'block' ) {\n\t\tconst parsedBlocks = parse( widget.instance.raw.content, {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( ! parsedBlocks.length ) {\n\t\t\treturn addWidgetIdToBlock(\n\t\t\t\tcreateBlock( 'core/paragraph', {}, [] ),\n\t\t\t\twidget.id\n\t\t\t);\n\t\t}\n\t\treturn addWidgetIdToBlock( parsedBlocks[ 0 ], widget.id );\n\t}\n\n\tlet attributes;\n\tif ( widget._embedded.about[ 0 ].is_multi ) {\n\t\tattributes = {\n\t\t\tidBase: widget.id_base,\n\t\t\tinstance: widget.instance,\n\t\t};\n\t} else {\n\t\tattributes = {\n\t\t\tid: widget.id,\n\t\t};\n\t}\n\n\treturn addWidgetIdToBlock(\n\t\tcreateBlock( 'core/legacy-widget', attributes, [] ),\n\t\twidget.id\n\t);\n}\n\n/**\n * Converts a block to a widget entity record.\n *\n * @param {Object} block The block.\n * @param {Object?} relatedWidget A related widget entity record from the API (optional).\n * @return {Object} the widget object (converted from block).\n */\nexport function transformBlockToWidget( block, relatedWidget = {} ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid: block.attributes.id ?? relatedWidget.id,\n\t\t\tid_base: block.attributes.idBase ?? relatedWidget.id_base,\n\t\t\tinstance: block.attributes.instance ?? relatedWidget.instance,\n\t\t};\n\t} else {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid_base: 'block',\n\t\t\tinstance: {\n\t\t\t\traw: {\n\t\t\t\t\tcontent: serialize( block ),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Delete read-only properties.\n\tdelete widget.rendered;\n\tdelete widget.rendered_form;\n\n\treturn widget;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"names":["createBlock","parse","serialize","addWidgetIdToBlock","transformWidgetToBlock","widget","id_base","parsedBlocks","instance","raw","content","__unstableSkipAutop","length","id","attributes","_embedded","about","is_multi","idBase","transformBlockToWidget","block","relatedWidget","isValidLegacyWidgetBlock","name","rendered","rendered_form"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,KAAtB,EAA6BC,SAA7B,QAA8C,mBAA9C;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCC,MAAjC,EAA0C;AAChD,MAAKA,MAAM,CAACC,OAAP,KAAmB,OAAxB,EAAkC;AACjC,UAAMC,YAAY,GAAGN,KAAK,CAAEI,MAAM,CAACG,QAAP,CAAgBC,GAAhB,CAAoBC,OAAtB,EAA+B;AACxDC,MAAAA,mBAAmB,EAAE;AADmC,KAA/B,CAA1B;;AAGA,QAAK,CAAEJ,YAAY,CAACK,MAApB,EAA6B;AAC5B,aAAOT,kBAAkB,CACxBH,WAAW,CAAE,gBAAF,EAAoB,EAApB,EAAwB,EAAxB,CADa,EAExBK,MAAM,CAACQ,EAFiB,CAAzB;AAIA;;AACD,WAAOV,kBAAkB,CAAEI,YAA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OAAO,EAAE,OAFD;AAGRE,MAAAA,QAAQ,EAAE;AACTC,QAAAA,GAAG,EAAE;AACJC,UAAAA,OAAO,EAAER,SAAS,CAAEkB,KAAF;AADd;AADI;AAHF,KAAT;AASA,GAxBkE,CA0BnE;;;AACA,SAAOf,MAAM,CAACmB,QAAd;AACA,SAAOnB,MAAM,CAACoB,aAAd;AAEA,SAAOpB,MAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, parse, serialize } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Converts a widget entity record into a block.\n *\n * @param {Object} widget The widget entity record.\n * @return {Object} a block (converted from the entity record).\n */\nexport function transformWidgetToBlock( widget ) {\n\tif ( widget.id_base === 'block' ) {\n\t\tconst parsedBlocks = parse( widget.instance.raw.content, {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( ! parsedBlocks.length ) {\n\t\t\treturn addWidgetIdToBlock(\n\t\t\t\tcreateBlock( 'core/paragraph', {}, [] ),\n\t\t\t\twidget.id\n\t\t\t);\n\t\t}\n\t\treturn addWidgetIdToBlock( parsedBlocks[ 0 ], widget.id );\n\t}\n\n\tlet attributes;\n\tif ( widget._embedded.about[ 0 ].is_multi ) {\n\t\tattributes = {\n\t\t\tidBase: widget.id_base,\n\t\t\tinstance: widget.instance,\n\t\t};\n\t} else {\n\t\tattributes = {\n\t\t\tid: widget.id,\n\t\t};\n\t}\n\n\treturn addWidgetIdToBlock(\n\t\tcreateBlock( 'core/legacy-widget', attributes, [] ),\n\t\twidget.id\n\t);\n}\n\n/**\n * Converts a block to a widget entity record.\n *\n * @param {Object} block The block.\n * @param {Object?} relatedWidget A related widget entity record from the API (optional).\n * @return {Object} the widget object (converted from block).\n */\nexport function transformBlockToWidget( block, relatedWidget = {} ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid: block.attributes.id ?? relatedWidget.id,\n\t\t\tid_base: block.attributes.idBase ?? relatedWidget.id_base,\n\t\t\tinstance: block.attributes.instance ?? relatedWidget.instance,\n\t\t};\n\t} else {\n\t\twidget = {\n\t\t\t...relatedWidget,\n\t\t\tid_base: 'block',\n\t\t\tinstance: {\n\t\t\t\traw: {\n\t\t\t\t\tcontent: serialize( block ),\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\t// Delete read-only properties.\n\tdelete widget.rendered;\n\tdelete widget.rendered_form;\n\n\treturn widget;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-widgets",
3
- "version": "5.11.0",
3
+ "version": "5.12.0",
4
4
  "description": "Widgets Page module for WordPress..",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,31 +27,31 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/api-fetch": "^6.31.0",
31
- "@wordpress/block-editor": "^12.2.0",
32
- "@wordpress/block-library": "^8.11.0",
33
- "@wordpress/blocks": "^12.11.0",
34
- "@wordpress/components": "^25.0.0",
35
- "@wordpress/compose": "^6.11.0",
36
- "@wordpress/core-data": "^6.11.0",
37
- "@wordpress/data": "^9.4.0",
38
- "@wordpress/deprecated": "^3.34.0",
39
- "@wordpress/dom": "^3.34.0",
40
- "@wordpress/element": "^5.11.0",
41
- "@wordpress/hooks": "^3.34.0",
42
- "@wordpress/i18n": "^4.34.0",
43
- "@wordpress/icons": "^9.25.0",
44
- "@wordpress/interface": "^5.11.0",
45
- "@wordpress/keyboard-shortcuts": "^4.11.0",
46
- "@wordpress/keycodes": "^3.34.0",
47
- "@wordpress/media-utils": "^4.25.0",
48
- "@wordpress/notices": "^4.2.0",
49
- "@wordpress/plugins": "^6.2.0",
50
- "@wordpress/preferences": "^3.11.0",
51
- "@wordpress/private-apis": "^0.16.0",
52
- "@wordpress/reusable-blocks": "^4.11.0",
53
- "@wordpress/url": "^3.35.0",
54
- "@wordpress/widgets": "^3.11.0",
30
+ "@wordpress/api-fetch": "^6.32.0",
31
+ "@wordpress/block-editor": "^12.3.0",
32
+ "@wordpress/block-library": "^8.12.0",
33
+ "@wordpress/blocks": "^12.12.0",
34
+ "@wordpress/components": "^25.1.0",
35
+ "@wordpress/compose": "^6.12.0",
36
+ "@wordpress/core-data": "^6.12.0",
37
+ "@wordpress/data": "^9.5.0",
38
+ "@wordpress/deprecated": "^3.35.0",
39
+ "@wordpress/dom": "^3.35.0",
40
+ "@wordpress/element": "^5.12.0",
41
+ "@wordpress/hooks": "^3.35.0",
42
+ "@wordpress/i18n": "^4.35.0",
43
+ "@wordpress/icons": "^9.26.0",
44
+ "@wordpress/interface": "^5.12.0",
45
+ "@wordpress/keyboard-shortcuts": "^4.12.0",
46
+ "@wordpress/keycodes": "^3.35.0",
47
+ "@wordpress/media-utils": "^4.26.0",
48
+ "@wordpress/notices": "^4.3.0",
49
+ "@wordpress/plugins": "^6.3.0",
50
+ "@wordpress/preferences": "^3.12.0",
51
+ "@wordpress/private-apis": "^0.17.0",
52
+ "@wordpress/reusable-blocks": "^4.12.0",
53
+ "@wordpress/url": "^3.36.0",
54
+ "@wordpress/widgets": "^3.12.0",
55
55
  "classnames": "^2.3.1"
56
56
  },
57
57
  "peerDependencies": {
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "c7c79cb11b677adcbf06cf5f8cfb6c5ec1699f19"
64
+ "gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
65
65
  }
@@ -9,6 +9,7 @@ import {
9
9
  useMergeRefs,
10
10
  } from '@wordpress/compose';
11
11
  import { useDispatch } from '@wordpress/data';
12
+ import { useState } from '@wordpress/element';
12
13
  import { __ } from '@wordpress/i18n';
13
14
  import { closeSmall } from '@wordpress/icons';
14
15
  import { ESCAPE } from '@wordpress/keycodes';
@@ -21,9 +22,14 @@ import { store as editWidgetsStore } from '../../store';
21
22
  export default function ListViewSidebar() {
22
23
  const { setIsListViewOpened } = useDispatch( editWidgetsStore );
23
24
 
25
+ // Use internal state instead of a ref to make sure that the component
26
+ // re-renders when the dropZoneElement updates.
27
+ const [ dropZoneElement, setDropZoneElement ] = useState( null );
28
+
24
29
  const focusOnMountRef = useFocusOnMount( 'firstElement' );
25
30
  const headerFocusReturnRef = useFocusReturn();
26
31
  const contentFocusReturnRef = useFocusReturn();
32
+
27
33
  function closeOnEscape( event ) {
28
34
  if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
29
35
  event.preventDefault();
@@ -53,9 +59,10 @@ export default function ListViewSidebar() {
53
59
  ref={ useMergeRefs( [
54
60
  contentFocusReturnRef,
55
61
  focusOnMountRef,
62
+ setDropZoneElement,
56
63
  ] ) }
57
64
  >
58
- <ListView />
65
+ <ListView dropZoneElement={ dropZoneElement } />
59
66
  </div>
60
67
  </div>
61
68
  );
@@ -7,7 +7,7 @@ import classnames from 'classnames';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { useEffect, Platform } from '@wordpress/element';
10
- import { __, sprintf } from '@wordpress/i18n';
10
+ import { isRTL, __, sprintf } from '@wordpress/i18n';
11
11
  import {
12
12
  ComplementaryArea,
13
13
  store as interfaceStore,
@@ -17,7 +17,7 @@ import {
17
17
  store as blockEditorStore,
18
18
  } from '@wordpress/block-editor';
19
19
 
20
- import { cog } from '@wordpress/icons';
20
+ import { drawerLeft, drawerRight } from '@wordpress/icons';
21
21
  import { Button } from '@wordpress/components';
22
22
  import { useSelect, useDispatch } from '@wordpress/data';
23
23
 
@@ -168,7 +168,7 @@ export default function Sidebar() {
168
168
  closeLabel={ __( 'Close Settings' ) }
169
169
  scope="core/edit-widgets"
170
170
  identifier={ currentArea }
171
- icon={ cog }
171
+ icon={ isRTL() ? drawerLeft : drawerRight }
172
172
  isActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }
173
173
  >
174
174
  { currentArea === WIDGET_AREAS_IDENTIFIER && (