@wordpress/customize-widgets 6.2.0 → 6.3.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 (147) hide show
  1. package/build/components/block-appender/index.cjs.map +1 -1
  2. package/build/components/customize-widgets/index.cjs +13 -11
  3. package/build/components/customize-widgets/index.cjs.map +1 -1
  4. package/build/components/customize-widgets/use-clear-selected-block.cjs.map +1 -1
  5. package/build/components/error-boundary/index.cjs.map +1 -1
  6. package/build/components/focus-control/index.cjs.map +1 -1
  7. package/build/components/focus-control/use-blocks-focus-control.cjs.map +1 -1
  8. package/build/components/header/index.cjs +23 -16
  9. package/build/components/header/index.cjs.map +1 -1
  10. package/build/components/inserter/use-inserter.cjs.map +1 -1
  11. package/build/components/keyboard-shortcut-help-modal/config.cjs +5 -0
  12. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -1
  13. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +9 -7
  14. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -1
  15. package/build/components/keyboard-shortcut-help-modal/index.cjs +12 -11
  16. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -1
  17. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +34 -13
  18. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -1
  19. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  20. package/build/components/more-menu/index.cjs +14 -9
  21. package/build/components/more-menu/index.cjs.map +1 -1
  22. package/build/components/sidebar-block-editor/index.cjs +15 -13
  23. package/build/components/sidebar-block-editor/index.cjs.map +1 -1
  24. package/build/components/sidebar-block-editor/sidebar-adapter.cjs.map +1 -1
  25. package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs +10 -8
  26. package/build/components/sidebar-block-editor/sidebar-editor-provider.cjs.map +1 -1
  27. package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs +9 -7
  28. package/build/components/sidebar-block-editor/use-sidebar-block-editor.cjs.map +1 -1
  29. package/build/controls/inserter-outer-section.cjs +2 -2
  30. package/build/controls/inserter-outer-section.cjs.map +1 -1
  31. package/build/controls/sidebar-control.cjs +10 -8
  32. package/build/controls/sidebar-control.cjs.map +1 -1
  33. package/build/controls/sidebar-section.cjs +8 -6
  34. package/build/controls/sidebar-section.cjs.map +1 -1
  35. package/build/index.cjs +12 -11
  36. package/build/index.cjs.map +1 -1
  37. package/build/store/index.cjs +11 -9
  38. package/build/store/index.cjs.map +1 -1
  39. package/build/utils.cjs.map +1 -1
  40. package/build-module/components/focus-control/use-blocks-focus-control.mjs.map +1 -1
  41. package/build-module/components/header/index.mjs +12 -7
  42. package/build-module/components/header/index.mjs.map +1 -1
  43. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +5 -0
  44. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -1
  45. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +1 -2
  46. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -1
  47. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +34 -13
  48. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -1
  49. package/build-module/components/more-menu/index.mjs +6 -3
  50. package/build-module/components/more-menu/index.mjs.map +1 -1
  51. package/build-module/components/sidebar-block-editor/sidebar-adapter.mjs.map +1 -1
  52. package/build-module/controls/inserter-outer-section.mjs +3 -3
  53. package/build-module/controls/inserter-outer-section.mjs.map +1 -1
  54. package/build-module/index.mjs +1 -2
  55. package/build-module/index.mjs.map +1 -1
  56. package/build-module/utils.mjs.map +1 -1
  57. package/build-style/style-rtl.css +30 -29
  58. package/build-style/style.css +30 -29
  59. package/build-types/components/block-appender/index.d.ts +2 -0
  60. package/build-types/components/block-appender/index.d.ts.map +1 -0
  61. package/build-types/components/block-inspector-button/index.d.ts +7 -0
  62. package/build-types/components/block-inspector-button/index.d.ts.map +1 -0
  63. package/build-types/components/customize-widgets/index.d.ts +6 -0
  64. package/build-types/components/customize-widgets/index.d.ts.map +1 -0
  65. package/build-types/components/customize-widgets/use-clear-selected-block.d.ts +18 -0
  66. package/build-types/components/customize-widgets/use-clear-selected-block.d.ts.map +1 -0
  67. package/build-types/components/error-boundary/index.d.ts +14 -0
  68. package/build-types/components/error-boundary/index.d.ts.map +1 -0
  69. package/build-types/components/focus-control/index.d.ts +7 -0
  70. package/build-types/components/focus-control/index.d.ts.map +1 -0
  71. package/build-types/components/focus-control/use-blocks-focus-control.d.ts +2 -0
  72. package/build-types/components/focus-control/use-blocks-focus-control.d.ts.map +1 -0
  73. package/build-types/components/header/index.d.ts +9 -0
  74. package/build-types/components/header/index.d.ts.map +1 -0
  75. package/build-types/components/inserter/index.d.ts +5 -0
  76. package/build-types/components/inserter/index.d.ts.map +1 -0
  77. package/build-types/components/inserter/use-inserter.d.ts +2 -0
  78. package/build-types/components/inserter/use-inserter.d.ts.map +1 -0
  79. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +3 -0
  80. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts.map +1 -0
  81. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts +5 -0
  82. package/build-types/components/keyboard-shortcut-help-modal/dynamic-shortcut.d.ts.map +1 -0
  83. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts +5 -0
  84. package/build-types/components/keyboard-shortcut-help-modal/index.d.ts.map +1 -0
  85. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +25 -0
  86. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts.map +1 -0
  87. package/build-types/components/keyboard-shortcuts/index.d.ts +11 -0
  88. package/build-types/components/keyboard-shortcuts/index.d.ts.map +1 -0
  89. package/build-types/components/more-menu/index.d.ts +2 -0
  90. package/build-types/components/more-menu/index.d.ts.map +1 -0
  91. package/build-types/components/sidebar-block-editor/index.d.ts +7 -0
  92. package/build-types/components/sidebar-block-editor/index.d.ts.map +1 -0
  93. package/build-types/components/sidebar-block-editor/sidebar-adapter.d.ts +37 -0
  94. package/build-types/components/sidebar-block-editor/sidebar-adapter.d.ts.map +1 -0
  95. package/build-types/components/sidebar-block-editor/sidebar-editor-provider.d.ts +6 -0
  96. package/build-types/components/sidebar-block-editor/sidebar-editor-provider.d.ts.map +1 -0
  97. package/build-types/components/sidebar-block-editor/use-sidebar-block-editor.d.ts +2 -0
  98. package/build-types/components/sidebar-block-editor/use-sidebar-block-editor.d.ts.map +1 -0
  99. package/build-types/components/sidebar-controls/index.d.ts +9 -0
  100. package/build-types/components/sidebar-controls/index.d.ts.map +1 -0
  101. package/build-types/components/welcome-guide/index.d.ts +4 -0
  102. package/build-types/components/welcome-guide/index.d.ts.map +1 -0
  103. package/build-types/controls/inserter-outer-section.d.ts +9 -0
  104. package/build-types/controls/inserter-outer-section.d.ts.map +1 -0
  105. package/build-types/controls/inspector-section.d.ts +17 -0
  106. package/build-types/controls/inspector-section.d.ts.map +1 -0
  107. package/build-types/controls/sidebar-control.d.ts +19 -0
  108. package/build-types/controls/sidebar-control.d.ts.map +1 -0
  109. package/build-types/controls/sidebar-section.d.ts +22 -0
  110. package/build-types/controls/sidebar-section.d.ts.map +1 -0
  111. package/build-types/filters/index.d.ts +4 -0
  112. package/build-types/filters/index.d.ts.map +1 -0
  113. package/build-types/filters/move-to-sidebar.d.ts +2 -0
  114. package/build-types/filters/move-to-sidebar.d.ts.map +1 -0
  115. package/build-types/filters/replace-media-upload.d.ts +2 -0
  116. package/build-types/filters/replace-media-upload.d.ts.map +1 -0
  117. package/build-types/filters/wide-widget-display.d.ts +2 -0
  118. package/build-types/filters/wide-widget-display.d.ts.map +1 -0
  119. package/build-types/index.d.ts +10 -0
  120. package/build-types/index.d.ts.map +1 -0
  121. package/build-types/lock-unlock.d.ts +2 -0
  122. package/build-types/lock-unlock.d.ts.map +1 -0
  123. package/build-types/store/actions.d.ts +39 -0
  124. package/build-types/store/actions.d.ts.map +1 -0
  125. package/build-types/store/constants.d.ts +5 -0
  126. package/build-types/store/constants.d.ts.map +1 -0
  127. package/build-types/store/index.d.ts +9 -0
  128. package/build-types/store/index.d.ts.map +1 -0
  129. package/build-types/store/reducer.d.ts +14 -0
  130. package/build-types/store/reducer.d.ts.map +1 -0
  131. package/build-types/store/selectors.d.ts +35 -0
  132. package/build-types/store/selectors.d.ts.map +1 -0
  133. package/build-types/utils.d.ts +32 -0
  134. package/build-types/utils.d.ts.map +1 -0
  135. package/package.json +28 -28
  136. package/src/components/header/index.jsx +1 -1
  137. package/src/components/header/style.scss +12 -9
  138. package/src/components/header/test/index.jsdom.test.tsx +5 -0
  139. package/src/components/inserter/style.scss +6 -4
  140. package/src/components/keyboard-shortcut-help-modal/config.js +3 -0
  141. package/src/components/keyboard-shortcut-help-modal/index.jsx +0 -2
  142. package/src/components/keyboard-shortcut-help-modal/shortcut.jsx +38 -25
  143. package/src/components/more-menu/index.jsx +3 -7
  144. package/src/components/sidebar-block-editor/style.scss +9 -0
  145. package/src/controls/inserter-outer-section.js +3 -3
  146. package/src/index.jsx +1 -4
  147. package/src/utils.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useRef","useSelect","blockEditorStore","ButtonBlockAppender"],"sources":["../../../src/components/block-appender/index.jsx"],"sourcesContent":["import { useRef, useEffect } from '@wordpress/element';\nimport {\n\tButtonBlockAppender,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function BlockAppender( props ) {\n\tconst ref = useRef();\n\tconst isBlocksListEmpty = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockCount() === 0\n\t);\n\n\t// Move the focus to the block appender to prevent focus from\n\t// being lost when emptying the widget area.\n\tuseEffect( () => {\n\t\tif ( isBlocksListEmpty && ref.current ) {\n\t\t\tconst { ownerDocument } = ref.current;\n\n\t\t\tif (\n\t\t\t\t! ownerDocument.activeElement ||\n\t\t\t\townerDocument.activeElement === ownerDocument.body\n\t\t\t) {\n\t\t\t\tref.current.focus();\n\t\t\t}\n\t\t}\n\t}, [ isBlocksListEmpty ] );\n\n\treturn <ButtonBlockAppender { ...props } ref={ ref } />;\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAwB,cAAe,OAAQ;CAC9C,MAAM,OAAA,GAAMA,mBAAAA,OAAAA,CAAO;CACnB,MAAM,qBAAA,GAAoBC,gBAAAA,UAAAA,EACvB,WAAY,OAAQC,wBAAAA,KAAiB,CAAC,CAAC,cAAc,MAAM,CAC9D;CAIA,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,qBAAqB,IAAI,SAAU;GACvC,MAAM,EAAE,kBAAkB,IAAI;GAE9B,IACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAE9C,IAAI,QAAQ,MAAM;EAEpB;CACD,GAAG,CAAE,iBAAkB,CAAE;CAEzB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,qBAAD;EAAqB,GAAK;EAAc;CAAO,CAAA;AACvD"}
1
+ {"version":3,"file":"index.cjs","names":["useRef","useSelect","blockEditorStore","useEffect","ButtonBlockAppender"],"sources":["../../../src/components/block-appender/index.jsx"],"sourcesContent":["import { useRef, useEffect } from '@wordpress/element';\nimport {\n\tButtonBlockAppender,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function BlockAppender( props ) {\n\tconst ref = useRef();\n\tconst isBlocksListEmpty = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockCount() === 0\n\t);\n\n\t// Move the focus to the block appender to prevent focus from\n\t// being lost when emptying the widget area.\n\tuseEffect( () => {\n\t\tif ( isBlocksListEmpty && ref.current ) {\n\t\t\tconst { ownerDocument } = ref.current;\n\n\t\t\tif (\n\t\t\t\t! ownerDocument.activeElement ||\n\t\t\t\townerDocument.activeElement === ownerDocument.body\n\t\t\t) {\n\t\t\t\tref.current.focus();\n\t\t\t}\n\t\t}\n\t}, [ isBlocksListEmpty ] );\n\n\treturn <ButtonBlockAppender { ...props } ref={ ref } />;\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAwB,cAAe,OAAQ;CAC9C,MAAM,OAAA,GAAMA,mBAAAA,OAAAA,CAAO;CACnB,MAAM,qBAAA,GAAoBC,gBAAAA,UAAAA,EACvB,WAAY,OAAQC,wBAAAA,KAAiB,CAAC,CAAC,cAAc,MAAM,CAC9D;CAIAC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IAAK,qBAAqB,IAAI,SAAU;GACvC,MAAM,EAAE,kBAAkB,IAAI;GAE9B,IACC,CAAE,cAAc,iBAChB,cAAc,kBAAkB,cAAc,MAE9C,IAAI,QAAQ,MAAM;EAEpB;CACD,GAAG,CAAE,iBAAkB,CAAE;CAEzB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,qBAAD;EAAqB,GAAK;EAAc;CAAO,CAAA;AACvD"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -30,16 +32,16 @@ let _wordpress_components = require("@wordpress/components");
30
32
  let _wordpress_theme = require("@wordpress/theme");
31
33
  let _wordpress_ui = require("@wordpress/ui");
32
34
  let ___error_boundary_index_jsx = require("../error-boundary/index.cjs");
33
- ___error_boundary_index_jsx = __toESM(___error_boundary_index_jsx);
34
35
  let ___sidebar_block_editor_index_jsx = require("../sidebar-block-editor/index.cjs");
35
- ___sidebar_block_editor_index_jsx = __toESM(___sidebar_block_editor_index_jsx);
36
36
  let ___focus_control_index_jsx = require("../focus-control/index.cjs");
37
- ___focus_control_index_jsx = __toESM(___focus_control_index_jsx);
38
37
  let ___sidebar_controls_index_jsx = require("../sidebar-controls/index.cjs");
39
- ___sidebar_controls_index_jsx = __toESM(___sidebar_controls_index_jsx);
40
38
  let __use_clear_selected_block_js = require("./use-clear-selected-block.cjs");
41
- __use_clear_selected_block_js = __toESM(__use_clear_selected_block_js);
42
39
  let react_jsx_runtime = require("react/jsx-runtime");
40
+ ___error_boundary_index_jsx = __toESM(___error_boundary_index_jsx);
41
+ ___sidebar_block_editor_index_jsx = __toESM(___sidebar_block_editor_index_jsx);
42
+ ___focus_control_index_jsx = __toESM(___focus_control_index_jsx);
43
+ ___sidebar_controls_index_jsx = __toESM(___sidebar_controls_index_jsx);
44
+ __use_clear_selected_block_js = __toESM(__use_clear_selected_block_js);
43
45
  // packages/customize-widgets/src/components/customize-widgets/index.jsx
44
46
  function CustomizeWidgets({ api, sidebarControls, blockEditorSettings }) {
45
47
  const [activeSidebarControl, setActiveSidebarControl] = (0, _wordpress_element.useState)(null);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useState","useRef","useMemo","getAdminThemeColors","createPortal","ErrorBoundary","SidebarBlockEditor","WCPopover","SlotFillProvider","ThemeProvider","SidebarControls","FocusControl"],"sources":["../../../src/components/customize-widgets/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover as WCPopover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { useEnableWpCompatOverlaySlot } from '@wordpress/ui';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\t// `useClearSelectedBlock` relies on the slot marker to spot overlays.\n\tuseEnableWpCompatOverlaySlot();\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<WCPopover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAwB,iBAAkB,EACzC,KACA,iBACA,uBACG;CACH,MAAM,CAAE,sBAAsB,4BAAA,GAA4BA,mBAAAA,SAAAA,CAAU,IAAK;CACzE,MAAM,kBAAkB,SAAS,eAChC,0BACD;CACA,MAAM,cAAA,GAAaC,mBAAAA,OAAAA,CAAO;CAC1B,MAAM,gBAAA,GAAeC,mBAAAA,QAAAA,QAAAA,GAAeC,oBAAAA,oBAAAA,CAAoB,CAAC,CAAC,SAAS,CAAC,CAAE;CAGtE,CAAA,GAAA,cAAA,6BAAA,CAA6B;CAC7B,CAAA,GAAA,8BAAA,QAAA,CAAuB,sBAAsB,UAAW;CAExD,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,MAAM,gBAAgB,gBAAgB,KAAO,mBAC5C,eAAe,WAAa,aAAc;GACzC,IAAK,UACJ,wBAAyB,cAAe;EAE1C,CAAE,CACH;EAEA,aAAa;GACZ,cAAc,SAAW,iBAAkB,aAAa,CAAE;EAC3D;CACD,GAAG,CAAE,eAAgB,CAAE;CAEvB,MAAM,gBACL,yBAAA,GACAC,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,SAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,SAAD;EAEuB;EACtB,SAAU,qBAAqB;EAC/B,UAAW,qBAAqB;EAChC,WAAY,qBAAqB;CACjC,GALM,qBAAqB,EAK3B,EACa,CAAA,GACf,qBAAqB,UAAW,EACjC;CAID,MAAM,UACL,oBAAA,GACAF,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EAA4B,KAAM;EAChD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,QAAU,MAAX,CAAiB,CAAA;CACb,CAAA,GACL,eACD;CAED,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,kBAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,eAAD;EAAe,QAAA;EAAO,OAAQ,EAAE,SAAS,aAAa;EACrD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD;GACmB;GACK;GAEvB,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACC,2BAAAA,SAAD;IACO;IACY;IAFnB,UAAA,CAIG,eACA,OACW;;EACE,CAAA;CACH,CAAA,EACE,CAAA;AAEpB"}
1
+ {"version":3,"file":"index.cjs","names":["useState","useRef","useMemo","getAdminThemeColors","useEnableWpCompatOverlaySlot","useClearSelectedBlock","useEffect","createPortal","ErrorBoundary","SidebarBlockEditor","WCPopover","SlotFillProvider","ThemeProvider","SidebarControls","FocusControl"],"sources":["../../../src/components/customize-widgets/index.jsx"],"sourcesContent":["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover as WCPopover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { useEnableWpCompatOverlaySlot } from '@wordpress/ui';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\t// `useClearSelectedBlock` relies on the slot marker to spot overlays.\n\tuseEnableWpCompatOverlaySlot();\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<WCPopover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAwB,iBAAkB,EACzC,KACA,iBACA,uBACG;CACH,MAAM,CAAE,sBAAsB,4BAAA,GAA4BA,mBAAAA,SAAAA,CAAU,IAAK;CACzE,MAAM,kBAAkB,SAAS,eAChC,0BACD;CACA,MAAM,cAAA,GAAaC,mBAAAA,OAAAA,CAAO;CAC1B,MAAM,gBAAA,GAAeC,mBAAAA,QAAAA,QAAAA,GAAeC,oBAAAA,oBAAAA,CAAoB,CAAC,CAAC,SAAS,CAAC,CAAE;CAGtEC,CAAAA,GAAAA,cAAAA,6BAAAA,CAA6B;CAC7BC,CAAAA,GAAAA,8BAAAA,QAAAA,CAAuB,sBAAsB,UAAW;CAExDC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,MAAM,gBAAgB,gBAAgB,KAAO,mBAC5C,eAAe,WAAa,aAAc;GACzC,IAAK,UACJ,wBAAyB,cAAe;EAE1C,CAAE,CACH;EAEA,aAAa;GACZ,cAAc,SAAW,iBAAkB,aAAa,CAAE;EAC3D;CACD,GAAG,CAAE,eAAgB,CAAE;CAEvB,MAAM,gBACL,yBAAA,GACAC,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,SAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,kCAAAA,SAAD;EAEuB;EACtB,SAAU,qBAAqB;EAC/B,UAAW,qBAAqB;EAChC,WAAY,qBAAqB;CACjC,GALM,qBAAqB,EAK3B,EACa,CAAA,GACf,qBAAqB,UAAW,EACjC;CAID,MAAM,UACL,oBAAA,GACAF,mBAAAA,aAAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EAA4B,KAAM;EAChD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,QAAU,MAAX,CAAiB,CAAA;CACb,CAAA,GACL,eACD;CAED,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,kBAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,iBAAAA,eAAD;EAAe,QAAA;EAAO,OAAQ,EAAE,SAAS,aAAa;EACrD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD;GACmB;GACK;GAEvB,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACC,2BAAAA,SAAD;IACO;IACY;IAFnB,UAAA,CAIG,eACA,OACW;;EACE,CAAA;CACH,CAAA,EACE,CAAA;AAEpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-clear-selected-block.cjs","names":["useSelect","blockEditorStore","useDispatch"],"sources":["../../../src/components/customize-widgets/use-clear-selected-block.js"],"sourcesContent":["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers, including `@wordpress/ui` overlays.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[data-wp-compat-overlay-slot]' ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAwB,sBAAuB,gBAAgB,YAAa;CAC3E,MAAM,EAAE,kBAAkB,uBAAA,GACzBA,gBAAAA,UAAAA,CAAWC,wBAAAA,KAAiB;CAC7B,MAAM,EAAE,wBAAA,GAAuBC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAE7D,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,WAAW,WAAW,gBAAiB;GAC3C,MAAM,YAAY,eAAe;GACjC,MAAM,YAAY,eAAe,UAAW;GAC5C,MAAM,gBAAgB,UAAU;GAChC,MAAM,cAAc,cAAc;GAElC,SAAS,yBAA0B,SAAU;IAC5C,KAEG,iBAAiB,KAAK,kBAAkB,MAE1C,WACA,cAAc,SAAU,OAAQ,KAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,+BAAgC,KACnD,CAAE,QAAQ,QAAS,mBAAkB,KAErC,CAAE,UAAU,SAAS,GAErB,mBAAmB;GAErB;GAGA,SAAS,gBAAiB,OAAQ;IACjC,yBAA0B,MAAM,MAAO;GACxC;GAEA,SAAS,aAAa;IACrB,yBAA0B,cAAc,aAAc;GACvD;GAEA,cAAc,iBAAkB,aAAa,eAAgB;GAC7D,YAAY,iBAAkB,QAAQ,UAAW;GAEjD,aAAa;IACZ,cAAc,oBACb,aACA,eACD;IACA,YAAY,oBAAqB,QAAQ,UAAW;GACrD;EACD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;CACD,CAAE;AACH"}
1
+ {"version":3,"file":"use-clear-selected-block.cjs","names":["useSelect","blockEditorStore","useDispatch","useEffect"],"sources":["../../../src/components/customize-widgets/use-clear-selected-block.js"],"sourcesContent":["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers, including `@wordpress/ui` overlays.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[data-wp-compat-overlay-slot]' ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAwB,sBAAuB,gBAAgB,YAAa;CAC3E,MAAM,EAAE,kBAAkB,uBAAA,GACzBA,gBAAAA,UAAAA,CAAWC,wBAAAA,KAAiB;CAC7B,MAAM,EAAE,wBAAA,GAAuBC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAE7DE,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IAAK,WAAW,WAAW,gBAAiB;GAC3C,MAAM,YAAY,eAAe;GACjC,MAAM,YAAY,eAAe,UAAW;GAC5C,MAAM,gBAAgB,UAAU;GAChC,MAAM,cAAc,cAAc;GAElC,SAAS,yBAA0B,SAAU;IAC5C,KAEG,iBAAiB,KAAK,kBAAkB,MAE1C,WACA,cAAc,SAAU,OAAQ,KAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,+BAAgC,KACnD,CAAE,QAAQ,QAAS,mBAAkB,KAErC,CAAE,UAAU,SAAS,GAErB,mBAAmB;GAErB;GAGA,SAAS,gBAAiB,OAAQ;IACjC,yBAA0B,MAAM,MAAO;GACxC;GAEA,SAAS,aAAa;IACrB,yBAA0B,cAAc,aAAc;GACvD;GAEA,cAAc,iBAAkB,aAAa,eAAgB;GAC7D,YAAY,iBAAkB,QAAQ,UAAW;GAEjD,aAAa;IACZ,cAAc,oBACb,aACA,eACD;IACA,YAAY,oBAAqB,QAAQ,UAAW;GACrD;EACD;CACD,GAAG;EACF;EACA;EACA;EACA;EACA;CACD,CAAE;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["__","useCopyToClipboard","Notice","Stack","Text","CollapsibleCard","Card","Component","_x"],"sources":["../../../src/components/error-boundary/index.jsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __, _x } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\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\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Copy error', 'button label' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAS,iBAAiB;CACzB,OAAO;EACN,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,wBAAyB;EACpC,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,iHACD;CACD;AACD;AAGA,SAAS,aAAc,OAAQ;CAC9B,OAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;CACjC,IAAK,OAAO,UAAU,YAAY,OACjC,OAAO;CAGR,IAAK,OAAO,OAAO,YAAY,YAAY,MAAM,SAChD,OAAO,MAAM;CAGd,OAAO;AACR;AAKA,SAAS,iBAAkB,OAAO,gBAAiB;CAClD,MAAM,WAAW,CAChB;EAAE,OAAO,aAAc,KAAM;EAAG,SAAS,gBAAiB,KAAM;CAAE,CACnE;CAEA,IAAK,OAAO,OACX,SAAS,KAAM;EACd,OAAO;EACP,SAAS,MAAM,MAAM,KAAK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AAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,aAAR,EAAA,UAAsB,YAAiC,CAAA;KACvD,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,SAAR,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD;MACC,SAAQ;MACR,YACC,eAAgB,OAAO,cAAe;MAGrCM,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,cAAc,cAAe;KACxB,CAAA,EACG,CAAA;IACJ;GACX,CAAA,GAAA,WAAW,eACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;IACS;IACS;GACjB,CAAA,IACE,IACE;;CAET;AACD"}
1
+ {"version":3,"file":"index.cjs","names":["__","useCopyToClipboard","Notice","Stack","Text","CollapsibleCard","Card","Component","speak","doAction","_x"],"sources":["../../../src/components/error-boundary/index.jsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __, _x } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\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\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Copy error', 'button label' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAS,iBAAiB;CACzB,OAAO;EACN,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,wBAAyB;EACpC,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,iHACD;CACD;AACD;AAGA,SAAS,aAAc,OAAQ;CAC9B,OAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;CACjC,IAAK,OAAO,UAAU,YAAY,OACjC,OAAO;CAGR,IAAK,OAAO,OAAO,YAAY,YAAY,MAAM,SAChD,OAAO,MAAM;CAGd,OAAO;AACR;AAKA,SAAS,iBAAkB,OAAO,gBAAiB;CAClD,MAAM,WAAW,CAChB;EAAE,OAAO,aAAc,KAAM;EAAG,SAAS,gBAAiB,KAAM;CAAE,CACnE;CAEA,IAAK,OAAO,OACX,SAAS,KAAM;EACd,OAAO;EACP,SAAS,MAAM,MAAM,KAAK;EAC1B,cAAc;CACf,CAAE;CAGH,IAAK,gBACJ,SAAS,KAAM;EACd,OAAO;EACP,SAAS,eAAe,KAAK;EAC7B,cAAc;CACf,CAAE;CAGH,SAAS,KAAM;EACd,OAAO;EACP,SAAS,eAAgB,OAAO,UAAU;EAC1C,cAAc;CACf,CAAE;CAEF,OAAO;AACR;AAIA,SAAS,eAAgB,OAAO,gBAAiB;CAQhD,OAAO,CAAE,oBAAoB,GAPZ,iBAAkB,OAAO,cAAe,CAAC,CAAC,KACxD,EAAE,OAAO,SAAS,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AAW,eACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;IACS;IACS;GACjB,CAAA,IACE,IACE;;CAET;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createContext","useState","useCallback","settingIdToWidgetId","useMemo","useContext"],"sources":["../../../src/components/focus-control/index.jsx"],"sourcesContent":["import {\n\tcreateContext,\n\tuseState,\n\tuseEffect,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { settingIdToWidgetId } from '../../utils';\n\nconst FocusControlContext = createContext();\nFocusControlContext.displayName = 'FocusControlContext';\n\nexport default function FocusControl( { api, sidebarControls, children } ) {\n\tconst [ focusedWidgetIdRef, setFocusedWidgetIdRef ] = useState( {\n\t\tcurrent: null,\n\t} );\n\n\tconst focusWidget = useCallback(\n\t\t( widgetId ) => {\n\t\t\tfor ( const sidebarControl of sidebarControls ) {\n\t\t\t\tconst widgets = sidebarControl.setting.get();\n\n\t\t\t\tif ( widgets.includes( widgetId ) ) {\n\t\t\t\t\tsidebarControl.sectionInstance.expand( {\n\t\t\t\t\t\t// Schedule it after the complete callback so that\n\t\t\t\t\t\t// it won't be overridden by the \"Back\" button focus.\n\t\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t\t// Create a \"ref-like\" object every time to ensure\n\t\t\t\t\t\t\t// the same widget id can also triggers the focus control.\n\t\t\t\t\t\t\tsetFocusedWidgetIdRef( { current: widgetId } );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ sidebarControls ]\n\t);\n\n\tuseEffect( () => {\n\t\tfunction handleFocus( settingId ) {\n\t\t\tconst widgetId = settingIdToWidgetId( settingId );\n\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\tlet previewBound = false;\n\n\t\tfunction handleReady() {\n\t\t\tapi.previewer.preview.bind(\n\t\t\t\t'focus-control-for-setting',\n\t\t\t\thandleFocus\n\t\t\t);\n\t\t\tpreviewBound = true;\n\t\t}\n\n\t\tapi.previewer.bind( 'ready', handleReady );\n\n\t\treturn () => {\n\t\t\tapi.previewer.unbind( 'ready', handleReady );\n\t\t\tif ( previewBound ) {\n\t\t\t\tapi.previewer.preview.unbind(\n\t\t\t\t\t'focus-control-for-setting',\n\t\t\t\t\thandleFocus\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, [ api, focusWidget ] );\n\n\tconst context = useMemo(\n\t\t() => [ focusedWidgetIdRef, focusWidget ],\n\t\t[ focusedWidgetIdRef, focusWidget ]\n\t);\n\n\treturn (\n\t\t<FocusControlContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</FocusControlContext.Provider>\n\t);\n}\n\nexport const useFocusControl = () => useContext( FocusControlContext );\n"],"mappings":";;;;;;;;;AAUA,MAAM,uBAAA,GAAsBA,mBAAAA,cAAAA,CAAc;AAC1C,oBAAoB,cAAc;AAElC,SAAwB,aAAc,EAAE,KAAK,iBAAiB,YAAa;CAC1E,MAAM,CAAE,oBAAoB,0BAAA,GAA0BC,mBAAAA,SAAAA,CAAU,EAC/D,SAAS,KACV,CAAE;CAEF,MAAM,eAAA,GAAcC,mBAAAA,YAAAA,EACjB,aAAc;EACf,KAAM,MAAM,kBAAkB,iBAG7B,IAFgB,eAAe,QAAQ,IAE5B,CAAC,CAAC,SAAU,QAAS,GAAI;GACnC,eAAe,gBAAgB,OAAQ,EAGtC,mBAAmB;IAGlB,sBAAuB,EAAE,SAAS,SAAS,CAAE;GAC9C,EACD,CAAE;GAEF;EACD;CAEF,GACA,CAAE,eAAgB,CACnB;CAEA,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,SAAS,YAAa,WAAY;GACjC,MAAM,YAAA,GAAWC,eAAAA,oBAAAA,CAAqB,SAAU;GAEhD,YAAa,QAAS;EACvB;EAEA,IAAI,eAAe;EAEnB,SAAS,cAAc;GACtB,IAAI,UAAU,QAAQ,KACrB,6BACA,WACD;GACA,eAAe;EAChB;EAEA,IAAI,UAAU,KAAM,SAAS,WAAY;EAEzC,aAAa;GACZ,IAAI,UAAU,OAAQ,SAAS,WAAY;GAC3C,IAAK,cACJ,IAAI,UAAU,QAAQ,OACrB,6BACA,WACD;EAEF;CACD,GAAG,CAAE,KAAK,WAAY,CAAE;CAExB,MAAM,WAAA,GAAUC,mBAAAA,QAAAA,OACT,CAAE,oBAAoB,WAAY,GACxC,CAAE,oBAAoB,WAAY,CACnC;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,oBAAoB,UAArB;EAA8B,OAAQ;EACnC;CAC2B,CAAA;AAEhC;AAEA,MAAa,yBAAA,GAAwBC,mBAAAA,WAAAA,CAAY,mBAAoB"}
1
+ {"version":3,"file":"index.cjs","names":["createContext","useState","useCallback","useEffect","settingIdToWidgetId","useMemo","useContext"],"sources":["../../../src/components/focus-control/index.jsx"],"sourcesContent":["import {\n\tcreateContext,\n\tuseState,\n\tuseEffect,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { settingIdToWidgetId } from '../../utils';\n\nconst FocusControlContext = createContext();\nFocusControlContext.displayName = 'FocusControlContext';\n\nexport default function FocusControl( { api, sidebarControls, children } ) {\n\tconst [ focusedWidgetIdRef, setFocusedWidgetIdRef ] = useState( {\n\t\tcurrent: null,\n\t} );\n\n\tconst focusWidget = useCallback(\n\t\t( widgetId ) => {\n\t\t\tfor ( const sidebarControl of sidebarControls ) {\n\t\t\t\tconst widgets = sidebarControl.setting.get();\n\n\t\t\t\tif ( widgets.includes( widgetId ) ) {\n\t\t\t\t\tsidebarControl.sectionInstance.expand( {\n\t\t\t\t\t\t// Schedule it after the complete callback so that\n\t\t\t\t\t\t// it won't be overridden by the \"Back\" button focus.\n\t\t\t\t\t\tcompleteCallback() {\n\t\t\t\t\t\t\t// Create a \"ref-like\" object every time to ensure\n\t\t\t\t\t\t\t// the same widget id can also triggers the focus control.\n\t\t\t\t\t\t\tsetFocusedWidgetIdRef( { current: widgetId } );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ sidebarControls ]\n\t);\n\n\tuseEffect( () => {\n\t\tfunction handleFocus( settingId ) {\n\t\t\tconst widgetId = settingIdToWidgetId( settingId );\n\n\t\t\tfocusWidget( widgetId );\n\t\t}\n\n\t\tlet previewBound = false;\n\n\t\tfunction handleReady() {\n\t\t\tapi.previewer.preview.bind(\n\t\t\t\t'focus-control-for-setting',\n\t\t\t\thandleFocus\n\t\t\t);\n\t\t\tpreviewBound = true;\n\t\t}\n\n\t\tapi.previewer.bind( 'ready', handleReady );\n\n\t\treturn () => {\n\t\t\tapi.previewer.unbind( 'ready', handleReady );\n\t\t\tif ( previewBound ) {\n\t\t\t\tapi.previewer.preview.unbind(\n\t\t\t\t\t'focus-control-for-setting',\n\t\t\t\t\thandleFocus\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, [ api, focusWidget ] );\n\n\tconst context = useMemo(\n\t\t() => [ focusedWidgetIdRef, focusWidget ],\n\t\t[ focusedWidgetIdRef, focusWidget ]\n\t);\n\n\treturn (\n\t\t<FocusControlContext.Provider value={ context }>\n\t\t\t{ children }\n\t\t</FocusControlContext.Provider>\n\t);\n}\n\nexport const useFocusControl = () => useContext( FocusControlContext );\n"],"mappings":";;;;;;;;;AAUA,MAAM,uBAAA,GAAsBA,mBAAAA,cAAAA,CAAc;AAC1C,oBAAoB,cAAc;AAElC,SAAwB,aAAc,EAAE,KAAK,iBAAiB,YAAa;CAC1E,MAAM,CAAE,oBAAoB,0BAAA,GAA0BC,mBAAAA,SAAAA,CAAU,EAC/D,SAAS,KACV,CAAE;CAEF,MAAM,eAAA,GAAcC,mBAAAA,YAAAA,EACjB,aAAc;EACf,KAAM,MAAM,kBAAkB,iBAG7B,IAFgB,eAAe,QAAQ,IAE5B,CAAC,CAAC,SAAU,QAAS,GAAI;GACnC,eAAe,gBAAgB,OAAQ,EAGtC,mBAAmB;IAGlB,sBAAuB,EAAE,SAAS,SAAS,CAAE;GAC9C,EACD,CAAE;GAEF;EACD;CAEF,GACA,CAAE,eAAgB,CACnB;CAEAC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,SAAS,YAAa,WAAY;GACjC,MAAM,YAAA,GAAWC,eAAAA,oBAAAA,CAAqB,SAAU;GAEhD,YAAa,QAAS;EACvB;EAEA,IAAI,eAAe;EAEnB,SAAS,cAAc;GACtB,IAAI,UAAU,QAAQ,KACrB,6BACA,WACD;GACA,eAAe;EAChB;EAEA,IAAI,UAAU,KAAM,SAAS,WAAY;EAEzC,aAAa;GACZ,IAAI,UAAU,OAAQ,SAAS,WAAY;GAC3C,IAAK,cACJ,IAAI,UAAU,QAAQ,OACrB,6BACA,WACD;EAEF;CACD,GAAG,CAAE,KAAK,WAAY,CAAE;CAExB,MAAM,WAAA,GAAUC,mBAAAA,QAAAA,OACT,CAAE,oBAAoB,WAAY,GACxC,CAAE,oBAAoB,WAAY,CACnC;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,oBAAoB,UAArB;EAA8B,OAAQ;EACnC;CAC2B,CAAA;AAEhC;AAEA,MAAa,yBAAA,GAAwBC,mBAAAA,WAAAA,CAAY,mBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-blocks-focus-control.cjs","names":["useDispatch","blockEditorStore","useFocusControl","useRef","getWidgetIdFromBlock"],"sources":["../../../src/components/focus-control/use-blocks-focus-control.js"],"sourcesContent":["import { useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { useFocusControl } from '.';\n\nexport default function useBlocksFocusControl( blocks ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst [ focusedWidgetIdRef ] = useFocusControl();\n\n\tconst blocksRef = useRef( blocks );\n\n\tuseEffect( () => {\n\t\tblocksRef.current = blocks;\n\t}, [ blocks ] );\n\n\tuseEffect( () => {\n\t\tif ( focusedWidgetIdRef.current ) {\n\t\t\tconst focusedBlock = blocksRef.current.find(\n\t\t\t\t( block ) =>\n\t\t\t\t\tgetWidgetIdFromBlock( block ) === focusedWidgetIdRef.current\n\t\t\t);\n\n\t\t\tif ( focusedBlock ) {\n\t\t\t\tselectBlock( focusedBlock.clientId );\n\t\t\t\t// If the block is already being selected, the DOM node won't\n\t\t\t\t// get focused again automatically.\n\t\t\t\t// We select the DOM and focus it manually here.\n\t\t\t\tconst blockNode = document.querySelector(\n\t\t\t\t\t`[data-block=\"${ focusedBlock.clientId }\"]`\n\t\t\t\t);\n\t\t\t\tblockNode?.focus();\n\t\t\t}\n\t\t}\n\t}, [ focusedWidgetIdRef, selectBlock ] );\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAwB,sBAAuB,QAAS;CACvD,MAAM,EAAE,iBAAA,GAAgBA,gBAAAA,YAAAA,CAAaC,wBAAAA,KAAiB;CACtD,MAAM,CAAE,uBAAA,GAAuBC,YAAAA,gBAAAA,CAAgB;CAE/C,MAAM,aAAA,GAAYC,mBAAAA,OAAAA,CAAQ,MAAO;CAEjC,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,UAAU,UAAU;CACrB,GAAG,CAAE,MAAO,CAAE;CAEd,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,mBAAmB,SAAU;GACjC,MAAM,eAAe,UAAU,QAAQ,MACpC,WAAA,GACDC,mBAAAA,qBAAAA,CAAsB,KAAM,MAAM,mBAAmB,OACvD;GAEA,IAAK,cAAe;IACnB,YAAa,aAAa,QAAS;IAOnC,SAH2B,cAC1B,gBAAiB,aAAa,SAAU,GAEjC,CAAC,EAAE,MAAM;GAClB;EACD;CACD,GAAG,CAAE,oBAAoB,WAAY,CAAE;AACxC"}
1
+ {"version":3,"file":"use-blocks-focus-control.cjs","names":["useDispatch","blockEditorStore","useFocusControl","useRef","useEffect","getWidgetIdFromBlock"],"sources":["../../../src/components/focus-control/use-blocks-focus-control.js"],"sourcesContent":["import { useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { useFocusControl } from '.';\n\nexport default function useBlocksFocusControl( blocks ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst [ focusedWidgetIdRef ] = useFocusControl();\n\n\tconst blocksRef = useRef( blocks );\n\n\tuseEffect( () => {\n\t\tblocksRef.current = blocks;\n\t}, [ blocks ] );\n\n\tuseEffect( () => {\n\t\tif ( focusedWidgetIdRef.current ) {\n\t\t\tconst focusedBlock = blocksRef.current.find(\n\t\t\t\t( block ) =>\n\t\t\t\t\tgetWidgetIdFromBlock( block ) === focusedWidgetIdRef.current\n\t\t\t);\n\n\t\t\tif ( focusedBlock ) {\n\t\t\t\tselectBlock( focusedBlock.clientId );\n\t\t\t\t// If the block is already being selected, the DOM node won't\n\t\t\t\t// get focused again automatically.\n\t\t\t\t// We select the DOM and focus it manually here.\n\t\t\t\tconst blockNode = document.querySelector(\n\t\t\t\t\t`[data-block=\"${ focusedBlock.clientId }\"]`\n\t\t\t\t);\n\t\t\t\tblockNode?.focus();\n\t\t\t}\n\t\t}\n\t}, [ focusedWidgetIdRef, selectBlock ] );\n}\n"],"mappings":";;;;;;;;;;;AAMA,SAAwB,sBAAuB,QAAS;CACvD,MAAM,EAAE,iBAAA,GAAgBA,gBAAAA,YAAAA,CAAaC,wBAAAA,KAAiB;CACtD,MAAM,CAAE,uBAAA,GAAuBC,YAAAA,gBAAAA,CAAgB;CAE/C,MAAM,aAAA,GAAYC,mBAAAA,OAAAA,CAAQ,MAAO;CAEjCC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,UAAU,UAAU;CACrB,GAAG,CAAE,MAAO,CAAE;CAEdA,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IAAK,mBAAmB,SAAU;GACjC,MAAM,eAAe,UAAU,QAAQ,MACpC,WAAA,GACDC,mBAAAA,qBAAAA,CAAsB,KAAM,MAAM,mBAAmB,OACvD;GAEA,IAAK,cAAe;IACnB,YAAa,aAAa,QAAS;IAIjB,SAAS,cAC1B,gBAAiB,aAAa,SAAU,GAEjC,CAAC,EAAE,MAAM;GAClB;EACD;CACD,GAAG,CAAE,oBAAoB,WAAY,CAAE;AACxC"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,7 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let clsx = require("clsx");
28
- clsx = __toESM(clsx);
29
30
  let _wordpress_components = require("@wordpress/components");
30
31
  let _wordpress_block_editor = require("@wordpress/block-editor");
31
32
  let _wordpress_element = require("@wordpress/element");
@@ -33,10 +34,11 @@ let _wordpress_keycodes = require("@wordpress/keycodes");
33
34
  let _wordpress_i18n = require("@wordpress/i18n");
34
35
  let _wordpress_icons = require("@wordpress/icons");
35
36
  let ___inserter_index_jsx = require("../inserter/index.cjs");
36
- ___inserter_index_jsx = __toESM(___inserter_index_jsx);
37
37
  let ___more_menu_index_jsx = require("../more-menu/index.cjs");
38
- ___more_menu_index_jsx = __toESM(___more_menu_index_jsx);
39
38
  let react_jsx_runtime = require("react/jsx-runtime");
39
+ clsx = __toESM(clsx);
40
+ ___inserter_index_jsx = __toESM(___inserter_index_jsx);
41
+ ___more_menu_index_jsx = __toESM(___more_menu_index_jsx);
40
42
  // packages/customize-widgets/src/components/header/index.jsx
41
43
  function Header({ sidebar, inserter, isInserterOpened, setIsInserterOpened, isFixedToolbarActive }) {
42
44
  const [[hasUndo, hasRedo], setUndoRedo] = (0, _wordpress_element.useState)([sidebar.hasUndo(), sidebar.hasRedo()]);
@@ -46,16 +48,19 @@ function Header({ sidebar, inserter, isInserterOpened, setIsInserterOpened, isFi
46
48
  setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]);
47
49
  });
48
50
  }, [sidebar]);
49
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
51
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
50
52
  className: (0, clsx.default)("customize-widgets-header", { "is-fixed-toolbar-active": isFixedToolbarActive }),
51
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_block_editor.NavigableToolbar, {
53
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_block_editor.NavigableToolbar, {
52
54
  className: "customize-widgets-header-toolbar",
53
55
  "aria-label": (0, _wordpress_i18n.__)("Document tools"),
54
56
  children: [
55
57
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, {
56
58
  as: _wordpress_components.Button,
57
59
  icon: !(0, _wordpress_i18n.isRTL)() ? _wordpress_icons.undo : _wordpress_icons.redo,
58
- label: (0, _wordpress_i18n.__)("Undo"),
60
+ label: (0, _wordpress_i18n.__)(
61
+ /** translators: button label text should, if possible, be under 16 characters. */
62
+ "Undo"
63
+ ),
59
64
  shortcut: _wordpress_keycodes.displayShortcut.primary("z"),
60
65
  "aria-disabled": !hasUndo,
61
66
  onClick: hasUndo ? sidebar.undo : void 0,
@@ -65,7 +70,10 @@ function Header({ sidebar, inserter, isInserterOpened, setIsInserterOpened, isFi
65
70
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, {
66
71
  as: _wordpress_components.Button,
67
72
  icon: !(0, _wordpress_i18n.isRTL)() ? _wordpress_icons.redo : _wordpress_icons.undo,
68
- label: (0, _wordpress_i18n.__)("Redo"),
73
+ label: (0, _wordpress_i18n.__)(
74
+ /** translators: button label text should, if possible, be under 16 characters. */
75
+ "Redo"
76
+ ),
69
77
  shortcut,
70
78
  "aria-disabled": !hasRedo,
71
79
  onClick: hasRedo ? sidebar.redo : void 0,
@@ -83,10 +91,9 @@ function Header({ sidebar, inserter, isInserterOpened, setIsInserterOpened, isFi
83
91
  setIsInserterOpened((isOpen) => !isOpen);
84
92
  },
85
93
  size: "compact"
86
- }),
87
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___more_menu_index_jsx.default, {})
94
+ })
88
95
  ]
89
- })
96
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___more_menu_index_jsx.default, {})]
90
97
  }), (0, _wordpress_element.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___inserter_index_jsx.default, { setIsOpened: setIsInserterOpened }), inserter.contentContainer[0])] });
