@wordpress/components 23.9.0 → 24.0.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 (279) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CONTRIBUTING.md +65 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/combobox-control/index.js +7 -5
  13. package/build/combobox-control/index.js.map +1 -1
  14. package/build/combobox-control/styles.js +3 -3
  15. package/build/combobox-control/styles.js.map +1 -1
  16. package/build/dimension-control/index.js +1 -1
  17. package/build/dimension-control/index.js.map +1 -1
  18. package/build/draggable/index.js +2 -7
  19. package/build/draggable/index.js.map +1 -1
  20. package/build/form-token-field/index.js +5 -3
  21. package/build/form-token-field/index.js.map +1 -1
  22. package/build/form-token-field/styles.js +3 -3
  23. package/build/form-token-field/styles.js.map +1 -1
  24. package/build/mobile/global-styles-context/index.native.js +13 -1
  25. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  26. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  27. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  28. package/build/modal/index.js +2 -1
  29. package/build/modal/index.js.map +1 -1
  30. package/build/navigable-container/container.js +39 -19
  31. package/build/navigable-container/container.js.map +1 -1
  32. package/build/navigable-container/index.js.map +1 -1
  33. package/build/navigable-container/menu.js +37 -5
  34. package/build/navigable-container/menu.js.map +1 -1
  35. package/build/navigable-container/tabbable.js +45 -4
  36. package/build/navigable-container/tabbable.js.map +1 -1
  37. package/build/navigable-container/types.js +6 -0
  38. package/build/navigable-container/types.js.map +1 -0
  39. package/build/palette-edit/index.js +34 -12
  40. package/build/palette-edit/index.js.map +1 -1
  41. package/build/sandbox/index.native.js +6 -2
  42. package/build/sandbox/index.native.js.map +1 -1
  43. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  44. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  45. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  46. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  47. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  48. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  49. package/build/slot-fill/fill.js +7 -31
  50. package/build/slot-fill/fill.js.map +1 -1
  51. package/build/slot-fill/index.js.map +1 -1
  52. package/build/slot-fill/provider.js +0 -6
  53. package/build/slot-fill/provider.js.map +1 -1
  54. package/build/slot-fill/slot.js +0 -5
  55. package/build/slot-fill/slot.js.map +1 -1
  56. package/build/tab-panel/index.js.map +1 -1
  57. package/build/theme/color-algorithms.js +1 -1
  58. package/build/theme/color-algorithms.js.map +1 -1
  59. package/build/toolbar/toolbar-button/index.js +1 -2
  60. package/build/toolbar/toolbar-button/index.js.map +1 -1
  61. package/build/toolbar/toolbar-item/index.js +4 -2
  62. package/build/toolbar/toolbar-item/index.js.map +1 -1
  63. package/build/utils/colors-values.js +3 -3
  64. package/build/utils/colors-values.js.map +1 -1
  65. package/build/utils/use-deprecated-props.js +35 -0
  66. package/build/utils/use-deprecated-props.js.map +1 -0
  67. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  68. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  69. package/build-module/autocomplete/index.js +3 -3
  70. package/build-module/autocomplete/index.js.map +1 -1
  71. package/build-module/button/index.js +2 -0
  72. package/build-module/button/index.js.map +1 -1
  73. package/build-module/card/card-media/component.js +2 -1
  74. package/build-module/card/card-media/component.js.map +1 -1
  75. package/build-module/combobox-control/index.js +6 -5
  76. package/build-module/combobox-control/index.js.map +1 -1
  77. package/build-module/combobox-control/styles.js +3 -3
  78. package/build-module/combobox-control/styles.js.map +1 -1
  79. package/build-module/dimension-control/index.js +1 -1
  80. package/build-module/dimension-control/index.js.map +1 -1
  81. package/build-module/draggable/index.js +2 -7
  82. package/build-module/draggable/index.js.map +1 -1
  83. package/build-module/form-token-field/index.js +4 -3
  84. package/build-module/form-token-field/index.js.map +1 -1
  85. package/build-module/form-token-field/styles.js +3 -3
  86. package/build-module/form-token-field/styles.js.map +1 -1
  87. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  88. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  89. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  90. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  91. package/build-module/modal/index.js +2 -1
  92. package/build-module/modal/index.js.map +1 -1
  93. package/build-module/navigable-container/container.js +43 -19
  94. package/build-module/navigable-container/container.js.map +1 -1
  95. package/build-module/navigable-container/index.js +0 -2
  96. package/build-module/navigable-container/index.js.map +1 -1
  97. package/build-module/navigable-container/menu.js +36 -4
  98. package/build-module/navigable-container/menu.js.map +1 -1
  99. package/build-module/navigable-container/tabbable.js +44 -3
  100. package/build-module/navigable-container/tabbable.js.map +1 -1
  101. package/build-module/navigable-container/types.js +2 -0
  102. package/build-module/navigable-container/types.js.map +1 -0
  103. package/build-module/palette-edit/index.js +34 -13
  104. package/build-module/palette-edit/index.js.map +1 -1
  105. package/build-module/sandbox/index.native.js +6 -2
  106. package/build-module/sandbox/index.native.js.map +1 -1
  107. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  108. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  109. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  110. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  111. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  112. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  113. package/build-module/slot-fill/fill.js +7 -31
  114. package/build-module/slot-fill/fill.js.map +1 -1
  115. package/build-module/slot-fill/index.js +1 -2
  116. package/build-module/slot-fill/index.js.map +1 -1
  117. package/build-module/slot-fill/provider.js +0 -6
  118. package/build-module/slot-fill/provider.js.map +1 -1
  119. package/build-module/slot-fill/slot.js +0 -5
  120. package/build-module/slot-fill/slot.js.map +1 -1
  121. package/build-module/tab-panel/index.js.map +1 -1
  122. package/build-module/theme/color-algorithms.js +1 -1
  123. package/build-module/theme/color-algorithms.js.map +1 -1
  124. package/build-module/toolbar/toolbar-button/index.js +1 -2
  125. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  126. package/build-module/toolbar/toolbar-item/index.js +5 -2
  127. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  128. package/build-module/utils/colors-values.js +3 -3
  129. package/build-module/utils/colors-values.js.map +1 -1
  130. package/build-module/utils/use-deprecated-props.js +25 -0
  131. package/build-module/utils/use-deprecated-props.js.map +1 -0
  132. package/build-style/style-rtl.css +58 -55
  133. package/build-style/style.css +58 -55
  134. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  135. package/build-types/autocomplete/index.d.ts.map +1 -1
  136. package/build-types/autocomplete/types.d.ts +2 -18
  137. package/build-types/autocomplete/types.d.ts.map +1 -1
  138. package/build-types/button/deprecated.d.ts +6 -0
  139. package/build-types/button/deprecated.d.ts.map +1 -1
  140. package/build-types/button/index.d.ts.map +1 -1
  141. package/build-types/button/types.d.ts +7 -0
  142. package/build-types/button/types.d.ts.map +1 -1
  143. package/build-types/card/card-media/component.d.ts +2 -1
  144. package/build-types/card/card-media/component.d.ts.map +1 -1
  145. package/build-types/card/stories/index.d.ts +21 -1
  146. package/build-types/card/stories/index.d.ts.map +1 -1
  147. package/build-types/combobox-control/index.d.ts +1 -1
  148. package/build-types/combobox-control/index.d.ts.map +1 -1
  149. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  150. package/build-types/combobox-control/styles.d.ts +1 -1
  151. package/build-types/combobox-control/types.d.ts +8 -1
  152. package/build-types/combobox-control/types.d.ts.map +1 -1
  153. package/build-types/dimension-control/index.d.ts +1 -1
  154. package/build-types/draggable/index.d.ts.map +1 -1
  155. package/build-types/form-token-field/index.d.ts.map +1 -1
  156. package/build-types/form-token-field/styles.d.ts +1 -1
  157. package/build-types/form-token-field/types.d.ts +8 -1
  158. package/build-types/form-token-field/types.d.ts.map +1 -1
  159. package/build-types/modal/index.d.ts.map +1 -1
  160. package/build-types/navigable-container/container.d.ts +20 -1
  161. package/build-types/navigable-container/container.d.ts.map +1 -1
  162. package/build-types/navigable-container/index.d.ts +5 -2
  163. package/build-types/navigable-container/index.d.ts.map +1 -1
  164. package/build-types/navigable-container/menu.d.ts +45 -11
  165. package/build-types/navigable-container/menu.d.ts.map +1 -1
  166. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  167. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  168. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  169. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  170. package/build-types/navigable-container/tabbable.d.ts +52 -9
  171. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  172. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  173. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  174. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  175. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  176. package/build-types/navigable-container/types.d.ts +61 -0
  177. package/build-types/navigable-container/types.d.ts.map +1 -0
  178. package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
  179. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  180. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  181. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  182. package/build-types/navigator/navigator-button/component.d.ts +1 -0
  183. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  184. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  185. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  186. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
  187. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  188. package/build-types/palette-edit/index.d.ts +1 -1
  189. package/build-types/palette-edit/index.d.ts.map +1 -1
  190. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  191. package/build-types/palette-edit/types.d.ts +8 -0
  192. package/build-types/palette-edit/types.d.ts.map +1 -1
  193. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  194. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  195. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  196. package/build-types/slot-fill/fill.d.ts +4 -2
  197. package/build-types/slot-fill/fill.d.ts.map +1 -1
  198. package/build-types/slot-fill/index.d.ts +1 -2
  199. package/build-types/slot-fill/index.d.ts.map +1 -1
  200. package/build-types/slot-fill/provider.d.ts +0 -2
  201. package/build-types/slot-fill/provider.d.ts.map +1 -1
  202. package/build-types/slot-fill/slot.d.ts.map +1 -1
  203. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  204. package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
  205. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  206. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  207. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  208. package/build-types/tree-grid/types.d.ts +7 -0
  209. package/build-types/tree-grid/types.d.ts.map +1 -1
  210. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  211. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  212. package/package.json +19 -19
  213. package/src/autocomplete/README.md +78 -52
  214. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  215. package/src/autocomplete/index.tsx +1 -2
  216. package/src/autocomplete/types.ts +3 -19
  217. package/src/button/index.tsx +2 -0
  218. package/src/button/style.scss +13 -6
  219. package/src/button/types.ts +7 -0
  220. package/src/card/card-media/README.md +1 -1
  221. package/src/card/card-media/component.tsx +2 -1
  222. package/src/card/stories/index.tsx +47 -26
  223. package/src/checkbox-control/style.scss +1 -4
  224. package/src/combobox-control/index.tsx +24 -18
  225. package/src/combobox-control/stories/index.tsx +0 -1
  226. package/src/combobox-control/styles.ts +4 -4
  227. package/src/combobox-control/types.ts +8 -1
  228. package/src/custom-gradient-picker/style.scss +2 -2
  229. package/src/dimension-control/index.tsx +1 -1
  230. package/src/draggable/index.tsx +1 -9
  231. package/src/form-toggle/style.scss +1 -5
  232. package/src/form-token-field/index.tsx +7 -3
  233. package/src/form-token-field/styles.ts +4 -4
  234. package/src/form-token-field/types.ts +8 -1
  235. package/src/mobile/global-styles-context/index.native.js +12 -1
  236. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  237. package/src/modal/index.tsx +6 -1
  238. package/src/modal/style.scss +1 -1
  239. package/src/navigable-container/README.md +24 -13
  240. package/src/navigable-container/{container.js → container.tsx} +57 -27
  241. package/src/navigable-container/{index.js → index.tsx} +0 -1
  242. package/src/navigable-container/menu.tsx +100 -0
  243. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  244. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  245. package/src/navigable-container/tabbable.tsx +92 -0
  246. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  247. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  248. package/src/navigable-container/types.ts +76 -0
  249. package/src/palette-edit/index.tsx +45 -7
  250. package/src/palette-edit/stories/index.tsx +4 -0
  251. package/src/palette-edit/types.ts +11 -0
  252. package/src/sandbox/index.native.js +4 -0
  253. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  254. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  255. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  256. package/src/slot-fill/fill.js +4 -26
  257. package/src/slot-fill/index.js +1 -3
  258. package/src/slot-fill/provider.js +0 -6
  259. package/src/slot-fill/slot.js +0 -5
  260. package/src/style.scss +6 -0
  261. package/src/tab-panel/index.tsx +1 -1
  262. package/src/theme/color-algorithms.ts +1 -1
  263. package/src/theme/stories/index.tsx +1 -1
  264. package/src/theme/test/color-algorithms.ts +2 -2
  265. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
  266. package/src/toolbar/stories/index.tsx +26 -24
  267. package/src/toolbar/toolbar-button/index.tsx +10 -13
  268. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  269. package/src/tree-grid/README.md +18 -0
  270. package/src/tree-grid/types.ts +7 -0
  271. package/src/utils/colors-values.js +3 -3
  272. package/src/utils/theme-variables.scss +4 -4
  273. package/src/utils/use-deprecated-props.ts +29 -0
  274. package/tsconfig.json +1 -0
  275. package/tsconfig.tsbuildinfo +1 -1
  276. package/src/CONTRIBUTING.md +0 -78
  277. package/src/README.md +0 -20
  278. package/src/navigable-container/menu.js +0 -62
  279. package/src/navigable-container/tabbable.js +0 -46
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/modal/index.tsx"],"names":["openModalCount","UnforwardedModal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","undefined","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","__experimentalHideHeader","ref","instanceId","Modal","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","focusOutsideProps","contentRef","childrenContainerRef","hasScrolledContent","setHasScrolledContent","hasScrollableContent","setHasScrollableContent","isContentScrollable","current","closestScrollContainer","ariaHelper","hideApp","document","body","classList","add","remove","showApp","window","ResizeObserver","resizeObserver","observe","disconnect","handleEscapeKeyDown","event","nativeEvent","isComposing","keyCode","code","defaultPrevented","preventDefault","onContentContainerScroll","e","scrollY","currentTarget","sc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AAGK,cADX;AAEC,IAAA,IAAI,EAAGsD,YAFR;AAGC,IAAA,KAAK,EACJpD,gBAAgB,IAAI,cAAI,OAAJ;AAJtB,IApBF,CAjBF,EA+CC;AAAK,IAAA,GAAG,EAAGkB;AAAX,KAAoCjB,QAApC,CA/CD,CAxBD,CADD,CARD,CAFM,EAuFN2B,QAAQ,CAACC,IAvFH,CAAP;AAyFA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMlB,KAAK,GAAG,yBAAY3B,gBAAZ,CAAd;;eAEQ2B,K","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef, KeyboardEvent, UIEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tforwardRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport type { ModalProps } from './types';\n\n// Used to count the number of open modals.\nlet openModalCount = 0;\n\nfunction UnforwardedModal(\n\tprops: ModalProps,\n\tforwardedRef: ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* Accessibility. */\n\t\taria = {\n\t\t\tlabelledby: undefined,\n\t\t\tdescribedby: undefined,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef< HTMLDivElement >();\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\tconst focusOnMountRef = useFocusOnMount( focusOnMount );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( onRequestClose );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst childrenContainerRef = useRef< HTMLDivElement >( null );\n\n\tconst [ hasScrolledContent, setHasScrolledContent ] = useState( false );\n\tconst [ hasScrollableContent, setHasScrollableContent ] = useState( false );\n\n\t// Determines whether the Modal content is scrollable and updates the state.\n\tconst isContentScrollable = useCallback( () => {\n\t\tif ( ! contentRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst closestScrollContainer = getScrollContainer( contentRef.current );\n\n\t\tif ( contentRef.current === closestScrollContainer ) {\n\t\t\tsetHasScrollableContent( true );\n\t\t} else {\n\t\t\tsetHasScrollableContent( false );\n\t\t}\n\t}, [ contentRef ] );\n\n\tuseEffect( () => {\n\t\topenModalCount++;\n\n\t\tif ( openModalCount === 1 ) {\n\t\t\tariaHelper.hideApp( ref.current );\n\t\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\t}\n\n\t\treturn () => {\n\t\t\topenModalCount--;\n\n\t\t\tif ( openModalCount === 0 ) {\n\t\t\t\tdocument.body.classList.remove( bodyOpenClassName );\n\t\t\t\tariaHelper.showApp();\n\t\t\t}\n\t\t};\n\t}, [ bodyOpenClassName ] );\n\n\t// Calls the isContentScrollable callback when the Modal children container resizes.\n\tuseLayoutEffect( () => {\n\t\tif ( ! window.ResizeObserver || ! childrenContainerRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeObserver = new ResizeObserver( isContentScrollable );\n\t\tresizeObserver.observe( childrenContainerRef.current );\n\n\t\tisContentScrollable();\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [ isContentScrollable, childrenContainerRef ] );\n\n\tfunction handleEscapeKeyDown( event: KeyboardEvent< HTMLDivElement > ) {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\tevent.code === 'Escape' &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onContentContainerScroll = useCallback(\n\t\t( e: UIEvent< HTMLDivElement > ) => {\n\t\t\tconst scrollY = e?.currentTarget?.scrollTop ?? -1;\n\n\t\t\tif ( ! hasScrolledContent && scrollY > 0 ) {\n\t\t\t\tsetHasScrolledContent( true );\n\t\t\t} else if ( hasScrolledContent && scrollY <= 0 ) {\n\t\t\t\tsetHasScrolledContent( false );\n\t\t\t}\n\t\t},\n\t\t[ hasScrolledContent ]\n\t);\n\n\treturn createPortal(\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-full-screen': isFullScreen,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? undefined : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t{ ...( shouldCloseOnClickOutside\n\t\t\t\t\t\t? focusOutsideProps\n\t\t\t\t\t\t: {} ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t\t'is-scrollable': hasScrollableContent,\n\t\t\t\t\t\t\t'has-scrolled-content': hasScrolledContent,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t\tonScroll={ onContentContainerScroll }\n\t\t\t\t\t\tref={ contentRef }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\thasScrollableContent\n\t\t\t\t\t\t\t\t? __( 'Scrollable section' )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabIndex={ hasScrollableContent ? 0 : undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel || __( 'Close' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<div ref={ childrenContainerRef }>{ children }</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\n/**\n * Modals give users information and choices related to a task they’re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef( UnforwardedModal );\n\nexport default Modal;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/modal/index.tsx"],"names":["openModalCount","UnforwardedModal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","undefined","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","__experimentalHideHeader","ref","instanceId","Modal","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","focusOutsideProps","contentRef","childrenContainerRef","hasScrolledContent","setHasScrolledContent","hasScrollableContent","setHasScrollableContent","isContentScrollable","current","closestScrollContainer","ariaHelper","hideApp","document","body","classList","add","remove","showApp","window","ResizeObserver","resizeObserver","observe","disconnect","handleEscapeKeyDown","event","nativeEvent","isComposing","keyCode","code","defaultPrevented","preventDefault","onContentContainerScroll","e","scrollY","currentTarget","scrollTop","close"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAeA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;;;AAnCA;AACA;AACA;;AAIA;AACA;AACA;;AAsBA;AACA;AACA;AAMA;AACA,IAAIA,cAAc,GAAG,CAArB;;AAEA,SAASC,gBAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAM;AACLC,IAAAA,iBAAiB,GAAG,YADf;AAELC,IAAAA,IAAI,GAAG,QAFF;AAGLC,IAAAA,KAAK,GAAG,IAHH;AAILC,IA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMlB,KAAK,GAAG,yBAAY3B,gBAAZ,CAAd;;eAEQ2B,K","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef, KeyboardEvent, UIEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tforwardRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport type { ModalProps } from './types';\n\n// Used to count the number of open modals.\nlet openModalCount = 0;\n\nfunction UnforwardedModal(\n\tprops: ModalProps,\n\tforwardedRef: ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* Accessibility. */\n\t\taria = {\n\t\t\tlabelledby: undefined,\n\t\t\tdescribedby: undefined,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef< HTMLDivElement >();\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\tconst focusOnMountRef = useFocusOnMount( focusOnMount );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( onRequestClose );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst childrenContainerRef = useRef< HTMLDivElement >( null );\n\n\tconst [ hasScrolledContent, setHasScrolledContent ] = useState( false );\n\tconst [ hasScrollableContent, setHasScrollableContent ] = useState( false );\n\n\t// Determines whether the Modal content is scrollable and updates the state.\n\tconst isContentScrollable = useCallback( () => {\n\t\tif ( ! contentRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst closestScrollContainer = getScrollContainer( contentRef.current );\n\n\t\tif ( contentRef.current === closestScrollContainer ) {\n\t\t\tsetHasScrollableContent( true );\n\t\t} else {\n\t\t\tsetHasScrollableContent( false );\n\t\t}\n\t}, [ contentRef ] );\n\n\tuseEffect( () => {\n\t\topenModalCount++;\n\n\t\tif ( openModalCount === 1 ) {\n\t\t\tariaHelper.hideApp( ref.current );\n\t\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\t}\n\n\t\treturn () => {\n\t\t\topenModalCount--;\n\n\t\t\tif ( openModalCount === 0 ) {\n\t\t\t\tdocument.body.classList.remove( bodyOpenClassName );\n\t\t\t\tariaHelper.showApp();\n\t\t\t}\n\t\t};\n\t}, [ bodyOpenClassName ] );\n\n\t// Calls the isContentScrollable callback when the Modal children container resizes.\n\tuseLayoutEffect( () => {\n\t\tif ( ! window.ResizeObserver || ! childrenContainerRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeObserver = new ResizeObserver( isContentScrollable );\n\t\tresizeObserver.observe( childrenContainerRef.current );\n\n\t\tisContentScrollable();\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [ isContentScrollable, childrenContainerRef ] );\n\n\tfunction handleEscapeKeyDown( event: KeyboardEvent< HTMLDivElement > ) {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\tevent.code === 'Escape' &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onContentContainerScroll = useCallback(\n\t\t( e: UIEvent< HTMLDivElement > ) => {\n\t\t\tconst scrollY = e?.currentTarget?.scrollTop ?? -1;\n\n\t\t\tif ( ! hasScrolledContent && scrollY > 0 ) {\n\t\t\t\tsetHasScrolledContent( true );\n\t\t\t} else if ( hasScrolledContent && scrollY <= 0 ) {\n\t\t\t\tsetHasScrolledContent( false );\n\t\t\t}\n\t\t},\n\t\t[ hasScrolledContent ]\n\t);\n\n\treturn createPortal(\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-full-screen': isFullScreen,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? undefined : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t{ ...( shouldCloseOnClickOutside\n\t\t\t\t\t\t? focusOutsideProps\n\t\t\t\t\t\t: {} ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t\t'is-scrollable': hasScrollableContent,\n\t\t\t\t\t\t\t'has-scrolled-content': hasScrolledContent,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t\tonScroll={ onContentContainerScroll }\n\t\t\t\t\t\tref={ contentRef }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\thasScrollableContent\n\t\t\t\t\t\t\t\t? __( 'Scrollable section' )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabIndex={ hasScrollableContent ? 0 : undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel || __( 'Close' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ childrenContainerRef }\n\t\t\t\t\t\t\tclassName=\"components-modal__children-container\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\n/**\n * Modals give users information and choices related to a task they’re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef( UnforwardedModal );\n\nexport default Modal;\n"]}
@@ -13,7 +13,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _dom = require("@wordpress/dom");
15
15
 
