@wordpress/edit-widgets 5.16.0 → 5.17.1

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 (178) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/blocks/widget-area/edit/index.js +4 -16
  3. package/build/blocks/widget-area/edit/index.js.map +1 -1
  4. package/build/blocks/widget-area/edit/inner-blocks.js +5 -10
  5. package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  6. package/build/blocks/widget-area/edit/use-is-dragging-within.js +5 -10
  7. package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
  8. package/build/blocks/widget-area/index.js +0 -5
  9. package/build/blocks/widget-area/index.js.map +1 -1
  10. package/build/components/error-boundary/index.js +1 -15
  11. package/build/components/error-boundary/index.js.map +1 -1
  12. package/build/components/header/index.js +9 -32
  13. package/build/components/header/index.js.map +1 -1
  14. package/build/components/header/undo-redo/redo.js +3 -9
  15. package/build/components/header/undo-redo/redo.js.map +1 -1
  16. package/build/components/header/undo-redo/undo.js +3 -9
  17. package/build/components/header/undo-redo/undo.js.map +1 -1
  18. package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
  19. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  20. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -9
  21. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  22. package/build/components/keyboard-shortcut-help-modal/index.js +4 -20
  23. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  24. package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -6
  25. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  26. package/build/components/keyboard-shortcuts/index.js +1 -18
  27. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  28. package/build/components/layout/index.js +2 -19
  29. package/build/components/layout/index.js.map +1 -1
  30. package/build/components/layout/interface.js +5 -21
  31. package/build/components/layout/interface.js.map +1 -1
  32. package/build/components/layout/unsaved-changes-warning.js +0 -6
  33. package/build/components/layout/unsaved-changes-warning.js.map +1 -1
  34. package/build/components/more-menu/index.js +2 -17
  35. package/build/components/more-menu/index.js.map +1 -1
  36. package/build/components/more-menu/tools-more-menu-group.js +1 -5
  37. package/build/components/more-menu/tools-more-menu-group.js.map +1 -1
  38. package/build/components/notices/index.js +1 -6
  39. package/build/components/notices/index.js.map +1 -1
  40. package/build/components/save-button/index.js +1 -7
  41. package/build/components/save-button/index.js.map +1 -1
  42. package/build/components/secondary-sidebar/index.js +1 -10
  43. package/build/components/secondary-sidebar/index.js.map +1 -1
  44. package/build/components/secondary-sidebar/inserter-sidebar.js +1 -11
  45. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  46. package/build/components/secondary-sidebar/list-view-sidebar.js +6 -15
  47. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  48. package/build/components/sidebar/index.js +12 -26
  49. package/build/components/sidebar/index.js.map +1 -1
  50. package/build/components/sidebar/widget-areas.js +1 -12
  51. package/build/components/sidebar/widget-areas.js.map +1 -1
  52. package/build/components/welcome-guide/index.js +3 -12
  53. package/build/components/welcome-guide/index.js.map +1 -1
  54. package/build/components/widget-areas-block-editor-content/index.js +1 -8
  55. package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
  56. package/build/components/widget-areas-block-editor-provider/index.js +8 -23
  57. package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
  58. package/build/constants.js.map +1 -1
  59. package/build/filters/index.js +0 -1
  60. package/build/filters/index.js.map +1 -1
  61. package/build/filters/move-to-widget-area.js +3 -9
  62. package/build/filters/move-to-widget-area.js.map +1 -1
  63. package/build/filters/replace-media-upload.js +1 -3
  64. package/build/filters/replace-media-upload.js.map +1 -1
  65. package/build/hooks/use-last-selected-widget-area.js +5 -13
  66. package/build/hooks/use-last-selected-widget-area.js.map +1 -1
  67. package/build/hooks/use-widget-library-insertion-point.js +6 -14
  68. package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
  69. package/build/index.js +6 -34
  70. package/build/index.js.map +1 -1
  71. package/build/lock-unlock.js +1 -2
  72. package/build/lock-unlock.js.map +1 -1
  73. package/build/store/actions.js +41 -79
  74. package/build/store/actions.js.map +1 -1
  75. package/build/store/constants.js +0 -1
  76. package/build/store/constants.js.map +1 -1
  77. package/build/store/index.js +4 -15
  78. package/build/store/index.js.map +1 -1
  79. package/build/store/reducer.js +4 -16
  80. package/build/store/reducer.js.map +1 -1
  81. package/build/store/resolvers.js +1 -17
  82. package/build/store/resolvers.js.map +1 -1
  83. package/build/store/selectors.js +28 -49
  84. package/build/store/selectors.js.map +1 -1
  85. package/build/store/transformers.js +7 -16
  86. package/build/store/transformers.js.map +1 -1
  87. package/build/store/utils.js +7 -16
  88. package/build/store/utils.js.map +1 -1
  89. package/build-module/blocks/widget-area/edit/index.js +5 -8
  90. package/build-module/blocks/widget-area/edit/index.js.map +1 -1
  91. package/build-module/blocks/widget-area/edit/inner-blocks.js +6 -6
  92. package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  93. package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +6 -9
  94. package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +1 -1
  95. package/build-module/blocks/widget-area/index.js +1 -1
  96. package/build-module/blocks/widget-area/index.js.map +1 -1
  97. package/build-module/components/error-boundary/index.js +0 -9
  98. package/build-module/components/error-boundary/index.js.map +1 -1
  99. package/build-module/components/header/index.js +9 -17
  100. package/build-module/components/header/index.js.map +1 -1
  101. package/build-module/components/header/undo-redo/redo.js +2 -2
  102. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  103. package/build-module/components/header/undo-redo/undo.js +2 -2
  104. package/build-module/components/header/undo-redo/undo.js.map +1 -1
  105. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  106. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -6
  107. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  108. package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -13
  109. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  110. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -5
  111. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  112. package/build-module/components/keyboard-shortcuts/index.js +1 -10
  113. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  114. package/build-module/components/layout/index.js +2 -8
  115. package/build-module/components/layout/index.js.map +1 -1
  116. package/build-module/components/layout/interface.js +5 -9
  117. package/build-module/components/layout/interface.js.map +1 -1
  118. package/build-module/components/layout/unsaved-changes-warning.js +2 -3
  119. package/build-module/components/layout/unsaved-changes-warning.js.map +1 -1
  120. package/build-module/components/more-menu/index.js +2 -6
  121. package/build-module/components/more-menu/index.js.map +1 -1
  122. package/build-module/components/more-menu/tools-more-menu-group.js +0 -3
  123. package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -1
  124. package/build-module/components/notices/index.js +0 -3
  125. package/build-module/components/notices/index.js.map +1 -1
  126. package/build-module/components/save-button/index.js +1 -4
  127. package/build-module/components/save-button/index.js.map +1 -1
  128. package/build-module/components/secondary-sidebar/index.js +1 -6
  129. package/build-module/components/secondary-sidebar/index.js.map +1 -1
  130. package/build-module/components/secondary-sidebar/inserter-sidebar.js +1 -2
  131. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  132. package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -7
  133. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  134. package/build-module/components/sidebar/index.js +13 -18
  135. package/build-module/components/sidebar/index.js.map +1 -1
  136. package/build-module/components/sidebar/widget-areas.js +1 -4
  137. package/build-module/components/sidebar/widget-areas.js.map +1 -1
  138. package/build-module/components/welcome-guide/index.js +3 -7
  139. package/build-module/components/welcome-guide/index.js.map +1 -1
  140. package/build-module/components/widget-areas-block-editor-content/index.js +1 -2
  141. package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
  142. package/build-module/components/widget-areas-block-editor-provider/index.js +8 -7
  143. package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
  144. package/build-module/constants.js.map +1 -1
  145. package/build-module/filters/index.js.map +1 -1
  146. package/build-module/filters/move-to-widget-area.js +4 -4
  147. package/build-module/filters/move-to-widget-area.js.map +1 -1
  148. package/build-module/filters/replace-media-upload.js +0 -2
  149. package/build-module/filters/replace-media-upload.js.map +1 -1
  150. package/build-module/hooks/use-last-selected-widget-area.js +7 -9
  151. package/build-module/hooks/use-last-selected-widget-area.js.map +1 -1
  152. package/build-module/hooks/use-widget-library-insertion-point.js +6 -10
  153. package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
  154. package/build-module/index.js +8 -20
  155. package/build-module/index.js.map +1 -1
  156. package/build-module/lock-unlock.js.map +1 -1
  157. package/build-module/store/actions.js +43 -56
  158. package/build-module/store/actions.js.map +1 -1
  159. package/build-module/store/constants.js.map +1 -1
  160. package/build-module/store/index.js +6 -6
  161. package/build-module/store/index.js.map +1 -1
  162. package/build-module/store/reducer.js +5 -11
  163. package/build-module/store/reducer.js.map +1 -1
  164. package/build-module/store/resolvers.js +3 -10
  165. package/build-module/store/resolvers.js.map +1 -1
  166. package/build-module/store/selectors.js +29 -38
  167. package/build-module/store/selectors.js.map +1 -1
  168. package/build-module/store/transformers.js +8 -13
  169. package/build-module/store/transformers.js.map +1 -1
  170. package/build-module/store/utils.js +7 -7
  171. package/build-module/store/utils.js.map +1 -1
  172. package/build-style/style-rtl.css +14 -11
  173. package/build-style/style.css +14 -11
  174. package/package.json +28 -27
  175. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
  176. package/src/components/widget-areas-block-editor-provider/index.js +3 -3
  177. package/src/index.js +0 -1
  178. package/src/store/selectors.js +10 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"names":["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":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CAAiCC,MAAjC,EAA0C;AAChD,MAAKA,MAAM,CAACC,OAAP,KAAmB,OAAxB,EAAkC;AACjC,UAAMC,YAAY,GAAG,mBAAOF,MAAM,CAACG,QAAP,CAAgBC,GAAhB,CAAoBC,OAA3B,EAAoC;AACxDC,MAAAA,mBAAmB,EAAE;AADmC,KAApC,CAArB;;AAGA,QAAK,CAAEJ,YAAY,CAACK,MAApB,EAA6B;AAC5B,aAAO,iCACN,yBAAa,gBAAb,EAA+B,EAA/B,EAAmC,EAAnC,CADM,EAENP,MAAM,CAACQ,EAFD,CAAP;AAIA;;AACD,WAAO,iCAAoBN,YAAY,CAAE,CAAF,CAAhC,EAAuCF,MAAM,CAACQ,EAA9C,CAAP;AACA;;AAED,MAAIC,UAAJ;;AACA,MAAKT,MAAM,CAACU,SAAP,CAAiBC,KAAjB,CAAwB,CAAxB,EAA4BC,QAAjC,EAA4C;AAC3CH,IAAAA,UAAU,GAAG;AACZI,MAAAA,MAAM,EAAEb,MAAM,CAACC,OADH;AAEZE,MAAAA,QAAQ,EAAEH,MAAM,CAACG;AAFL,KAAb;AAIA,GALD,MAKO;AACNM,IAAAA,UAAU,GAAG;AACZD,MAAAA,EAAE,EAAER,MAAM,CAACQ;AADC,KAAb;AAGA;;AAED,SAAO,iCACN,yBAAa,oBAAb,EAAmCC,UAAnC,EAA+C,EAA/C,CADM,EAENT,MAAM,CAACQ,EAFD,CAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,sBAAT,CAAiCC,KAAjC,EAAwCC,aAAa,GAAG,EAAxD,EAA6D;AACnE,MAAIhB,MAAJ;AAEA,QAAMiB,wBAAwB,GAC7BF,KAAK,CAACG,IAAN,KAAe,oBAAf,KACEH,KAAK,CAACN,UAAN,CAAiBD,EAAjB,IAAuBO,KAAK,CAACN,UAAN,CAAiBN,QAD1C,CADD;;AAIA,MAAKc,wBAAL,EAAgC;AAAA;;AAC/BjB,IAAAA,MAAM,GAAG,EACR,GAAGgB,aADK;AAERR,MAAAA,EAAE,0BAAEO,KAAK,CAACN,UAAN,CAAiBD,EAAnB,uEAAyBQ,aAAa,CAACR,EAFjC;AAGRP,MAAAA,OAAO,2BAAEc,KAAK,CAACN,UAAN,CAAiBI,MAAnB,yEAA6BG,aAAa,CAACf,OAH1C;AAIRE,MAAAA,QAAQ,2BAAEY,KAAK,CAACN,UAAN,CAAiBN,QAAnB,yEAA+Ba,aAAa,CAACb;AAJ7C,KAAT;AAMA,GAPD,MAOO;AACNH,IAAAA,MAAM,GAAG,EACR,GAAGgB,aADK;AAERf,MAAAA,OAAO,EAAE,OAFD;AAGRE,MAAAA,QAAQ,EAAE;AACTC,QAAAA,GAAG,EAAE;AACJC,UAAAA,OAAO,EAAE,uBAAWU,KAAX;AADL;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,"names":["_blocks","require","_widgets","transformWidgetToBlock","widget","id_base","parsedBlocks","parse","instance","raw","content","__unstableSkipAutop","length","addWidgetIdToBlock","createBlock","id","attributes","_embedded","about","is_multi","idBase","transformBlockToWidget","block","relatedWidget","isValidLegacyWidgetBlock","name","_block$attributes$id","_block$attributes$idB","_block$attributes$ins","serialize","rendered","rendered_form"],"sources":["@wordpress/edit-widgets/src/store/transformers.js"],"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"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sBAAsBA,CAAEC,MAAM,EAAG;EAChD,IAAKA,MAAM,CAACC,OAAO,KAAK,OAAO,EAAG;IACjC,MAAMC,YAAY,GAAG,IAAAC,aAAK,EAAEH,MAAM,CAACI,QAAQ,CAACC,GAAG,CAACC,OAAO,EAAE;MACxDC,mBAAmB,EAAE;IACtB,CAAE,CAAC;IACH,IAAK,CAAEL,YAAY,CAACM,MAAM,EAAG;MAC5B,OAAO,IAAAC,2BAAkB,EACxB,IAAAC,mBAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAG,CAAC,EACvCV,MAAM,CAACW,EACR,CAAC;IACF;IACA,OAAO,IAAAF,2BAAkB,EAAEP,YAAY,CAAE,CAAC,CAAE,EAAEF,MAAM,CAACW,EAAG,CAAC;EAC1D;EAEA,IAAIC,UAAU;EACd,IAAKZ,MAAM,CAACa,SAAS,CAACC,KAAK,CAAE,CAAC,CAAE,CAACC,QAAQ,EAAG;IAC3CH,UAAU,GAAG;MACZI,MAAM,EAAEhB,MAAM,CAACC,OAAO;MACtBG,QAAQ,EAAEJ,MAAM,CAACI;IAClB,CAAC;EACF,CAAC,MAAM;IACNQ,UAAU,GAAG;MACZD,EAAE,EAAEX,MAAM,CAACW;IACZ,CAAC;EACF;EAEA,OAAO,IAAAF,2BAAkB,EACxB,IAAAC,mBAAW,EAAE,oBAAoB,EAAEE,UAAU,EAAE,EAAG,CAAC,EACnDZ,MAAM,CAACW,EACR,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,sBAAsBA,CAAEC,KAAK,EAAEC,aAAa,GAAG,CAAC,CAAC,EAAG;EACnE,IAAInB,MAAM;EAEV,MAAMoB,wBAAwB,GAC7BF,KAAK,CAACG,IAAI,KAAK,oBAAoB,KACjCH,KAAK,CAACN,UAAU,CAACD,EAAE,IAAIO,KAAK,CAACN,UAAU,CAACR,QAAQ,CAAE;EAErD,IAAKgB,wBAAwB,EAAG;IAAA,IAAAE,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA;IAC/BxB,MAAM,GAAG;MACR,GAAGmB,aAAa;MAChBR,EAAE,GAAAW,oBAAA,GAAEJ,KAAK,CAACN,UAAU,CAACD,EAAE,cAAAW,oBAAA,cAAAA,oBAAA,GAAIH,aAAa,CAACR,EAAE;MAC3CV,OAAO,GAAAsB,qBAAA,GAAEL,KAAK,CAACN,UAAU,CAACI,MAAM,cAAAO,qBAAA,cAAAA,qBAAA,GAAIJ,aAAa,CAAClB,OAAO;MACzDG,QAAQ,GAAAoB,qBAAA,GAAEN,KAAK,CAACN,UAAU,CAACR,QAAQ,cAAAoB,qBAAA,cAAAA,qBAAA,GAAIL,aAAa,CAACf;IACtD,CAAC;EACF,CAAC,MAAM;IACNJ,MAAM,GAAG;MACR,GAAGmB,aAAa;MAChBlB,OAAO,EAAE,OAAO;MAChBG,QAAQ,EAAE;QACTC,GAAG,EAAE;UACJC,OAAO,EAAE,IAAAmB,iBAAS,EAAEP,KAAM;QAC3B;MACD;IACD,CAAC;EACF;;EAEA;EACA,OAAOlB,MAAM,CAAC0B,QAAQ;EACtB,OAAO1B,MAAM,CAAC2B,aAAa;EAE3B,OAAO3B,MAAM;AACd"}
@@ -7,76 +7,70 @@ exports.buildWidgetAreasPostId = exports.buildWidgetAreaPostId = exports.WIDGET_
7
7
  exports.buildWidgetAreasQuery = buildWidgetAreasQuery;
8
8
  exports.buildWidgetsQuery = buildWidgetsQuery;
9
9
  exports.createStubPost = void 0;
10
-
11
10
  /**
12
11
  * "Kind" of the navigation post.
13
12
  *
14
13
  * @type {string}
15
14
  */
16
15
  const KIND = 'root';
16
+
17
17
  /**
18
18
  * "post type" of the navigation post.
19
19
  *
20
20
  * @type {string}
21
21
  */
22
-
23
22
  exports.KIND = KIND;
24
23
  const WIDGET_AREA_ENTITY_TYPE = 'sidebar';
24
+
25
25
  /**
26
26
  * "post type" of the widget area post.
27
27
  *
28
28
  * @type {string}
29
29
  */
30
-
31
30
  exports.WIDGET_AREA_ENTITY_TYPE = WIDGET_AREA_ENTITY_TYPE;
32
31
  const POST_TYPE = 'postType';
32
+
33
33
  /**
34
34
  * Builds an ID for a new widget area post.
35
35
  *
36
36
  * @param {number} widgetAreaId Widget area id.
37
37
  * @return {string} An ID.
38
38
  */
39
-
40
39
  exports.POST_TYPE = POST_TYPE;
41
-
42
40
  const buildWidgetAreaPostId = widgetAreaId => `widget-area-${widgetAreaId}`;
41
+
43
42
  /**
44
43
  * Builds an ID for a global widget areas post.
45
44
  *
46
45
  * @return {string} An ID.
47
46
  */
48
-
49
-
50
47
  exports.buildWidgetAreaPostId = buildWidgetAreaPostId;
51
-
52
48
  const buildWidgetAreasPostId = () => `widget-areas`;
49
+
53
50
  /**
54
51
  * Builds a query to resolve sidebars.
55
52
  *
56
53
  * @return {Object} Query.
57
54
  */
58
-
59
-
60
55
  exports.buildWidgetAreasPostId = buildWidgetAreasPostId;
61
-
62
56
  function buildWidgetAreasQuery() {
63
57
  return {
64
58
  per_page: -1
65
59
  };
66
60
  }
61
+
67
62
  /**
68
63
  * Builds a query to resolve widgets.
69
64
  *
70
65
  * @return {Object} Query.
71
66
  */
72
-
73
-
74
67
  function buildWidgetsQuery() {
75
68
  return {
76
69
  per_page: -1,
77
70
  _embed: 'about'
78
71
  };
79
72
  }
73
+
80
74
  /**
81
75
  * Creates a stub post with given id and set of blocks. Used as a governing entity records
82
76
  * for all widget areas.
@@ -85,8 +79,6 @@ function buildWidgetsQuery() {
85
79
  * @param {Array} blocks The list of blocks.
86
80
  * @return {Object} A stub post object formatted in compliance with the data layer.
87
81
  */
88
-
89
-
90
82
  const createStubPost = (id, blocks) => ({
91
83
  id,
92
84
  slug: id,
@@ -97,6 +89,5 @@ const createStubPost = (id, blocks) => ({
97
89
  widgetAreaId: id
98
90
  }
99
91
  });
100
-
101
92
  exports.createStubPost = createStubPost;
102
93
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/utils.js"],"names":["KIND","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","widgetAreaId","buildWidgetAreasPostId","buildWidgetAreasQuery","per_page","buildWidgetsQuery","_embed","createStubPost","id","blocks","slug","status","type","meta"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAI,GAAG,MAAb;AAEP;AACA;AACA;AACA;AACA;;;AACO,MAAMC,uBAAuB,GAAG,SAAhC;AAEP;AACA;AACA;AACA;AACA;;;AACO,MAAMC,SAAS,GAAG,UAAlB;AAEP;AACA;AACA;AACA;AACA;AACA;;;;AACO,MAAMC,qBAAqB,GAAKC,YAAF,IACnC,eAAeA,YAAc,EADxB;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,sBAAsB,GAAG,MAAO,cAAtC;AAEP;AACA;AACA;AACA;AACA;;;;;AACO,SAASC,qBAAT,GAAiC;AACvC,SAAO;AACNC,IAAAA,QAAQ,EAAE,CAAC;AADL,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,iBAAT,GAA6B;AACnC,SAAO;AACND,IAAAA,QAAQ,EAAE,CAAC,CADL;AAENE,IAAAA,MAAM,EAAE;AAFF,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,cAAc,GAAG,CAAEC,EAAF,EAAMC,MAAN,MAAoB;AACjDD,EAAAA,EADiD;AAEjDE,EAAAA,IAAI,EAAEF,EAF2C;AAGjDG,EAAAA,MAAM,EAAE,OAHyC;AAIjDC,EAAAA,IAAI,EAAE,MAJ2C;AAKjDH,EAAAA,MALiD;AAMjDI,EAAAA,IAAI,EAAE;AACLZ,IAAAA,YAAY,EAAEO;AADT;AAN2C,CAApB,CAAvB","sourcesContent":["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"]}
1
+ {"version":3,"names":["KIND","exports","WIDGET_AREA_ENTITY_TYPE","POST_TYPE","buildWidgetAreaPostId","widgetAreaId","buildWidgetAreasPostId","buildWidgetAreasQuery","per_page","buildWidgetsQuery","_embed","createStubPost","id","blocks","slug","status","type","meta"],"sources":["@wordpress/edit-widgets/src/store/utils.js"],"sourcesContent":["/**\n * \"Kind\" of the navigation post.\n *\n * @type {string}\n */\nexport const KIND = 'root';\n\n/**\n * \"post type\" of the navigation post.\n *\n * @type {string}\n */\nexport const WIDGET_AREA_ENTITY_TYPE = 'sidebar';\n\n/**\n * \"post type\" of the widget area post.\n *\n * @type {string}\n */\nexport const POST_TYPE = 'postType';\n\n/**\n * Builds an ID for a new widget area post.\n *\n * @param {number} widgetAreaId Widget area id.\n * @return {string} An ID.\n */\nexport const buildWidgetAreaPostId = ( widgetAreaId ) =>\n\t`widget-area-${ widgetAreaId }`;\n\n/**\n * Builds an ID for a global widget areas post.\n *\n * @return {string} An ID.\n */\nexport const buildWidgetAreasPostId = () => `widget-areas`;\n\n/**\n * Builds a query to resolve sidebars.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetAreasQuery() {\n\treturn {\n\t\tper_page: -1,\n\t};\n}\n\n/**\n * Builds a query to resolve widgets.\n *\n * @return {Object} Query.\n */\nexport function buildWidgetsQuery() {\n\treturn {\n\t\tper_page: -1,\n\t\t_embed: 'about',\n\t};\n}\n\n/**\n * Creates a stub post with given id and set of blocks. Used as a governing entity records\n * for all widget areas.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks The list of blocks.\n * @return {Object} A stub post object formatted in compliance with the data layer.\n */\nexport const createStubPost = ( id, blocks ) => ( {\n\tid,\n\tslug: id,\n\tstatus: 'draft',\n\ttype: 'page',\n\tblocks,\n\tmeta: {\n\t\twidgetAreaId: id,\n\t},\n} );\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAI,GAAG,MAAM;;AAE1B;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAD,IAAA,GAAAA,IAAA;AAKO,MAAME,uBAAuB,GAAG,SAAS;;AAEhD;AACA;AACA;AACA;AACA;AAJAD,OAAA,CAAAC,uBAAA,GAAAA,uBAAA;AAKO,MAAMC,SAAS,GAAG,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AALAF,OAAA,CAAAE,SAAA,GAAAA,SAAA;AAMO,MAAMC,qBAAqB,GAAKC,YAAY,IACjD,eAAeA,YAAc,EAAC;;AAEhC;AACA;AACA;AACA;AACA;AAJAJ,OAAA,CAAAG,qBAAA,GAAAA,qBAAA;AAKO,MAAME,sBAAsB,GAAGA,CAAA,KAAO,cAAa;;AAE1D;AACA;AACA;AACA;AACA;AAJAL,OAAA,CAAAK,sBAAA,GAAAA,sBAAA;AAKO,SAASC,qBAAqBA,CAAA,EAAG;EACvC,OAAO;IACNC,QAAQ,EAAE,CAAC;EACZ,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAAA,EAAG;EACnC,OAAO;IACND,QAAQ,EAAE,CAAC,CAAC;IACZE,MAAM,EAAE;EACT,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAGA,CAAEC,EAAE,EAAEC,MAAM,MAAQ;EACjDD,EAAE;EACFE,IAAI,EAAEF,EAAE;EACRG,MAAM,EAAE,OAAO;EACfC,IAAI,EAAE,MAAM;EACZH,MAAM;EACNI,IAAI,EAAE;IACLZ,YAAY,EAAEO;EACf;AACD,CAAC,CAAE;AAACX,OAAA,CAAAU,cAAA,GAAAA,cAAA"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -7,13 +6,14 @@ import { useEffect, useState, useCallback, useRef } from '@wordpress/element';
7
6
  import { useSelect, useDispatch } from '@wordpress/data';
8
7
  import { EntityProvider } from '@wordpress/core-data';
9
8
  import { __unstableDisclosureContent as DisclosureContent, Panel, PanelBody } from '@wordpress/components';
9
+
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
13
-
14
13
  import WidgetAreaInnerBlocks from './inner-blocks';
15
14
  import { store as editWidgetsStore } from '../../../store';
16
15
  import useIsDraggingWithin from './use-is-dragging-within';
16
+
17
17
  /** @typedef {import('@wordpress/element').RefObject} RefObject */
18
18
 
19
19
  export default function WidgetAreaEdit({
@@ -38,7 +38,6 @@ export default function WidgetAreaEdit({
38
38
  setOpenedWhileDragging(false);
39
39
  return;
40
40
  }
41
-
42
41
  if (isDraggingWithin && !isOpen) {
43
42
  setOpen(true);
44
43
  setOpenedWhileDragging(true);
@@ -58,7 +57,8 @@ export default function WidgetAreaEdit({
58
57
  scrollAfterOpen: !isDragging
59
58
  }, ({
60
59
  opened
61
- }) => // This is required to ensure LegacyWidget blocks are not
60
+ }) =>
61
+ // This is required to ensure LegacyWidget blocks are not
62
62
  // unmounted when the panel is collapsed. Unmounting legacy
63
63
  // widgets may have unintended consequences (e.g. TinyMCE
64
64
  // not being properly reinitialized)
@@ -73,6 +73,7 @@ export default function WidgetAreaEdit({
73
73
  id: id
74
74
  })))));
75
75
  }
76
+
76
77
  /**
77
78
  * A React hook to determine if dragging is active.
78
79
  *
@@ -80,22 +81,18 @@ export default function WidgetAreaEdit({
80
81
  *
81
82
  * @return {boolean} Is dragging within the entire document.
82
83
  */
83
-
84
84
  const useIsDragging = elementRef => {
85
85
  const [isDragging, setIsDragging] = useState(false);
86
86
  useEffect(() => {
87
87
  const {
88
88
  ownerDocument
89
89
  } = elementRef.current;
90
-
91
90
  function handleDragStart() {
92
91
  setIsDragging(true);
93
92
  }
94
-
95
93
  function handleDragEnd() {
96
94
  setIsDragging(false);
97
95
  }
98
-
99
96
  ownerDocument.addEventListener('dragstart', handleDragStart);
100
97
  ownerDocument.addEventListener('dragend', handleDragEnd);
101
98
  return () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","opened","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,WAA9B,EAA2CC,MAA3C,QAAyD,oBAAzD;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,cAAT,QAA+B,sBAA/B;AACA,SACCC,2BAA2B,IAAIC,iBADhC,EAECC,KAFD,EAGCC,SAHD,QAIO,uBAJP;AAMA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,gBAAlC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA;;AAEA,eAAe,SAASC,cAAT,CAAyB;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,SAFuC;AAGvCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN;AAH2B,CAAzB,EAIX;AACH,QAAMC,MAAM,GAAGjB,SAAS,CACrBkB,MAAF,IACCA,MAAM,CAAET,gBAAF,CAAN,CAA2BU,mBAA3B,CAAgDP,QAAhD,CAFsB,EAGvB,CAAEA,QAAF,CAHuB,CAAxB;AAKA,QAAM;AAAEQ,IAAAA;AAAF,MAA0BnB,WAAW,CAAEQ,gBAAF,CAA3C;AAEA,QAAMY,OAAO,GAAGtB,MAAM,EAAtB;AACA,QAAMuB,OAAO,GAAGxB,WAAW,CACxByB,SAAF,IAAiBH,mBAAmB,CAAER,QAAF,EAAYW,SAAZ,CADV,EAE1B,CAAEX,QAAF,CAF0B,CAA3B;AAIA,QAAMY,UAAU,GAAGC,aAAa,CAAEJ,OAAF,CAAh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D;AA+BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMU,aAAa,GAAKK,UAAF,IAAkB;AACvC,QAAM,CAAEN,UAAF,EAAcO,aAAd,IAAgClC,QAAQ,CAAE,KAAF,CAA9C;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAM;AAAEoC,MAAAA;AAAF,QAAoBF,UAAU,CAACG,OAArC;;AAEA,aAASC,eAAT,GAA2B;AAC1BH,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;;AAED,aAASI,aAAT,GAAyB;AACxBJ,MAAAA,aAAa,CAAE,KAAF,CAAb;AACA;;AAEDC,IAAAA,aAAa,CAACI,gBAAd,CAAgC,WAAhC,EAA6CF,eAA7C;AACAF,IAAAA,aAAa,CAACI,gBAAd,CAAgC,SAAhC,EAA2CD,aAA3C;AAEA,WAAO,MAAM;AACZH,MAAAA,aAAa,CAACK,mBAAd,CAAmC,WAAnC,EAAgDH,eAAhD;AACAF,MAAAA,aAAa,CAACK,mBAAd,CAAmC,SAAnC,EAA8CF,aAA9C;AACA,KAHD;AAIA,GAlBQ,EAkBN,EAlBM,CAAT;AAoBA,SAAOX,UAAP;AACA,CAxBD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"]}
1
+ {"version":3,"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","createElement","ref","title","opened","onToggle","scrollAfterOpen","visible","kind","type","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAC7E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,sBAAsB;AACrD,S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,EAAED,aAAc,CAAC;IAE1D,OAAO,MAAM;MACZH,aAAa,CAACK,mBAAmB,CAAE,WAAW,EAAEH,eAAgB,CAAC;MACjEF,aAAa,CAACK,mBAAmB,CAAE,SAAS,EAAEF,aAAc,CAAC;IAC9D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OAAOnB,UAAU;AAClB,CAAC"}
@@ -1,20 +1,19 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * External dependencies
5
4
  */
6
5
  import classnames from 'classnames';
6
+
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
-
11
10
  import { useEntityBlockEditor } from '@wordpress/core-data';
12
11
  import { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';
13
12
  import { useRef } from '@wordpress/element';
13
+
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
-
18
17
  import useIsDraggingWithin from './use-is-dragging-within';
19
18
  export default function WidgetAreaInnerBlocks({
20
19
  id
@@ -22,8 +21,8 @@ export default function WidgetAreaInnerBlocks({
22
21
  const [blocks, onInput, onChange] = useEntityBlockEditor('root', 'postType');
23
22
  const innerBlocksRef = useRef();
24
23
  const isDraggingWithinInnerBlocks = useIsDraggingWithin(innerBlocksRef);
25
- const shouldHighlightDropZone = isDraggingWithinInnerBlocks; // Using the experimental hook so that we can control the className of the element.
26
-
24
+ const shouldHighlightDropZone = isDraggingWithinInnerBlocks;
25
+ // Using the experimental hook so that we can control the className of the element.
27
26
  const innerBlocksProps = useInnerBlocksProps({
28
27
  ref: innerBlocksRef
29
28
  }, {
@@ -38,7 +37,8 @@ export default function WidgetAreaInnerBlocks({
38
37
  className: classnames('wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper', {
39
38
  'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone
40
39
  })
41
- }, createElement("div", { ...innerBlocksProps
40
+ }, createElement("div", {
41
+ ...innerBlocksProps
42
42
  }));
43
43
  }
44
44
  //# sourceMappingURL=inner-blocks.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js"],"names":["classnames","useEntityBlockEditor","InnerBlocks","useInnerBlocksProps","useRef","useIsDraggingWithin","WidgetAreaInnerBlocks","id","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","ButtonBlockAppender"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SAASC,WAAT,EAAsBC,mBAAtB,QAAiD,yBAAjD;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA,eAAe,SAASC,qBAAT,CAAgC;AAAEC,EAAAA;AAAF,CAAhC,EAAyC;AACvD,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCT,oBAAoB,CACzD,MADyD,EAEzD,UAFyD,CAA1D;AAIA,QAAMU,cAAc,GAAGP,MAAM,EAA7B;AACA,QAAMQ,2BAA2B,GAAGP,mBAAmB,CAAEM,cAAF,CAAvD;AACA,QAAME,uBAAuB,GAAGD,2BAAhC,CAPuD,CAQvD;;AACA,QAAME,gBAAgB,GAAGX,mBAAmB,CAC3C;AAAEY,IAAAA,GAAG,EAAEJ;AAAP,GAD2C,EAE3C;AACCK,IAAAA,KAAK,EAAER,MADR;AAECC,IAAAA,OAFD;AAGCC,IAAAA,QAHD;AAICO,IAAAA,YAAY,EAAE,KAJf;AAKCC,IAAAA,cAAc,EAAEhB,WAAW,CAACiB;AAL7B,GAF2C,CAA5C;AAWA,SACC;AACC,2BAAsBZ,EADvB;AAEC,IAAA,SAAS,EAAGP,UAAU,CACrB,oFADqB,EAErB;AACC,mDACCa;AAFF,KAFqB;AAFvB,KAUC,0BAAUC;AAAV,IAVD,CADD;AAcA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ classnames(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"names":["classnames","useEntityBlockEditor","InnerBlocks","useInnerBlocksProps","useRef","useIsDraggingWithin","WidgetAreaInnerBlocks","id","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","ButtonBlockAppender","createElement","className"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport { InnerBlocks, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ classnames(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone':\n\t\t\t\t\t\tshouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,oBAAoB,QAAQ,sBAAsB;AAC3D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC1E,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,0BAA0B;AAE1D,eAAe,SAASC,qBAAqBA,CAAE;EAAEC;AAAG,CAAC,EAAG;EACvD,MAAM,CAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,CAAE,GAAGT,oBAAoB,CACzD,MAAM,EACN,UACD,CAAC;EACD,MAAMU,cAAc,GAAGP,MAAM,CAAC,CAAC;EAC/B,MAAMQ,2BAA2B,GAAGP,mBAAmB,CAAEM,cAAe,CAAC;EACzE,MAAME,uBAAuB,GAAGD,2BAA2B;EAC3D;EACA,MAAME,gBAAgB,GAAGX,mBAAmB,CAC3C;IAAEY,GAAG,EAAEJ;EAAe,CAAC,EACvB;IACCK,KAAK,EAAER,MAAM;IACbC,OAAO;IACPC,QAAQ;IACRO,YAAY,EAAE,KAAK;IACnBC,cAAc,EAAEhB,WAAW,CAACiB;EAC7B,CACD,CAAC;EAED,OACCC,aAAA;IACC,uBAAsBb,EAAI;IAC1Bc,SAAS,EAAGrB,UAAU,CACrB,oFAAoF,EACpF;MACC,2CAA2C,EAC1Ca;IACF,CACD;EAAG,GAEHO,aAAA;IAAA,GAAUN;EAAgB,CAAI,CAC1B,CAAC;AAER"}
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useState, useEffect } from '@wordpress/element';
5
+
5
6
  /** @typedef {import('@wordpress/element').RefObject} RefObject */
6
7
 
7
8
  /**
@@ -11,24 +12,21 @@ import { useState, useEffect } from '@wordpress/element';
11
12
  *
12
13
  * @return {boolean} Is dragging within the target element.
13
14
  */
14
-
15
15
  const useIsDraggingWithin = elementRef => {
16
16
  const [isDraggingWithin, setIsDraggingWithin] = useState(false);
17
17
  useEffect(() => {
18
18
  const {
19
19
  ownerDocument
20
20
  } = elementRef.current;
21
-
22
21
  function handleDragStart(event) {
23
22
  // Check the first time when the dragging starts.
24
23
  handleDragEnter(event);
25
- } // Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.
26
-
24
+ }
27
25
 
26
+ // Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.
28
27
  function handleDragEnd() {
29
28
  setIsDraggingWithin(false);
30
29
  }
31
-
32
30
  function handleDragEnter(event) {
33
31
  // Check if the current target is inside the item element.
34
32
  if (elementRef.current.contains(event.target)) {
@@ -36,10 +34,10 @@ const useIsDraggingWithin = elementRef => {
36
34
  } else {
37
35
  setIsDraggingWithin(false);
38
36
  }
39
- } // Bind these events to the document to catch all drag events.
40
- // Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.
41
-
37
+ }
42
38
 
39
+ // Bind these events to the document to catch all drag events.
40
+ // Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.
43
41
  ownerDocument.addEventListener('dragstart', handleDragStart);
44
42
  ownerDocument.addEventListener('dragend', handleDragEnd);
45
43
  ownerDocument.addEventListener('dragenter', handleDragEnter);
@@ -51,6 +49,5 @@ const useIsDraggingWithin = elementRef => {
51
49
  }, []);
52
50
  return isDraggingWithin;
53
51
  };
54
-
55
52
  export default useIsDraggingWithin;
56
53
  //# sourceMappingURL=use-is-dragging-within.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/use-is-dragging-within.js"],"names":["useState","useEffect","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAKC,UAAF,IAAkB;AAC7C,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4CL,QAAQ,CAAE,KAAF,CAA1D;AAEAC,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAM;AAAEK,MAAAA;AAAF,QAAoBH,UAAU,CAACI,OAArC;;AAEA,aAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACjC;AACAC,MAAAA,eAAe,CAAED,KAAF,CAAf;AACA,KANe,CAQhB;;;AACA,aAASE,aAAT,GAAyB;AACxBN,MAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;;AAED,aAASK,eAAT,CAA0BD,KAA1B,EAAkC;AACjC;AACA,UAAKN,UAAU,CAACI,OAAX,CAAmBK,QAAnB,CAA6BH,KAAK,CAACI,MAAnC,CAAL,EAAmD;AAClDR,QAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA,OAFD,MAEO;AACNA,QAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;AACD,KApBe,CAsBhB;AACA;;;AACAC,IAAAA,aAAa,CAACQ,gBAAd,CAAgC,WAAhC,EAA6CN,eAA7C;AACAF,IAAAA,aAAa,CAACQ,gBAAd,CAAgC,SAAhC,EAA2CH,aAA3C;AACAL,IAAAA,aAAa,CAACQ,gBAAd,CAAgC,WAAhC,EAA6CJ,eAA7C;AAEA,WAAO,MAAM;AACZJ,MAAAA,aAAa,CAACS,mBAAd,CAAmC,WAAnC,EAAgDP,eAAhD;AACAF,MAAAA,aAAa,CAACS,mBAAd,CAAmC,SAAnC,EAA8CJ,aAA9C;AACAL,MAAAA,aAAa,CAACS,mBAAd,CAAmC,WAAnC,EAAgDL,eAAhD;AACA,KAJD;AAKA,GAjCQ,EAiCN,EAjCM,CAAT;AAmCA,SAAON,gBAAP;AACA,CAvCD;;AAyCA,eAAeF,mBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"]}
1
+ {"version":3,"names":["useState","useEffect","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/use-is-dragging-within.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nexport default useIsDraggingWithin;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAExD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAKC,UAAU,IAAM;EAC7C,MAAM,CAAEC,gBAAgB,EAAEC,mBAAmB,CAAE,GAAGL,QAAQ,CAAE,KAAM,CAAC;EAEnEC,SAAS,CAAE,MAAM;IAChB,MAAM;MAAEK;IAAc,CAAC,GAAGH,UAAU,CAACI,OAAO;IAE5C,SAASC,eAAeA,CAAEC,KAAK,EAAG;MACjC;MACAC,eAAe,CAAED,KAAM,CAAC;IACzB;;IAEA;IACA,SAASE,aAAaA,CAAA,EAAG;MACxBN,mBAAmB,CAAE,KAAM,CAAC;IAC7B;IAEA,SAASK,eAAeA,CAAED,KAAK,EAAG;MACjC;MACA,IAAKN,UAAU,CAACI,OAAO,CAACK,QAAQ,CAAEH,KAAK,CAACI,MAAO,CAAC,EAAG;QAClDR,mBAAmB,CAAE,IAAK,CAAC;MAC5B,CAAC,MAAM;QACNA,mBAAmB,CAAE,KAAM,CAAC;MAC7B;IACD;;IAEA;IACA;IACAC,aAAa,CAACQ,gBAAgB,CAAE,WAAW,EAAEN,eAAgB,CAAC;IAC9DF,aAAa,CAACQ,gBAAgB,CAAE,SAAS,EAAEH,aAAc,CAAC;IAC1DL,aAAa,CAACQ,gBAAgB,CAAE,WAAW,EAAEJ,eAAgB,CAAC;IAE9D,OAAO,MAAM;MACZJ,aAAa,CAACS,mBAAmB,CAAE,WAAW,EAAEP,eAAgB,CAAC;MACjEF,aAAa,CAACS,mBAAmB,CAAE,SAAS,EAAEJ,aAAc,CAAC;MAC7DL,aAAa,CAACS,mBAAmB,CAAE,WAAW,EAAEL,eAAgB,CAAC;IAClE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OAAON,gBAAgB;AACxB,CAAC;AAED,eAAeF,mBAAmB"}
@@ -2,10 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  const metadata = {
10
10
  name: "core/widget-area",
11
11
  category: "widgets",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"names":["__","edit","name","metadata","settings","title","description","__experimentalLabel","label"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBC,EAAAA,KAAK,EAAEL,EAAE,CAAE,aAAF,CADc;AAEvBM,EAAAA,WAAW,EAAEN,EAAE,CAAE,0BAAF,CAFQ;AAGvBO,EAAAA,mBAAmB,EAAE,CAAE;AAAEL,IAAAA,IAAI,EAAEM;AAAR,GAAF,KAAuBA,KAHrB;AAIvBP,EAAAA;AAJuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"]}
1
+ {"version":3,"names":["__","metadata","name","category","attributes","id","type","supports","html","inserter","customClassName","reusable","__experimentalToolbar","__experimentalParentSelector","__experimentalDisableBlockOverlay","editorStyle","style","edit","settings","title","description","__experimentalLabel","label"],"sources":["@wordpress/edit-widgets/src/blocks/widget-area/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,MAAAC,QAAA;EAAAC,IAAA;EAAAC,QAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;IAAA;IAAAJ,IAAA;MAAAI,IAAA;IAAA;EAAA;EAAAC,QAAA;IAAAC,IAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,QAAA;IAAAC,qBAAA;IAAAC,4BAAA;IAAAC,iCAAA;EAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAIA,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAEf;AAAK,CAAC,GAAGD,QAAQ;AACzB,SAASA,QAAQ,EAAEC,IAAI;AAEvB,OAAO,MAAMgB,QAAQ,GAAG;EACvBC,KAAK,EAAEnB,EAAE,CAAE,aAAc,CAAC;EAC1BoB,WAAW,EAAEpB,EAAE,CAAE,0BAA2B,CAAC;EAC7CqB,mBAAmB,EAAEA,CAAE;IAAEnB,IAAI,EAAEoB;EAAM,CAAC,KAAMA,KAAK;EACjDL;AACD,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -9,7 +8,6 @@ import { Button } from '@wordpress/components';
9
8
  import { Warning } from '@wordpress/block-editor';
10
9
  import { useCopyToClipboard } from '@wordpress/compose';
11
10
  import { doAction } from '@wordpress/hooks';
12
-
13
11
  function CopyButton({
14
12
  text,
15
13
  children
@@ -20,7 +18,6 @@ function CopyButton({
20
18
  ref: ref
21
19
  }, children);
22
20
  }
23
-
24
21
  function ErrorBoundaryWarning({
25
22
  message,
26
23
  error
@@ -34,7 +31,6 @@ function ErrorBoundaryWarning({
34
31
  actions: actions
35
32
  }, message);
36
33
  }
37
-
38
34
  export default class ErrorBoundary extends Component {
39
35
  constructor() {
40
36
  super(...arguments);
@@ -42,27 +38,22 @@ export default class ErrorBoundary extends Component {
42
38
  error: null
43
39
  };
44
40
  }
45
-
46
41
  componentDidCatch(error) {
47
42
  doAction('editor.ErrorBoundary.errorLogged', error);
48
43
  }
49
-
50
44
  static getDerivedStateFromError(error) {
51
45
  return {
52
46
  error
53
47
  };
54
48
  }
55
-
56
49
  render() {
57
50
  if (!this.state.error) {
58
51
  return this.props.children;
59
52
  }
60
-
61
53
  return createElement(ErrorBoundaryWarning, {
62
54
  message: __('The editor has encountered an unexpected error.'),
63
55
  error: this.state.error
64
56
  });
65
57
  }
66
-
67
58
  }
68
59
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/error-boundary/index.js"],"names":["Component","__","Button","Warning","useCopyToClipboard","doAction","CopyButton","text","children","ref","ErrorBoundaryWarning","message","error","actions","stack","ErrorBoundary","constructor","arguments","state","componentDidCatch","getDerivedStateFromError","render","props"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,kBAAzB;;AAEA,SAASC,UAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAA0C;AACzC,QAAMC,GAAG,GAAGL,kBAAkB,CAAEG,IAAF,CAA9B;AACA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,SAASE,oBAAT,CAA+B;AAAEC,EAAAA,OAAF;AAAWC,EAAAA;AAAX,CAA/B,EAAoD;AACnD,QAAMC,OAAO,GAAG,CACf,cAAC,UAAD;AAAY,IAAA,GAAG,EAAC,YAAhB;AAA6B,IAAA,IAAI,EAAGD,KAAK,CAACE;AAA1C,KACGb,EAAE,CAAE,YAAF,CADL,CADe,CAAhB;AAMA,SACC,cAAC,OAAD;AAAS,IAAA,SAAS,EAAC,6BAAnB;AAAiD,IAAA,OAAO,EAAGY;AAA3D,KACGF,OADH,CADD;AAKA;;AAED,eAAe,MAAMI,aAAN,SAA4Bf,SAA5B,CAAsC;AACpDgB,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZN,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDO,EAAAA,iBAAiB,CAAEP,KAAF,EAAU;AAC1BP,IAAAA,QAAQ,CAAE,kCAAF,EAAsCO,KAAtC,CAAR;AACA;;AAE8B,SAAxBQ,wBAAwB,CAAER,KAAF,EAAU;AACxC,WAAO;AAAEA,MAAAA;AAAF,KAAP;AACA;;AAEDS,EAAAA,MAAM,GAAG;AACR,QAAK,CAAE,KAAKH,KAAL,CAAWN,KAAlB,EAA0B;AACzB,aAAO,KAAKU,KAAL,CAAWd,QAAlB;AACA;;AAED,WACC,cAAC,oBAAD;AACC,MAAA,OAAO,EAAGP,EAAE,CACX,iDADW,CADb;AAIC,MAAA,KAAK,EAAG,KAAKiB,KAAL,CAAWN;AAJpB,MADD;AAQA;;AA9BmD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nfunction ErrorBoundaryWarning( { message, error } ) {\n\tconst actions = [\n\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t{ __( 'Copy Error' ) }\n\t\t</CopyButton>,\n\t];\n\n\treturn (\n\t\t<Warning className=\"edit-widgets-error-boundary\" actions={ actions }>\n\t\t\t{ message }\n\t\t</Warning>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tif ( ! this.state.error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor has encountered an unexpected error.'\n\t\t\t\t) }\n\t\t\t\terror={ this.state.error }\n\t\t\t/>\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"names":["Component","__","Button","Warning","useCopyToClipboard","doAction","CopyButton","text","children","ref","createElement","variant","ErrorBoundaryWarning","message","error","actions","key","stack","className","ErrorBoundary","constructor","arguments","state","componentDidCatch","getDerivedStateFromError","render","props"],"sources":["@wordpress/edit-widgets/src/components/error-boundary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nfunction ErrorBoundaryWarning( { message, error } ) {\n\tconst actions = [\n\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t{ __( 'Copy Error' ) }\n\t\t</CopyButton>,\n\t];\n\n\treturn (\n\t\t<Warning className=\"edit-widgets-error-boundary\" actions={ actions }>\n\t\t\t{ message }\n\t\t</Warning>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tif ( ! this.state.error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor has encountered an unexpected error.'\n\t\t\t\t) }\n\t\t\t\terror={ this.state.error }\n\t\t\t/>\n\t\t);\n\t}\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,OAAO,QAAQ,yBAAyB;AACjD,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,SAASC,UAAUA,CAAE;EAAEC,IAAI;EAAEC;AAAS,CAAC,EAAG;EACzC,MAAMC,GAAG,GAAGL,kBAAkB,CAAEG,IAAK,CAAC;EACtC,OACCG,aAAA,CAACR,MAAM;IAACS,OAAO,EAAC,WAAW;IAACF,GAAG,EAAGA;EAAK,GACpCD,QACK,CAAC;AAEX;AAEA,SAASI,oBAAoBA,CAAE;EAAEC,OAAO;EAAEC;AAAM,CAAC,EAAG;EACnD,MAAMC,OAAO,GAAG,CACfL,aAAA,CAACJ,UAAU;IAACU,GAAG,EAAC,YAAY;IAACT,IAAI,EAAGO,KAAK,CAACG;EAAO,GAC9ChB,EAAE,CAAE,YAAa,CACR,CAAC,CACb;EAED,OACCS,aAAA,CAACP,OAAO;IAACe,SAAS,EAAC,6BAA6B;IAACH,OAAO,EAAGA;EAAS,GACjEF,OACM,CAAC;AAEZ;AAEA,eAAe,MAAMM,aAAa,SAASnB,SAAS,CAAC;EACpDoB,WAAWA,CAAA,EAAG;IACb,KAAK,CAAE,GAAGC,SAAU,CAAC;IAErB,IAAI,CAACC,KAAK,GAAG;MACZR,KAAK,EAAE;IACR,CAAC;EACF;EAEAS,iBAAiBA,CAAET,KAAK,EAAG;IAC1BT,QAAQ,CAAE,kCAAkC,EAAES,KAAM,CAAC;EACtD;EAEA,OAAOU,wBAAwBA,CAAEV,KAAK,EAAG;IACxC,OAAO;MAAEA;IAAM,CAAC;EACjB;EAEAW,MAAMA,CAAA,EAAG;IACR,IAAK,CAAE,IAAI,CAACH,KAAK,CAACR,KAAK,EAAG;MACzB,OAAO,IAAI,CAACY,KAAK,CAAClB,QAAQ;IAC3B;IAEA,OACCE,aAAA,CAACE,oBAAoB;MACpBC,OAAO,EAAGZ,EAAE,CACX,iDACD,CAAG;MACHa,KAAK,EAAG,IAAI,CAACQ,KAAK,CAACR;IAAO,CAC1B,CAAC;EAEJ;AACD"}
@@ -1,5 +1,4 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -11,10 +10,10 @@ import { PinnedItems } from '@wordpress/interface';
11
10
  import { listView, plus } from '@wordpress/icons';
12
11
  import { useCallback, useRef } from '@wordpress/element';
13
12
  import { useViewportMatch } from '@wordpress/compose';
13
+
14
14
  /**
15
15
  * Internal dependencies
16
16
  */
17
-
18
17
  import SaveButton from '../save-button';
19
18
  import UndoButton from './undo-redo/undo';
20
19
  import RedoButton from './undo-redo/redo';
@@ -25,7 +24,6 @@ import { unlock } from '../../lock-unlock';
25
24
  const {
26
25
  useShouldContextualToolbarShow
27
26
  } = unlock(blockEditorPrivateApis);
28
-
29
27
  function Header() {
30
28
  const isMediumViewport = useViewportMatch('medium');
31
29
  const inserterButton = useRef();
@@ -52,7 +50,6 @@ function Header() {
52
50
  const {
53
51
  selectBlock
54
52
  } = useDispatch(blockEditorStore);
55
-
56
53
  const handleClick = () => {
57
54
  if (isInserterOpen) {
58
55
  // Focusing the inserter button closes the inserter popover.
@@ -60,28 +57,26 @@ function Header() {
60
57
  } else {
61
58
  if (!isLastSelectedWidgetAreaOpen) {
62
59
  // Select the last selected block if hasn't already.
63
- selectBlock(widgetAreaClientId); // Open the last selected widget area when opening the inserter.
64
-
60
+ selectBlock(widgetAreaClientId);
61
+ // Open the last selected widget area when opening the inserter.
65
62
  setIsWidgetAreaOpen(widgetAreaClientId, true);
66
- } // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the
63
+ }
64
+ // The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the
67
65
  // same tick and pretty much in a random order. The inserter is closed if any other part of the
68
66
  // app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then
69
67
  // the inserter is visible for a brief moment and then gets auto-closed due to focus moving to
70
68
  // the selected block.
71
-
72
-
73
69
  window.requestAnimationFrame(() => setIsInserterOpened(true));
74
70
  }
75
71
  };
76
-
77
72
  const toggleListView = useCallback(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
78
73
  const {
79
74
  shouldShowContextualToolbar,
80
75
  canFocusHiddenToolbar,
81
76
  fixedToolbarCanBeFocused
82
- } = useShouldContextualToolbarShow(); // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
77
+ } = useShouldContextualToolbarShow();
78
+ // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
83
79
  // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
84
-
85
80
  const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || fixedToolbarCanBeFocused;
86
81
  return createElement(Fragment, null, createElement("div", {
87
82
  className: "edit-widgets-header"
@@ -108,16 +103,14 @@ function Header() {
108
103
  onClick: handleClick,
109
104
  icon: plus
110
105
  /* translators: button label text should, if possible, be under 16
111
- characters. */
112
- ,
106
+ characters. */,
113
107
  label: _x('Toggle block inserter', 'Generic label for block inserter button')
114
108
  }), isMediumViewport && createElement(Fragment, null, createElement(UndoButton, null), createElement(RedoButton, null), createElement(ToolbarItem, {
115
109
  as: Button,
116
110
  className: "edit-widgets-header-toolbar__list-view-toggle",
117
111
  icon: listView,
118
112
  isPressed: isListViewOpen
119
- /* translators: button label text should, if possible, be under 16 characters. */
120
- ,
113
+ /* translators: button label text should, if possible, be under 16 characters. */,
121
114
  label: __('List View'),
122
115
  onClick: toggleListView
123
116
  })))), createElement("div", {
@@ -126,6 +119,5 @@ function Header() {
126
119
  scope: "core/edit-widgets"
127
120
  }), createElement(MoreMenu, null))));
128
121
  }
129
-
130
122
  export default Header;
131
123
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","VisuallyHidden","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","PinnedItems","listView","plus","useCallback","useRef","useViewportMatch","SaveButton","UndoButton","RedoButton","MoreMenu","useLastSelectedWidgetArea","editWidgetsStore","unlock","useShouldContextualToolbarShow","Header","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","event","preventDefault"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,MAAT,EAAiBC,WAAjB,EAA8BC,cAA9B,QAAoD,uBAApD;AACA,SACCC,gBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAAW,IAAIC,sBAHhB,QAIO,yBAJP;AAKA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,O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3B;AACP;AACP;AAZM;AAaC,IAAA,KAAK,EAAGX,EAAE,CACT,uBADS,EAET,yCAFS;AAbX,IAPD,EAyBGwB,gBAAgB,IACjB,8BACC,cAAC,UAAD,OADD,EAEC,cAAC,UAAD,OAFD,EAGC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGvB,MADN;AAEC,IAAA,SAAS,EAAC,+CAFX;AAGC,IAAA,IAAI,EAAGS,QAHR;AAIC,IAAA,SAAS,EAAGqB;AACZ;AALD;AAMC,IAAA,KAAK,EAAGhC,EAAE,CAAE,WAAF,CANX;AAOC,IAAA,OAAO,EAAG0C;AAPX,IAHD,CA1BF,CAdD,CADD,EAyDC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,UAAD,OADD,EAEC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IAFD,EAGC,cAAC,QAAD,OAHD,CAzDD,CADD,CADD;AAmEA;;AAED,eAAelB,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\n\tconst { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {\n\t\tconst { isInserterOpened, isListViewOpened } =\n\t\t\tselect( editWidgetsStore );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"]}
1
+ {"version":3,"names":["useSelect","useDispatch","__","_x","Button","ToolbarItem","VisuallyHidden","NavigableToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","PinnedItems","listView","plus","useCallback","useRef","useViewportMatch","SaveButton","UndoButton","RedoButton","MoreMenu","useLastSelectedWidgetArea","editWidgetsStore","unlock","useShouldContextualToolbarShow","Header","isMediumViewport","inserterButton","widgetAreaClientId","isLastSelectedWidgetAreaOpen","select","getIsWidgetAreaOpen","isInserterOpen","isListViewOpen","isInserterOpened","isListViewOpened","setIsWidgetAreaOpen","setIsInserterOpened","setIsListViewOpened","selectBlock","handleClick","window","requestAnimationFrame","toggleListView","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","createElement","Fragment","className","as","shouldUseKeyboardFocusShortcut","ref","variant","isPressed","onMouseDown","event","preventDefault","onClick","icon","label","Slot","scope"],"sources":["@wordpress/edit-widgets/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem, VisuallyHidden } from '@wordpress/components';\nimport {\n\tNavigableToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PinnedItems } from '@wordpress/interface';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport UndoButton from './undo-redo/undo';\nimport RedoButton from './undo-redo/redo';\nimport MoreMenu from '../more-menu';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nfunction Header() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\tconst inserterButton = useRef();\n\tconst widgetAreaClientId = useLastSelectedWidgetArea();\n\tconst isLastSelectedWidgetAreaOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen(\n\t\t\t\twidgetAreaClientId\n\t\t\t),\n\t\t[ widgetAreaClientId ]\n\t);\n\tconst { isInserterOpen, isListViewOpen } = useSelect( ( select ) => {\n\t\tconst { isInserterOpened, isListViewOpened } =\n\t\t\tselect( editWidgetsStore );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsWidgetAreaOpen, setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst handleClick = () => {\n\t\tif ( isInserterOpen ) {\n\t\t\t// Focusing the inserter button closes the inserter popover.\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tif ( ! isLastSelectedWidgetAreaOpen ) {\n\t\t\t\t// Select the last selected block if hasn't already.\n\t\t\t\tselectBlock( widgetAreaClientId );\n\t\t\t\t// Open the last selected widget area when opening the inserter.\n\t\t\t\tsetIsWidgetAreaOpen( widgetAreaClientId, true );\n\t\t\t}\n\t\t\t// The DOM updates resulting from selectBlock() and setIsInserterOpened() calls are applied the\n\t\t\t// same tick and pretty much in a random order. The inserter is closed if any other part of the\n\t\t\t// app receives focus. If selectBlock() happens to take effect after setIsInserterOpened() then\n\t\t\t// the inserter is visible for a brief moment and then gets auto-closed due to focus moving to\n\t\t\t// the selected block.\n\t\t\twindow.requestAnimationFrame( () => setIsInserterOpened( true ) );\n\t\t}\n\t};\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-widgets-header\">\n\t\t\t\t<div className=\"edit-widgets-header__navigable-toolbar-wrapper\">\n\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t<h1 className=\"edit-widgets-header__title\">\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</h1>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMediumViewport && (\n\t\t\t\t\t\t<VisuallyHidden\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header__title\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Widgets' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigableToolbar\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t\t\tshouldUseKeyboardFocusShortcut={\n\t\t\t\t\t\t\t! blockToolbarCanBeFocused\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClick={ handleClick }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Toggle block inserter',\n\t\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isMediumViewport && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<UndoButton />\n\t\t\t\t\t\t\t\t<RedoButton />\n\t\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavigableToolbar>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-widgets-header__actions\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-widgets\" />\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,WAAW,EAAEC,cAAc,QAAQ,uBAAuB;AAC3E,SACCC,gBAAgB,EAChBC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,QAAQ,EAAEC,IAAI,QAAQ,kBAAkB;AACjD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AACvC,OAAOC,UAAU,MAA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