91
98
  }
92
99
  exports.default = Header;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useState","isAppleOS","displayShortcut","NavigableToolbar","__","ToolbarItem","Button","isRTL","undoIcon","redoIcon","plus","_x","MoreMenu","createPortal","Inserter"],"sources":["../../../src/components/header/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { createPortal, useEffect, useState } from '@wordpress/element';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport { plus, undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport Inserter from '../inserter';\nimport MoreMenu from '../more-menu';\n\nfunction Header( {\n\tsidebar,\n\tinserter,\n\tisInserterOpened,\n\tsetIsInserterOpened,\n\tisFixedToolbarActive,\n} ) {\n\tconst [ [ hasUndo, hasRedo ], setUndoRedo ] = useState( [\n\t\tsidebar.hasUndo(),\n\t\tsidebar.hasRedo(),\n\t] );\n\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribeHistory( () => {\n\t\t\tsetUndoRedo( [ sidebar.hasUndo(), sidebar.hasRedo() ] );\n\t\t} );\n\t}, [ sidebar ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'customize-widgets-header', {\n\t\t\t\t\t'is-fixed-toolbar-active': isFixedToolbarActive,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<NavigableToolbar\n\t\t\t\t\tclassName=\"customize-widgets-header-toolbar\"\n\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasUndo }\n\t\t\t\t\t\tonClick={ hasUndo ? sidebar.undo : undefined }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button undo-button\"\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t// If there are no redo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasRedo }\n\t\t\t\t\t\tonClick={ hasRedo ? sidebar.redo : undefined }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button redo-button\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"customize-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t'Add block',\n\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsInserterOpened( ( isOpen ) => ! isOpen );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t\t<MoreMenu />\n\t\t\t\t</NavigableToolbar>\n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AAI;KAIxC,iBAAgB,CAAE;KAClB,SAAU,UAAU,QAAQ,OAAO,KAAA;KACnC,MAAK;KACL,WAAU;IACV,CAAA;IACD,iBAAA,GAAA,kBAAA,IAAA,CAACG,sBAAAA,aAAD;KACC,IAAKC,sBAAAA;KACL,MAAO,EAAA,GAAEC,gBAAAA,MAAAA,CAAM,IAAIE,iBAAAA,OAAWD,iBAAAA;KAE9B,QAAA,GAAQJ,gBAAAA,GAAAA,CAAI,MAAO;KACR;KAIX,iBAAgB,CAAE;KAClB,SAAU,UAAU,QAAQ,OAAO,KAAA;KACnC,MAAK;KACL,WAAU;IACV,CAAA;IAED,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,aAAD;KACC,IAAKC,sBAAAA;KACL,WAAU;KACV,WAAY;KACZ,SAAQ;KACR,MAAOI,iBAAAA;KACP,QAAA,GAAQC,gBAAAA,GAAAA,CACP,aACA,yCACD;KACA,eAAgB;MACf,qBAAuB,WAAY,CAAE,MAAO;KAC7C;KACA,MAAK;IACL,CAAA;IACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,SAAD,CAAW,CAAA;GACM;;CACd,CAAA,IAAA,GAEHC,mBAAAA,aAAAA,CACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,SAAD,EAAU,aAAc,oBAAuB,CAAA,GAC/C,SAAS,iBAAkB,EAC5B,CACC,EAAA,CAAA;AAEJ"}
1
+ {"version":3,"file":"index.cjs","names":["useState","isAppleOS","displayShortcut","useEffect","clsx","NavigableToolbar","__","ToolbarItem","Button","isRTL","undoIcon","redoIcon","plus","_x","MoreMenu","createPortal","Inserter"],"sources":["../../../src/components/header/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { createPortal, useEffect, useState } from '@wordpress/element';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport { plus, undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport Inserter from '../inserter';\nimport MoreMenu from '../more-menu';\n\nfunction Header( {\n\tsidebar,\n\tinserter,\n\tisInserterOpened,\n\tsetIsInserterOpened,\n\tisFixedToolbarActive,\n} ) {\n\tconst [ [ hasUndo, hasRedo ], setUndoRedo ] = useState( [\n\t\tsidebar.hasUndo(),\n\t\tsidebar.hasRedo(),\n\t] );\n\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tuseEffect( () => {\n\t\treturn sidebar.subscribeHistory( () => {\n\t\t\tsetUndoRedo( [ sidebar.hasUndo(), sidebar.hasRedo() ] );\n\t\t} );\n\t}, [ sidebar ] );\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'customize-widgets-header', {\n\t\t\t\t\t'is-fixed-toolbar-active': isFixedToolbarActive,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<NavigableToolbar\n\t\t\t\t\tclassName=\"customize-widgets-header-toolbar\"\n\t\t\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\t\t>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Undo' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasUndo }\n\t\t\t\t\t\tonClick={ hasUndo ? sidebar.undo : undefined }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button undo-button\"\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'Redo' ) }\n\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t// If there are no redo levels we don't want to actually disable this\n\t\t\t\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\t\t\t\taria-disabled={ ! hasRedo }\n\t\t\t\t\t\tonClick={ hasRedo ? sidebar.redo : undefined }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tclassName=\"customize-widgets-editor-history-button redo-button\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"customize-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t'Add block',\n\t\t\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsInserterOpened( ( isOpen ) => ! isOpen );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</NavigableToolbar>\n\t\t\t\t<MoreMenu />\n\t\t\t</div>\n\n\t\t\t{ createPortal(\n\t\t\t\t<Inserter setIsOpened={ setIsInserterOpened } />,\n\t\t\t\tinserter.contentContainer[ 0 ]\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAS,OA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AAAA,CAAM,IAAIE,iBAAAA,OAAWD,iBAAAA;KAE9B,QAAA,GAAQJ,gBAAAA,GAAAA;;MAAI;KAAO;KACR;KAIX,iBAAgB,CAAE;KAClB,SAAU,UAAU,QAAQ,OAAO,KAAA;KACnC,MAAK;KACL,WAAU;IACV,CAAA;IAED,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,aAAD;KACC,IAAKC,sBAAAA;KACL,WAAU;KACV,WAAY;KACZ,SAAQ;KACR,MAAOI,iBAAAA;KACP,QAAA,GAAQC,gBAAAA,GAAAA,CACP,aACA,yCACD;KACA,eAAgB;MACf,qBAAuB,WAAY,CAAE,MAAO;KAC7C;KACA,MAAK;IACL,CAAA;GACgB;EAClB,CAAA,GAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,SAAD,CAAW,CAAA,CACP;CAEHC,CAAAA,IAAAA,GAAAA,mBAAAA,aAAAA,CACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,SAAD,EAAU,aAAc,oBAAuB,CAAA,GAC/C,SAAS,iBAAkB,EAC5B,CACC,EAAA,CAAA;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-inserter.cjs","names":["useSelect","customizeWidgetsStore","useDispatch","useCallback","selectStore"],"sources":["../../../src/components/inserter/use-inserter.js"],"sourcesContent":["import { useEffect, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch, select as selectStore } from '@wordpress/data';\nimport { store as customizeWidgetsStore } from '../../store';\n\nexport default function useInserter( inserter ) {\n\tconst isInserterOpened = useSelect(\n\t\t( select ) => select( customizeWidgetsStore ).isInserterOpened(),\n\t\t[]\n\t);\n\tconst { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n\n\tuseEffect( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\tinserter.open();\n\t\t} else {\n\t\t\tinserter.close();\n\t\t}\n\t}, [ inserter, isInserterOpened ] );\n\n\treturn [\n\t\tisInserterOpened,\n\t\tuseCallback(\n\t\t\t( updater ) => {\n\t\t\t\tlet isOpen = updater;\n\t\t\t\tif ( typeof updater === 'function' ) {\n\t\t\t\t\tisOpen = updater(\n\t\t\t\t\t\tselectStore( customizeWidgetsStore ).isInserterOpened()\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsetIsInserterOpened( isOpen );\n\t\t\t},\n\t\t\t[ setIsInserterOpened ]\n\t\t),\n\t];\n}\n"],"mappings":";;;;;;;;;AAIA,SAAwB,YAAa,UAAW;CAC/C,MAAM,oBAAA,GAAmBA,gBAAAA,UAAAA,EACtB,WAAY,OAAQC,qBAAAA,KAAsB,CAAC,CAAC,iBAAiB,GAC/D,CAAC,CACF;CACA,MAAM,EAAE,yBAAA,GAAwBC,gBAAAA,YAAAA,CAAaD,qBAAAA,KAAsB;CAEnE,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,kBACJ,SAAS,KAAK;OAEd,SAAS,MAAM;CAEjB,GAAG,CAAE,UAAU,gBAAiB,CAAE;CAElC,OAAO,CACN,mBAAA,GACAE,mBAAAA,YAAAA,EACG,YAAa;EACd,IAAI,SAAS;EACb,IAAK,OAAO,YAAY,YACvB,SAAS,SAAA,GACRC,gBAAAA,OAAAA,CAAaH,qBAAAA,KAAsB,CAAC,CAAC,iBAAiB,CACvD;EAGD,oBAAqB,MAAO;CAC7B,GACA,CAAE,mBAAoB,CACvB,CACD;AACD"}
1
+ {"version":3,"file":"use-inserter.cjs","names":["useSelect","customizeWidgetsStore","useDispatch","useEffect","useCallback","selectStore"],"sources":["../../../src/components/inserter/use-inserter.js"],"sourcesContent":["import { useEffect, useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch, select as selectStore } from '@wordpress/data';\nimport { store as customizeWidgetsStore } from '../../store';\n\nexport default function useInserter( inserter ) {\n\tconst isInserterOpened = useSelect(\n\t\t( select ) => select( customizeWidgetsStore ).isInserterOpened(),\n\t\t[]\n\t);\n\tconst { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n\n\tuseEffect( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\tinserter.open();\n\t\t} else {\n\t\t\tinserter.close();\n\t\t}\n\t}, [ inserter, isInserterOpened ] );\n\n\treturn [\n\t\tisInserterOpened,\n\t\tuseCallback(\n\t\t\t( updater ) => {\n\t\t\t\tlet isOpen = updater;\n\t\t\t\tif ( typeof updater === 'function' ) {\n\t\t\t\t\tisOpen = updater(\n\t\t\t\t\t\tselectStore( customizeWidgetsStore ).isInserterOpened()\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tsetIsInserterOpened( isOpen );\n\t\t\t},\n\t\t\t[ setIsInserterOpened ]\n\t\t),\n\t];\n}\n"],"mappings":";;;;;;;;;AAIA,SAAwB,YAAa,UAAW;CAC/C,MAAM,oBAAA,GAAmBA,gBAAAA,UAAAA,EACtB,WAAY,OAAQC,qBAAAA,KAAsB,CAAC,CAAC,iBAAiB,GAC/D,CAAC,CACF;CACA,MAAM,EAAE,yBAAA,GAAwBC,gBAAAA,YAAAA,CAAaD,qBAAAA,KAAsB;CAEnEE,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IAAK,kBACJ,SAAS,KAAK;OAEd,SAAS,MAAM;CAEjB,GAAG,CAAE,UAAU,gBAAiB,CAAE;CAElC,OAAO,CACN,mBAAA,GACAC,mBAAAA,YAAAA,EACG,YAAa;EACd,IAAI,SAAS;EACb,IAAK,OAAO,YAAY,YACvB,SAAS,SAAA,GACRC,gBAAAA,OAAAA,CAAaJ,qBAAAA,KAAsB,CAAC,CAAC,iBAAiB,CACvD;EAGD,oBAAqB,MAAO;CAC7B,GACA,CAAE,mBAAoB,CACvB,CACD;AACD"}
@@ -5,6 +5,7 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  let _wordpress_i18n = require("@wordpress/i18n");
7
7
  // packages/customize-widgets/src/components/keyboard-shortcut-help-modal/config.js
8
+ /** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */
8
9
  const textFormattingShortcuts = [
9
10
  {
10
11
  keyCombination: {
@@ -36,6 +37,10 @@ const textFormattingShortcuts = [
36
37
  },
37
38
  {
38
39
  keyCombination: { character: "[[" },
40
+ ariaLabel: (0, _wordpress_i18n.__)(
41
+ /** translators: The keyboard sequence [[, pressing the left bracket key twice. */
42
+ "Left bracket twice"
43
+ ),
39
44
  description: (0, _wordpress_i18n.__)("Insert a link to a post or page.")
40
45
  },
41
46
  {
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","names":["__"],"sources":["../../../src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\n\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {\n\t\t\tmodifier: 'access',\n\t\t\tcharacter: '0',\n\t\t},\n\t\taliases: [\n\t\t\t{\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '7',\n\t\t\t},\n\t\t],\n\t\tdescription: __( 'Convert the current heading to a paragraph.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: '1-6' },\n\t\tdescription: __(\n\t\t\t'Convert the current paragraph or heading to a heading of level 1 to 6.'\n\t\t),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'SPACE' },\n\t\tdescription: __( 'Add non breaking space.' ),\n\t},\n];\n"],"mappings":";;;;;;;AAEA,MAAa,0BAA0B;CACtC;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gCAAiC;CACnD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,wCAAyC;CAC3D;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;EAC3D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gBAAiB;CACnC;CACA;EACC,gBAAgB,EAAE,WAAW,KAAK;EAClC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,qCAAsC;CACxD;CACA;EACC,gBAAgB;GACf,UAAU;GACV,WAAW;EACZ;EACA,SAAS,CACR;GACC,UAAU;GACV,WAAW;EACZ,CACD;EACA,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,6CAA8C;CAChE;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAM;EACvD,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,wEACD;CACD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAQ;EAC/D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,yBAA0B;CAC5C;AACD"}
1
+ {"version":3,"file":"config.cjs","names":["__"],"sources":["../../../src/components/keyboard-shortcut-help-modal/config.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\n\n/** @type {Array<import('react').ComponentProps<typeof import('./shortcut').default>>} */\nexport const textFormattingShortcuts = [\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'b' },\n\t\tdescription: __( 'Make the selected text bold.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'i' },\n\t\tdescription: __( 'Make the selected text italic.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'k' },\n\t\tdescription: __( 'Convert the selected text into a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'k' },\n\t\tdescription: __( 'Remove a link.' ),\n\t},\n\t{\n\t\tkeyCombination: { character: '[[' },\n\t\t/* translators: The keyboard sequence [[, pressing the left bracket key twice. */\n\t\tariaLabel: __( 'Left bracket twice' ),\n\t\tdescription: __( 'Insert a link to a post or page.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primary', character: 'u' },\n\t\tdescription: __( 'Underline the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'd' },\n\t\tdescription: __( 'Strikethrough the selected text.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: 'x' },\n\t\tdescription: __( 'Make the selected text inline code.' ),\n\t},\n\t{\n\t\tkeyCombination: {\n\t\t\tmodifier: 'access',\n\t\t\tcharacter: '0',\n\t\t},\n\t\taliases: [\n\t\t\t{\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '7',\n\t\t\t},\n\t\t],\n\t\tdescription: __( 'Convert the current heading to a paragraph.' ),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'access', character: '1-6' },\n\t\tdescription: __(\n\t\t\t'Convert the current paragraph or heading to a heading of level 1 to 6.'\n\t\t),\n\t},\n\t{\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'SPACE' },\n\t\tdescription: __( 'Add non breaking space.' ),\n\t},\n];\n"],"mappings":";;;;;;;;AAGA,MAAa,0BAA0B;CACtC;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gCAAiC;CACnD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,wCAAyC;CAC3D;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;EAC3D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,gBAAiB;CACnC;CACA;EACC,gBAAgB,EAAE,WAAW,KAAK;EAElC,YAAA,GAAWA,gBAAAA,GAAAA;;GAAI;EAAqB;EACpC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;EACtD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;CACjD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,kCAAmC;CACrD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAI;EACrD,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,qCAAsC;CACxD;CACA;EACC,gBAAgB;GACf,UAAU;GACV,WAAW;EACZ;EACA,SAAS,CACR;GACC,UAAU;GACV,WAAW;EACZ,CACD;EACA,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,6CAA8C;CAChE;CACA;EACC,gBAAgB;GAAE,UAAU;GAAU,WAAW;EAAM;EACvD,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,wEACD;CACD;CACA;EACC,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAQ;EAC/D,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,yBAA0B;CAC5C;AACD"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -27,8 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
29
  let _wordpress_data = require("@wordpress/data");
28
30
  let _wordpress_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
29
31
  let __shortcut_jsx = require("./shortcut.cjs");
30
- __shortcut_jsx = __toESM(__shortcut_jsx);
31
32
  let react_jsx_runtime = require("react/jsx-runtime");
33
+ __shortcut_jsx = __toESM(__shortcut_jsx);
32
34
  // packages/customize-widgets/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx
33
35
  function DynamicShortcut({ name }) {
34
36
  const { keyCombination, description, aliases } = (0, _wordpress_data.useSelect)((select) => {
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-shortcut.cjs","names":["useSelect","keyboardShortcutsStore","Shortcut"],"sources":["../../../src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport Shortcut from './shortcut';\n\nfunction DynamicShortcut( { name } ) {\n\tconst { keyCombination, description, aliases } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetShortcutKeyCombination,\n\t\t\t\tgetShortcutDescription,\n\t\t\t\tgetShortcutAliases,\n\t\t\t} = select( keyboardShortcutsStore );\n\n\t\t\treturn {\n\t\t\t\tkeyCombination: getShortcutKeyCombination( name ),\n\t\t\t\taliases: getShortcutAliases( name ),\n\t\t\t\tdescription: getShortcutDescription( name ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\n\tif ( ! keyCombination ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Shortcut\n\t\t\tkeyCombination={ keyCombination }\n\t\t\tdescription={ description }\n\t\t\taliases={ aliases }\n\t\t/>\n\t);\n}\n\nexport default DynamicShortcut;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,gBAAiB,EAAE,QAAS;CACpC,MAAM,EAAE,gBAAgB,aAAa,aAAA,GAAYA,gBAAAA,UAAAA,EAC9C,WAAY;EACb,MAAM,EACL,2BACA,wBACA,uBACG,OAAQC,8BAAAA,KAAuB;EAEnC,OAAO;GACN,gBAAgB,0BAA2B,IAAK;GAChD,SAAS,mBAAoB,IAAK;GAClC,aAAa,uBAAwB,IAAK;EAC3C;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAK,CAAE,gBACN,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,SAAD;EACkB;EACH;EACJ;CACV,CAAA;AAEH"}
1
+ {"version":3,"file":"dynamic-shortcut.cjs","names":["useSelect","keyboardShortcutsStore","Shortcut"],"sources":["../../../src/components/keyboard-shortcut-help-modal/dynamic-shortcut.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport Shortcut from './shortcut';\n\nfunction DynamicShortcut( { name } ) {\n\tconst { keyCombination, description, aliases } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetShortcutKeyCombination,\n\t\t\t\tgetShortcutDescription,\n\t\t\t\tgetShortcutAliases,\n\t\t\t} = select( keyboardShortcutsStore );\n\n\t\t\treturn {\n\t\t\t\tkeyCombination: getShortcutKeyCombination( name ),\n\t\t\t\taliases: getShortcutAliases( name ),\n\t\t\t\tdescription: getShortcutDescription( name ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\n\tif ( ! keyCombination ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Shortcut\n\t\t\tkeyCombination={ keyCombination }\n\t\t\tdescription={ description }\n\t\t\taliases={ aliases }\n\t\t/>\n\t);\n}\n\nexport default DynamicShortcut;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,gBAAiB,EAAE,QAAS;CACpC,MAAM,EAAE,gBAAgB,aAAa,aAAA,GAAYA,gBAAAA,UAAAA,EAC9C,WAAY;EACb,MAAM,EACL,2BACA,wBACA,uBACG,OAAQC,8BAAAA,KAAuB;EAEnC,OAAO;GACN,gBAAgB,0BAA2B,IAAK;GAChD,SAAS,mBAAoB,IAAK;GAClC,aAAa,uBAAwB,IAAK;EAC3C;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAK,CAAE,gBACN,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,SAAD;EACkB;EACH;EACJ;CACV,CAAA;AAEH"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,7 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let clsx = require("clsx");
28
- clsx = __toESM(clsx);
29
30
  let _wordpress_components = require("@wordpress/components");
30
31
  let _wordpress_i18n = require("@wordpress/i18n");
31
32
  let _wordpress_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
@@ -33,10 +34,11 @@ let _wordpress_data = require("@wordpress/data");
33
34
  let _wordpress_element = require("@wordpress/element");
34
35
  let __config_js = require("./config.cjs");
35
36
  let __shortcut_jsx = require("./shortcut.cjs");
36
- __shortcut_jsx = __toESM(__shortcut_jsx);
37
37
  let __dynamic_shortcut_jsx = require("./dynamic-shortcut.cjs");
38
- __dynamic_shortcut_jsx = __toESM(__dynamic_shortcut_jsx);
39
38
  let react_jsx_runtime = require("react/jsx-runtime");
39
+ clsx = __toESM(clsx);
40
+ __shortcut_jsx = __toESM(__shortcut_jsx);
41
+ __dynamic_shortcut_jsx = __toESM(__dynamic_shortcut_jsx);
40
42
  // packages/customize-widgets/src/components/keyboard-shortcut-help-modal/index.jsx
41
43
  const ShortcutList = ({ shortcuts }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
42
44
  className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-list",
@@ -99,8 +101,7 @@ function KeyboardShortcutHelpModal({ isModalActive, toggleModal }) {
99
101
  categoryName: "block",
100
102
  additionalShortcuts: [{
101
103
  keyCombination: { character: "/" },
102
- description: (0, _wordpress_i18n.__)("Change the block type after adding a new paragraph."),
103
- ariaLabel: (0, _wordpress_i18n.__)("Forward-slash")
104
+ description: (0, _wordpress_i18n.__)("Change the block type after adding a new paragraph.")
104
105
  }]
105
106
  }),
106
107
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShortcutSection, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["DynamicShortcut","Shortcut","useSelect","keyboardShortcutsStore","useDispatch","__","Modal","textFormattingShortcuts"],"sources":["../../../src/components/keyboard-shortcut-help-modal/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nconst ShortcutList = ( { shortcuts } ) => (\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\t<ul\n\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-list\"\n\t\trole=\"list\"\n\t>\n\t\t{ shortcuts.map( ( shortcut, index ) => (\n\t\t\t<li\n\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut\"\n\t\t\t\tkey={ index }\n\t\t\t>\n\t\t\t\t{ typeof shortcut === 'string' ? (\n\t\t\t\t\t<DynamicShortcut name={ shortcut } />\n\t\t\t\t) : (\n\t\t\t\t\t<Shortcut { ...shortcut } />\n\t\t\t\t) }\n\t\t\t</li>\n\t\t) ) }\n\t</ul>\n\t/* eslint-enable jsx-a11y/no-redundant-roles */\n);\n\nconst ShortcutSection = ( { title, shortcuts, className } ) => (\n\t<section\n\t\tclassName={ clsx(\n\t\t\t'customize-widgets-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"customize-widgets-keyboard-shortcut-help-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t) }\n\t\t<ShortcutList shortcuts={ shortcuts } />\n\t</section>\n);\n\nconst ShortcutCategorySection = ( {\n\ttitle,\n\tcategoryName,\n\tadditionalShortcuts = [],\n} ) => {\n\tconst categoryShortcuts = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( keyboardShortcutsStore ).getCategoryShortcuts(\n\t\t\t\tcategoryName\n\t\t\t);\n\t\t},\n\t\t[ categoryName ]\n\t);\n\n\treturn (\n\t\t<ShortcutSection\n\t\t\ttitle={ title }\n\t\t\tshortcuts={ categoryShortcuts.concat( additionalShortcuts ) }\n\t\t/>\n\t);\n};\n\nexport default function KeyboardShortcutHelpModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/customize-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut( 'core/customize-widgets/keyboard-shortcuts', toggleModal );\n\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/customize-widgets/keyboard-shortcuts' ] }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Global shortcuts' ) }\n\t\t\t\tcategoryName=\"global\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Selection shortcuts' ) }\n\t\t\t\tcategoryName=\"selection\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Block shortcuts' ) }\n\t\t\t\tcategoryName=\"block\"\n\t\t\t\tadditionalShortcuts={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tkeyCombination: { character: '/' },\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Change the block type after adding a new paragraph.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t/* translators: The forward-slash character. e.g. '/'. */\n\t\t\t\t\t\tariaLabel: __( 'Forward-slash' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t\t<ShortcutSection\n\t\t\t\ttitle={ __( 'Text formatting' ) }\n\t\t\t\tshortcuts={ textFormattingShortcuts }\n\t\t\t/>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,gBAAiB,EAAE,gBAMxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACC,WAAU;CACV,MAAK;CAEH,UAAA,UAAU,KAA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BAAA,YAAA,CAAa,6CAA6C,WAAY;CAEtE,IAAK,CAAE,eACN,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,sBAAAA,OAAD;EACC,WAAU;EACV,QAAA,GAAQD,gBAAAA,GAAAA,CAAI,oBAAqB;EACjC,gBAAiB;EAHlB,UAAA;GAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD;IACC,WAAU;IACV,WAAY,CAAE,2CAA4C;GAC1D,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,yBAAD;IACC,QAAA,GAAQA,gBAAAA,GAAAA,CAAI,kBAAmB;IAC/B,cAAa;GACb,CAAA;GAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,yBAAD;IACC,QAAA,GAAQA,gBAAAA,GAAAA,CAAI,qBAAsB;IAClC,cAAa;GACb,CAAA;GAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,yBAAD;IACC,QAAA,GAAQA,gBAAAA,GAAAA,CAAI,iBAAkB;IAC9B,cAAa;IACb,qBAAsB,CACrB;KACC,gBAAgB,EAAE,WAAW,IAAI;KACjC,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,qDACD;KAEA,YAAA,GAAWA,gBAAAA,GAAAA,CAAI,eAAgB;IAChC,CACD;GACA,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD;IACC,QAAA,GAAQA,gBAAAA,GAAAA,CAAI,iBAAkB;IAC9B,WAAYE,YAAAA;GACZ,CAAA;EACK;;AAET"}
1
+ {"version":3,"file":"index.cjs","names":["DynamicShortcut","Shortcut","clsx","useSelect","keyboardShortcutsStore","useDispatch","useEffect","__","useShortcut","Modal","textFormattingShortcuts"],"sources":["../../../src/components/keyboard-shortcut-help-modal/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nconst ShortcutList = ( { shortcuts } ) => (\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\t<ul\n\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-list\"\n\t\trole=\"list\"\n\t>\n\t\t{ shortcuts.map( ( shortcut, index ) => (\n\t\t\t<li\n\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut\"\n\t\t\t\tkey={ index }\n\t\t\t>\n\t\t\t\t{ typeof shortcut === 'string' ? (\n\t\t\t\t\t<DynamicShortcut name={ shortcut } />\n\t\t\t\t) : (\n\t\t\t\t\t<Shortcut { ...shortcut } />\n\t\t\t\t) }\n\t\t\t</li>\n\t\t) ) }\n\t</ul>\n\t/* eslint-enable jsx-a11y/no-redundant-roles */\n);\n\nconst ShortcutSection = ( { title, shortcuts, className } ) => (\n\t<section\n\t\tclassName={ clsx(\n\t\t\t'customize-widgets-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"customize-widgets-keyboard-shortcut-help-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t) }\n\t\t<ShortcutList shortcuts={ shortcuts } />\n\t</section>\n);\n\nconst ShortcutCategorySection = ( {\n\ttitle,\n\tcategoryName,\n\tadditionalShortcuts = [],\n} ) => {\n\tconst categoryShortcuts = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( keyboardShortcutsStore ).getCategoryShortcuts(\n\t\t\t\tcategoryName\n\t\t\t);\n\t\t},\n\t\t[ categoryName ]\n\t);\n\n\treturn (\n\t\t<ShortcutSection\n\t\t\ttitle={ title }\n\t\t\tshortcuts={ categoryShortcuts.concat( additionalShortcuts ) }\n\t\t/>\n\t);\n};\n\nexport default function KeyboardShortcutHelpModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/customize-widgets/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut( 'core/customize-widgets/keyboard-shortcuts', toggleModal );\n\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/customize-widgets/keyboard-shortcuts' ] }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Global shortcuts' ) }\n\t\t\t\tcategoryName=\"global\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Selection shortcuts' ) }\n\t\t\t\tcategoryName=\"selection\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Block shortcuts' ) }\n\t\t\t\tcategoryName=\"block\"\n\t\t\t\tadditionalShortcuts={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tkeyCombination: { character: '/' },\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Change the block type after adding a new paragraph.'\n\t\t\t\t\t\t),\n\t\t\t\t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K;;AAET"}
@@ -5,24 +5,45 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  let _wordpress_element = require("@wordpress/element");
7
7
  let _wordpress_keycodes = require("@wordpress/keycodes");
8
+ let _wordpress_ui = require("@wordpress/ui");
8
9
  let react_jsx_runtime = require("react/jsx-runtime");
9
10
  // packages/customize-widgets/src/components/keyboard-shortcut-help-modal/shortcut.jsx
10
- function KeyCombination({ keyCombination, forceAriaLabel }) {
11
- const shortcut = keyCombination.modifier ? _wordpress_keycodes.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
12
- const ariaLabel = keyCombination.modifier ? _wordpress_keycodes.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
13
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
11
+ /**
12
+ * @typedef {Object} ShortcutKeyCombination
13
+ * @property {string} character Shortcut key.
14
+ * @property {import('@wordpress/keycodes').WPKeycodeModifier | null} [modifier] Optional shortcut modifier.
15
+ */
16
+ /**
17
+ * @param {Object} props Component props.
18
+ * @param {ShortcutKeyCombination} props.keyCombination Shortcut to display.
19
+ * @param {string} [props.ariaLabel] Custom readable shortcut label.
20
+ */
21
+ function KeyCombination({ keyCombination, ariaLabel }) {
22
+ const { character, modifier } = keyCombination;
23
+ const normalizedModifier = modifier ?? "undefined";
24
+ const keys = _wordpress_keycodes.displayShortcutList[normalizedModifier](character);
25
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("kbd", {
14
26
  className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
15
27
  dir: "ltr",
16
- "aria-label": forceAriaLabel || ariaLabel,
17
- children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
18
- if (character === "+") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_element.Fragment, { children: character }, index);
19
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
28
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.VisuallyHidden, {
29
+ render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {}),
30
+ children: ariaLabel || _wordpress_keycodes.shortcutAriaLabel[normalizedModifier](character)
31
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
32
+ "aria-hidden": "true",
33
+ children: keys.map((key, index) => key === "+" && index < keys.length - 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_element.Fragment, { children: key }, index) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
20
34
  className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key",
21
- children: character
22
- }, index);
23
- })
35
+ children: key
36
+ }, index))
37
+ })]
24
38
  });