16
- // @ts-nocheck
16
+ /**
17
+ * External dependencies
18
+ */
17
19
 
18
20
  /**
19
21
  * WordPress dependencies
@@ -35,8 +37,8 @@ function cycleValue(value, total, offset) {
35
37
  }
36
38
 
37
39
  class NavigableContainer extends _element.Component {
38
- constructor() {
39
- super(...arguments);
40
+ constructor(args) {
41
+ super(args);
40
42
  this.onKeyDown = this.onKeyDown.bind(this);
41
43
  this.bindContainer = this.bindContainer.bind(this);
42
44
  this.getFocusableContext = this.getFocusableContext.bind(this);
@@ -44,18 +46,24 @@ class NavigableContainer extends _element.Component {
44
46
  }
45
47
 
46
48
  componentDidMount() {
47
- // We use DOM event listeners instead of React event listeners
49
+ if (!this.container) {
50
+ return;
51
+ } // We use DOM event listeners instead of React event listeners
48
52
  // because we want to catch events from the underlying DOM tree
49
53
  // The React Tree can be different from the DOM tree when using
50
54
  // portals. Block Toolbars for instance are rendered in a separate
51
55
  // React Trees.
56
+
57
+
52
58
  this.container.addEventListener('keydown', this.onKeyDown);
53
- this.container.addEventListener('focus', this.onFocus);
54
59
  }
55
60
 
56
61
  componentWillUnmount() {
62
+ if (!this.container) {
63
+ return;
64
+ }
65
+
57
66
  this.container.removeEventListener('keydown', this.onKeyDown);
58
- this.container.removeEventListener('focus', this.onFocus);
59
67
  }
60
68
 
61
69
  bindContainer(ref) {
@@ -72,6 +80,10 @@ class NavigableContainer extends _element.Component {
72
80
  }
73
81
 
74
82
  getFocusableContext(target) {
83
+ if (!this.container) {
84
+ return null;
85
+ }
86
+
75
87
  const {
76
88
  onlyBrowserTabstops
77
89
  } = this.props;
@@ -91,14 +103,12 @@ class NavigableContainer extends _element.Component {
91
103
  }
92
104
 
93
105
  getFocusableIndex(focusables, target) {
94
- const directIndex = focusables.indexOf(target);
95
-
96
- if (directIndex !== -1) {
97
- return directIndex;
98
- }
106
+ return focusables.indexOf(target);
99
107
  }
100
108
 
101
109
  onKeyDown(event) {
110
+ var _event$target2, _event$target2$ownerD;
111
+
102
112
  if (this.props.onKeyDown) {
103
113
  this.props.onKeyDown(event);
104
114
  }
@@ -115,19 +125,18 @@ class NavigableContainer extends _element.Component {
115
125
  const offset = eventToOffset(event); // eventToOffset returns undefined if the event is not handled by the component.
116
126
 
117
127
  if (offset !== undefined && stopNavigationEvents) {
128
+ var _event$target;
129
+
118
130
  // Prevents arrow key handlers bound to the document directly interfering.
119
131
  event.stopImmediatePropagation(); // When navigating a collection of items, prevent scroll containers
120
132
  // from scrolling. The preventDefault also prevents Voiceover from
121
133
  // 'handling' the event, as voiceover will try to use arrow keys
122
134
  // for highlighting text.
123
135
 
124
- const targetRole = event.target.getAttribute('role');
125
- const targetHasMenuItemRole = MENU_ITEM_ROLES.includes(targetRole); // `preventDefault()` on tab to avoid having the browser move the focus
126
- // after this component has already moved it.
127
-
128
- const isTab = event.code === 'Tab';
136
+ const targetRole = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role');
137
+ const targetHasMenuItemRole = !!targetRole && MENU_ITEM_ROLES.includes(targetRole);
129
138
 
130
- if (targetHasMenuItemRole || isTab) {
139
+ if (targetHasMenuItemRole) {
131
140
  event.preventDefault();
132
141
  }
133
142
  }
@@ -136,7 +145,13 @@ class NavigableContainer extends _element.Component {
136
145
  return;
137
146
  }
138
147
 
139
- const context = getFocusableContext(event.target.ownerDocument.activeElement);
148
+ const activeElement = (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : (_event$target2$ownerD = _event$target2.ownerDocument) === null || _event$target2$ownerD === void 0 ? void 0 : _event$target2$ownerD.activeElement;
149
+
150
+ if (!activeElement) {
151
+ return;
152
+ }
153
+
154
+ const context = getFocusableContext(activeElement);
140
155
 
141
156
  if (!context) {
142
157
  return;
@@ -150,7 +165,12 @@ class NavigableContainer extends _element.Component {
150
165
 
151
166
  if (nextIndex >= 0 && nextIndex < focusables.length) {
152
167
  focusables[nextIndex].focus();
153
- onNavigate(nextIndex, focusables[nextIndex]);
168
+ onNavigate(nextIndex, focusables[nextIndex]); // `preventDefault()` on tab to avoid having the browser move the focus
169
+ // after this component has already moved it.
170
+
171
+ if (event.code === 'Tab') {
172
+ event.preventDefault();
173
+ }
154
174
  }
155
175
  }
156
176
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/navigable-container/container.js"],"names":["noop","MENU_ITEM_ROLES","cycleValue","value","total","offset","nextValue","NavigableContainer","Component","constructor","arguments","onKeyDown","bind","bindContainer","getFocusableContext","getFocusableIndex","componentDidMount","container","addEventListener","onFocus","componentWillUnmount","removeEventListener","ref","forwardedRef","props","current","target","onlyBrowserTabstops","finder","focus","tabbable","focusable","focusables","find","index","directIndex","indexOf","event","cycle","eventToOffset","onNavigate","stopNavigationEvents","undefined","stopImmediatePropagation","targetRole","getAttribute","targetHasMenuItemRole","includes","isTab","code","preventDefault","context","ownerDocument","activeElement","nextIndex","length","render","children","restProps","forwardedNavigableContainer","displayName"],"mappings":";;;;;;;;;AAIA;;;;AACA;;AALA;;AACA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,eAAe,GAAG,CAAE,UAAF,EAAc,eAAd,EAA+B,kBAA/B,CAAxB;;AAEA,SAASC,UAAT,CAAqBC,KAArB,EAA4BC,KAA5B,EAAmCC,MAAnC,EAA4C;AAC3C,QAAMC,SAAS,GAAGH,KAAK,GAAGE,MAA1B;;AACA,MAAKC,SAAS,GAAG,CAAjB,EAAqB;AACpB,WAAOF,KAAK,GAAGE,SAAf;AACA,GAFD,MAEO,IAAKA,SAAS,IAAIF,KAAlB,EAA0B;AAChC,WAAOE,SAA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,KAAkB;AACrD,SAAO,4BAAC,kBAAD,6BAAyBE,KAAzB;AAAiC,IAAA,YAAY,EAAGF;AAAhD,KAAP;AACA,CAFD;;AAGAqC,2BAA2B,CAACC,WAA5B,GAA0C,oBAA1C;;eAEe,yBAAYD,2BAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\nconst noop = () => {};\nconst MENU_ITEM_ROLES = [ 'menuitem', 'menuitemradio', 'menuitemcheckbox' ];\n\nfunction cycleValue( value, total, offset ) {\n\tconst nextValue = value + offset;\n\tif ( nextValue < 0 ) {\n\t\treturn total + nextValue;\n\t} else if ( nextValue >= total ) {\n\t\treturn nextValue - total;\n\t}\n\n\treturn nextValue;\n}\n\nclass NavigableContainer extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.bindContainer = this.bindContainer.bind( this );\n\n\t\tthis.getFocusableContext = this.getFocusableContext.bind( this );\n\t\tthis.getFocusableIndex = this.getFocusableIndex.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\t// We use DOM event listeners instead of React event listeners\n\t\t// because we want to catch events from the underlying DOM tree\n\t\t// The React Tree can be different from the DOM tree when using\n\t\t// portals. Block Toolbars for instance are rendered in a separate\n\t\t// React Trees.\n\t\tthis.container.addEventListener( 'keydown', this.onKeyDown );\n\t\tthis.container.addEventListener( 'focus', this.onFocus );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.container.removeEventListener( 'keydown', this.onKeyDown );\n\t\tthis.container.removeEventListener( 'focus', this.onFocus );\n\t}\n\n\tbindContainer( ref ) {\n\t\tconst { forwardedRef } = this.props;\n\t\tthis.container = ref;\n\n\t\tif ( typeof forwardedRef === 'function' ) {\n\t\t\tforwardedRef( ref );\n\t\t} else if ( forwardedRef && 'current' in forwardedRef ) {\n\t\t\tforwardedRef.current = ref;\n\t\t}\n\t}\n\n\tgetFocusableContext( target ) {\n\t\tconst { onlyBrowserTabstops } = this.props;\n\t\tconst finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;\n\t\tconst focusables = finder.find( this.container );\n\n\t\tconst index = this.getFocusableIndex( focusables, target );\n\t\tif ( index > -1 && target ) {\n\t\t\treturn { index, target, focusables };\n\t\t}\n\t\treturn null;\n\t}\n\n\tgetFocusableIndex( focusables, target ) {\n\t\tconst directIndex = focusables.indexOf( target );\n\t\tif ( directIndex !== -1 ) {\n\t\t\treturn directIndex;\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tif ( this.props.onKeyDown ) {\n\t\t\tthis.props.onKeyDown( event );\n\t\t}\n\n\t\tconst { getFocusableContext } = this;\n\t\tconst {\n\t\t\tcycle = true,\n\t\t\teventToOffset,\n\t\t\tonNavigate = noop,\n\t\t\tstopNavigationEvents,\n\t\t} = this.props;\n\n\t\tconst offset = eventToOffset( event );\n\n\t\t// eventToOffset returns undefined if the event is not handled by the component.\n\t\tif ( offset !== undefined && stopNavigationEvents ) {\n\t\t\t// Prevents arrow key handlers bound to the document directly interfering.\n\t\t\tevent.stopImmediatePropagation();\n\n\t\t\t// When navigating a collection of items, prevent scroll containers\n\t\t\t// from scrolling. The preventDefault also prevents Voiceover from\n\t\t\t// 'handling' the event, as voiceover will try to use arrow keys\n\t\t\t// for highlighting text.\n\t\t\tconst targetRole = event.target.getAttribute( 'role' );\n\t\t\tconst targetHasMenuItemRole =\n\t\t\t\tMENU_ITEM_ROLES.includes( targetRole );\n\n\t\t\t// `preventDefault()` on tab to avoid having the browser move the focus\n\t\t\t// after this component has already moved it.\n\t\t\tconst isTab = event.code === 'Tab';\n\n\t\t\tif ( targetHasMenuItemRole || isTab ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tif ( ! offset ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst context = getFocusableContext(\n\t\t\tevent.target.ownerDocument.activeElement\n\t\t);\n\t\tif ( ! context ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { index, focusables } = context;\n\t\tconst nextIndex = cycle\n\t\t\t? cycleValue( index, focusables.length, offset )\n\t\t\t: index + offset;\n\t\tif ( nextIndex >= 0 && nextIndex < focusables.length ) {\n\t\t\tfocusables[ nextIndex ].focus();\n\t\t\tonNavigate( nextIndex, focusables[ nextIndex ] );\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tstopNavigationEvents,\n\t\t\teventToOffset,\n\t\t\tonNavigate,\n\t\t\tonKeyDown,\n\t\t\tcycle,\n\t\t\tonlyBrowserTabstops,\n\t\t\tforwardedRef,\n\t\t\t...restProps\n\t\t} = this.props;\n\t\treturn (\n\t\t\t<div ref={ this.bindContainer } { ...restProps }>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nconst forwardedNavigableContainer = ( props, ref ) => {\n\treturn <NavigableContainer { ...props } forwardedRef={ ref } />;\n};\nforwardedNavigableContainer.displayName = 'NavigableContainer';\n\nexport default forwardRef( forwardedNavigableContainer );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/navigable-container/container.tsx"],"names":["noop","MENU_ITEM_ROLES","cycleValue","value","total","offset","nextValue","NavigableContainer","Component","constructor","args","onKeyDown","bind","bindContainer","getFocusableContext","getFocusableIndex","componentDidMount","container","addEventListener","componentWillUnmount","removeEventListener","ref","forwardedRef","props","current","target","onlyBrowserTabstops","finder","focus","tabbable","focusable","focusables","find","index","indexOf","event","cycle","eventToOffset","onNavigate","stopNavigationEvents","undefined","stopImmediatePropagation","targetRole","getAttribute","targetHasMenuItemRole","includes","preventDefault","activeElement","ownerDocument","context","nextIndex","length","code","render","children","restProps","forwardedNavigableContainer","displayName"],"mappings":";;;;;;;;;AAQA;;;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AASA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,eAAe,GAAG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C3BjB,QAAAA,KAAK,CAACW,cAAN;AACA;AACD;AACD;;AAEDO,EAAAA,MAAM,GAAG;AACR,UAAM;AACLC,MAAAA,QADK;AAELf,MAAAA,oBAFK;AAGLF,MAAAA,aAHK;AAILC,MAAAA,UAJK;AAKL3B,MAAAA,SALK;AAMLyB,MAAAA,KANK;AAOLV,MAAAA,mBAPK;AAQLJ,MAAAA,YARK;AASL,SAAGiC;AATE,QAUF,KAAKhC,KAVT;AAWA,WACC;AAAK,MAAA,GAAG,EAAG,KAAKV;AAAhB,OAAqC0C,SAArC,GACGD,QADH,CADD;AAKA;;AApJoE;;AAuJtE,MAAME,2BAA2B,GAAG,CACnCjC,KADmC,EAEnCF,GAFmC,KAG/B;AACJ,SAAO,4BAAC,kBAAD,6BAAyBE,KAAzB;AAAiC,IAAA,YAAY,EAAGF;AAAhD,KAAP;AACA,CALD;;AAMAmC,2BAA2B,CAACC,WAA5B,GAA0C,oBAA1C;;eAEe,yBAAYD,2BAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport type { NavigableContainerProps } from './types';\n\nconst noop = () => {};\nconst MENU_ITEM_ROLES = [ 'menuitem', 'menuitemradio', 'menuitemcheckbox' ];\n\nfunction cycleValue( value: number, total: number, offset: number ) {\n\tconst nextValue = value + offset;\n\tif ( nextValue < 0 ) {\n\t\treturn total + nextValue;\n\t} else if ( nextValue >= total ) {\n\t\treturn nextValue - total;\n\t}\n\n\treturn nextValue;\n}\n\nclass NavigableContainer extends Component< NavigableContainerProps > {\n\tcontainer?: HTMLDivElement;\n\n\tconstructor( args: NavigableContainerProps ) {\n\t\tsuper( args );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.bindContainer = this.bindContainer.bind( this );\n\n\t\tthis.getFocusableContext = this.getFocusableContext.bind( this );\n\t\tthis.getFocusableIndex = this.getFocusableIndex.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( ! this.container ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We use DOM event listeners instead of React event listeners\n\t\t// because we want to catch events from the underlying DOM tree\n\t\t// The React Tree can be different from the DOM tree when using\n\t\t// portals. Block Toolbars for instance are rendered in a separate\n\t\t// React Trees.\n\t\tthis.container.addEventListener( 'keydown', this.onKeyDown );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( ! this.container ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.container.removeEventListener( 'keydown', this.onKeyDown );\n\t}\n\n\tbindContainer( ref: HTMLDivElement ) {\n\t\tconst { forwardedRef } = this.props;\n\t\tthis.container = ref;\n\n\t\tif ( typeof forwardedRef === 'function' ) {\n\t\t\tforwardedRef( ref );\n\t\t} else if ( forwardedRef && 'current' in forwardedRef ) {\n\t\t\tforwardedRef.current = ref;\n\t\t}\n\t}\n\n\tgetFocusableContext( target: Element ) {\n\t\tif ( ! this.container ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { onlyBrowserTabstops } = this.props;\n\t\tconst finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;\n\t\tconst focusables = finder.find( this.container ) as HTMLElement[];\n\n\t\tconst index = this.getFocusableIndex( focusables, target );\n\t\tif ( index > -1 && target ) {\n\t\t\treturn { index, target, focusables };\n\t\t}\n\t\treturn null;\n\t}\n\n\tgetFocusableIndex( focusables: Element[], target: Element ) {\n\t\treturn focusables.indexOf( target );\n\t}\n\n\tonKeyDown( event: KeyboardEvent ) {\n\t\tif ( this.props.onKeyDown ) {\n\t\t\tthis.props.onKeyDown( event );\n\t\t}\n\n\t\tconst { getFocusableContext } = this;\n\t\tconst {\n\t\t\tcycle = true,\n\t\t\teventToOffset,\n\t\t\tonNavigate = noop,\n\t\t\tstopNavigationEvents,\n\t\t} = this.props;\n\n\t\tconst offset = eventToOffset( event );\n\n\t\t// eventToOffset returns undefined if the event is not handled by the component.\n\t\tif ( offset !== undefined && stopNavigationEvents ) {\n\t\t\t// Prevents arrow key handlers bound to the document directly interfering.\n\t\t\tevent.stopImmediatePropagation();\n\n\t\t\t// When navigating a collection of items, prevent scroll containers\n\t\t\t// from scrolling. The preventDefault also prevents Voiceover from\n\t\t\t// 'handling' the event, as voiceover will try to use arrow keys\n\t\t\t// for highlighting text.\n\t\t\tconst targetRole = (\n\t\t\t\tevent.target as HTMLDivElement | null\n\t\t\t )?.getAttribute( 'role' );\n\t\t\tconst targetHasMenuItemRole =\n\t\t\t\t!! targetRole && MENU_ITEM_ROLES.includes( targetRole );\n\n\t\t\tif ( targetHasMenuItemRole ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tif ( ! offset ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst activeElement = ( event.target as HTMLElement | null )\n\t\t\t?.ownerDocument?.activeElement;\n\t\tif ( ! activeElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst context = getFocusableContext( activeElement );\n\t\tif ( ! context ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { index, focusables } = context;\n\t\tconst nextIndex = cycle\n\t\t\t? cycleValue( index, focusables.length, offset )\n\t\t\t: index + offset;\n\n\t\tif ( nextIndex >= 0 && nextIndex < focusables.length ) {\n\t\t\tfocusables[ nextIndex ].focus();\n\t\t\tonNavigate( nextIndex, focusables[ nextIndex ] );\n\n\t\t\t// `preventDefault()` on tab to avoid having the browser move the focus\n\t\t\t// after this component has already moved it.\n\t\t\tif ( event.code === 'Tab' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tstopNavigationEvents,\n\t\t\teventToOffset,\n\t\t\tonNavigate,\n\t\t\tonKeyDown,\n\t\t\tcycle,\n\t\t\tonlyBrowserTabstops,\n\t\t\tforwardedRef,\n\t\t\t...restProps\n\t\t} = this.props;\n\t\treturn (\n\t\t\t<div ref={ this.bindContainer } { ...restProps }>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nconst forwardedNavigableContainer = (\n\tprops: NavigableContainerProps,\n\tref: ForwardedRef< HTMLDivElement >\n) => {\n\treturn <NavigableContainer { ...props } forwardedRef={ ref } />;\n};\nforwardedNavigableContainer.displayName = 'NavigableContainer';\n\nexport default forwardRef( forwardedNavigableContainer );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/navigable-container/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA;;AACA","sourcesContent":["// @ts-nocheck\n/**\n * Internal Dependencies\n */\nexport { default as NavigableMenu } from './menu';\nexport { default as TabbableContainer } from './tabbable';\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/navigable-container/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AACA","sourcesContent":["/**\n * Internal Dependencies\n */\nexport { default as NavigableMenu } from './menu';\nexport { default as TabbableContainer } from './tabbable';\n"]}
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.NavigableMenu = NavigableMenu;
8
+ exports.NavigableMenu = void 0;
9
+ exports.UnforwardedNavigableMenu = UnforwardedNavigableMenu;
9
10
  exports.default = void 0;