25
39
  }
40
+ /**
41
+ * @param {Object} props Component props.
42
+ * @param {string} props.description Description of the shortcut action.
43
+ * @param {ShortcutKeyCombination} props.keyCombination Primary shortcut.
44
+ * @param {ShortcutKeyCombination[]} [props.aliases] Alternative shortcuts.
45
+ * @param {string} [props.ariaLabel] Custom readable shortcut label.
46
+ */
26
47
  function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
27
48
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
28
49
  className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-description",
@@ -31,10 +52,10 @@ function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
31
52
  className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-term",
32
53
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyCombination, {
33
54
  keyCombination,
34
- forceAriaLabel: ariaLabel
55
+ ariaLabel
35
56
  }), aliases.map((alias, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyCombination, {
36
57
  keyCombination: alias,
37
- forceAriaLabel: ariaLabel
58
+ ariaLabel
38
59
  }, index))]
39
60
  })] });
40
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shortcut.cjs","names":["displayShortcutList","shortcutAriaLabel","Fragment"],"sources":["../../../src/components/keyboard-shortcut-help-modal/shortcut.jsx"],"sourcesContent":["import { Fragment } from '@wordpress/element';\nimport { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';\n\nfunction KeyCombination( { keyCombination, forceAriaLabel } ) {\n\tconst shortcut = keyCombination.modifier\n\t\t? displayShortcutList[ keyCombination.modifier ](\n\t\t\t\tkeyCombination.character\n\t\t\t)\n\t\t: keyCombination.character;\n\tconst ariaLabel = keyCombination.modifier\n\t\t? shortcutAriaLabel[ keyCombination.modifier ](\n\t\t\t\tkeyCombination.character\n\t\t\t)\n\t\t: keyCombination.character;\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination\"\n\t\t\tdir=\"ltr\"\n\t\t\taria-label={ forceAriaLabel || ariaLabel }\n\t\t>\n\t\t\t{ ( Array.isArray( shortcut ) ? shortcut : [ shortcut ] ).map(\n\t\t\t\t( character, index ) => {\n\t\t\t\t\tif ( character === '+' ) {\n\t\t\t\t\t\treturn <Fragment key={ index }>{ character }</Fragment>;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<kbd\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ character }\n\t\t\t\t\t\t</kbd>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t</kbd>\n\t);\n}\n\nfunction Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-description\">\n\t\t\t\t{ description }\n\t\t\t</div>\n\t\t\t<div className=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-term\">\n\t\t\t\t<KeyCombination\n\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\tforceAriaLabel={ ariaLabel }\n\t\t\t\t/>\n\t\t\t\t{ aliases.map( ( alias, index ) => (\n\t\t\t\t\t<KeyCombination\n\t\t\t\t\t\tkeyCombination={ alias }\n\t\t\t\t\t\tforceAriaLabel={ ariaLabel }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Shortcut;\n"],"mappings":";;;;;;;;;AAGA,SAAS,eAAgB,EAAE,gBAAgB,kBAAmB;CAC7D,MAAM,WAAW,eAAe,WAC7BA,oBAAAA,oBAAqB,eAAe,SAAU,CAC9C,eAAe,SAChB,IACC,eAAe;CAClB,MAAM,YAAY,eAAe,WAC9BC,oBAAAA,kBAAmB,eAAe,SAAU,CAC5C,eAAe,SAChB,IACC,eAAe;CAElB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,WAAU;EACV,KAAI;EACJ,cAAa,kBAAkB;EAE3B,WAAA,MAAM,QAAS,QAAS,IAAI,WAAW,CAAE,QAAS,EAAA,CAAI,KACvD,WAAW,UAAW;GACvB,IAAK,cAAc,KAClB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,UAAD,EAAA,UAA0B,UAAqB,GAA/B,KAA+B;GAGvD,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAEC,WAAU;IAER,UAAA;GACE,GAJE,KAIF;EAEP,CACD;CACI,CAAA;AAEP;AAEA,SAAS,SAAU,EAAE,aAAa,gBAAgB,UAAU,CAAC,GAAG,aAAc;CAC7E,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EACZ,UAAA;CACE,CAAA,GACL,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GACkB;GACjB,gBAAiB;EACjB,CAAA,GACC,QAAQ,KAAO,OAAO,UACvB,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GACC,gBAAiB;GACjB,gBAAiB;EAEjB,GADM,KACN,CACA,CACE;CACJ,CAAA,CAAA,EAAA,CAAA;AAEJ"}
1
+ {"version":3,"file":"shortcut.cjs","names":["displayShortcutList","VisuallyHidden","shortcutAriaLabel","Fragment"],"sources":["../../../src/components/keyboard-shortcut-help-modal/shortcut.jsx"],"sourcesContent":["import { Fragment } from '@wordpress/element';\nimport { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * @typedef {Object} ShortcutKeyCombination\n * @property {string} character Shortcut key.\n * @property {import('@wordpress/keycodes').WPKeycodeModifier | null} [modifier] Optional shortcut modifier.\n */\n\n/**\n * @param {Object} props Component props.\n * @param {ShortcutKeyCombination} props.keyCombination Shortcut to display.\n * @param {string} [props.ariaLabel] Custom readable shortcut label.\n */\nfunction KeyCombination( { keyCombination, ariaLabel } ) {\n\tconst { character, modifier } = keyCombination;\n\tconst normalizedModifier = modifier ?? 'undefined';\n\tconst keys = displayShortcutList[ normalizedModifier ]( character );\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination\"\n\t\t\tdir=\"ltr\"\n\t\t>\n\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t{ ariaLabel ||\n\t\t\t\t\tshortcutAriaLabel[ normalizedModifier ]( character ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t{ keys.map( ( key, index ) =>\n\t\t\t\t\tkey === '+' && index < keys.length - 1 ? (\n\t\t\t\t\t\t<Fragment key={ index }>{ key }</Fragment>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<kbd\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tclassName=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ key }\n\t\t\t\t\t\t</kbd>\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</kbd>\n\t);\n}\n\n/**\n * @param {Object} props Component props.\n * @param {string} props.description Description of the shortcut action.\n * @param {ShortcutKeyCombination} props.keyCombination Primary shortcut.\n * @param {ShortcutKeyCombination[]} [props.aliases] Alternative shortcuts.\n * @param {string} [props.ariaLabel] Custom readable shortcut label.\n */\nfunction Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-description\">\n\t\t\t\t{ description }\n\t\t\t</div>\n\t\t\t<div className=\"customize-widgets-keyboard-shortcut-help-modal__shortcut-term\">\n\t\t\t\t<KeyCombination\n\t\t\t\t\tkeyCombination={ keyCombination }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t/>\n\t\t\t\t{ aliases.map( ( alias, index ) => (\n\t\t\t\t\t<KeyCombination\n\t\t\t\t\t\tkeyCombination={ alias }\n\t\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default Shortcut;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,SAAS,eAAgB,EAAE,gBAAgB,aAAc;CACxD,MAAM,EAAE,WAAW,aAAa;CAChC,MAAM,qBAAqB,YAAY;CACvC,MAAM,OAAOA,oBAAAA,oBAAqB,mBAAoB,CAAE,SAAU;CAElE,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACC,WAAU;EACV,KAAI;EAFL,UAAA,CAIC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,gBAAD;GAAgB,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