10
11
 
11
12
  var _element = require("@wordpress/element");
@@ -14,7 +15,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
14
15
 
15
16
  var _container = _interopRequireDefault(require("./container"));
16
17
 
17
- // @ts-nocheck
18
+ /**
19
+ * External dependencies
20
+ */
18
21
 
19
22
  /**
20
23
  * WordPress dependencies
@@ -23,7 +26,7 @@ var _container = _interopRequireDefault(require("./container"));
23
26
  /**
24
27
  * Internal dependencies
25
28
  */
26
- function NavigableMenu(_ref, ref) {
29
+ function UnforwardedNavigableMenu(_ref, ref) {
27
30
  let {
28
31
  role = 'menu',
29
32
  orientation = 'vertical',
@@ -57,6 +60,8 @@ function NavigableMenu(_ref, ref) {
57
60
  // in an offset.
58
61
  return 0;
59
62
  }
63
+
64
+ return undefined;
60
65
  };
61
66
 
62
67
  return (0, _element.createElement)(_container.default, (0, _extends2.default)({
@@ -64,12 +69,39 @@ function NavigableMenu(_ref, ref) {
64
69
  stopNavigationEvents: true,
65
70
  onlyBrowserTabstops: false,
66
71
  role: role,
67
- "aria-orientation": role === 'presentation' ? null : orientation,
72
+ "aria-orientation": role !== 'presentation' && (orientation === 'vertical' || orientation === 'horizontal') ? orientation : undefined,
68
73
  eventToOffset: eventToOffset
69
74
  }, rest));
70
75
  }
76
+ /**
77
+ * A container for a navigable menu.
78
+ *
79
+ * ```jsx
80
+ * import {
81
+ * NavigableMenu,
82
+ * Button,
83
+ * } from '@wordpress/components';
84
+ *
85
+ * function onNavigate( index, target ) {
86
+ * console.log( `Navigates to ${ index }`, target );
87
+ * }
88
+ *
89
+ * const MyNavigableContainer = () => (
90
+ * <div>
91
+ * <span>Navigable Menu:</span>
92
+ * <NavigableMenu onNavigate={ onNavigate } orientation="horizontal">
93
+ * <Button variant="secondary">Item 1</Button>
94
+ * <Button variant="secondary">Item 2</Button>
95
+ * <Button variant="secondary">Item 3</Button>
96
+ * </NavigableMenu>
97
+ * </div>
98
+ * );
99
+ * ```
100
+ */
71
101
 
72
- var _default = (0, _element.forwardRef)(NavigableMenu);
73
102
 
103
+ const NavigableMenu = (0, _element.forwardRef)(UnforwardedNavigableMenu);
104
+ exports.NavigableMenu = NavigableMenu;
105
+ var _default = NavigableMenu;
74
106
  exports.default = _default;
75
107
  //# sourceMappingURL=menu.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/navigable-container/menu.js"],"names":["NavigableMenu","ref","role","orientation","rest","eventToOffset","evt","code","next","previous","includes"],"mappings":";;;;;;;;;;AAKA;;;;AAKA;;AAVA;;AAEA;A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A;;eAEc,yBAAYJ,aAAZ,C","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\n\nexport function NavigableMenu(\n\t{ role = 'menu', orientation = 'vertical', ...rest },\n\tref\n) {\n\tconst eventToOffset = ( evt ) => {\n\t\tconst { code } = evt;\n\n\t\tlet next = [ 'ArrowDown' ];\n\t\tlet previous = [ 'ArrowUp' ];\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tnext = [ 'ArrowRight' ];\n\t\t\tprevious = [ 'ArrowLeft' ];\n\t\t}\n\n\t\tif ( orientation === 'both' ) {\n\t\t\tnext = [ 'ArrowRight', 'ArrowDown' ];\n\t\t\tprevious = [ 'ArrowLeft', 'ArrowUp' ];\n\t\t}\n\n\t\tif ( next.includes( code ) ) {\n\t\t\treturn 1;\n\t\t} else if ( previous.includes( code ) ) {\n\t\t\treturn -1;\n\t\t} else if (\n\t\t\t[ 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ].includes(\n\t\t\t\tcode\n\t\t\t)\n\t\t) {\n\t\t\t// Key press should be handled, e.g. have event propagation and\n\t\t\t// default behavior handled by NavigableContainer but not result\n\t\t\t// in an offset.\n\t\t\treturn 0;\n\t\t}\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops={ false }\n\t\t\trole={ role }\n\t\t\taria-orientation={ role === 'presentation' ? null : orientation }\n\t\t\teventToOffset={ eventToOffset }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( NavigableMenu );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/navigable-container/menu.tsx"],"names":["UnforwardedNavigableMenu","ref","role","orientation","rest","eventToOffset","evt","code","next","previous","includes","undefined","NavigableMenu"],"mappings":";;;;;;;;;;;AAQA;;;;AAKA;;AAbA;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K,YADhD,IAEGA,WAFH,GAGGQ,SATL;AAWC,IAAA,aAAa,EAAGN;AAXjB,KAYMD,IAZN,EADD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMQ,aAAa,GAAG,yBAAYZ,wBAAZ,CAAtB;;eAEQY,a","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\nimport type { NavigableMenuProps } from './types';\n\nexport function UnforwardedNavigableMenu(\n\t{ role = 'menu', orientation = 'vertical', ...rest }: NavigableMenuProps,\n\tref: ForwardedRef< any >\n) {\n\tconst eventToOffset = ( evt: KeyboardEvent ) => {\n\t\tconst { code } = evt;\n\n\t\tlet next = [ 'ArrowDown' ];\n\t\tlet previous = [ 'ArrowUp' ];\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tnext = [ 'ArrowRight' ];\n\t\t\tprevious = [ 'ArrowLeft' ];\n\t\t}\n\n\t\tif ( orientation === 'both' ) {\n\t\t\tnext = [ 'ArrowRight', 'ArrowDown' ];\n\t\t\tprevious = [ 'ArrowLeft', 'ArrowUp' ];\n\t\t}\n\n\t\tif ( next.includes( code ) ) {\n\t\t\treturn 1;\n\t\t} else if ( previous.includes( code ) ) {\n\t\t\treturn -1;\n\t\t} else if (\n\t\t\t[ 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ].includes(\n\t\t\t\tcode\n\t\t\t)\n\t\t) {\n\t\t\t// Key press should be handled, e.g. have event propagation and\n\t\t\t// default behavior handled by NavigableContainer but not result\n\t\t\t// in an offset.\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn undefined;\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops={ false }\n\t\t\trole={ role }\n\t\t\taria-orientation={\n\t\t\t\trole !== 'presentation' &&\n\t\t\t\t( orientation === 'vertical' || orientation === 'horizontal' )\n\t\t\t\t\t? orientation\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\teventToOffset={ eventToOffset }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n}\n\n/**\n * A container for a navigable menu.\n *\n * ```jsx\n * import {\n * NavigableMenu,\n * Button,\n * } from '@wordpress/components';\n *\n * function onNavigate( index, target ) {\n * console.log( `Navigates to ${ index }`, target );\n * }\n *\n * const MyNavigableContainer = () => (\n * <div>\n * <span>Navigable Menu:</span>\n * <NavigableMenu onNavigate={ onNavigate } orientation=\"horizontal\">\n * <Button variant=\"secondary\">Item 1</Button>\n * <Button variant=\"secondary\">Item 2</Button>\n * <Button variant=\"secondary\">Item 3</Button>\n * </NavigableMenu>\n * </div>\n * );\n * ```\n */\nexport const NavigableMenu = forwardRef( UnforwardedNavigableMenu );\n\nexport default NavigableMenu;\n"]}
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.TabbableContainer = TabbableContainer;
8
+ exports.TabbableContainer = void 0;
9
+ exports.UnforwardedTabbableContainer = UnforwardedTabbableContainer;
9
10
  exports.default = void 0;
10
11
 
11
12
  var _element = require("@wordpress/element");
@@ -14,7 +15,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
14
15
 
15
16
  var _container = _interopRequireDefault(require("./container"));
16
17
 
17
- // @ts-nocheck
18
+ /**
19
+ * External dependencies
20
+ */
18
21
 
19
22
  /**
20
23
  * WordPress dependencies
@@ -23,7 +26,7 @@ var _container = _interopRequireDefault(require("./container"));
23
26
  /**
24
27
  * Internal dependencies
25
28
  */
26
- function TabbableContainer(_ref, ref) {
29
+ function UnforwardedTabbableContainer(_ref, ref) {
27
30
  let {
28
31
  eventToOffset,
29
32
  ...props
@@ -53,6 +56,8 @@ function TabbableContainer(_ref, ref) {
53
56
  if (eventToOffset) {
54
57
  return eventToOffset(evt);
55
58
  }
59
+
60
+ return undefined;
56
61
  };
57
62
 
58
63
  return (0, _element.createElement)(_container.default, (0, _extends2.default)({
@@ -62,8 +67,44 @@ function TabbableContainer(_ref, ref) {
62
67
  eventToOffset: innerEventToOffset
63
68
  }, props));
64
69
  }
70
+ /**
71
+ * A container for tabbable elements.
72
+ *
73
+ * ```jsx
74
+ * import {
75
+ * TabbableContainer,
76
+ * Button,
77
+ * } from '@wordpress/components';
78
+ *
79
+ * function onNavigate( index, target ) {
80
+ * console.log( `Navigates to ${ index }`, target );
81
+ * }
82
+ *
83
+ * const MyTabbableContainer = () => (
84
+ * <div>
85
+ * <span>Tabbable Container:</span>
86
+ * <TabbableContainer onNavigate={ onNavigate }>
87
+ * <Button variant="secondary" tabIndex="0">
88
+ * Section 1
89
+ * </Button>
90
+ * <Button variant="secondary" tabIndex="0">
91
+ * Section 2
92
+ * </Button>
93
+ * <Button variant="secondary" tabIndex="0">
94
+ * Section 3
95
+ * </Button>
96
+ * <Button variant="secondary" tabIndex="0">
97
+ * Section 4
98
+ * </Button>
99
+ * </TabbableContainer>
100
+ * </div>
101
+ * );
102
+ * ```
103
+ */
65
104
 
66
- var _default = (0, _element.forwardRef)(TabbableContainer);
67
105
 
106
+ const TabbableContainer = (0, _element.forwardRef)(UnforwardedTabbableContainer);
107
+ exports.TabbableContainer = TabbableContainer;
108
+ var _default = TabbableContainer;
68
109
  exports.default = _default;
69
110
  //# sourceMappingURL=tabbable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/navigable-container/tabbable.js"],"names":["TabbableContainer","ref","eventToOffset","props","innerEventToOffset","evt","code","shiftKey"],"mappings":";;;;;;;;;;AAIA;;;;AAKA;;AATA;;AACA;AACA;AACA;;AAGA;AACA;AACA;AAGO,SAASA,iBAAT,OAAyDC,GAAzD,EAA+D;AAAA,MAAnC;AAAEC,IAAAA,aAAF;AAAiB,OAAGC;AAApB,GAAmC;;AACrE,QAAMC,kBAAkB,GAAKC,GAAF,IAAW;AACrC,UAAM;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,QAAqBF,GAA3B;;AACA,QAAK,UAAUC,IAAf,EAAsB;AACrB,aAAOC,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAAvB;AACA,KAJoC,CAMrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAKL,aAAL,EAAqB;AACpB,aAAOA,aAAa,CAAEG,GAAF,CAApB;AACA;AACD,GApBD;;AAsBA,SACC,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGJ,GADP;AAEC,IAAA,oBAAoB,MAFrB;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,aAAa,EAAGG;AAJjB,KAKMD,KALN,EADD;AASA;;eAEc,yBAAYH,iBAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\n\nexport function TabbableContainer( { eventToOffset, ...props }, ref ) {\n\tconst innerEventToOffset = ( evt ) => {\n\t\tconst { code, shiftKey } = evt;\n\t\tif ( 'Tab' === code ) {\n\t\t\treturn shiftKey ? -1 : 1;\n\t\t}\n\n\t\t// Allow custom handling of keys besides Tab.\n\t\t//\n\t\t// By default, TabbableContainer will move focus forward on Tab and\n\t\t// backward on Shift+Tab. The handler below will be used for all other\n\t\t// events. The semantics for `eventToOffset`'s return\n\t\t// values are the following:\n\t\t//\n\t\t// - +1: move focus forward\n\t\t// - -1: move focus backward\n\t\t// - 0: don't move focus, but acknowledge event and thus stop it\n\t\t// - undefined: do nothing, let the event propagate.\n\t\tif ( eventToOffset ) {\n\t\t\treturn eventToOffset( evt );\n\t\t}\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops\n\t\t\teventToOffset={ innerEventToOffset }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( TabbableContainer );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/navigable-container/tabbable.tsx"],"names":["UnforwardedTabbableContainer","ref","eventToOffset","props","innerEventToOffset","evt","code","shiftKey","undefined","TabbableContainer"],"mappings":";;;;;;;;;;;AAQA;;;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAIO,SAASA,4BAAT,OAENC,GAFM,EAGL;AAAA,MAFD;AAAEC,IAAAA,aAAF;AAAiB,OAAGC;AAApB,GAEC;;AACD,QAAMC,kBAAkB,GAAKC,GAAF,IAA0B;AACpD,UAAM;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,QAAqBF,GAA3B;;AACA,QAAK,UAAUC,IAAf,EAAsB;AACrB,aAAOC,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAAvB;AACA,KAJmD,CAMpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAKL,aAAL,EAAqB;AACpB,aAAOA,aAAa,CAAEG,GAAF,CAApB;AACA;;AAED,WAAOG,SAAP;AACA,GAtBD;;AAwBA,SACC,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGP,GADP;AAEC,IAAA,oBAAoB,MAFrB;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,aAAa,EAAGG;AAJjB,KAKMD,KALN,EADD;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMM,iBAAiB,GAAG,yBAAYT,4BAAZ,CAA1B;;eAEQS,iB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\nimport type { TabbableContainerProps } from './types';\n\nexport function UnforwardedTabbableContainer(\n\t{ eventToOffset, ...props }: TabbableContainerProps,\n\tref: ForwardedRef< any >\n) {\n\tconst innerEventToOffset = ( evt: KeyboardEvent ) => {\n\t\tconst { code, shiftKey } = evt;\n\t\tif ( 'Tab' === code ) {\n\t\t\treturn shiftKey ? -1 : 1;\n\t\t}\n\n\t\t// Allow custom handling of keys besides Tab.\n\t\t//\n\t\t// By default, TabbableContainer will move focus forward on Tab and\n\t\t// backward on Shift+Tab. The handler below will be used for all other\n\t\t// events. The semantics for `eventToOffset`'s return\n\t\t// values are the following:\n\t\t//\n\t\t// - +1: move focus forward\n\t\t// - -1: move focus backward\n\t\t// - 0: don't move focus, but acknowledge event and thus stop it\n\t\t// - undefined: do nothing, let the event propagate.\n\t\tif ( eventToOffset ) {\n\t\t\treturn eventToOffset( evt );\n\t\t}\n\n\t\treturn undefined;\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops\n\t\t\teventToOffset={ innerEventToOffset }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\n/**\n * A container for tabbable elements.\n *\n * ```jsx\n * import {\n * TabbableContainer,\n * Button,\n * } from '@wordpress/components';\n *\n * function onNavigate( index, target ) {\n * console.log( `Navigates to ${ index }`, target );\n * }\n *\n * const MyTabbableContainer = () => (\n * <div>\n * <span>Tabbable Container:</span>\n * <TabbableContainer onNavigate={ onNavigate }>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 1\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 2\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 3\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 4\n * </Button>\n * </TabbableContainer>\n * </div>\n * );\n * ```\n */\nexport const TabbableContainer = forwardRef( UnforwardedTabbableContainer );\n\nexport default TabbableContainer;\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -13,6 +13,8 @@ var _element = require("@wordpress/element");
13
13
 
14
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
15
 
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
16
18
  var _changeCase = require("change-case");
17
19
 
18
20
  var _i18n = require("@wordpress/i18n");
@@ -115,14 +117,19 @@ function ColorPickerPopover(_ref2) {
115
117
  isGradient,
116
118
  element,
117
119
  onChange,
120
+ popoverProps: receivedPopoverProps,
118
121
  onClose = () => {}
119
122
  } = _ref2;
120
- return (0, _element.createElement)(_popover.default, {
121
- placement: "left-start",
123
+ const popoverProps = (0, _element.useMemo)(() => ({
124
+ shift: true,
122
125
  offset: 20,
123
- className: "components-palette-edit__popover",
126
+ placement: 'left-start',
127
+ ...receivedPopoverProps,
128
+ className: (0, _classnames.default)('components-palette-edit__popover', receivedPopoverProps === null || receivedPopoverProps === void 0 ? void 0 : receivedPopoverProps.className)
129
+ }), [receivedPopoverProps]);
130
+ return (0, _element.createElement)(_popover.default, (0, _extends2.default)({}, popoverProps, {
124
131
  onClose: onClose
125
- }, !isGradient && (0, _element.createElement)(_colorPicker.ColorPicker, {
132
+ }), !isGradient && (0, _element.createElement)(_colorPicker.ColorPicker, {
126
133
  color: element.color,
127
134
  enableAlpha: true,
128
135
  onChange: newColor => {
@@ -153,15 +160,24 @@ function Option(_ref3) {
153
160
  onStartEditing,
154
161
  onRemove,
155
162
  onStopEditing,
163
+ popoverProps: receivedPopoverProps,
156
164
  slugPrefix,
157
165
  isGradient
158
166
  } = _ref3;
159
167
  const focusOutsideProps = (0, _compose.__experimentalUseFocusOutside)(onStopEditing);
160
- const value = isGradient ? element.gradient : element.color;
168
+ const value = isGradient ? element.gradient : element.color; // Use internal state instead of a ref to make sure that the component
169
+ // re-renders when the popover's anchor updates.
170
+
171
+ const [popoverAnchor, setPopoverAnchor] = (0, _element.useState)(null);
172
+ const popoverProps = (0, _element.useMemo)(() => ({ ...receivedPopoverProps,
173
+ // Use the custom palette color item as the popover anchor.
174
+ anchor: popoverAnchor
175
+ }), [popoverAnchor, receivedPopoverProps]);
161
176
  return (0, _element.createElement)(_styles.PaletteItem, (0, _extends2.default)({
162
177
  className: isEditing ? 'is-selected' : undefined,
163
178
  as: "div",
164
- onClick: onStartEditing
179
+ onClick: onStartEditing,
180
+ ref: setPopoverAnchor
165
181
  }, isEditing ? { ...focusOutsideProps
166
182
  } : {
167
183
  style: {
@@ -189,7 +205,8 @@ function Option(_ref3) {
189
205
  }))), isEditing && (0, _element.createElement)(ColorPickerPopover, {
190
206
  isGradient: isGradient,
191
207
  onChange: onChange,
192
- element: element
208
+ element: element,
209
+ popoverProps: popoverProps
193
210
  }));
194
211
  }
195
212
 
@@ -211,7 +228,8 @@ function PaletteEditListView(_ref5) {
211
228
  setEditingElement,
212
229
  canOnlyChangeValues,
213
230
  slugPrefix,
214
- isGradient
231
+ isGradient,
232
+ popoverProps
215
233
  } = _ref5;
216
234
  // When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
217
235
  const elementsReference = (0, _element.useRef)();
@@ -271,7 +289,8 @@ function PaletteEditListView(_ref5) {
271
289
  setEditingElement(null);
272
290
  }
273
291
  },
274
- slugPrefix: slugPrefix
292
+ slugPrefix: slugPrefix,
293
+ popoverProps: popoverProps
275
294
  }))));
276
295
  }
277
296
 
@@ -307,7 +326,8 @@ function PaletteEdit(_ref6) {
307
326
  emptyMessage,
308
327
  canOnlyChangeValues,
309
328
  canReset,
310
- slugPrefix = ''
329
+ slugPrefix = '',
330
+ popoverProps
311
331
  } = _ref6;
312
332
  const isGradient = !!gradients;
313
333
  const elements = isGradient ? gradients : colors;
@@ -404,7 +424,8 @@ function PaletteEdit(_ref6) {
404
424
  editingElement: editingElement,
405
425
  setEditingElement: setEditingElement,
406
426
  slugPrefix: slugPrefix,
407
- isGradient: isGradient
427
+ isGradient: isGradient,
428
+ popoverProps: popoverProps
408
429
  }), !isEditing && editingElement !== null && (0, _element.createElement)(ColorPickerPopover, {
409
430
  isGradient: isGradient,
410
431
  onClose: () => setEditingElement(null),
@@ -418,7 +439,8 @@ function PaletteEdit(_ref6) {
418
439
  return currentElement;
419
440
  }));
420
441
  },
421
- element: elements[editingElement !== null && editingElement !== void 0 ? editingElement : -1]
442
+ element: elements[editingElement !== null && editingElement !== void 0 ? editingElement : -1],
443
+ popoverProps: popoverProps
422
444
  }), !isEditing && (isGradient ? (0, _element.createElement)(_gradientPicker.default, {
423
445
  __nextHasNoMargin: true,
424
446
  gradients: gradients,